Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
HistoToWorkspaceFactory.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id: cranmer $
2 // Author: Kyle Cranmer, Akira Shibata
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #ifndef ROOSTATS_HISTOTOWORKSPACEFACTORY
12 #define ROOSTATS_HISTOTOWORKSPACEFACTORY
13 
14 #include <vector>
15 #include <string>
16 #include <map>
17 #include <iostream>
18 #include <sstream>
19 
20 #include <RooPlot.h>
21 #include <RooArgSet.h>
22 #include <RooFitResult.h>
23 #include <RooAbsReal.h>
24 #include <RooRealVar.h>
25 #include <RooWorkspace.h>
26 #include <TObject.h>
27 #include <TH1.h>
28 #include <TDirectory.h>
29 
30 
31 namespace RooStats{
32 namespace HistFactory{
33 
34  struct EstimateSummary;
35 
36  class HistoToWorkspaceFactory: public TObject {
37 
38  public:
39 
40  HistoToWorkspaceFactory( std::string, std::string , std::vector<std::string> , double =200, double =20, int =0, int =6, TFile * =0);
41  HistoToWorkspaceFactory();
42  virtual ~HistoToWorkspaceFactory();
43 
44  void AddEfficiencyTerms(RooWorkspace* proto, std::string prefix, std::string interpName,
45  std::map<std::string,std::pair<double,double> > systMap,
46  std::vector<std::string>& likelihoodTermNames, std::vector<std::string>& totSystTermNames);
47 
48  std::string AddNormFactor(RooWorkspace *, std::string & , std::string & , EstimateSummary & , bool );
49 
50  void AddMultiVarGaussConstraint(RooWorkspace* proto, std::string prefix,int lowBin, int highBin, std::vector<std::string>& likelihoodTermNames);
51 
52  void AddPoissonTerms(RooWorkspace* proto, std::string prefix, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin,
53  std::vector<std::string>& likelihoodTermNames);
54 
55  //void Combine_old();
56 
57  RooWorkspace * MakeCombinedModel(std::vector<std::string>, std::vector<RooWorkspace*>);
58 
59  //void Combine_ratio(std::vector<std::string> , std::vector<RooWorkspace*>);
60 
61  void Customize(RooWorkspace* proto, const char* pdfNameChar, std::map<std::string,std::string> renameMap);
62 
63  void EditSyst(RooWorkspace* proto, const char* pdfNameChar, std::map<std::string,double> gammaSyst, std::map<std::string,double> uniformSyst, std::map<std::string,double> logNormSyst);
64 
65  void FormatFrameForLikelihood(RooPlot* frame, std::string XTitle=std::string("#sigma / #sigma_{SM}"), std::string YTitle=std::string("-log likelihood"));
66 
67 
68  void LinInterpWithConstraint(RooWorkspace* proto, TH1* nominal, std::vector<TH1*> lowHist, std::vector<TH1*> highHist,
69  std::vector<std::string> sourceName, std::string prefix, std::string productPrefix, std::string systTerm,
70  int lowBin, int highBin, std::vector<std::string>& likelihoodTermNames);
71 
72  TDirectory* Makedirs( TDirectory* file, std::vector<std::string> names );
73 
74  RooWorkspace* MakeSingleChannelModel(std::vector<RooStats::HistFactory::EstimateSummary> summary, std::vector<std::string> systToFix, bool doRatio=false);
75 
76  void MakeTotalExpected(RooWorkspace* proto, std::string totName, std::string /**/, std::string /**/,
77  int lowBin, int highBin, std::vector<std::string>& syst_x_expectedPrefixNames,
78  std::vector<std::string>& normByNames);
79 
80  TDirectory* Mkdir( TDirectory * file, std::string name );
81 
82  void PrintCovarianceMatrix(RooFitResult* result, RooArgSet* params, std::string filename);
83  void ProcessExpectedHisto(TH1* hist,RooWorkspace* proto, std::string prefix, std::string productPrefix, std::string systTerm, double low, double high, int lowBin, int highBin);
84  void SetObsToExpected(RooWorkspace* proto, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin);
85  void FitModel(RooWorkspace *, std::string, std::string, std::string, bool=false );
86  std::string FilePrefixStr(std::string);
87 
88 
89  std::string fFileNamePrefix;
90  std::string fRowTitle;
91  std::vector<std::string> fSystToFix;
92  double fNomLumi, fLumiError;
93  int fLowBin, fHighBin;
94  std::stringstream fResultsPrefixStr;
95  TFile * fOut_f;
96  FILE * pFile;
97 
98  ClassDef(RooStats::HistFactory::HistoToWorkspaceFactory,1)
99  };
100 
101 }
102 }
103 
104 #endif