GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Condition.cxx
Go to the documentation of this file.
1 // $Id: TGo4Condition.cxx 3077 2021-03-13 13:23:52Z 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 "TGo4Condition.h"
15 
16 #include "TH1.h"
17 #include "TROOT.h"
18 #include "TObjArray.h"
19 #include "TObjString.h"
20 #include "TVirtualPad.h"
21 #include "TDatime.h"
22 
23 #include "TGo4Log.h"
24 #include "TGo4ConditionPainter.h"
25 
26 const Double_t TGo4Condition::fgdUPDATEEPSILON=0.01;
27 
28 Bool_t TGo4Condition::fgbLABELDRAW=kTRUE;
29 Bool_t TGo4Condition::fgbLIMITSDRAW=kTRUE;
30 Bool_t TGo4Condition::fgbINTDRAW=kTRUE;
31 Bool_t TGo4Condition::fgbXMEANDRAW=kTRUE;
32 Bool_t TGo4Condition::fgbXRMSDRAW=kTRUE;
33 Bool_t TGo4Condition::fgbYMEANDRAW=kFALSE;
34 Bool_t TGo4Condition::fgbYRMSDRAW=kFALSE;
35 Bool_t TGo4Condition::fgbXMAXDRAW=kTRUE;
36 Bool_t TGo4Condition::fgbYMAXDRAW=kFALSE;
37 Bool_t TGo4Condition::fgbCMAXDRAW=kTRUE;
38 TString TGo4Condition::fgxNUMFORMAT="%.4E";
39 
41 TString TGo4Condition::fgxURL_RESET="resetcounters";
42 TString TGo4Condition::fgxURL_RESULT="resultmode";
43 TString TGo4Condition::fgxURL_INVERT="invertmode";
44 TString TGo4Condition::fgxURL_VISIBLE="visible";
45 TString TGo4Condition::fgxURL_LABEL="labeldraw";
46 TString TGo4Condition::fgxURL_LIMITS="limitsdraw";
47 TString TGo4Condition::fgxURL_INTEGRAL="intdraw";
48 TString TGo4Condition::fgxURL_XMEAN="xmeandraw";
49 TString TGo4Condition::fgxURL_XRMS="xrmsdraw";
50 TString TGo4Condition::fgxURL_YMEAN="ymeandraw";
51 TString TGo4Condition::fgxURL_YRMS="yrmsdraw";
52 TString TGo4Condition::fgxURL_XMAX="xmaxdraw";
53 TString TGo4Condition::fgxURL_YMAX="ymaxdraw";
54 TString TGo4Condition::fgxURL_CMAX="cmaxdraw";
55 
56 // -----------------------------------------------
57 // Constructors
58 // ---------------------------------------------------------
60  TNamed(),
61  TAttLine(),
62  TAttFill(),
63  fxPainter(0),
64  fxUrlOptionArray(0),
65  fxHisto(0),
66  fiIsChanged(0)
67 {
68  GO4TRACE((15,"TGo4Condition::TGo4Condition()",__LINE__, __FILE__));
69  fiDim=0;
70  fbEnabled = false;
71  fbResult = true;
72  fbTrue = true;
73  fbFalse = false;
74  fbMarkReset = false;
75  fiCounts = 0;
76  fiTrueCounts= 0;
77  fbVisible=true;
78  fbMultiEdit= true;
79  fbHistogramLink=false;
81  fbIsPainted=kFALSE;
82  fbOwnedByEditor=kFALSE;
83  fbStreamedCondition=kTRUE;
85 }
86 
87 // -----------------------------------------------
88 TGo4Condition::TGo4Condition(const char* name, const char* title) :
89  TNamed(name, title),
90  TAttLine(),
91  TAttFill(),
92  fxPainter(0),
93  fxUrlOptionArray(0),
94  fxHisto(0),
95  fiIsChanged(0)
96 {
97  GO4TRACE((15,"TGo4Condition::TGo4Condition(const char*)",__LINE__, __FILE__));
98  fiDim=0;
99  fbEnabled = false;
100  fbResult = true;
101  fbTrue = true;
102  fbFalse = false;
103  fbMarkReset = false;
104  fiCounts = 0;
105  fiTrueCounts = 0;
106  fbVisible=true;
107  fbMultiEdit= true;
108  fbHistogramLink=false;
110  fbIsPainted=kFALSE;
111  fbOwnedByEditor=kFALSE;
112  fbStreamedCondition=kFALSE;
113  InitLabelStyle();
114 }
115 
116 // ---------------------------------------------------------
118 {
119  GO4TRACE((15,"TGo4Condition::~TGo4Condition()",__LINE__, __FILE__));
120  //std::cout <<"TGo4Condition "<<(long) this <<" dtor " << std::endl;
121  //UnDraw("reset");
122  if(fxPainter) {
123  delete fxPainter;
124  fxPainter = 0;
125  }
126 
127  if (fxUrlOptionArray) {
128  fxUrlOptionArray->Delete();
129  delete fxUrlOptionArray;
130  fxUrlOptionArray = 0;
131  }
132 }
133 
134 // ---------------------------------------------------------
136 {
137  fiCounts++;
138  return true;
139 }
140 // ---------------------------------------------------------
141 
143 {
144 GO4TRACE((14,"TGo4Condition::AddCondition(TGo4Condition*)",__LINE__, __FILE__));
145 }
146 // ---------------------------------------------------------
148 {
149 GO4TRACE((12,"TGo4Condition::IncTrueCounts()",__LINE__, __FILE__));
150  fiTrueCounts++;
151 }
152 // ---------------------------------------------------------
154 {
155 GO4TRACE((12,"TGo4Condition::IncCounts()",__LINE__, __FILE__));
156  fiCounts++;
157 }
158 // ---------------------------------------------------------
160 {
161 GO4TRACE((12,"TGo4Condition::Counts()",__LINE__, __FILE__));
162  return fiCounts;
163 }
164 // ---------------------------------------------------------
166 {
167 GO4TRACE((12,"TGo4Condition::TrueCounts()",__LINE__, __FILE__));
168  return fiTrueCounts;
169 }
170 // ---------------------------------------------------------
172 {
173 GO4TRACE((12,"TGo4Condition::ResetCounts()",__LINE__, __FILE__));
174  fiTrueCounts=0;
175  fiCounts=0;
176 }
177 // ---------------------------------------------------------
178 void TGo4Condition::SetCounts(Int_t truecounts, Int_t counts)
179 {
180 GO4TRACE((12,"TGo4Condition::SetCounts()",__LINE__, __FILE__));
181  fiTrueCounts=truecounts;
182  fiCounts=counts;
183 }
184 
185 
186 // ---------------------------------------------------------
187 void TGo4Condition::Invert(Bool_t on)
188 {
189 GO4TRACE((12,"TGo4Condition::Invert",__LINE__, __FILE__));
190 fbTrue = on ^ true;
191 fbFalse = on ^ false;
192 }
193 
194 // ---------------------------------------------------------
196 {
197  std::cout << "Name:" << GetName() << " type:" << ClassName() << " title:" << GetTitle() << std::endl;
198  if (fbHistogramLink)
199  std::cout << "Connected to histogram " << fxHistoName << std::endl;
200 
201  Float_t perc = (fiCounts == 0) ? 0.0 : 100.0 / fiCounts * fiTrueCounts;
202 
203  TString line;
204  if (fbEnabled)
205  line = "Is Checked ";
206  else if (fbResult)
207  line = "Always True ";
208  else
209  line = "Always False ";
210  line.Append(fbTrue ? "normal " : "inverse ");
211  line.Append(TString::Format(", tested: %8d true: %8d is %3.0f%s", fiCounts, fiTrueCounts, perc, "%"));
212  std::cout << line << std::endl;
213 }
214 // ---------------------------------------------------------
216 {
217  Float_t perc = (fiCounts==0) ? 0. : 100.0/fiCounts*fiTrueCounts;
218  if (perc < 0)
219  perc = 0;
220  else if (perc>100)
221  perc = 100;
222 
223  char num[64];
224  strncpy(num, "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++", sizeof(num));
225  char *pc = num + (Int_t)perc/2;
226  *pc = 0;
227  std::cout << TString::Format("%-24s %8d %3.0f%s |%-50s|",GetName(),fiCounts,perc,"%",num) << std::endl;
228 }
229 // -----------------------------------------------
230 void TGo4Condition::Print(Option_t* opt) const
231 {
232  //std::cout <<"MyPrint:"<<GetName() << std::endl;
233  TGo4Condition* localthis=const_cast<TGo4Condition*>(this);
234  TString option=opt;
235  option.ToLower();
236  if (option.IsNull() || option == "*") {
237  // old default: we print bar graphics to std::cout
238  localthis->PrintBar();
239  } else {
240  // new printout of condition with different options:
241  TString textbuffer = "\nCondition ";
242  textbuffer.Append(GetName());
243  if (localthis->IsPolygonType()) {
244  textbuffer.Append(" (Polygon type, 2-dim)");
245  } else {
246  // JAM2019: use this kludge to avoid changing the baseclass api...
247  if (InheritsFrom("TGo4ListCond")) {
248  textbuffer.Append(" (Whitelist type, 1-dim)");
249  } else {
250 
251  textbuffer.Append(" (Window type,");
252  if (localthis->GetActiveCondition()->GetDimension() > 1)
253  textbuffer.Append(" 2-dim)");
254  else
255  textbuffer.Append(" 1-dim)");
256  }
257  }
258 
259  // textbuffer+="\n";
260  if (option.Contains("limits"))
261  textbuffer.Append(
262  TString::Format("\n! Xlow: \t\tXup: \t\tYlow: \t\tYup:\n %.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t",
263  localthis->GetXLow(), localthis->GetXUp(), localthis->GetYLow(), localthis->GetYUp()));
264 
265  if (option.Contains("flags"))
266  textbuffer.Append(TString::Format(
267  "\n! Status:\n! Enab.: \tVis.: \tRes.: \tTrue: \tCnts: \tTrueCnts:\n %d\t\t%d\t%d\t%d\t%d\t%d",
268  localthis->fbEnabled, localthis->IsVisible(), localthis->fbResult, localthis->fbTrue, localthis->Counts(),
269  localthis->TrueCounts()));
270 
271  if (option.Contains("stats")) {
272  // output of region statistics
273 
274  textbuffer.Append("\n! with");
275  TH1 *hist = localthis->GetWorkHistogram();
276  if (hist) {
277  textbuffer.Append(" histogram: ");
278  textbuffer.Append(hist->GetName());
279  textbuffer.Append(
280  TString::Format("\n! Int:\t\tXmax:\t\tYmax:\t\tCmax:\t\tXmean:\t\tYmean:\t\tXrms:\t\tYrms:\n "
281  "%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f",
282  localthis->GetIntegral(hist), localthis->GetXMax(hist), localthis->GetYMax(hist),
283  localthis->GetCMax(hist), localthis->GetMean(hist, 1), localthis->GetMean(hist, 2),
284  localthis->GetRMS(hist, 1), localthis->GetRMS(hist, 2)));
285  } else {
286  textbuffer.Append("out histogram");
287  }
288  }
289  // now check output mode:
290  if (option.Contains("go4log")) {
291  TGo4Log::Message(1, textbuffer.Data());
292  } else {
293  std::cout << textbuffer.Data() << std::endl;
294  }
295  } // if(option.IsNull())
296 }
297 
298 // ---------------------------------------------------------
299 Bool_t TGo4Condition::UpdateFrom(TGo4Condition * cond, Bool_t counts)
300 {
301  fbTrue = cond->TGo4Condition::IsTrue();
302  fbFalse = cond->TGo4Condition::IsFalse();
303  fbResult = cond->TGo4Condition::FixedResult();
304  fbEnabled = cond->TGo4Condition::IsEnabled();
305  fbMarkReset = cond->fbMarkReset;
306  fbVisible=cond->TGo4Condition::IsVisible();
307  fbLabelDraw=cond->TGo4Condition::IsLabelDraw();
308  fbLimitsDraw=cond->TGo4Condition::IsLimitsDraw();
309  fbMultiEdit=cond->TGo4Condition::IsMultiEdit();
310  fbIntDraw= cond->TGo4Condition::IsIntDraw();
311  fbXMeanDraw= cond->TGo4Condition::IsXMeanDraw();
312  fbXRMSDraw= cond->TGo4Condition::IsXRMSDraw();
313  fbYMeanDraw= cond->TGo4Condition::IsYMeanDraw();
314  fbYRMSDraw= cond->TGo4Condition::IsYRMSDraw();
315  fbXMaxDraw= cond->TGo4Condition::IsXMaxDraw();
316  fbYMaxDraw= cond->TGo4Condition::IsYMaxDraw();
317  fbCMaxDraw= cond->TGo4Condition::IsCMaxDraw();
318  fbHistogramLink=cond->TGo4Condition::IsHistogramLink();
319  fxHistoName=cond->fxHistoName;
321  fiDim=cond->GetDimension();
322  if(counts){
323  fiCounts = cond->TGo4Condition::Counts();
324  fiTrueCounts = cond->TGo4Condition::TrueCounts();
325  fbMarkReset = false;
326  }
327  if(fbMarkReset){
328  ResetCounts();
329  fbMarkReset = false;
330  }
331 
332  return kTRUE;
333 }
334 
335 void TGo4Condition::BuildUrlOptionArray(const char* rest_url_opt)
336 {
337  if(fxUrlOptionArray) {
338  fxUrlOptionArray->Delete();
339  delete fxUrlOptionArray;
340  fxUrlOptionArray=0; // bad implementation of Tokenize, many memory leak dangers!
341  }
342  TString options = rest_url_opt;
343  fxUrlOptionArray = options.Tokenize("&");
344 }
345 
346 Bool_t TGo4Condition::UrlOptionHasKey(const char* key)
347 {
348  TObjArrayIter iter(fxUrlOptionArray);
349  TObject *cursor = 0;
350  while ((cursor = iter.Next()) != 0) {
351  TObjString *curopt = dynamic_cast<TObjString *>(cursor);
352  if (curopt) {
353  TString theOption = curopt->GetString();
354  if (theOption.Contains(key)) {
355  return kTRUE;
356  }
357  }
358  } // while
359  return kFALSE;
360 }
361 
362 TString TGo4Condition::GetUrlOptionAsString(const char* key, TString def_value)
363 {
364  TObjArrayIter iter(fxUrlOptionArray);
365  TObject *cursor = 0;
366  TObjArray *valuearray;
367  while ((cursor = iter.Next()) != 0) {
368  TObjString *curopt = dynamic_cast<TObjString *>(cursor);
369  if (curopt) {
370  TString theOption = curopt->GetString();
371  if (theOption.Contains(key)) {
372  valuearray = theOption.Tokenize("=");
373  TString theValue = valuearray->Last()->GetName();
374  valuearray->Delete();
375  delete valuearray; // bad implementation of Tokenize, many memory leak dangers!
376  return theValue;
377  }
378  }
379  } // while
380  return def_value;
381 }
382 
383 Int_t TGo4Condition::GetUrlOptionAsInt(const char* key, Int_t def_value)
384 {
385  TString valstring = GetUrlOptionAsString(key, "");
386  if (valstring.IsNull())
387  return def_value;
388  else
389  return valstring.Atoi();
390 }
391 
392 Double_t TGo4Condition::GetUrlOptionAsDouble(const char* key, Double_t def_value)
393 {
394  TString valstring=GetUrlOptionAsString(key,"");
395  if(valstring.IsNull())
396  return def_value;
397  else
398  return valstring.Atof();
399 }
400 
401 
402 Bool_t TGo4Condition::UpdateFromUrl(const char* rest_url_opt)
403 {
404  TString message;
405  message.Form("TGo4Condition::UpdateFromUrl - condition %s: with url:%s", GetName(), rest_url_opt);
406  TGo4Log::Message(1,message.Data());
407  BuildUrlOptionArray(rest_url_opt); // split option string into separate key value entries
408 
409 
410  // all keywords are defined as static class variables of condition class
411 
412  Int_t resetcounters=GetUrlOptionAsInt(TGo4Condition::fgxURL_RESET.Data(), -1);
413 
414  Int_t resultmode = GetUrlOptionAsInt(TGo4Condition::fgxURL_RESULT.Data(), -1);
415  Int_t invertmode = GetUrlOptionAsInt(TGo4Condition::fgxURL_INVERT.Data(), -1);
416  Int_t visible = GetUrlOptionAsInt(TGo4Condition::fgxURL_VISIBLE.Data(), -1);
417  Int_t labeldraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_LABEL.Data(), -1);
418  Int_t limitsdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_LIMITS.Data(), -1);
419  Int_t integraldraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_INTEGRAL.Data(), -1);
420  Int_t xmeandraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_XMEAN.Data(), -1);
421  Int_t xrmsdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_XRMS.Data(), -1);
422  Int_t ymeandraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_YMEAN.Data(), -1);
423  Int_t yrmsdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_YRMS.Data(), -1);
424  Int_t xmaxdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_XMAX.Data(), -1);
425  Int_t ymaxdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_YMAX.Data(), -1);
426  Int_t cmaxdraw = GetUrlOptionAsInt(TGo4Condition::fgxURL_CMAX.Data(), -1);
427 
428  message.Form("Set condition %s:", GetName());
429 
430  if (resetcounters > 0) {
431  ResetCounts();
432  message.Append(TString::Format(", resetcounters=%d", resetcounters));
433  }
434 
435  if (resultmode >= 0) {
436  // same as in Go4 GUI condition editor:
437  switch (resultmode) {
438  case 0: Enable(); break;
439  case 1: Disable(kTRUE); break;
440  case 2: Disable(kFALSE); break;
441  default: Enable(); break;
442  };
443  message.Append(TString::Format(", resultmode=%d", resultmode));
444  }
445 
446  if (invertmode >= 0) {
447  // same as in Go4 GUI condition editor:
448  Invert(invertmode == 1);
449  message.Append(TString::Format(", invertmode=%d", invertmode));
450  }
451 
452  if (visible >= 0) {
453  SetVisible(visible == 1);
454  message.Append(TString::Format(", visible=%d", visible));
455  }
456  if (labeldraw >= 0) {
457  SetLabelDraw(labeldraw == 1);
458  message.Append(TString::Format(", labeldraw=%d", labeldraw));
459  }
460  if (limitsdraw >= 0) {
461  SetLimitsDraw(limitsdraw == 1);
462  message.Append(TString::Format(", limitsdraw=%d", limitsdraw));
463  }
464  if (integraldraw >= 0) {
465  SetIntDraw(integraldraw == 1);
466  message.Append(TString::Format(", intdraw=%d", integraldraw));
467  }
468  if (xmeandraw >= 0) {
469  SetXMeanDraw(xmeandraw == 1);
470  message.Append(TString::Format(", xmeandraw=%d", xmeandraw));
471  }
472  if (xrmsdraw >= 0) {
473  SetXRMSDraw(xrmsdraw == 1);
474  message.Append(TString::Format(", xrmsdraw=%d", xrmsdraw));
475  }
476  if (ymeandraw >= 0) {
477  SetYMeanDraw(ymeandraw == 1);
478  message.Append(TString::Format(", ymeandraw=%d", ymeandraw));
479  }
480  if (yrmsdraw >= 0) {
481  SetYRMSDraw(yrmsdraw == 1);
482  message.Append(TString::Format(", yrmsdraw=%d", yrmsdraw));
483  }
484  if (xmaxdraw >= 0) {
485  SetXMaxDraw(xmaxdraw == 1);
486  message.Append(TString::Format(", xmaxdraw=%d", xmaxdraw));
487  }
488  if (ymaxdraw >= 0) {
489  SetYMaxDraw(ymaxdraw == 1);
490  message.Append(TString::Format(", ymaxdraw=%d", ymaxdraw));
491  }
492  if (cmaxdraw >= 0) {
493  SetCMaxDraw(cmaxdraw == 1);
494  message.Append(TString::Format(", cmaxdraw=%d", cmaxdraw));
495  }
496 
497  TGo4Log::Message(1, message.Data());
498 
499  return kTRUE;
500 }
501 
502 
503 void TGo4Condition::GetValues(Int_t & dim, Double_t & xmin, Double_t & xmax, Double_t & ymin, Double_t & ymax)
504 {
505  xmin = GetXLow();
506  xmax = GetXUp();
507  ymin = GetYLow();
508  ymax = GetYUp();
509  dim = GetDimension();
510 
511 }
512 
514 {
515  Int_t size = sizeof(*this);
516  if (GetName()!=0) size+=strlen(GetName());
517  if (GetTitle()!=0) size+=strlen(GetTitle());
518  return size;
519 }
520 
522 {
523  fbMarkReset = on;
524 }
525 
526 void TGo4Condition::Clear(Option_t *)
527 {
528  ResetCounts();
529 }
530 
531 void TGo4Condition::GetFlags(Bool_t *enabled, Bool_t *lastresult, Bool_t *markreset, Bool_t *result, Bool_t *truevalue,
532  Bool_t *falsevalue)
533 {
534  *enabled = fbEnabled;
535  *lastresult = fbLastResult;
536  *markreset = fbMarkReset;
537  *result = fbResult;
538  *truevalue = fbTrue;
539  *falsevalue = fbFalse;
540 }
541 
542 void TGo4Condition::SetFlags(Bool_t enabled, Bool_t lastresult, Bool_t markreset, Bool_t result, Bool_t truevalue,
543  Bool_t falsevalue)
544 {
545  fbEnabled = enabled;
546  fbLastResult = lastresult;
547  fbMarkReset = markreset;
548  fbResult = result;
549  fbTrue = truevalue;
550  fbFalse = falsevalue;
551 }
552 
553 void TGo4Condition::Disable(Bool_t result)
554 {
555  fbEnabled=kFALSE;
556  fbResult=result;
557 }
558 
560 {
561  fbEnabled=kTRUE;
562 }
563 
564 void TGo4Condition::SetHistogram(const char* name)
565 {
566  if ((name==0) || (*name==0)) {
567  fxHistoName = "";
568  fbHistogramLink = false;
569  } else {
570  fxHistoName = name;
571  fbHistogramLink = true;
572  }
573 }
574 
576 {
577  return fxHistoName.Data();
578 }
579 
581 {
582 // delete old painter, replace by the new one
583 // overwritten method in subclass may check if painter is correct type
584 }
585 
586 
587 void TGo4Condition::Paint(Option_t* opt)
588 {
590  if (fbStreamedCondition) {
591  SetPainted(kTRUE);
592  fbStreamedCondition = kFALSE;
593  }
594 
595  if (!IsPainted())
596  return;
597  if (fxPainter == 0)
599  // condition subclass may not provide a real painter, then we skip painting:
600  if (fxPainter != 0) {
601  fxPainter->SetCondition(this); // JAM2016
603  fxPainter->PaintLabel(opt);
604  }
605 }
606 
607 void TGo4Condition::Draw(Option_t* opt)
608 {
609  // std::cout<<"TGo4Condition::Draw of instance:"<<(long) this << " with visible="<< TGo4Condition::IsVisible()<<
610  // std::endl;
611  if (TGo4Condition::IsVisible()) {
612  if (gPad && gPad->GetListOfPrimitives()->FindObject(this) == 0) {
613 
614  // UnDraw(); // JAM2016: do we need this? for switching condition between different pads...? no!
615  AppendPad(opt);
616  }
617  SetPainted(kTRUE);
618  } else {
619  // std::cout<<"TGo4Condition::Draw does undraw"<< std::endl;
620  UnDraw(opt);
621  }
622 }
623 
624 void TGo4Condition::UnDraw(Option_t* opt)
625 {
626  SetPainted(kFALSE);
627  gROOT->GetListOfCanvases()->RecursiveRemove(this);
628  //std::cout<<"TGo4Condition::UnDraw of instance:"<<(long) this << std::endl;
630  // condition subclass may not provide a real painter, then we skip unpainting:
631  if(fxPainter!=0) {
633  //if(strcmp(opt,"keeplabel"))
635  }
636 }
637 
639 {
641 }
642 
644 {
645  return 0;
646 }
647 
649 {
661 }
662 
664 {
676 }
677 
678 void TGo4Condition::SetGlobalStyle(Bool_t LABELDRAW, Bool_t LIMITSDRAW, Bool_t INTDRAW,
679  Bool_t XMEANDRAW, Bool_t YMEANDRAW, Bool_t XRMSDRAW, Bool_t YRMSDRAW,
680  Bool_t XMAXDRAW, Bool_t YMAXDRAW, Bool_t CMAXDRAW, const char *NUMFORMAT)
681 {
682  TGo4Condition::fgbLABELDRAW = LABELDRAW;
683  TGo4Condition::fgbLIMITSDRAW = LIMITSDRAW;
684  TGo4Condition::fgbINTDRAW = INTDRAW;
685  TGo4Condition::fgbXMEANDRAW = XMEANDRAW;
686  TGo4Condition::fgbYMEANDRAW = YMEANDRAW;
687  TGo4Condition::fgbXRMSDRAW = XRMSDRAW;
688  TGo4Condition::fgbYRMSDRAW = YRMSDRAW;
689  TGo4Condition::fgbXMAXDRAW = XMAXDRAW;
690  TGo4Condition::fgbYMAXDRAW = YMAXDRAW;
691  TGo4Condition::fgbCMAXDRAW = CMAXDRAW;
692  TGo4Condition::fgxNUMFORMAT = NUMFORMAT;
693 }
694 
695 void TGo4Condition::GetGlobalStyle(Bool_t &LABELDRAW, Bool_t &LIMITSDRAW, Bool_t &INTDRAW,
696  Bool_t &XMEANDRAW, Bool_t &YMEANDRAW, Bool_t &XRMSDRAW, Bool_t &YRMSDRAW,
697  Bool_t &XMAXDRAW, Bool_t &YMAXDRAW, Bool_t &CMAXDRAW, TString &NUMFORMAT)
698 {
699  LABELDRAW = TGo4Condition::fgbLABELDRAW;
700  LIMITSDRAW = TGo4Condition::fgbLIMITSDRAW;
701  INTDRAW = TGo4Condition::fgbINTDRAW;
702  XMEANDRAW = TGo4Condition::fgbXMEANDRAW;
703  YMEANDRAW = TGo4Condition::fgbYMEANDRAW;
704  XRMSDRAW = TGo4Condition::fgbXRMSDRAW;
705  YRMSDRAW = TGo4Condition::fgbYRMSDRAW;
706  XMAXDRAW = TGo4Condition::fgbXMAXDRAW;
707  YMAXDRAW = TGo4Condition::fgbYMAXDRAW;
708  CMAXDRAW = TGo4Condition::fgbCMAXDRAW;
709  NUMFORMAT = TGo4Condition::fgxNUMFORMAT;
710 }
711 
712 
713 void TGo4Condition::ResetLabel(Option_t* opt)
714 {
715  if(fxPainter) {
716  fxPainter->UnPaintLabel(opt);
718  }
719 }
720 
722 {
723  if (fxPainter!=0) {
724  delete fxPainter;
725  fxPainter = 0;
726  }
727 }
728 
729 const char* TGo4Condition::MakeScript(std::ostream& out, const char* varname, Option_t* opt, const char* arrextraargs)
730 {
731  Bool_t savemacro = (opt!=0) && (strstr(opt,"savemacro")!=0);
732  Bool_t saveprefix = savemacro;
733 
734  const char* subname = strstr(opt, "name:");
735  if (subname != 0) { varname = subname + 5; saveprefix = kFALSE; }
736 
737  if (saveprefix) {
738  out << Form(" %s* %s = (%s*) go4->GetAnalysisCondition(\"%s\",\"%s\");",
739  ClassName(), varname, ClassName(), GetName(), ClassName()) << std::endl;
740  out << Form(" if (%s==0) {", varname) << std::endl;
741  out << Form(" TGo4Log::Error(\"Could not find condition %s of class %s\");", GetName(), ClassName()) << std::endl;
742  out << Form(" return;") << std::endl;
743  out << Form(" }") << std::endl << std::endl;
744  out << Form(" TGo4Log::Info(\"Set condition %s as saved at %s\");",
745  GetName(),TDatime().AsString()) << std::endl << std::endl;
746  } else
747  if (!savemacro && ((opt==0) || (strstr(opt, "nocreate")==0))) {
748  out << Form(" %s* %s = new %s(\"%s\"%s);", ClassName(), varname, ClassName(), GetName(), (arrextraargs ? arrextraargs : "")) << std::endl << std::endl;
749  }
750 
751  if (arrextraargs==0) {
752 
753  Bool_t enabled,last,mark,result,vtrue,vfalse;
754  GetFlags(&enabled, &last, &mark, &result, &vtrue, &vfalse);
755 
756  out << " // SetFlags(enabled,last,mark,result,vtrue,vfalse);" << std::endl;
757 
758  out << Form(" %s%s->SetFlags(%s, %s, %s, %s, %s, %s);",
759  savemacro ? "if (flags) " : "", varname,
760  enabled ? "kTRUE" : "kFALSE",
761  last ? "kTRUE" : "kFALSE",
762  mark ? "kTRUE" : "kFALSE",
763  result ? "kTRUE" : "kFALSE",
764  vtrue ? "kTRUE" : "kFALSE",
765  vfalse ? "kTRUE" : "kFALSE") << std::endl;
766 
767  out << Form(" %s%s->SetCounts(%d, %d);",
768  savemacro ? "if (counters) " : "", varname,
769  TrueCounts(), Counts()) << std::endl;
770 
771  if (savemacro)
772  out << Form(" if (reset) %s->ResetCounts();", varname) << std::endl;
773  }
774 
775  return varname;
776 }
TString fxNumFormat
static Bool_t fgbXRMSDRAW
static TString fgxURL_CMAX
static Bool_t fgbYMAXDRAW
Bool_t UrlOptionHasKey(const char *key)
static TString fgxURL_XRMS
virtual void SetIntDraw(Bool_t on)
static Bool_t fgbLIMITSDRAW
static void GetGlobalStyle(Bool_t &LABELDRAW, Bool_t &LIMITSDRAW, Bool_t &INTDRAW, Bool_t &XMEANDRAW, Bool_t &YMEANDRAW, Bool_t &XRMSDRAW, Bool_t &YRMSDRAW, Bool_t &XMAXDRAW, Bool_t &YMAXDRAW, Bool_t &CMAXDRAW, TString &NUMFORMAT)
Bool_t fbLastResult
virtual Double_t GetRMS(TH1 *, Int_t=1)
static TString fgxURL_RESET
virtual void SetYMaxDraw(Bool_t on)
virtual void PaintCondition(Option_t *opt="")
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
virtual void UnDraw(Option_t *opt="")
Bool_t fbMarkReset
virtual void SetCMaxDraw(Bool_t on)
virtual Bool_t IsPolygonType()
virtual Double_t GetYUp()
Int_t GetDimension()
virtual void SetPainter(TGo4ConditionPainter *painter)
virtual void UnPaintLabel(Option_t *opt="")
TString GetUrlOptionAsString(const char *key, TString def_value)
static Bool_t fgbCMAXDRAW
virtual void UnPaintCondition(Option_t *opt="")
virtual void PrintCondition(Bool_t full=kTRUE)
static TString fgxURL_YMEAN
virtual void SetYRMSDraw(Bool_t on)
virtual ~TGo4Condition()
virtual Bool_t IsVisible()
Bool_t fbOwnedByEditor
static Bool_t fgbLABELDRAW
Bool_t fbHistogramLink
void BuildUrlOptionArray(const char *rest_url_opt)
static TString fgxNUMFORMAT
static TString fgxURL_RESULT
virtual void SetXMeanDraw(Bool_t on)
static Bool_t fgbXMEANDRAW
Bool_t fbYMeanDraw
virtual Double_t GetIntegral(TH1 *, Option_t *="")
virtual Double_t GetXLow()
virtual void PaintLabel(Option_t *opt="")
Bool_t fbIsPainted
virtual void ResetCounts()
virtual void Draw(Option_t *opt="")
static TString fgxURL_INTEGRAL
void SetPainted(Bool_t on)
virtual void SetCounts(Int_t truecounts, Int_t counts)
virtual void Enable()
virtual void PrintBar()
Bool_t fbMultiEdit
static void SetGlobalStyle(Bool_t LABELDRAW, Bool_t LIMITSDRAW, Bool_t INTDRAW, Bool_t XMEANDRAW, Bool_t YMEANDRAW, Bool_t XRMSDRAW, Bool_t YRMSDRAW, Bool_t XMAXDRAW, Bool_t YMAXDRAW, Bool_t CMAXDRAW, const char *NUMFORMAT)
virtual void SetXMaxDraw(Bool_t on)
virtual Bool_t UpdateFromUrl(const char *rest_url_opt)
virtual void Pop()
virtual void Clear(Option_t *opt="")
Bool_t fbXMeanDraw
virtual void Print(Option_t *opt="") const
static Bool_t fgbYMEANDRAW
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:207
virtual void Disable(Bool_t result)
TH1 * GetWorkHistogram()
virtual void SetCondition(TGo4Condition *con)
virtual Double_t GetYLow()
void ResetLabel(Option_t *opt="reset")
virtual TGo4Condition * GetActiveCondition()
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)
static TString fgxURL_YMAX
static Bool_t fgbXMAXDRAW
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
static Bool_t fgbYRMSDRAW
virtual Double_t GetMean(TH1 *, Int_t=1)
virtual Double_t GetYMax(TH1 *)
TObjArray * fxUrlOptionArray
virtual void GetValues(Int_t &dim, Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2)
virtual Int_t GetMemorySize()
Int_t GetUrlOptionAsInt(const char *key, Int_t def_value)
const char * GetLinkedHistogram()
virtual void SetYMeanDraw(Bool_t on)
virtual Int_t TrueCounts()
virtual Int_t Counts()
static TString fgxURL_XMEAN
TString fxHistoName
static TString fgxURL_YRMS
virtual Double_t GetXUp()
virtual void DisplayToFront(Option_t *opt="")
virtual void AddCondition(TGo4Condition *next)
Bool_t fbLimitsDraw
virtual void SetLabelDraw(Bool_t on)
static TString fgxURL_LABEL
static const Double_t fgdUPDATEEPSILON
virtual void SetVisible(Bool_t on)
Double_t fdUpdateEpsilon
virtual Double_t GetCMax(TH1 *)
virtual void Invert(Bool_t on)
Double_t GetUrlOptionAsDouble(const char *key, Double_t def_value)
Bool_t fbLabelDraw
static TString fgxURL_XMAX
virtual Double_t GetXMax(TH1 *)
Bool_t fbStreamedCondition
static Bool_t fgbINTDRAW