GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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"
25
26const Double_t TGo4Condition::fgdUPDATEEPSILON = 0.01;
27
30Bool_t TGo4Condition::fgbINTDRAW=kTRUE;
33Bool_t TGo4Condition::fgbYMEANDRAW=kFALSE;
34Bool_t TGo4Condition::fgbYRMSDRAW=kFALSE;
36Bool_t TGo4Condition::fgbYMAXDRAW=kFALSE;
38TString TGo4Condition::fgxNUMFORMAT="%.4E";
39
41TString TGo4Condition::fgxURL_RESET="resetcounters";
42TString TGo4Condition::fgxURL_RESULT="resultmode";
43TString TGo4Condition::fgxURL_INVERT="invertmode";
44TString TGo4Condition::fgxURL_VISIBLE="visible";
45TString TGo4Condition::fgxURL_LABEL="labeldraw";
46TString TGo4Condition::fgxURL_LIMITS="limitsdraw";
47TString TGo4Condition::fgxURL_INTEGRAL="intdraw";
48TString TGo4Condition::fgxURL_XMEAN="xmeandraw";
49TString TGo4Condition::fgxURL_XRMS="xrmsdraw";
50TString TGo4Condition::fgxURL_YMEAN="ymeandraw";
51TString TGo4Condition::fgxURL_YRMS="yrmsdraw";
52TString TGo4Condition::fgxURL_XMAX="xmaxdraw";
53TString TGo4Condition::fgxURL_YMAX="ymaxdraw";
54TString TGo4Condition::fgxURL_CMAX="cmaxdraw";
55
56// -----------------------------------------------
57// Constructors
58// ---------------------------------------------------------
60 TNamed(),
61 TAttLine(),
62 TAttFill(),
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// -----------------------------------------------
85TGo4Condition::TGo4Condition(const char *name, const char *title) :
86 TNamed(name, title),
87 TAttLine(),
88 TAttFill(),
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;
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// ---------------------------------------------------------
171void 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// ---------------------------------------------------------
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// -----------------------------------------------
225void 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// ---------------------------------------------------------
293Bool_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
329void 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
340Bool_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
356TString 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
377Int_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
386Double_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
396Bool_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
497void 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
520void TGo4Condition::Clear(Option_t *)
521{
522 ResetCounts();
523}
524
525void 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
536void 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
547void TGo4Condition::Disable(Bool_t result)
548{
549 fbEnabled = kFALSE;
550 fbResult = result;
551}
552
554{
555 fbEnabled = kTRUE;
556}
557
558void 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
581void TGo4Condition::Paint(Option_t *opt)
582{
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
596 fxPainter->PaintCondition(opt);
597 fxPainter->PaintLabel(opt);
598 }
599}
600
601void TGo4Condition::Draw(Option_t *opt)
602{
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
615void 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) {
622 fxPainter->UnPaintCondition(opt);
623 //if(strcmp(opt,"keeplabel"))
624 fxPainter->UnPaintLabel();
625 }
626}
627
629{
630 if(fxPainter) fxPainter->DisplayToFront();
631}
632
634{
635 return nullptr;
636}
637
652
667
668void 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;
675 TGo4Condition::fgbXMEANDRAW = XMEANDRAW;
676 TGo4Condition::fgbYMEANDRAW = YMEANDRAW;
682 TGo4Condition::fgxNUMFORMAT = NUMFORMAT;
683}
684
685void 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;
692 XMEANDRAW = TGo4Condition::fgbXMEANDRAW;
693 YMEANDRAW = TGo4Condition::fgbYMEANDRAW;
699 NUMFORMAT = TGo4Condition::fgxNUMFORMAT;
700}
701
702
703void TGo4Condition::ResetLabel(Option_t *opt)
704{
705 if(fxPainter) {
706 fxPainter->UnPaintLabel(opt);
707 fxPainter->PaintLabel();
708 }
709}
710
712{
713 if (fxPainter) {
714 delete fxPainter;
715 fxPainter = nullptr;
716 }
717}
718
719const 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}
#define GO4TRACE(X)
Definition TGo4Log.h:25
virtual Int_t TrueCounts()
Return number of true results of the Test method call.
Bool_t fbTrue
These are inverted by Invert(true), and restored by Invert(false)
static Bool_t fgbCMAXDRAW
default setting for all conditions for label draw cmax flag.
virtual Double_t GetXUp() const
Bool_t fbHistogramLink
is true if this condition has link to a histogram name
Bool_t fbCMaxDraw
If true, draw corresponding value as label on working pad.
void Clear(Option_t *opt="") override
Bool_t fbIsPainted
Flag to prevent Paint() method to redraw condition views after UnDraw.
virtual void SetYMeanDraw(Bool_t on)
static TString fgxURL_RESULT
web condition editor keyword used in UpdateFromUrl.
virtual TGo4ConditionPainter * CreatePainter()
Factory method to generate the subclass implementation for painter.
void SetPainted(Bool_t on)
static TString fgxURL_YMAX
web condition editor keyword used in UpdateFromUrl.
Int_t fiCounts
Counts the number of calls of the Test method.
Bool_t fbFalse
These are inverted by Invert(true), and restored by Invert(false).
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)
Bool_t fbXMeanDraw
If true, draw corresponding value as label on working pad.
static TString fgxURL_XRMS
web condition editor keyword used in UpdateFromUrl.
Bool_t fbXRMSDraw
If true, draw corresponding value as label on working pad.
static TString fgxURL_VISIBLE
web condition editor keyword used in UpdateFromUrl.
static TString fgxNUMFORMAT
default setting for all conditions with format string for numbers.
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
Copy values from cond to this.
void InitLabelStyle()
Initialize label setup from static default variables.
TString GetUrlOptionAsString(const char *key, TString def_value)
Scan list of url options for key.
Double_t GetUrlOptionAsDouble(const char *key, Double_t def_value)
Scan list of url options for key.
Bool_t fbXMaxDraw
If true, draw corresponding value as label on working pad.
static TString fgxURL_LIMITS
web condition editor keyword used in UpdateFromUrl.
Int_t fiIsChanged
Counter indicate how many times condition was changed from graphical view.
TString fxNumFormat
format string for all label numbers.
virtual void SetLabelDraw(Bool_t on)
virtual const TGo4Condition * GetActiveCondition() const
To be overwritten for condition array.
static TString fgxURL_YMEAN
web condition editor keyword used in UpdateFromUrl.
virtual void SetVisible(Bool_t on)
Set/Unset visibility.
static TString fgxURL_YRMS
web condition editor keyword used in UpdateFromUrl.
virtual void GetFlags(Bool_t *enabled, Bool_t *lastresult, Bool_t *markreset, Bool_t *result, Bool_t *truevalue, Bool_t *falsevalue)
Sets values of internal boolean flags to external variables.
virtual void Enable()
Enable (unfreeze) Test execution.
virtual Bool_t UpdateFromUrl(const char *rest_url_opt)
Method used by HTTP server to update some fields, specified in URL syntax.
Bool_t fbYMeanDraw
If true, draw corresponding value as label on working pad.
virtual void SetCounts(Int_t truecounts, Int_t counts)
Set counters.
Int_t fiDim
Dimension (1 or 2).
virtual void SetPainter(TGo4ConditionPainter *painter)
Replace default painter of this condition by external one.
virtual void SetLimitsDraw(Bool_t on)
Int_t GetUrlOptionAsInt(const char *key, Int_t def_value)
Scan list of url options for key.
TH1 * GetWorkHistogram() const
access work histogram reference
static TString fgxURL_LABEL
web condition editor keyword used in UpdateFromUrl.
virtual void GetValues(Int_t &dim, Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2)
virtual void AddCondition(TGo4Condition *next)
Add another condition to this one.
virtual Double_t GetMean(TH1 *, Int_t=1)
Calculate value for histogram inside condition limits.
virtual Bool_t IsPolygonType() const
virtual Int_t GetMemorySize() const
Int_t GetDimension() const
const char * GetLinkedHistogram() const
Access name of the associated histogram.
static Bool_t fgbLABELDRAW
default setting for all conditions for label draw on/off flag.
Bool_t fbLastResult
This can be used to store the last result by SetLast(bool).
void SetHistogram(const char *name)
Define the name of the associated histogram.
virtual void ResetCounts()
Clear counters.
Bool_t fbYMaxDraw
If true, draw corresponding value as label on working pad.
static Bool_t fgbYMAXDRAW
default setting for all conditions for label draw ymax flag.
void IncCounts()
Increment the test counter.
Bool_t fbLabelDraw
If true, draw corresponding value as label on working pad.
virtual void SetIntDraw(Bool_t on)
void Pop() override
Re-implement TObject method to pop all our views to front.
virtual Int_t Counts()
Return number of calls of the Test method.
TGo4ConditionPainter * fxPainter
Painter instance to display the condition in root pad.
TObjArray * fxUrlOptionArray
array with TObjStrings evaluated by UpdateFromUrl
Bool_t fbOwnedByEditor
Flag to suppress interactive deletion of condition.
void ResetLabel(Option_t *opt="reset")
Will reset label position to defaults with other option than reset, just pop label to front.
Bool_t fbIntDraw
If true, draw corresponding value as label on working pad.
static Bool_t fgbXRMSDRAW
default setting for all conditions for label draw xrms flag.
Bool_t fbStreamedCondition
This allows to treat conditions streamed into pad.
Double_t fdUpdateEpsilon
Precision for the check if graphical representation change requires update.
virtual void SetYRMSDraw(Bool_t on)
static TString fgxURL_INTEGRAL
web condition editor keyword used in UpdateFromUrl.
static TString fgxURL_XMAX
web condition editor keyword used in UpdateFromUrl.
void Draw(Option_t *opt="") override
Draw this condition on current pad.
Bool_t IsPainted() const
static Bool_t fgbXMAXDRAW
default setting for all conditions for label draw xmax flag.
void BuildUrlOptionArray(const char *rest_url_opt)
re-build the list of url options from string
virtual Bool_t Test()
Test if condition is true.
static const Double_t fgdUPDATEEPSILON
default value for graphical update tolerance.
Bool_t fbResult
If fbEnabled is false, return this as result.
virtual void SetYMaxDraw(Bool_t on)
TString fxHistoName
contains associated histogram name
virtual Double_t GetYMax(TH1 *)
Calculate value for histogram inside condition limits.
Bool_t fbVisible
Property to store visibility of condition on display.
virtual Bool_t IsVisible() const
Visibility property for gui display in editor.
Bool_t fbEnabled
Flag to enable/disable this condition.
virtual ~TGo4Condition()
virtual Double_t GetXLow() const
void IncTrueCounts()
Increment the "test was true" counter.
void Print(Option_t *opt="") const override
Default printout for root object lists.
virtual void SetXRMSDraw(Bool_t on)
static TString fgxURL_CMAX
web condition editor keyword used in UpdateFromUrl.
Bool_t UrlOptionHasKey(const char *key)
returns true if key is present in list of url options.
virtual void SetXMeanDraw(Bool_t on)
virtual void PrintCondition(Bool_t full=kTRUE)
Prints counters and boolean members.
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)
virtual void Disable(Bool_t result)
Freeze condition, on Test() return result.
virtual Double_t GetCMax(TH1 *)
Calculate value for histogram inside condition limits.
virtual void PrintBar()
Prints counters and bar.
virtual void SetFlags(Bool_t enabled, Bool_t lastresult, Bool_t markreset, Bool_t result, Bool_t truevalue, Bool_t falsevalue)
Sets values of external boolean flags to internal variables.
virtual Double_t GetIntegral(TH1 *, Option_t *="")
Calculate value for histogram inside condition limits.
virtual void Invert(Bool_t on)
Inverts return values, when on is true, i.e.
Int_t fiTrueCounts
Counts the number of calls of the Test method with true result.
static Bool_t fgbYMEANDRAW
default setting for all conditions for label draw ymean flag.
virtual void MarkReset(Bool_t on)
defines if condition counters shall be reset in UpdateFrom method
virtual Double_t GetXMax(TH1 *)
Calculate value for histogram inside condition limits.
static Bool_t fgbLIMITSDRAW
default setting for all conditions for label draw limits flag.
static TString fgxURL_INVERT
web condition editor keyword used in UpdateFromUrl.
static Bool_t fgbINTDRAW
default setting for all conditions for label draw integral flag.
virtual Double_t GetYUp() const
static TString fgxURL_XMEAN
web condition editor keyword used in UpdateFromUrl.
const char * MakeScript(std::ostream &out, const char *varname, Option_t *opt="", const char *arrextraargs=nullptr)
virtual void SetCMaxDraw(Bool_t on)
Bool_t fbMultiEdit
Flag to indicate that properties of all conditions in array are edited/used.
Bool_t fbYRMSDraw
If true, draw corresponding value as label on working pad.
static TString fgxURL_RESET
web condition editor keyword used in UpdateFromUrl.
virtual Double_t GetYLow() const
static Bool_t fgbYRMSDRAW
default setting for all conditions for label draw yrms flag.
virtual void UnDraw(Option_t *opt="")
Erase view of this condition from the pad.
virtual void SetXMaxDraw(Bool_t on)
Bool_t fbLimitsDraw
If true, draw corresponding value as label on working pad.
virtual Double_t GetRMS(TH1 *, Int_t=1)
Calculate value for histogram inside condition limits.
void Paint(Option_t *opt="") override
Display condition with plain root canvas and in go4 viewpanel.
static Bool_t fgbXMEANDRAW
default setting for all conditions for label draw xmean flag.
void SaveLabelStyle()
This will save draw flags into static default setup.
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Display a message.
Definition TGo4Log.cxx:206