43 namespace HistFactory{
55 sample.SetChannelName( GetName() );
56 fSamples.push_back(
sample );
62 stream <<
"\t Channel Name: " << fName
63 <<
"\t InputFile: " << fInputFile
66 stream <<
"\t Data:" << std::endl;
67 fData.Print( stream );
70 stream <<
"\t statErrorConfig:" << std::endl;
71 fStatErrorConfig.Print( stream );
74 if( !fSamples.empty() ) {
76 stream <<
"\t Samples: " << std::endl;
77 for(
unsigned int i = 0; i < fSamples.size(); ++i ) {
78 fSamples.at(i).Print( stream );
83 stream <<
"\t End of Channel " << fName << std::endl;
92 cxcoutPHF <<
"Printing XML Files for channel: " << GetName() << std::endl;
94 std::string
XMLName = prefix + fName +
".xml";
100 xml <<
"<!--" << std::endl;
101 xml <<
"This xml file created automatically on: " << std::endl;
112 xml <<
"-->" << std::endl;
115 xml <<
"<!DOCTYPE Channel SYSTEM 'HistFactorySchema.dtd'> " << std::endl << std::endl;
118 xml <<
" <Channel Name=\"" << fName <<
"\" InputFile=\"" << fInputFile <<
"\" >" << std::endl << std::endl;
120 fData.PrintXML(
xml );
121 for(
auto const&
data : fAdditionalData) {
125 fStatErrorConfig.PrintXML(
xml );
132 for(
auto const&
sample : fSamples) {
134 xml << std::endl << std::endl;
138 xml <<
" </Channel> " << std::endl;
141 cxcoutPHF <<
"Finished printing XML files" << std::endl;
160 fData.SetHisto(
hData );
174 hData->SetBinContent( 1, val );
205 std::map<std::string,std::unique_ptr<TFile>>
fileHandles;
209 if( !fData.GetInputFile().empty() ) {
210 fData.SetHisto( GetHistogram(fData.GetInputFile(),
211 fData.GetHistoPath(),
212 fData.GetHistoName(),
217 for(
auto&
data : fAdditionalData) {
218 if( !
data.GetInputFile().empty() ) {
230 cxcoutDHF <<
"Collecting Nominal Histogram" << std::endl;
240 if(
sample.GetStatError().GetUseHisto() ) {
241 sample.GetStatError().SetErrorHist( GetHistogram(
sample.GetStatError().GetInputFile(),
242 sample.GetStatError().GetHistoPath(),
243 sample.GetStatError().GetHistoName(),
317 if( fData.GetHisto() ==
nullptr && !fData.GetInputFile().empty() ) {
318 cxcoutEHF <<
"Error: Data Histogram for channel " << GetName() <<
" is nullptr." << std::endl;
328 if(
sample.GetHisto() ==
nullptr ) {
329 cxcoutEHF <<
"Error: Nominal Histogram for sample " <<
sample.GetName() <<
" is nullptr." << std::endl;
346 <<
" in Channel = " << GetName() <<
" has negative entries in bin numbers = ";
349 if(
ibin>0) std::cout <<
" , " ;
352 std::cout << std::endl;
358 if(
sample.GetStatError().GetUseHisto() ) {
359 if(
sample.GetStatError().GetErrorHist() ==
nullptr ) {
360 cxcoutEHF <<
"Error: Statistical Error Histogram for sample " <<
sample.GetName() <<
" is nullptr." << std::endl;
371 if(
histoSys.GetHistoLow() ==
nullptr ) {
373 <<
" in sample " <<
sample.GetName() <<
" is nullptr." << std::endl;
376 if(
histoSys.GetHistoHigh() ==
nullptr ) {
378 <<
" in sample " <<
sample.GetName() <<
" is nullptr." << std::endl;
392 <<
" in sample " <<
sample.GetName() <<
" is nullptr." << std::endl;
397 <<
" in sample " <<
sample.GetName() <<
" is nullptr." << std::endl;
409 if(
shapeSys.GetErrorHist() ==
nullptr ) {
411 <<
" in sample " <<
sample.GetName() <<
" is nullptr." << std::endl;
444 if (dir ==
nullptr) {
446 <<
"' wasn't found in file '" <<
InputFile <<
"'." << std::endl;
453 if (key ==
nullptr) {
455 <<
"' wasn't found in file '" <<
InputFile
456 <<
"' in directory '" <<
HistoPath <<
"'." << std::endl;
460 std::unique_ptr<TH1> hist(key->ReadObject<
TH1>());
463 <<
"' wasn't found in file '" <<
InputFile
464 <<
"' in directory '" <<
HistoPath <<
"'." << std::endl;
469 TH1 * ptr =
static_cast<TH1 *
>(hist->Clone());
472 std::cerr <<
"Not all necessary info are set to access the input file. Check your config" << std::endl;
480 std::cout <<
"Found Histogram: " <<
HistoName " at address: " << ptr
481 <<
" with integral " << ptr->
Integral() <<
" and mean " << ptr->
GetMean()
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 data
This class encapsulates all information for the statistical interpretation of one experiment.
void Print(std::ostream &=std::cout)
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
Configuration for an *un*constrained, coherent shape variation of affected samples.
Configuration for a constrained, coherent shape variation of affected samples.
*Un*constrained bin-by-bin variation of affected histogram.
Constrained bin-by-bin variation of affected histogram.
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
virtual TKey * GetKey(const char *, Short_t=9999) const
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 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 Double_t Integral(Option_t *option="") const
Return integral of bin contents.
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)
Namespace for the RooStats classes.