ROOT  6.06/09
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 #include "RooStats/ModelConfig.h"
14 
15 
16 namespace RooStats {
17  namespace HistFactory {
18 
20 
21 
22  public:
23 
24  // Initialze 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 
31  virtual ~HistFactoryNavigation() {}
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
57  void PrintModelAndData(RooDataSet* data);
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=NULL);
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 minimial 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 
103  int GetMaxBinToPrint() const { return _maxBinToPrint; }
104 
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 NULL
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=NULL);
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 varous 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 funciton
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
TH1 * MakeHistFromRooFunction(RooAbsReal *func, RooArgList vars, std::string name="Hist")
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Definition: ModelConfig.h:52
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
The Histogram stack class.
Definition: THStack.h:35
RooRealVar * var(const std::string &varName) const
void PrintMultiDimHist(TH1 *hist, int bin_print_width)
RooAbsReal * GetConstraintTerm(const std::string &parameter)
TH1 * GetSampleHist(const std::string &channel, const std::string &sample, const std::string &name="")
RooAbsArg * findChild(const std::string &name, RooAbsReal *parent) const
void PrintChannelParameters(const std::string &channel, bool IncludeConstantParams=false)
std::map< std::string, RooAbsPdf * > fChannelPdfMap
#define ClassDef(name, id)
Definition: Rtypes.h:254
void PrintSampleComponents(const std::string &channel, const std::string &sample)
THStack * GetChannelStack(const std::string &channel, const std::string &name="")
void ReplaceNode(const std::string &ToReplace, RooAbsArg *ReplaceWith)
RooAbsReal * SampleFunction(const std::string &channel, const std::string &sample)
TH1 * GetChannelHist(const std::string &channel, const std::string &name="")
std::map< std::string, RooArgSet * > fChannelObservMap
std::map< std::string, std::map< std::string, RooAbsReal * > > fChannelSampleFunctionMap
void PrintDataSet(RooDataSet *data, const std::string &channel="")
double GetBinValue(int bin, const std::string &channel)
Namespace for the RooStats classes.
Definition: Asimov.h:20
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
void PrintSampleParameters(const std::string &channel, const std::string &sample, bool IncludeConstantParams=false)
TH1 * GetDataHist(RooDataSet *data, const std::string &channel, const std::string &name="")
double func(double *x, double *p)
Definition: stressTF1.cxx:213
The TH1 histogram class.
Definition: TH1.h:80
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
#define name(a, b)
Definition: linkTestLib0.cpp:5
std::map< std::string, RooAbsReal * > GetSampleFunctionMap(const std::string &channel)
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
#define NULL
Definition: Rtypes.h:82
void PrintParameters(bool IncludeConstantParams=false)
double GetConstraintUncertainty(const std::string &parameter)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
std::vector< std::string > GetChannelSampleList(const std::string &channel)
RooAbsPdf * GetChannelPdf(const std::string &channel)
std::map< std::string, RooAbsPdf * > fChannelSumNodeMap
RooArgSet * GetObservableSet(const std::string &channel)
void SetConstant(const std::string &regExpr=".*", bool constant=true)
void DrawChannel(const std::string &channel, RooDataSet *data=NULL)