42 fPOI(), fLumi( 1.0 ), fLumiRelErr( .10 ),
43 fBinLow( 0 ), fBinHigh( 1 ), fExportOnly( false )
77 std::cout <<
"Warning: Setting parameter: " << param
78 <<
" to constant, but it is already listed as constant. " 79 <<
"You may ignore this warning." 97 std::cout <<
"Warning: Chainging parameter: " << param
104 std::cout <<
"Setting parameter: " << param
105 <<
" value to " << value
127 std::vector<std::string> PreprocessFunctionExpressions;
130 PreprocessFunctionExpressions.push_back( expression );
132 return PreprocessFunctionExpressions;
168 for(
unsigned int i = 0; i <
fChannels.size(); ++i ) {
171 if( chan.
GetName() == ChanName ) {
186 for(
unsigned int i = 0; i <
fChannels.size(); ++i ) {
189 if( chan.
GetName() == ChanName ) {
197 std::cout <<
"Error: Did not find channel: " << ChanName
198 <<
" in measurement: " <<
GetName() << std::endl;
218 stream <<
"Measurement Name: " <<
GetName()
221 for(
unsigned int i = 0; i <
fPOI.size(); ++i) {
222 stream <<
fPOI.at(i);
224 stream <<
"\t Lumi: " <<
fLumi 233 stream <<
"Constant Params: ";
241 stream <<
"Preprocess Functions: ";
249 stream <<
"Channels:" << std::endl;
250 for(
unsigned int i = 0; i <
fChannels.size(); ++i ) {
255 std::cout <<
"End Measurement: " <<
GetName() << std::endl;
271 auto testExists = [](
const std::string& theDirectory) {
273 bool exists = dir !=
nullptr;
280 if ( !directory.empty() && !testExists(directory) ) {
283 std::cout <<
"Error: Failed to make directory: " << directory << std::endl;
290 std::cout <<
"Printing XML Files for measurement: " <<
GetName() << std::endl;
292 std::string XMLName = std::string(
GetName()) +
".xml";
293 if( directory !=
"" ) XMLName = directory +
"/" + XMLName;
295 ofstream xml( XMLName.c_str() );
297 if( ! xml.is_open() ) {
298 std::cout <<
"Error opening xml file: " << XMLName << std::endl;
304 xml <<
"<!--" << std::endl;
305 xml <<
"This xml file created automatically on: " << std::endl;
319 t.
GetDate(
true, 0, &year, &month, &day);
325 xml <<
"-->" << std::endl;
328 xml <<
"<!DOCTYPE Combination SYSTEM 'HistFactorySchema.dtd'>" << std::endl << std::endl;
332 xml <<
"<Combination OutputFilePrefix=\"" << newOutputPrefix <<
"\" >" << std::endl << std::endl;
349 for(
unsigned int i = 0; i <
fChannels.size(); ++i ) {
350 xml <<
" <Input>" <<
"./";
351 if (!directory.empty() ) xml << directory <<
"/";
352 xml <<
GetName() <<
"_" <<
fChannels.at(i).GetName() <<
".xml" <<
"</Input>" << std::endl;
358 xml <<
" <Measurement Name=\"" <<
GetName() <<
"\" " 359 <<
"Lumi=\"" <<
fLumi <<
"\" " 363 <<
"ExportOnly=\"" << (
fExportOnly ? std::string(
"True") : std::string(
"False")) <<
"\" " 364 <<
" >" << std::endl;
369 for(
unsigned int i = 0; i <
fPOI.size(); ++i) {
370 if(i==0) xml <<
fPOI.at(i);
371 else xml <<
" " <<
fPOI.at(i);
373 xml <<
"</POI> " << std::endl;
377 xml <<
" <ParamSetting Const=\"True\">";
382 xml <<
"</ParamSetting>" << std::endl;
386 std::map<std::string, double>::iterator ConstrItr;
390 xml <<
"<ConstraintTerm Type=\"Gamma\" RelativeUncertainty=\"" 391 << ConstrItr->second <<
"\">" << ConstrItr->first
392 <<
"</ConstraintTerm>" << std::endl;
396 xml <<
"<ConstraintTerm Type=\"Uniform\" RelativeUncertainty=\"" 397 << ConstrItr->second <<
"\">" << ConstrItr->first
398 <<
"</ConstraintTerm>" << std::endl;
402 xml <<
"<ConstraintTerm Type=\"LogNormal\" RelativeUncertainty=\"" 403 << ConstrItr->second <<
"\">" << ConstrItr->first
404 <<
"</ConstraintTerm>" << std::endl;
407 for( ConstrItr =
fNoSyst.begin(); ConstrItr !=
fNoSyst.end(); ++ConstrItr ) {
408 xml <<
"<ConstraintTerm Type=\"NoSyst\" RelativeUncertainty=\"" 409 << ConstrItr->second <<
"\">" << ConstrItr->first
410 <<
"</ConstraintTerm>" << std::endl;
415 xml <<
" </Measurement> " << std::endl << std::endl;
418 xml <<
"</Combination>" << std::endl;
425 std::string prefix = std::string(
GetName()) +
"_";
427 for(
unsigned int i = 0; i <
fChannels.size(); ++i ) {
428 fChannels.at(i).PrintXML( directory, prefix );
432 std::cout <<
"Finished printing XML files" << std::endl;
454 std::string OutputFileName = file->GetName();
460 for(
unsigned int chanItr = 0; chanItr < outMeas.
fChannels.size(); ++chanItr ) {
469 std::string chanName = channel.
GetName();
473 std::cout <<
"Measurement.writeToFile(): Channel: " << chanName
474 <<
" has uninitialized histogram pointers" << std::endl;
488 if( chanDir == NULL ) {
489 std::cout <<
"Error: Cannot create channel " << (chanName +
"_hists")
497 if( dataDir == NULL ) {
498 std::cout <<
"Error: Cannot make directory " << chanDir << std::endl;
520 for(
unsigned int sampItr = 0; sampItr < channel.
GetSamples().size(); ++sampItr ) {
523 std::string sampName = sample.
GetName();
525 std::cout <<
"Writing sample: " << sampName << std::endl;
530 if( sampleDir == NULL ) {
531 std::cout <<
"Error: Directory " << sampName <<
" not created properly" << std::endl;
534 std::string sampleDirPath =
GetDirPath( sampleDir );
537 std::cout <<
"Error making directory: " << sampName
538 <<
" in directory: " << chanName
546 sample.
writeToFile( OutputFileName, sampleDirPath );
608 std::cout <<
"Saved all histograms" << std::endl;
613 std::cout <<
"Saved Measurement" << std::endl;
623 std::string path = dir->
GetPath();
625 if( path.find(
":") != std::string::npos ) {
626 size_t index = path.find(
":");
627 path.replace( 0, index+1,
"" );
658 for(
unsigned int chanItr = 0; chanItr <
fChannels.size(); ++chanItr) {
void AddUniformSyst(std::string syst)
virtual const char * GetName() const
Returns name of object.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
std::map< std::string, double > fGammaSyst
void PrintXML(std::string Directory="", std::string NewOutputPrefix="")
virtual int MakeDirectory(const char *name)
Make a directory.
void AddPreprocessFunction(std::string name, std::string expression, std::string dependencies)
virtual TDirectory * mkdir(const char *name, const char *title="")
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
std::vector< std::string > GetPreprocessFunctions()
std::vector< RooStats::HistFactory::Channel > fChannels
std::map< std::string, double > fParamValues
void AddFunctionObject(const RooStats::HistFactory::PreprocessFunction function)
The TNamed class is the base class for all named ROOT classes.
bool HasChannel(std::string)
std::string GetDirPath(TDirectory *dir)
std::vector< std::string > fConstantParams
void writeToFile(std::string FileName, std::string DirName)
void writeToFile(std::string FileName, std::string DirName)
void AddGammaSyst(std::string syst, double uncert)
R__EXTERN TSystem * gSystem
void AddConstantParam(const std::string ¶m)
std::vector< std::string > fPOI
virtual const char * GetPath() const
Returns the full path of the directory.
virtual void FreeDirectory(void *dirp)
Free a directory.
Describe directory structure in memory.
The TTimeStamp encapsulates seconds and ns since EPOCH.
void AddNoSyst(std::string syst)
std::vector< RooStats::HistFactory::Sample > & GetSamples()
RooStats::HistFactory::Channel & GetChannel(std::string)
void SetParamValue(const std::string ¶m, double value)
std::map< std::string, double > fLogNormSyst
std::map< std::string, double > fUniformSyst
std::map< std::string, double > fNoSyst
void PrintXML(std::ostream &)
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
std::string fOutputFilePrefix
void AddLogNormSyst(std::string syst, double uncert)
UInt_t GetDate(Bool_t inUTC=kTRUE, Int_t secOffset=0, UInt_t *year=0, UInt_t *month=0, UInt_t *day=0) const
Return date in form of 19971224 (i.e.
void PrintTree(std::ostream &=std::cout)
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects
void writeToFile(TFile *file)