GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4CondArray.cxx
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
14#include "TGo4CondArray.h"
15
16#include "TROOT.h"
17#include "TObjArray.h"
18
19#include "TGo4Log.h"
20#include "TGo4WinCond.h"
21#include "TGo4PolyCond.h"
23
24// ----------------------------------------------------------
26{
27 if(fiType != kGO4CONDWINDOW) return nullptr;
28 return (TGo4WinCond*) At(i);
29}
30// ----------------------------------------------------------
32{
33 if(fiType != kGO4CONDPOLYGON) return nullptr;
34 return (TGo4PolyCond*) At(i);
35}
36// ----------------------------------------------------------
38{
39 return (TGo4Condition *) condarr->At(i);
40}
41// ----------------------------------------------------------
43{
44 // boundary check by TObjArray, returns [0] in case
45 return (TGo4Condition *) condarr->At(i);
46}
47// ----------------------------------------------------------
50 condarr(nullptr),
51 fiNumCond(0),
52 fiType(0),
54{
55}
56// ----------------------------------------------------------
57TGo4CondArray::TGo4CondArray(const char *name, Int_t elements, Int_t contype) :
58 TGo4Condition(name,"TGo4CondArray"),
59 condarr(nullptr),
60 fiNumCond(0),
61 fiType(0),
63{
64 fiNumCond = elements;
65 if(contype == kGO4CONDWINDOW) {
66 condarr = new TObjArray(elements);
67 fiType = contype;
68 for(Int_t i = 0; i < elements; i++)
69 condarr->AddLast(new TGo4WinCond(TString::Format("%s%06d",name,i).Data()));
70 } else
71 if(contype == kGO4CONDPOLYGON) {
72 condarr = new TObjArray(elements);
73 fiType = contype;
74 for(Int_t i = 0; i < elements; i++)
75 condarr->AddLast(new TGo4PolyCond(TString::Format("%s%06d",name,i).Data()));
76
78 } else {
79 fiNumCond = 0;
80 fiType = 0;
81 }
82}
83// ----------------------------------------------------------
84TGo4CondArray::TGo4CondArray(const char *name, Int_t elements, const char *type)
85: TGo4Condition(name,type),fiSelectedCond(0)
86{
87 fiNumCond = elements;
88 if(strcmp(type,"TGo4WinCond") == 0) {
89 condarr = new TObjArray(elements);
91 for(Int_t i = 0; i < elements; i++)
92 condarr->AddLast(new TGo4WinCond(TString::Format("%s%06d",name,i).Data()));
93 } else
94 if(strcmp(type,"TGo4PolyCond") == 0) {
95 condarr = new TObjArray(elements);
97 for(Int_t i = 0; i < elements; i++)
98 condarr->AddLast(new TGo4PolyCond(TString::Format("%s%06d",name,i).Data()));
99
101 } else {
102 fiNumCond = 0;
103 fiType = 0;
104 }
105}
106// ----------------------------------------------------------
108{
109 if(fxPainter) delete fxPainter; // delete painter before this subclass is gone
110 // when called in TGo4Condition dtor only, painter
111 // cannot cast correctly on TGo4CondArray!
112 fxPainter = nullptr;
113 if (condarr) {
114 condarr->Delete();
115 delete condarr;
116 condarr = nullptr;
117 }
118
119}
120
121// ----------------------------------------------------------
122
123Bool_t TGo4CondArray::Test(Double_t x, Double_t y)
124{
125 Bool_t rev = kTRUE;
126 if (IsMultiEdit()) {
127 Int_t ii = condarr->GetLast() + 1;
128 for (Int_t i = 0; i < ii; i++) {
129 IncCounts();
130 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
131 Bool_t result = cond->Test(x, y);
132 if (result)
134 rev &= result;
135 }
136 } else {
137 TGo4Condition *conny = At(GetCurrentIndex());
138 if (conny)
139 rev = conny->Test(x, y);
140 }
141 return rev;
142}
143
144// ----------------------------------------------------------
145Bool_t TGo4CondArray::Test(Double_t x)
146{
147 Bool_t rev = kTRUE;
148 if (IsMultiEdit()) {
149 Int_t ii = condarr->GetLast() + 1;
150 for (Int_t i = 0; i < ii; i++) {
151 IncCounts();
152 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
153 Bool_t result = cond->Test(x);
154 if (result)
156 rev &= result;
157 }
158 } else {
159 TGo4Condition *conny = At(GetCurrentIndex());
160 if (conny)
161 rev = conny->Test(x);
162 }
163 return rev;
164}
165
166// ----------------------------------------------------------
168{
169 // all entries are used!
170 Int_t ii = condarr->GetLast()+1;
171 TGo4Condition *cond = (TGo4Condition *) condarr->At(0);
172 std::cout << GetName() << " has " << ii << " " << cond->ClassName() << " conditions" << std::endl;
173 for(Int_t i = 0; i < ii; i++) {
174 cond = dynamic_cast<TGo4Condition *> (condarr->UncheckedAt(i));
175 if (cond) cond->PrintCondition(points);
176 }
177}
178
179// ----------------------------------------------------------
181{
182 Int_t ii = condarr->GetLast()+1;
183 std::cout <<"-"<<ClassName()<<" "<<GetName()<<" Printout:" << std::endl;
184 //TROOT::IncreaseDirLevel();
185 for(Int_t i = 0; i < ii; i++)
186 {
187 TGo4Condition *cond = dynamic_cast<TGo4Condition *> (condarr->UncheckedAt(i));
188 TROOT::IndentLevel();
189 if (cond) cond->PrintBar();
190 }
191 //TROOT::DecreaseDirLevel();
192}
193
194// ----------------------------------------------------------
196{
197 return GetNumber();
198}
199
200// ----------------------------------------------------------
202{
203 return (condarr->GetLast()+1);
204}
205
206// ----------------------------------------------------------
207const char *TGo4CondArray::GetType() const
208{
209 TGo4Condition *cond = (TGo4Condition *) condarr->At(0);
210 return cond->ClassName();
211}
212
213// -----------------------------------------------
214void TGo4CondArray::GetType(Int_t &type) const
215{
216 type = fiType;
217}
218// -----------------------------------------------
220{
222 if (IsMultiEdit()) {
223 Int_t ii = condarr->GetLast() + 1;
224 for (Int_t i = 0; i < ii; i++) {
225 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
226 cond->Enable();
227 }
228 } else {
229 TGo4Condition *conny = At(GetCurrentIndex());
230 if (conny)
231 conny->Enable();
232 }
233}
234// -----------------------------------------------
235void TGo4CondArray::Disable(Bool_t result)
236{
238 if (IsMultiEdit()) {
239 Int_t ii = condarr->GetLast() + 1;
240 for (Int_t i = 0; i < ii; i++) {
241 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
242 cond->Disable(result);
243 }
244 } else {
245 TGo4Condition *conny = At(GetCurrentIndex());
246 if (conny)
247 conny->Disable(result);
248 }
249}
250// -----------------------------------------------
252{
254 if (IsMultiEdit()) {
255 Int_t ii = condarr->GetLast() + 1;
256 for (Int_t i = 0; i < ii; i++) {
257 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
258 cond->Invert(on);
259 }
260 } else {
261 TGo4Condition *conny = At(GetCurrentIndex());
262 if (conny)
263 conny->Invert(on);
264 }
265}
266
268{
270 if (IsMultiEdit()) {
271 Int_t ii = condarr->GetLast() + 1;
272 for (Int_t i = 0; i < ii; i++) {
273 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
274 cond->MarkReset(on);
275 }
276 } else {
277 TGo4Condition *conny = At(GetCurrentIndex());
278 if (conny)
279 conny->MarkReset(on);
280 }
281}
282
283void TGo4CondArray::GetFlags(Bool_t *enabled, Bool_t *lastresult, Bool_t *markreset, Bool_t *result, Bool_t *truevalue,
284 Bool_t *falsevalue)
285{
286 if (IsMultiEdit()) {
287 Int_t ii = condarr->GetLast() + 1;
288 for (Int_t i = 0; i < ii; i++) {
289 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
290 cond->GetFlags(enabled, lastresult, markreset, result, truevalue, falsevalue);
291 }
292 } else {
293 TGo4Condition *conny = At(GetCurrentIndex());
294 if (conny)
295 conny->GetFlags(enabled, lastresult, markreset, result, truevalue, falsevalue);
296 }
297}
298
299// -----------------------------------------------
301{
303 if (IsMultiEdit()) {
304 Int_t ii = condarr->GetLast() + 1;
305 for (Int_t i = 0; i < ii; i++) {
306 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
307 cond->ResetCounts();
308 }
309 } else {
310 TGo4Condition *conny = At(GetCurrentIndex());
311 if (conny)
312 conny->ResetCounts();
313 }
314}
315
317{
318 Int_t rev = 0;
319 if (IsMultiEdit()) {
320 rev = TGo4Condition::Counts();
321 } else {
322 TGo4Condition *conny = At(GetCurrentIndex());
323 if (conny)
324 rev = conny->Counts();
325 }
326 return rev;
327}
328// ---------------------------------------------------------
330{
331 Int_t rev = 0;
332 if (IsMultiEdit()) {
333 rev = TGo4Condition::Counts();
334 } else {
335 TGo4Condition *conny = At(GetCurrentIndex());
336 if (conny)
337 rev = conny->Counts();
338 }
339 return rev;
340}
341
343{
344 Double_t rev = 0;
345 if (IsMultiEdit()) {
346 rev = -1;
347 } else {
348 TGo4Condition *conny = At(GetCurrentIndex());
349 if (conny)
350 rev = conny->GetXLow();
351 }
352 return rev;
353}
354
355Double_t TGo4CondArray::GetXUp() const
356{
357 Double_t rev = 0;
358 if (IsMultiEdit()) {
359 rev = -1;
360 } else {
361 TGo4Condition *conny = At(GetCurrentIndex());
362 if (conny)
363 rev = conny->GetXUp();
364 }
365 return rev;
366}
367
369{
370 Double_t rev = 0;
371 if (IsMultiEdit()) {
372 rev = -1;
373 } else {
374 TGo4Condition *conny = At(GetCurrentIndex());
375 if (conny)
376 rev = conny->GetYLow();
377 }
378 return rev;
379}
380
381Double_t TGo4CondArray::GetYUp() const
382{
383 Double_t rev = 0;
384 if (IsMultiEdit()) {
385 rev = -1;
386 } else {
387 TGo4Condition *conny = At(GetCurrentIndex());
388 if (conny)
389 rev = conny->GetYUp();
390 }
391 return rev;
392}
393
394// -----------------------------------------------
395void TGo4CondArray::SetValues(Double_t low1, Double_t up1)
396{
397 if (fiType == kGO4CONDWINDOW) {
398 if (IsMultiEdit()) {
399 Int_t ii = condarr->GetLast() + 1;
400 for (Int_t i = 0; i < ii; i++) {
401 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
402 cond->SetValues(low1, up1);
403 }
404 } else {
405 TGo4Condition *conny = At(GetCurrentIndex());
406 if (conny)
407 conny->SetValues(low1, up1);
408 }
409 }
410}
411// -----------------------------------------------
412void TGo4CondArray::SetValues(Double_t low1, Double_t up1, Double_t low2, Double_t up2)
413{
414 if (fiType == kGO4CONDWINDOW) {
415 if (IsMultiEdit()) {
416 Int_t ii = condarr->GetLast() + 1;
417 for (Int_t i = 0; i < ii; i++) {
418 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
419 cond->SetValues(low1, up1, low2, up2);
420 }
421 } else {
422 TGo4Condition *conny = At(GetCurrentIndex());
423 if (conny)
424 conny->SetValues(low1, up1, low2, up2);
425 }
426 }
427}
428
429// -----------------------------------------------
430void TGo4CondArray::SetValues(TCutG *newcut)
431{
432 if (fiType == kGO4CONDPOLYGON) {
433 if (IsMultiEdit()) {
434 Int_t ii = condarr->GetLast() + 1;
435 for (Int_t i = 0; i < ii; i++) {
436 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
437 cond->SetValues(newcut);
438 }
439 } else {
440 TGo4Condition *conny = At(GetCurrentIndex());
441 if (conny)
442 conny->SetValues(newcut);
443 }
444 }
445}
446
447// -----------------------------------------------
448Bool_t TGo4CondArray::UpdateFrom(TGo4Condition *cond, Bool_t counts)
449{
450 TGo4Condition::UpdateFrom(cond, counts); // make sure to copy general flags
451 TGo4Condition *scond; // source member
452 TGo4Condition *dcond; // destination member
453 TGo4CondArray *carr; // source array
454 if (cond->InheritsFrom(TGo4CondArray::Class())) {
455 Int_t dii = condarr->GetLast() + 1; // this is destination
456 Int_t sii = ((TGo4CondArray *)cond)->GetNumber(); // elements in source array
457 if (dii == sii) {
458 Bool_t result = kTRUE;
459 carr = (TGo4CondArray *)cond;
460 // std::cout << GetName() << ": Update " << dii << " from " << cond->GetName() << std::endl;
461 for (Int_t i = 0; i < dii; i++) {
462 dcond = (TGo4Condition *)condarr->UncheckedAt(i); // destination is this
463 scond = (TGo4Condition *)(*carr)[i]; // source is from cond
464 result = result && (dcond->UpdateFrom(scond, counts));
465 }
466 return result;
467 } else {
468 return kFALSE;
469 }
470 } else {
471 return kFALSE;
472 }
473}
474
475// -----------------------------------------------
477{
478 if (IsMultiEdit()) {
480 Int_t ii = condarr->GetLast() + 1;
481 for (Int_t i = 0; i < ii; i++) {
482 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
483 cond->SetVisible(on);
484 }
485 } else {
486 TGo4Condition *conny = At(GetCurrentIndex());
487 if (conny)
488 conny->SetVisible(on);
489 }
490}
491
492// -----------------------------------------------
494{
495 Bool_t rev = kFALSE;
496 if (IsMultiEdit()) {
498 } else {
499 TGo4Condition *conny = At(GetCurrentIndex());
500 if (conny)
501 rev = conny->IsVisible();
502 }
503 return rev;
504}
505
506// -----------------------------------------------
508{
509 if (IsMultiEdit()) {
511 Int_t ii = condarr->GetLast() + 1;
512 for (Int_t i = 0; i < ii; i++) {
513 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
514 cond->SetLabelDraw(on);
515 }
516 } else {
517 TGo4Condition *conny = At(GetCurrentIndex());
518 if (conny)
519 conny->SetLabelDraw(on);
520 }
521}
522
523// -----------------------------------------------
525{
526 Bool_t rev = kFALSE;
527 if (IsMultiEdit()) {
529 } else {
530 TGo4Condition *conny = At(GetCurrentIndex());
531 if (conny)
532 rev = conny->IsLabelDraw();
533 }
534 return rev;
535}
536
537// -----------------------------------------------
539{
540 if (IsMultiEdit()) {
542 Int_t ii = condarr->GetLast() + 1;
543 for (Int_t i = 0; i < ii; i++) {
544 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
545 cond->SetLimitsDraw(on);
546 }
547 } else {
548 TGo4Condition *conny = At(GetCurrentIndex());
549 if (conny)
550 conny->SetLimitsDraw(on);
551 }
552}
553
554// -----------------------------------------------
556{
557 Bool_t rev = kFALSE;
558 if (IsMultiEdit()) {
560 } else {
561 TGo4Condition *conny = At(GetCurrentIndex());
562 if (conny)
563 rev = conny->IsLimitsDraw();
564 }
565 return rev;
566}
567
568// -----------------------------------------------
570{
571 if (IsMultiEdit()) {
573 Int_t ii = condarr->GetLast() + 1;
574 for (Int_t i = 0; i < ii; i++) {
575 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
576 cond->SetIntDraw(on);
577 }
578 } else {
579 TGo4Condition *conny = At(GetCurrentIndex());
580 if (conny)
581 conny->SetIntDraw(on);
582 }
583}
584
585// -----------------------------------------------
587{
588 Bool_t rev = kFALSE;
589 if (IsMultiEdit()) {
591 } else {
592 TGo4Condition *conny = At(GetCurrentIndex());
593 if (conny)
594 rev = conny->IsIntDraw();
595 }
596 return rev;
597}
598
599// -----------------------------------------------
601{
602 if (IsMultiEdit()) {
604 Int_t ii = condarr->GetLast() + 1;
605 for (Int_t i = 0; i < ii; i++) {
606 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
607 cond->SetXMeanDraw(on);
608 }
609 } else {
610 TGo4Condition *conny = At(GetCurrentIndex());
611 if (conny)
612 conny->SetXMeanDraw(on);
613 }
614}
615
616// -----------------------------------------------
618{
619 Bool_t rev = kFALSE;
620 if (IsMultiEdit()) {
622 } else {
623 TGo4Condition *conny = At(GetCurrentIndex());
624 if (conny)
625 rev = conny->IsXMeanDraw();
626 }
627 return rev;
628}
629
630// -----------------------------------------------
632{
633 if (IsMultiEdit()) {
635 Int_t ii = condarr->GetLast() + 1;
636 for (Int_t i = 0; i < ii; i++) {
637 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
638 cond->SetXRMSDraw(on);
639 }
640 } else {
641 TGo4Condition *conny = At(GetCurrentIndex());
642 if (conny)
643 conny->SetXRMSDraw(on);
644 }
645}
646
647// -----------------------------------------------
649{
650 Bool_t rev = kFALSE;
651 if (IsMultiEdit()) {
653 } else {
654 TGo4Condition *conny = At(GetCurrentIndex());
655 if (conny)
656 rev = conny->IsXRMSDraw();
657 }
658 return rev;
659}
660
661// -----------------------------------------------
663{
664 if (IsMultiEdit()) {
666 Int_t ii = condarr->GetLast() + 1;
667 for (Int_t i = 0; i < ii; i++) {
668 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
669 cond->SetYMeanDraw(on);
670 }
671 } else {
672 TGo4Condition *conny = At(GetCurrentIndex());
673 if (conny)
674 conny->SetYMeanDraw(on);
675 }
676}
677
678// -----------------------------------------------
680{
681 Bool_t rev = kFALSE;
682 if (IsMultiEdit()) {
684 } else {
685 TGo4Condition *conny = At(GetCurrentIndex());
686 if (conny)
687 rev = conny->IsYMeanDraw();
688 }
689 return rev;
690}
691
692// -----------------------------------------------
694{
695 if (IsMultiEdit()) {
697 Int_t ii = condarr->GetLast() + 1;
698 for (Int_t i = 0; i < ii; i++) {
699 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
700 cond->SetYRMSDraw(on);
701 }
702 } else {
703 TGo4Condition *conny = At(GetCurrentIndex());
704 if (conny)
705 conny->SetYRMSDraw(on);
706 }
707}
708
709// -----------------------------------------------
711{
712 Bool_t rev = kFALSE;
713 if (IsMultiEdit()) {
715 } else {
716 TGo4Condition *conny = At(GetCurrentIndex());
717 if (conny)
718 rev = conny->IsYRMSDraw();
719 }
720 return rev;
721}
722
723// -----------------------------------------------
725{
726 if (IsMultiEdit()) {
728 Int_t ii = condarr->GetLast() + 1;
729 for (Int_t i = 0; i < ii; i++) {
730 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
731 cond->SetXMaxDraw(on);
732 }
733 } else {
734 TGo4Condition *conny = At(GetCurrentIndex());
735 if (conny)
736 conny->SetXMaxDraw(on);
737 }
738}
739
740// -----------------------------------------------
742{
743 Bool_t rev = kFALSE;
744 if (IsMultiEdit()) {
746 } else {
747 TGo4Condition *conny = At(GetCurrentIndex());
748 if (conny)
749 rev = conny->IsXMaxDraw();
750 }
751 return rev;
752}
753
754// -----------------------------------------------
756{
757 if (IsMultiEdit()) {
759 Int_t ii = condarr->GetLast() + 1;
760 for (Int_t i = 0; i < ii; i++) {
761 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
762 cond->SetYMaxDraw(on);
763 }
764 } else {
765 TGo4Condition *conny = At(GetCurrentIndex());
766 if (conny)
767 conny->SetYMaxDraw(on);
768 }
769}
770
771// -----------------------------------------------
773{
774 Bool_t rev = kFALSE;
775 if (IsMultiEdit()) {
777 } else {
778 TGo4Condition *conny = At(GetCurrentIndex());
779 if (conny)
780 rev = conny->IsYMaxDraw();
781 }
782 return rev;
783}
784
785// -----------------------------------------------
787{
788 if (IsMultiEdit()) {
790 Int_t ii = condarr->GetLast() + 1;
791 for (Int_t i = 0; i < ii; i++) {
792 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
793 cond->SetCMaxDraw(on);
794 }
795 } else {
796 TGo4Condition *conny = At(GetCurrentIndex());
797 if (conny)
798 conny->SetCMaxDraw(on);
799 }
800}
801
802// -----------------------------------------------
804{
805 Bool_t rev = kFALSE;
806 if (IsMultiEdit()) {
808 } else {
809 TGo4Condition *conny = At(GetCurrentIndex());
810 if (conny)
811 rev = conny->IsCMaxDraw();
812 }
813 return rev;
814}
815
816// -----------------------------------------------
817Double_t TGo4CondArray::GetIntegral(TH1 *histo, Option_t *opt)
818{
819 Double_t rev = 0;
820 if (IsMultiEdit()) {
821 // return sum of all integrals
822 Int_t ii = condarr->GetLast() + 1;
823 for (Int_t i = 0; i < ii; i++) {
824 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
825 rev += cond->GetIntegral(histo, opt);
826 }
827 } else {
828 TGo4Condition *conny = At(GetCurrentIndex());
829 if (conny)
830 rev = conny->GetIntegral(histo, opt);
831 }
832 return rev;
833}
834
835// -----------------------------------------------
836Double_t TGo4CondArray::GetMean(TH1 *histo, Int_t axis)
837{
838 Double_t rev = 0;
839 if (IsMultiEdit()) {
840 // give back mean value of means. does this make sense?
841 Int_t ii = condarr->GetLast() + 1;
842 Double_t sum = 0;
843 for (Int_t i = 0; i < ii; i++) {
844 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
845 sum += cond->GetMean(histo, axis);
846 rev = sum / ii;
847 }
848 } else {
849 TGo4Condition *conny = At(GetCurrentIndex());
850 if (conny)
851 rev = conny->GetMean(histo, axis);
852 }
853 return rev;
854}
855
856// -----------------------------------------------
857Double_t TGo4CondArray::GetRMS(TH1 *histo, Int_t axis)
858{
859 Double_t rev = 0;
860 if (IsMultiEdit()) {
861 rev = -2; // what is the result RMS of all sub-conditions?
862 } else {
863 TGo4Condition *conny = At(GetCurrentIndex());
864 if (conny)
865 rev = conny->GetRMS(histo, axis);
866 }
867 return rev;
868}
869
870// -----------------------------------------------
871Double_t TGo4CondArray::GetSkewness(TH1 *histo, Int_t axis)
872{
873 Double_t rev = 0;
874 if (IsMultiEdit()) {
875 rev = -2; // what is the result Skewness of all subconditions?
876 } else {
877 TGo4Condition *conny = At(GetCurrentIndex());
878 if (conny)
879 rev = conny->GetSkewness(histo, axis);
880 }
881 return rev;
882}
883
884// -----------------------------------------------
885Double_t TGo4CondArray::GetCurtosis(TH1 *histo, Int_t axis)
886{
887 Double_t rev = 0;
888 if (IsMultiEdit()) {
889 rev = -2; // what is the result Curtosis of all subconditions?
890 } else {
891 TGo4Condition *conny = At(GetCurrentIndex());
892 if (conny)
893 rev = conny->GetCurtosis(histo, axis);
894 }
895 return rev;
896}
897
898// -----------------------------------------------
899Double_t TGo4CondArray::GetXMax(TH1 *histo)
900{
901 Double_t rev = 0;
902 if (IsMultiEdit()) {
903 rev = -2; // would need the xmax of the maximum content of all
904 } else {
905 TGo4Condition *conny = At(GetCurrentIndex());
906 if (conny)
907 rev = conny->GetXMax(histo);
908 }
909 return rev;
910}
911
912// -----------------------------------------------
913Double_t TGo4CondArray::GetYMax(TH1 *histo)
914{
915 Double_t rev = 0;
916 if (IsMultiEdit()) {
917 rev = -2;
918 } else {
919 TGo4Condition *conny = At(GetCurrentIndex());
920 if (conny)
921 rev = conny->GetYMax(histo);
922 }
923 return rev;
924}
925
926// -----------------------------------------------
927Double_t TGo4CondArray::GetCMax(TH1 *histo)
928{
929 Double_t rev = 0;
930 if (IsMultiEdit()) {
931 // return highest channel content of all subconditions
932 Int_t ii = condarr->GetLast() + 1;
933 for (Int_t i = 0; i < ii; i++) {
934 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
935 Double_t lmax = cond->GetCMax(histo);
936 if (lmax > rev)
937 rev = lmax;
938 }
939 } else {
940 TGo4Condition *conny = At(GetCurrentIndex());
941 if (conny)
942 rev = conny->GetCMax(histo);
943 }
944 return rev;
945}
946
947// -----------------------------------------------
949{
950 if (IsMultiEdit())
951 return this;
952 else
953 return At(GetCurrentIndex());
954}
955
956// -----------------------------------------------
958{
959 for (Int_t i = 0; i <= condarr->GetLast(); i++) {
960 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
961 cond->SetChanged(on);
962 }
963}
964
965// -----------------------------------------------
967{
968 Int_t cnt = 0;
969 for (Int_t i = 0; i <= condarr->GetLast(); i++) {
970 TGo4Condition *cond = (TGo4Condition *)condarr->UncheckedAt(i);
971 cnt += cond->IsChanged();
972 }
973 return cnt;
974}
975
976// -----------------------------------------------
978{
979 Bool_t rev = kFALSE;
980 if (IsMultiEdit()) {
981 if (fiType == kGO4CONDPOLYGON)
982 rev = kTRUE;
983 else
984 rev = kFALSE;
985 } else {
986 TGo4Condition *conny = At(GetCurrentIndex());
987 if (conny)
988 rev = conny->IsPolygonType();
989 }
990 return rev;
991}
992
993// -----------------------------------------------
995{
996 fiSelectedCond = ix;
997}
998
999// -----------------------------------------------
1001{
1002 return fiSelectedCond;
1003}
1004
1005// -----------------------------------------------
1006void TGo4CondArray::Draw(Option_t *opt)
1007{
1009 Int_t selid = -1;
1010 if (opt)
1011 if (strstr(opt, "sel=") == opt)
1012 selid = atoi(opt + 4);
1013 for (Int_t i = 0; i < GetNumber(); ++i) {
1014 TGo4Condition *con = At(i);
1015 bool selected = (selid < 0) || (selid == i);
1016 if (con)
1017 con->SetPainted(IsPainted() && selected);
1018 }
1019}
1020
1021// -----------------------------------------------
1023{
1024 if (!painter)
1025 return;
1026 if (painter->InheritsFrom(TGo4CondArrayPainter::Class())) {
1027 if (fxPainter)
1028 delete fxPainter;
1029 fxPainter = painter;
1030 } else {
1031 TGo4Log::Warn("Could not set painter of class %s for TGo4CondArray %s", painter->ClassName(), GetName());
1032 }
1033}
1034
1035// -----------------------------------------------
1037{
1038 auto painter = new TGo4CondArrayPainter(GetName());
1039 painter->SetCondition(this);
1040 return painter;
1041}
1042
1043// -----------------------------------------------
1045{
1046 Int_t size = sizeof(*this);
1047 if (GetName())
1048 size += strlen(GetName());
1049 if (GetTitle())
1050 size += strlen(GetTitle());
1051
1052 if (condarr)
1053 size += sizeof(*condarr) + condarr->GetEntriesFast() * sizeof(TObject *);
1054
1055 for (Int_t n = 0; n < GetNumberOfConditions(); n++) {
1056 TGo4Condition *cond = At(n);
1057 if (cond)
1058 size += cond->GetMemorySize();
1059 }
1060
1061 return size;
1062}
1063
1064// -----------------------------------------------
1065void TGo4CondArray::SavePrimitive(std::ostream &out, Option_t *opt)
1066{
1067 static int cnt = 0;
1068 TString extraargs = TString::Format(", %d, \"%s\"", GetNumber(), GetType());
1069 TString varname = MakeScript(out, TString::Format("condarr%d", cnt++).Data(), opt, extraargs.Data());
1070
1071 // exclude name: options
1072 TString options = opt;
1073 const char *subname = strstr(opt, "name:");
1074 if (subname)
1075 options.Resize(subname - opt);
1076
1077 for (int n = 0; n < GetNumber(); n++) {
1078 TString subopt = options + TString::Format(" nocreate name:%s->At(%d)", varname.Data(), n);
1079 At(n)->SavePrimitive(out, subopt.Data());
1080 out << std::endl;
1081 }
1082}
@ kGO4CONDWINDOW
@ kGO4CONDPOLYGON
Bool_t IsXMaxDraw() const override
Int_t GetNumberOfConditions() const override
for condition aggregates: return total number of conditions, i.e.size of condition array
Double_t GetIntegral(TH1 *histo, Option_t *opt="") override
Calculate value for histogram inside condition limits.
Bool_t IsYRMSDraw() const override
Double_t GetYLow() const override
Double_t GetMean(TH1 *histo, Int_t axis=1) override
Calculate value for histogram inside condition limits.
TGo4ConditionPainter * CreatePainter() override
Factory method to generate the subclass implementation for painter.
Int_t GetNumber() const
Returns number of conditions in array.
void SetXMaxDraw(Bool_t on) override
Int_t GetMemorySize() const override
void SavePrimitive(std::ostream &fs, Option_t *opt="") override
Standard way to store parameter in form of macro.
void SetXMeanDraw(Bool_t on) override
Double_t GetCurtosis(TH1 *histo, Int_t axis=1) override
Calculate value for histogram inside condition limits.
void SetYMeanDraw(Bool_t on) override
Double_t GetRMS(TH1 *histo, Int_t axis=1) override
Calculate value for histogram inside condition limits.
void GetFlags(Bool_t *enabled, Bool_t *lastresult, Bool_t *markreset, Bool_t *result, Bool_t *truevalue, Bool_t *falsevalue) override
Sets values of internal boolean flags to external variables.
Double_t GetYUp() const override
Int_t fiNumCond
Number of conditions in array.
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts) override
Copy values from cond to this.
void Enable() override
Calls Enable for all conditions (multi edit mode) or for currently selected (single edit mode)
Bool_t IsYMeanDraw() const override
TGo4WinCond * Win(Int_t i) const
Returns window condition object i from object array.
void PrintCondition(Bool_t points) override
Noop.
Bool_t IsIntDraw() const override
void Invert(Bool_t on) override
Calls Invert for all conditions (multi edit mode) or for currently selected (single edit mode)
Bool_t IsXRMSDraw() const override
void SetPainter(TGo4ConditionPainter *painter) override
Replace default painter of this condition by external one.
virtual void SetValues()
Noop.
Bool_t IsPolygonType() const override
Double_t GetXMax(TH1 *histo) override
Calculate value for histogram inside condition limits.
TObjArray * condarr
The object array of conditions.
const TGo4Condition * GetActiveCondition() const override
Access to the currently selected condition.
Bool_t IsXMeanDraw() const override
void SetLabelDraw(Bool_t on) override
TGo4Condition * operator[](Int_t i) const
Returns condition object i from object array.
void SetVisible(Bool_t on) override
we overwrite single condition visibility setter
TGo4PolyCond * Poly(Int_t i) const
Returns polygon condition object i from object array.
Int_t fiType
Condition type ID (kGO4CONDWINDOW or kGO4CONDPOLYGON)
Double_t GetYMax(TH1 *histo) override
Calculate value for histogram inside condition limits.
void SetCMaxDraw(Bool_t on) override
Int_t GetCurrentIndex() const override
get index for array type subclasses
Bool_t IsVisible() const override
we overwrite single condition visibility getter
Int_t TrueCounts() override
Return number of true results of the Test method call.
virtual Bool_t Test()
Test if condition is true.
Double_t GetXUp() const override
void MarkReset(Bool_t on) override
defines if condition counters shall be reset in UpdateFrom method
void Draw(Option_t *opt="") override
Reimplement Draw to set painted flag for all array conditions.
Bool_t IsCMaxDraw() const override
Int_t IsChanged() const override
we overwrite single condition changed property
Int_t Counts() override
Return number of calls of the Test method.
void SetChanged(Bool_t on=kTRUE) override
we overwrite single condition changed property
Bool_t IsLabelDraw() const override
void PrintBar() override
Prints counters and bar.
void SetYMaxDraw(Bool_t on) override
Bool_t IsYMaxDraw() const override
Bool_t IsLimitsDraw() const override
Double_t GetXLow() const override
TGo4Condition * At(Int_t i) const
Returns condition object i from object array.
void Disable(Bool_t result) override
Calls Disable for all conditions (multi edit mode) or for currently selected (single edit mode)
void SetXRMSDraw(Bool_t on) override
Double_t GetCMax(TH1 *histo) override
Calculate value for histogram inside condition limits.
Int_t fiSelectedCond
Index of selected condition.
void SetYRMSDraw(Bool_t on) override
void SetCurrentIndex(Int_t ix) override
set index for array type subclasses
Double_t GetSkewness(TH1 *histo, Int_t axis=1) override
Calculate value for histogram inside condition limits.
virtual ~TGo4CondArray()
void ResetCounts() override
Calls ResetCounts for all conditions (multi edit mode) or for currently selected (single edit mode)
const char * GetType() const
Returns class name of conditions.
void SetIntDraw(Bool_t on) override
void SetLimitsDraw(Bool_t on) override
virtual Bool_t IsYMaxDraw() const
virtual Double_t GetXUp() const
virtual void SetYMeanDraw(Bool_t on)
void SetPainted(Bool_t on)
virtual Bool_t IsXMaxDraw() const
virtual Double_t GetCurtosis(TH1 *, Int_t=1)
Calculate value for histogram inside condition limits.
virtual Bool_t IsYMeanDraw() const
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
Copy values from cond to this.
virtual void SetLabelDraw(Bool_t on)
virtual void SetVisible(Bool_t on)
Set/Unset visibility.
virtual void GetFlags(Bool_t *enabled, Bool_t *lastresult, Bool_t *markreset, Bool_t *result, Bool_t *truevalue, Bool_t *falsevalue)
Sets values of internal boolean flags to external variables.
virtual void Enable()
Enable (unfreeze) Test execution.
virtual void SetLimitsDraw(Bool_t on)
virtual void SetValues()
Set values needed, i.e.
virtual Double_t GetMean(TH1 *, Int_t=1)
Calculate value for histogram inside condition limits.
virtual Bool_t IsPolygonType() const
virtual Int_t GetMemorySize() const
virtual Bool_t IsYRMSDraw() const
virtual Bool_t IsXMeanDraw() const
virtual void ResetCounts()
Clear counters.
virtual Double_t GetSkewness(TH1 *, Int_t=1)
Calculate value for histogram inside condition limits.
void IncCounts()
Increment the test counter.
virtual void SetIntDraw(Bool_t on)
virtual Int_t Counts()
Return number of calls of the Test method.
TGo4ConditionPainter * fxPainter
Painter instance to display the condition in root pad.
virtual void SetYRMSDraw(Bool_t on)
void Draw(Option_t *opt="") override
Draw this condition on current pad.
Bool_t IsPainted() const
virtual Bool_t Test()
Test if condition is true.
virtual Bool_t IsLimitsDraw() const
virtual Int_t IsChanged() const
virtual void SetYMaxDraw(Bool_t on)
virtual Double_t GetYMax(TH1 *)
Calculate value for histogram inside condition limits.
virtual Bool_t IsXRMSDraw() const
virtual Bool_t IsVisible() const
Visibility property for gui display in editor.
virtual Bool_t IsCMaxDraw() const
virtual Double_t GetXLow() const
virtual Bool_t IsIntDraw() const
void IncTrueCounts()
Increment the "test was true" counter.
virtual void SetXRMSDraw(Bool_t on)
virtual Bool_t IsLabelDraw() const
virtual void SetXMeanDraw(Bool_t on)
virtual void SetChanged(Bool_t on=kTRUE)
virtual void PrintCondition(Bool_t full=kTRUE)
Prints counters and boolean members.
virtual void Disable(Bool_t result)
Freeze condition, on Test() return result.
virtual Double_t GetCMax(TH1 *)
Calculate value for histogram inside condition limits.
virtual void PrintBar()
Prints counters and bar.
virtual Double_t GetIntegral(TH1 *, Option_t *="")
Calculate value for histogram inside condition limits.
virtual void Invert(Bool_t on)
Inverts return values, when on is true, i.e.
virtual void MarkReset(Bool_t on)
defines if condition counters shall be reset in UpdateFrom method
virtual Double_t GetXMax(TH1 *)
Calculate value for histogram inside condition limits.
virtual Double_t GetYUp() const
const char * MakeScript(std::ostream &out, const char *varname, Option_t *opt="", const char *arrextraargs=nullptr)
virtual void SetCMaxDraw(Bool_t on)
virtual Double_t GetYLow() const
virtual void SetXMaxDraw(Bool_t on)
virtual Double_t GetRMS(TH1 *, Int_t=1)
Calculate value for histogram inside condition limits.
virtual Bool_t IsMultiEdit() const
static void Warn(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 2.
Definition TGo4Log.cxx:307
Polygon condition.
static void CleanupSpecials()
Remove all references to any TCutGs from ROOT list of specials.
Window condition.
Definition TGo4WinCond.h:26