56 cxcoutWHF <<
"Warning: Setting parameter: " << param <<
" to constant, but it is already listed as constant. "
57 <<
"You may ignore this warning." << std::endl;
73 <<
" to: " << value << std::endl;
77 cxcoutIHF <<
"Setting parameter: " << param <<
" value to " << value << std::endl;
95 std::vector<std::string> PreprocessFunctionExpressions;
98 PreprocessFunctionExpressions.push_back(expression);
100 return PreprocessFunctionExpressions;
131 for (
unsigned int i = 0; i <
fChannels.size(); ++i) {
134 if (chan.
GetName() == ChanName) {
146 for (
unsigned int i = 0; i <
fChannels.size(); ++i) {
149 if (chan.
GetName() == ChanName) {
156 cxcoutEHF <<
"Error: Did not find channel: " << ChanName <<
" in measurement: " <<
GetName() << std::endl;
168 for (
unsigned int i = 0; i <
fPOI.size(); ++i) {
169 stream <<
fPOI.at(i);
175 stream <<
"Constant Params: ";
183 stream <<
"Preprocess Functions: ";
191 stream <<
"Channels:" << std::endl;
192 for (
unsigned int i = 0; i <
fChannels.size(); ++i) {
208 auto testExists = [](
const std::string &theDirectory) {
209 void *dir =
gSystem->OpenDirectory(theDirectory.c_str());
210 bool exists = dir !=
nullptr;
217 if (!directory.empty() && !testExists(directory)) {
218 int success =
gSystem->MakeDirectory(directory.c_str());
220 cxcoutEHF <<
"Error: Failed to make directory: " << directory << std::endl;
227 cxcoutPHF <<
"Printing XML Files for measurement: " <<
GetName() << std::endl;
229 std::string XMLName = std::string(
GetName()) +
".xml";
230 if (!directory.empty())
231 XMLName = directory +
"/" + XMLName;
233 std::ofstream xml(XMLName.c_str());
235 if (!xml.is_open()) {
236 cxcoutEHF <<
"Error opening xml file: " << XMLName << std::endl;
241 xml <<
"<!--" << std::endl;
242 xml <<
"This xml file created automatically on: " << std::endl;
249 t.
GetDate(
true, 0, &year, &month, &day);
250 xml << year <<
'-' << month <<
'-' << day << std::endl;
252 xml <<
"-->" << std::endl;
255 xml <<
"<!DOCTYPE Combination SYSTEM 'HistFactorySchema.dtd'>" << std::endl << std::endl;
258 if (newOutputPrefix.empty())
260 xml <<
"<Combination OutputFilePrefix=\"" << newOutputPrefix <<
"\" >" << std::endl
272 for (
unsigned int i = 0; i <
fChannels.size(); ++i) {
273 xml <<
" <Input>" <<
"./";
274 if (!directory.empty())
275 xml << directory <<
"/";
276 xml <<
GetName() <<
"_" <<
fChannels.at(i).GetName() <<
".xml" <<
"</Input>" << std::endl;
282 xml <<
" <Measurement Name=\"" <<
GetName() <<
"\" "
283 <<
"Lumi=\"" <<
fLumi <<
"\" "
288 <<
"ExportOnly=\"" << (
fExportOnly ? std::string(
"True") : std::string(
"False")) <<
"\" "
289 <<
" >" << std::endl;
293 for (
unsigned int i = 0; i <
fPOI.size(); ++i) {
297 xml <<
" " <<
fPOI.at(i);
299 xml <<
"</POI> " << std::endl;
303 xml <<
" <ParamSetting Const=\"True\">";
310 xml <<
"</ParamSetting>" << std::endl;
314 std::map<std::string, double>::iterator ConstrItr;
318 xml <<
"<ConstraintTerm Type=\"Gamma\" RelativeUncertainty=\"" << ConstrItr->second <<
"\">" << ConstrItr->first
319 <<
"</ConstraintTerm>" << std::endl;
323 xml <<
"<ConstraintTerm Type=\"Uniform\" RelativeUncertainty=\"" << ConstrItr->second <<
"\">" << ConstrItr->first
324 <<
"</ConstraintTerm>" << std::endl;
328 xml <<
"<ConstraintTerm Type=\"LogNormal\" RelativeUncertainty=\"" << ConstrItr->second <<
"\">"
329 << ConstrItr->first <<
"</ConstraintTerm>" << std::endl;
332 for (ConstrItr =
fNoSyst.begin(); ConstrItr !=
fNoSyst.end(); ++ConstrItr) {
333 xml <<
"<ConstraintTerm Type=\"NoSyst\" RelativeUncertainty=\"" << ConstrItr->second <<
"\">" << ConstrItr->first
334 <<
"</ConstraintTerm>" << std::endl;
338 xml <<
" </Measurement> " << std::endl << std::endl;
341 xml <<
"</Combination>" << std::endl;
348 std::string prefix = std::string(
GetName()) +
"_";
350 for (
unsigned int i = 0; i <
fChannels.size(); ++i) {
351 fChannels.at(i).PrintXML(directory, prefix);
354 cxcoutPHF <<
"Finished printing XML files" << std::endl;
373 std::string OutputFileName = file->
GetName();
385 std::string chanName = channel.GetName();
387 if (!channel.CheckHistograms()) {
388 cxcoutEHF <<
"Measurement.writeToFile(): Channel: " << chanName <<
" has uninitialized histogram pointers"
403 if (chanDir ==
nullptr) {
404 cxcoutEHF <<
"Error: Cannot create channel " << (chanName +
"_hists") << std::endl;
411 if (dataDir ==
nullptr) {
412 cxcoutEHF <<
"Error: Cannot make directory " << chanDir << std::endl;
417 channel.fData.writeToFile(OutputFileName,
GetDirPath(dataDir));
420 for (
Sample &sample : channel.GetSamples()) {
421 cxcoutPHF <<
"Writing sample: " << sample.GetName() << std::endl;
426 if (sampleDir ==
nullptr) {
427 cxcoutEHF <<
"Error: Directory " << sample.GetName() <<
" not created properly" << std::endl;
430 std::string sampleDirPath =
GetDirPath(sampleDir);
433 cxcoutEHF <<
"Error making directory: " << sample.GetName() <<
" in directory: " << chanName << std::endl;
440 sample.writeToFile(OutputFileName, sampleDirPath);
446 cxcoutPHF <<
"Saved all histograms" << std::endl;
451 cxcoutPHF <<
"Saved Measurement" << std::endl;
458 std::string path = dir->
GetPath();
460 if (path.find(
':') != std::string::npos) {
461 size_t index = path.find(
':');
462 path.replace(0, index + 1,
"");
479 chan.CollectHistograms();
513 SetValue(other.fhCountingHist->GetBinContent(1));
515 fhCountingHist.reset();
550Sample::Sample(std::string SampName, std::string SampHistoName, std::string SampInputFile, std::string SampHistoPath)
572 histNominal->
Write();
608 std::string SampleHistName =
fName +
"_hist";
613 fhCountingHist = std::make_unique<TH1F>(SampleHistName.c_str(), SampleHistName.c_str(), 1, 0, 1);
628 stream <<
"\t \t \t \t "
630 <<
"\t HistoAddress: "
636 stream <<
"\t \t \t StatError Activate: " <<
fStatError.GetActivate() <<
"\t InputFile: " <<
fInputFile
637 <<
"\t HistName: " <<
fStatError.GetHistoName() <<
"\t HistoPath: " <<
fStatError.GetHistoPath()
638 <<
"\t HistoAddress: " <<
fStatError.GetErrorHist() << std::endl;
656 xml <<
" <Sample Name=\"" <<
fName <<
"\" "
660 <<
" NormalizeByTheory=\"" << (
fNormalizeByTheory ? std::string(
"True") : std::string(
"False")) <<
"\" "
753 xml <<
" </Sample>" << std::endl;
813 std::string SysHistoPathLow, std::string SysHistoNameHigh, std::string SysHistoFileHigh,
814 std::string SysHistoPathHigh)
837 std::string SysHistoPathLow, std::string SysHistoNameHigh, std::string SysHistoFileHigh,
838 std::string SysHistoPathHigh)
874 std::string SysHistoFile, std::string SysHistoPath)
924 stream <<
"\t Channel Name: " <<
fName <<
"\t InputFile: " <<
fInputFile << std::endl;
926 stream <<
"\t Data:" << std::endl;
929 stream <<
"\t statErrorConfig:" << std::endl;
934 stream <<
"\t Samples: " << std::endl;
935 for (
unsigned int i = 0; i <
fSamples.size(); ++i) {
940 stream <<
"\t End of Channel " <<
fName << std::endl;
949 std::string XMLName = prefix +
fName +
".xml";
950 if (!directory.empty())
951 XMLName = directory +
"/" + XMLName;
953 std::ofstream xml(XMLName.c_str());
956 xml <<
"<!--" << std::endl;
957 xml <<
"This xml file created automatically on: " << std::endl;
963 t.
GetDate(
true, 0, &year, &month, &day);
964 xml << year <<
'-' << month <<
'-' << day << std::endl;
965 xml <<
"-->" << std::endl;
968 xml <<
"<!DOCTYPE Channel SYSTEM 'HistFactorySchema.dtd'> " << std::endl << std::endl;
971 xml <<
" <Channel Name=\"" <<
fName <<
"\" InputFile=\"" <<
fInputFile <<
"\" >" << std::endl << std::endl;
985 for (
auto const &sample :
fSamples) {
986 sample.PrintXML(xml);
987 xml << std::endl << std::endl;
991 xml <<
" </Channel> " << std::endl;
994 cxcoutPHF <<
"Finished printing XML files" << std::endl;
997void Channel::SetData(std::string DataHistoName, std::string DataInputFile, std::string DataHistoPath)
1002 fData.SetHistoName(DataHistoName);
1003 fData.SetInputFile(DataInputFile);
1004 fData.SetHistoPath(DataHistoPath);
1010 fData.SetHisto(hData);
1021 std::string DataHistName =
fName +
"_data";
1024 TH1F *hData =
new TH1F(DataHistName.c_str(), DataHistName.c_str(), 1, 0, 1);
1053 std::map<std::string, std::unique_ptr<TFile>> fileHandles;
1057 if (!
fData.GetInputFile().empty()) {
1063 if (!data.GetInputFile().empty()) {
1064 data.SetHisto(
GetHistogram(data.GetInputFile(), data.GetHistoPath(), data.GetHistoName(), fileHandles));
1071 cxcoutDHF <<
"Collecting Nominal Histogram" << std::endl;
1072 TH1 *Nominal =
GetHistogram(sample.GetInputFile(), sample.GetHistoPath(), sample.GetHistoName(), fileHandles);
1074 sample.SetHisto(Nominal);
1077 if (sample.GetStatError().GetUseHisto()) {
1078 sample.GetStatError().SetErrorHist(
GetHistogram(sample.GetStatError().GetInputFile(),
1079 sample.GetStatError().GetHistoPath(),
1080 sample.GetStatError().GetHistoName(), fileHandles));
1084 for (
HistoSys &histoSys : sample.GetHistoSysList()) {
1085 histoSys.SetHistoLow(
GetHistogram(histoSys.GetInputFileLow(), histoSys.GetHistoPathLow(),
1086 histoSys.GetHistoNameLow(), fileHandles));
1088 histoSys.SetHistoHigh(
GetHistogram(histoSys.GetInputFileHigh(), histoSys.GetHistoPathHigh(),
1089 histoSys.GetHistoNameHigh(), fileHandles));
1093 for (
HistoFactor &histoFactor : sample.GetHistoFactorList()) {
1094 histoFactor.SetHistoLow(
GetHistogram(histoFactor.GetInputFileLow(), histoFactor.GetHistoPathLow(),
1095 histoFactor.GetHistoNameLow(), fileHandles));
1097 histoFactor.SetHistoHigh(
GetHistogram(histoFactor.GetInputFileHigh(), histoFactor.GetHistoPathHigh(),
1098 histoFactor.GetHistoNameHigh(), fileHandles));
1102 for (
ShapeSys &shapeSys : sample.GetShapeSysList()) {
1103 shapeSys.SetErrorHist(
1104 GetHistogram(shapeSys.GetInputFile(), shapeSys.GetHistoPath(), shapeSys.GetHistoName(), fileHandles));
1108 for (
ShapeFactor &shapeFactor : sample.GetShapeFactorList()) {
1110 if (shapeFactor.HasInitialShape()) {
1111 TH1 *hist =
GetHistogram(shapeFactor.GetInputFile(), shapeFactor.GetHistoPath(), shapeFactor.GetHistoName(),
1113 shapeFactor.SetInitialShape(hist);
1127 if (
fData.GetHisto() ==
nullptr && !
fData.GetInputFile().empty()) {
1128 cxcoutEHF <<
"Error: Data Histogram for channel " <<
GetName() <<
" is nullptr." << std::endl;
1135 if (sample.GetHisto() ==
nullptr) {
1136 cxcoutEHF <<
"Error: Nominal Histogram for sample " << sample.GetName() <<
" is nullptr." << std::endl;
1141 std::vector<int> NegativeBinNumber;
1142 std::vector<double> NegativeBinContent;
1143 const TH1 *histNominal = sample.GetHisto();
1144 for (
int ibin = 1; ibin <= histNominal->
GetNbinsX(); ++ibin) {
1146 NegativeBinNumber.push_back(ibin);
1147 NegativeBinContent.push_back(histNominal->
GetBinContent(ibin));
1150 if (!NegativeBinNumber.empty()) {
1151 cxcoutWHF <<
"WARNING: Nominal Histogram " << histNominal->
GetName() <<
" for Sample = " << sample.GetName()
1152 <<
" in Channel = " <<
GetName() <<
" has negative entries in bin numbers = ";
1154 for (
unsigned int ibin = 0; ibin < NegativeBinNumber.size(); ++ibin) {
1157 std::cout << NegativeBinNumber[ibin] <<
" : " << NegativeBinContent[ibin];
1159 std::cout << std::endl;
1164 if (sample.GetStatError().GetUseHisto()) {
1165 if (sample.GetStatError().GetErrorHist() ==
nullptr) {
1166 cxcoutEHF <<
"Error: Statistical Error Histogram for sample " << sample.GetName() <<
" is nullptr."
1173 for (
const HistoSys &histoSys : sample.GetHistoSysList()) {
1175 if (histoSys.GetHistoLow() ==
nullptr) {
1176 cxcoutEHF <<
"Error: HistoSyst Low for Systematic " << histoSys.GetName() <<
" in sample "
1177 << sample.GetName() <<
" is nullptr." << std::endl;
1180 if (histoSys.GetHistoHigh() ==
nullptr) {
1181 cxcoutEHF <<
"Error: HistoSyst High for Systematic " << histoSys.GetName() <<
" in sample "
1182 << sample.GetName() <<
" is nullptr." << std::endl;
1189 for (
const HistoFactor &histoFactor : sample.GetHistoFactorList()) {
1191 if (histoFactor.GetHistoLow() ==
nullptr) {
1192 cxcoutEHF <<
"Error: HistoSyst Low for Systematic " << histoFactor.GetName() <<
" in sample "
1193 << sample.GetName() <<
" is nullptr." << std::endl;
1196 if (histoFactor.GetHistoHigh() ==
nullptr) {
1197 cxcoutEHF <<
"Error: HistoSyst High for Systematic " << histoFactor.GetName() <<
" in sample "
1198 << sample.GetName() <<
" is nullptr." << std::endl;
1205 for (
const ShapeSys &shapeSys : sample.GetShapeSysList()) {
1206 if (shapeSys.GetErrorHist() ==
nullptr) {
1207 cxcoutEHF <<
"Error: HistoSyst High for Systematic " << shapeSys.GetName() <<
" in sample "
1208 << sample.GetName() <<
" is nullptr." << std::endl;
1224 std::map<std::string, std::unique_ptr<TFile>> &lsof)
1227 cxcoutPHF <<
"Getting histogram " << InputFile <<
":" << HistoPath <<
"/" << HistoName << std::endl;
1229 auto &inFile = lsof[InputFile];
1230 if (!inFile || !inFile->IsOpen()) {
1232 if (!inFile || !inFile->IsOpen()) {
1233 cxcoutEHF <<
"Error: Unable to open input file: " << InputFile << std::endl;
1236 cxcoutIHF <<
"Opened input file: " << InputFile <<
": " << std::endl;
1240 if (dir ==
nullptr) {
1241 cxcoutEHF <<
"Histogram path '" << HistoPath <<
"' wasn't found in file '" << InputFile <<
"'." << std::endl;
1247 auto key = dir->
GetKey(HistoName.c_str());
1248 if (key ==
nullptr) {
1249 cxcoutEHF <<
"Histogram '" << HistoName <<
"' wasn't found in file '" << InputFile <<
"' in directory '"
1250 << HistoPath <<
"'." << std::endl;
1254 std::unique_ptr<TH1> hist(key->ReadObject<
TH1>());
1256 cxcoutEHF <<
"Histogram '" << HistoName <<
"' wasn't found in file '" << InputFile <<
"' in directory '"
1257 << HistoPath <<
"'." << std::endl;
1262 TH1 *ptr =
static_cast<TH1 *
>(hist->Clone());
1265 std::cerr <<
"Not all necessary info are set to access the input file. Check your config" << std::endl;
1266 std::cerr <<
"filename: " << InputFile <<
"path: " << HistoPath <<
"obj: " << HistoName << std::endl;
1271 std::cout <<
"Found Histogram: " << HistoName
" at address: " << ptr <<
" with integral " << ptr->
Integral()
1272 <<
" and mean " << ptr->
GetMean() << std::endl;
1284Data::Data(std::string HistoName, std::string InputFile, std::string HistoPath)
1303 <<
"\t HistoAddress: " <<
GetHisto() << std::endl;
1311 if (histData !=
nullptr) {
1327 xml <<
" <Data HistoName=\"" <<
GetHistoName() <<
"\" "
1331 xml <<
"Name=\"" <<
GetName() <<
"\" ";
1333 xml <<
" /> " << std::endl << std::endl;
1344std::string escapeXML(
const std::string &src)
1346 std::stringstream dst;
1347 for (
char ch : src) {
1349 case '&': dst <<
"&";
break;
1350 case '\'': dst <<
"'";
break;
1351 case '"': dst <<
""";
break;
1352 case '<': dst <<
"<";
break;
1353 case '>': dst <<
">";
break;
1354 default: dst << ch;
break;
1363 std::string
const &dependents)
1381 xml <<
"<Function Name=\"" <<
fName <<
"\" "
1382 <<
"Expression=\"" << escapeXML(
fExpression) <<
"\" "
1427 std::string param = itr->first;
1428 double val = itr->second;
1433 std::cout <<
"Error: Trying to set variable: " << var
1434 <<
" to a specific value in creation of asimov dataset: " <<
fName
1435 <<
" but this variable doesn't appear to exist in the workspace" << std::endl;
1440 double inRange = var->
inRange(val,
nullptr);
1442 std::cout <<
"Error: Attempting to set variable: " << var <<
" to value: " << val <<
", however it appears"
1443 <<
" that this is not withn the variable's range: "
1444 <<
"[" << var->
getMin() <<
", " << var->
getMax() <<
"]" << std::endl;
1449 std::cout <<
"Configuring Asimov Dataset: Setting " << param <<
" = " << val << std::endl;
1462 std::cout <<
"Error: Trying to set variable: " << var <<
" constant in creation of asimov dataset: " <<
fName
1463 <<
" but this variable doesn't appear to exist in the workspace" << std::endl;
1467 std::cout <<
"Configuring Asimov Dataset: Setting " << param <<
" to constant " << std::endl;
1504 fHist = std::move(other.fHist);
1516 return static_cast<TH1 *
>(
h->Clone());
1539 return fHist.release();
1557 std::cout <<
"Error: Given empty name for ConstraintType" << std::endl;
1561 else if (
Name ==
"Gaussian" ||
Name ==
"Gauss") {
1565 else if (
Name ==
"Poisson" ||
Name ==
"Pois") {
1570 std::cout <<
"Error: Unknown name given for Constraint Type: " <<
Name << std::endl;
1577 stream <<
"\t \t Name: " <<
fName <<
"\t Val: " <<
fVal <<
"\t Low: " <<
fLow <<
"\t High: " <<
fHigh << std::endl;
1582 xml <<
" <NormFactor Name=\"" <<
GetName() <<
"\" "
1583 <<
" Val=\"" <<
GetVal() <<
"\" "
1584 <<
" High=\"" <<
GetHigh() <<
"\" "
1585 <<
" Low=\"" <<
GetLow() <<
"\" "
1586 <<
" /> " << std::endl;
1591 stream <<
"\t \t Name: " <<
fName <<
"\t Low: " <<
fLow <<
"\t High: " <<
fHigh << std::endl;
1596 xml <<
" <OverallSys Name=\"" <<
GetName() <<
"\" "
1597 <<
" High=\"" <<
GetHigh() <<
"\" "
1598 <<
" Low=\"" <<
GetLow() <<
"\" "
1599 <<
" /> " << std::endl;
1629 if (histLow ==
nullptr) {
1630 std::cout <<
"Error: Cannot write " <<
GetName() <<
" to file: " << FileName <<
" HistoLow is nullptr"
1640 if (histHigh ==
nullptr) {
1641 std::cout <<
"Error: Cannot write " <<
GetName() <<
" to file: " << FileName <<
" HistoHigh is nullptr"
1653 xml <<
" <HistoSys Name=\"" <<
GetName() <<
"\" "
1661 <<
" /> " << std::endl;
1677 xml <<
" <ShapeSys Name=\"" <<
GetName() <<
"\" "
1682 <<
" /> " << std::endl;
1688 if (histError ==
nullptr) {
1689 std::cout <<
"Error: Cannot write " <<
GetName() <<
" to file: " << FileName <<
" ErrorHist is nullptr"
1701 xml <<
" <HistoFactor Name=\"" <<
GetName() <<
"\" "
1710 <<
" /> " << std::endl;
1721 stream <<
"\t \t Name: " <<
fName << std::endl;
1730 stream <<
"\t \t ( Constant ): " << std::endl;
1739 if (histInitialShape ==
nullptr) {
1740 std::cout <<
"Error: Cannot write " <<
GetName() <<
" to file: " << FileName <<
" InitialShape is nullptr"
1744 histInitialShape->Write();
1753 xml <<
" <ShapeFactor Name=\"" <<
GetName() <<
"\" ";
1759 xml <<
" /> " << std::endl;
1777 <<
"/> " << std::endl
1791 xml <<
" <StatError Activate=\"" << (
GetActivate() ? std::string(
"True") : std::string(
"False")) <<
"\" "
1795 <<
" /> " << std::endl;
1804 std::string statErrorHistName =
"statisticalErrors";
1807 if (hStatError ==
nullptr) {
1808 std::cout <<
"Error: Stat Error error hist is nullptr" << std::endl;
1811 hStatError->Write(statErrorHistName.c_str());
1831 fhLow->SetDirectory(
nullptr);
1833 fhHigh->SetDirectory(
nullptr);
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
void setConstant(bool value=true)
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
bool inRange(const char *name) const override
Check if current value is inside range with given name.
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
std::map< std::string, double > fParamValsToSet
void ConfigureWorkspace(RooWorkspace *)
std::map< std::string, bool > fParamsToFix
This class encapsulates all information for the statistical interpretation of one experiment.
std::vector< RooStats::HistFactory::Sample > fSamples
std::vector< RooStats::HistFactory::Data > fAdditionalData
One can add additional datasets These are simply added to the xml under a different name.
void Print(std::ostream &=std::cout)
HistFactory::StatErrorConfig fStatErrorConfig
void SetData(const RooStats::HistFactory::Data &data)
set data object
void AddSample(RooStats::HistFactory::Sample sample)
bool CheckHistograms() const
TH1 * GetHistogram(std::string InputFile, std::string HistoPath, std::string HistoName, std::map< std::string, std::unique_ptr< TFile > > &lsof)
Open a file and copy a histogram.
void SetStatErrorConfig(double RelErrorThreshold, Constraint::Type ConstraintType)
void PrintXML(std::string const &directory, std::string const &prefix="") const
std::string GetName() const
get name of channel
void Print(std::ostream &=std::cout)
std::string const & GetInputFile() const
void PrintXML(std::ostream &) const
void writeToFile(std::string FileName, std::string DirName)
std::string const & GetHistoName() const
std::string const & GetHistoPath() const
std::string const & GetName() const
HistRef(TH1 *h=nullptr)
constructor - use gives away ownerhip of the given pointer
HistRef & operator=(const HistRef &other)
assignment operator (delete previous contained histogram)
void SetObject(TH1 *h)
set the object - user gives away the ownerhisp
std::unique_ptr< TH1 > fHist
pointer to contained histogram
static TH1 * CopyObject(const TH1 *h)
TH1 * ReleaseObject()
Release ownership of object.
Configuration for an *un*constrained, coherent shape variation of affected samples.
void PrintXML(std::ostream &) const override
Configuration for a constrained, coherent shape variation of affected samples.
void PrintXML(std::ostream &) const override
////////////////////////////////////////////////////////////////////////////////////////////Base clas...
void SetInputFileHigh(const std::string &InputFileHigh)
std::unique_ptr< TH1 > fhHigh
void SetHistoHigh(TH1 *High)
void SetName(const std::string &Name)
std::string fHistoPathHigh
virtual void writeToFile(const std::string &FileName, const std::string &DirName)
std::string fInputFileLow
void SetHistoPathHigh(const std::string &HistoPathHigh)
HistogramUncertaintyBase()
std::string fHistoPathLow
const std::string & GetName() const
void SetInputFileLow(const std::string &InputFileLow)
const TH1 * GetHistoHigh() const
const std::string & GetHistoNameHigh() const
std::string fHistoNameLow
std::string fHistoNameHigh
const std::string & GetHistoNameLow() const
std::string fInputFileHigh
void SetHistoNameHigh(const std::string &HistoNameHigh)
void SetHistoNameLow(const std::string &HistoNameLow)
virtual void Print(std::ostream &=std::cout) const
HistogramUncertaintyBase & operator=(const HistogramUncertaintyBase &oth)
const std::string & GetHistoPathLow() const
const std::string & GetInputFileHigh() const
const std::string & GetInputFileLow() const
void SetHistoPathLow(const std::string &HistoPathLow)
void SetHistoLow(TH1 *Low)
std::unique_ptr< TH1 > fhLow
const std::string & GetHistoPathHigh() const
const TH1 * GetHistoLow() const
virtual ~HistogramUncertaintyBase()
void writeToFile(TFile *file)
A measurement, once fully configured, can be saved into a ROOT file.
std::map< std::string, double > fUniformSyst
std::string fOutputFilePrefix
Configurables of this measurement.
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.
std::map< std::string, double > fNoSyst
std::vector< RooStats::HistFactory::Channel > fChannels
Channels that make up this measurement.
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.
void SetParamValue(const std::string ¶m, double value)
Set a parameter to a specific value (And optionally fix it).
std::map< std::string, double > fGammaSyst
List of Alternate constraint terms.
std::map< std::string, double > fParamValues
Map of parameter names to initial values to be set.
void CollectHistograms()
The most common way to add histograms to channels is to have them stored in ROOT files and to give Hi...
std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects
List of Preprocess Function objects.
RooStats::HistFactory::Channel & GetChannel(std::string)
Get channel with given name from this measurement throws an exception in case the channel is not foun...
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.
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::map< std::string, double > fLogNormSyst
std::vector< std::string > fPOI
std::vector< std::string > fConstantParams
List of Parameters to be set constant.
Configuration for an un- constrained overall systematic to scale sample normalisations.
std::string GetName() const
void Print(std::ostream &=std::cout) const
void PrintXML(std::ostream &) const
void SetHigh(double High)
void SetName(const std::string &Name)
Configuration for a constrained overall systematic to scale sample normalisations.
void SetName(const std::string &Name)
const std::string & GetName() const
void PrintXML(std::ostream &) const
void SetHigh(double High)
void Print(std::ostream &=std::cout) const
void Print(std::ostream &=std::cout) const
std::string GetCommand() const
void PrintXML(std::ostream &) const
std::vector< RooStats::HistFactory::ShapeFactor > fShapeFactorList
std::unique_ptr< TH1 > fhCountingHist
void AddShapeSys(std::string Name, Constraint::Type ConstraintType, std::string HistoName, std::string HistoFile, std::string HistoPath="")
void AddOverallSys(std::string Name, double Low, double High)
void writeToFile(std::string FileName, std::string DirName)
const TH1 * GetHisto() const
void SetValue(double Val)
RooStats::HistFactory::StatError fStatError
Properties.
void SetChannelName(const std::string &ChannelName)
set name of associated channel
std::vector< RooStats::HistFactory::NormFactor > fNormFactorList
void AddNormFactor(std::string const &Name, double Val, double Low, double High)
Sample & operator=(const Sample &other)
std::string fChannelName
The Name of the parent channel.
std::vector< RooStats::HistFactory::OverallSys > fOverallSysList
void SetHisto(TH1 *histo)
void Print(std::ostream &=std::cout) const
std::vector< RooStats::HistFactory::HistoSys > fHistoSysList
RooStats::HistFactory::StatError & GetStatError()
void AddHistoFactor(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow, std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh)
std::vector< RooStats::HistFactory::ShapeFactor > & GetShapeFactorList()
std::vector< RooStats::HistFactory::HistoFactor > & GetHistoFactorList()
std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList()
std::vector< RooStats::HistFactory::HistoFactor > fHistoFactorList
std::vector< RooStats::HistFactory::ShapeSys > fShapeSysList
HistRef fhNominal
The Nominal Shape.
void AddShapeFactor(std::string Name)
std::vector< RooStats::HistFactory::ShapeSys > & GetShapeSysList()
void AddHistoSys(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow, std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh)
void PrintXML(std::ofstream &xml) const
*Un*constrained bin-by-bin variation of affected histogram.
void PrintXML(std::ostream &) const override
const std::string & GetHistoPath() const
const TH1 * GetInitialShape() const
void SetInitialShape(TH1 *shape)
void writeToFile(const std::string &FileName, const std::string &DirName) override
void Print(std::ostream &=std::cout) const override
const std::string & GetInputFile() const
bool HasInitialShape() const
const std::string & GetHistoName() const
Constrained bin-by-bin variation of affected histogram.
std::string GetHistoPath() const
void PrintXML(std::ostream &) const override
Constraint::Type GetConstraintType() const
const TH1 * GetErrorHist() const
std::string GetHistoName() const
void SetInputFile(const std::string &InputFile)
void writeToFile(const std::string &FileName, const std::string &DirName) override
void Print(std::ostream &=std::cout) const override
void SetHistoName(const std::string &HistoName)
void SetConstraintType(Constraint::Type ConstrType)
std::string GetInputFile() const
void SetErrorHist(TH1 *hError)
void SetHistoPath(const std::string &HistoPath)
double fRelErrorThreshold
void PrintXML(std::ostream &) const
Constraint::Type fConstraintType
double GetRelErrorThreshold() const
Constraint::Type GetConstraintType() const
void Print(std::ostream &=std::cout) const
const std::string & GetHistoPath() const
const TH1 * GetErrorHist() const
void SetErrorHist(TH1 *Error)
const std::string & GetInputFile() const
const std::string & GetHistoName() const
void Print(std::ostream &=std::cout) const override
void PrintXML(std::ostream &) const override
void writeToFile(const std::string &FileName, const std::string &DirName) override
Persistable container for RooFit projects.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
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/...".
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
virtual const char * GetPath() const
Returns the full path of the directory.
virtual Bool_t cd()
Change current directory to "this" directory.
virtual TKey * GetKey(const char *, Short_t=9999) const
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
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.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
virtual Double_t GetMean(Int_t axis=1) const
For axis = 1,2 or 3 returns the mean value of the histogram along X,Y or Z axis.
virtual Int_t GetNbinsX() const
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
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.
Type GetType(const std::string &Name)
std::string Name(Type type)