34 : _minBinToPrint(-1), _maxBinToPrint(-1),
35 _label_print_width(20), _bin_print_width(12) {
38 std::cout <<
"Error: The supplied ModelConfig is nullptr " << std::endl;
45 std::cout <<
"Error: The pdf found in the ModelConfig: " <<
mc->GetName()
46 <<
" is nullptr" << std::endl;
56 std::cout <<
"Error: Observable set in the ModelConfig: " <<
mc->GetName()
57 <<
" is nullptr" << std::endl;
62 <<
" found in ModelConfig: " <<
mc->GetName()
63 <<
" has no entries." << std::endl;
80 _minBinToPrint(-1), _maxBinToPrint(-1),
81 _label_print_width(20), _bin_print_width(12) {
84 auto file = std::make_unique<TFile>(FileName.c_str());
86 std::cout <<
"Error: Failed to open file: " << FileName << std::endl;
93 std::cout <<
"Error: Failed to get workspace: " <<
WorkspaceName
94 <<
" from file: " << FileName << std::endl;
103 <<
" in file: " << FileName << std::endl;
110 std::cout <<
"Error: The pdf found in the ModelConfig: " <<
ModelConfigName
111 <<
" is nullptr" << std::endl;
121 std::cout <<
"Error: Observable set in the ModelConfig: " <<
ModelConfigName
122 <<
" is nullptr" << std::endl;
128 <<
" in file: " << FileName
129 <<
" has no entries." << std::endl;
144 _minBinToPrint(-1), _maxBinToPrint(-1),
145 _label_print_width(20), _bin_print_width(12) {
149 std::cout <<
"Error: The supplied pdf is nullptr" << std::endl;
159 std::cout <<
"Error: Supplied Observable set is nullptr" << std::endl;
162 if( observables->
empty() ) {
163 std::cout <<
"Error: Observable list: " << observables->
GetName()
164 <<
" has no entries." << std::endl;
191 std::cout << std::endl;
199 std::map< std::string, RooAbsPdf* >::iterator
itr;
203 std::cout <<
"Warning: Could not find channel: " << channel
209 if( pdf ==
nullptr ) {
210 std::cout <<
"Warning: Pdf associated with channel: " << channel
211 <<
" is nullptr" << std::endl;
223 std::cout << std::endl << channel <<
":" << std::endl;
265 std::string
tmp_name = channel +
"_pretty_tmp";
350 std::cout << std::endl;
360 std::cout << std::endl;
363 std::cout << std::setw(30) <<
"Parameter";
364 std::cout << std::setw(15) <<
"Value"
365 << std::setw(15) <<
"Error Low"
366 << std::setw(15) <<
"Error High"
373 std::cout << std::setw(30) << param->GetName();
374 std::cout << std::setw(15) << param->getVal();
375 if( !param->isConstant() ) {
376 std::cout << std::setw(15) << param->getErrorLo() << std::setw(15) << param->getErrorHi();
378 std::cout<< std::endl;
380 std::cout << std::endl;
393 std::cout << std::endl;
396 std::cout << std::setw(30) <<
"Parameter";
397 std::cout << std::setw(15) <<
"Value"
398 << std::setw(15) <<
"Error Low"
399 << std::setw(15) <<
"Error High"
406 std::cout << std::setw(30) << param->GetName();
407 std::cout << std::setw(15) << param->getVal();
408 if( !param->isConstant() ) {
409 std::cout << std::setw(15) << param->getErrorLo() << std::setw(15) << param->getErrorHi();
411 std::cout<< std::endl;
413 std::cout << std::endl;
418 const std::string&
sample,
428 std::cout << std::endl;
431 std::cout << std::setw(30) <<
"Parameter";
432 std::cout << std::setw(15) <<
"Value"
433 << std::setw(15) <<
"Error Low"
434 << std::setw(15) <<
"Error High"
441 std::cout << std::setw(30) << param->GetName();
442 std::cout << std::setw(15) << param->getVal();
443 if( !param->isConstant() ) {
444 std::cout << std::setw(15) << param->getErrorLo() << std::setw(15) << param->getErrorHi();
446 std::cout<< std::endl;
448 std::cout << std::endl;
479 std::map< std::string, std::map< std::string, RooAbsReal*> >::iterator
channel_itr;
482 std::cout <<
"Error: Channel: " << channel <<
" not found in Navigation" << std::endl;
494 std::map< std::string, std::map< std::string, RooAbsReal*> >::iterator
channel_itr;
497 std::cout <<
"Error: Channel: " << channel <<
" not found in Navigation" << std::endl;
502 std::map< std::string, RooAbsReal*>::iterator
sample_itr;
505 std::cout <<
"Error: Sample: " <<
sample <<
" not found in Navigation" << std::endl;
517 std::map< std::string, RooArgSet*>::iterator
channel_itr;
520 std::cout <<
"Error: Channel: " << channel <<
" not found in Navigation" << std::endl;
586 else total_hist->SetName( (channel +
"_hist").c_str() );
609 const std::string&
name) {
616 for(
unsigned int i=0; i <
samples.size(); ++i) {
630 const std::string&
name) {
655 int dim = vars.
size();
660 std::cout <<
"Error: To Create Histogram from RooDataSet" << std::endl;
665 }
else if( dim==1 ) {
684 std::cout <<
"Error: To Create Histogram from RooDataSet, Dimension must be 1, 2, or 3" << std::endl;
685 std::cout <<
"Observables: " << std::endl;
711 if(
data!=
nullptr ) {
731 std::string ClassName = arg->
ClassName();
732 if( ClassName ==
"RooProduct" ) {
802 for (
auto *arg : *
comps) {
803 std::string ClassName = arg->
ClassName();
804 if( ClassName ==
"RooRealSumPdf" ) {
834 if(
SampleName.find(
"L_x_") != std::string::npos ) {
864 for (
auto arg : *
comps) {
865 std::string
ArgName = arg->GetName();
878 std::unique_ptr<RooArgSet> parameters{parent->
getParameters(&args)};
879 for (
auto *param : *parameters) {
880 std::string
ParamName = param->GetName();
911 if( param==
nullptr ) {
912 std::cout <<
"Error: Couldn't Find parameter: " <<
parameter <<
" in model."
918 if(
parameter.find(
"gamma_stat_") != std::string::npos ) {
925 if(
term==
nullptr ) {
926 std::cout <<
"Error: Couldn't Find constraint term for parameter: " <<
parameter
939 if( constraintTerm==
nullptr ) {
940 std::cout <<
"Error: Cannot get uncertainty because parameter: " <<
parameter
941 <<
" has no constraint term" << std::endl;
952 std::cout <<
"Error: Constraint type is an empty string."
953 <<
" This simply should not be." << std::endl;
966 if(
parameter.find(
"alpha_")!=std::string::npos ) {
969 else if(
parameter.find(
"gamma_stat_")!=std::string::npos ) {
976 std::cout <<
"Error: Failed to find the 'sigma' node: " <<
sigmaName
977 <<
" in the RooGaussian: " << constraintTerm->
GetName() << std::endl;
988 std::cout <<
"Error: Failed to find the nominal 'tau' node: " <<
tauName
989 <<
" for the RooPoisson: " << constraintTerm->
GetName() << std::endl;
996 std::cout <<
"Error: Encountered unknown constraint type for Stat Uncertainties: "
1010 std::cout <<
"Error: Cannot replace node: " <<
ToReplace
1011 <<
" because this node wasn't found in: " <<
fModel->
GetName()
1036 std::cout <<
"Replaced: " <<
ToReplace <<
" with: " << ReplaceWith->
GetName()
1037 <<
" in node: " << client->GetName() << std::endl;
1050 const std::string&
sample) {
1085 std::cout << std::endl;
1086 std::cout <<
"Channel: " << channel <<
" Sample: " <<
sample << std::endl;
1089 for(
unsigned int i=0; i <
num_bins; ++i) {
1092 std::stringstream
sstr;
1096 std::cout << std::endl;
1106 std::unique_ptr<TH1> hist;
1133 std::string
name ) {
1148 int dim = vars.
size();
1171 std::cout <<
"Error: To Create Histogram from RooAbsReal function, Dimension must be 1, 2, or 3" << std::endl;
1181 const RooArgSet* observables =
mc->GetObservables();
1200 std::cout << std::endl;
1203 std::cout << std::setw(30) <<
"Parameter";
1204 std::cout << std::setw(15) <<
"Value"
1205 << std::setw(15) <<
"Error Low"
1206 << std::setw(15) <<
"Error High"
1212 std::string
ParamName = param->GetName();
1221 std::cout <<
"Setting param: " <<
ParamName <<
" constant"
1222 <<
" (matches regex: " <<
regExpr <<
")" << std::endl;
1229 if( !arg )
return nullptr;
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
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...
bool redirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool isRecursionStep=false)
Replace all direct servers of this object with the new servers in newServerList.
RooFit::OwningPtr< RooArgSet > getComponents() const
Create a RooArgSet with all components (branch nodes) of the expression tree headed by this object.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
RooAbsArg * findServer(const char *name) const
Return server of this with name name. Returns nullptr if not found.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value and implements functionality common to al...
TH1 * createHistogram(RooStringView varNameList, Int_t xbins=0, Int_t ybins=0, Int_t zbins=0) const
Create and fill a ROOT histogram TH1, TH2 or TH3 with the values of this function for the variables w...
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.
Container class to hold unbinned data.
static RooMsgService & instance()
Return reference to singleton instance.
Represents the product of a given set of RooAbsReal objects.
Implements a PDF constructed from a sum of functions:
const RooArgList & funcList() const
Variable that can be changed from the outside.
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
void PrintParameters(bool IncludeConstantParams=false)
Print the current values and errors of pdf parameters.
std::vector< std::string > fChannelNameVec
The list of channels.
RooArgSet * GetObservableSet(const std::string &channel)
Get the set of observables for a given channel.
TH1 * GetDataHist(RooDataSet *data, const std::string &channel, const std::string &name="")
Get a histogram from the dataset for this channel.
RooArgSet * fObservables
The observables.
void _GetNodes(ModelConfig *mc)
Fetch the node information for the pdf in question, and save it in the various collections in this cl...
std::map< std::string, RooAbsPdf * > fChannelSumNodeMap
Map of channel names to pdf without constraint.
void ReplaceNode(const std::string &ToReplace, RooAbsArg *ReplaceWith)
Find a node in the pdf and replace it with a new node These nodes can be functions,...
void PrintState()
Should pretty print all channels and the current values

void PrintSampleComponents(const std::string &channel, const std::string &sample)
Print the different components that make up a sample (NormFactors, Statistical Uncertainties,...
void SetPrintWidths(const std::string &channel)
Set the title and bin widths.
RooAbsPdf * fModel
The HistFactory Pdf Pointer.
TH1 * GetChannelHist(const std::string &channel, const std::string &name="")
Get the total channel histogram for this channel.
TH1 * GetSampleHist(const std::string &channel, const std::string &sample, const std::string &name="")
The (current) histogram for that sample This includes all parameters and interpolation.
TH1 * MakeHistFromRooFunction(RooAbsReal *func, RooArgList vars, std::string name="Hist")
Make a histogram from a function Edit so it can take a RooArgSet of parameters.
void PrintMultiDimHist(TH1 *hist, int bin_print_width)
Print a histogram's contents to the screen void PrettyPrintHistogram(TH1* hist);.
void PrintSampleParameters(const std::string &channel, const std::string &sample, bool IncludeConstantParams=false)
Print parameters that effect a particular sample.
std::map< std::string, RooAbsReal * > GetSampleFunctionMap(const std::string &channel)
Get a map of sample names to their functions for a particular channel.
RooAbsReal * SampleFunction(const std::string &channel, const std::string &sample)
Get the RooAbsReal function for a given sample in a given channel.
HistFactoryNavigation(ModelConfig *mc)
Initialize based on an already-created HistFactory Model.
double GetBinValue(int bin, const std::string &channel)
The value of the ith bin for the total in that channel.
RooAbsArg * findChild(const std::string &name, RooAbsReal *parent) const
Internal method implementation of finding a daughter node from a parent node (looping over all genera...
std::map< std::string, std::map< std::string, RooAbsReal * > > fChannelSampleFunctionMap
Map of Map of Channel, Sample names to Function Nodes Used by doing: fChannelSampleFunctionMap["MyCha...
std::map< std::string, RooAbsPdf * > fChannelPdfMap
Map of channel names to their full pdf's.
std::vector< std::string > GetChannelSampleList(const std::string &channel)
void PrintModelAndData(RooDataSet *data)
Print the model and the data, comparing channel by channel.
std::map< std::string, RooArgSet * > fChannelObservMap
Map of channel names to their set of ovservables.
RooAbsPdf * GetChannelPdf(const std::string &channel)
void PrintDataSet(RooDataSet *data, const std::string &channel="")
Print a "HistFactory style" RooDataSet in a readable way.
void PrintChannelParameters(const std::string &channel, bool IncludeConstantParams=false)
Print parameters that effect a particular channel.
void SetConstant(const std::string ®Expr=".*", bool constant=true)
RooArgSet _GetAllProducts(RooProduct *node)
Recursively get all products of products.
THStack * GetChannelStack(const std::string &channel, const std::string &name="")
Get a stack of all samples in a channel.
RooAbsReal * GetConstraintTerm(const std::string ¶meter)
Get the constraint term for a given systematic (alpha or gamma)
void DrawChannel(const std::string &channel, RooDataSet *data=nullptr)
Draw a stack of the channel, and include data if the pointer is supplied.
RooRealVar * var(const std::string &varName) const
double GetConstraintUncertainty(const std::string ¶meter)
Get the uncertainty based on the constraint term for a given systematic.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Persistable container for RooFit projects.
TObject * obj(RooStringView name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsZ() const
virtual Int_t GetNbinsX() const
Bool_t IsBinUnderflow(Int_t bin, Int_t axis=0) const
Return true if the bin is underflow.
Bool_t IsBinOverflow(Int_t bin, Int_t axis=0) const
Return true if the bin is overflow.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
The Histogram stack class.
virtual void Add(TH1 *h, Option_t *option="")
Add a new histogram to the list.
void Draw(Option_t *chopt="") override
Draw this stack with its current attributes.
const char * GetName() const override
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Regular expression class.
RooCmdArg YVar(const RooAbsRealLValue &var, const RooCmdArg &arg={})
RooCmdArg Scaling(bool flag)
RooCmdArg Binning(const RooAbsBinning &binning)
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
Namespace for the RooStats classes.