65enum ETestCommandIdentifiers {
94 vector<RooPlot *> fPlotList;
95 map<TGTripleHSlider *, const char *> fSliderMap;
96 map<TGTripleHSlider *, TGLabel *> fLabelMap;
113 ~ModelInspectorGUI()
override;
116 void DoText(
const char *
text);
118 void DoSlider(
const char *);
121 void HandleButtons();
136 if (strcmp(fMC->GetPdf()->ClassName(),
"RooSimultaneous") == 0) {
137 cout <<
"Is a simultaneous PDF" << endl;
140 cout <<
" with " << channelCat->
numTypes() <<
" categories" << endl;
143 cout <<
"Is not a simultaneous PDF" << endl;
153 AddFrame(fCanvas, fLcan);
154 fPlotList.resize(numCats);
156 fCanvas->GetCanvas()->Divide(numCats);
157 for (
int i = 0; i < numCats; ++i) {
158 fCanvas->GetCanvas()->cd(i + 1)->SetBorderMode(0);
159 fCanvas->GetCanvas()->cd(i + 1)->SetGrid();
165 fCheck1 =
new TGCheckButton(fHframe0,
"&Constrained", HCId1);
169 fCheck1->SetToolTipText(
"Pointer position constrained to slider sides");
170 fCheck2->SetToolTipText(
"Pointer position relative to slider position");
172 fHframe0->Resize(200, 50);
177 fFitButton->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"DoFit()");
179 fExitButton->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"DoExit()");
181 fCheck1->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"HandleButtons()");
182 fCheck2->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"HandleButtons()");
184 fHframe2->Resize(100, 25);
194 fHframe2->AddFrame(fFitButton, fBfly2);
195 fHframe2->AddFrame(fExitButton, fBfly3);
197 AddFrame(fHframe0, fBly);
198 AddFrame(fHframe2, fBly);
203 parameters.
add(*fMC->GetParametersOfInterest());
204 parameters.
add(*fMC->GetNuisanceParameters());
212 fCan->SetContainer(fVFrame);
217 cout <<
"Adding Slider for " << param->
GetName() << endl;
224 hsliderk->
Connect(
"PointerPositionChanged()",
"ModelInspectorGUI",
this,
"DoSlider()");
225 hsliderk->
Connect(
"PositionChanged()",
"ModelInspectorGUI",
this,
"DoSlider()");
229 fSliderList.Add(hsliderk);
230 fFrameList.Add(hframek);
237 fVFrame->AddFrame(hframek, fBly);
238 fSliderMap[hsliderk] = param->
GetName();
239 fLabelMap[hsliderk] = hlabel;
244 SetWindowName(
"RooFit/RooStats Model Inspector");
246 Resize(GetDefaultSize());
253ModelInspectorGUI::~ModelInspectorGUI()
261void ModelInspectorGUI::CloseWindow()
269void ModelInspectorGUI::DoText(
const char * )
277 case HId1: fHslider1->SetPosition(atof(fTbh1->GetString()),
static_cast<double>(fHslider1->GetMaxPosition()));
break;
278 case HId2: fHslider1->SetPointerPosition(atof(fTbh2->GetString()));
break;
279 case HId3: fHslider1->SetPosition(
static_cast<double>(fHslider1->GetMinPosition()), atof(fTbh1->GetString()));
break;
286void ModelInspectorGUI::DoFit()
288 fFitRes = fMC->GetPdf()->fitTo(*fData,
Save());
289 map<TGTripleHSlider *, const char *>::iterator it;
291 it = fSliderMap.begin();
292 for (; it != fSliderMap.end(); ++it) {
294 param = (
RooRealVar *)fFitRes->floatParsFinal().find(it->second);
296 it->first->SetPointerPosition(param->
getVal());
302void ModelInspectorGUI::DoSlider(
const char *
text)
304 cout <<
"." <<
text << endl;
308void ModelInspectorGUI::DoSlider()
316 if (strcmp(fMC->GetPdf()->ClassName(),
"RooSimultaneous") == 0) {
330 map<TGTripleHSlider *, const char *>::iterator it;
333 fPlot = ((
RooRealVar *)fMC->GetObservables()->first())->frame();
334 fData->plotOn(fPlot);
338 it = fSliderMap.begin();
339 for (; it != fSliderMap.end(); ++it) {
340 const char *
name = it->second;
341 fWS->var(
name)->setVal(it->first->GetMaxPosition());
343 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]", param->
GetName(), it->first->GetPointerPosition(),
344 it->first->GetMinPosition(), it->first->GetMaxPosition()));
346 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
350 it = fSliderMap.begin();
351 for (; it != fSliderMap.end(); ++it) {
352 const char *
name = it->second;
353 fWS->var(
name)->setVal(it->first->GetMinPosition());
355 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
359 it = fSliderMap.begin();
360 for (; it != fSliderMap.end(); ++it) {
361 const char *
name = it->second;
362 fWS->var(
name)->setVal(it->first->GetPointerPosition());
364 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
368 fCanvas->GetCanvas()->Modified();
369 fCanvas->GetCanvas()->Update();
377 Int_t frameIndex = 0;
378 for (
auto const&
tt : *channelCat) {
379 auto const& catName =
tt.first;
382 fCanvas->GetCanvas()->cd(frameIndex);
389 fPlot = fPlotList.at(frameIndex - 1);
392 fPlot = obs->
frame();
393 fPlotList.at(frameIndex - 1) = fPlot;
402 map<TGTripleHSlider *, const char *>::iterator it;
407 it = fSliderMap.begin();
408 for (; it != fSliderMap.end(); ++it) {
409 const char *
name = it->second;
410 fWS->var(
name)->setVal(it->first->GetMaxPosition());
412 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]", param->
GetName(),
413 it->first->GetPointerPosition(), it->first->GetMinPosition(),
414 it->first->GetMaxPosition()));
420 it = fSliderMap.begin();
421 for (; it != fSliderMap.end(); ++it) {
422 const char *
name = it->second;
423 fWS->var(
name)->setVal(it->first->GetMinPosition());
425 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]", param->
GetName(),
426 it->first->GetPointerPosition(), it->first->GetMinPosition(),
427 it->first->GetMaxPosition()));
433 it = fSliderMap.begin();
434 for (; it != fSliderMap.end(); ++it) {
435 const char *
name = it->second;
436 fWS->var(
name)->setVal(it->first->GetPointerPosition());
438 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]", param->
GetName(),
439 it->first->GetPointerPosition(), it->first->GetMinPosition(),
440 it->first->GetMaxPosition()));
458 fCanvas->GetCanvas()->Modified();
459 fCanvas->GetCanvas()->Update();
466void ModelInspectorGUI::HandleButtons()
474 case HCId1: fHslider1->SetConstrained(fCheck1->GetState());
break;
475 case HCId2: fHslider1->SetRelative(fCheck2->GetState());
break;
479void ModelInspectorGUI::DoExit()
481 printf(
"Exit application...");
485void ModelInspector(
const char *infile =
"",
const char *workspaceName =
"combined",
486 const char *modelConfigName =
"ModelConfig",
const char *dataName =
"obsData")
493 if (!strcmp(infile,
"")) {
494 filename =
"results/example_combined_GaussExample_model.root";
499 cout <<
"will run standard hist2workspace example" << endl;
500 gROOT->ProcessLine(
".! prepareHistFactory .");
501 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
502 cout <<
"\n\n---------------------" << endl;
503 cout <<
"Done creating example input" << endl;
504 cout <<
"---------------------\n\n" << endl;
515 cout <<
"StandardRooStatsDemoMacro: Input file " <<
filename <<
" is not found" << endl;
526 cout <<
"workspace not found" << endl;
539 cout <<
"data or ModelConfig was not found" << endl;
543 new ModelInspectorGUI(
w, mc,
data);
R__EXTERN TApplication * gApplication
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Option_t Option_t TPoint TPoint const char text
R__EXTERN void * gTQSender
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
Int_t numTypes(const char *=nullptr) const
Return number of types defined (in range named rangeName if rangeName!=nullptr)
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooAbsArg * first() const
TIterator * createIterator(bool dir=kIterForward) const
TIterator-style iteration over contained elements.
Abstract base class for binned and unbinned datasets.
Abstract interface for all probability density functions.
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={}, const RooCmdArg &arg10={}) const override
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
RooPlot * frame(const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Object to represent discrete states.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
void setGlobalKillBelow(RooFit::MsgLevel level)
RooFit::MsgLevel globalKillBelow() const
A RooPlot is a plot frame and a container for graphics objects within that frame.
RooRealVar represents a variable that can be changed from the outside.
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooAbsPdf * getPdf(RooStringView catName) const
Return the p.d.f associated with the given index category name.
const RooAbsCategoryLValue & indexCat() const
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Persistable container for RooFit projects.
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
virtual void SetRange(Float_t min, Float_t max)
virtual void SetPosition(Float_t min, Float_t max)
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
A composite frame that layout their children in horizontal way.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
virtual void CloseWindow()
Close and delete main frame.
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
A TGTextEntry is a one line text input widget.
TripleSlider inherit from DoubleSlider widgets and allow easy selection of a min, max and pointer val...
virtual void SetPointerPosition(Double_t pos)
Set pointer position in scaled (real) value.
A composite frame that layout their children in vertical way.
const char * GetName() const override
Returns name of object.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
This class creates a TGCanvas in which a TCanvas is created.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
RooCmdArg Save(bool flag=true)
RooCmdArg DataError(Int_t)
RooCmdArg FillColor(Color_t color)
RooCmdArg LineWidth(Width_t width)
RooCmdArg Normalization(double scaleFactor)
RooCmdArg VisualizeError(const RooDataSet ¶mData, double Z=1)
RooCmdArg MarkerSize(Size_t size)
RooCmdArg Cut(const char *cutSpec)
RooCmdArg LineColor(Color_t color)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
Namespace for the RooStats classes.
void removeTopic(RooFit::MsgTopic oldTopic)