39 : fLumi(1.0), fLumiRelErr(.10), fBinLow(0), fBinHigh(1)
54 :
TNamed(Name, Title), fLumi(1.0), fLumiRelErr(.10), fBinLow(0), fBinHigh(1)
72 if( std::find(fConstantParams.begin(), fConstantParams.end(), param) != fConstantParams.end() ) {
73 cxcoutWHF <<
"Warning: Setting parameter: " << param
74 <<
" to constant, but it is already listed as constant. "
75 <<
"You may ignore this warning."
80 fConstantParams.push_back( param );
92 if( fParamValues.find(param) != fParamValues.end() ) {
93 cxcoutWHF <<
"Warning: Chainging parameter: " << param
94 <<
" value from: " << fParamValues[param]
100 cxcoutIHF <<
"Setting parameter: " << param
101 <<
" value to " <<
value
104 fParamValues[param] =
value;
116 AddFunctionObject(func);
126 for(
unsigned int i = 0; i < fFunctionObjects.size(); ++i ) {
127 std::string expression = fFunctionObjects.at(i).GetCommand();
148 fUniformSyst[
syst] = 1.0;
162 for(
unsigned int i = 0; i < fChannels.size(); ++i ) {
180 for(
unsigned int i = 0; i < fChannels.size(); ++i ) {
192 <<
" in measurement: " << GetName() << std::endl;
213 stream <<
"Measurement Name: " << GetName()
214 <<
"\t OutputFilePrefix: " << fOutputFilePrefix
216 for(
unsigned int i = 0; i < fPOI.size(); ++i) {
217 stream << fPOI.at(i);
219 stream <<
"\t Lumi: " << fLumi
220 <<
"\t LumiRelErr: " << fLumiRelErr
221 <<
"\t BinLow: " << fBinLow
222 <<
"\t BinHigh: " << fBinHigh
223 <<
"\t ExportOnly: " << fExportOnly
227 if( !fConstantParams.empty() ) {
228 stream <<
"Constant Params: ";
229 for(
unsigned int i = 0; i < fConstantParams.size(); ++i ) {
230 stream <<
" " << fConstantParams.at(i);
235 if( !fFunctionObjects.empty() ) {
236 stream <<
"Preprocess Functions: ";
237 for(
unsigned int i = 0; i < fFunctionObjects.size(); ++i ) {
238 stream <<
" " << fFunctionObjects.at(i).GetCommand();
243 if( !fChannels.empty() ) {
244 stream <<
"Channels:" << std::endl;
245 for(
unsigned int i = 0; i < fChannels.size(); ++i ) {
246 fChannels.at(i).Print( stream );
250 cxcoutIHF <<
"End Measurement: " << GetName() << std::endl;
265 bool exists = dir !=
nullptr;
282 cxcoutPHF <<
"Printing XML Files for measurement: " << GetName() << std::endl;
284 std::string
XMLName = std::string(GetName()) +
".xml";
289 if( !
xml.is_open() ) {
296 xml <<
"<!--" << std::endl;
297 xml <<
"This xml file created automatically on: " << std::endl;
317 xml <<
"-->" << std::endl;
320 xml <<
"<!DOCTYPE Combination SYSTEM 'HistFactorySchema.dtd'>" << std::endl << std::endl;
324 xml <<
"<Combination OutputFilePrefix=\"" <<
newOutputPrefix <<
"\" >" << std::endl << std::endl;
327 for(
unsigned int i = 0; i < fFunctionObjects.size(); ++i ) {
341 for(
unsigned int i = 0; i < fChannels.size(); ++i ) {
342 xml <<
" <Input>" <<
"./";
344 xml << GetName() <<
"_" << fChannels.at(i).GetName() <<
".xml" <<
"</Input>" << std::endl;
350 xml <<
" <Measurement Name=\"" << GetName() <<
"\" "
351 <<
"Lumi=\"" << fLumi <<
"\" "
352 <<
"LumiRelErr=\"" << fLumiRelErr <<
"\" "
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;
368 if(!fConstantParams.empty()) {
369 xml <<
" <ParamSetting Const=\"True\">";
370 for(
unsigned int i = 0; i < fConstantParams.size(); ++i ) {
371 if (i==0)
xml << fConstantParams.at(i);
372 else xml <<
" " << fConstantParams.at(i);
374 xml <<
"</ParamSetting>" << std::endl;
378 std::map<std::string, double>::iterator
ConstrItr;
382 xml <<
"<ConstraintTerm Type=\"Gamma\" RelativeUncertainty=\""
384 <<
"</ConstraintTerm>" << std::endl;
388 xml <<
"<ConstraintTerm Type=\"Uniform\" RelativeUncertainty=\""
390 <<
"</ConstraintTerm>" << std::endl;
394 xml <<
"<ConstraintTerm Type=\"LogNormal\" RelativeUncertainty=\""
396 <<
"</ConstraintTerm>" << std::endl;
400 xml <<
"<ConstraintTerm Type=\"NoSyst\" RelativeUncertainty=\""
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 cxcoutPHF <<
"Finished printing XML files" << std::endl;
465 <<
" has uninitialized histogram pointers" << std::endl;
522 cxcoutEHF <<
"Error: Directory " <<
sampName <<
" not created properly" << std::endl;
599 cxcoutPHF <<
"Saved all histograms" << std::endl;
604 cxcoutPHF <<
"Saved Measurement" << std::endl;
614 std::string path = dir->
GetPath();
616 if( path.find(
':') != std::string::npos ) {
617 size_t index = path.find(
':');
618 path.replace( 0,
index+1,
"" );
652 chan.CollectHistograms();
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
const_iterator begin() const
const_iterator end() const
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.
void AddGammaSyst(std::string syst, double uncert)
Set constraint term for given systematic to Gamma distribution.
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)
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.
void AddUniformSyst(std::string syst)
Set constraint term for given systematic to uniform distribution.
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 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.
void PrintXML(std::ostream &) const
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 const char * GetPath() const
Returns the full path of the directory.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual int MakeDirectory(const char *name)
Make a 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.