58 fCombinationDone(false),
85 fCombinationDone(false),
99 TNamed(
"hlfactory",
"hlfactory"),
104 fCombinationDone(false),
142 const char* SigBkgPdfName,
143 const char* BkgPdfName,
144 const char* DatasetName){
146 std::cerr <<
"Cannot add anymore channels. "
147 <<
"Combination already carried out.\n";
151 if (SigBkgPdfName!=0){
152 if (
fWs->
pdf(SigBkgPdfName)==
nullptr){
153 std::cerr <<
"Pdf " << SigBkgPdfName <<
" not found in workspace!\n";
161 if (
fWs->
pdf(BkgPdfName)==
nullptr){
162 std::cerr <<
"Pdf " << BkgPdfName <<
" not found in workspace!\n";
170 if (
fWs->
data(DatasetName)==
nullptr){
171 std::cerr <<
"Dataset " << DatasetName <<
" not found in workspace!\n";
211 for(
auto * ostring : static_range_cast<TObjString*>(
fSigBkgPdfNames)) {
212 pdfs.
add( *(
fWs->
pdf(ostring->String())) );
256 for(
auto * ostring : static_range_cast<TObjString*>(
fBkgPdfNames)) {
257 pdfs.
add( *(
fWs->
pdf(ostring->String())) );
316 if (!
data)
return nullptr;
388 const int maxDeepness=50;
390 TString warning(
"The inclusion stack is deeper than ");
391 warning+=maxDeepness;
392 warning+=
". Is this a recursive inclusion?";
398 std::ifstream ifile(fileName);
403 error+=
" could not be opened.";
414 TString ifileContentStripped(
"");
416 std::unique_ptr<TObjArray> lines_array{ifileContent.
Tokenize(
"\n")};
418 bool in_comment=
false;
421 for(
TObject * line_o : *lines_array) {
426 if (
line.EndsWith(
"*/")){
428 if (
fVerbose)
Info(
"fReadFile",
"Out of multiline comment ...");
435 if ((
line.BeginsWith(
"/*") &&
line.EndsWith(
"*/")) ||
436 line.BeginsWith(
"//")){
437 if (
fVerbose)
Info(
"fReadFile",
"In single line comment ...");
442 if (
line.BeginsWith(
"/*")){
444 if (
fVerbose)
Info(
"fReadFile",
"In multiline comment ...");
448 ifileContentStripped+=
line+
"\n";
453 lines_array.reset(ifileContentStripped.
Tokenize(
";"));
456 const int nNeutrals=2;
457 TString neutrals[nNeutrals]={
"\t",
" "};
459 for(
TObject * line_o : *lines_array) {
467 line.ReplaceAll(
"\n",
"");
470 if (
line.BeginsWith(
"echo")){
473 std::cout <<
"Echoing line " <<
line.Data() << std::endl;
474 std::cout <<
"[" <<
GetName() <<
"] echo: "
475 <<
line.Data() << std::endl;
480 for (
int i=0;i<nNeutrals;++i)
481 line.ReplaceAll(neutrals[i],
"");
488 if (
fVerbose)
Info(
"fReadFile",
"%s",
"Empty line: skipping ...");
494 if (
line.BeginsWith(
"#include")){
495 line.ReplaceAll(
"#include",
"");
496 if (
fVerbose)
Info(
"fReadFile",
"Reading included file...");
526 for (
auto * ostring : static_range_cast<TObjString*>(
fLabelsNames)) {
542 std::cerr <<
"The number of datasets and models added as channels "
543 <<
" is not the same!\n";
556 const int nequals =
line.CountChar(
'=');
560 if (
line.Contains(
"::") ||
562 (
line.Contains(
"[") &&
563 line.Contains(
"]") &&
565 !
line.Contains(
"(") &&
566 !
line.Contains(
")"))) {
573 (nequals > 1 &&
line.Contains(
"SIMUL"))){
577 const int equal_index=
line.First(
'=');
578 const int par_index=
line.First(
'(');
580 TString o_class(
line(equal_index+1,par_index-equal_index-1));
583 if (
fVerbose)
Info(
"fParseLine",
"o_name=%s o_class=%s o_descr=%s",
588 if (o_class ==
"import"){
594 const int n_descr_parts=descr_array->
GetEntries();
596 if (n_descr_parts<2 || n_descr_parts>3)
597 Error(
"fParseLine",
"Import wrong syntax: cannot process %s", o_descr.
Data());
603 std::unique_ptr<TFile> ifile{
TFile::Open(rootfile_name)};
607 if (n_descr_parts==3){
611 else if(n_descr_parts==2){
613 Info(
"fParseLine",
"Importing %s from %s under the name of %s",
615 TObject* the_obj=ifile->Get(obj_name);
621 new_line=o_class+
"::"+o_name+
"("+o_descr+
")";
624 std::cout <<
"DEBUG: line: " <<
line.Data() << std::endl;
625 std::cout <<
"DEBUG: new_line: " << new_line.
Data() << std::endl;
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 Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
void Print(Option_t *options=nullptr) const override
Print the object to the defaultPrintStream().
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.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooCategory is an object to represent discrete states.
bool setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
bool defineType(const std::string &label)
Define a state with given name.
RooDataSet is a container class to hold unbinned data.
virtual RooAbsArg * addColumn(RooAbsArg &var, bool adjustRange=true)
Add a column with the values of the given (function) argument to this dataset.
void append(RooDataSet &data)
Add all data points of given data set to this data set.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
HLFactory is an High Level model Factory allows you to describe your models in a configuration file (...
TList fSigBkgPdfNames
List of channels names to combine for the signal plus background pdfs.
RooWorkspace * fWs
The RooWorkspace containing the models and variables.
TList fBkgPdfNames
List of channels names to combine for the background pdfs.
int fInclusionLevel
Keep trace of the inclusion deepness.
RooAbsPdf * fComboBkgPdf
The background model combination.
TList fLabelsNames
List of channels names to combine for the datasets.
RooDataSet * GetTotDataSet()
Get the combined dataset.
int fParseLine(TString &line)
Parse a single line an puts the content in the RooWorkSpace.
HLFactory()
Default Constructor.
RooCategory * fComboCat
The category of the combination.
RooDataSet * fComboDataset
The datasets combination.
TList fDatasetsNames
List of channels names to combine for the datasets.
RooAbsPdf * GetTotBkgPdf()
Get the combined background pdf.
RooAbsPdf * fComboSigBkgPdf
The signal plus background model combination.
bool fNamesListsConsistent()
Check the length of the lists.
bool fCombinationDone
Flag to keep trace of the status of the combination.
RooAbsPdf * GetTotSigBkgPdf()
Get the combined signal plus background pdf.
int AddChannel(const char *label, const char *SigBkgPdfName, const char *BkgPdfName=nullptr, const char *datasetName=nullptr)
Add channel for the combination.
int ProcessCard(const char *filename)
Process a configuration file.
RooCategory * GetTotCategory()
Get the combined dataset.
bool fOwnWs
Owns workspace.
~HLFactory() override
Default Destructor.
void fCreateCategory()
Create the category for the combinations.
bool fVerbose
The verbosity flag.
int fReadFile(const char *fileName, bool is_included=false)
Read the actual cfg file.
The RooWorkspace is a persistable container for RooFit projects.
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
RooFactoryWSTool & factory()
Return instance to factory tool.
RooAbsData * data(RooStringView name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void Add(TObject *obj) override
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const override
Collectable string class.
const TString & GetString() const
Mother of all ROOT objects.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
std::istream & ReadFile(std::istream &str)
Replace string with the contents of strm, stopping at an EOF.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.