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