Logo ROOT   6.12/07
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 
14 namespace 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");
29 
30  virtual ~HistFactoryNavigation() {}
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
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:30
The Histogram stack class.
Definition: THStack.h:31
RooAbsArg * findChild(const std::string &name, RooAbsReal *parent) 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="")
void PrintChannelParameters(const std::string &channel, bool IncludeConstantParams=false)
std::map< std::string, RooAbsPdf *> fChannelPdfMap
#define ClassDef(name, id)
Definition: Rtypes.h:320
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="")
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
std::map< std::string, RooArgSet * > fChannelObservMap
RooRealVar * var(const std::string &varName) const
std::map< std::string, std::map< std::string, RooAbsReal * > > fChannelSampleFunctionMap
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
RooProduct a RooAbsReal implementation that represent the product of a given set of other RooAbsReal ...
Definition: RooProduct.h:32
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="")
The TH1 histogram class.
Definition: TH1.h:56
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
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)
char name[80]
Definition: TGX11.cxx:109
void SetConstant(const std::string &regExpr=".*", bool constant=true)
void DrawChannel(const std::string &channel, RooDataSet *data=NULL)