Logo ROOT   6.14/05
Reference Guide
HistoToWorkspaceFactoryFast.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_HISTOTOWORKSPACEFACTORYFAST
12 #define ROOSTATS_HISTOTOWORKSPACEFACTORYFAST
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 
31 class ParamHistFunc;
32 
33 
34 namespace RooStats{
35  namespace HistFactory{
36 
37  // Forward Declarations FTW
38  class Measurement;
39  class Channel;
40  class Sample;
41 
43 
44  public:
45 
46 
50 
51  static void ConfigureWorkspaceForMeasurement( const std::string& ModelName,
52  RooWorkspace* ws_single,
53  Measurement& measurement );
54 
55  RooWorkspace* MakeSingleChannelModel( Measurement& measurement, Channel& channel );
56  RooWorkspace* MakeCombinedModel(std::vector<std::string>, std::vector<RooWorkspace*>);
57 
58  static RooWorkspace* MakeCombinedModel( Measurement& measurement );
59  static void PrintCovarianceMatrix(RooFitResult* result, RooArgSet* params,
60  std::string filename);
61 
62  void SetFunctionsToPreprocess(std::vector<std::string> lines) { fPreprocessFunctions=lines; }
63 
64  protected:
65 
66  void AddConstraintTerms(RooWorkspace* proto, Measurement& measurement, std::string prefix, std::string interpName,
67  std::vector<OverallSys>& systList,
68  std::vector<std::string>& likelihoodTermNames,
69  std::vector<std::string>& totSystTermNames);
70 
71  std::string AddNormFactor(RooWorkspace* proto, std::string& channel,
72  std::string& sigmaEpsilon, Sample& sample, bool doRatio);
73 
74  void AddMultiVarGaussConstraint(RooWorkspace* proto, std::string prefix,
75  int lowBin, int highBin,
76  std::vector<std::string>& likelihoodTermNames);
77 
78  void AddPoissonTerms(RooWorkspace* proto, std::string prefix, std::string obsPrefix,
79  std::string expPrefix, int lowBin, int highBin,
80  std::vector<std::string>& likelihoodTermNames);
81 
82  static void EditSyst(RooWorkspace* proto, const char* pdfNameChar,
83  std::map<std::string,double> gammaSyst,
84  std::map<std::string,double> uniformSyst,
85  std::map<std::string,double> logNormSyst,
86  std::map<std::string,double> noSyst);
87 
88  void LinInterpWithConstraint(RooWorkspace* proto, TH1* nominal, std::vector<HistoSys>,
89  std::string prefix, std::string productPrefix,
90  std::string systTerm,
91  std::vector<std::string>& likelihoodTermNames);
92 
94 
95  void MakeTotalExpected(RooWorkspace* proto, std::string totName,
96  std::vector<std::string>& syst_x_expectedPrefixNames,
97  std::vector<std::string>& normByNames);
98 
100  std::vector<RooWorkspace*> wspace_vec,
101  std::vector<std::string> channel_names,
102  std::string dataSetName,
103  RooArgList obsList,
104  RooCategory* channelCat);
105 
106  void ProcessExpectedHisto(TH1* hist, RooWorkspace* proto, std::string prefix,
107  std::string productPrefix, std::string systTerm );
108 
109  void SetObsToExpected(RooWorkspace* proto, std::string obsPrefix, std::string expPrefix,
110  int lowBin, int highBin);
111 
112  TH1* MakeScaledUncertaintyHist(const std::string& Name,
113  std::vector< std::pair<TH1*, TH1*> > HistVec );
114 
115  TH1* MakeAbsolUncertaintyHist( const std::string& Name, const TH1* Hist );
116 
118  std::vector<std::string>& constraintTerms,
119  ParamHistFunc& paramHist, TH1* uncertHist,
120  Constraint::Type type, Double_t minSigma );
121 
122  void ConfigureHistFactoryDataset(RooDataSet* obsData, TH1* nominal, RooWorkspace* proto,
123  std::vector<std::string> obsNameVec);
124 
125  std::vector<std::string> fSystToFix;
126  std::map<std::string, double> fParamValues;
127  double fNomLumi;
128  double fLumiError;
129  int fLowBin;
130  int fHighBin;
131 
132  private:
133 
134  void GuessObsNameVec(TH1* hist);
135 
136  std::vector<std::string> fObsNameVec;
137  std::string fObsName;
138  std::vector<std::string> fPreprocessFunctions;
139 
141  };
142 
143  }
144 }
145 
146 #endif
RooWorkspace * MakeCombinedModel(std::vector< std::string >, std::vector< RooWorkspace *>)
void AddMultiVarGaussConstraint(RooWorkspace *proto, std::string prefix, int lowBin, int highBin, std::vector< std::string > &likelihoodTermNames)
void AddPoissonTerms(RooWorkspace *proto, std::string prefix, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin, std::vector< std::string > &likelihoodTermNames)
static 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, std::map< std::string, double > noSyst)
RooWorkspace * MakeSingleChannelWorkspace(Measurement &measurement, Channel &channel)
RooDataSet * MergeDataSets(RooWorkspace *combined, std::vector< RooWorkspace *> wspace_vec, std::vector< std::string > channel_names, std::string dataSetName, RooArgList obsList, RooCategory *channelCat)
static void ConfigureWorkspaceForMeasurement(const std::string &ModelName, RooWorkspace *ws_single, Measurement &measurement)
std::string AddNormFactor(RooWorkspace *proto, std::string &channel, std::string &sigmaEpsilon, Sample &sample, bool doRatio)
const char * Name
Definition: TXMLSetup.cxx:66
void SetFunctionsToPreprocess(std::vector< std::string > lines)
#define ClassDef(name, id)
Definition: Rtypes.h:320
void ProcessExpectedHisto(TH1 *hist, RooWorkspace *proto, std::string prefix, std::string productPrefix, std::string systTerm)
void AddConstraintTerms(RooWorkspace *proto, Measurement &measurement, std::string prefix, std::string interpName, std::vector< OverallSys > &systList, std::vector< std::string > &likelihoodTermNames, std::vector< std::string > &totSystTermNames)
void LinInterpWithConstraint(RooWorkspace *proto, TH1 *nominal, std::vector< HistoSys >, std::string prefix, std::string productPrefix, std::string systTerm, std::vector< std::string > &likelihoodTermNames)
void SetObsToExpected(RooWorkspace *proto, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin)
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
RooWorkspace * MakeSingleChannelModel(Measurement &measurement, Channel &channel)
Namespace for the RooStats classes.
Definition: Asimov.h:20
double Double_t
Definition: RtypesCore.h:55
int type
Definition: TGX11.cxx:120
The TH1 histogram class.
Definition: TH1.h:56
static void PrintCovarianceMatrix(RooFitResult *result, RooArgSet *params, std::string filename)
Mother of all ROOT objects.
Definition: TObject.h:37
TH1 * MakeScaledUncertaintyHist(const std::string &Name, std::vector< std::pair< TH1 *, TH1 *> > HistVec)
const char * proto
Definition: civetweb.c:15049
TH1 * MakeAbsolUncertaintyHist(const std::string &Name, const TH1 *Hist)
void ConfigureHistFactoryDataset(RooDataSet *obsData, TH1 *nominal, RooWorkspace *proto, std::vector< std::string > obsNameVec)
void MakeTotalExpected(RooWorkspace *proto, std::string totName, std::vector< std::string > &syst_x_expectedPrefixNames, std::vector< std::string > &normByNames)
RooArgList createStatConstraintTerms(RooWorkspace *proto, std::vector< std::string > &constraintTerms, ParamHistFunc &paramHist, TH1 *uncertHist, Constraint::Type type, Double_t minSigma)
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43