GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
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"
22 #include "TGo4CondArrayPainter.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 // ----------------------------------------------------------
49  TGo4Condition(),
50  condarr(nullptr),
51  fiNumCond(0),
52  fiType(0),
54 {
55 }
56 // ----------------------------------------------------------
57 TGo4CondArray::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 
77  TGo4PolyCond::CleanupSpecials(); // JAM2016
78  } else {
79  fiNumCond = 0;
80  fiType = 0;
81  }
82 }
83 // ----------------------------------------------------------
84 TGo4CondArray::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 
100  TGo4PolyCond::CleanupSpecials(); // JAM2016
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 
123 Bool_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)
133  IncTrueCounts();
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 // ----------------------------------------------------------
145 Bool_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)
155  IncTrueCounts();
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 // ----------------------------------------------------------
167 void TGo4CondArray::PrintCondition(Bool_t points)
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 // ----------------------------------------------------------
207 const char *TGo4CondArray::GetType() const
208 {
209  TGo4Condition *cond = (TGo4Condition *) condarr->At(0);
210  return cond->ClassName();
211 }
212 
213 // -----------------------------------------------
214 void 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 // -----------------------------------------------
235 void TGo4CondArray::Disable(Bool_t result)
236 {
237  TGo4Condition::Disable(result);
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 // -----------------------------------------------
251 void TGo4CondArray::Invert(Bool_t on)
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 
283 void 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 
342 Double_t TGo4CondArray::GetXLow() const
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 
355 Double_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 
368 Double_t TGo4CondArray::GetYLow() const
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 
381 Double_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 // -----------------------------------------------
395 void 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 // -----------------------------------------------
412 void 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 // -----------------------------------------------
430 void 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 // -----------------------------------------------
448 Bool_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()) {
497  rev = TGo4Condition::IsVisible();
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()) {
590  rev = TGo4Condition::IsIntDraw();
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 // -----------------------------------------------
817 Double_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 // -----------------------------------------------
836 Double_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 // -----------------------------------------------
857 Double_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 // -----------------------------------------------
871 Double_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 // -----------------------------------------------
885 Double_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 // -----------------------------------------------
899 Double_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 // -----------------------------------------------
913 Double_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 // -----------------------------------------------
927 Double_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 // -----------------------------------------------
1006 void TGo4CondArray::Draw(Option_t *opt)
1007 {
1008  TGo4Condition::Draw(opt);
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  TGo4ConditionPainter *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 // -----------------------------------------------
1065 void 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 }
TGo4ConditionPainter * CreatePainter() override
Int_t GetNumberOfConditions() const override
virtual Bool_t IsLabelDraw() const
void SetYMaxDraw(Bool_t on) override
Bool_t IsCMaxDraw() const override
void SavePrimitive(std::ostream &fs, Option_t *opt="") override
Bool_t IsXMaxDraw() const override
void ResetCounts() override
virtual void SetIntDraw(Bool_t on)
void Disable(Bool_t result) override
virtual Bool_t IsYMeanDraw() const
virtual Double_t GetRMS(TH1 *, Int_t=1)
TGo4WinCond * Win(Int_t i) const
Bool_t IsXMeanDraw() const override
void Draw(Option_t *opt="") override
void SetLabelDraw(Bool_t on) override
virtual void SetYMaxDraw(Bool_t on)
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
virtual Double_t GetCurtosis(TH1 *, Int_t=1)
Bool_t IsPolygonType() const override
virtual void SetCMaxDraw(Bool_t on)
virtual Double_t GetYLow() const
Bool_t IsXRMSDraw() const override
Double_t GetCurtosis(TH1 *histo, Int_t axis=1) override
virtual Bool_t IsXMeanDraw() const
virtual ~TGo4CondArray()
virtual Bool_t IsYRMSDraw() const
virtual Bool_t IsCMaxDraw() const
virtual void PrintCondition(Bool_t full=kTRUE)
void MarkReset(Bool_t on) override
virtual void SetYRMSDraw(Bool_t on)
void SetXMeanDraw(Bool_t on) override
Double_t GetXMax(TH1 *histo) override
Bool_t IsIntDraw() const override
Double_t GetCMax(TH1 *histo) override
virtual Double_t GetYUp() const
const char * GetType() const
Double_t GetYUp() const override
Double_t GetRMS(TH1 *histo, Int_t axis=1) override
static void CleanupSpecials()
virtual void SetValues()
Definition: TGo4Condition.h:93
virtual void SetXMeanDraw(Bool_t on)
virtual Double_t GetIntegral(TH1 *, Option_t *="")
const char * MakeScript(std::ostream &out, const char *varname, Option_t *opt="", const char *arrextraargs=nullptr)
Int_t IsChanged() const override
Double_t GetSkewness(TH1 *histo, Int_t axis=1) override
void SetCMaxDraw(Bool_t on) override
virtual void ResetCounts()
const TGo4Condition * GetActiveCondition() const override
virtual Double_t GetSkewness(TH1 *, Int_t=1)
Int_t GetCurrentIndex() const override
void Invert(Bool_t on) override
Bool_t IsYRMSDraw() const override
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts) override
void SetPainted(Bool_t on)
void SetCurrentIndex(Int_t ix) override
Int_t TrueCounts() override
TObjArray * condarr
virtual void Enable()
virtual void PrintBar()
void SetPainter(TGo4ConditionPainter *painter) override
virtual Bool_t IsIntDraw() const
TGo4Condition * operator[](Int_t i) const
Bool_t IsPainted() const
Double_t GetXLow() const override
virtual void SetXMaxDraw(Bool_t on)
virtual Bool_t IsPolygonType() const
virtual Bool_t IsXRMSDraw() const
Bool_t IsYMeanDraw() const override
virtual Bool_t IsYMaxDraw() const
virtual Int_t GetMemorySize() const
void SetChanged(Bool_t on=kTRUE) override
Bool_t IsVisible() const override
Int_t GetNumber() const
void SetXMaxDraw(Bool_t on) override
virtual void Disable(Bool_t result)
Bool_t IsLimitsDraw() const override
Double_t GetIntegral(TH1 *histo, Option_t *opt="") override
virtual Double_t GetXLow() const
virtual Double_t GetXUp() const
virtual void SetCondition(TGo4Condition *con)
void SetYMeanDraw(Bool_t on) override
Double_t GetXUp() const override
virtual void SetXRMSDraw(Bool_t on)
virtual void SetLimitsDraw(Bool_t on)
void SetLimitsDraw(Bool_t on) override
void GetFlags(Bool_t *enabled, Bool_t *lastresult, Bool_t *markreset, Bool_t *result, Bool_t *truevalue, Bool_t *falsevalue) override
virtual void GetFlags(Bool_t *enabled, Bool_t *lastresult, Bool_t *markreset, Bool_t *result, Bool_t *truevalue, Bool_t *falsevalue)
virtual Bool_t Test()
TGo4PolyCond * Poly(Int_t i) const
virtual void MarkReset(Bool_t on)
virtual void SetChanged(Bool_t on=kTRUE)
Double_t GetYLow() const override
void SetIntDraw(Bool_t on) override
TGo4ConditionPainter * fxPainter
virtual Int_t IsChanged() const
virtual Bool_t IsLimitsDraw() const
Int_t Counts() override
void SetXRMSDraw(Bool_t on) override
virtual Double_t GetMean(TH1 *, Int_t=1)
virtual Double_t GetYMax(TH1 *)
void SetVisible(Bool_t on) override
void Enable() override
void Draw(Option_t *opt="") override
virtual Bool_t IsMultiEdit() const
void PrintBar() override
virtual Bool_t IsXMaxDraw() const
virtual void SetYMeanDraw(Bool_t on)
void SetYRMSDraw(Bool_t on) override
virtual Int_t Counts()
Bool_t IsLabelDraw() const override
Int_t fiSelectedCond
Double_t GetYMax(TH1 *histo) override
TGo4Condition * At(Int_t i) const
virtual void SetLabelDraw(Bool_t on)
static void Warn(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:307
Double_t GetMean(TH1 *histo, Int_t axis=1) override
virtual void SetVisible(Bool_t on)
virtual Double_t GetCMax(TH1 *)
Bool_t IsYMaxDraw() const override
virtual void Invert(Bool_t on)
Int_t GetMemorySize() const override
virtual Double_t GetXMax(TH1 *)
virtual Bool_t IsVisible() const
void PrintCondition(Bool_t points) override