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