22 namespace HistFactory{
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";
47 bool FoundSumPdf=
false;
50 std::string NodeClassName = sum_pdf_arg->
ClassName();
51 if( NodeClassName == std::string(
"RooRealSumPdf") ) {
59 std::cout <<
"Failed to find RooRealSumPdf for channel: " << sim_channel->
GetName() << std::endl;
66 if(verbose) std::cout <<
"Found RooRealSumPdf: " << sum_pdf->
GetName() << std::endl;
79 const std::type_info &
id =
typeid(pdf);
83 for (
int i = 0,
n = list.getSize(); i <
n; ++i) {
90 for (
int ic = 0, nc = cat->
numBins((
const char *)0); ic < nc; ++ic) {
98 if (!constraints.
contains(pdf)) constraints.
add(pdf);
187 bool FoundParamHistFunc=
false;
190 std::string NodeName = paramfunc_arg->
GetName();
191 std::string NodeClassName = paramfunc_arg->
ClassName();
192 if( NodeClassName != std::string(
"ParamHistFunc") )
continue;
193 if( NodeName.find(
"mc_stat_") != std::string::npos ) {
194 FoundParamHistFunc=
true;
199 if( ! FoundParamHistFunc || !paramfunc ) {
200 if(verbose) std::cout <<
"Failed to find ParamHistFunc for channel: " << channel->
GetName() << std::endl;
209 if(verbose) gammaList->
Print(
"V");
232 if( strcmp(temp->
ClassName(),
"RooCategory")==0){
238 if(!cat) std::cout <<
"didn't find category"<< std::endl;
239 else std::cout <<
"found category"<< std::endl;
245 if(verbose) dataByCategory->
Print();
258 std::string ChannelName = pdftmp->
GetName();
259 if(verbose) std::cout <<
"Getting data for channel: " << ChannelName << std::endl;
260 ChannelBinDataMap[ ChannelName ] = std::vector<double>();
263 if(verbose) dataForChan->Print();
268 if(verbose) obs->
Print();
282 TH1* histForN = dataForChan->createHistogram(
"HhstForN",*obs);
283 for(
int i=1; i<=histForN->
GetNbinsX(); ++i){
285 if(verbose) std::cout <<
"n" << i <<
" = " << n << std::endl;
286 ChannelBinDataMap[ ChannelName ].push_back( n );
312 bool FoundConstraintTerm=
false;
315 std::string TermName = term_constr->
GetName();
319 if( term_constr->
dependsOn( *gamma_stat) ) {
320 if( TermName.find(
"_constraint")!=std::string::npos ) {
321 FoundConstraintTerm=
true;
322 constraintTerm = (
RooAbsPdf*) term_constr;
327 if( FoundConstraintTerm==
false ) {
328 std::cout <<
"Error: Couldn't find constraint term for parameter: " << gamma_stat->
GetName()
329 <<
" among constraints: " << constraints->
GetName() << std::endl;
330 constraints->
Print(
"V");
331 throw std::runtime_error(
"Failed to find Gamma ConstraintTerm");
349 bool FoundNomMean=
false;
353 std::string serverName = term_pois->
GetName();
355 if( serverName.find(
"nom_")!=std::string::npos ) {
360 if( !FoundNomMean || !pois_nom ) {
361 std::cout <<
"Error: Did not find Nominal Pois Mean parameter in gamma constraint term PoissonMean: " 362 << constraintTerm->
GetName() << std::endl;
363 throw std::runtime_error(
"Failed to find Nom Pois Mean");
366 if(verbose) std::cout <<
"Found Poisson 'data' term: " << pois_nom->
GetName() << std::endl;
375 bool FoundPoissonMean =
false;
376 while(( pois_mean_arg = (
RooAbsArg*) iter_constr->
Next() )) {
377 std::string serverName = pois_mean_arg->
GetName();
378 if( pois_mean_arg->
dependsOn( *gamma_stat ) ) {
379 FoundPoissonMean=
true;
384 if( !FoundPoissonMean || !pois_mean_arg ) {
385 std::cout <<
"Error: Did not find PoissonMean parameter in gamma constraint term: " 386 << constraintTerm->
GetName() << std::endl;
387 throw std::runtime_error(
"Failed to find PoissonMean");
391 if(verbose) std::cout <<
"Found Poisson 'mean' term: " << pois_mean_arg->
GetName() << std::endl;
400 std::string serverName = term_in_product->
GetName();
402 if( serverName.find(
"_tau")!=std::string::npos ) {
407 if( !FoundTau || !tau ) {
408 std::cout <<
"Error: Did not find Tau parameter in gamma constraint term PoissonMean: " 409 << pois_mean_arg->
GetName() << std::endl;
410 throw std::runtime_error(
"Failed to find Tau");
413 if(verbose) std::cout <<
"Found Poisson 'tau' term: " << tau->
GetName() << std::endl;
virtual const char * GetName() const
Returns name of object.
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
int getStatUncertaintyConstraintTerm(RooArgList *constraints, RooRealVar *gamma_stat, RooAbsReal *&pois_mean, RooRealVar *&tau)
const RooArgList & paramList() const
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
virtual const RooArgSet * get() const
RooProdPdf is an efficient implementation of a product of PDFs of the form.
bool getStatUncertaintyFromChannel(RooAbsPdf *channel, ParamHistFunc *¶mfunc, RooArgList *gammaList)
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
std::string channelNameFromPdf(RooAbsPdf *channelPdf)
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Iterator abstract base class.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual Int_t numBins(const char *rangeName) const
Returm the number of fit bins ( = number of types )
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t tau
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state...
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooRealVar represents a fundamental (non-derived) real valued object.
TIterator * typeIterator() const
Return iterator over all defined states.
virtual const Text_t * GetName() const
Returns name of object.
const RooAbsCategoryLValue & indexCat() const
RooAbsArg * first() const
const RooArgList & pdfList() const
RooArgSet * getComponents() const
void getDataValuesForObservables(std::map< std::string, std::vector< double > > &ChannelBinDataMap, RooAbsData *data, RooAbsPdf *simPdf)
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const char * getLabel() const
Return label string of current state.
RooCategory represents a fundamental (non-derived) discrete value object.
TIterator * serverIterator() const
Namespace for the RooStats classes.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
const char * GetName() const
Returns name of object.
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
virtual void setBin(Int_t ibin, const char *rangeName=0)
Set category to i-th fit bin, which is the i-th registered state.
virtual TObject * Next()=0
virtual TList * split(const RooAbsCategory &splitCat, Bool_t createEmptyDataSets=kFALSE) const
Split dataset into subsets based on states of given splitCat in this dataset.
Bool_t contains(const RooAbsArg &var) const
virtual Int_t GetNbinsX() const
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
RooAbsPdf * getSumPdfFromChannel(RooAbsPdf *channel)
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset...
void FactorizeHistFactoryPdf(const RooArgSet &, RooAbsPdf &, RooArgList &, RooArgList &)