65enum ETestCommandIdentifiers {
92 vector<RooPlot *> fPlotList;
93 map<TGTripleHSlider *, const char *> fSliderMap;
94 map<TGTripleHSlider *, TGLabel *> fLabelMap;
111 virtual ~ModelInspectorGUI();
114 void DoText(
const char *
text);
116 void DoSlider(
const char *);
119 void HandleButtons();
135 if (strcmp(fMC->GetPdf()->ClassName(),
"RooSimultaneous") == 0) {
136 cout <<
"Is a simultaneous PDF" << endl;
139 cout <<
" with " << channelCat->
numTypes() <<
" categories" << endl;
142 cout <<
"Is not a simultaneous PDF" << endl;
152 AddFrame(fCanvas, fLcan);
153 fPlotList.resize(numCats);
155 fCanvas->GetCanvas()->Divide(numCats);
156 for (
int i = 0; i < numCats; ++i) {
157 fCanvas->GetCanvas()->cd(i + 1)->SetBorderMode(0);
158 fCanvas->GetCanvas()->cd(i + 1)->SetGrid();
164 fCheck1 =
new TGCheckButton(fHframe0,
"&Constrained", HCId1);
168 fCheck1->SetToolTipText(
"Pointer position constrained to slider sides");
169 fCheck2->SetToolTipText(
"Pointer position relative to slider position");
171 fHframe0->Resize(200, 50);
176 fFitButton->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"DoFit()");
178 fExitButton->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"DoExit()");
180 fCheck1->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"HandleButtons()");
181 fCheck2->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"HandleButtons()");
183 fHframe2->Resize(100, 25);
193 fHframe2->AddFrame(fFitButton, fBfly2);
194 fHframe2->AddFrame(fExitButton, fBfly3);
196 AddFrame(fHframe0, fBly);
197 AddFrame(fHframe2, fBly);
202 parameters.
add(*fMC->GetParametersOfInterest());
203 parameters.
add(*fMC->GetNuisanceParameters());
211 fCan->SetContainer(fVFrame);
216 cout <<
"Adding Slider for " << param->
GetName() << endl;
223 hsliderk->
Connect(
"PointerPositionChanged()",
"ModelInspectorGUI",
this,
"DoSlider()");
224 hsliderk->
Connect(
"PositionChanged()",
"ModelInspectorGUI",
this,
"DoSlider()");
228 fSliderList.Add(hsliderk);
229 fFrameList.Add(hframek);
236 fVFrame->AddFrame(hframek, fBly);
237 fSliderMap[hsliderk] = param->
GetName();
238 fLabelMap[hsliderk] = hlabel;
243 SetWindowName(
"RooFit/RooStats Model Inspector");
245 Resize(GetDefaultSize());
252ModelInspectorGUI::~ModelInspectorGUI()
260void ModelInspectorGUI::CloseWindow()
268void ModelInspectorGUI::DoText(
const char * )
276 case HId1: fHslider1->SetPosition(atof(fTbh1->GetString()), fHslider1->GetMaxPosition());
break;
277 case HId2: fHslider1->SetPointerPosition(atof(fTbh2->GetString()));
break;
278 case HId3: fHslider1->SetPosition(fHslider1->GetMinPosition(), atof(fTbh1->GetString()));
break;
285void ModelInspectorGUI::DoFit()
287 fFitRes = fMC->GetPdf()->fitTo(*fData,
Save());
288 map<TGTripleHSlider *, const char *>::iterator it;
290 it = fSliderMap.begin();
291 for (; it != fSliderMap.end(); ++it) {
293 param = (
RooRealVar *)fFitRes->floatParsFinal().find(it->second);
295 it->first->SetPointerPosition(param->
getVal());
301void ModelInspectorGUI::DoSlider(
const char *
text)
303 cout <<
"." <<
text << endl;
307void ModelInspectorGUI::DoSlider()
315 if (strcmp(fMC->GetPdf()->ClassName(),
"RooSimultaneous") == 0) {
329 map<TGTripleHSlider *, const char *>::iterator it;
332 fPlot = ((
RooRealVar *)fMC->GetObservables()->first())->frame();
333 fData->plotOn(fPlot);
337 it = fSliderMap.begin();
338 for (; it != fSliderMap.end(); ++it) {
339 const char *
name = it->second;
340 fWS->var(
name)->setVal(it->first->GetMaxPosition());
342 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]", param->
GetName(), it->first->GetPointerPosition(),
343 it->first->GetMinPosition(), it->first->GetMaxPosition()));
345 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
349 it = fSliderMap.begin();
350 for (; it != fSliderMap.end(); ++it) {
351 const char *
name = it->second;
352 fWS->var(
name)->setVal(it->first->GetMinPosition());
354 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
358 it = fSliderMap.begin();
359 for (; it != fSliderMap.end(); ++it) {
360 const char *
name = it->second;
361 fWS->var(
name)->setVal(it->first->GetPointerPosition());
363 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
367 fCanvas->GetCanvas()->Modified();
368 fCanvas->GetCanvas()->Update();
378 Int_t frameIndex = 0;
381 fCanvas->GetCanvas()->cd(frameIndex);
388 fPlot = fPlotList.at(frameIndex - 1);
391 fPlot = obs->
frame();
392 fPlotList.at(frameIndex - 1) = fPlot;
401 map<TGTripleHSlider *, const char *>::iterator it;
406 it = fSliderMap.begin();
407 for (; it != fSliderMap.end(); ++it) {
408 const char *
name = it->second;
409 fWS->var(
name)->setVal(it->first->GetMaxPosition());
411 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]", param->
GetName(),
412 it->first->GetPointerPosition(), it->first->GetMinPosition(),
413 it->first->GetMaxPosition()));
419 it = fSliderMap.begin();
420 for (; it != fSliderMap.end(); ++it) {
421 const char *
name = it->second;
422 fWS->var(
name)->setVal(it->first->GetMinPosition());
424 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]", param->
GetName(),
425 it->first->GetPointerPosition(), it->first->GetMinPosition(),
426 it->first->GetMaxPosition()));
432 it = fSliderMap.begin();
433 for (; it != fSliderMap.end(); ++it) {
434 const char *
name = it->second;
435 fWS->var(
name)->setVal(it->first->GetPointerPosition());
437 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]", param->
GetName(),
438 it->first->GetPointerPosition(), it->first->GetMinPosition(),
439 it->first->GetMaxPosition()));
457 fCanvas->GetCanvas()->Modified();
458 fCanvas->GetCanvas()->Update();
465void ModelInspectorGUI::HandleButtons()
473 case HCId1: fHslider1->SetConstrained(fCheck1->GetState());
break;
474 case HCId2: fHslider1->SetRelative(fCheck2->GetState());
break;
478void ModelInspectorGUI::DoExit()
480 printf(
"Exit application...");
484void ModelInspector(
const char *infile =
"",
const char *workspaceName =
"combined",
485 const char *modelConfigName =
"ModelConfig",
const char *dataName =
"obsData")
492 const char *filename =
"";
493 if (!strcmp(infile,
"")) {
494 filename =
"results/example_combined_GaussExample_model.root";
499 cout <<
"HistFactory file cannot be generated on Windows - exit" << endl;
503 cout <<
"will run standard hist2workspace example" << endl;
504 gROOT->ProcessLine(
".! prepareHistFactory .");
505 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
506 cout <<
"\n\n---------------------" << endl;
507 cout <<
"Done creating example input" << endl;
508 cout <<
"---------------------\n\n" << endl;
519 cout <<
"StandardRooStatsDemoMacro: Input file " << filename <<
" is not found" << endl;
530 cout <<
"workspace not found" << endl;
543 cout <<
"data or ModelConfig was not found" << endl;
547 new ModelInspectorGUI(w, mc, data);
#define ClassDef(name, id)
R__EXTERN TApplication * gApplication
R__EXTERN void * gTQSender
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
TIterator * typeIterator() const
Int_t numTypes(const char *=0) const
Return number of types defined (in range named rangeName if rangeName!=0)
RooAbsArg * first() const
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events from this p.d.f for use in extended likelihood calculations.
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none(), const RooCmdArg &arg9=RooCmdArg::none(), const RooCmdArg &arg10=RooCmdArg::none()) const
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
RooPlot * frame(const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
RooCategory is an 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.
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
RooRealVar represents a variable that can be changed from the outside.
Double_t getError() const
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
const RooAbsCategoryLValue & indexCat() const
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
The RooWorkspace is a persistable container for RooFit projects.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
void Print(Option_t *opts=0) const
Print contents of the workspace.
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
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 a suite of consecutive data records (TKey instances) with a well defined format.
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.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
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)
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
virtual void CloseWindow()
Close and delete main frame.
virtual void SetPointerPosition(Double_t pos)
Set pointer position in scaled (real) value.
Iterator abstract base class.
virtual TObject * Next()=0
virtual const char * GetName() const
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.
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_t flag=kTRUE)
RooCmdArg DataError(Int_t)
RooCmdArg VisualizeError(const RooDataSet ¶mData, Double_t Z=1)
RooCmdArg FillColor(Color_t color)
RooCmdArg LineWidth(Width_t width)
RooCmdArg MarkerSize(Size_t size)
RooCmdArg Cut(const char *cutSpec)
RooCmdArg LineColor(Color_t color)
RooCmdArg Normalization(Double_t scaleFactor)
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)