GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Condition.cxx
Go to the documentation of this file.
1 // $Id: TGo4Condition.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 "TGo4Condition.h"
15 
16 
17 #include "TH1.h"
18 #include "TROOT.h"
19 #include "TList.h"
20 #include "TObjArray.h"
21 #include "TObjString.h"
22 #include "TCutG.h"
23 #include "TVirtualPad.h"
24 #include "Riostream.h"
25 #include "snprintf.h"
26 
27 #include "TGo4Log.h"
28 #include "TGo4ConditionPainter.h"
29 
30 const Double_t TGo4Condition::fgdUPDATEEPSILON=0.01;
31 
32 Bool_t TGo4Condition::fgbLABELDRAW=kTRUE;
33 Bool_t TGo4Condition::fgbLIMITSDRAW=kTRUE;
34 Bool_t TGo4Condition::fgbINTDRAW=kTRUE;
35 Bool_t TGo4Condition::fgbXMEANDRAW=kTRUE;
36 Bool_t TGo4Condition::fgbXRMSDRAW=kTRUE;
37 Bool_t TGo4Condition::fgbYMEANDRAW=kFALSE;
38 Bool_t TGo4Condition::fgbYRMSDRAW=kFALSE;
39 Bool_t TGo4Condition::fgbXMAXDRAW=kTRUE;
40 Bool_t TGo4Condition::fgbYMAXDRAW=kFALSE;
41 Bool_t TGo4Condition::fgbCMAXDRAW=kTRUE;
42 TString TGo4Condition::fgxNUMFORMAT="%.4E";
43 
45 TString TGo4Condition::fgxURL_RESET="resetcounters";
46 TString TGo4Condition::fgxURL_RESULT="resultmode";
47 TString TGo4Condition::fgxURL_INVERT="invertmode";
48 TString TGo4Condition::fgxURL_VISIBLE="visible";
49 TString TGo4Condition::fgxURL_LABEL="labeldraw";
50 TString TGo4Condition::fgxURL_LIMITS="limitsdraw";
51 TString TGo4Condition::fgxURL_INTEGRAL="intdraw";
52 TString TGo4Condition::fgxURL_XMEAN="xmeandraw";
53 TString TGo4Condition::fgxURL_XRMS="xrmsdraw";
54 TString TGo4Condition::fgxURL_YMEAN="ymeandraw";
55 TString TGo4Condition::fgxURL_YRMS="yrmsdraw";
56 TString TGo4Condition::fgxURL_XMAX="xmaxdraw";
57 TString TGo4Condition::fgxURL_YMAX="ymaxdraw";
58 TString TGo4Condition::fgxURL_CMAX="cmaxdraw";
59 
60 
61 
62 
63 // -----------------------------------------------
64 // Constructors
65 // ---------------------------------------------------------
67  TNamed(),
68  TAttLine(),
69  TAttFill(),
70  fxPainter(0),
71  fxCutHis(0),
72  fxUrlOptionArray(0),
73  fxHisto(0),
74  fiIsChanged(0)
75 {
76  GO4TRACE((15,"TGo4Condition::TGo4Condition()",__LINE__, __FILE__));
77  fiDim=0;
78  fbEnabled = false;
79  fbResult = true;
80  fbTrue = true;
81  fbFalse = false;
82  fbMarkReset = false;
83  fiCounts = 0;
84  fiTrueCounts= 0;
85  fbVisible=true;
86  fbMultiEdit= true;
87  fbHistogramLink=false;
89  fbIsPainted=kFALSE;
90  fbOwnedByEditor=kFALSE;
91  fbStreamedCondition=kTRUE;
93 }
94 
95 // -----------------------------------------------
96 TGo4Condition::TGo4Condition(const char* name, const char* title) :
97  TNamed(name, title),
98  TAttLine(),
99  TAttFill(),
100  fxPainter(0),
101  fxCutHis(0),
102  fxUrlOptionArray(0),
103  fxHisto(0),
104  fiIsChanged(0)
105 
106 {
107  GO4TRACE((15,"TGo4Condition::TGo4Condition(const char*)",__LINE__, __FILE__));
108  fiDim=0;
109  fbEnabled = false;
110  fbResult = true;
111  fbTrue = true;
112  fbFalse = false;
113  fbMarkReset = false;
114  fiCounts = 0;
115  fiTrueCounts = 0;
116  fbVisible=true;
117  fbMultiEdit= true;
118  fbHistogramLink=false;
120  fbIsPainted=kFALSE;
121  fbOwnedByEditor=kFALSE;
122  fbStreamedCondition=kFALSE;
123  InitLabelStyle();
124 }
125 
126 // ---------------------------------------------------------
128 {
129  GO4TRACE((15,"TGo4Condition::~TGo4Condition()",__LINE__, __FILE__));
130  //std::cout <<"TGo4Condition "<<(long) this <<" dtor " << std::endl;
131  //UnDraw("reset");
132  if(fxPainter) {
133  //std::cout <<"TGo4Condition "<<(long) this <<" dtor deletes painter"<< (long) fxPainter << std::endl;
134  delete fxPainter;
135  fxPainter = 0;
136  }
137  if(fxCutHis) {
138  //std::cout <<"TGo4Condition "<<(long) this <<" dtor deletes cuthistogram"<< (long) fxCutHis << std::endl;
139  delete fxCutHis;
140  fxCutHis = 0;
141  }
142 
143  if(fxUrlOptionArray) {
144  fxUrlOptionArray->Delete();
145  delete fxUrlOptionArray;
146  }
147 
148 }
149 // ---------------------------------------------------------
151 {
152  fiCounts++;
153  return true;
154 }
155 // ---------------------------------------------------------
156 
158 {
159 GO4TRACE((14,"TGo4Condition::AddCondition(TGo4Condition*)",__LINE__, __FILE__));
160 }
161 // ---------------------------------------------------------
163 {
164 GO4TRACE((12,"TGo4Condition::IncTrueCounts()",__LINE__, __FILE__));
165  fiTrueCounts++;
166 }
167 // ---------------------------------------------------------
169 {
170 GO4TRACE((12,"TGo4Condition::IncCounts()",__LINE__, __FILE__));
171  fiCounts++;
172 }
173 // ---------------------------------------------------------
175 {
176 GO4TRACE((12,"TGo4Condition::Counts()",__LINE__, __FILE__));
177  return fiCounts;
178 }
179 // ---------------------------------------------------------
181 {
182 GO4TRACE((12,"TGo4Condition::TrueCounts()",__LINE__, __FILE__));
183  return fiTrueCounts;
184 }
185 // ---------------------------------------------------------
187 {
188 GO4TRACE((12,"TGo4Condition::ResetCounts()",__LINE__, __FILE__));
189  fiTrueCounts=0;
190  fiCounts=0;
191 }
192 // ---------------------------------------------------------
193 void TGo4Condition::SetCounts(Int_t truecounts, Int_t counts)
194 {
195 GO4TRACE((12,"TGo4Condition::SetCounts()",__LINE__, __FILE__));
196  fiTrueCounts=truecounts;
197  fiCounts=counts;
198 }
199 
200 
201 // ---------------------------------------------------------
202 void TGo4Condition::Invert(Bool_t on)
203 {
204 GO4TRACE((12,"TGo4Condition::Invert",__LINE__, __FILE__));
205 fbTrue = on ^ true;
206 fbFalse = on ^ false;
207 }
208 
209 // ---------------------------------------------------------
211 {
212  Float_t perc;
213  char line[128];
214  char num[64];
215  if(fiCounts==0)perc=0.0;
216  else perc=100.0/fiCounts*fiTrueCounts;
217  std::cout << "Name:" << GetName()
218  << " type:" << ClassName()
219  << " title:" << GetTitle() << std::endl;
220  if(fbHistogramLink)
221  std::cout << "Connected to histogram " << fxHistoName << std::endl;
222  if(fbEnabled) {
223  strcpy(line,"Is Checked ");
224  } else {
225  if(fbResult) strcpy(line,"Always True ");
226  else strcpy(line,"Always False ");
227  }
228  if(fbTrue) strcat(line,"normal ");
229  else strcat(line,"inverse ");
230  snprintf(num,63,", tested: %8d true: %8d is %3.0f%%",fiCounts,fiTrueCounts,perc);
231  strcat(line,num);
232  std::cout << line << std::endl;
233 }
234 // ---------------------------------------------------------
236 {
237  Float_t perc;
238  char line[128];
239  char num[64];
240  strcpy(num,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
241  Char_t *pc;
242  if(fiCounts==0) perc=0.0;
243  else perc=100.0/fiCounts*fiTrueCounts;
244  pc=num + (Int_t)perc/2;
245  *pc=0;
246  snprintf(line,127,"%-24s %8d %3.0f%% |%-50s|",GetName(),fiCounts,perc,num);
247  *pc='+';
248  std::cout << line << std::endl;
249 }
250 // -----------------------------------------------
251 void TGo4Condition::Print(Option_t* opt) const
252 {
253  //std::cout <<"MyPrint:"<<GetName() << std::endl;
254  TGo4Condition* localthis=const_cast<TGo4Condition*>(this);
255  TString option=opt;
256  option.ToLower();
257  if(option.IsNull() || option=="*")
258  {
259  // old default: we print bar graphics to std::cout
260  localthis->PrintBar();
261  }
262  else
263  {
264  // new printout of condition with different options:
265  TString textbuffer="\nCondition ";
266  textbuffer+=localthis->GetName();
267  if(localthis->IsPolygonType())
268  {
269  textbuffer+=" (Polygon type, 2-dim)";
270  }
271  else
272  {
273  textbuffer+=" (Window type,";
274  if(localthis->GetActiveCondition()->GetDimension()>1)
275  textbuffer+=" 2-dim)";
276  else
277  textbuffer+=" 1-dim)";
278  }
279 
280 
281  //textbuffer+="\n";
282  if(option.Contains("limits"))
283  textbuffer +=
284  TString::Format("\n! Xlow: \t\tXup: \t\tYlow: \t\tYup:\n %.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t",
285  localthis->GetXLow(),localthis->GetXUp(),localthis->GetYLow(),localthis->GetYUp());
286 
287  if(option.Contains("flags"))
288  textbuffer +=
289  TString::Format("\n! Status:\n! Enab.: \tVis.: \tRes.: \tTrue: \tCnts: \tTrueCnts:\n %d\t\t%d\t%d\t%d\t%d\t%d",
290  localthis->fbEnabled, localthis->IsVisible(), localthis->fbResult, localthis->fbTrue,
291  localthis->Counts(), localthis->TrueCounts());
292 
293  if(option.Contains("stats"))
294  {
295  // output of region statistics
296 
297  textbuffer+="\n! with";
298  TH1* hist=localthis->GetWorkHistogram();
299  if(hist)
300  {
301  textbuffer+=" histogram: ";
302  textbuffer+=hist->GetName();
303  textbuffer +=
304  TString::Format("\n! Int:\t\tXmax:\t\tYmax:\t\tCmax:\t\tXmean:\t\tYmean:\t\tXrms:\t\tYrms:\n %.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f",
305  localthis->GetIntegral(hist), localthis->GetXMax(hist),localthis->GetYMax(hist), localthis->GetCMax(hist),
306  localthis->GetMean(hist,1), localthis->GetMean(hist,2), localthis->GetRMS(hist,1), localthis->GetRMS(hist,2));
307  }
308  else
309  {
310  textbuffer+="out histogram";
311  }
312  }
313  // now check output mode:
314  if(option.Contains("go4log"))
315  {
316  TGo4Log::Message(1,textbuffer.Data());
317  }
318  else
319  {
320  std::cout << textbuffer.Data() << std::endl;
321  }
322  } //if(option.IsNull())
323 }
324 
325 // ---------------------------------------------------------
326 Bool_t TGo4Condition::UpdateFrom(TGo4Condition * cond, Bool_t counts)
327 {
328  fbTrue = cond->TGo4Condition::IsTrue();
329  fbFalse = cond->TGo4Condition::IsFalse();
330  fbResult = cond->TGo4Condition::FixedResult();
331  fbEnabled = cond->TGo4Condition::IsEnabled();
332  fbMarkReset = cond->fbMarkReset;
333  fbVisible=cond->TGo4Condition::IsVisible();
334  fbLabelDraw=cond->TGo4Condition::IsLabelDraw();
335  fbLimitsDraw=cond->TGo4Condition::IsLimitsDraw();
336  fbMultiEdit=cond->TGo4Condition::IsMultiEdit();
337  fbIntDraw= cond->TGo4Condition::IsIntDraw();
338  fbXMeanDraw= cond->TGo4Condition::IsXMeanDraw();
339  fbXRMSDraw= cond->TGo4Condition::IsXRMSDraw();
340  fbYMeanDraw= cond->TGo4Condition::IsYMeanDraw();
341  fbYRMSDraw= cond->TGo4Condition::IsYRMSDraw();
342  fbXMaxDraw= cond->TGo4Condition::IsXMaxDraw();
343  fbYMaxDraw= cond->TGo4Condition::IsYMaxDraw();
344  fbCMaxDraw= cond->TGo4Condition::IsCMaxDraw();
345  fbHistogramLink=cond->TGo4Condition::IsHistogramLink();
346  fxHistoName=cond->fxHistoName;
348  fiDim=cond->GetDimension();
349  if(counts){
350  fiCounts = cond->TGo4Condition::Counts();
351  fiTrueCounts = cond->TGo4Condition::TrueCounts();
352  fbMarkReset = false;
353  }
354  if(fbMarkReset){
355  ResetCounts();
356  fbMarkReset = false;
357  }
358 
359 return kTRUE;
360 }
361 
362 
363 void TGo4Condition::BuildUrlOptionArray(const char* rest_url_opt)
364 {
365  if(fxUrlOptionArray) {
366  fxUrlOptionArray->Delete();
367  delete fxUrlOptionArray;
368  fxUrlOptionArray=0; // bad implementation of Tokenize, many memory leak dangers!
369  }
370  TString options=rest_url_opt;
371  fxUrlOptionArray=options.Tokenize("&");
372 
373 
374 }
375 
376 
377 Bool_t TGo4Condition::UrlOptionHasKey(const char* key)
378 {
379  TObjArrayIter iter(fxUrlOptionArray);
380  TObject* cursor = 0;
381  while ((cursor = iter.Next()) != 0)
382  {
383  TObjString* curopt = dynamic_cast<TObjString*>(cursor);
384  if (curopt)
385  {
386  TString theOption = curopt->GetString();
387  if (theOption.Contains(key))
388  {
389  return kTRUE;
390  }
391  }
392  } // while
393  return kFALSE;
394 }
395 
396 TString TGo4Condition::GetUrlOptionAsString(const char* key, TString def_value)
397 {
398  TObjArrayIter iter(fxUrlOptionArray);
399  TObject* cursor=0;
400  TObjArray* valuearray;
401  while((cursor=iter.Next()) !=0)
402  {
403  TObjString* curopt=dynamic_cast<TObjString*>(cursor);
404  if(curopt)
405  {
406  TString theOption=curopt->GetString();
407  if(theOption.Contains(key)){
408  valuearray=theOption.Tokenize("=");
409  TString theValue= valuearray->Last()->GetName();
410  valuearray->Delete();
411  delete valuearray; // bad implementation of Tokenize, many memory leak dangers!
412  return theValue;
413  }
414  }
415  } // while
416  return def_value;
417 }
418 
419 
420 
421 Int_t TGo4Condition::GetUrlOptionAsInt(const char* key, Int_t def_value)
422 {
423  TString valstring=GetUrlOptionAsString(key,"");
424  if(valstring.IsNull())
425  return def_value;
426  else
427  return valstring.Atoi();
428 }
429 
430 Double_t TGo4Condition::GetUrlOptionAsDouble(const char* key, Double_t def_value)
431 {
432  TString valstring=GetUrlOptionAsString(key,"");
433  if(valstring.IsNull())
434  return def_value;
435  else
436  return valstring.Atof();
437 }
438 
439 
440 Bool_t TGo4Condition::UpdateFromUrl(const char* rest_url_opt){
441  TString message;
442  message.Form("TGo4Condition::UpdateFromUrl - condition %s: with url:%s", GetName(), rest_url_opt);
443  TGo4Log::Message(1,message.Data());
444  BuildUrlOptionArray(rest_url_opt); // split option string into separate key value entries
445 
446 
447  // all keywords are defined as static class variables of condition class
448 
449 
450  Int_t resetcounters=GetUrlOptionAsInt(TGo4Condition::fgxURL_RESET.Data(), -1);
451 
452  Int_t resultmode = GetUrlOptionAsInt(TGo4Condition::fgxURL_RESULT.Data(), -1);
453  Int_t invertmode = GetUrlOptionAsInt(TGo4Condition::fgxURL_INVERT.Data(), -1);
454  Int_t visible = GetUrlOptionAsInt(TGo4Condition::fgxURL_VISIBLE.Data(), -1);
455  Int_t labeldraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_LABEL.Data(), -1);
456  Int_t limitsdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_LIMITS.Data(), -1);
457  Int_t integraldraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_INTEGRAL.Data(), -1);
458  Int_t xmeandraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_XMEAN.Data(), -1);
459  Int_t xrmsdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_XRMS.Data(), -1);
460  Int_t ymeandraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_YMEAN.Data(), -1);
461  Int_t yrmsdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_YRMS.Data(), -1);
462  Int_t xmaxdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_XMAX.Data(), -1);
463  Int_t ymaxdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_YMAX.Data(), -1);
464  Int_t cmaxdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_CMAX.Data(), -1);
465 
466 
467 
468 
469  message.Form("Set condition %s:", GetName());
470 
471  if (resetcounters > 0)
472  {
473  ResetCounts();
474  message.Append(TString::Format(", resetcounters=%d", resetcounters));
475  }
476 
477  if (resultmode >= 0)
478  {
479  // same as in Go4 GUI condition editor:
480  switch (resultmode)
481  {
482  case 0:
483  Enable();
484  break;
485  case 1:
486  Disable(kTRUE);
487  break;
488  case 2:
489  Disable(kFALSE);
490  break;
491  default:
492  Enable();
493  break;
494  };
495  message.Append(TString::Format(", resultmode=%d", resultmode));
496  }
497 
498 
499 
500  if (invertmode >= 0)
501  {
502  // same as in Go4 GUI condition editor:
503  Invert(invertmode == 1);
504  message.Append(TString::Format(", invertmode=%d", invertmode));
505  }
506 
507  if (visible >= 0)
508  {
509  SetVisible(visible == 1);
510  message.Append(TString::Format(", visible=%d", visible));
511  }
512  if (labeldraw >= 0)
513  {
514  SetLabelDraw(labeldraw == 1);
515  message.Append(TString::Format(", labeldraw=%d", labeldraw));
516  }
517  if (limitsdraw >= 0)
518  {
519  SetLimitsDraw(limitsdraw == 1);
520  message.Append(TString::Format(", limitsdraw=%d", limitsdraw));
521  }
522  if (integraldraw >= 0)
523  {
524  SetIntDraw(integraldraw == 1);
525  message.Append(TString::Format(", intdraw=%d", integraldraw));
526  }
527  if (xmeandraw >= 0)
528  {
529  SetXMeanDraw(xmeandraw == 1);
530  message.Append(TString::Format(", xmeandraw=%d", xmeandraw));
531  }
532  if (xrmsdraw >= 0)
533  {
534  SetXRMSDraw(xrmsdraw == 1);
535  message.Append(TString::Format(", xrmsdraw=%d", xrmsdraw));
536  }
537  if (ymeandraw >= 0)
538  {
539  SetYMeanDraw(ymeandraw == 1);
540  message.Append(TString::Format(", ymeandraw=%d", ymeandraw));
541  }
542  if (yrmsdraw >= 0)
543  {
544  SetYRMSDraw(yrmsdraw == 1);
545  message.Append(TString::Format(", yrmsdraw=%d", yrmsdraw));
546  }
547  if (xmaxdraw >= 0)
548  {
549  SetXMaxDraw(xmaxdraw == 1);
550  message.Append(TString::Format(", xmaxdraw=%d", xmaxdraw));
551  }
552  if (ymaxdraw >= 0)
553  {
554  SetYMaxDraw(ymaxdraw == 1);
555  message.Append(TString::Format(", ymaxdraw=%d", ymaxdraw));
556  }
557  if (cmaxdraw >= 0)
558  {
559  SetCMaxDraw(cmaxdraw == 1);
560  message.Append(TString::Format(", cmaxdraw=%d", cmaxdraw));
561  }
562 
563 
564  TGo4Log::Message(1,message.Data());
565 
566  return kTRUE;
567 }
568 
569 
570 void TGo4Condition::GetValues(Int_t & dim, Double_t & xmin, Double_t & xmax, Double_t & ymin, Double_t & ymax)
571 {
572  xmin = GetXLow();
573  xmax = GetXUp();
574  ymin = GetYLow();
575  ymax = GetYUp();
576  dim = GetDimension();
577 
578 }
579 Double_t TGo4Condition::GetXLow(){return 0;}
580 Double_t TGo4Condition::GetXUp(){return 0;}
581 Double_t TGo4Condition::GetYLow(){return 0;}
582 Double_t TGo4Condition::GetYUp(){return 0;}
583 TCutG* TGo4Condition::GetCut(Bool_t owner){ return 0;}
584 Bool_t TGo4Condition::IsPolygonType(){return kFALSE;}
585 Bool_t TGo4Condition::IsArrayType(){return kFALSE;}
587 
590 {
591  return 0;
592 }
593 
595 {
596  return 1;
597 }
598 
600 {
601  Int_t size = sizeof(*this);
602  if (GetName()!=0) size+=strlen(GetName());
603  if (GetTitle()!=0) size+=strlen(GetTitle());
604  return size;
605 }
606 
608 {
609  fbMarkReset = on;
610 }
611 void TGo4Condition::Clear(Option_t* opt){
612 ResetCounts();
613 }
614 
615 void TGo4Condition::GetFlags(Bool_t* enabled, Bool_t* lastresult, Bool_t* markreset,
616  Bool_t* result, Bool_t* truevalue, Bool_t* falsevalue)
617 {
618  *enabled=fbEnabled;
619  *lastresult=fbLastResult;
620  *markreset=fbMarkReset;
621  *result=fbResult;
622  *truevalue=fbTrue;
623  *falsevalue=fbFalse;
624 }
625 void TGo4Condition::SetFlags(Bool_t enabled, Bool_t lastresult, Bool_t markreset,
626  Bool_t result, Bool_t truevalue, Bool_t falsevalue)
627 {
628  fbEnabled=enabled;
629  fbLastResult=lastresult;
630  fbMarkReset=markreset;
631  fbResult=result;
632  fbTrue=truevalue;
633  fbFalse=falsevalue;
634 }
635 
636 
637 
638 Double_t TGo4Condition::GetIntegral(TH1* histo, Option_t* opt)
639 {
640  return 0;
641 }
642 
643 Double_t TGo4Condition::GetMean(TH1* histo, Int_t axis)
644 {
645  return 0;
646 }
647 Double_t TGo4Condition::GetRMS(TH1* histo, Int_t axis)
648 {
649  return 0;
650 }
651 
652 Double_t TGo4Condition::GetSkewness(TH1* histo, Int_t axis)
653 {
654  return 0;
655 }
656 
657 Double_t TGo4Condition::GetCurtosis(TH1* histo, Int_t axis)
658 {
659  return 0;
660 }
661 
662 Double_t TGo4Condition::GetXMax(TH1* histo)
663 {
664  return 0;
665 }
666 Double_t TGo4Condition::GetYMax(TH1* histo)
667 {
668  return 0;
669 }
670 Double_t TGo4Condition::GetCMax(TH1* histo)
671 {
672  return 0;
673 }
674 
675 void TGo4Condition::Disable(Bool_t result)
676 {
677  fbEnabled=kFALSE;
678  fbResult=result;
679 }
680 
682 {
683  fbEnabled=kTRUE;
684 }
685 
686 
688 {
689  fbVisible=on;
690 }
691 
693 {
694  return fbVisible;
695 }
696 
698 {
699  fbHistogramLink=on;
700 }
701 
703 {
704  return (Bool_t) fbHistogramLink;
705 }
706 
708 {
709 fbLabelDraw=on;
710 }
711 
713 {
714 return fbLabelDraw;
715 }
716 
718 {
719 fbLimitsDraw=on;
720 }
721 
723 {
724 return fbLimitsDraw;
725 }
726 
728 {
729 fbIntDraw=on;
730 }
732 {
733 return fbIntDraw;
734 }
736 {
737 fbXMeanDraw=on;
738 }
740 {
741 return fbXMeanDraw;
742 }
744 {
745 fbXRMSDraw=on;
746 }
748 {
749 return fbXRMSDraw;
750 }
752 {
753 fbYMeanDraw=on;
754 }
756 {
757 return fbYMeanDraw;
758 }
760 {
761 fbYRMSDraw=on;
762 }
764 {
765 return fbYRMSDraw;
766 }
768 {
769 fbXMaxDraw=on;
770 }
772 {
773 return fbXMaxDraw;
774 }
776 {
777 fbYMaxDraw=on;
778 }
780 {
781 return fbYMaxDraw;
782 }
784 {
785 fbCMaxDraw=on;
786 }
788 {
789  return fbCMaxDraw;
790 }
791 
793 {
794  return fxNumFormat.Data();
795 }
796 void TGo4Condition::SetLabelNumFormat(const char* fmt)
797 {
798  fxNumFormat=fmt;
799 }
800 
801 
802 void TGo4Condition::SetHistogram(const char* name)
803 {
804  if ((name==0) || (*name==0)) {
805  fxHistoName = "";
806  fbHistogramLink = false;
807  } else {
808  fxHistoName = name;
809  fbHistogramLink = true;
810  }
811 }
812 
814 {
815  return fxHistoName.Data();
816 }
817 
819 {
820 // delete old painter, replace by the new one
821 // overwritten method in subclass may check if painter is correct type
822 
823 }
824 
825 
826 void TGo4Condition::Paint(Option_t* opt)
827 {
830  SetPainted(kTRUE);
831  fbStreamedCondition=kFALSE;
832 }
833 
834 if(!IsPainted()) return;
836 // condition subclass may not provide a real painter, then we skip painting:
837 if(fxPainter!=0)
838  {
839  fxPainter->SetCondition(this); // JAM2016
841  fxPainter->PaintLabel(opt);
842  }
843 }
844 
845 void TGo4Condition::Draw(Option_t* opt)
846 {
847 
848  //std::cout<<"TGo4Condition::Draw of instance:"<<(long) this << " with visible="<< TGo4Condition::IsVisible()<< std::endl;
850  if(gPad && gPad->GetListOfPrimitives()->FindObject(this)==0) {
851 
852  //UnDraw(); // JAM2016: do we need this? for switching condition between different pads...? no!
853  AppendPad(opt);
854  }
855  SetPainted(kTRUE);
856  } else{
857  //std::cout<<"TGo4Condition::Draw does undraw"<< std::endl;
858  UnDraw(opt);
859  }
860 }
861 
862 void TGo4Condition::UnDraw(Option_t* opt)
863 {
864  SetPainted(kFALSE);
865  gROOT->GetListOfCanvases()->RecursiveRemove(this);
866  //std::cout<<"TGo4Condition::UnDraw of instance:"<<(long) this << std::endl;
868  // condition subclass may not provide a real painter, then we skip unpainting:
869  if(fxPainter!=0) {
871  //if(strcmp(opt,"keeplabel"))
873  }
874 }
875 
877 {
879 }
880 
882 {
883  return 0;
884 }
885 
887 {
899 }
900 
902 {
914 }
915 
916 void TGo4Condition::ResetLabel(Option_t* opt)
917 {
918  if(fxPainter) {
919  fxPainter->UnPaintLabel(opt);
921  }
922 }
923 
925 {
926  fxHisto=histo;
927  //std::cout <<"TGo4Condition "<<(long) this <<" ::SetWorkHistogram deletes cuthistogram"<< (long) fxCutHis<<", new histogram is:"<<(long) histo << std::endl;
928  delete fxCutHis; // discard internal cut histogram
929  fxCutHis=0;
930 }
931 
933 {
934  if (fxPainter!=0) {
935  delete fxPainter;
936  fxPainter = 0;
937  }
938 }
939 
940 const char* TGo4Condition::MakeScript(std::ostream& out, const char* varname, Option_t* opt, const char* arrextraargs)
941 {
942  Bool_t savemacro = (opt!=0) && (strstr(opt,"savemacro")!=0);
943  Bool_t saveprefix = savemacro;
944 
945  const char* subname = strstr(opt, "name:");
946  if (subname != 0) { varname = subname + 5; saveprefix = kFALSE; }
947 
948  if (saveprefix) {
949  out << Form(" %s* %s = (%s*) go4->GetAnalysisCondition(\"%s\",\"%s\");",
950  ClassName(), varname, ClassName(), GetName(), ClassName()) << std::endl;
951  out << Form(" if (%s==0) {", varname) << std::endl;
952  out << Form(" TGo4Log::Error(\"Could not find condition %s of class %s\");", GetName(), ClassName()) << std::endl;
953  out << Form(" return;") << std::endl;
954  out << Form(" }") << std::endl << std::endl;
955  out << Form(" TGo4Log::Info(\"Set condition %s as saved at %s\");",
956  GetName(),TDatime().AsString()) << std::endl << std::endl;
957  } else
958  if (!savemacro && ((opt==0) || (strstr(opt, "nocreate")==0))) {
959  out << Form(" %s* %s = new %s(\"%s\"%s);", ClassName(), varname, ClassName(), GetName(), (arrextraargs ? arrextraargs : "")) << std::endl << std::endl;
960  }
961 
962  if (arrextraargs==0) {
963 
964  Bool_t enabled,last,mark,result,vtrue,vfalse;
965  GetFlags(&enabled, &last, &mark, &result, &vtrue, &vfalse);
966 
967  out << " // SetFlags(enabled,last,mark,result,vtrue,vfalse);" << std::endl;
968 
969  out << Form(" %s%s->SetFlags(%s, %s, %s, %s, %s, %s);",
970  savemacro ? "if (flags) " : "", varname,
971  enabled ? "kTRUE" : "kFALSE",
972  last ? "kTRUE" : "kFALSE",
973  mark ? "kTRUE" : "kFALSE",
974  result ? "kTRUE" : "kFALSE",
975  vtrue ? "kTRUE" : "kFALSE",
976  vfalse ? "kTRUE" : "kFALSE") << std::endl;
977 
978  out << Form(" %s%s->SetCounts(%d, %d);",
979  savemacro ? "if (counters) " : "", varname,
980  TrueCounts(), Counts()) << std::endl;
981 
982  if (savemacro)
983  out << Form(" if (reset) %s->ResetCounts();", varname) << std::endl;
984  }
985 
986  return varname;
987 }
TString fxNumFormat
Bool_t IsHistogramLink()
virtual Bool_t IsYRMSDraw()
static Bool_t fgbXRMSDRAW
static TString fgxURL_CMAX
static Bool_t fgbYMAXDRAW
Bool_t UrlOptionHasKey(const char *key)
static TString fgxURL_XRMS
static Bool_t fgbLIMITSDRAW
virtual Bool_t IsLabelDraw()
Bool_t fbLastResult
virtual Double_t GetXMax(TH1 *histo)
virtual Double_t GetMean(TH1 *histo, Int_t axis=1)
virtual void SetLimitsDraw(Bool_t on)
static TString fgxURL_RESET
virtual void PaintCondition(Option_t *opt="")
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
virtual Double_t GetCMax(TH1 *histo)
virtual void UnDraw(Option_t *opt="")
virtual Double_t GetCurtosis(TH1 *histo, Int_t axis=1)
Bool_t fbMarkReset
virtual void SetYRMSDraw(Bool_t on)
Int_t GetDimension()
virtual void SetPainter(TGo4ConditionPainter *painter)
virtual void UnPaintLabel(Option_t *opt="")
virtual void SetLabelNumFormat(const char *fmt)
TString GetUrlOptionAsString(const char *key, TString def_value)
virtual Bool_t IsXMeanDraw()
static Bool_t fgbCMAXDRAW
virtual void UnPaintCondition(Option_t *opt="")
virtual void PrintCondition(Bool_t full=kTRUE)
static TString fgxURL_YMEAN
virtual Bool_t IsLimitsDraw()
virtual Double_t GetSkewness(TH1 *histo, Int_t axis=1)
virtual ~TGo4Condition()
virtual Bool_t IsYMeanDraw()
virtual Double_t GetYUp()
Bool_t fbOwnedByEditor
static Bool_t fgbLABELDRAW
Bool_t fbHistogramLink
virtual Int_t GetCurrentIndex()
void BuildUrlOptionArray(const char *rest_url_opt)
virtual void SetVisible(Bool_t on)
static TString fgxNUMFORMAT
virtual Int_t GetNumberOfConditions()
static TString fgxURL_RESULT
virtual void SetCurrentIndex(Int_t ix)
virtual void SetXMaxDraw(Bool_t on)
static Bool_t fgbXMEANDRAW
Bool_t fbYMeanDraw
virtual Bool_t IsIntDraw()
virtual void PaintLabel(Option_t *opt="")
Bool_t fbIsPainted
virtual void ResetCounts()
virtual void Draw(Option_t *opt="")
virtual Bool_t IsXRMSDraw()
static TString fgxURL_INTEGRAL
virtual void SetYMaxDraw(Bool_t on)
void SetPainted(Bool_t on)
virtual void SetCounts(Int_t truecounts, Int_t counts)
virtual void Enable()
virtual void PrintBar()
Bool_t fbMultiEdit
virtual Bool_t IsXMaxDraw()
virtual Bool_t UpdateFromUrl(const char *rest_url_opt)
virtual Bool_t IsVisible()
virtual void Pop()
virtual void Clear(Option_t *opt="")
void SetHistogramLink(Bool_t on)
virtual void SetIntDraw(Bool_t on)
Bool_t fbXMeanDraw
virtual void Print(Option_t *opt="") const
static Bool_t fgbYMEANDRAW
virtual void SetYMeanDraw(Bool_t on)
virtual void SetFlags(Bool_t enabled, Bool_t lastresult, Bool_t markreset, Bool_t result, Bool_t truevalue, Bool_t falsevalue)
void SetHistogram(const char *name)
static TString fgxURL_VISIBLE
static TString fgxURL_INVERT
Bool_t IsPainted() const
static const char * Message(Int_t prio, const char *text,...)
Definition: TGo4Log.cxx:209
virtual void Disable(Bool_t result)
TH1 * GetWorkHistogram()
virtual void SetCondition(TGo4Condition *con)
virtual const char * GetLabelNumFormat()
void ResetLabel(Option_t *opt="reset")
const char * MakeScript(std::ostream &out, const char *varname, Option_t *opt="", const char *arrextraargs=0)
virtual Double_t GetXLow()
static TString fgxURL_YMAX
static Bool_t fgbXMAXDRAW
virtual void SetXMeanDraw(Bool_t on)
virtual TGo4ConditionPainter * CreatePainter()
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()
virtual void MarkReset(Bool_t on)
virtual void Paint(Option_t *opt="")
#define GO4TRACE(X)
Definition: TGo4Log.h:26
TGo4ConditionPainter * fxPainter
static TString fgxURL_LIMITS
virtual Bool_t IsArrayType()
virtual Double_t GetYMax(TH1 *histo)
virtual void SetLabelDraw(Bool_t on)
static Bool_t fgbYRMSDRAW
void SetWorkHistogram(TH1 *histo)
TObjArray * fxUrlOptionArray
virtual void GetValues(Int_t &dim, Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2)
virtual Int_t GetMemorySize()
virtual Bool_t IsPolygonType()
Int_t GetUrlOptionAsInt(const char *key, Int_t def_value)
virtual Double_t GetXUp()
virtual Double_t GetRMS(TH1 *histo, Int_t axis=1)
const char * GetLinkedHistogram()
virtual Int_t TrueCounts()
virtual Bool_t IsCMaxDraw()
virtual void SetXRMSDraw(Bool_t on)
virtual Int_t Counts()
static TString fgxURL_XMEAN
TString fxHistoName
static TString fgxURL_YRMS
virtual void DisplayToFront(Option_t *opt="")
virtual void AddCondition(TGo4Condition *next)
Bool_t fbLimitsDraw
static TString fgxURL_LABEL
virtual TCutG * GetCut(Bool_t owner)
static const Double_t fgdUPDATEEPSILON
virtual Bool_t IsYMaxDraw()
Double_t fdUpdateEpsilon
virtual Double_t GetIntegral(TH1 *histo, Option_t *opt="")
virtual TGo4Condition * GetActiveCondition()
virtual void Invert(Bool_t on)
Double_t GetUrlOptionAsDouble(const char *key, Double_t def_value)
Bool_t fbLabelDraw
static TString fgxURL_XMAX
virtual void SetCMaxDraw(Bool_t on)
Bool_t fbStreamedCondition
static Bool_t fgbINTDRAW
virtual Double_t GetYLow()