65 enum 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,
182 fCheck2->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
185 fHframe2->Resize(100, 25);
195 fHframe2->AddFrame(fFitButton, fBfly2);
196 fHframe2->AddFrame(fExitButton, fBfly3);
198 AddFrame(fHframe0, fBly);
199 AddFrame(fHframe2, fBly);
204 parameters.
add(*fMC->GetParametersOfInterest());
205 parameters.
add(*fMC->GetNuisanceParameters());
213 fCan->SetContainer(fVFrame);
218 cout <<
"Adding Slider for "<<param->
GetName()<<endl;
224 GetDefaultFrameBackground(),
226 hsliderk->
Connect(
"PointerPositionChanged()",
"ModelInspectorGUI",
228 hsliderk->
Connect(
"PositionChanged()",
"ModelInspectorGUI",
233 fSliderList.Add(hsliderk);
234 fFrameList.Add(hframek);
241 fVFrame->AddFrame(hframek, fBly);
242 fSliderMap[hsliderk]=param->
GetName();
243 fLabelMap[hsliderk]=hlabel;
248 SetWindowName(
"RooFit/RooStats Model Inspector");
250 Resize(GetDefaultSize());
257 ModelInspectorGUI::~ModelInspectorGUI()
265 void ModelInspectorGUI::CloseWindow()
273 void ModelInspectorGUI::DoText(
const char * )
282 fHslider1->SetPosition(atof(fTbh1->GetString()),
283 fHslider1->GetMaxPosition());
286 fHslider1->SetPointerPosition(atof(fTbh2->GetString()));
289 fHslider1->SetPosition(fHslider1->GetMinPosition(),
290 atof(fTbh1->GetString()));
299 void ModelInspectorGUI::DoFit()
301 fFitRes = fMC->GetPdf()->fitTo(*fData,
Save());
302 map<TGTripleHSlider*,const char*>::iterator it;;
303 it = fSliderMap.begin();
304 for(; it!=fSliderMap.end(); ++it){
306 param = (
RooRealVar*) fFitRes->floatParsFinal().find(it->second);
308 it->first->SetPointerPosition(param->
getVal());
315 void ModelInspectorGUI::DoSlider(
const char*
text)
317 cout <<
"." << text <<endl;
321 void ModelInspectorGUI::DoSlider()
329 if(strcmp(fMC->GetPdf()->ClassName(),
"RooSimultaneous")==0){
344 map<TGTripleHSlider*,const char*>::iterator it;;
346 fPlot = ((
RooRealVar*)fMC->GetObservables()->first())->frame();
347 fData->plotOn(fPlot);
351 it = fSliderMap.begin();
352 for(; it!=fSliderMap.end(); ++it){
353 const char*
name = it->second;
354 fWS->var(name)->setVal(it->first->GetMaxPosition());
356 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]",param->
GetName(),it->first->GetPointerPosition(),it->first->GetMinPosition(),it->first->GetMaxPosition()));
358 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
362 it = fSliderMap.begin();
363 for(; it!=fSliderMap.end(); ++it){
364 const char* name = it->second;
365 fWS->var(name)->setVal(it->first->GetMinPosition());
367 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
371 it = fSliderMap.begin();
372 for(; it!=fSliderMap.end(); ++it){
373 const char* name = it->second;
374 fWS->var(name)->setVal(it->first->GetPointerPosition());
376 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
380 fCanvas->GetCanvas()->Modified();
381 fCanvas->GetCanvas()->Update();
391 Int_t frameIndex = 0;
394 fCanvas->GetCanvas()->cd(frameIndex);
401 fPlot = fPlotList.at(frameIndex-1);
402 if(fPlot)
delete fPlot;
403 fPlot = obs->
frame();
404 fPlotList.at(frameIndex-1) = fPlot;
412 map<TGTripleHSlider*,const char*>::iterator it;;
416 it = fSliderMap.begin();
417 for(; it!=fSliderMap.end(); ++it){
418 const char* name = it->second;
419 fWS->var(name)->setVal(it->first->GetMaxPosition());
421 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]",param->
GetName(),it->first->GetPointerPosition(),it->first->GetMinPosition(),it->first->GetMaxPosition()));
428 it = fSliderMap.begin();
429 for(; it!=fSliderMap.end(); ++it){
430 const char* name = it->second;
431 fWS->var(name)->setVal(it->first->GetMinPosition());
433 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]",param->
GetName(),it->first->GetPointerPosition(),it->first->GetMinPosition(),it->first->GetMaxPosition()));
439 it = fSliderMap.begin();
440 for(; it!=fSliderMap.end(); ++it){
441 const char* name = it->second;
442 fWS->var(name)->setVal(it->first->GetPointerPosition());
444 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]",param->
GetName(),it->first->GetPointerPosition(),it->first->GetMinPosition(),it->first->GetMaxPosition()));
459 fCanvas->GetCanvas()->Modified();
460 fCanvas->GetCanvas()->Update();
469 void ModelInspectorGUI::HandleButtons()
478 fHslider1->SetConstrained(fCheck1->GetState());
481 fHslider1->SetRelative(fCheck2->GetState());
487 void ModelInspectorGUI::DoExit()
489 printf(
"Exit application...");
494 void ModelInspector(
const char* infile =
"",
495 const char* workspaceName =
"combined",
496 const char* modelConfigName =
"ModelConfig",
497 const char* dataName =
"obsData"){
505 const char* filename =
"";
506 if (!strcmp(infile,
"")) {
507 filename =
"results/example_combined_GaussExample_model.root";
512 cout <<
"HistFactory file cannot be generated on Windows - exit" << endl;
516 cout <<
"will run standard hist2workspace example"<<endl;
517 gROOT->ProcessLine(
".! prepareHistFactory .");
518 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
519 cout <<
"\n\n---------------------"<<endl;
520 cout <<
"Done creating example input"<<endl;
521 cout <<
"---------------------\n\n"<<endl;
533 cout <<
"StandardRooStatsDemoMacro: Input file " << filename <<
" is not found" << endl;
544 cout <<
"workspace not found" << endl;
557 cout <<
"data or ModelConfig was not found" <<endl;
561 new ModelInspectorGUI(w,mc,data);
virtual Double_t getMin(const char *name=0) const
virtual const char * GetName() const
Returns name of object.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
TIterator * createIterator(Bool_t dir=kIterForward) const
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.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
virtual Double_t getMax(const char *name=0) const
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
RooCmdArg Cut(const char *cutSpec)
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
RooCmdArg LineColor(Color_t color)
RooCmdArg VisualizeError(const RooDataSet ¶mData, Double_t Z=1)
R__EXTERN void * gTQSender
Double_t getVal(const RooArgSet *set=0) const
RooFit::MsgLevel globalKillBelow() const
StreamConfig & getStream(Int_t id)
void removeTopic(RooFit::MsgTopic oldTopic)
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
static RooMsgService & instance()
Return reference to singleton instance.
virtual void SetRange(Float_t min, Float_t max)
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
Plot (project) PDF on specified frame.
R__EXTERN TApplication * gApplication
Iterator abstract base class.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Int_t numTypes(const char *=0) const
#define ClassDef(name, id)
RooCmdArg MarkerSize(Size_t size)
RooCmdArg DataError(Int_t)
virtual void SetPointerPosition(Float_t pos)
Set pointer position in scaled (real) value.
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state...
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events from this p.d.f for use in extended likelihood calculations.
RooRealVar represents a fundamental (non-derived) real valued object.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found...
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...
R__EXTERN TSystem * gSystem
TIterator * typeIterator() const
Return iterator over all defined states.
virtual const Text_t * GetName() const
Returns name of object.
const RooAbsCategoryLValue & indexCat() const
RooAbsArg * first() const
char * Form(const char *fmt,...)
void setGlobalKillBelow(RooFit::MsgLevel level)
RooAbsData is the common abstract base class for binned and unbinned datasets.
RooCategory represents a fundamental (non-derived) discrete value object.
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
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name) ...
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
Namespace for the RooStats classes.
RooCmdArg FillColor(Color_t color)
RooCmdArg Normalization(Double_t scaleFactor)
RooCmdArg LineWidth(Width_t width)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
RooCmdArg Save(Bool_t flag=kTRUE)
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
virtual TObject * Next()=0
virtual void SetPosition(Float_t min, Float_t max)
Double_t getError() const
void Print(Option_t *opts=0) const
Print contents of the workspace.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset...
The RooWorkspace is a persistable container for RooFit projects.
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.