Logo ROOT  
Reference Guide
HistFactoryNavigation.h
Go to the documentation of this file.
1#ifndef INCLUDE_HISTFACTORYNAVIGATION_H
2#define INCLUDE_HISTFACTORYNAVIGATION_H
3
4#include <map>
5
6#include "TH1.h"
7#include "THStack.h"
8
9#include "RooDataSet.h"
10#include "RooRealVar.h"
11#include "RooProduct.h"
13
14namespace RooStats {
15 class ModelConfig;
16 namespace HistFactory {
17
19
20
21 public:
22
23 /// Initialze based on an already-created HistFactory Model
25 HistFactoryNavigation(const std::string& File,
26 const std::string& WorkspaceName="combined",
27 const std::string& ModelConfigName="ModelConfig");
28 HistFactoryNavigation(RooAbsPdf* model, RooArgSet* observables);
29
31
32 /// Should pretty print all channels and the current values

33 void PrintState();
34 /// Should pretty print this and the current values
35 void PrintState(const std::string& channel);
36
37 /// Print the current values and errors of pdf parameters
38 void PrintParameters(bool IncludeConstantParams=false);
39
40 /// Print parameters that effect a particular channel
41 void PrintChannelParameters(const std::string& channel,
42 bool IncludeConstantParams=false);
43
44 /// Print parameters that effect a particular sample
45 void PrintSampleParameters(const std::string& channel, const std::string& sample,
46 bool IncludeConstantParams=false);
47
48 /// Print the different components that make up a sample
49 /// (NormFactors, Statistical Uncertainties, Interpolation, etc)
50 void PrintSampleComponents(const std::string& channel, const std::string& sample);
51
52 /// Print a "HistFactory style" RooDataSet in a readable way
53 void PrintDataSet(RooDataSet* data, const std::string& channel="");
54
55 /// Print the model and the data, comparing channel by channel
56 void PrintModelAndData(RooDataSet* data);
57
58 /// The value of the ith bin for the total in that channel
59 double GetBinValue(int bin, const std::string& channel);
60 /// The value of the ith bin for that sample and channel

61 double GetBinValue(int bin, const std::string& channel, const std::string& sample);
62
63 /// The (current) histogram for that sample
64 /// This includes all parameters and interpolation
65 TH1* GetSampleHist(const std::string& channel,
66 const std::string& sample, const std::string& name="");
67
68 /// Get the total channel histogram for this channel
69 TH1* GetChannelHist(const std::string& channel, const std::string& name="");
70
71 /// Get a histogram from the dataset for this channel
72 TH1* GetDataHist(RooDataSet* data, const std::string& channel, const std::string& name="");
73
74 /// Get a stack of all samples in a channel
75 THStack* GetChannelStack(const std::string& channel, const std::string& name="");
76
77 /// Draw a stack of the channel, and include data if the pointer is supplied
78 void DrawChannel(const std::string& channel, RooDataSet* data=NULL);
79
80 /// Get the RooAbsReal function for a given sample in a given channel
81 RooAbsReal* SampleFunction(const std::string& channel, const std::string& sample);
82
83 /// Get the set of observables for a given channel
84 RooArgSet* GetObservableSet(const std::string& channel);
85
86 /// Get the constraint term for a given systematic (alpha or gamma)
87 RooAbsReal* GetConstraintTerm(const std::string& parameter);
88
89 /// Get the uncertainty based on the constraint term for a given systematic
90 double GetConstraintUncertainty(const std::string& parameter);
91
92 /// Find a node in the pdf and replace it with a new node
93 /// These nodes can be functions, pdf's, RooRealVar's, etc
94 /// Will do minimial checking to make sure the replacement makes sense
95 void ReplaceNode(const std::string& ToReplace, RooAbsArg* ReplaceWith);
96
97 // Set any RooRealVar's const (or not const) if they match
98 // the supplied regular expression
99 void SetConstant(const std::string& regExpr=".*", bool constant=true);
100
101 void SetMaxBinToPrint(int max) { _maxBinToPrint = max; }
102 int GetMaxBinToPrint() const { return _maxBinToPrint; }
103
104 void SetMinBinToPrint(int min) { _minBinToPrint = min; }
105 int GetMinBinToPrint() const { return _minBinToPrint; }
106
107 /// Get the model for this channel
108 RooAbsPdf* GetModel() const { return fModel; }
109
110 //
111 RooAbsPdf* GetChannelPdf(const std::string& channel);
112
113
114 std::vector< std::string > GetChannelSampleList(const std::string& channel);
115
116 // Return the RooRealVar by the same name used in the model
117 // If not found, return NULL
118 RooRealVar* var(const std::string& varName) const;
119
120 /*
121 // Add a channel to the pdf
122 // Combine the data if it is provided
123 void AddChannel(const std::string& channel, RooAbsPdf* pdf, RooDataSet* data=NULL);
124 */
125
126 /*
127 // Add a constraint term to the pdf
128 // This method requires that the pdf NOT be simultaneous
129 void AddConstraintTerm(RooAbsArg* constraintTerm);
130
131 // Add a constraint term to the pdf of a particular channel
132 // This method requires that the pdf be simultaneous
133 // OR that the channel string match the channel that the pdf represents
134 void AddConstraintTerm(RooAbsArg* constraintTerm, const std::string& channel);
135 */
136
137 protected:
138
139 /// Set the title and bin widths
140 void SetPrintWidths(const std::string& channel);
141
142 /// Fetch the node information for the pdf in question, and
143 /// save it in the varous collections in this class
144 void _GetNodes(ModelConfig* mc);
145 void _GetNodes(RooAbsPdf* model, const RooArgSet* observables);
146
147 /// Print a histogram's contents to the screen
148 /// void PrettyPrintHistogram(TH1* hist);
149 void PrintMultiDimHist(TH1* hist, int bin_print_width);
150
151 /// Make a histogram from a funciton
152 /// Edit so it can take a RooArgSet of parameters
153 TH1* MakeHistFromRooFunction( RooAbsReal* func, RooArgList vars, std::string name="Hist" );
154
155 /// Get a map of sample names to their functions for a particular channel
156 std::map< std::string, RooAbsReal*> GetSampleFunctionMap(const std::string& channel);
157
158 private:
159
160 /// The HistFactory Pdf Pointer
162
163 /// The observables
165
168
171
172 /// The list of channels
173 std::vector<std::string> fChannelNameVec;
174
175 /// Map of channel names to their full pdf's
176 std::map< std::string, RooAbsPdf* > fChannelPdfMap;
177
178 /// Map of channel names to pdf without constraint
179 std::map< std::string, RooAbsPdf* > fChannelSumNodeMap;
180
181 /// Map of channel names to their set of ovservables
182 std::map< std::string, RooArgSet*> fChannelObservMap;
183
184 /// Map of Map of Channel, Sample names to Function Nodes
185 /// Used by doing: fChannelSampleFunctionMap["MyChannel"]["MySample"]
186 std::map< std::string, std::map< std::string, RooAbsReal*> > fChannelSampleFunctionMap;
187
188 /// Internal method implementation of finding a daughter node
189 /// from a parent node (looping over all generations)
190 RooAbsArg* findChild(const std::string& name, RooAbsReal* parent) const;
191
192 /// Recursively get all products of products
194
195
196 protected:
198
199 };
200
201 }
202}
203#endif // INCLUDE_HISTFACTORYNAVIGATION_H
#define ClassDef(name, id)
Definition: Rtypes.h:322
char name[80]
Definition: TGX11.cxx:109
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:73
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:60
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
A RooProduct represents the product of a given set of RooAbsReal objects.
Definition: RooProduct.h:30
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
void PrintParameters(bool IncludeConstantParams=false)
Print the current values and errors of pdf parameters.
std::vector< std::string > fChannelNameVec
The list of channels.
RooArgSet * GetObservableSet(const std::string &channel)
Get the set of observables for a given channel.
TH1 * GetDataHist(RooDataSet *data, const std::string &channel, const std::string &name="")
Get a histogram from the dataset for this channel.
void _GetNodes(ModelConfig *mc)
Fetch the node information for the pdf in question, and save it in the varous collections in this cla...
std::map< std::string, RooAbsPdf * > fChannelSumNodeMap
Map of channel names to pdf without constraint.
void ReplaceNode(const std::string &ToReplace, RooAbsArg *ReplaceWith)
Find a node in the pdf and replace it with a new node These nodes can be functions,...
void PrintState()
Should pretty print all channels and the current values

