CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

BestFitSigmaTestStat Class Reference

#include <BestFitSigmaTestStat.h>

List of all members.

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_.

:
    pdf_(&pdf),
    verbosity_(verbosity)
{
    params.snapshot(snap_,false);
    ((RooRealVar*)snap_.find(params.first()->GetName()))->setConstant(false);
    poi_.add(snap_);
    if (nuisances) { nuisances_.add(*nuisances); snap_.addClone(*nuisances, /*silent=*/true); }
    params_.reset(pdf_->getParameters(observables));
}

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().

{
    if (typeid(pdf) == typeid(RooSimultaneousOpt)) {
        if (nll_.get() == 0) nll_.reset(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
        else ((cacheutils::CachingSimNLL&)(*nll_)).setData(data);
        return true;
    } else {
        nll_.reset(pdf.createNLL(data, RooFit::Constrain(nuisances_)));
        return false;
    }
}
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_.

{
    // Take snapshot of initial state, to restore it at the end 
    RooArgSet initialState; params_->snapshot(initialState);

   // Initialize parameters
    *params_ = snap_;

    // Initialize signal strength
    RooRealVar *rIn = (RooRealVar *) poi_.first();
    RooRealVar *r   = (RooRealVar *) params_->find(rIn->GetName());
    bool canKeepNLL = createNLL(*pdf_, data);

    double initialR = rIn->getVal();

    // Perform unconstrained minimization
    r->setVal(initialR == 0 ? 0.5 : 0.5*initialR); //best guess
    r->setConstant(false);

    std::cout << "Doing a fit for with " << r->GetName() << " in range [ " << r->getMin() << " , " << r->getMax() << "]" << std::endl;
    std::cout << "Starting point is " << r->GetName() << " = " << r->getVal() << std::endl;
    minNLL(/*constrained=*/false, r);
    double bestFitR = r->getVal();
    std::cout << "Fit result was " << r->GetName() << " = " << r->getVal() << std::endl;

    //Restore initial state, to avoid issues with ToyMCSampler
    *params_ = initialState;

    if (!canKeepNLL) nll_.reset();

    return bestFitR;
}
virtual const TString BestFitSigmaTestStat::GetVarName ( ) const [inline, virtual]

Definition at line 26 of file BestFitSigmaTestStat.h.

References testEve_cfg::level, and verbosity_.

double BestFitSigmaTestStat::minNLL ( bool  constrained,
RooRealVar *  r = 0 
) [private]
void BestFitSigmaTestStat::setPrintLevel ( Int_t  level) [inline]

Definition at line 29 of file BestFitSigmaTestStat.h.


Member Data Documentation

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

Definition at line 35 of file BestFitSigmaTestStat.h.

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

RooArgSet BestFitSigmaTestStat::nuisances_ [private]

Definition at line 33 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and createNLL().

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

Definition at line 34 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and Evaluate().

RooAbsPdf* BestFitSigmaTestStat::pdf_ [private]

Definition at line 32 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and Evaluate().

RooArgSet BestFitSigmaTestStat::poi_ [private]

Definition at line 33 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and Evaluate().

RooArgSet BestFitSigmaTestStat::snap_ [private]

Definition at line 33 of file BestFitSigmaTestStat.h.

Referenced by BestFitSigmaTestStat(), and Evaluate().

Definition at line 36 of file BestFitSigmaTestStat.h.

Referenced by GetVarName(), and minNLL().