32 using namespace RooStats;
33 using namespace RooFit;
40 HLFactory::HLFactory(
const char *
name,
48 fCombinationDone(
false),
75 fCombinationDone(
false),
89 TNamed(
"hlfactory",
"hlfactory"),
94 fCombinationDone(
false),
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?";
397 std::ifstream ifile(fileName);
402 error+=
" could not be opened.";
418 bool in_comment=
false;
422 while((line_o=(*lineIt)())){
423 line = (
static_cast<TObjString*
>(line_o))->GetString();
429 if (
fVerbose)
Info(
"fReadFile",
"Out of multiline comment ...");
438 if (
fVerbose)
Info(
"fReadFile",
"In single line comment ...");
445 if (
fVerbose)
Info(
"fReadFile",
"In multiline comment ...");
449 ifileContentStripped+=line+
"\n";
457 lines_array = ifileContentStripped.
Tokenize(
";");
461 const int nNeutrals=2;
464 while((line_o=(*lineIt)())){
466 line = (
static_cast<TObjString*
>(line_o))->GetString();
478 std::cout <<
"Echoing line " << line.
Data() << std::endl;
479 std::cout <<
"[" <<
GetName() <<
"] echo: "
480 << line.
Data() << std::endl;
493 if (
fVerbose)
Info(
"fReadFile",
"%s",
"Empty line: skipping ...");
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";
585 (nequals > 1 && line.
Contains(
"SIMUL"))){
589 const int equal_index=line.
First(
'=');
590 const int par_index=line.
First(
'(');
592 TString o_class(
line(equal_index+1,par_index-equal_index-1));
595 if (
fVerbose)
Info(
"fParseLine",
"o_name=%s o_class=%s o_descr=%s",
600 if (o_class ==
"import"){
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){
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 Int_t GetEntries() const
std::istream & ReadFile(std::istream &str)
Replace string with the contents of strm, stopping at an EOF.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
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.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found...
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.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
static const char * filename()
RooDataSet * GetTotDataSet()
Get the combined dataset.
ClassImp(RooStats::HLFactory)
RooWorkspace * fWs
The RooWorkspace containing the models and variables.
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
TIterator * MakeIterator(Bool_t dir=kIterForward) const
Returns an array iterator.
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.
const char * Data() const
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.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
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 (...
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
RooDataSet * fComboDataset
The datasets combination.
HLFactory()
Default Constructor.
RooAbsPdf * GetTotBkgPdf()
Get the combined background pdf.
RooAbsPdf * fComboBkgPdf
The background model combination.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
TList fDatasetsNames
List of channels names to combine for the datasets.
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual const char * GetName() const
Returns name of object.
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
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.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
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.
virtual Int_t GetSize() const
RooCategory * GetTotCategory()
Get the combined dataset.
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.
Int_t GetEntries() const
Return the number of objects in array (i.e.
Mother of all ROOT objects.
RooFactoryWSTool & factory()
Return instance to factory tool.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
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.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual TObject * Next()=0
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
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.
TObject * At(Int_t idx) const
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset...
Ssiz_t First(char c) const
Find first occurrence of a character c.
The RooWorkspace is a persistable container for RooFit projects.
int fReadFile(const char *fileName, bool is_included=false)
Read the actual cfg file.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.