19#include "TObjString.h"
20#include "TVirtualPad.h"
65 GO4TRACE((15,
"TGo4Condition::TGo4Condition()",__LINE__, __FILE__));
91 GO4TRACE((15,
"TGo4Condition::TGo4Condition(const char *)",__LINE__, __FILE__));
113 GO4TRACE((15,
"TGo4Condition::~TGo4Condition()",__LINE__, __FILE__));
137 GO4TRACE((14,
"TGo4Condition::AddCondition(TGo4Condition *)",__LINE__, __FILE__));
142 GO4TRACE((12,
"TGo4Condition::IncTrueCounts()",__LINE__, __FILE__));
148 GO4TRACE((12,
"TGo4Condition::IncCounts()",__LINE__, __FILE__));
154 GO4TRACE((12,
"TGo4Condition::Counts()",__LINE__, __FILE__));
160 GO4TRACE((12,
"TGo4Condition::TrueCounts()",__LINE__, __FILE__));
166 GO4TRACE((12,
"TGo4Condition::ResetCounts()",__LINE__, __FILE__));
173 GO4TRACE((12,
"TGo4Condition::SetCounts()",__LINE__, __FILE__));
182 GO4TRACE((12,
"TGo4Condition::Invert",__LINE__, __FILE__));
190 std::cout <<
"Name:" << GetName() <<
" type:" << ClassName() <<
" title:" << GetTitle() << std::endl;
192 std::cout <<
"Connected to histogram " <<
fxHistoName << std::endl;
198 line =
"Is Checked ";
200 line =
"Always True ";
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;
218 strncpy(num,
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
sizeof(num));
219 char *pc = num + (Int_t)perc/2;
221 std::cout << TString::Format(
"%-24s %8d %3.0f%s |%-50s|",GetName(),
fiCounts,perc,
"%",num) << std::endl;
228 TString option = opt;
230 if (option.IsNull() || option ==
"*") {
235 TString textbuffer =
"\nCondition ";
236 textbuffer.Append(GetName());
238 textbuffer.Append(
" (Polygon type, 2-dim)");
241 if (InheritsFrom(
"TGo4ListCond")) {
242 textbuffer.Append(
" (Whitelist type, 1-dim)");
245 textbuffer.Append(
" (Window type,");
247 textbuffer.Append(
" 2-dim)");
249 textbuffer.Append(
" 1-dim)");
254 if (option.Contains(
"limits"))
256 TString::Format(
"\n! Xlow: \t\tXup: \t\tYlow: \t\tYup:\n %.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t",
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",
265 if (option.Contains(
"stats")) {
268 textbuffer.Append(
"\n! with");
271 textbuffer.Append(
" histogram: ");
272 textbuffer.Append(hist->GetName());
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",
278 localthis->
GetRMS(hist, 1), localthis->
GetRMS(hist, 2)));
280 textbuffer.Append(
"out histogram");
284 if (option.Contains(
"go4log")) {
287 std::cout << textbuffer.Data() << std::endl;
295 fbTrue = cond->TGo4Condition::IsTrue();
296 fbFalse = cond->TGo4Condition::IsFalse();
297 fbResult = cond->TGo4Condition::FixedResult();
298 fbEnabled = cond->TGo4Condition::IsEnabled();
300 fbVisible = cond->TGo4Condition::IsVisible();
304 fbIntDraw = cond->TGo4Condition::IsIntDraw();
306 fbXRMSDraw = cond->TGo4Condition::IsXRMSDraw();
308 fbYRMSDraw = cond->TGo4Condition::IsYRMSDraw();
309 fbXMaxDraw = cond->TGo4Condition::IsXMaxDraw();
310 fbYMaxDraw = cond->TGo4Condition::IsYMaxDraw();
311 fbCMaxDraw = cond->TGo4Condition::IsCMaxDraw();
317 fiCounts = cond->TGo4Condition::Counts();
336 TString options = rest_url_opt;
343 TObject *cursor =
nullptr;
344 while ((cursor = iter.Next()) !=
nullptr) {
345 TObjString *curopt =
dynamic_cast<TObjString *
>(cursor);
347 TString theOption = curopt->GetString();
348 if (theOption.Contains(key)) {
359 TObject *cursor =
nullptr;
360 TObjArray *valuearray;
361 while ((cursor = iter.Next()) !=
nullptr) {
362 TObjString *curopt =
dynamic_cast<TObjString *
>(cursor);
364 TString theOption = curopt->GetString();
365 if (theOption.Contains(key)) {
366 valuearray = theOption.Tokenize(
"=");
367 TString theValue = valuearray->Last()->GetName();
368 valuearray->Delete();
380 if (valstring.IsNull())
383 return valstring.Atoi();
389 if(valstring.IsNull())
392 return valstring.Atof();
399 message.Form(
"TGo4Condition::UpdateFromUrl - condition %s: with url:%s", GetName(), rest_url_opt);
422 message.Form(
"Set condition %s:", GetName());
424 if (resetcounters > 0) {
426 message.Append(TString::Format(
", resetcounters=%d", resetcounters));
429 if (resultmode >= 0) {
431 switch (resultmode) {
434 case 2:
Disable(kFALSE);
break;
437 message.Append(TString::Format(
", resultmode=%d", resultmode));
440 if (invertmode >= 0) {
443 message.Append(TString::Format(
", invertmode=%d", invertmode));
448 message.Append(TString::Format(
", visible=%d", visible));
450 if (labeldraw >= 0) {
452 message.Append(TString::Format(
", labeldraw=%d", labeldraw));
454 if (limitsdraw >= 0) {
456 message.Append(TString::Format(
", limitsdraw=%d", limitsdraw));
458 if (integraldraw >= 0) {
460 message.Append(TString::Format(
", intdraw=%d", integraldraw));
462 if (xmeandraw >= 0) {
464 message.Append(TString::Format(
", xmeandraw=%d", xmeandraw));
468 message.Append(TString::Format(
", xrmsdraw=%d", xrmsdraw));
470 if (ymeandraw >= 0) {
472 message.Append(TString::Format(
", ymeandraw=%d", ymeandraw));
476 message.Append(TString::Format(
", yrmsdraw=%d", yrmsdraw));
480 message.Append(TString::Format(
", xmaxdraw=%d", xmaxdraw));
484 message.Append(TString::Format(
", ymaxdraw=%d", ymaxdraw));
488 message.Append(TString::Format(
", cmaxdraw=%d", cmaxdraw));
509 Int_t size =
sizeof(*this);
510 if (GetName()) size += strlen(GetName());
511 if (GetTitle()) size += strlen(GetTitle());
560 if (!name || !*name) {
604 if (gPad && !gPad->GetListOfPrimitives()->FindObject(
this)) {
618 gROOT->GetListOfCanvases()->RecursiveRemove(
this);
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)
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)
721 Bool_t savemacro = opt && strstr(opt,
"savemacro");
722 Bool_t saveprefix = savemacro;
724 const char *subname = strstr(opt,
"name:");
725 if (subname) { varname = subname + 5; saveprefix = kFALSE; }
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;
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;
743 Bool_t enabled,last,mark,result,vtrue,vfalse;
744 GetFlags(&enabled, &last, &mark, &result, &vtrue, &vfalse);
746 out <<
" // SetFlags(enabled,last,mark,result,vtrue,vfalse);" << std::endl;
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;
757 out << TString::Format(
" %s%s->SetCounts(%d, %d);",
758 savemacro ?
"if (counters) " :
"", varname,
762 out << TString::Format(
" if (reset) %s->ResetCounts();", varname) << std::endl;
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.
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 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.