40 : fLumi(1.0), fLumiRelErr(.10), fBinLow(0), fBinHigh(1), fExportOnly(
false)
55 :
TNamed(Name, Title), fLumi(1.0), fLumiRelErr(.10), fBinLow(0), fBinHigh(1), fExportOnly(
false)
73 if( std::find(fConstantParams.begin(), fConstantParams.end(), param) != fConstantParams.end() ) {
74 cxcoutWHF <<
"Warning: Setting parameter: " << param
75 <<
" to constant, but it is already listed as constant. "
76 <<
"You may ignore this warning."
81 fConstantParams.push_back( param );
93 if( fParamValues.find(param) != fParamValues.end() ) {
94 cxcoutWHF <<
"Warning: Chainging parameter: " << param
95 <<
" value from: " << fParamValues[param]
101 cxcoutIHF <<
"Setting parameter: " << param
102 <<
" value to " <<
value
105 fParamValues[param] =
value;
117 AddFunctionObject(func);
127 for(
unsigned int i = 0; i < fFunctionObjects.size(); ++i ) {
128 std::string expression = fFunctionObjects.at(i).GetCommand();
149 fUniformSyst[
syst] = 1.0;
163 for(
unsigned int i = 0; i < fChannels.size(); ++i ) {
181 for(
unsigned int i = 0; i < fChannels.size(); ++i ) {
193 <<
" in measurement: " << GetName() << std::endl;
214 stream <<
"Measurement Name: " << GetName()
215 <<
"\t OutputFilePrefix: " << fOutputFilePrefix
217 for(
unsigned int i = 0; i < fPOI.size(); ++i) {
218 stream << fPOI.at(i);
220 stream <<
"\t Lumi: " << fLumi
221 <<
"\t LumiRelErr: " << fLumiRelErr
222 <<
"\t BinLow: " << fBinLow
223 <<
"\t BinHigh: " << fBinHigh
224 <<
"\t ExportOnly: " << fExportOnly
228 if( !fConstantParams.empty() ) {
229 stream <<
"Constant Params: ";
230 for(
unsigned int i = 0; i < fConstantParams.size(); ++i ) {
231 stream <<
" " << fConstantParams.at(i);
236 if( !fFunctionObjects.empty() ) {
237 stream <<
"Preprocess Functions: ";
238 for(
unsigned int i = 0; i < fFunctionObjects.size(); ++i ) {
239 stream <<
" " << fFunctionObjects.at(i).GetCommand();
244 if( !fChannels.empty() ) {
245 stream <<
"Channels:" << std::endl;
246 for(
unsigned int i = 0; i < fChannels.size(); ++i ) {
247 fChannels.at(i).Print( stream );
251 cxcoutIHF <<
"End Measurement: " << GetName() << std::endl;
266 bool exists =
dir !=
nullptr;
283 cxcoutPHF <<
"Printing XML Files for measurement: " << GetName() << std::endl;
285 std::string
XMLName = std::string(GetName()) +
".xml";
290 if( !
xml.is_open() ) {
297 xml <<
"<!--" << std::endl;
298 xml <<
"This xml file created automatically on: " << std::endl;
318 xml <<
"-->" << std::endl;
321 xml <<
"<!DOCTYPE Combination SYSTEM 'HistFactorySchema.dtd'>" << std::endl << std::endl;
325 xml <<
"<Combination OutputFilePrefix=\"" <<
newOutputPrefix <<
"\" >" << std::endl << std::endl;
328 for(
unsigned int i = 0; i < fFunctionObjects.size(); ++i ) {
342 for(
unsigned int i = 0; i < fChannels.size(); ++i ) {
343 xml <<
" <Input>" <<
"./";
345 xml << GetName() <<
"_" << fChannels.at(i).GetName() <<
".xml" <<
"</Input>" << std::endl;
351 xml <<
" <Measurement Name=\"" << GetName() <<
"\" "
352 <<
"Lumi=\"" << fLumi <<
"\" "
353 <<
"LumiRelErr=\"" << fLumiRelErr <<
"\" "
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;
369 if(!fConstantParams.empty()) {
370 xml <<
" <ParamSetting Const=\"True\">";
371 for(
unsigned int i = 0; i < fConstantParams.size(); ++i ) {
372 if (i==0)
xml << fConstantParams.at(i);
373 else xml <<
" " << fConstantParams.at(i);;
375 xml <<
"</ParamSetting>" << std::endl;
379 std::map<std::string, double>::iterator
ConstrItr;
383 xml <<
"<ConstraintTerm Type=\"Gamma\" RelativeUncertainty=\""
385 <<
"</ConstraintTerm>" << std::endl;
389 xml <<
"<ConstraintTerm Type=\"Uniform\" RelativeUncertainty=\""
391 <<
"</ConstraintTerm>" << std::endl;
395 xml <<
"<ConstraintTerm Type=\"LogNormal\" RelativeUncertainty=\""
397 <<
"</ConstraintTerm>" << std::endl;
401 xml <<
"<ConstraintTerm Type=\"NoSyst\" RelativeUncertainty=\""
403 <<
"</ConstraintTerm>" << std::endl;
408 xml <<
" </Measurement> " << std::endl << std::endl;
411 xml <<
"</Combination>" << std::endl;
418 std::string prefix = std::string(GetName()) +
"_";
420 for(
unsigned int i = 0; i < fChannels.size(); ++i ) {
421 fChannels.at(i).PrintXML(
directory, prefix );
425 cxcoutPHF <<
"Finished printing XML files" << std::endl;
466 <<
" has uninitialized histogram pointers" << std::endl;
523 cxcoutEHF <<
"Error: Directory " <<
sampName <<
" not created properly" << std::endl;
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,
"" );
653 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.
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.