void PrintSampleComponents(const std::string &channel, const std::string &sample)
Print the different components that make up a sample (NormFactors, Statistical Uncertainties,...
void SetPrintWidths(const std::string &channel)
Set the title and bin widths.
RooAbsPdf * fModel
The HistFactory Pdf Pointer.
TH1 * GetChannelHist(const std::string &channel, const std::string &name="")
Get the total channel histogram for this channel.
TH1 * GetSampleHist(const std::string &channel, const std::string &sample, const std::string &name="")
The (current) histogram for that sample This includes all parameters and interpolation.
TH1 * MakeHistFromRooFunction(RooAbsReal *func, RooArgList vars, std::string name="Hist")
Make a histogram from a funciton Edit so it can take a RooArgSet of parameters.
void PrintMultiDimHist(TH1 *hist, int bin_print_width)
Print a histogram's contents to the screen void PrettyPrintHistogram(TH1* hist);.
void DrawChannel(const std::string &channel, RooDataSet *data=NULL)
Draw a stack of the channel, and include data if the pointer is supplied.
void PrintSampleParameters(const std::string &channel, const std::string &sample, bool IncludeConstantParams=false)
Print parameters that effect a particular sample.
std::map< std::string, RooAbsReal * > GetSampleFunctionMap(const std::string &channel)
Get a map of sample names to their functions for a particular channel.
RooAbsReal * SampleFunction(const std::string &channel, const std::string &sample)
Get the RooAbsReal function for a given sample in a given channel.
HistFactoryNavigation(ModelConfig *mc)
Initialze based on an already-created HistFactory Model.
double GetBinValue(int bin, const std::string &channel)
The value of the ith bin for the total in that channel.
RooAbsArg * findChild(const std::string &name, RooAbsReal *parent) const
Internal method implementation of finding a daughter node from a parent node (looping over all genera...
std::map< std::string, std::map< std::string, RooAbsReal * > > fChannelSampleFunctionMap
Map of Map of Channel, Sample names to Function Nodes Used by doing: fChannelSampleFunctionMap["MyCha...
std::map< std::string, RooAbsPdf * > fChannelPdfMap
Map of channel names to their full pdf's.
std::vector< std::string > GetChannelSampleList(const std::string &channel)
RooAbsPdf * GetModel() const
Get the model for this channel.
void PrintModelAndData(RooDataSet *data)
Print the model and the data, comparing channel by channel.
std::map< std::string, RooArgSet * > fChannelObservMap
Map of channel names to their set of ovservables.
RooAbsPdf * GetChannelPdf(const std::string &channel)
void PrintDataSet(RooDataSet *data, const std::string &channel="")
Print a "HistFactory style" RooDataSet in a readable way.
void PrintChannelParameters(const std::string &channel, bool IncludeConstantParams=false)
Print parameters that effect a particular channel.
void SetConstant(const std::string &regExpr=".*", bool constant=true)
RooArgSet _GetAllProducts(RooProduct *node)
Recursively get all products of products.
THStack * GetChannelStack(const std::string &channel, const std::string &name="")
Get a stack of all samples in a channel.
RooAbsReal * GetConstraintTerm(const std::string &parameter)
Get the constraint term for a given systematic (alpha or gamma)
RooRealVar * var(const std::string &varName) const
double GetConstraintUncertainty(const std::string &parameter)
Get the uncertainty based on the constraint term for a given systematic.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Definition: ModelConfig.h:30
The TH1 histogram class.
Definition: TH1.h:56
The Histogram stack class.
Definition: THStack.h:31
@ HistFactory
Definition: RooGlobalFunc.h:69
Namespace for the RooStats classes.
Definition: Asimov.h:19