69 using namespace RooFit;
70 using namespace RooStats;
71 class ModelInspectorGUI :
public TGMainFrame {
86 vector<RooPlot*> fPlotList;
87 map<TGTripleHSlider*,const char*> fSliderMap;
88 map<TGTripleHSlider*,TGLabel*> fLabelMap;
106 virtual ~ModelInspectorGUI();
109 void DoText(
const char *
text);
111 void DoSlider(
const char*);
114 void HandleButtons();
121 : TGMainFrame(
gClient->GetRoot(), 100, 100)
130 if(strcmp(fMC->GetPdf()->ClassName(),
"RooSimultaneous")==0){
131 cout <<
"Is a simultaneous PDF"<< endl;
134 cout <<
" with " << channelCat->
numTypes() <<
" categories"<<endl;
137 cout <<
"Is not a simultaneous PDF"<<endl;
149 AddFrame(fCanvas, fLcan);
150 fPlotList.resize(numCats);
152 fCanvas->GetCanvas()->Divide(numCats);
153 for(
int i=0; i<numCats; ++i){
156 fCanvas->GetCanvas()->cd(i+1)->SetBorderMode(0);
157 fCanvas->GetCanvas()->cd(i+1)->SetGrid();
168 fCheck1->SetToolTipText(
"Pointer position constrained to slider sides");
169 fCheck2->SetToolTipText(
"Pointer position relative to slider position");
171 fHframe0->Resize(200, 50);
177 fFitButton->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"DoFit()");
179 fExitButton->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
"DoExit()");
182 fCheck1->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
184 fCheck2->Connect(
"Clicked()",
"ModelInspectorGUI",
this,
187 fHframe2->Resize(100, 25);
199 fHframe2->AddFrame(fFitButton, fBfly2);
200 fHframe2->AddFrame(fExitButton, fBfly3);
202 AddFrame(fHframe0, fBly);
203 AddFrame(fHframe2, fBly);
209 parameters.
add(*fMC->GetParametersOfInterest());
210 parameters.
add(*fMC->GetNuisanceParameters());
218 fCan->SetContainer(fVFrame);
223 cout <<
"Adding Slider for "<<param->
GetName()<<endl;
229 GetDefaultFrameBackground(),
231 hsliderk->
Connect(
"PointerPositionChanged()",
"ModelInspectorGUI",
233 hsliderk->
Connect(
"PositionChanged()",
"ModelInspectorGUI",
238 fSliderList.Add(hsliderk);
239 fFrameList.Add(hframek);
246 fVFrame->AddFrame(hframek, fBly);
247 fSliderMap[hsliderk]=param->
GetName();
248 fLabelMap[hsliderk]=hlabel;
253 SetWindowName(
"RooFit/RooStats Model Inspector");
255 Resize(GetDefaultSize());
262 ModelInspectorGUI::~ModelInspectorGUI()
270 void ModelInspectorGUI::CloseWindow()
278 void ModelInspectorGUI::DoText(
const char * )
287 fHslider1->SetPosition(atof(fTbh1->GetString()),
288 fHslider1->GetMaxPosition());
291 fHslider1->SetPointerPosition(atof(fTbh2->GetString()));
294 fHslider1->SetPosition(fHslider1->GetMinPosition(),
295 atof(fTbh1->GetString()));
306 fFitRes = fMC->GetPdf()->fitTo(*fData,
Save());
307 map<TGTripleHSlider*,const char*>::iterator it;;
308 it = fSliderMap.begin();
309 for(; it!=fSliderMap.end(); ++it){
311 param = (
RooRealVar*) fFitRes->floatParsFinal().find(it->second);
313 it->first->SetPointerPosition(param->
getVal());
320 void ModelInspectorGUI::DoSlider(
const char*
text)
322 cout <<
"." << text <<endl;
326 void ModelInspectorGUI::DoSlider()
334 if(strcmp(fMC->GetPdf()->ClassName(),
"RooSimultaneous")==0){
349 map<TGTripleHSlider*,const char*>::iterator it;;
351 fPlot = ((
RooRealVar*)fMC->GetObservables()->first())->frame();
352 fData->plotOn(fPlot);
356 it = fSliderMap.begin();
357 for(; it!=fSliderMap.end(); ++it){
358 const char* name = it->second;
359 fWS->var(name)->setVal(it->first->GetMaxPosition());
361 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]",param->
GetName(),it->first->GetPointerPosition(),it->first->GetMinPosition(),it->first->GetMaxPosition()));
363 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
367 it = fSliderMap.begin();
368 for(; it!=fSliderMap.end(); ++it){
369 const char* name = it->second;
370 fWS->var(name)->setVal(it->first->GetMinPosition());
372 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
376 it = fSliderMap.begin();
377 for(; it!=fSliderMap.end(); ++it){
378 const char* name = it->second;
379 fWS->var(name)->setVal(it->first->GetPointerPosition());
381 normCount = fMC->GetPdf()->expectedEvents(*fMC->GetObservables());
385 fCanvas->GetCanvas()->Modified();
386 fCanvas->GetCanvas()->Update();
396 Int_t frameIndex = 0;
399 fCanvas->GetCanvas()->cd(frameIndex);
406 fPlot = fPlotList.at(frameIndex-1);
407 if(fPlot)
delete fPlot;
408 fPlot = obs->
frame();
409 fPlotList.at(frameIndex-1) = fPlot;
417 map<TGTripleHSlider*,const char*>::iterator it;;
421 it = fSliderMap.begin();
422 for(; it!=fSliderMap.end(); ++it){
423 const char* name = it->second;
424 fWS->var(name)->setVal(it->first->GetMaxPosition());
426 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]",param->
GetName(),it->first->GetPointerPosition(),it->first->GetMinPosition(),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->GetMinPosition());
438 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]",param->
GetName(),it->first->GetPointerPosition(),it->first->GetMinPosition(),it->first->GetMaxPosition()));
444 it = fSliderMap.begin();
445 for(; it!=fSliderMap.end(); ++it){
446 const char* name = it->second;
447 fWS->var(name)->setVal(it->first->GetPointerPosition());
449 fLabelMap[it->first]->SetText(
Form(
"%s = %.3f [%.3f,%.3f]",param->
GetName(),it->first->GetPointerPosition(),it->first->GetMinPosition(),it->first->GetMaxPosition()));
464 fCanvas->GetCanvas()->Modified();
465 fCanvas->GetCanvas()->Update();
474 void ModelInspectorGUI::HandleButtons()
483 fHslider1->SetConstrained(fCheck1->GetState());
486 fHslider1->SetRelative(fCheck2->GetState());
492 void ModelInspectorGUI::DoExit()
494 printf(
"Exit application...");
500 const char* workspaceName =
"combined",
501 const char* modelConfigName =
"ModelConfig",
502 const char* dataName =
"obsData"){
505 cout <<
"You must use ACLIC for this. Use ModelInspector.C+"<<endl;
516 filename =
"results/example_combined_GaussExample_model.root";
521 cout <<
"HistFactory file cannot be generated on Windows - exit" << endl;
525 cout <<
"will run standard hist2workspace example"<<endl;
526 gROOT->ProcessLine(
".! prepareHistFactory .");
527 gROOT->ProcessLine(
".! hist2workspace config/example.xml");
528 cout <<
"\n\n---------------------"<<endl;
529 cout <<
"Done creating example input"<<endl;
530 cout <<
"---------------------\n\n"<<endl;
542 cout <<
"StandardRooStatsDemoMacro: Input file " << filename <<
" is not found" << endl;
555 cout <<
"workspace not found" << endl;
568 cout <<
"data or ModelConfig was not found" <<endl;
572 new ModelInspectorGUI(w,mc,data);
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.
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...
RooCmdArg Cut(const char *cutSpec)
RooCmdArg LineColor(Color_t color)
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found...
RooCmdArg VisualizeError(const RooDataSet ¶mData, Double_t Z=1)
R__EXTERN void * gTQSender
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
const RooAbsCategoryLValue & indexCat() const
void DoFit(THnSparse *s, TF1 *f, ROOT::Fit::BinData &bd)
static const char * filename()
virtual Double_t getMin(const char *name=0) 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)
R__EXTERN TApplication * gApplication
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events from this p.d.f for use in extended likelihood calculations.
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.
RooAbsArg * first() 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.
Int_t numTypes(const char *=0) const
TIterator * createIterator(Bool_t dir=kIterForward) const
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state...
Double_t getVal(const RooArgSet *set=0) const
RooRealVar represents a fundamental (non-derived) real valued object.
RooFit::MsgLevel globalKillBelow() const
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
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.
void ModelInspector(const char *infile="", const char *workspaceName="combined", const char *modelConfigName="ModelConfig", const char *dataName="obsData")
char * Form(const char *fmt,...)
void setGlobalKillBelow(RooFit::MsgLevel level)
virtual const char * GetName() const
Returns name of object.
RooAbsData is the common abstract base class for binned and unbinned datasets.
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
RooCategory represents a fundamental (non-derived) discrete value object.
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
RooCmdArg FillColor(Color_t color)
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
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.
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name) ...
virtual Double_t getMax(const char *name=0) const
RooCmdArg Save(Bool_t flag=kTRUE)
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
void Print(Option_t *opts=0) const
Print contents of the workspace.
virtual TObject * Next()=0
virtual void SetPosition(Float_t min, Float_t max)
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset...
virtual const Text_t * GetName() const
Returns name of object.
TIterator * typeIterator() const
Return iterator over all defined states.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
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.
Double_t getError() const