Logo ROOT  
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, const 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(const 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  std::unique_ptr<TH1> MakeScaledUncertaintyHist(const std::string& Name,
113  std::vector< std::pair<const TH1*, const TH1*> > HistVec ) const;
114 
115  TH1* MakeAbsolUncertaintyHist( const std::string& Name, const TH1* Hist );
116 
118  std::vector<std::string>& constraintTerms,
119  ParamHistFunc& paramHist, const 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(const 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
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelWorkspace
RooWorkspace * MakeSingleChannelWorkspace(Measurement &measurement, Channel &channel)
Definition: HistoToWorkspaceFactoryFast.cxx:1203
RooWorkspace.h
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fSystToFix
std::vector< std::string > fSystToFix
Definition: HistoToWorkspaceFactoryFast.h:125
RooStats::HistFactory::Sample
Definition: Sample.h:27
RooAbsReal.h
TDirectory.h
RooStats::HistFactory::HistoToWorkspaceFactoryFast
Definition: HistoToWorkspaceFactoryFast.h:42
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeTotalExpected
void MakeTotalExpected(RooWorkspace *proto, std::string totName, std::vector< std::string > &syst_x_expectedPrefixNames, std::vector< std::string > &normByNames)
Definition: HistoToWorkspaceFactoryFast.cxx:745
RooArgSet.h
RooStats::HistFactory::HistoToWorkspaceFactoryFast::LinInterpWithConstraint
void LinInterpWithConstraint(RooWorkspace *proto, const TH1 *nominal, std::vector< HistoSys >, std::string prefix, std::string productPrefix, std::string systTerm, std::vector< std::string > &likelihoodTermNames)
Definition: HistoToWorkspaceFactoryFast.cxx:412
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeScaledUncertaintyHist
std::unique_ptr< TH1 > MakeScaledUncertaintyHist(const std::string &Name, std::vector< std::pair< const TH1 *, const TH1 * > > HistVec) const
Definition: HistoToWorkspaceFactoryFast.cxx:2457
RooStats::HistFactory::HistoToWorkspaceFactoryFast::ConfigureHistFactoryDataset
void ConfigureHistFactoryDataset(RooDataSet *obsData, TH1 *nominal, RooWorkspace *proto, std::vector< std::string > obsNameVec)
Definition: HistoToWorkspaceFactoryFast.cxx:2045
RooStats::HistFactory::HistoToWorkspaceFactoryFast::SetFunctionsToPreprocess
void SetFunctionsToPreprocess(std::vector< std::string > lines)
Definition: HistoToWorkspaceFactoryFast.h:62
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeCombinedModel
RooWorkspace * MakeCombinedModel(std::vector< std::string >, std::vector< RooWorkspace * >)
Definition: HistoToWorkspaceFactoryFast.cxx:2115
RooArgList
Definition: RooArgList.h:21
RooStats::HistFactory::HistoToWorkspaceFactoryFast::AddConstraintTerms
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)
Definition: HistoToWorkspaceFactoryFast.cxx:592
RooStats::HistFactory::HistoToWorkspaceFactoryFast::AddPoissonTerms
void AddPoissonTerms(RooWorkspace *proto, std::string prefix, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin, std::vector< std::string > &likelihoodTermNames)
Definition: HistoToWorkspaceFactoryFast.cxx:824
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fObsNameVec
std::vector< std::string > fObsNameVec
Definition: HistoToWorkspaceFactoryFast.h:136
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fLowBin
int fLowBin
Definition: HistoToWorkspaceFactoryFast.h:129
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fParamValues
std::map< std::string, double > fParamValues
Definition: HistoToWorkspaceFactoryFast.h:126
RooStats::HistFactory::HistoToWorkspaceFactoryFast::EditSyst
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)
Definition: HistoToWorkspaceFactoryFast.cxx:889
RooFit::HistFactory
@ HistFactory
Definition: RooGlobalFunc.h:69
RooFitResult
Definition: RooFitResult.h:40
RooStats::HistFactory::HistoToWorkspaceFactoryFast::ProcessExpectedHisto
void ProcessExpectedHisto(const TH1 *hist, RooWorkspace *proto, std::string prefix, std::string productPrefix, std::string systTerm)
Definition: HistoToWorkspaceFactoryFast.cxx:326
RooStats::HistFactory::Channel
Definition: Channel.h:30
RooStats::HistFactory::Measurement
Definition: Measurement.h:42
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fObsName
std::string fObsName
Definition: HistoToWorkspaceFactoryFast.h:137
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fNomLumi
double fNomLumi
Definition: HistoToWorkspaceFactoryFast.h:127
RooStats::HistFactory::HistoToWorkspaceFactoryFast::createStatConstraintTerms
RooArgList createStatConstraintTerms(RooWorkspace *proto, std::vector< std::string > &constraintTerms, ParamHistFunc &paramHist, const TH1 *uncertHist, Constraint::Type type, Double_t minSigma)
Definition: HistoToWorkspaceFactoryFast.cxx:2591
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fLumiError
double fLumiError
Definition: HistoToWorkspaceFactoryFast.h:128
RooStats::HistFactory::HistoToWorkspaceFactoryFast::ConfigureWorkspaceForMeasurement
static void ConfigureWorkspaceForMeasurement(const std::string &ModelName, RooWorkspace *ws_single, Measurement &measurement)
Definition: HistoToWorkspaceFactoryFast.cxx:114
RooStats::HistFactory::HistoToWorkspaceFactoryFast::AddNormFactor
std::string AddNormFactor(RooWorkspace *proto, std::string &channel, std::string &sigmaEpsilon, Sample &sample, bool doRatio)
Definition: HistoToWorkspaceFactoryFast.cxx:525
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelModel
RooWorkspace * MakeSingleChannelModel(Measurement &measurement, Channel &channel)
Definition: HistoToWorkspaceFactoryFast.cxx:236
RooPlot.h
RooStats::HistFactory::Constraint::Type
Type
Definition: Systematics.h:43
RooStats::HistFactory::HistoToWorkspaceFactoryFast::GuessObsNameVec
void GuessObsNameVec(const TH1 *hist)
Definition: HistoToWorkspaceFactoryFast.cxx:2096
RooRealVar.h
RooFitResult.h
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fPreprocessFunctions
std::vector< std::string > fPreprocessFunctions
Definition: HistoToWorkspaceFactoryFast.h:138
xmlio::Name
const char * Name
Definition: TXMLSetup.cxx:73
proto
const char * proto
Definition: civetweb.c:16604
RooWorkspace
Definition: RooWorkspace.h:43
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject.h
RooCategory
Definition: RooCategory.h:27
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeAbsolUncertaintyHist
TH1 * MakeAbsolUncertaintyHist(const std::string &Name, const TH1 *Hist)
Definition: HistoToWorkspaceFactoryFast.cxx:2397
RooStats
Definition: Asimov.h:19
RooStats::HistFactory::HistoToWorkspaceFactoryFast::SetObsToExpected
void SetObsToExpected(RooWorkspace *proto, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin)
Definition: HistoToWorkspaceFactoryFast.cxx:848
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TH1
Definition: TH1.h:57
RooStats::HistFactory::HistoToWorkspaceFactoryFast::HistoToWorkspaceFactoryFast
HistoToWorkspaceFactoryFast()
Definition: HistoToWorkspaceFactoryFast.cxx:93
ParamHistFunc
Definition: ParamHistFunc.h:32
RooDataSet
Definition: RooDataSet.h:33
type
int type
Definition: TGX11.cxx:121
RooStats::HistFactory::HistoToWorkspaceFactoryFast::~HistoToWorkspaceFactoryFast
virtual ~HistoToWorkspaceFactoryFast()
Definition: HistoToWorkspaceFactoryFast.cxx:98
Systematics.h
RooStats::HistFactory::HistoToWorkspaceFactoryFast::AddMultiVarGaussConstraint
void AddMultiVarGaussConstraint(RooWorkspace *proto, std::string prefix, int lowBin, int highBin, std::vector< std::string > &likelihoodTermNames)
Definition: HistoToWorkspaceFactoryFast.cxx:381
RooStats::HistFactory::HistoToWorkspaceFactoryFast::PrintCovarianceMatrix
static void PrintCovarianceMatrix(RooFitResult *result, RooArgSet *params, std::string filename)
Definition: HistoToWorkspaceFactoryFast.cxx:1170
TH1.h
RooArgSet
Definition: RooArgSet.h:28
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MergeDataSets
RooDataSet * MergeDataSets(RooWorkspace *combined, std::vector< RooWorkspace * > wspace_vec, std::vector< std::string > channel_names, std::string dataSetName, RooArgList obsList, RooCategory *channelCat)
Definition: HistoToWorkspaceFactoryFast.cxx:2342
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fHighBin
int fHighBin
Definition: HistoToWorkspaceFactoryFast.h:130