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

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

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