50HLFactory::HLFactory(
const char *
name,
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)==NULL){
153 std::cerr <<
"Pdf " << SigBkgPdfName <<
" not found in workspace!\n";
161 if (
fWs->
pdf(BkgPdfName)==NULL){
162 std::cerr <<
"Pdf " << BkgPdfName <<
" not found in workspace!\n";
170 if (
fWs->
data(DatasetName)==NULL){
171 std::cerr <<
"Dataset " << DatasetName <<
" not found in workspace!\n";
214 while ((obj = it->
Next())){
264 while ((obj = it->
Next())){
321 while ((obj = it->
Next())){
325 if (!data)
return NULL;
398 const int maxDeepness=50;
400 TString warning(
"The inclusion stack is deeper than ");
401 warning+=maxDeepness;
402 warning+=
". Is this a recursive inclusion?";
408 std::ifstream ifile(fileName);
413 error+=
" could not be opened.";
424 TString ifileContentStripped(
"");
429 bool in_comment=
false;
433 while((line_o=(*lineIt)())){
438 if (
line.EndsWith(
"*/")){
440 if (
fVerbose)
Info(
"fReadFile",
"Out of multiline comment ...");
447 if ((
line.BeginsWith(
"/*") &&
line.EndsWith(
"*/")) ||
448 line.BeginsWith(
"//")){
449 if (
fVerbose)
Info(
"fReadFile",
"In single line comment ...");
454 if (
line.BeginsWith(
"/*")){
456 if (
fVerbose)
Info(
"fReadFile",
"In multiline comment ...");
460 ifileContentStripped+=
line+
"\n";
468 lines_array = ifileContentStripped.
Tokenize(
";");
472 const int nNeutrals=2;
473 TString neutrals[nNeutrals]={
"\t",
" "};
475 while((line_o=(*lineIt)())){
483 line.ReplaceAll(
"\n",
"");
486 if (
line.BeginsWith(
"echo")){
489 std::cout <<
"Echoing line " <<
line.Data() << std::endl;
490 std::cout <<
"[" <<
GetName() <<
"] echo: "
491 <<
line.Data() << std::endl;
496 for (
int i=0;i<nNeutrals;++i)
497 line.ReplaceAll(neutrals[i],
"");
504 if (
fVerbose)
Info(
"fReadFile",
"%s",
"Empty line: skipping ...");
510 if (
line.BeginsWith(
"#include")){
511 line.ReplaceAll(
"#include",
"");
512 if (
fVerbose)
Info(
"fReadFile",
"Reading included file...");
548 while ((obj = it->
Next())){
565 std::cerr <<
"The number of datasets and models added as channels "
566 <<
" is not the same!\n";
579 const int nequals =
line.CountChar(
'=');
583 if (
line.Contains(
"::") ||
585 (
line.Contains(
"[") &&
586 line.Contains(
"]") &&
588 !
line.Contains(
"(") &&
589 !
line.Contains(
")"))) {
596 (nequals > 1 &&
line.Contains(
"SIMUL"))){
600 const int equal_index=
line.First(
'=');
601 const int par_index=
line.First(
'(');
603 TString o_class(
line(equal_index+1,par_index-equal_index-1));
606 if (
fVerbose)
Info(
"fParseLine",
"o_name=%s o_class=%s o_descr=%s",
611 if (o_class ==
"import"){
617 const int n_descr_parts=descr_array->
GetEntries();
619 if (n_descr_parts<2 || n_descr_parts>3)
620 Error(
"fParseLine",
"Import wrong syntax: cannot process %s", o_descr.
Data());
630 if (n_descr_parts==3){
634 else if(n_descr_parts==2){
636 Info(
"fParseLine",
"Importing %s from %s under the name of %s",
645 new_line=o_class+
"::"+o_name+
"("+o_descr+
")";
648 std::cout <<
"DEBUG: line: " <<
line.Data() << std::endl;
649 std::cout <<
"DEBUG: new_line: " << new_line.
Data() << std::endl;
static RooMathCoreReg dummy
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooCategory represents a fundamental (non-derived) discrete value object.
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index.
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
Set value by specifying the index code of the desired state.
RooDataSet is a container class to hold unbinned data.
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
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.
~HLFactory()
Default Destructor.
int AddChannel(const char *label, const char *SigBkgPdfName, const char *BkgPdfName=0, const char *datasetName=0)
Add channel for the combination.
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 ProcessCard(const char *filename)
Process a configuration file.
RooCategory * GetTotCategory()
Get the combined dataset.
bool fOwnWs
Owns workspace.
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.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
Bool_t 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.
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) 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.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Int_t netopt=0)
Create / open a file.
Iterator abstract base class.
virtual TObject * Next()=0
virtual void Add(TObject *obj)
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
Int_t GetEntries() const
Return the number of objects in array (i.e.
TIterator * MakeIterator(Bool_t dir=kIterForward) const
Returns an array iterator.
TObject * At(Int_t idx) const
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.
Template specialisation used in RooAbsArg:
Namespace for the RooStats classes.