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 #include <memory>
20 
21 #include <RooPlot.h>
22 #include <RooArgSet.h>
23 #include <RooFitResult.h>
24 #include <RooAbsReal.h>
25 #include <RooRealVar.h>
26 #include <RooWorkspace.h>
27 #include <TObject.h>
28 #include <TH1.h>
29 #include <TDirectory.h>
30 
32 class ParamHistFunc;
33 
34 
35 namespace RooStats{
36  namespace HistFactory{
37 
38  // Forward Declarations FTW
39  class Measurement;
40  class Channel;
41  class Sample;
42 
44 
45  public:
46 
47 
51 
52  static void ConfigureWorkspaceForMeasurement( const std::string& ModelName,
53  RooWorkspace* ws_single,
54  Measurement& measurement );
55 
56  RooWorkspace* MakeSingleChannelModel( Measurement& measurement, Channel& channel );
57  RooWorkspace* MakeCombinedModel(std::vector<std::string>, std::vector<std::unique_ptr<RooWorkspace>>&);
58 
59  static RooWorkspace* MakeCombinedModel( Measurement& measurement );
60  static void PrintCovarianceMatrix(RooFitResult* result, RooArgSet* params,
61  std::string filename);
62 
63  void SetFunctionsToPreprocess(std::vector<std::string> lines) { fPreprocessFunctions=lines; }
64 
65  protected:
66 
67  void AddConstraintTerms(RooWorkspace* proto, Measurement& measurement, std::string prefix, std::string interpName,
68  std::vector<OverallSys>& systList,
69  std::vector<std::string>& likelihoodTermNames,
70  std::vector<std::string>& totSystTermNames);
71 
72  std::string AddNormFactor(RooWorkspace* proto, std::string& channel,
73  std::string& sigmaEpsilon, Sample& sample, bool doRatio);
74 
75  void AddMultiVarGaussConstraint(RooWorkspace* proto, std::string prefix,
76  int lowBin, int highBin,
77  std::vector<std::string>& likelihoodTermNames);
78 
79  void AddPoissonTerms(RooWorkspace* proto, std::string prefix, std::string obsPrefix,
80  std::string expPrefix, int lowBin, int highBin,
81  std::vector<std::string>& likelihoodTermNames);
82 
83  static void EditSyst(RooWorkspace* proto, const char* pdfNameChar,
84  std::map<std::string,double> gammaSyst,
85  std::map<std::string,double> uniformSyst,
86  std::map<std::string,double> logNormSyst,
87  std::map<std::string,double> noSyst);
88 
89  void LinInterpWithConstraint(RooWorkspace* proto, const TH1* nominal, std::vector<HistoSys>,
90  std::string prefix, std::string productPrefix,
91  std::string systTerm,
92  std::vector<std::string>& likelihoodTermNames);
93 
95 
96  void MakeTotalExpected(RooWorkspace* proto, std::string totName,
97  std::vector<std::string>& syst_x_expectedPrefixNames,
98  std::vector<std::string>& normByNames);
99 
101  std::vector<std::unique_ptr<RooWorkspace>>& wspace_vec,
102  std::vector<std::string> channel_names,
103  std::string dataSetName,
104  RooArgList obsList,
105  RooCategory* channelCat);
106 
107  void ProcessExpectedHisto(const TH1* hist, RooWorkspace* proto, std::string prefix,
108  std::string productPrefix, std::string systTerm );
109 
110  void SetObsToExpected(RooWorkspace* proto, std::string obsPrefix, std::string expPrefix,
111  int lowBin, int highBin);
112 
113  std::unique_ptr<TH1> MakeScaledUncertaintyHist(const std::string& Name,
114  std::vector< std::pair<const TH1*, const TH1*> > HistVec ) const;
115 
116  TH1* MakeAbsolUncertaintyHist( const std::string& Name, const TH1* Hist );
117 
119  std::vector<std::string>& constraintTerms,
120  ParamHistFunc& paramHist, const TH1* uncertHist,
121  Constraint::Type type, Double_t minSigma );
122 
123  void ConfigureHistFactoryDataset(RooDataSet* obsData, TH1* nominal, RooWorkspace* proto,
124  std::vector<std::string> obsNameVec);
125 
126  std::vector<std::string> fSystToFix;
127  std::map<std::string, double> fParamValues;
128  double fNomLumi;
129  double fLumiError;
130  int fLowBin;
131  int fHighBin;
132 
133  private:
134 
135  void GuessObsNameVec(const TH1* hist);
136 
137  std::vector<std::string> fObsNameVec;
138  std::string fObsName;
139  std::vector<std::string> fPreprocessFunctions;
140 
142  };
143 
144  }
145 }
146 
147 #endif
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelWorkspace
RooWorkspace * MakeSingleChannelWorkspace(Measurement &measurement, Channel &channel)
Definition: HistoToWorkspaceFactoryFast.cxx:1197
RooWorkspace.h
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fSystToFix
std::vector< std::string > fSystToFix
Definition: HistoToWorkspaceFactoryFast.h:126
RooStats::HistFactory::Sample
Definition: Sample.h:27
RooAbsReal.h
TDirectory.h
RooStats::HistFactory::HistoToWorkspaceFactoryFast
This class provides helper functions for creating likelihood models from histograms.
Definition: HistoToWorkspaceFactoryFast.h:43
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:739
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:407
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:2450
RooStats::HistFactory::HistoToWorkspaceFactoryFast::ConfigureHistFactoryDataset
void ConfigureHistFactoryDataset(RooDataSet *obsData, TH1 *nominal, RooWorkspace *proto, std::vector< std::string > obsNameVec)
Definition: HistoToWorkspaceFactoryFast.cxx:2039
RooStats::HistFactory::HistoToWorkspaceFactoryFast::SetFunctionsToPreprocess
void SetFunctionsToPreprocess(std::vector< std::string > lines)
Definition: HistoToWorkspaceFactoryFast.h:63
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
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:586
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:818
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fObsNameVec
std::vector< std::string > fObsNameVec
Definition: HistoToWorkspaceFactoryFast.h:137
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fLowBin
int fLowBin
Definition: HistoToWorkspaceFactoryFast.h:130
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fParamValues
std::map< std::string, double > fParamValues
Definition: HistoToWorkspaceFactoryFast.h:127
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:883
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeCombinedModel
RooWorkspace * MakeCombinedModel(std::vector< std::string >, std::vector< std::unique_ptr< RooWorkspace >> &)
Definition: HistoToWorkspaceFactoryFast.cxx:2109
RooFit::HistFactory
@ HistFactory
Definition: RooGlobalFunc.h:62
RooFitResult
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
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:321
RooStats::HistFactory::Channel
This class encapsulates all information for the statistical interpretation of one experiment.
Definition: Channel.h:30
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MergeDataSets
RooDataSet * MergeDataSets(RooWorkspace *combined, std::vector< std::unique_ptr< RooWorkspace >> &wspace_vec, std::vector< std::string > channel_names, std::string dataSetName, RooArgList obsList, RooCategory *channelCat)
Definition: HistoToWorkspaceFactoryFast.cxx:2335
RooStats::HistFactory::Measurement
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
Definition: Measurement.h:30
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fObsName
std::string fObsName
Definition: HistoToWorkspaceFactoryFast.h:138
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fNomLumi
double fNomLumi
Definition: HistoToWorkspaceFactoryFast.h:128
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:2584
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fLumiError
double fLumiError
Definition: HistoToWorkspaceFactoryFast.h:129
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:519
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelModel
RooWorkspace * MakeSingleChannelModel(Measurement &measurement, Channel &channel)
Definition: HistoToWorkspaceFactoryFast.cxx:236
RooPlot.h
RooStats::HistFactory::Constraint::Type
Type
Definition: Systematics.h:25
RooStats::HistFactory::HistoToWorkspaceFactoryFast::GuessObsNameVec
void GuessObsNameVec(const TH1 *hist)
Definition: HistoToWorkspaceFactoryFast.cxx:2090
RooRealVar.h
RooFitResult.h
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fPreprocessFunctions
std::vector< std::string > fPreprocessFunctions
Definition: HistoToWorkspaceFactoryFast.h:139
xmlio::Name
const char * Name
Definition: TXMLSetup.cxx:67
proto
const char * proto
Definition: civetweb.c:16604
RooWorkspace
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject.h
RooCategory
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:27
RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeAbsolUncertaintyHist
TH1 * MakeAbsolUncertaintyHist(const std::string &Name, const TH1 *Hist)
Definition: HistoToWorkspaceFactoryFast.cxx:2390
RooStats
Namespace for the RooStats classes.
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:842
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TH1
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
RooStats::HistFactory::HistoToWorkspaceFactoryFast::HistoToWorkspaceFactoryFast
HistoToWorkspaceFactoryFast()
Definition: HistoToWorkspaceFactoryFast.cxx:93
ParamHistFunc
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
Definition: ParamHistFunc.h:30
RooDataSet
RooDataSet is a container class to hold unbinned data.
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:376
RooStats::HistFactory::HistoToWorkspaceFactoryFast::PrintCovarianceMatrix
static void PrintCovarianceMatrix(RooFitResult *result, RooArgSet *params, std::string filename)
Definition: HistoToWorkspaceFactoryFast.cxx:1164
TH1.h
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:33
RooStats::HistFactory::HistoToWorkspaceFactoryFast::fHighBin
int fHighBin
Definition: HistoToWorkspaceFactoryFast.h:131