26 std::string channelPdfName = channelPdf->
GetName();
27 std::string ChannelName = channelPdfName.substr(6, channelPdfName.size() );
35 if(verbose) std::cout <<
"Getting the RooRealSumPdf for the channel: "
36 << sim_channel->
GetName() << std::endl;
38 std::string channelPdfName = sim_channel->
GetName();
39 std::string ChannelName = channelPdfName.substr(6, channelPdfName.size() );
43 std::string realSumPdfName = ChannelName +
"_model";
46 bool FoundSumPdf=
false;
47 std::unique_ptr<RooArgSet> components{sim_channel->
getComponents()};
48 for (
auto *sum_pdf_arg : *components) {
49 std::string NodeClassName = sum_pdf_arg->ClassName();
50 if( NodeClassName == std::string(
"RooRealSumPdf") ) {
52 sum_pdf =
static_cast<RooAbsPdf*
>(sum_pdf_arg);
58 std::cout <<
"Failed to find RooRealSumPdf for channel: " << sim_channel->
GetName() << std::endl;
65 if(verbose) std::cout <<
"Found RooRealSumPdf: " << sum_pdf->
GetName() << std::endl;
76 const std::type_info &
id =
typeid(pdf);
80 for (
int i = 0,
n = list.
getSize(); i <
n; ++i) {
87 for (
int ic = 0, nc = cat->numBins((
const char *)
nullptr); ic < nc; ++ic) {
94 if (!constraints.
contains(pdf)) constraints.
add(pdf);
104 bool FoundParamHistFunc=
false;
105 std::unique_ptr<RooArgSet> components{channel->
getComponents()};
106 for(
auto *paramfunc_arg : *components) {
107 std::string NodeName = paramfunc_arg->GetName();
108 std::string NodeClassName = paramfunc_arg->ClassName();
109 if( NodeClassName != std::string(
"ParamHistFunc") )
continue;
110 if( NodeName.find(
"mc_stat_") != std::string::npos ) {
111 FoundParamHistFunc=
true;
116 if( ! FoundParamHistFunc || !paramfunc ) {
117 if(verbose) std::cout <<
"Failed to find ParamHistFunc for channel: " << channel->
GetName() << std::endl;
123 if(verbose) gammaList->
Print(
"V");
139 for (
auto* temp : *
data->get()) {
140 if( strcmp(temp->ClassName(),
"RooCategory")==0){
146 if(!cat) std::cout <<
"didn't find category"<< std::endl;
147 else std::cout <<
"found category"<< std::endl;
151 std::cerr <<
"Category not found"<< std::endl;
156 std::unique_ptr<TList> dataByCategory{
data->split(*cat)};
157 if(verbose) dataByCategory->Print();
163 for (
const auto& nameIdx : *channelCat) {
168 std::string ChannelName = pdftmp->
GetName();
169 if(verbose) std::cout <<
"Getting data for channel: " << ChannelName << std::endl;
170 ChannelBinDataMap[ ChannelName ] = std::vector<double>();
173 if(verbose) dataForChan->
Print();
178 if(verbose) obs->
Print();
193 for (
int i = 0; i < dataForChan->
numEntries(); i++) {
197 const double n = dataForChan->
weight();
199 std::cout <<
"n" << i <<
" = " <<
n << std::endl;
200 ChannelBinDataMap[ChannelName].push_back(
n);
205 dataByCategory->Delete();
221 bool FoundConstraintTerm=
false;
223 for (
auto *term_constr : *constraints) {
224 std::string TermName = term_constr->
GetName();
225 if( term_constr->dependsOn( *gamma_stat) ) {
226 if( TermName.find(
"_constraint")!=std::string::npos ) {
227 FoundConstraintTerm=
true;
228 constraintTerm =
static_cast<RooAbsPdf*
>(term_constr);
233 if( FoundConstraintTerm==
false ) {
234 std::cout <<
"Error: Couldn't find constraint term for parameter: " << gamma_stat->
GetName()
235 <<
" among constraints: " << constraints->
GetName() << std::endl;
236 constraints->
Print(
"V");
237 throw std::runtime_error(
"Failed to find Gamma ConstraintTerm");
254 bool FoundNomMean=
false;
256 std::string serverName = term_pois->GetName();
258 if( serverName.find(
"nom_")!=std::string::npos ) {
263 if( !FoundNomMean || !pois_nom ) {
264 std::cout <<
"Error: Did not find Nominal Pois Mean parameter in gamma constraint term PoissonMean: "
265 << constraintTerm->
GetName() << std::endl;
266 throw std::runtime_error(
"Failed to find Nom Pois Mean");
269 if(verbose) std::cout <<
"Found Poisson 'data' term: " << pois_nom->
GetName() << std::endl;
277 if( arg->dependsOn( *gamma_stat ) ) {
282 if( !pois_mean_arg ) {
283 std::cout <<
"Error: Did not find PoissonMean parameter in gamma constraint term: "
284 << constraintTerm->
GetName() << std::endl;
285 throw std::runtime_error(
"Failed to find PoissonMean");
289 if(verbose) std::cout <<
"Found Poisson 'mean' term: " << pois_mean_arg->
GetName() << std::endl;
294 std::string serverName = term_in_product->GetName();
296 if( serverName.find(
"_tau")!=std::string::npos ) {
301 if( !FoundTau || !tau ) {
302 std::cout <<
"Error: Did not find Tau parameter in gamma constraint term PoissonMean: "
303 << pois_mean_arg->
GetName() << std::endl;
304 throw std::runtime_error(
"Failed to find Tau");
307 if(verbose) std::cout <<
"Found Poisson 'tau' term: " << tau->
GetName() << std::endl;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
const RooArgList & paramList() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
void Print(Option_t *options=nullptr) const override
Print the object to the defaultPrintStream().
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.
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
RooFit::OwningPtr< RooArgSet > getComponents() const
Create a RooArgSet with all components (branch nodes) of the expression tree headed by this object.
const RefCountList_t & servers() const
List of all servers of this object.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
void setBin(Int_t ibin, const char *rangeName=nullptr) override
Set category to i-th fit bin, which is the i-th registered state.
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
Int_t getSize() const
Return the number of elements in the collection.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
Abstract base class for binned and unbinned datasets.
virtual double weight() const =0
virtual const RooArgSet * get() const
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.
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value and implements functionality common to al...
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.
Object to represent discrete states.
Efficient implementation of a product of PDFs of the form.
const RooArgList & pdfList() const
RooRealVar represents a variable that can be changed from the outside.
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
const char * GetName() const override
Returns name of object.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
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)
std::string channelNameFromPdf(RooAbsPdf *channelPdf)
Namespace for the RooStats classes.