GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4CondArray.cxx
Go to the documentation of this file.
1 // $Id: TGo4CondArray.cxx 1922 2016-06-13 10:23:16Z adamczew $
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 für 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 <stdlib.h>
17 
18 #include "Riostream.h"
19 #include "TROOT.h"
20 #include "TClass.h"
21 #include "TObjArray.h"
22 
23 #include "TGo4Log.h"
24 #include "TGo4WinCond.h"
25 #include "TGo4PolyCond.h"
26 #include "TGo4CondArrayPainter.h"
27 
28 // ----------------------------------------------------------
30 {
31  if(fiType != kGO4CONDWINDOW) return 0;
32  return (TGo4WinCond*) At(i);
33 }
34 // ----------------------------------------------------------
36 {
37  if(fiType != kGO4CONDPOLYGON) return 0;
38  return (TGo4PolyCond*) At(i);
39 }
40 // ----------------------------------------------------------
42 {
43  return (TGo4Condition*) condarr->At(i);
44 }
45 // ----------------------------------------------------------
47 {
48  // boundary check by TObjArray, returns [0] in case
49  return (TGo4Condition*) condarr->At(i);
50 }
51 // ----------------------------------------------------------
53  TGo4Condition(),
54  condarr(0),
55  fiNumCond(0),
56  fiType(0),
57  fiSelectedCond(0)
58 {
59 }
60 // ----------------------------------------------------------
61 TGo4CondArray::TGo4CondArray(const char* name, Int_t elements, Int_t contype) :
62  TGo4Condition(name,"TGo4CondArray"),
63  condarr(0),
64  fiNumCond(0),
65  fiType(0),
66  fiSelectedCond(0)
67 {
68  fiNumCond = elements;
69  if(contype == kGO4CONDWINDOW) {
70  condarr = new TObjArray(elements);
71  fiType = contype;
72  for(Int_t i = 0; i < elements; i++)
73  condarr->AddLast(new TGo4WinCond(Form("%s%06d",name,i)));
74  } else
75  if(contype == kGO4CONDPOLYGON) {
76  condarr = new TObjArray(elements);
77  fiType = contype;
78  for(Int_t i = 0; i < elements; i++)
79  condarr->AddLast(new TGo4PolyCond(Form("%s%06d",name,i)));
80 
81  TGo4PolyCond::CleanupSpecials(); // JAM2016
82  } else {
83  fiNumCond = 0;
84  fiType = 0;
85  }
86 }
87 // ----------------------------------------------------------
88 TGo4CondArray::TGo4CondArray(const char* name, Int_t elements, const char* type)
89 : TGo4Condition(name,type),fiSelectedCond(0)
90 {
91  fiNumCond = elements;
92  if(strcmp(type,"TGo4WinCond")==0) {
93  condarr = new TObjArray(elements);
95  for(Int_t i = 0; i < elements; i++)
96  condarr->AddLast(new TGo4WinCond(Form("%s%06d",name,i)));
97  } else
98  if(strcmp(type,"TGo4PolyCond")==0) {
99  condarr = new TObjArray(elements);
101  for(Int_t i = 0; i < elements; i++)
102  condarr->AddLast(new TGo4PolyCond(Form("%s%06d",name,i)));
103 
104  TGo4PolyCond::CleanupSpecials(); // JAM2016
105  } else {
106  fiNumCond = 0;
107  fiType = 0;
108  }
109 }
110 // ----------------------------------------------------------
112 {
113  if(fxPainter) delete fxPainter; // delete painter before this subclass is gone
114  // when called in TGo4Condition dtor only, painter
115  // cannot cast correctly on TGo4CondArray!
116  fxPainter=0;
117  if (condarr!=0) {
118  condarr->Delete();
119  delete condarr;
120  }
121 
122 }
123 
124 Bool_t TGo4CondArray::IsArrayType(){return kTRUE;}
125 
126 // ----------------------------------------------------------
127 
128 Bool_t TGo4CondArray::Test(Double_t x, Double_t y)
129 {
130 Bool_t rev=kTRUE;
131 if(IsMultiEdit())
132  {
133  Int_t ii = condarr->GetLast()+1;
134  for(Int_t i = 0; i < ii; i++)
135  {
136  IncCounts();
137  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
138  Bool_t result=cond->Test(x,y);
139  if(result) IncTrueCounts();
140  rev&=result;
141  }
142  }
143 else
144  {
145  TGo4Condition* conny=At(GetCurrentIndex());
146  if(conny) rev=conny->Test(x,y);
147  }
148 return rev;
149 
150 }
151 Bool_t TGo4CondArray::Test(Double_t x)
152 {
153 Bool_t rev=kTRUE;
154 if(IsMultiEdit())
155  {
156  Int_t ii = condarr->GetLast()+1;
157  for(Int_t i = 0; i < ii; i++)
158  {
159  IncCounts();
160  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
161  Bool_t result=cond->Test(x);
162  if(result) IncTrueCounts();
163  rev&=result;
164  }
165  }
166 else
167  {
168  TGo4Condition* conny=At(GetCurrentIndex());
169  if(conny) rev=conny->Test(x);
170  }
171 return rev;
172 }
173 
174 // ----------------------------------------------------------
175 void TGo4CondArray::PrintCondition(Bool_t points)
176 {
177  // all entries are used!
178  Int_t ii = condarr->GetLast()+1;
179  TGo4Condition* cond = (TGo4Condition*) condarr->At(0);
180  std::cout << GetName() << " has " << ii << " " << cond->ClassName() << " conditions" << std::endl;
181  for(Int_t i = 0; i < ii; i++)
182  {
183  TGo4Condition* cond = dynamic_cast<TGo4Condition*> (condarr->UncheckedAt(i));
184  if (cond) cond->PrintCondition(points);
185  }
186 }
187 // ----------------------------------------------------------
189 {
190  Int_t ii = condarr->GetLast()+1;
191  std::cout <<"-"<<ClassName()<<" "<<GetName()<<" Printout:" << std::endl;
192  //TROOT::IncreaseDirLevel();
193  for(Int_t i = 0; i < ii; i++)
194  {
195  TGo4Condition* cond = dynamic_cast<TGo4Condition*> (condarr->UncheckedAt(i));
196  TROOT::IndentLevel();
197  if (cond) cond->PrintBar();
198  }
199 //TROOT::DecreaseDirLevel();
200 }
201 
203 {
204  return GetNumber();
205 }
206 
207 // ----------------------------------------------------------
209 {
210  return (condarr->GetLast()+1);
211 }
212 
213 // ----------------------------------------------------------
214 const char* TGo4CondArray::GetType() const
215 {
216  TGo4Condition *cond = (TGo4Condition*) condarr->At(0);
217  return cond->ClassName();
218 }
219 
220 // -----------------------------------------------
221 void TGo4CondArray::GetType(Int_t& type) const
222 {
223  type = fiType;
224 }
225 // -----------------------------------------------
228 if(IsMultiEdit())
229  {
230  Int_t ii = condarr->GetLast()+1;
231  //std::cout << GetName() << ": Enable " <<ii<<" conditions " << std::endl;
232  for(Int_t i = 0; i < ii; i++)
233  {
234  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
235  cond->Enable();
236  }
237  }
238 else
239  {
240  TGo4Condition* conny=At(GetCurrentIndex());
241  if(conny) conny->Enable();
242  }
243 }
244 // -----------------------------------------------
245 void TGo4CondArray::Disable(Bool_t result)
246 {
247 TGo4Condition::Disable(result);
248 if(IsMultiEdit())
249  {
250  Int_t ii = condarr->GetLast()+1;
251  //std::cout << GetName() << ": Disable " <<ii<<" conditions " << " " << result << std::endl;
252  for(Int_t i = 0; i < ii; i++)
253  {
254  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
255  cond->Disable(result);
256  }
257  }
258 else
259  {
260  TGo4Condition* conny=At(GetCurrentIndex());
261  if(conny) conny->Disable(result);
262  }
263 }
264 // -----------------------------------------------
265 void TGo4CondArray::Invert(Bool_t on)
266 {
268 if(IsMultiEdit())
269  {
270  Int_t ii = condarr->GetLast()+1;
271  //std::cout << GetName() << ": Invert " <<ii<<" conditions " << " " << on << std::endl;
272  for(Int_t i = 0; i < ii; i++)
273  {
274  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
275  cond->Invert(on);
276  }
277  }
278 else
279  {
280  TGo4Condition* conny=At(GetCurrentIndex());
281  if(conny) conny->Invert(on);
282  }
283 }
284 
286 {
288 if(IsMultiEdit())
289  {
290  Int_t ii = condarr->GetLast()+1;
291  for(Int_t i = 0; i < ii; i++)
292  {
293  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
294  cond->MarkReset(on);
295  }
296  }
297 else
298  {
299  TGo4Condition* conny=At(GetCurrentIndex());
300  if(conny) conny->MarkReset(on);
301  }
302 }
303 
304 void TGo4CondArray::GetFlags(Bool_t* enabled, Bool_t* lastresult, Bool_t* markreset,
305  Bool_t* result, Bool_t* truevalue, Bool_t* falsevalue)
306 {
307 if(IsMultiEdit())
308  {
309  Int_t ii = condarr->GetLast()+1;
310  for(Int_t i = 0; i < ii; i++)
311  {
312  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
313  cond->GetFlags(enabled,lastresult,markreset, result, truevalue, falsevalue);
314  }
315  }
316 else
317  {
318  TGo4Condition* conny=At(GetCurrentIndex());
319  if(conny) conny->GetFlags(enabled,lastresult,markreset, result, truevalue, falsevalue);
320 
321  }
322 }
323 
324 
325 
326 
327 
328 // -----------------------------------------------
331 if(IsMultiEdit())
332  {
333  //std::cout << GetName() << ": Reset " <<ii<<" conditions " << " " << on << std::endl;
334  Int_t ii = condarr->GetLast()+1;
335  for(Int_t i = 0; i < ii; i++)
336  {
337  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
338  cond->ResetCounts();
339  }
340  }
341 else
342  {
343  TGo4Condition* conny=At(GetCurrentIndex());
344  if(conny) conny->ResetCounts();
345  }
346 }
347 
349 {
350 Int_t rev=0;
351 if(IsMultiEdit())
352  {
353  rev=TGo4Condition::Counts();
354  }
355 else
356  {
357  TGo4Condition* conny=At(GetCurrentIndex());
358  if(conny) rev=conny->Counts();
359  }
360 return rev;
361 }
362 // ---------------------------------------------------------
364 {
365 Int_t rev=0;
366 if(IsMultiEdit())
367  {
368  rev=TGo4Condition::Counts();
369  }
370 else
371  {
372  TGo4Condition* conny=At(GetCurrentIndex());
373  if(conny) rev=conny->Counts();
374  }
375 return rev;
376 }
377 
379 {
380 Double_t rev=0;
381 if(IsMultiEdit())
382  {
383  rev=-1;
384  }
385 else
386  {
387  TGo4Condition* conny=At(GetCurrentIndex());
388  if(conny) rev=conny->GetXLow();
389  }
390 return rev;
391 }
392 
394 {
395 Double_t rev=0;
396 if(IsMultiEdit())
397  {
398  rev=-1;
399  }
400 else
401  {
402  TGo4Condition* conny=At(GetCurrentIndex());
403  if(conny) rev=conny->GetXUp();
404  }
405 return rev;
406 }
407 
409 {
410 Double_t rev=0;
411 if(IsMultiEdit())
412  {
413  rev=-1;
414  }
415 else
416  {
417  TGo4Condition* conny=At(GetCurrentIndex());
418  if(conny) rev=conny->GetYLow();
419  }
420 return rev;
421 }
422 
424 {
425 Double_t rev=0;
426 if(IsMultiEdit())
427  {
428  rev=-1;
429  }
430 else
431  {
432  TGo4Condition* conny=At(GetCurrentIndex());
433  if(conny) rev=conny->GetYUp();
434  }
435 return rev;
436 }
437 
438 
439 // -----------------------------------------------
440 void TGo4CondArray::SetValues(Double_t low1, Double_t up1){
441 if(fiType == kGO4CONDWINDOW)
442 {
443  if(IsMultiEdit())
444  {
445  Int_t ii = condarr->GetLast()+1;
446  for(Int_t i = 0; i < ii; i++)
447  {
448  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
449  cond->SetValues(low1,up1);
450  }
451  }
452  else
453  {
454  TGo4Condition* conny=At(GetCurrentIndex());
455  if(conny) conny->SetValues(low1,up1);
456  }
457 }
458 }
459 // -----------------------------------------------
460 void TGo4CondArray::SetValues(Double_t low1, Double_t up1, Double_t low2, Double_t up2){
461 if(fiType == kGO4CONDWINDOW)
462 {
463  if(IsMultiEdit())
464  {
465  Int_t ii = condarr->GetLast()+1;
466  for(Int_t i = 0; i < ii; i++)
467  {
468  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
469  cond->SetValues(low1,up1,low2,up2);
470  }
471  }
472  else
473  {
474  TGo4Condition* conny=At(GetCurrentIndex());
475  if(conny) conny->SetValues(low1,up1,low2,up2);
476  }
477 }
478 }
479 // -----------------------------------------------
480 void TGo4CondArray::SetValues(TCutG * newcut)
481 {
482 if(fiType == kGO4CONDPOLYGON)
483 {
484  if(IsMultiEdit())
485  {
486  Int_t ii = condarr->GetLast()+1;
487  for(Int_t i = 0; i < ii; i++)
488  {
489  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
490  cond->SetValues(newcut);
491  }
492  }
493  else
494  {
495  TGo4Condition* conny=At(GetCurrentIndex());
496  if(conny) conny->SetValues(newcut);
497  }
498 }
499 }
500 
501 Bool_t TGo4CondArray::UpdateFrom(TGo4Condition * cond, Bool_t counts)
502 {
503  TGo4Condition::UpdateFrom(cond,counts); // make sure to copy general flags
504  TGo4Condition *scond; // source member
505  TGo4Condition *dcond; // destination member
506  TGo4CondArray *carr; // source array
507  if(cond->InheritsFrom(TGo4CondArray::Class()))
508  {
509  Int_t dii = condarr->GetLast()+1; // this is destination
510  Int_t sii = ((TGo4CondArray*)cond)->GetNumber(); // elements in source array
511  if(dii == sii)
512  {
513  Bool_t result=kTRUE;
514  carr = (TGo4CondArray*)cond;
515 // std::cout << GetName() << ": Update " << dii << " from " << cond->GetName() << std::endl;
516  for(Int_t i = 0; i < dii; i++){
517  dcond=(TGo4Condition*) condarr->UncheckedAt(i); // destination is this
518  scond=(TGo4Condition*) (*carr)[i]; // source is from cond
519  result = result && ( dcond->UpdateFrom(scond,counts));
520  }
521  return result;
522  }
523  else
524  {
525  return kFALSE;
526  }
527  }
528 else
529  {
530  return kFALSE;
531  }
532 }
533 
535 {
536 if(IsMultiEdit())
537  {
539  Int_t ii = condarr->GetLast()+1;
540  for(Int_t i = 0; i < ii; i++)
541  {
542  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
543  cond->SetVisible(on);
544  }
545  }
546 else
547  {
548  TGo4Condition* conny=At(GetCurrentIndex());
549  if(conny) conny->SetVisible(on);
550  }
551 }
552 
554 {
555 Bool_t rev=kFALSE;
556 if(IsMultiEdit())
557  {
559  }
560 else
561  {
562  TGo4Condition* conny=At(GetCurrentIndex());
563  if(conny) rev=conny->IsVisible();
564  }
565 return rev;
566 }
567 
569 {
570 if(IsMultiEdit())
571  {
573  Int_t ii = condarr->GetLast()+1;
574  for(Int_t i = 0; i < ii; i++)
575  {
576  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
577  cond->SetLabelDraw(on);
578  }
579  }
580 else
581  {
582  TGo4Condition* conny=At(GetCurrentIndex());
583  if(conny) conny->SetLabelDraw(on);
584  }
585 }
587 {
588 Bool_t rev=kFALSE;
589 if(IsMultiEdit())
590  {
592  }
593 else
594  {
595  TGo4Condition* conny=At(GetCurrentIndex());
596  if(conny) rev=conny->IsLabelDraw();
597  }
598 return rev;
599 }
600 
601 
603 {
604 if(IsMultiEdit())
605  {
607  Int_t ii = condarr->GetLast()+1;
608  for(Int_t i = 0; i < ii; i++)
609  {
610  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
611  cond->SetLimitsDraw(on);
612  }
613  }
614 else
615  {
616  TGo4Condition* conny=At(GetCurrentIndex());
617  if(conny) conny->SetLimitsDraw(on);
618  }
619 }
620 
622 {
623 Bool_t rev=kFALSE;
624 if(IsMultiEdit())
625  {
627  }
628 else
629  {
630  TGo4Condition* conny=At(GetCurrentIndex());
631  if(conny) rev=conny->IsLimitsDraw();
632  }
633 return rev;
634 }
635 
636 
638 {
639 if(IsMultiEdit())
640  {
642  Int_t ii = condarr->GetLast()+1;
643  for(Int_t i = 0; i < ii; i++)
644  {
645  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
646  cond->SetIntDraw(on);
647  }
648  }
649 else
650  {
651  TGo4Condition* conny=At(GetCurrentIndex());
652  if(conny) conny->SetIntDraw(on);
653  }
654 }
656 {
657 Bool_t rev=kFALSE;
658 if(IsMultiEdit())
659  {
661  }
662 else
663  {
664  TGo4Condition* conny=At(GetCurrentIndex());
665  if(conny) rev=conny->IsIntDraw();
666  }
667 return rev;
668 }
670 {
671 if(IsMultiEdit())
672  {
674  Int_t ii = condarr->GetLast()+1;
675  for(Int_t i = 0; i < ii; i++)
676  {
677  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
678  cond->SetXMeanDraw(on);
679  }
680  }
681 else
682  {
683  TGo4Condition* conny=At(GetCurrentIndex());
684  if(conny) conny->SetXMeanDraw(on);
685  }
686 }
688 {
689 Bool_t rev=kFALSE;
690 if(IsMultiEdit())
691  {
693  }
694 else
695  {
696  TGo4Condition* conny=At(GetCurrentIndex());
697  if(conny) rev=conny->IsXMeanDraw();
698  }
699 return rev;
700 }
702 {
703 if(IsMultiEdit())
704  {
706  Int_t ii = condarr->GetLast()+1;
707  for(Int_t i = 0; i < ii; i++)
708  {
709  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
710  cond->SetXRMSDraw(on);
711  }
712  }
713 else
714  {
715  TGo4Condition* conny=At(GetCurrentIndex());
716  if(conny) conny->SetXRMSDraw(on);
717  }
718 }
720 {
721 Bool_t rev=kFALSE;
722 if(IsMultiEdit())
723  {
725  }
726 else
727  {
728  TGo4Condition* conny=At(GetCurrentIndex());
729  if(conny) rev=conny->IsXRMSDraw();
730  }
731 return rev;
732 }
734 {
735 if(IsMultiEdit())
736  {
738  Int_t ii = condarr->GetLast()+1;
739  for(Int_t i = 0; i < ii; i++)
740  {
741  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
742  cond->SetYMeanDraw(on);
743  }
744  }
745 else
746  {
747  TGo4Condition* conny=At(GetCurrentIndex());
748  if(conny) conny->SetYMeanDraw(on);
749  }
750 }
752 {
753 Bool_t rev=kFALSE;
754 if(IsMultiEdit())
755  {
757  }
758 else
759  {
760  TGo4Condition* conny=At(GetCurrentIndex());
761  if(conny) rev=conny->IsYMeanDraw();
762  }
763 return rev;
764 }
766 {
767 if(IsMultiEdit())
768  {
770  Int_t ii = condarr->GetLast()+1;
771  for(Int_t i = 0; i < ii; i++)
772  {
773  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
774  cond->SetYRMSDraw(on);
775  }
776  }
777 else
778  {
779  TGo4Condition* conny=At(GetCurrentIndex());
780  if(conny) conny->SetYRMSDraw(on);
781  }
782 }
784 {
785 Bool_t rev=kFALSE;
786 if(IsMultiEdit())
787  {
789  }
790 else
791  {
792  TGo4Condition* conny=At(GetCurrentIndex());
793  if(conny) rev=conny->IsYRMSDraw();
794  }
795 return rev;
796 }
798 {
799 if(IsMultiEdit())
800  {
802  Int_t ii = condarr->GetLast()+1;
803  for(Int_t i = 0; i < ii; i++)
804  {
805  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
806  cond->SetXMaxDraw(on);
807  }
808  }
809 else
810  {
811  TGo4Condition* conny=At(GetCurrentIndex());
812  if(conny) conny->SetXMaxDraw(on);
813  }
814 }
816 {
817 Bool_t rev=kFALSE;
818 if(IsMultiEdit())
819  {
821  }
822 else
823  {
824  TGo4Condition* conny=At(GetCurrentIndex());
825  if(conny) rev=conny->IsXMaxDraw();
826  }
827 return rev;
828 }
830 {
831 if(IsMultiEdit())
832  {
834  Int_t ii = condarr->GetLast()+1;
835  for(Int_t i = 0; i < ii; i++)
836  {
837  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
838  cond->SetYMaxDraw(on);
839  }
840  }
841 else
842  {
843  TGo4Condition* conny=At(GetCurrentIndex());
844  if(conny) conny->SetYMaxDraw(on);
845  }
846 }
848 {
849 Bool_t rev=kFALSE;
850 if(IsMultiEdit())
851  {
853  }
854 else
855  {
856  TGo4Condition* conny=At(GetCurrentIndex());
857  if(conny) rev=conny->IsYMaxDraw();
858  }
859 return rev;
860 }
862 {
863 if(IsMultiEdit())
864  {
866  Int_t ii = condarr->GetLast()+1;
867  for(Int_t i = 0; i < ii; i++)
868  {
869  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
870  cond->SetCMaxDraw(on);
871  }
872  }
873 else
874  {
875  TGo4Condition* conny=At(GetCurrentIndex());
876  if(conny) conny->SetCMaxDraw(on);
877  }
878 }
880 {
881 Bool_t rev=kFALSE;
882 if(IsMultiEdit())
883  {
885  }
886 else
887  {
888  TGo4Condition* conny=At(GetCurrentIndex());
889  if(conny) rev=conny->IsCMaxDraw();
890  }
891 return rev;
892 }
893 
894 Double_t TGo4CondArray::GetIntegral(TH1* histo, Option_t* opt)
895 {
896 Double_t rev=0;
897 if(IsMultiEdit())
898  {
899  // return sum of all integrals
900  Int_t ii = condarr->GetLast()+1;
901  for(Int_t i = 0; i < ii; i++)
902  {
903  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
904  rev+=cond->GetIntegral(histo,opt);
905  }
906  }
907 else
908  {
909  TGo4Condition* conny=At(GetCurrentIndex());
910  if(conny) rev=conny->GetIntegral(histo,opt);
911  }
912 return rev;
913 }
914 
915 Double_t TGo4CondArray::GetMean(TH1* histo, Int_t axis)
916 {
917 Double_t rev=0;
918 if(IsMultiEdit())
919  {
920  // give back mean value of means. does this make sense?
921  Int_t ii = condarr->GetLast()+1;
922  Double_t sum=0;
923  for(Int_t i = 0; i < ii; i++)
924  {
925  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
926  sum+=cond->GetMean(histo,axis);
927  rev=sum/ii;
928  }
929  }
930 else
931  {
932  TGo4Condition* conny=At(GetCurrentIndex());
933  if(conny) rev=conny->GetMean(histo,axis);
934  }
935 return rev;
936 }
937 Double_t TGo4CondArray::GetRMS(TH1* histo, Int_t axis)
938 {
939 Double_t rev=0;
940 if(IsMultiEdit())
941  {
942  rev=-2; // what is the result RMS of all subconditions?
943  }
944 else
945  {
946  TGo4Condition* conny=At(GetCurrentIndex());
947  if(conny) rev=conny->GetRMS(histo,axis);
948  }
949 return rev;
950 }
951 Double_t TGo4CondArray::GetSkewness(TH1* histo, Int_t axis)
952 {
953 Double_t rev=0;
954 if(IsMultiEdit())
955  {
956  rev=-2; // what is the result Skewness of all subconditions?
957  }
958 else
959  {
960  TGo4Condition* conny=At(GetCurrentIndex());
961  if(conny) rev=conny->GetSkewness(histo,axis);
962  }
963 return rev;
964 }
965 Double_t TGo4CondArray::GetCurtosis(TH1* histo, Int_t axis)
966 {
967 Double_t rev=0;
968 if(IsMultiEdit())
969  {
970  rev=-2; // what is the result Curtosis of all subconditions?
971  }
972 else
973  {
974  TGo4Condition* conny=At(GetCurrentIndex());
975  if(conny) rev=conny->GetCurtosis(histo,axis);
976  }
977 return rev;
978 }
979 Double_t TGo4CondArray::GetXMax(TH1* histo)
980 {
981 Double_t rev=0;
982 if(IsMultiEdit())
983  {
984  rev=-2; // would need the xmax of the maximum content of all
985  }
986 else
987  {
988  TGo4Condition* conny=At(GetCurrentIndex());
989  if(conny) rev=conny->GetXMax(histo);
990  }
991 return rev;
992 }
993 Double_t TGo4CondArray::GetYMax(TH1* histo)
994 {
995 Double_t rev=0;
996 if(IsMultiEdit())
997  {
998  rev=-2;
999  }
1000 else
1001  {
1002  TGo4Condition* conny=At(GetCurrentIndex());
1003  if(conny) rev=conny->GetYMax(histo);
1004  }
1005 return rev;
1006 }
1007 Double_t TGo4CondArray::GetCMax(TH1* histo)
1008 {
1009 Double_t rev=0;
1010 if(IsMultiEdit())
1011  {
1012  // return highest channel content of all subconditions
1013  Int_t ii = condarr->GetLast()+1;
1014  for(Int_t i = 0; i < ii; i++)
1015  {
1016  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
1017  Double_t lmax=cond->GetCMax(histo);
1018  if(lmax>rev) rev=lmax;
1019  }
1020  }
1021 else
1022  {
1023  TGo4Condition* conny=At(GetCurrentIndex());
1024  if(conny) rev=conny->GetCMax(histo);
1025  }
1026 return rev;
1027 }
1028 
1029 
1031 {
1032 if(IsMultiEdit())
1033  return this;
1034 else
1035  return At(GetCurrentIndex());
1036 }
1037 
1038 
1040 {
1041  for(Int_t i = 0; i <= condarr->GetLast(); i++) {
1042  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
1043  cond->SetChanged(on);
1044  }
1045 }
1046 
1047 
1049 {
1050  Int_t cnt = 0;
1051  for(Int_t i = 0; i <= condarr->GetLast(); i++) {
1052  TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
1053  cnt += cond->IsChanged();
1054  }
1055  return cnt;
1056 }
1057 
1058 
1060 {
1061 Bool_t rev=kFALSE;
1062 if(IsMultiEdit())
1063  {
1064  if(fiType == kGO4CONDPOLYGON)
1065  rev=kTRUE;
1066  else
1067  rev=kFALSE;
1068  }
1069 else
1070  {
1071  TGo4Condition* conny=At(GetCurrentIndex());
1072  if(conny) rev=conny->IsPolygonType();
1073  }
1074 return rev;
1075 }
1076 
1078 {
1079  fiSelectedCond=ix;
1080 }
1081 
1082 
1084 {
1085  return fiSelectedCond;
1086 }
1087 
1088 
1089 void TGo4CondArray::Draw(Option_t* opt)
1090 {
1091  TGo4Condition::Draw(opt);
1092  Int_t selid = -1;
1093  if (opt!=0)
1094  if (strstr(opt,"sel=")==opt)
1095  selid = atoi(opt+4);
1096  for(Int_t i=0; i<GetNumber(); ++i) {
1097  TGo4Condition* con = At(i);
1098  bool selected = (selid<0) || (selid==i);
1099  if(con!=0)
1100  con->SetPainted(IsPainted() && selected);
1101  }
1102 }
1103 
1104 
1105 
1107 {
1108 if(painter==0) return;
1109 if(painter->InheritsFrom(TGo4CondArrayPainter::Class()))
1110  {
1111  if(fxPainter) delete fxPainter;
1112  fxPainter=painter;
1113  }
1114 else
1115  {
1116  TGo4Log::Warn("Could not set painter of class %s for TGo4CondArray %s",
1117  painter->ClassName(),GetName());
1118  }
1119 }
1120 
1122 {
1123  TGo4ConditionPainter* painter=new TGo4CondArrayPainter(GetName());
1124  painter->SetCondition(this);
1125  return painter;
1126 }
1127 
1129 {
1130  Int_t size = sizeof(*this);
1131  if (GetName()!=0) size+=strlen(GetName());
1132  if (GetTitle()!=0) size+=strlen(GetTitle());
1133 
1134  if (condarr!=0)
1135  size+=sizeof(*condarr) + condarr->GetEntriesFast() * sizeof(TObject*);
1136 
1137  for (Int_t n=0;n<GetNumberOfConditions();n++) {
1138  TGo4Condition* cond = At(n);
1139  if (cond!=0) size+=cond->GetMemorySize();
1140 
1141  }
1142 
1143 
1144  return size;
1145 }
1146 
1147 void TGo4CondArray::SavePrimitive(std::ostream& out, Option_t* opt)
1148 {
1149  static int cnt = 0;
1150  TString extraargs = TString::Format(", %d, \"%s\"", GetNumber(), GetType());
1151  TString varname = MakeScript(out, Form("condarr%d", cnt++), opt, extraargs.Data());
1152 
1153  // exclude name: options
1154  TString options = opt;
1155  const char* subname = strstr(opt, "name:");
1156  if (subname!=0) options.Resize(subname - opt);
1157 
1158  for (int n=0; n<GetNumber(); n++) {
1159  TString subopt = options + TString::Format(" nocreate name:%s->At(%d)", varname.Data(), n);
1160  At(n)->SavePrimitive(out, subopt.Data());
1161  out << std::endl;
1162  }
1163 }
virtual Double_t GetRMS(TH1 *histo, Int_t axis=1)
virtual Bool_t IsYRMSDraw()
virtual void Enable()
virtual void SetChanged(Bool_t on)
virtual Int_t TrueCounts()
virtual void MarkReset(Bool_t on)
virtual void SetIntDraw(Bool_t on)
virtual Bool_t IsVisible()
virtual Bool_t IsXMaxDraw()
const char * GetType() const
virtual Bool_t IsLabelDraw()
virtual Double_t GetXMax(TH1 *histo)
virtual Double_t GetMean(TH1 *histo, Int_t axis=1)
virtual void SetLimitsDraw(Bool_t on)
virtual Bool_t IsXRMSDraw()
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
virtual void SetLimitsDraw(Bool_t on)
void PrintCondition(Bool_t points)
virtual Double_t GetCMax(TH1 *histo)
virtual Bool_t IsXMeanDraw()
virtual Double_t GetCurtosis(TH1 *histo, Int_t axis=1)
virtual Int_t IsChanged()
virtual void SetYRMSDraw(Bool_t on)
virtual void GetFlags(Bool_t *enabled, Bool_t *lastresult, Bool_t *markreset, Bool_t *result, Bool_t *truevalue, Bool_t *falsevalue)
virtual void SetYRMSDraw(Bool_t on)
virtual void SetXMaxDraw(Bool_t on)
virtual ~TGo4CondArray()
virtual Double_t GetYMax(TH1 *histo)
virtual Bool_t IsXMeanDraw()
virtual Bool_t IsLimitsDraw()
virtual void SetPainter(TGo4ConditionPainter *painter)
virtual void PrintCondition(Bool_t full=kTRUE)
virtual Int_t Counts()
static void Warn(const char *text,...)
Definition: TGo4Log.cxx:296
virtual Bool_t IsLimitsDraw()
virtual Double_t GetSkewness(TH1 *histo, Int_t axis=1)
virtual Double_t GetXMax(TH1 *histo)
virtual Bool_t IsYMeanDraw()
virtual Double_t GetYUp()
TGo4WinCond * Win(Int_t i)
virtual void SetVisible(Bool_t on)
static void CleanupSpecials()
virtual void SetValues()
virtual Double_t GetIntegral(TH1 *histo, Option_t *opt="")
virtual void SetXMaxDraw(Bool_t on)
virtual Bool_t IsIntDraw()
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
virtual void ResetCounts()
virtual void Draw(Option_t *opt="")
virtual Bool_t IsXRMSDraw()
virtual void SetVisible(Bool_t on)
virtual Bool_t IsIntDraw()
virtual void SetYMaxDraw(Bool_t on)
void SetPainted(Bool_t on)
virtual Double_t GetXLow()
TObjArray * condarr
virtual void Enable()
virtual void PrintBar()
virtual Bool_t IsArrayType()
virtual void SetYMeanDraw(Bool_t on)
virtual void SavePrimitive(std::ostream &fs, Option_t *="")
virtual TGo4Condition * GetActiveCondition()
virtual Bool_t IsXMaxDraw()
virtual void PrintBar()
virtual Double_t GetMean(TH1 *histo, Int_t axis=1)
virtual Double_t GetCurtosis(TH1 *histo, Int_t axis=1)
virtual Int_t GetNumberOfConditions()
virtual Bool_t IsVisible()
virtual void Invert(Bool_t on)
virtual void Disable(Bool_t result)
virtual Bool_t IsMultiEdit()
virtual void SetIntDraw(Bool_t on)
virtual Bool_t IsYMaxDraw()
virtual Double_t GetYLow()
virtual void SetYMeanDraw(Bool_t on)
virtual Bool_t IsCMaxDraw()
Bool_t IsPainted() const
virtual void Disable(Bool_t result)
virtual void SetCMaxDraw(Bool_t on)
virtual void SetYMaxDraw(Bool_t on)
virtual void SetChanged(Bool_t on)
virtual void SetCondition(TGo4Condition *con)
virtual Bool_t IsYRMSDraw()
const char * MakeScript(std::ostream &out, const char *varname, Option_t *opt="", const char *arrextraargs=0)
virtual Double_t GetXLow()
virtual void SetXMeanDraw(Bool_t on)
virtual void GetFlags(Bool_t *enabled, Bool_t *lastresult, Bool_t *markreset, Bool_t *result, Bool_t *truevalue, Bool_t *falsevalue)
virtual Double_t GetSkewness(TH1 *histo, Int_t axis=1)
virtual Bool_t IsLabelDraw()
virtual void Draw(Option_t *opt="")
virtual void SetXMeanDraw(Bool_t on)
virtual TGo4ConditionPainter * CreatePainter()
TGo4PolyCond * Poly(Int_t i)
virtual Bool_t Test()
virtual void MarkReset(Bool_t on)
virtual void SetXRMSDraw(Bool_t on)
TGo4ConditionPainter * fxPainter
virtual Double_t GetYMax(TH1 *histo)
virtual void SetLabelDraw(Bool_t on)
virtual Int_t GetMemorySize()
virtual Bool_t IsPolygonType()
virtual Bool_t IsPolygonType()
TGo4Condition * At(Int_t i)
virtual Double_t GetXUp()
virtual Double_t GetRMS(TH1 *histo, Int_t axis=1)
virtual void SetCurrentIndex(Int_t ix)
virtual Bool_t IsCMaxDraw()
virtual void SetXRMSDraw(Bool_t on)
virtual Int_t Counts()
virtual Bool_t IsYMeanDraw()
virtual Double_t GetXUp()
virtual void SetLabelDraw(Bool_t on)
Int_t fiSelectedCond
virtual Double_t GetCMax(TH1 *histo)
virtual Int_t IsChanged()
TGo4Condition * operator[](Int_t i)
Int_t GetNumber() const
virtual Bool_t IsYMaxDraw()
virtual void ResetCounts()
virtual Double_t GetIntegral(TH1 *histo, Option_t *opt="")
virtual void Invert(Bool_t on)
virtual Int_t GetMemorySize()
virtual Double_t GetYUp()
virtual void SetCMaxDraw(Bool_t on)
virtual Int_t GetCurrentIndex()
virtual Double_t GetYLow()