CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
BestFitSigmaTestStat Class Reference

#include <BestFitSigmaTestStat.h>

Inheritance diagram for BestFitSigmaTestStat:

Public Member Functions

 BestFitSigmaTestStat (const RooArgSet &observables, RooAbsPdf &pdf, const RooArgSet *nuisances, const RooArgSet &params, int verbosity=0)
 
virtual Double_t Evaluate (RooAbsData &data, RooArgSet &nullPOI)
 
virtual const TString GetVarName () const
 
void setPrintLevel (Int_t level)
 

Private Member Functions

bool createNLL (RooAbsPdf &pdf, RooAbsData &data)
 
double minNLL (bool constrained, RooRealVar *r=0)
 

Private Attributes

std::auto_ptr< RooAbsReal > nll_
 
RooArgSet nuisances_
 
std::auto_ptr< RooArgSet > params_
 
RooAbsPdf * pdf_
 
RooArgSet poi_
 
RooArgSet snap_
 
Int_t verbosity_
 

Detailed Description

Definition at line 15 of file BestFitSigmaTestStat.h.

Constructor & Destructor Documentation

BestFitSigmaTestStat::BestFitSigmaTestStat ( const RooArgSet &  observables,
RooAbsPdf &  pdf,
const RooArgSet *  nuisances,
const RooArgSet &  params,
int  verbosity = 0 
)

Definition at line 42 of file BestFitSigmaTestStat.cc.

References nuisances_, params_, pdf_, poi_, and snap_.

48 :
49  pdf_(&pdf),
51 {
52  params.snapshot(snap_,false);
53  ((RooRealVar*)snap_.find(params.first()->GetName()))->setConstant(false);
54  poi_.add(snap_);
55  if (nuisances) { nuisances_.add(*nuisances); snap_.addClone(*nuisances, /*silent=*/true); }
56  params_.reset(pdf_->getParameters(observables));
57 }
std::auto_ptr< RooArgSet > params_

Member Function Documentation

bool BestFitSigmaTestStat::createNLL ( RooAbsPdf &  pdf,
RooAbsData &  data 
)
private

Definition at line 93 of file BestFitSigmaTestStat.cc.

References nll_, and nuisances_.

Referenced by Evaluate().

94 {
95  if (typeid(pdf) == typeid(RooSimultaneousOpt)) {
96  if (nll_.get() == 0) nll_.reset(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
97  else ((cacheutils::CachingSimNLL&)(*nll_)).setData(data);
98  return true;
99  } else {
100  nll_.reset(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
101  return false;
102  }
103 }
std::auto_ptr< RooAbsReal > nll_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Double_t BestFitSigmaTestStat::Evaluate ( RooAbsData &  data,
RooArgSet &  nullPOI 
)
virtual

Definition at line 60 of file BestFitSigmaTestStat.cc.

References gather_cfg::cout, createNLL(), minNLL(), nll_, params_, pdf_, poi_, alignCSCRings::r, and snap_.

61 {
62  // Take snapshot of initial state, to restore it at the end
63  RooArgSet initialState; params_->snapshot(initialState);
64 
65  // Initialize parameters
66  *params_ = snap_;
67 
68  // Initialize signal strength
69  RooRealVar *rIn = (RooRealVar *) poi_.first();
70  RooRealVar *r = (RooRealVar *) params_->find(rIn->GetName());
71  bool canKeepNLL = createNLL(*pdf_, data);
72 
73  double initialR = rIn->getVal();
74 
75  // Perform unconstrained minimization
76  r->setVal(initialR == 0 ? 0.5 : 0.5*initialR); //best guess
77  r->setConstant(false);
78 
79  std::cout << "Doing a fit for with " << r->GetName() << " in range [ " << r->getMin() << " , " << r->getMax() << "]" << std::endl;
80  std::cout << "Starting point is " << r->GetName() << " = " << r->getVal() << std::endl;
81  minNLL(/*constrained=*/false, r);
82  double bestFitR = r->getVal();
83  std::cout << "Fit result was " << r->GetName() << " = " << r->getVal() << std::endl;
84 
85  //Restore initial state, to avoid issues with ToyMCSampler
86  *params_ = initialState;
87 
88  if (!canKeepNLL) nll_.reset();
89 
90  return bestFitR;
91 }
bool createNLL(RooAbsPdf &pdf, RooAbsData &data)
std::auto_ptr< RooArgSet > params_
std::auto_ptr< RooAbsReal > nll_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple cout
Definition: gather_cfg.py:121
double minNLL(bool constrained, RooRealVar *r=0)
virtual const TString BestFitSigmaTestStat::GetVarName ( ) const
inlinevirtual

Definition at line 24 of file BestFitSigmaTestStat.h.

24 { return "mu-hat`"; }
double BestFitSigmaTestStat::minNLL ( bool  constrained,
RooRealVar *  r = 0 
)
private
void BestFitSigmaTestStat::setPrintLevel ( Int_t  level)
inline

Definition at line 27 of file BestFitSigmaTestStat.h.

References testEve_cfg::level, and verbosity_.

Member Data Documentation

std::auto_ptr<RooAbsReal> BestFitSigmaTestStat::nll_
private

Definition at line 33 of file BestFitSigmaTestStat.h.

Referenced by createNLL(), Evaluate(), and minNLL().

RooArgSet BestFitSigmaTestStat::nuisances_
private

Definition at line 31 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and createNLL().

std::auto_ptr<RooArgSet> BestFitSigmaTestStat::params_
private

Definition at line 32 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and Evaluate().

RooAbsPdf* BestFitSigmaTestStat::pdf_
private

Definition at line 30 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and Evaluate().

RooArgSet BestFitSigmaTestStat::poi_
private

Definition at line 31 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and Evaluate().

RooArgSet BestFitSigmaTestStat::snap_
private

Definition at line 31 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and Evaluate().

Int_t BestFitSigmaTestStat::verbosity_
private

Definition at line 34 of file BestFitSigmaTestStat.h.

Referenced by minNLL(), and setPrintLevel().