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