74 cxcoutWHF <<
"Warning: Setting parameter: " << param
75 <<
" to constant, but it is already listed as constant. "
76 <<
"You may ignore this warning."
94 cxcoutWHF <<
"Warning: Chainging parameter: " << param
101 cxcoutIHF <<
"Setting parameter: " << param
102 <<
" value to " <<
value
126 std::vector<std::string> PreprocessFunctionExpressions;
129 PreprocessFunctionExpressions.push_back( expression );
131 return PreprocessFunctionExpressions;
166 if( chan.
GetName() == ChanName ) {
184 if( chan.
GetName() == ChanName ) {
192 cxcoutEHF <<
"Error: Did not find channel: " << ChanName
193 <<
" in measurement: " <<
GetName() << std::endl;
214 stream <<
"Measurement Name: " <<
GetName()
217 for(
unsigned int i = 0;
i <
fPOI.size(); ++
i) {
218 stream <<
fPOI.at(
i);
220 stream <<
"\t Lumi: " <<
fLumi
229 stream <<
"Constant Params: ";
237 stream <<
"Preprocess Functions: ";
245 stream <<
"Channels:" << std::endl;
251 cxcoutIHF <<
"End Measurement: " <<
GetName() << std::endl;
264 auto testExists = [](
const std::string& theDirectory) {
265 void* dir =
gSystem->OpenDirectory(theDirectory.c_str());
266 bool exists = dir !=
nullptr;
273 if ( !directory.empty() && !testExists(directory) ) {
274 int success =
gSystem->MakeDirectory(directory.c_str() );
276 cxcoutEHF <<
"Error: Failed to make directory: " << directory << std::endl;
283 cxcoutPHF <<
"Printing XML Files for measurement: " <<
GetName() << std::endl;
285 std::string XMLName = std::string(
GetName()) +
".xml";
286 if( !directory.empty() ) XMLName = directory +
"/" + XMLName;
288 ofstream xml( XMLName.c_str() );
290 if( ! xml.is_open() ) {
291 cxcoutEHF <<
"Error opening xml file: " << XMLName << std::endl;
297 xml <<
"<!--" << std::endl;
298 xml <<
"This xml file created automatically on: " << std::endl;
312 t.
GetDate(
true, 0, &year, &month, &day);
318 xml <<
"-->" << std::endl;
321 xml <<
"<!DOCTYPE Combination SYSTEM 'HistFactorySchema.dtd'>" << std::endl << std::endl;
325 xml <<
"<Combination OutputFilePrefix=\"" << newOutputPrefix <<
"\" >" << std::endl << std::endl;
343 xml <<
" <Input>" <<
"./";
344 if (!directory.empty() ) xml << directory <<
"/";
345 xml <<
GetName() <<
"_" <<
fChannels.at(
i).GetName() <<
".xml" <<
"</Input>" << std::endl;
351 xml <<
" <Measurement Name=\"" <<
GetName() <<
"\" "
352 <<
"Lumi=\"" <<
fLumi <<
"\" "
356 <<
"ExportOnly=\"" << (
fExportOnly ? std::string(
"True") : std::string(
"False")) <<
"\" "
357 <<
" >" << std::endl;
362 for(
unsigned int i = 0;
i <
fPOI.size(); ++
i) {
363 if(
i==0) xml <<
fPOI.at(
i);
364 else xml <<
" " <<
fPOI.at(
i);
366 xml <<
"</POI> " << std::endl;
370 xml <<
" <ParamSetting Const=\"True\">";
375 xml <<
"</ParamSetting>" << std::endl;
379 std::map<std::string, double>::iterator ConstrItr;
383 xml <<
"<ConstraintTerm Type=\"Gamma\" RelativeUncertainty=\""
384 << ConstrItr->second <<
"\">" << ConstrItr->first
385 <<
"</ConstraintTerm>" << std::endl;
389 xml <<
"<ConstraintTerm Type=\"Uniform\" RelativeUncertainty=\""
390 << ConstrItr->second <<
"\">" << ConstrItr->first
391 <<
"</ConstraintTerm>" << std::endl;
395 xml <<
"<ConstraintTerm Type=\"LogNormal\" RelativeUncertainty=\""
396 << ConstrItr->second <<
"\">" << ConstrItr->first
397 <<
"</ConstraintTerm>" << std::endl;
400 for( ConstrItr =
fNoSyst.begin(); ConstrItr !=
fNoSyst.end(); ++ConstrItr ) {
401 xml <<
"<ConstraintTerm Type=\"NoSyst\" RelativeUncertainty=\""
402 << ConstrItr->second <<
"\">" << ConstrItr->first
403 <<
"</ConstraintTerm>" << std::endl;
408 xml <<
" </Measurement> " << std::endl << std::endl;
411 xml <<
"</Combination>" << std::endl;
418 std::string prefix = std::string(
GetName()) +
"_";
421 fChannels.at(
i).PrintXML( directory, prefix );
425 cxcoutPHF <<
"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 cxcoutEHF <<
"Measurement.writeToFile(): Channel: " << chanName
466 <<
" has uninitialized histogram pointers" << std::endl;
480 if( chanDir ==
nullptr ) {
481 cxcoutEHF <<
"Error: Cannot create channel " << (chanName +
"_hists")
489 if( dataDir ==
nullptr ) {
490 cxcoutEHF <<
"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 cxcoutPHF <<
"Writing sample: " << sampName << std::endl;
522 if( sampleDir ==
nullptr ) {
523 cxcoutEHF <<
"Error: Directory " << sampName <<
" not created properly" << std::endl;
526 std::string sampleDirPath =
GetDirPath( sampleDir );
529 cxcoutEHF <<
"Error making directory: " << sampName
530 <<
" in directory: " << chanName
538 sample.
writeToFile( OutputFileName, sampleDirPath );
600 cxcoutPHF <<
"Saved all histograms" << std::endl;
605 cxcoutPHF <<
"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,
"" );
649 for(
unsigned int chanItr = 0; chanItr <
fChannels.size(); ++chanItr) {
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
R__EXTERN TSystem * gSystem
This class encapsulates all information for the statistical interpretation of one experiment.
bool CheckHistograms() const
std::vector< RooStats::HistFactory::Sample > & GetSamples()
get vector of samples for this channel
std::string GetName() const
get name of channel
void writeToFile(std::string FileName, std::string DirName)
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
void writeToFile(TFile *file)
A measurement, once fully configured, can be saved into a ROOT file.
std::string fOutputFilePrefix
Configurables of this measurement.
void AddGammaSyst(std::string syst, double uncert)
Set constraint term for given systematic to Gamma distribution.
std::map< std::string, double > fGammaSyst
List of Alternate constraint terms.
std::string GetDirPath(TDirectory *dir)
Return the directory's path, stripped of unnecessary prefixes.
void AddLogNormSyst(std::string syst, double uncert)
Set constraint term for given systematic to LogNormal distribution.
void PrintXML(std::string Directory="", std::string NewOutputPrefix="")
Print to a stream.
RooStats::HistFactory::Channel & GetChannel(std::string)
Get channel with given name from this measurement throws an exception in case the channel is not foun...
void SetParamValue(const std::string ¶m, double value)
Set a parameter to a specific value (And optionally fix it)
std::map< std::string, double > fLogNormSyst
std::map< std::string, double > fNoSyst
void CollectHistograms()
The most common way to add histograms to channels is to have them stored in ROOT files and to give Hi...
bool HasChannel(std::string)
Check if the given channel is part of this measurement.
std::vector< std::string > fConstantParams
List of Parameters to be set constant.
void AddUniformSyst(std::string syst)
Set constraint term for given systematic to uniform distribution.
std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects
List of Preprocess Function objects.
std::map< std::string, double > fParamValues
Map of parameter names to initial values to be set.
void PrintTree(std::ostream &=std::cout)
Print information about measurement object in tree-like structure to given stream.
Measurement()
Standard constructor.
void AddNoSyst(std::string syst)
Define given systematics to have no external constraint.
void AddConstantParam(const std::string ¶m)
Add a parameter to be set as constant (Similar to ParamSetting method below)
void AddFunctionObject(const RooStats::HistFactory::PreprocessFunction function)
add a preprocess function object
void AddPreprocessFunction(std::string name, std::string expression, std::string dependencies)
Add a preprocessed function by giving the function a name, a functional expression,...
std::vector< std::string > GetPreprocessFunctions() const
Returns a list of defined preprocess function expressions.
std::vector< std::string > fPOI
std::map< std::string, double > fUniformSyst
std::vector< RooStats::HistFactory::Channel > fChannels
Channels that make up this measurement.
void PrintXML(std::ostream &) const
std::string GetName() const
get name of sample
void writeToFile(std::string FileName, std::string DirName)
Bool_t cd() override
Change current directory to "this" directory.
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
Describe directory structure in memory.
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
virtual Bool_t cd()
Change current directory to "this" directory.
virtual const char * GetPath() const
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
const char * GetName() const override
Returns name of object.
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
The TTimeStamp encapsulates seconds and ns since EPOCH.
UInt_t GetDate(Bool_t inUTC=kTRUE, Int_t secOffset=0, UInt_t *year=nullptr, UInt_t *month=nullptr, UInt_t *day=nullptr) const
Return date in form of 19971224 (i.e.