200        bool useWeights, 
bool cloneData, 
const char* newName,
 
  212  for (
const auto arg : yieldsList) {
 
  214      coutE(InputArguments) << 
"SPlot::SPlot(" << 
GetName() << 
") input argument " 
  215             << arg->GetName() << 
" is not of type RooRealVar (or RooLinearVar)." 
  216             << 
"\nRooStats must be able to set it to 0 and to 1 to probe the PDF." << endl ;
 
  217      throw std::invalid_argument(
Form(
"SPlot::SPlot(%s) input argument %s is not of type RooRealVar/RooLinearVar",
GetName(),arg->GetName())) ;
 
  225  this->
AddSWeight(pdf, yieldsList, projDeps, useWeights, arg5, arg6, arg7, arg8);
 
  255      coutE(InputArguments)  << 
"Invalid Entry Number" << endl;
 
  261      coutE(InputArguments)  << 
"Invalid Entry Number" << endl;
 
  265  double totalYield = 0;
 
  267  std::string varname(sVariable);
 
  289    coutE(InputArguments) << 
"InputVariable not in list of sWeighted variables" << endl;
 
  304      coutE(InputArguments)  << 
"Invalid Entry Number" << endl;
 
  310      coutE(InputArguments)  << 
"Invalid Entry Number" << endl;
 
  316  double eventSWeight = 0;
 
  320  for (
Int_t i = 0; i < numSWeightVars; i++)
 
  334  double totalYield = 0;
 
  336  std::string varname(sVariable);
 
  363    coutE(InputArguments) << 
"InputVariable not in list of sWeighted variables" << endl;
 
  420         const RooArgSet &projDeps, 
bool includeWeights,
 
  427  for (
unsigned int i=0; i < constParameters->size(); ++i) {
 
  429    auto& par = *(*constParameters)[i];
 
  430    if (std::any_of(yieldsTmp.
begin(), yieldsTmp.
end(), [&](
const RooAbsArg* yield){ return yield->dependsOn(par); })) {
 
  431      constParameters->remove(par, 
true, 
true);
 
  439  std::vector<RooAbsRealLValue*> constVarHolder;
 
  441  for(
Int_t i = 0; i < constParameters->getSize(); i++)
 
  447      constVarHolder.push_back(varTemp);
 
  457  vars.
remove(projDeps, 
true, 
true);
 
  460  std::vector<double> yieldsHolder;
 
  469    coutI(InputArguments) << 
"Printing Yields" << endl;
 
  475  std::vector<RooAbsRealLValue*> yieldvars ;
 
  479  std::vector<double> yieldvalues ;
 
  480  for (
Int_t k = 0; k < nspec; ++k) {
 
  481    auto thisyield = 
static_cast<const RooAbsReal*
>(yields.
at(k)) ;
 
  486      coutI(InputArguments)<< 
"yield in pdf: " << yieldinpdf->GetName() << 
" " << thisyield->getVal(&vars) << endl;
 
  488      yieldvars.push_back(yieldinpdf) ;
 
  489      yieldvalues.push_back(thisyield->getVal(&vars)) ;
 
  504    if (theVar->getMin() > 0) {
 
  505      coutE(InputArguments)  << 
"Yield variables need to have a range that includes at least [0, 1]. Minimum for " 
  506          << theVar->GetName() << 
" is " << theVar->getMin() << std::endl;
 
  508        coutE(InputArguments)  << 
"Setting min range to 0" << std::endl;
 
  511        throw std::invalid_argument(std::string(
"Yield variable ") + theVar->GetName() + 
" must have a range that includes 0.");
 
  515    if (theVar->getMax() < 1) {
 
  516      coutW(InputArguments)  << 
"Yield variables need to have a range that includes at least [0, 1]. Maximum for " 
  517          << theVar->GetName() << 
" is " << theVar->getMax() << std::endl;
 
  519        coutE(InputArguments)  << 
"Setting max range to 1" << std::endl;
 
  522        throw std::invalid_argument(std::string(
"Yield variable ") + theVar->GetName() + 
" must have a range that includes 1.");
 
  534  std::unique_ptr<RooArgSet> pdfvars{pdf->
getVariables()};
 
  535  std::vector<std::vector<double> > pdfvalues(numevents,std::vector<double>(nspec,0)) ;
 
  537  for (
Int_t ievt = 0; ievt <numevents; ievt++)
 
  543    for(
Int_t k = 0; k < nspec; ++k) {
 
  549      double f_k = pdf->
getVal(&vars) ;
 
  550      pdfvalues[ievt][k] = f_k ;
 
  551      if( !(f_k>1 || f_k<1) )
 
  552        coutW(InputArguments) << 
"Strange pdf value: " << ievt << 
" " << k << 
" " << f_k << std::endl ;
 
  553      theVar->setVal( 0 ) ;
 
  558  std::vector<double> norm(nspec,0) ;
 
  559  for (
Int_t ievt = 0; ievt <numevents ; ievt++)
 
  562      for(
Int_t k=0; k<nspec; ++k) dnorm += yieldvalues[k] * pdfvalues[ievt][k] ;
 
  563      for(
Int_t j=0; j<nspec; ++j) norm[j] += pdfvalues[ievt][j]/dnorm ;
 
  566  coutI(Contents) << 
"likelihood norms: "  ;
 
  568  for(
Int_t k=0; k<nspec; ++k)  
coutI(Contents) << norm[k] << 
" " ;
 
  569  coutI(Contents) << std::endl ;
 
  573  for (
Int_t i = 0; i < nspec; i++) 
for (
Int_t j = 0; j < nspec; j++) covInv(i,j) = 0;
 
  575  coutI(Contents) << 
"Calculating covariance matrix";
 
  579  for (
Int_t ievt = 0; ievt < numevents; ++ievt)
 
  589      for(
Int_t k = 0; k < nspec; ++k)
 
  590   dsum += pdfvalues[ievt][k] * yieldvalues[k] ;
 
  593   for(
Int_t j=0; j<nspec; ++j)
 
  596         covInv(
n,j) +=  
fSData->
weight()*pdfvalues[ievt][
n]*pdfvalues[ievt][j]/(dsum*dsum) ;
 
  598         covInv(
n,j) +=                   pdfvalues[ievt][
n]*pdfvalues[ievt][j]/(dsum*dsum) ;
 
  610      coutE(Eval) << 
"SPlot Error: covariance matrix is singular; I can't invert it!" << std::endl;
 
  619    coutI(Eval) << 
"Checking Likelihood normalization:  " << std::endl;
 
  620    coutI(Eval) << 
"Yield of specie  Sum of Row in Matrix   Norm" << std::endl;
 
  621    for(
Int_t k=0; k<nspec; ++k)
 
  624      for(
Int_t m=0; 
m<nspec; ++
m) covnorm += covInv[k][
m]*yieldvalues[
m] ;
 
  626      for(
Int_t m = 0; 
m < nspec; ++
m) sumrow += covMatrix[k][
m] ;
 
  627      coutI(Eval)  << yieldvalues[k] << 
" " << sumrow << 
" " << covnorm << endl ;
 
  632  coutI(Eval) << 
"Calculating sWeight" << std::endl;
 
  633  std::vector<RooRealVar*> sweightvec ;
 
  634  std::vector<RooRealVar*> pdfvec ;
 
  642  for(
Int_t k=0; k<nspec; ++k)
 
  644       std::string wname = std::string(yieldvars[k]->
GetName()) + 
"_sw";
 
  646       sweightvec.push_back( var) ;
 
  647       sweightset.
add(*var) ;
 
  650       wname = 
"L_" + std::string(yieldvars[k]->
GetName());
 
  651       var = 
new RooRealVar(wname.c_str(),wname.c_str(),0) ;
 
  652       pdfvec.push_back( var) ;
 
  653       sweightset.
add(*var) ;
 
  661  for(
Int_t ievt = 0; ievt < numevents; ++ievt)
 
  668      for(
Int_t k = 0; k < nspec; ++k)   dsum +=  pdfvalues[ievt][k] * yieldvalues[k] ;
 
  673     for(
Int_t j=0; j<nspec; ++j) nsum += covMatrix(
n,j) * pdfvalues[ievt][j] ;
 
  681     if(includeWeights) sweightvec[
n]->setVal(
fSData->
weight() * nsum/dsum) ;
 
  682     else  sweightvec[
n]->setVal( nsum/dsum) ;
 
  684     pdfvec[
n]->setVal( pdfvalues[ievt][
n] ) ;
 
  686     if( !(std::abs(nsum/dsum)>=0 ) )
 
  688         coutE(Contents) << 
"error: " << nsum/dsum << endl ;
 
  693      sWeightData->
add(sweightset) ;
 
  710  for(
Int_t i=0; i < (
Int_t) constVarHolder.size(); i++)
 
  711    constVarHolder.at(i)->setConstant(
false);
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
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...
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
void treeNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=nullptr, bool doBranch=true, bool doLeaf=true, bool valueOnly=false, bool recurseNonDerived=false) const
Fill supplied list with nodes of the arg tree, following all server links, starting with ourself as t...
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
RooAbsCollection * snapshot(bool deepCopy=true) const
Take a snap shot of current collection contents.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
const_iterator end() const
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
const_iterator begin() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
virtual RooFit::OwningPtr< RooFitResult > fitTo(RooAbsData &data, const RooLinkedList &cmdList={})
Fit PDF to given dataset.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
void setConstant(bool value=true)
virtual void setVal(double value)=0
Set the current value of the object. Needs to be overridden by implementations.
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.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
RooDataSet is a container class to hold unbinned data.
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
void add(const RooArgSet &row, double weight=1.0, double weightError=0.0) override
Add one ore more rows of data.
bool merge(RooDataSet *data1, RooDataSet *data2=nullptr, RooDataSet *data3=nullptr, RooDataSet *data4=nullptr, RooDataSet *data5=nullptr, RooDataSet *data6=nullptr)
double weight() const override
Return event weight of current event.
static RooMsgService & instance()
Return reference to singleton instance.
bool isActive(const RooAbsArg *self, RooFit::MsgTopic facility, RooFit::MsgLevel level)
Check if logging is active for given object/topic/RooFit::MsgLevel combination.
RooRealVar represents a variable that can be changed from the outside.
A class to calculate "sWeights" used to create an "sPlot".
double GetSWeight(Int_t numEvent, const char *sVariable) const
Retrieve an s weight.
void AddSWeight(RooAbsPdf *pdf, const RooArgList &yieldsTmp, const RooArgSet &projDeps=RooArgSet(), bool includeWeights=true, const RooCmdArg &fitToarg5=RooCmdArg::none(), const RooCmdArg &fitToarg6=RooCmdArg::none(), const RooCmdArg &fitToarg7=RooCmdArg::none(), const RooCmdArg &fitToarg8=RooCmdArg::none())
Method which adds the sWeights to the dataset.
RooArgList GetSWeightVars() const
Return a RooArgList containing all paramters that have s weights.
double GetSumOfEventSWeight(Int_t numEvent) const
Sum the SWeights for a particular event.
SPlot()
Default constructor.
Int_t GetNumSWeightVars() const
Return the number of SWeights In other words, return the number of species that we are trying to extr...
RooDataSet * SetSData(RooDataSet *data)
Set dataset (if not passed in constructor).
RooDataSet * GetSDataSet() const
Retrieve s-weighted data.
double GetYieldFromSWeight(const char *sVariable) const
Sum the SWeights for a particular species over all events.
void Print(Option_t *name="") const override
Print the matrix as a table of elements.
Double_t Determinant() const override
Return the matrix determinant.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
virtual void Clear(Option_t *="")
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
RooCmdArg SumW2Error(bool flag)
RooCmdArg PrintEvalErrors(Int_t numErrors)
RooCmdArg PrintLevel(Int_t code)
RooCmdArg Extended(bool flag=true)
Namespace for the RooStats classes.