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;
41 bool FoundSumPdf=
false;
42 std::unique_ptr<RooArgSet> components{sim_channel->
getComponents()};
43 for (
auto *sum_pdf_arg : *components) {
44 std::string NodeClassName = sum_pdf_arg->ClassName();
45 if( NodeClassName == std::string(
"RooRealSumPdf") ) {
47 sum_pdf =
static_cast<RooAbsPdf*
>(sum_pdf_arg);
53 std::cout <<
"Failed to find RooRealSumPdf for channel: " << sim_channel->
GetName() << std::endl;
54 components->Print(
"V");
60 if(verbose) std::cout <<
"Found RooRealSumPdf: " << sum_pdf->
GetName() << std::endl;
71 const std::type_info &
id =
typeid(pdf);
75 for (
int i = 0,
n = list.size(); i <
n; ++i) {
82 for (
int ic = 0, nc = cat->numBins((
const char *)
nullptr); ic < nc; ++ic) {
89 if (!constraints.
contains(pdf)) constraints.
add(pdf);
99 bool FoundParamHistFunc=
false;
100 std::unique_ptr<RooArgSet> components{channel->
getComponents()};
101 for(
auto *paramfunc_arg : *components) {
102 std::string NodeName = paramfunc_arg->GetName();
103 std::string NodeClassName = paramfunc_arg->ClassName();
104 if( NodeClassName != std::string(
"ParamHistFunc") )
continue;
105 if( NodeName.find(
"mc_stat_") != std::string::npos ) {
106 FoundParamHistFunc=
true;
111 if( ! FoundParamHistFunc || !paramfunc ) {
112 if(verbose) std::cout <<
"Failed to find ParamHistFunc for channel: " << channel->
GetName() << std::endl;
118 if(verbose) gammaList->
Print(
"V");
134 for (
auto* temp : *
data->get()) {
135 if( strcmp(temp->ClassName(),
"RooCategory")==0){
141 if(!cat) std::cout <<
"didn't find category"<< std::endl;
142 else std::cout <<
"found category"<< std::endl;
146 std::cerr <<
"Category not found"<< std::endl;
151 std::vector<std::unique_ptr<RooAbsData>> dataByCategory{
data->split(*cat)};
155 for (
const auto& nameIdx : *channelCat) {
160 std::string ChannelName = pdftmp->
GetName();
161 if(verbose) std::cout <<
"Getting data for channel: " << ChannelName << std::endl;
162 ChannelBinDataMap[ ChannelName ] = std::vector<double>();
164 auto found = std::find_if(dataByCategory.begin(), dataByCategory.end(), [&](
auto const &item) {
165 return nameIdx.first == item->GetName();
167 RooAbsData *dataForChan = found != dataByCategory.end() ? found->
get() :
nullptr;
168 if(verbose) dataForChan->
Print();
173 if(verbose) obs->
Print();
188 std::vector<double> &channelBin = ChannelBinDataMap[ChannelName];
189 channelBin.reserve(dataForChan->
numEntries());
190 for (
int i = 0; i < dataForChan->
numEntries(); i++) {
194 const double n = dataForChan->
weight();
196 std::cout <<
"n" << i <<
" = " <<
n << std::endl;
197 channelBin.push_back(
n);
216 bool FoundConstraintTerm=
false;
218 for (
auto *term_constr : *constraints) {
219 std::string TermName = term_constr->
GetName();
220 if( term_constr->dependsOn( *gamma_stat) ) {
221 if( TermName.find(
"_constraint")!=std::string::npos ) {
222 FoundConstraintTerm=
true;
223 constraintTerm =
static_cast<RooAbsPdf*
>(term_constr);
228 if( FoundConstraintTerm==
false ) {
229 std::cout <<
"Error: Couldn't find constraint term for parameter: " << gamma_stat->
GetName()
230 <<
" among constraints: " << constraints->
GetName() << std::endl;
231 constraints->
Print(
"V");
232 throw std::runtime_error(
"Failed to find Gamma ConstraintTerm");
249 bool FoundNomMean=
false;
251 std::string serverName = term_pois->GetName();
253 if( serverName.find(
"nom_")!=std::string::npos ) {
255 pois_nom =
static_cast<RooRealVar*
>(term_pois);
258 if( !FoundNomMean || !pois_nom ) {
259 std::cout <<
"Error: Did not find Nominal Pois Mean parameter in gamma constraint term PoissonMean: "
260 << constraintTerm->
GetName() << std::endl;
261 throw std::runtime_error(
"Failed to find Nom Pois Mean");
264 if(verbose) std::cout <<
"Found Poisson 'data' term: " << pois_nom->
GetName() << std::endl;
272 if( arg->dependsOn( *gamma_stat ) ) {
277 if( !pois_mean_arg ) {
278 std::cout <<
"Error: Did not find PoissonMean parameter in gamma constraint term: "
279 << constraintTerm->
GetName() << std::endl;
280 throw std::runtime_error(
"Failed to find PoissonMean");
284 if(verbose) std::cout <<
"Found Poisson 'mean' term: " << pois_mean_arg->
GetName() << std::endl;
289 std::string serverName = term_in_product->GetName();
291 if( serverName.find(
"_tau")!=std::string::npos ) {
293 tau =
static_cast<RooRealVar*
>(term_in_product);
296 if( !FoundTau || !tau ) {
297 std::cout <<
"Error: Did not find Tau parameter in gamma constraint term PoissonMean: "
298 << pois_mean_arg->
GetName() << std::endl;
299 throw std::runtime_error(
"Failed to find Tau");
302 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 char *name) const
Check if collection contains an argument with a specific name.
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.
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
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.
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)
int getStatUncertaintyConstraintTerm(RooArgList *constraints, RooRealVar *gamma_stat, RooAbsReal *&pois_nom, RooRealVar *&tau)
RooAbsPdf * getSumPdfFromChannel(RooAbsPdf *channel)
std::string channelNameFromPdf(RooAbsPdf *channelPdf)
Namespace for the RooStats classes.