File indexing completed on 2025-12-16 10:29:44
0001 #ifndef INCLUDE_HISTFACTORYNAVIGATION_H
0002 #define INCLUDE_HISTFACTORYNAVIGATION_H
0003
0004 #include <map>
0005 #include <vector>
0006 #include <string>
0007
0008 #include "TH1.h"
0009 #include "THStack.h"
0010
0011 #include "RooDataSet.h"
0012 #include "RooRealVar.h"
0013 #include "RooProduct.h"
0014 #include "RooStats/HistFactory/Measurement.h"
0015
0016 namespace RooStats {
0017 class ModelConfig;
0018 namespace HistFactory {
0019
0020 class HistFactoryNavigation {
0021
0022 public:
0023
0024
0025 HistFactoryNavigation(ModelConfig* mc);
0026 HistFactoryNavigation(const std::string& File,
0027 const std::string& WorkspaceName="combined",
0028 const std::string& ModelConfigName="ModelConfig");
0029 HistFactoryNavigation(RooAbsPdf* model, RooArgSet* observables);
0030
0031 virtual ~HistFactoryNavigation() {}
0032
0033
0034 void PrintState();
0035
0036 void PrintState(const std::string& channel);
0037
0038
0039 void PrintParameters(bool IncludeConstantParams=false);
0040
0041
0042 void PrintChannelParameters(const std::string& channel,
0043 bool IncludeConstantParams=false);
0044
0045
0046 void PrintSampleParameters(const std::string& channel, const std::string& sample,
0047 bool IncludeConstantParams=false);
0048
0049
0050
0051 void PrintSampleComponents(const std::string& channel, const std::string& sample);
0052
0053
0054 void PrintDataSet(RooDataSet* data, const std::string& channel="");
0055
0056
0057 void PrintModelAndData(RooDataSet* data);
0058
0059
0060 double GetBinValue(int bin, const std::string& channel);
0061
0062 double GetBinValue(int bin, const std::string& channel, const std::string& sample);
0063
0064
0065
0066 TH1* GetSampleHist(const std::string& channel,
0067 const std::string& sample, const std::string& name="");
0068
0069
0070 TH1* GetChannelHist(const std::string& channel, const std::string& name="");
0071
0072
0073 TH1* GetDataHist(RooDataSet* data, const std::string& channel, const std::string& name="");
0074
0075
0076 THStack* GetChannelStack(const std::string& channel, const std::string& name="");
0077
0078
0079 void DrawChannel(const std::string& channel, RooDataSet* data=nullptr);
0080
0081
0082 RooAbsReal* SampleFunction(const std::string& channel, const std::string& sample);
0083
0084
0085 RooArgSet* GetObservableSet(const std::string& channel);
0086
0087
0088 RooAbsReal* GetConstraintTerm(const std::string& parameter);
0089
0090
0091 double GetConstraintUncertainty(const std::string& parameter);
0092
0093
0094
0095
0096 void ReplaceNode(const std::string& ToReplace, RooAbsArg* ReplaceWith);
0097
0098
0099
0100 void SetConstant(const std::string& regExpr=".*", bool constant=true);
0101
0102 void SetMaxBinToPrint(int max) { _maxBinToPrint = max; }
0103 int GetMaxBinToPrint() const { return _maxBinToPrint; }
0104
0105 void SetMinBinToPrint(int min) { _minBinToPrint = min; }
0106 int GetMinBinToPrint() const { return _minBinToPrint; }
0107
0108
0109 RooAbsPdf* GetModel() const { return fModel; }
0110
0111
0112 RooAbsPdf* GetChannelPdf(const std::string& channel);
0113
0114
0115 std::vector< std::string > GetChannelSampleList(const std::string& channel);
0116
0117
0118
0119 RooRealVar* var(const std::string& varName) const;
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 protected:
0139
0140
0141 void SetPrintWidths(const std::string& channel);
0142
0143
0144
0145 void _GetNodes(ModelConfig* mc);
0146 void _GetNodes(RooAbsPdf* model, const RooArgSet* observables);
0147
0148
0149
0150 void PrintMultiDimHist(TH1* hist, int bin_print_width);
0151
0152
0153
0154 TH1* MakeHistFromRooFunction( RooAbsReal* func, RooArgList vars, std::string name="Hist" );
0155
0156
0157 std::map< std::string, RooAbsReal*> GetSampleFunctionMap(const std::string& channel);
0158
0159 private:
0160
0161
0162 RooAbsPdf* fModel;
0163
0164
0165 RooArgSet* fObservables;
0166
0167 int _minBinToPrint;
0168 int _maxBinToPrint;
0169
0170 int _label_print_width;
0171 int _bin_print_width;
0172
0173
0174 std::vector<std::string> fChannelNameVec;
0175
0176
0177 std::map< std::string, RooAbsPdf* > fChannelPdfMap;
0178
0179
0180 std::map< std::string, RooAbsPdf* > fChannelSumNodeMap;
0181
0182
0183 std::map< std::string, RooArgSet*> fChannelObservMap;
0184
0185
0186
0187 std::map< std::string, std::map< std::string, RooAbsReal*> > fChannelSampleFunctionMap;
0188
0189
0190
0191 RooAbsArg* findChild(const std::string& name, RooAbsReal* parent) const;
0192
0193
0194 RooArgSet _GetAllProducts(RooProduct* node);
0195
0196
0197 protected:
0198 ClassDef(RooStats::HistFactory::HistFactoryNavigation,2)
0199
0200 };
0201
0202 }
0203 }
0204 #endif