40 HLFactory::HLFactory(
const char *
name,
48 fCombinationDone(false),
89 TNamed(
"hlfactory",
"hlfactory"),
132 const char* SigBkgPdfName,
133 const char* BkgPdfName,
134 const char* DatasetName){
136 std::cerr <<
"Cannot add anymore channels. " 137 <<
"Combination already carried out.\n";
141 if (SigBkgPdfName!=0){
143 std::cerr <<
"Pdf " << SigBkgPdfName <<
" not found in workspace!\n";
152 std::cerr <<
"Pdf " << BkgPdfName <<
" not found in workspace!\n";
161 std::cerr <<
"Dataset " << DatasetName <<
" not found in workspace!\n";
204 while ((obj = it->
Next())){
253 while ((obj = it->
Next())){
310 while ((obj = it->
Next())){
314 if (!data)
return NULL;
387 const int maxDeepness=50;
389 TString warning(
"The inclusion stack is deeper than ");
390 warning+=maxDeepness;
391 warning+=
". Is this a recursive inclusion?";
392 Warning(
"fReadFile",
"%s", warning.Data());
397 std::ifstream ifile(fileName);
400 TString error(
"File ");
402 error+=
" could not be opened.";
403 Error(
"fReadFile",
"%s", error.Data());
407 TString ifileContent(
"");
408 ifileContent.ReadFile(ifile);
422 while((line_o=(*lineIt)())){
423 line = (
static_cast<TObjString*
>(line_o))->GetString();
427 if (line.EndsWith(
"*/")){
429 if (
fVerbose)
Info(
"fReadFile",
"Out of multiline comment ...");
436 if ((line.BeginsWith(
"/*") && line.EndsWith(
"*/")) ||
437 line.BeginsWith(
"//")){
438 if (
fVerbose)
Info(
"fReadFile",
"In single line comment ...");
443 if (line.BeginsWith(
"/*")){
445 if (
fVerbose)
Info(
"fReadFile",
"In multiline comment ...");
449 ifileContentStripped+=line+
"\n";
457 lines_array = ifileContentStripped.Tokenize(
";");
464 while((line_o=(*lineIt)())){
466 line = (
static_cast<TObjString*
>(line_o))->GetString();
472 line.ReplaceAll(
"\n",
"");
475 if (line.BeginsWith(
"echo")){
476 line =
line(5,line.Length()-1);
478 std::cout <<
"Echoing line " << line.Data() << std::endl;
479 std::cout <<
"[" <<
GetName() <<
"] echo: " 480 << line.Data() << std::endl;
486 line.ReplaceAll(neutrals[i],
"");
489 if (
fVerbose)
Info(
"fReadFile",
"Reading --> %s <--", line.Data());
493 if (
fVerbose)
Info(
"fReadFile",
"%s",
"Empty line: skipping ...");
499 if (line.BeginsWith(
"#include")){
500 line.ReplaceAll(
"#include",
"");
501 if (
fVerbose)
Info(
"fReadFile",
"Reading included file...");
537 while ((obj = it->
Next())){
554 std::cerr <<
"The number of datasets and models added as channels " 555 <<
" is not the same!\n";
564 if (
fVerbose)
Info(
"fParseLine",
"Parsing line: %s", line.Data());
566 TString new_line(
"");
568 const int nequals = line.CountChar(
'=');
572 if (line.Contains(
"::") ||
574 (line.Contains(
"[") &&
575 line.Contains(
"]") &&
577 ! line.Contains(
"(") &&
578 ! line.Contains(
")"))) {
585 (nequals > 1 && line.Contains(
"SIMUL"))){
589 const int equal_index=line.First(
'=');
590 const int par_index=line.First(
'(');
591 TString o_name(
line(0,equal_index));
592 TString o_class(
line(equal_index+1,par_index-equal_index-1));
593 TString o_descr(
line(par_index+1,line.Length()-par_index-2));
595 if (
fVerbose)
Info(
"fParseLine",
"o_name=%s o_class=%s o_descr=%s",
596 o_name.Data(), o_class.Data(), o_descr.Data());
600 if (o_class ==
"import"){
604 TObjArray* descr_array = o_descr.Tokenize(
",");
606 const int n_descr_parts=descr_array->
GetEntries();
608 if (n_descr_parts<2 || n_descr_parts>3)
609 Error(
"fParseLine",
"Import wrong syntax: cannot process %s", o_descr.Data());
611 TString obj_name (static_cast<TObjString*>(descr_array->
At(n_descr_parts-1))->GetString());
613 TString rootfile_name (static_cast<TObjString*>(descr_array->
At(0))->GetString());
619 if (n_descr_parts==3){
620 o_descr.ReplaceAll(
",",
":");
623 else if(n_descr_parts==2){
625 Info(
"fParseLine",
"Importing %s from %s under the name of %s",
626 obj_name.Data(), rootfile_name.Data(), o_name.Data());
627 TObject* the_obj=ifile->Get(obj_name);
634 new_line=o_class+
"::"+o_name+
"("+o_descr+
")";
637 std::cout <<
"DEBUG: line: " << line.Data() << std::endl;
638 std::cout <<
"DEBUG: new_line: " << new_line.Data() << std::endl;
virtual const char * GetName() const
Returns name of object.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
RooCategory * fComboCat
The category of the combination.
Collectable string class.
int AddChannel(const char *label, const char *SigBkgPdfName, const char *BkgPdfName=0, const char *datasetName=0)
Add channel for the combination.
bool fOwnWs
Owns workspace.
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
Set value by specifying the index code of the desired state.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetEntries() const
RooDataSet * GetTotDataSet()
Get the combined dataset.
TString neutrals[nNeutrals]
TObject * At(Int_t idx) const
RooWorkspace * fWs
The RooWorkspace containing the models and variables.
TList fBkgPdfNames
List of channels names to combine for the background pdfs.
Iterator abstract base class.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
void fCreateCategory()
Create the category for the combinations.
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a column with the values of the given (function) argument to this dataset.
The TNamed class is the base class for all named ROOT classes.
HLFactory is an High Level model Factory allows you to describe your models in a configuration file (...
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
RooDataSet * fComboDataset
The datasets combination.
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
HLFactory()
Default Constructor.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found...
RooAbsPdf * GetTotBkgPdf()
Get the combined background pdf.
RooAbsPdf * fComboBkgPdf
The background model combination.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
TList fDatasetsNames
List of channels names to combine for the datasets.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
RooAbsPdf * fComboSigBkgPdf
The signal plus background model combination.
RooDataSet is a container class to hold unbinned data.
int fInclusionLevel
Keep trace of the inclusion deepness.
RooCategory represents a fundamental (non-derived) discrete value object.
bool fNamesListsConsistent()
Check the length of the lists.
~HLFactory()
Default Destructor.
bool fVerbose
The verbosity flag.
int ProcessCard(const char *filename)
Process a configuration file.
Namespace for the RooStats classes.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
TIterator * MakeIterator(Bool_t dir=kIterForward) const
Returns an array iterator.
RooCategory * GetTotCategory()
Get the combined dataset.
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
void append(RooDataSet &data)
Add all data points of given data set to this data set.
static RooMathCoreReg dummy
bool fCombinationDone
Flag to keep trace of the status of the combination.
TList fSigBkgPdfNames
List of channels names to combine for the signal plus background pdfs.
TList fLabelsNames
List of channels names to combine for the datasets.
Mother of all ROOT objects.
RooFactoryWSTool & factory()
Return instance to factory tool.
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
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.
virtual void Add(TObject *obj)
int fParseLine(TString &line)
Parse a single line an puts the content in the RooWorkSpace.
virtual TObject * Next()=0
Int_t GetEntries() const
Return the number of objects in array (i.e.
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index...
RooAbsPdf * GetTotSigBkgPdf()
Get the combined signal plus background pdf.
virtual Int_t GetSize() const
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset...
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
The RooWorkspace is a persistable container for RooFit projects.
int fReadFile(const char *fileName, bool is_included=false)
Read the actual cfg file.