50   RooAbsReal(
"RooBarlowBeestonLL",
"RooBarlowBeestonLL"),
 
   54  _pdf(nullptr), _data(nullptr)
 
   66  _nll(
"input",
"-log(L) function",this,nllIn),
 
   69  _pdf(nullptr), _data(nullptr)
 
   95  _nll(
"nll",this,other._nll),
 
   98  _pdf(nullptr), _data(nullptr),
 
   99  _paramFixed(other._paramFixed)
 
  112  for (
auto const *var : static_range_cast<RooRealVar *>(*bin_center)) {
 
  114    target->setVal(var->getVal()) ;
 
  125    std::cout << 
"Error: Must initialize data before initializing cache" << std::endl;
 
  126    throw std::runtime_error(
"Uninitialized Data");
 
  129    std::cout << 
"Error: Must initialize model pdf before initializing cache" << std::endl;
 
  130    throw std::runtime_error(
"Uninitialized model pdf");
 
  134  std::map< std::string, std::vector<double> > ChannelBinDataMap;
 
  140  RooArgSet* obsSet = std::unique_ptr<RooArgSet>{_pdf->getObservables(*_data)}.release();
 
  143  if( obsTerms.
empty() ) {
 
  144    std::cout << 
"Error: Found no observable terms with pdf: " << _pdf->GetName()
 
  145         << 
" using dataset: " << _data->GetName() << std::endl;
 
  148  if( constraints.
empty() ) {
 
  149    std::cout << 
"Error: Found no constraint terms with pdf: " << _pdf->GetName()
 
  150         << 
" using dataset: " << _data->GetName() << std::endl;
 
  164  for (
const auto& nameIdx : *channelCat) {
 
  169    std::string channel_name = channelPdf->
GetName();
 
  175    if( ! hasStatUncert ) {
 
  177   std::cout << 
"Channel: " << channel_name
 
  178        << 
" doesn't have statistical uncertainties" 
  184      if(verbose) std::cout << 
"Found ParamHistFunc: " << param_func->
GetName() << std::endl;
 
  191    int num_bins = param_func->
numBins();
 
  196    std::vector<BarlowCache> temp_cache( num_bins );
 
  197    bool channel_has_stat_uncertainty=
false;
 
  199    for( 
Int_t bin_index = 0; bin_index < num_bins; ++bin_index ) {
 
  206      if(!gamma_stat) 
throw std::runtime_error(
"ParamHistFunc contains non-RooRealVar, not supported in RooBarlowBeestonLL");
 
  208   if(verbose) std::cout << 
"Ignoring constant gamma: " << gamma_stat->
GetName() << std::endl;
 
  213   channel_has_stat_uncertainty=
true;
 
  214   cache.
gamma = gamma_stat;
 
  215   _statUncertParams.insert( gamma_stat->
GetName() );
 
  232      if( !tau || !pois_mean ) {
 
  233   std::cout << 
"Failed to find pois mean or tau parameter for " << gamma_stat->
GetName() << std::endl;
 
  236   if(verbose) std::cout << 
"Found pois mean and tau for parameter: " << gamma_stat->
GetName()
 
  238               << 
" pois_mean: " << pois_mean->
GetName() << 
" " << pois_mean->
getVal()
 
  247      if( sum_pdf == 
nullptr )  {
 
  248   std::cout << 
"Failed to find RooRealSumPdf in channel " <<  channel_name
 
  249        << 
", therefor skipping this channel for analytic uncertainty minimization" 
  251   channel_has_stat_uncertainty=
false;
 
  257      if( ChannelBinDataMap.find(channel_name) == ChannelBinDataMap.end() ) {
 
  258   std::cout << 
"Error: channel with name: " << channel_name
 
  259        << 
" not found in BinDataMap" << std::endl;
 
  260   throw runtime_error(
"BinDataMap");
 
  262      double nData = ChannelBinDataMap[channel_name].at(bin_index);
 
  265      temp_cache.at(bin_index) = cache;
 
  270    if( channel_has_stat_uncertainty ) {
 
  271      std::cout << 
"Adding channel: " << channel_name
 
  272      << 
" to the barlow cache" << std::endl;
 
  273      _barlowCache[channel_name] = temp_cache;
 
  330                                                              bool stripDisconnected)
 const {
 
  334  toRemove.
reserve( _statUncertParams.size());
 
  336  for (
auto const& arg : outputSet) {
 
  341    if( _statUncertParams.find(arg->GetName()) != _statUncertParams.end() ) {
 
  342      toRemove.
add( *arg );
 
  346  for( 
auto& arg : toRemove) outputSet.
remove( *arg, 
true );
 
  348  return errorInBaseCall || 
false;
 
  356const RooArgSet& RooStats::HistFactory::RooBarlowBeestonLL::bestFitParams() const
 
  359  return _paramAbsMin ;
 
  365const RooArgSet& RooStats::HistFactory::RooBarlowBeestonLL::bestFitObs() const
 
  424  std::map< std::string, std::vector< BarlowCache > >::iterator iter_cache;
 
  425  for( iter_cache = _barlowCache.begin(); iter_cache != _barlowCache.end(); ++iter_cache ) {
 
  427    std::string channel_name = (*iter_cache).first;
 
  428    std::vector< BarlowCache >& channel_cache = (*iter_cache).second;
 
  443    for( 
unsigned int i = 0; i < channel_cache.size(); ++i ) {
 
  449    std::vector< double > nu_b_vec( channel_cache.size() );
 
  450    for( 
unsigned int i = 0; i < channel_cache.size(); ++i ) {
 
  460      nu_b_vec.at(i) = nu_b;
 
  465    for( 
unsigned int i = 0; i < channel_cache.size(); ++i ) {
 
  471    std::vector< double > nu_b_stat_vec( channel_cache.size() );
 
  472    for( 
unsigned int i = 0; i < channel_cache.size(); ++i ) {
 
  481      double nu_b_stat = sum_pdf->
getVal(*obsSet)*sum_pdf->
expectedEvents(*obsSet)*binVolume - nu_b_vec.at(i);
 
  482      nu_b_stat_vec.at(i) = nu_b_stat;
 
  493    for( 
unsigned int i = 0; i < channel_cache.size(); ++i ) {
 
  517      double nu_b = nu_b_vec.at(i);
 
  518      double nu_b_stat = nu_b_stat_vec.at(i);
 
  520      double tau_val = tau->
getVal();
 
  521      double nData = bin_cache.
nData;
 
  522      double m_val = pois_mean->
getVal();
 
  525      double gamma_hat_hat = 1.0;
 
  528      if(nu_b_stat > 0.00000001) {
 
  530   double A = nu_b_stat*nu_b_stat + tau_val*nu_b_stat;
 
  531   double B = nu_b*tau_val + nu_b*nu_b_stat - nData*nu_b_stat - m_val*nu_b_stat;
 
  532   double C = -1*m_val*nu_b;
 
  534   double discrim = B*B-4*A*C;
 
  537     std::cout << 
"Warning: Discriminant (B*B - 4AC) < 0" << std::endl;
 
  538     std::cout << 
"Warning: Taking B*B - 4*A*C == 0" << std::endl;
 
  543     std::cout << 
"Warning: A <= 0" << std::endl;
 
  544     throw runtime_error(
"BarlowBeestonLL::evaluate() : A < 0");
 
  547   gamma_hat_hat = ( -1*B + 
TMath::Sqrt(discrim) ) / (2*A);
 
  553   gamma_hat_hat = m_val/tau_val;
 
  558   std::cout << 
"ERROR: gamma hat hat is NAN" << std::endl;
 
  559   throw runtime_error(
"BarlowBeestonLL::evaluate() : gamma hat hat is NAN");
 
  562      if( gamma_hat_hat <= 0 ) {
 
  563   std::cout << 
"WARNING: gamma hat hat <= 0.  Setting to 0" << std::endl;
 
  580      gamma->setVal( gamma_hat_hat );
 
  610void RooStats::HistFactory::RooBarlowBeestonLL::validateAbsMin() const
 
  612  // Check if constant status of any of the parameters have changed
 
  616    while((par=(RooAbsArg*)_piter->Next())) {
 
  617      if (_paramFixed[par->GetName()] != par->isConstant()) {
 
  618   cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") constant status of parameter " << par->GetName() << " has changed from "
 
  619            << (_paramFixed[par->GetName()]?"fixed":"floating") << " to " << (par->isConstant()?"fixed":"floating")
 
  620            << ", recalculating absolute minimum" << endl ;
 
  621   _absMinValid = false ;
 
  628  // If we don't have the absolute minimum w.r.t all observables, calculate that first
 
  631    cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") determining minimum likelihood for current configurations w.r.t all observable" << endl ;
 
  634    // Save current values of non-marginalized parameters
 
  635    RooArgSet* obsStart = (RooArgSet*) _obs.snapshot(false) ;
 
  637    // Start from previous global minimum
 
  638    if (_paramAbsMin.getSize()>0) {
 
  639      const_cast<RooSetProxy&>(_par).assignValueOnly(_paramAbsMin) ;
 
  641    if (_obsAbsMin.getSize()>0) {
 
  642      const_cast<RooSetProxy&>(_obs).assignValueOnly(_obsAbsMin) ;
 
  645    // Find minimum with all observables floating
 
  646    const_cast<RooSetProxy&>(_obs).setAttribAll("Constant",false) ;
 
  649    // Save value and remember
 
  651    _absMinValid = true ;
 
  653    // Save parameter values at abs minimum as well
 
  654    _paramAbsMin.removeAll() ;
 
  656    // Only store non-constant parameters here!
 
  657    RooArgSet* tmp = (RooArgSet*) _par.selectByAttrib("Constant",false) ;
 
  658    _paramAbsMin.addClone(*tmp) ;
 
  661    _obsAbsMin.addClone(_obs) ;
 
  663    // Save constant status of all parameters
 
  666    while((par=(RooAbsArg*)_piter->Next())) {
 
  667      _paramFixed[par->GetName()] = par->isConstant() ;
 
  670    if (dologI(Minimization)) {
 
  671      cxcoutI(Minimization) << "RooStats::HistFactory::RooBarlowBeestonLL::evaluate(" << GetName() << ") minimum found at (" ;
 
  676      while ((arg=(RooAbsReal*)_oiter->Next())) {
 
  677   ccxcoutI(Minimization) << (first?"":", ") << arg->GetName() << "=" << arg->getVal() ;
 
  680      ccxcoutI(Minimization) << ")" << endl ;
 
  683    // Restore original parameter values
 
  684    const_cast<RooSetProxy&>(_obs) = *obsStart ;
 
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 RooArgSet * get(Int_t masterIdx) const
 
RooAbsReal & getParameter() const
 
bool isConstant() const
Check if the "Constant" attribute is set.
 
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...
 
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
 
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
 
void reserve(Storage_t::size_type count)
 
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
 
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
 
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.
 
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
 
RooCategory is an object to represent discrete states.
 
RooRealVar represents a variable that can be changed from the outside.
 
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
 
RooAbsPdf * getPdf(RooStringView catName) const
Return the p.d.f associated with the given index category name.
 
const RooAbsCategoryLValue & indexCat() const
 
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...
 
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)
 
Double_t Sqrt(Double_t x)
Returns the square root of x.