43  fInputFile( other.fInputFile ),
 
   44  fHistoPath( other.fHistoPath ),
 
   46  fAdditionalData( other.fAdditionalData ),
 
   47  fStatErrorConfig( other.fStatErrorConfig ),
 
   48  fSamples( other.fSamples )
 
   53  fName( ChanName ), fInputFile( ChanInputFile )
 
   59  namespace HistFactory{
 
   72  fSamples.push_back( sample );
 
   78  stream << 
"\t Channel Name: " << fName
 
   79    << 
"\t InputFile: " << fInputFile
 
   82  stream << 
"\t Data:" << std::endl;
 
   83  fData.Print( stream );
 
   86  stream << 
"\t statErrorConfig:" << std::endl;
 
   87  fStatErrorConfig.Print( stream );
 
   90  if( !fSamples.empty() ) {
 
   92    stream << 
"\t Samples: " << std::endl;
 
   93    for( 
unsigned int i = 0; i < fSamples.size(); ++i ) {
 
   94      fSamples.at(i).Print( stream );
 
   99  stream << 
"\t End of Channel " << fName <<  std::endl;
 
  108  cxcoutPHF << 
"Printing XML Files for channel: " << GetName() << std::endl;
 
  110  std::string XMLName = prefix + fName + 
".xml";
 
  111  if(!directory.empty()) XMLName = directory + 
"/" + XMLName;
 
  113  ofstream xml( XMLName.c_str() );
 
  116  xml << 
"<!--" << std::endl;
 
  117  xml << 
"This xml file created automatically on: " << std::endl;
 
  123  t.
GetDate(
true, 0, &year, &month, &day);
 
  128  xml << 
"-->" << std::endl;
 
  131  xml << 
"<!DOCTYPE Channel  SYSTEM 'HistFactorySchema.dtd'>  " << std::endl << std::endl;
 
  134  xml << 
"  <Channel Name=\"" << fName << 
"\" InputFile=\"" << fInputFile << 
"\" >" << std::endl << std::endl;
 
  136  fData.PrintXML( xml );
 
  137  for(
auto const& 
data : fAdditionalData) {
 
  141  fStatErrorConfig.PrintXML( xml );
 
  148  for(
auto const& sample : fSamples) {
 
  149    sample.PrintXML( xml );
 
  150    xml << std::endl << std::endl;
 
  154  xml << 
"  </Channel>  " << std::endl;
 
  157  cxcoutPHF << 
"Finished printing XML files" << std::endl;
 
  166  fData.SetHistoName( DataHistoName );
 
  167  fData.SetInputFile( DataInputFile );
 
  168  fData.SetHistoPath( DataHistoPath );
 
  176  fData.SetHisto( hData );
 
  186  std::string DataHistName = fName + 
"_data";
 
  189  TH1F* hData = 
new TH1F( DataHistName.c_str(), DataHistName.c_str(), 1, 0, 1 );
 
  201  fStatErrorConfig.SetRelErrorThreshold( StatRelErrorThreshold );
 
  202  fStatErrorConfig.SetConstraintType( StatConstraintType );
 
  208  fStatErrorConfig.SetRelErrorThreshold( StatRelErrorThreshold );
 
  221  std::map<std::string,std::unique_ptr<TFile>> fileHandles;
 
  225  if( fData.GetInputFile() != 
"" ) {
 
  226    fData.SetHisto( GetHistogram(fData.GetInputFile(),
 
  227             fData.GetHistoPath(),
 
  228             fData.GetHistoName(),
 
  233  for(
auto& 
data : fAdditionalData) {
 
  234    if( 
data.GetInputFile() != 
"" ) {
 
  235      data.SetHisto( GetHistogram(
data.GetInputFile(), 
data.GetHistoPath(), 
data.GetHistoName(), fileHandles) );
 
  240  for( 
unsigned int sampItr = 0; sampItr < fSamples.size(); ++sampItr ) {
 
  246    cxcoutDHF << 
"Collecting Nominal Histogram" << std::endl;
 
  265    for( 
unsigned int histoSysItr = 0; histoSysItr < sample.
GetHistoSysList().
size(); ++histoSysItr ) {
 
  282    for( 
unsigned int histoFactorItr = 0; histoFactorItr < sample.
GetHistoFactorList().
size(); ++histoFactorItr ) {
 
  299    for( 
unsigned int shapeSysItr = 0; shapeSysItr < sample.
GetShapeSysList().
size(); ++shapeSysItr ) {
 
  311    for( 
unsigned int shapeFactorItr = 0; shapeFactorItr < sample.
GetShapeFactorList().
size(); ++shapeFactorItr ) {
 
  335    if( fData.GetHisto() == 
nullptr && fData.GetInputFile() != 
"" ) {
 
  336      cxcoutEHF << 
"Error: Data Histogram for channel " << GetName() << 
" is nullptr." << std::endl;
 
  341    for( 
unsigned int sampItr = 0; sampItr < fSamples.size(); ++sampItr ) {
 
  346      if( sample.
GetHisto() == 
nullptr ) {
 
  347   cxcoutEHF << 
"Error: Nominal Histogram for sample " << sample.
GetName() << 
" is nullptr." << std::endl;
 
  353   std::vector<int> NegativeBinNumber;
 
  354   std::vector<double> NegativeBinContent;
 
  356   for(
int ibin=1; ibin<=histNominal->
GetNbinsX(); ++ibin) {
 
  358       NegativeBinNumber.push_back(ibin);
 
  359       NegativeBinContent.push_back(histNominal->
GetBinContent(ibin));
 
  362   if(NegativeBinNumber.size()>0) {
 
  364          << 
" in Channel = " << GetName() << 
" has negative entries in bin numbers = ";
 
  366     for(
unsigned int ibin=0; ibin<NegativeBinNumber.size(); ++ibin) {
 
  367       if(ibin>0) std::cout << 
" , " ;
 
  368       std::cout << NegativeBinNumber[ibin] << 
" : " << NegativeBinContent[ibin] ;
 
  370     std::cout << std::endl;
 
  378     cxcoutEHF << 
"Error: Statistical Error Histogram for sample " << sample.
GetName() << 
" is nullptr." << std::endl;
 
  385      for( 
unsigned int histoSysItr = 0; histoSysItr < sample.
GetHistoSysList().
size(); ++histoSysItr ) {
 
  391          << 
" in sample " << sample.
GetName() << 
" is nullptr." << std::endl;
 
  396          << 
" in sample " << sample.
GetName() << 
" is nullptr." << std::endl;
 
  404      for( 
unsigned int histoFactorItr = 0; histoFactorItr < sample.
GetHistoFactorList().
size(); ++histoFactorItr ) {
 
  409     cxcoutEHF << 
"Error: HistoSyst Low for Systematic " << histoFactor.
GetName()
 
  410          << 
" in sample " << sample.
GetName() << 
" is nullptr." << std::endl;
 
  414     cxcoutEHF << 
"Error: HistoSyst High for Systematic " << histoFactor.
GetName()
 
  415          << 
" in sample " << sample.
GetName() << 
" is nullptr." << std::endl;
 
  423      for( 
unsigned int shapeSysItr = 0; shapeSysItr < sample.
GetShapeSysList().
size(); ++shapeSysItr ) {
 
  429          << 
" in sample " << sample.
GetName() << 
" is nullptr." << std::endl;
 
  438  catch(std::exception& 
e)
 
  440      std::cout << 
e.what() << std::endl;
 
  460  cxcoutPHF << 
"Getting histogram " << InputFile << 
":" << HistoPath << 
"/" << HistoName << std::endl;
 
  462  auto& inFile = lsof[InputFile];
 
  463  if (!inFile || !inFile->IsOpen()) {
 
  465    if ( !inFile || !inFile->IsOpen() ) {
 
  466      cxcoutEHF << 
"Error: Unable to open input file: " << InputFile << std::endl;
 
  469    cxcoutIHF << 
"Opened input file: " << InputFile << 
": " << std::endl;
 
  473  if (dir == 
nullptr) {
 
  474    cxcoutEHF << 
"Histogram path '" << HistoPath
 
  475        << 
"' wasn't found in file '" << InputFile << 
"'." << std::endl;
 
  481  auto key = dir->
GetKey(HistoName.c_str());
 
  482  if (key == 
nullptr) {
 
  484        << 
"' wasn't found in file '" << InputFile
 
  485        << 
"' in directory '" << HistoPath << 
"'." << std::endl;
 
  489  auto hist = 
dynamic_cast<TH1*
>(key->ReadObj());
 
  492        << 
"' wasn't found in file '" << InputFile
 
  493        << 
"' in directory '" << HistoPath << 
"'." << std::endl;
 
  501    std::cerr << 
"Not all necessary info are set to access the input file. Check your config" << std::endl;
 
  502    std::cerr << 
"filename: " << InputFile
 
  503         << 
"path: " << HistoPath
 
  504         << 
"obj: " << HistoName << std::endl;
 
  512  std::cout << 
"Found Histogram: " << HistoName 
" at address: " << ptr
 
  513       << 
" with integral "   << ptr->
Integral() << 
" and mean " << ptr->
GetMean()
 
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 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.
 
void SetHistoHigh(TH1 *High)
 
const std::string & GetName() const
 
const TH1 * GetHistoHigh() const
 
const std::string & GetHistoNameHigh() const
 
const std::string & GetHistoNameLow() const
 
const std::string & GetHistoPathLow() const
 
const std::string & GetInputFileHigh() const
 
const std::string & GetInputFileLow() const
 
void SetHistoLow(TH1 *Low)
 
const std::string & GetHistoPathHigh() const
 
const TH1 * GetHistoLow() const
 
std::string GetHistoName() const
get histogram name
 
std::string GetName() const
get name of sample
 
const TH1 * GetHisto() const
 
void SetChannelName(const std::string &ChannelName)
set name of associated channel
 
void SetHisto(TH1 *histo)
 
std::string GetHistoPath() const
get histogram path
 
RooStats::HistFactory::StatError & GetStatError()
 
std::vector< RooStats::HistFactory::ShapeFactor > & GetShapeFactorList()
 
std::vector< RooStats::HistFactory::HistoFactor > & GetHistoFactorList()
 
std::string GetInputFile() const
get input ROOT file
 
std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList()
 
std::vector< RooStats::HistFactory::ShapeSys > & GetShapeSysList()
 
*Un*constrained bin-by-bin variation of affected histogram.
 
const std::string & GetHistoPath() const
 
void SetInitialShape(TH1 *shape)
 
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
 
const TH1 * GetErrorHist() const
 
std::string GetHistoName() const
 
std::string GetInputFile() const
 
void SetErrorHist(TH1 *hError)
 
const std::string & GetHistoPath() const
 
const TH1 * GetErrorHist() const
 
void SetErrorHist(TH1 *Error)
 
const std::string & GetInputFile() const
 
const std::string & GetHistoName() const
 
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 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 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.
 
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
 
const char * GetName() const override
Returns name of object.
 
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.