Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
HistoToWorkspaceFactoryFast.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id: cranmer $
2 // Author: Kyle Cranmer, Akira Shibata
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #ifndef ROOSTATS_HISTOTOWORKSPACEFACTORYFAST
12 #define ROOSTATS_HISTOTOWORKSPACEFACTORYFAST
13 
14 #include <vector>
15 #include <string>
16 #include <map>
17 #include <iostream>
18 #include <sstream>
19 
20 #include <RooPlot.h>
21 #include <RooArgSet.h>
22 #include <RooFitResult.h>
23 #include <RooAbsReal.h>
24 #include <RooRealVar.h>
25 #include <RooWorkspace.h>
26 #include <TObject.h>
27 #include <TH1.h>
28 #include <TDirectory.h>
29 
31 class ParamHistFunc;
32 
33 
34 namespace RooStats{
35  namespace HistFactory{
36 
37  // Forward Declarations FTW
38  class Measurement;
39  class Channel;
40  class Sample;
41 
42  class HistoToWorkspaceFactoryFast: public TObject {
43 
44  public:
45 
46 
47  HistoToWorkspaceFactoryFast();
48  HistoToWorkspaceFactoryFast( RooStats::HistFactory::Measurement& Meas );
49  virtual ~HistoToWorkspaceFactoryFast();
50 
51  static void ConfigureWorkspaceForMeasurement( const std::string& ModelName,
52  RooWorkspace* ws_single,
53  Measurement& measurement );
54 
55  RooWorkspace* MakeSingleChannelModel( Measurement& measurement, Channel& channel );
56  RooWorkspace* MakeCombinedModel(std::vector<std::string>, std::vector<RooWorkspace*>);
57 
58  static RooWorkspace* MakeCombinedModel( Measurement& measurement );
59  static void PrintCovarianceMatrix(RooFitResult* result, RooArgSet* params,
60  std::string filename);
61 
62  void SetFunctionsToPreprocess(std::vector<std::string> lines) { fPreprocessFunctions=lines; }
63 
64  protected:
65 
66  void AddConstraintTerms(RooWorkspace* proto, Measurement& measurement, std::string prefix, std::string interpName,
67  std::vector<OverallSys>& systList,
68  std::vector<std::string>& likelihoodTermNames,
69  std::vector<std::string>& totSystTermNames);
70 
71  std::string AddNormFactor(RooWorkspace* proto, std::string& channel,
72  std::string& sigmaEpsilon, Sample& sample, bool doRatio);
73 
74  void AddMultiVarGaussConstraint(RooWorkspace* proto, std::string prefix,
75  int lowBin, int highBin,
76  std::vector<std::string>& likelihoodTermNames);
77 
78  void AddPoissonTerms(RooWorkspace* proto, std::string prefix, std::string obsPrefix,
79  std::string expPrefix, int lowBin, int highBin,
80  std::vector<std::string>& likelihoodTermNames);
81 
82  static void EditSyst(RooWorkspace* proto, const char* pdfNameChar,
83  std::map<std::string,double> gammaSyst,
84  std::map<std::string,double> uniformSyst,
85  std::map<std::string,double> logNormSyst,
86  std::map<std::string,double> noSyst);
87 
88  void LinInterpWithConstraint(RooWorkspace* proto, const TH1* nominal, std::vector<HistoSys>,
89  std::string prefix, std::string productPrefix,
90  std::string systTerm,
91  std::vector<std::string>& likelihoodTermNames);
92 
93  RooWorkspace* MakeSingleChannelWorkspace(Measurement& measurement, Channel& channel);
94 
95  void MakeTotalExpected(RooWorkspace* proto, std::string totName,
96  std::vector<std::string>& syst_x_expectedPrefixNames,
97  std::vector<std::string>& normByNames);
98 
99  RooDataSet* MergeDataSets(RooWorkspace* combined,
100  std::vector<RooWorkspace*> wspace_vec,
101  std::vector<std::string> channel_names,
102  std::string dataSetName,
103  RooArgList obsList,
104  RooCategory* channelCat);
105 
106  void ProcessExpectedHisto(const TH1* hist, RooWorkspace* proto, std::string prefix,
107  std::string productPrefix, std::string systTerm );
108 
109  void SetObsToExpected(RooWorkspace* proto, std::string obsPrefix, std::string expPrefix,
110  int lowBin, int highBin);
111 
112  TH1* MakeScaledUncertaintyHist(const std::string& Name,
113  std::vector< std::pair<const TH1*, const TH1*> > HistVec );
114 
115  TH1* MakeAbsolUncertaintyHist( const std::string& Name, const TH1* Hist );
116 
117  RooArgList createStatConstraintTerms( RooWorkspace* proto,
118  std::vector<std::string>& constraintTerms,
119  ParamHistFunc& paramHist, const TH1* uncertHist,
120  Constraint::Type type, Double_t minSigma );
121 
122  void ConfigureHistFactoryDataset(RooDataSet* obsData, TH1* nominal, RooWorkspace* proto,
123  std::vector<std::string> obsNameVec);
124 
125  std::vector<std::string> fSystToFix;
126  std::map<std::string, double> fParamValues;
127  double fNomLumi;
128  double fLumiError;
129  int fLowBin;
130  int fHighBin;
131 
132  private:
133 
134  void GuessObsNameVec(const TH1* hist);
135 
136  std::vector<std::string> fObsNameVec;
137  std::string fObsName;
138  std::vector<std::string> fPreprocessFunctions;
139 
140  ClassDef(RooStats::HistFactory::HistoToWorkspaceFactoryFast,3)
141  };
142 
143  }
144 }
145 
146 #endif