50 HLFactory::HLFactory(
const char *
name,
58 fCombinationDone(false),
99 TNamed(
"hlfactory",
"hlfactory"),
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?";
403 Warning(
"fReadFile",
"%s", warning.Data());
408 std::ifstream ifile(fileName);
411 TString error(
"File ");
413 error+=
" could not be opened.";
414 Error(
"fReadFile",
"%s", error.Data());
418 TString ifileContent(
"");
419 ifileContent.ReadFile(ifile);
424 TString ifileContentStripped(
"");
426 TObjArray* lines_array = ifileContent.Tokenize(
"\n");
429 bool in_comment=
false;
433 while((line_o=(*lineIt)())){
434 line = (
static_cast<TObjString*
>(line_o))->GetString();
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)())){
477 line = (
static_cast<TObjString*
>(line_o))->GetString();
483 line.ReplaceAll(
"\n",
"");
486 if (line.BeginsWith(
"echo")){
487 line =
line(5,line.Length()-1);
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],
"");
500 if (
fVerbose)
Info(
"fReadFile",
"Reading --> %s <--", line.Data());
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";
575 if (
fVerbose)
Info(
"fParseLine",
"Parsing line: %s", line.Data());
577 TString new_line(
"");
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(
'(');
602 TString o_name(
line(0,equal_index));
603 TString o_class(
line(equal_index+1,par_index-equal_index-1));
604 TString o_descr(
line(par_index+1,line.Length()-par_index-2));
606 if (
fVerbose)
Info(
"fParseLine",
"o_name=%s o_class=%s o_descr=%s",
607 o_name.Data(), o_class.Data(), o_descr.Data());
611 if (o_class ==
"import"){
615 TObjArray* descr_array = o_descr.Tokenize(
",");
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());
622 TString obj_name (static_cast<TObjString*>(descr_array->
At(n_descr_parts-1))->GetString());
624 TString rootfile_name (static_cast<TObjString*>(descr_array->
At(0))->GetString());
630 if (n_descr_parts==3){
631 o_descr.ReplaceAll(
",",
":");
634 else if(n_descr_parts==2){
636 Info(
"fParseLine",
"Importing %s from %s under the name of %s",
637 obj_name.Data(), rootfile_name.Data(), o_name.Data());
638 TObject* the_obj=ifile->Get(obj_name);
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;
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.
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.
int fReadFile(const char *fileName, bool is_included=false)
Read the actual cfg file.
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.