CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ToyMCSamplerOpt.h
Go to the documentation of this file.
1 #ifndef ROOT_ToyMCSamplerOpt_h
2 #define ROOT_ToyMCSamplerOpt_h
3 
4 #include <RooStats/ToyMCSampler.h>
5 struct RooProdPdf;
6 struct RooPoisson;
7 
8 namespace toymcoptutils {
10  public:
12  SinglePdfGenInfo(RooAbsPdf &pdf, const RooArgSet& observables, bool preferBinned, const RooDataSet* protoData = NULL, int forceEvents = 0) ;
14  RooAbsData *generate(const RooDataSet* protoData = NULL, int forceEvents = 0) ;
15  RooDataSet *generateAsimov(RooRealVar *&weightVar) ;
16  RooDataSet *generatePseudoAsimov(RooRealVar *&weightVar, int nPoints) ;
17  const RooAbsPdf * pdf() const { return pdf_; }
18  void setCacheTemplates(bool cache) { keepHistoSpec_ = cache; }
19  private:
21  RooAbsPdf *pdf_;
22  RooArgSet observables_;
23  RooAbsPdf::GenSpec *spec_;
24  TH1 *histoSpec_;
26  RooRealVar *weightVar_;
27  RooDataSet *generateWithHisto(RooRealVar *&weightVar, bool asimov) ;
28  RooDataSet *generateCountingAsimov() ;
29  void setToExpected(RooProdPdf &prod, RooArgSet &obs) ;
30  void setToExpected(RooPoisson &pois, RooArgSet &obs) ;
31  };
32  class SimPdfGenInfo {
33  public:
34  SimPdfGenInfo(RooAbsPdf &pdf, const RooArgSet& observables, bool preferBinned, const RooDataSet* protoData = NULL, int forceEvents = 0) ;
35  ~SimPdfGenInfo() ;
36  RooAbsData *generate(RooRealVar *&weightVar, const RooDataSet* protoData = NULL, int forceEvents = 0) ;
37  RooAbsData *generateAsimov(RooRealVar *&weightVar) ;
38  void setCopyData(bool copyData) { copyData_ = copyData; }
39  void setCacheTemplates(bool cache) ;
40  private:
41  RooAbsPdf *pdf_;
42  RooAbsCategoryLValue *cat_;
43  RooArgSet observables_;
44  std::vector<SinglePdfGenInfo *> pdfs_;
45  RooArgSet ownedCrap_;
46  std::map<std::string,RooAbsData*> datasetPieces_;
47  bool copyData_;
48  //std::map<std::string,RooDataSet*> datasetPieces_;
49 
50  };
51 }
52 
53 class ToyMCSamplerOpt : public RooStats::ToyMCSampler{
54  public:
55  ToyMCSamplerOpt(RooStats::TestStatistic& ts, Int_t ntoys, RooAbsPdf *globalObsPdf = 0, bool generateNuisances = false) ;
56  ToyMCSamplerOpt(const RooStats::ToyMCSampler &base) ;
57  ToyMCSamplerOpt(const ToyMCSamplerOpt &other) ;
59  virtual void SetPdf(RooAbsPdf& pdf) ;
60  void setGlobalObsPdf(RooAbsPdf *pdf) { globalObsPdf_ = pdf; }
61  virtual RooAbsData* GenerateToyData(RooArgSet& /*nullPOI*/, double& weight) const ;
62  private:
63  RooAbsData* Generate(RooAbsPdf& pdf, RooArgSet& observables, const RooDataSet* protoData = NULL, int forceEvents = 0) const ;
64  RooAbsPdf *globalObsPdf_;
65  mutable RooDataSet *globalObsValues_;
66  mutable int globalObsIndex_;
67 
68  // We can't use the NuisanceParameterSampler because, even if public, there's no interface file for it
69  mutable RooDataSet *nuisValues_;
70  mutable int nuisIndex_;
71 
72  mutable RooRealVar *weightVar_;
73  mutable std::map<RooAbsPdf *, toymcoptutils::SimPdfGenInfo *> genCache_;
74 
75 };
76 
77 #endif
tuple base
Main Program
Definition: newFWLiteAna.py:92
RooAbsCategoryLValue * cat_
ToyMCSamplerOpt(RooStats::TestStatistic &ts, Int_t ntoys, RooAbsPdf *globalObsPdf=0, bool generateNuisances=false)
RooDataSet * nuisValues_
RooAbsData * Generate(RooAbsPdf &pdf, RooArgSet &observables, const RooDataSet *protoData=NULL, int forceEvents=0) const
RooAbsData * generateAsimov(RooRealVar *&weightVar)
RooAbsData * generate(const RooDataSet *protoData=NULL, int forceEvents=0)
#define NULL
Definition: scimark2.h:8
RooDataSet * globalObsValues_
std::map< std::string, RooAbsData * > datasetPieces_
const RooAbsPdf * pdf() const
virtual RooAbsData * GenerateToyData(RooArgSet &, double &weight) const
RooDataSet * generatePseudoAsimov(RooRealVar *&weightVar, int nPoints)
void setToExpected(RooProdPdf &prod, RooArgSet &obs)
std::map< RooAbsPdf *, toymcoptutils::SimPdfGenInfo * > genCache_
void setCacheTemplates(bool cache)
RooAbsData * generate(RooRealVar *&weightVar, const RooDataSet *protoData=NULL, int forceEvents=0)
virtual void SetPdf(RooAbsPdf &pdf)
RooDataSet * generateWithHisto(RooRealVar *&weightVar, bool asimov)
void setCopyData(bool copyData)
RooAbsPdf * globalObsPdf_
RooDataSet * generateAsimov(RooRealVar *&weightVar)
std::vector< SinglePdfGenInfo * > pdfs_
SimPdfGenInfo(RooAbsPdf &pdf, const RooArgSet &observables, bool preferBinned, const RooDataSet *protoData=NULL, int forceEvents=0)
void setGlobalObsPdf(RooAbsPdf *pdf)
SinglePdfGenInfo(RooAbsPdf &pdf, const RooArgSet &observables, bool preferBinned, const RooDataSet *protoData=NULL, int forceEvents=0)
RooRealVar * weightVar_