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;
275 std::cout <<
"Error: Failed to make directory: " << directory << std::endl;
282 std::cout <<
"Printing XML Files for measurement: " <<
GetName() << std::endl;
284 std::string XMLName = std::string(
GetName()) +
".xml";
285 if( directory !=
"" ) XMLName = directory +
"/" + XMLName;
287 ofstream xml( XMLName.c_str() );
289 if( ! xml.is_open() ) {
290 std::cout <<
"Error opening xml file: " << XMLName << std::endl;
296 xml <<
"<!--" << std::endl;
297 xml <<
"This xml file created automatically on: " << std::endl;
311 t.
GetDate(
true, 0, &year, &month, &day);
317 xml <<
"-->" << std::endl;
320 xml <<
"<!DOCTYPE Combination SYSTEM 'HistFactorySchema.dtd'>" << std::endl << std::endl;
324 xml <<
"<Combination OutputFilePrefix=\"" << newOutputPrefix <<
"\" >" << std::endl << std::endl;
341 for(
unsigned int i = 0; i <
fChannels.size(); ++i ) {
342 xml <<
" <Input>" <<
"./";
343 if (!directory.empty() ) xml << directory <<
"/";
344 xml <<
GetName() <<
"_" <<
fChannels.at(i).GetName() <<
".xml" <<
"</Input>" << std::endl;
350 xml <<
" <Measurement Name=\"" <<
GetName() <<
"\" " 351 <<
"Lumi=\"" <<
fLumi <<
"\" " 355 <<
"ExportOnly=\"" << (
fExportOnly ? std::string(
"True") : std::string(
"False")) <<
"\" " 356 <<
" >" << std::endl;
361 for(
unsigned int i = 0; i <
fPOI.size(); ++i) {
362 if(i==0) xml <<
fPOI.at(i);
363 else xml <<
" " <<
fPOI.at(i);
365 xml <<
"</POI> " << std::endl;
369 xml <<
" <ParamSetting Const=\"True\">";
374 xml <<
"</ParamSetting>" << std::endl;
378 std::map<std::string, double>::iterator ConstrItr;
382 xml <<
"<ConstraintTerm Type=\"Gamma\" RelativeUncertainty=\"" 383 << ConstrItr->second <<
"\">" << ConstrItr->first
384 <<
"</ConstraintTerm>" << std::endl;
388 xml <<
"<ConstraintTerm Type=\"Uniform\" RelativeUncertainty=\"" 389 << ConstrItr->second <<
"\">" << ConstrItr->first
390 <<
"</ConstraintTerm>" << std::endl;
394 xml <<
"<ConstraintTerm Type=\"LogNormal\" RelativeUncertainty=\"" 395 << ConstrItr->second <<
"\">" << ConstrItr->first
396 <<
"</ConstraintTerm>" << std::endl;
399 for( ConstrItr =
fNoSyst.begin(); ConstrItr !=
fNoSyst.end(); ++ConstrItr ) {
400 xml <<
"<ConstraintTerm Type=\"NoSyst\" RelativeUncertainty=\"" 401 << ConstrItr->second <<
"\">" << ConstrItr->first
402 <<
"</ConstraintTerm>" << std::endl;
407 xml <<
" </Measurement> " << std::endl << std::endl;
410 xml <<
"</Combination>" << std::endl;
417 std::string prefix = std::string(
GetName()) +
"_";
419 for(
unsigned int i = 0; i <
fChannels.size(); ++i ) {
420 fChannels.at(i).PrintXML( directory, prefix );
424 std::cout <<
"Finished printing XML files" << std::endl;
446 std::string OutputFileName = file->GetName();
452 for(
unsigned int chanItr = 0; chanItr < outMeas.
fChannels.size(); ++chanItr ) {
461 std::string chanName = channel.
GetName();
465 std::cout <<
"Measurement.writeToFile(): Channel: " << chanName
466 <<
" has uninitialized histogram pointers" << std::endl;
480 if( chanDir ==
NULL ) {
481 std::cout <<
"Error: Cannot create channel " << (chanName +
"_hists")
489 if( dataDir ==
NULL ) {
490 std::cout <<
"Error: Cannot make directory " << chanDir << std::endl;
512 for(
unsigned int sampItr = 0; sampItr < channel.
GetSamples().size(); ++sampItr ) {
515 std::string sampName = sample.
GetName();
517 std::cout <<
"Writing sample: " << sampName << std::endl;
522 if( sampleDir ==
NULL ) {
523 std::cout <<
"Error: Directory " << sampName <<
" not created properly" << std::endl;
526 std::string sampleDirPath =
GetDirPath( sampleDir );
529 std::cout <<
"Error making directory: " << sampName
530 <<
" in directory: " << chanName
538 sample.
writeToFile( OutputFileName, sampleDirPath );
600 std::cout <<
"Saved all histograms" << std::endl;
605 std::cout <<
"Saved Measurement" << std::endl;
615 std::string path = dir->
GetPath();
617 if( path.find(
":") != std::string::npos ) {
618 size_t index = path.find(
":");
619 path.replace( 0, index+1,
"" );
650 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 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.
void writeToFile(std::string FileName, std::string DirName)
Describe directory structure in memory.
The TTimeStamp encapsulates seconds and ns since EPOCH.
double func(double *x, double *p)
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)