109 const char* SigBkgPdfName,
110 const char* BkgPdfName,
111 const char* DatasetName){
113 std::cerr <<
"Cannot add anymore channels. "
114 <<
"Combination already carried out.\n";
118 if (SigBkgPdfName!=
nullptr){
119 if (
fWs->pdf(SigBkgPdfName)==
nullptr){
120 std::cerr <<
"Pdf " << SigBkgPdfName <<
" not found in workspace!\n";
127 if (BkgPdfName!=
nullptr){
128 if (
fWs->pdf(BkgPdfName)==
nullptr){
129 std::cerr <<
"Pdf " << BkgPdfName <<
" not found in workspace!\n";
136 if (DatasetName!=
nullptr){
137 if (
fWs->data(DatasetName)==
nullptr){
138 std::cerr <<
"Dataset " << DatasetName <<
" not found in workspace!\n";
178 pdfs.
add( *(
fWs->pdf(ostring->String().Data())) );
223 pdfs.
add( *
fWs->pdf(ostring->String().Data()) );
282 if (!
data)
return nullptr;
355 const int maxDeepness=50;
357 TString warning(
"The inclusion stack is deeper than ");
358 warning+=maxDeepness;
359 warning+=
". Is this a recursive inclusion?";
365 std::ifstream ifile(fileName);
370 error+=
" could not be opened.";
381 TString ifileContentStripped(
"");
383 std::unique_ptr<TObjArray> lines_array{ifileContent.
Tokenize(
"\n")};
385 bool in_comment=
false;
388 for(
TObject * line_o : *lines_array) {
393 if (
line.EndsWith(
"*/")){
395 if (
fVerbose)
Info(
"fReadFile",
"Out of multiline comment ...");
403 if ((
line.BeginsWith(
"/*") &&
line.EndsWith(
"*/")) ||
404 line.BeginsWith(
"//")){
405 if (
fVerbose)
Info(
"fReadFile",
"In single line comment ...");
410 if (
line.BeginsWith(
"/*")){
412 if (
fVerbose)
Info(
"fReadFile",
"In multiline comment ...");
416 ifileContentStripped+=
line+
"\n";
421 lines_array.reset(ifileContentStripped.
Tokenize(
";"));
424 const int nNeutrals=2;
425 TString neutrals[nNeutrals]={
"\t",
" "};
427 for(
TObject * line_o : *lines_array) {
435 line.ReplaceAll(
"\n",
"");
438 if (
line.BeginsWith(
"echo")){
441 std::cout <<
"Echoing line " <<
line.Data() << std::endl;
442 std::cout <<
"[" <<
GetName() <<
"] echo: "
443 <<
line.Data() << std::endl;
448 for (
int i=0;
i<nNeutrals;++
i)
449 line.ReplaceAll(neutrals[
i],
"");
456 if (
fVerbose)
Info(
"fReadFile",
"%s",
"Empty line: skipping ...");
462 if (
line.BeginsWith(
"#include")){
463 line.ReplaceAll(
"#include",
"");
464 if (
fVerbose)
Info(
"fReadFile",
"Reading included file...");
495 fComboCat->defineType(ostring->String());
510 std::cerr <<
"The number of datasets and models added as channels "
511 <<
" is not the same!\n";
524 const int nequals =
line.CountChar(
'=');
528 if (
line.Contains(
"::") ||
530 (
line.Contains(
"[") &&
531 line.Contains(
"]") &&
533 !
line.Contains(
"(") &&
534 !
line.Contains(
")"))) {
541 (nequals > 1 &&
line.Contains(
"SIMUL"))){
545 const int equal_index=
line.First(
'=');
546 const int par_index=
line.First(
'(');
548 TString o_class(
line(equal_index+1,par_index-equal_index-1));
551 if (
fVerbose)
Info(
"fParseLine",
"o_name=%s o_class=%s o_descr=%s",
556 if (o_class ==
"import"){
562 const int n_descr_parts=descr_array->
GetEntries();
564 if (n_descr_parts<2 || n_descr_parts>3)
565 Error(
"fParseLine",
"Import wrong syntax: cannot process %s", o_descr.
Data());
571 std::unique_ptr<TFile> ifile{
TFile::Open(rootfile_name)};
575 if (n_descr_parts==3){
577 fWs->import(o_descr);
579 else if(n_descr_parts==2){
581 Info(
"fParseLine",
"Importing %s from %s under the name of %s", obj_name.
Data(), rootfile_name.
Data(),
584 TObject* the_obj=ifile->Get(obj_name);
585 fWs->import(*the_obj,o_name);
590 new_line=o_class+
"::"+o_name+
"("+o_descr+
")";
593 std::cout <<
"DEBUG: line: " <<
line.Data() << std::endl;
594 std::cout <<
"DEBUG: new_line: " << new_line.
Data() << std::endl;
true
Register systematic variations for multiple existing columns using auto-generated tags.
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Abstract interface for all probability density functions.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Object to represent discrete states.
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.
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.
Persistable container for RooFit projects.
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.
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
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.
TObject()
TObject constructor.
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.