42using std::runtime_error;
60 _nll(
"input",
"-log(L) function",
this,
nllIn)
88 _paramFixed(
other._paramFixed)
103 target->setVal(var->getVal()) ;
114 std::cout <<
"Error: Must initialize data before initializing cache" << std::endl;
115 throw std::runtime_error(
"Uninitialized Data");
118 std::cout <<
"Error: Must initialize model pdf before initializing cache" << std::endl;
119 throw std::runtime_error(
"Uninitialized model pdf");
129 RooArgSet*
obsSet = std::unique_ptr<RooArgSet>{_pdf->getObservables(*_data)}.release();
133 std::cout <<
"Error: Found no observable terms with pdf: " << _pdf->GetName()
134 <<
" using dataset: " << _data->GetName() << std::endl;
137 if( constraints.
empty() ) {
138 std::cout <<
"Error: Found no constraint terms with pdf: " << _pdf->GetName()
139 <<
" using dataset: " << _data->GetName() << std::endl;
157 if( ! hasStatUncert ) {
160 <<
" doesn't have statistical uncertainties"
166 if(verbose) std::cout <<
"Found ParamHistFunc: " <<
param_func->GetName() << std::endl;
188 if(!
gamma_stat)
throw std::runtime_error(
"ParamHistFunc contains non-RooRealVar, not supported in RooBarlowBeestonLL");
190 if(verbose) std::cout <<
"Ignoring constant gamma: " <<
gamma_stat->GetName() << std::endl;
197 _statUncertParams.insert(
gamma_stat->GetName() );
215 std::cout <<
"Failed to find pois mean or tau parameter for " <<
gamma_stat->GetName() << std::endl;
219 std::cout <<
"Found pois mean and tau for parameter: " <<
gamma_stat->GetName() <<
" tau: " << tau->
GetName()
231 std::cout <<
"Failed to find RooRealSumPdf in channel " <<
channel_name
232 <<
", therefor skipping this channel for analytic uncertainty minimization"
241 std::cout <<
"Error: channel with name: " <<
channel_name
242 <<
" not found in BinDataMap" << std::endl;
243 throw runtime_error(
"BinDataMap");
255 <<
" to the barlow cache" << std::endl;
317 toRemove.reserve( _statUncertParams.size());
324 if( _statUncertParams.find(arg->GetName()) != _statUncertParams.end() ) {
339const RooArgSet& RooStats::HistFactory::RooBarlowBeestonLL::bestFitParams() const
342 return _paramAbsMin ;
348const RooArgSet& RooStats::HistFactory::RooBarlowBeestonLL::bestFitObs() const
406 std::map< std::string, std::vector< BarlowCache > >::iterator
iter_cache;
410 std::vector< BarlowCache >&
channel_cache = (*iter_cache).second;
514 double C = -1*m_val*
nu_b;
519 std::cout <<
"Warning: Discriminant (B*B - 4AC) < 0" << std::endl;
520 std::cout <<
"Warning: Taking B*B - 4*A*C == 0" << std::endl;
525 std::cout <<
"Warning: A <= 0" << std::endl;
526 throw runtime_error(
"BarlowBeestonLL::evaluate() : A < 0");
540 std::cout <<
"ERROR: gamma hat hat is NAN" << std::endl;
541 throw runtime_error(
"BarlowBeestonLL::evaluate() : gamma hat hat is NAN");
545 std::cout <<
"WARNING: gamma hat hat <= 0. Setting to 0" << std::endl;
592void RooStats::HistFactory::RooBarlowBeestonLL::validateAbsMin() const
594 // Check if constant status of any of the parameters have changed
598 while((par=(RooAbsArg*)_piter->Next())) {
599 if (_paramFixed[par->GetName()] != par->isConstant()) {
600 cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") constant status of parameter " << par->GetName() << " has changed from "
601 << (_paramFixed[par->GetName()]?"fixed":"floating") << " to " << (par->isConstant()?"fixed":"floating")
602 << ", recalculating absolute minimum" << endl ;
603 _absMinValid = false ;
610 // If we don't have the absolute minimum w.r.t all observables, calculate that first
613 cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") determining minimum likelihood for current configurations w.r.t all observable" << endl ;
616 // Save current values of non-marginalized parameters
617 std::unique_ptr<RooArgSet> obsStart{(RooArgSet*) _obs.snapshot(false)};
619 // Start from previous global minimum
620 if (_paramAbsMin.size()>0) {
621 const_cast<RooSetProxy&>(_par).assignValueOnly(_paramAbsMin) ;
623 if (_obsAbsMin.size()>0) {
624 const_cast<RooSetProxy&>(_obs).assignValueOnly(_obsAbsMin) ;
627 // Find minimum with all observables floating
628 const_cast<RooSetProxy&>(_obs).setAttribAll("Constant",false) ;
631 // Save value and remember
633 _absMinValid = true ;
635 // Save parameter values at abs minimum as well
636 _paramAbsMin.removeAll() ;
638 // Only store non-constant parameters here!
639 std::unique_ptr<RooArgSet> tmp{_par.selectByAttrib("Constant",false)};
640 _paramAbsMin.addClone(*tmp) ;
642 _obsAbsMin.addClone(_obs) ;
644 // Save constant status of all parameters
647 while((par=(RooAbsArg*)_piter->Next())) {
648 _paramFixed[par->GetName()] = par->isConstant() ;
651 if (dologI(Minimization)) {
652 cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") minimum found at (" ;
657 while ((arg=(RooAbsReal*)_oiter->Next())) {
658 ccxcoutI(Minimization) << (first?"":", ") << arg->GetName() << "=" << arg->getVal() ;
661 ccxcoutI(Minimization) << ")" << endl ;
664 // Restore original parameter values
665 const_cast<RooSetProxy&>(_obs) = *obsStart ;
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
const_iterator begin() const
const_iterator end() const
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Object to represent discrete states.
Variable that can be changed from the outside.
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooAbsReal * nom_pois_mean
void SetBinCenter() const
Class RooBarlowBeestonLL implements the profile likelihood estimator for a given likelihood and set o...
double evaluate() const override
Optimized implementation of createProfile for profile likelihoods.
bool getParameters(const RooArgSet *depList, RooArgSet &outputSet, bool stripDisconnected=true) const override
Fills a list with leaf nodes in the arg tree starting with ourself as top node that don't match any o...
RooBarlowBeestonLL()
Default constructor. Should only be used by proof.
void initializeBarlowCache()
const char * GetName() const override
Returns name of object.
bool getStatUncertaintyFromChannel(RooAbsPdf *channel, ParamHistFunc *¶mfunc, RooArgList *gammaList)
void FactorizeHistFactoryPdf(const RooArgSet &, RooAbsPdf &, RooArgList &, RooArgList &)
void getDataValuesForObservables(std::map< std::string, std::vector< double > > &ChannelBinDataMap, RooAbsData *data, RooAbsPdf *simPdf)
RooAbsPdf * getSumPdfFromChannel(RooAbsPdf *channel)
int getStatUncertaintyConstraintTerm(RooArgList *constraints, RooRealVar *gamma_stat, RooAbsReal *&pois_mean, RooRealVar *&tau)