Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:29:43

0001 // @(#)root/roostats:$Id$
0002 // Author: George Lewis, Kyle Cranmer
0003 /*************************************************************************
0004  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef HISTFACTORY_CHANNEL_H
0012 #define HISTFACTORY_CHANNEL_H
0013 
0014 #include "RooStats/HistFactory/Data.h"
0015 #include "RooStats/HistFactory/Sample.h"
0016 #include "RooStats/HistFactory/Systematics.h"
0017 
0018 #include <string>
0019 #include <fstream>
0020 #include <iostream>
0021 #include <map>
0022 #include <memory>
0023 #include <vector>
0024 
0025 class TFile;
0026 
0027 namespace RooStats{
0028 namespace HistFactory {
0029 
0030 class Channel  {
0031 
0032 
0033 public:
0034   friend class Measurement;
0035 
0036   Channel() = default;
0037   Channel(std::string Name, std::string InputFile="");
0038 
0039   /// set name of channel
0040   void SetName( const std::string& Name ) { fName = Name; }
0041   /// get name of channel
0042   std::string GetName() const { return fName; }
0043   /// set name of input file containing histograms
0044   void SetInputFile( const std::string& file ) { fInputFile = file; }
0045   /// get name of input file
0046   std::string GetInputFile() const { return fInputFile; }
0047   /// set path for histograms in input file
0048   void SetHistoPath( const std::string& file ) { fHistoPath = file; }
0049   /// get path to histograms in input file
0050   std::string GetHistoPath() const { return fHistoPath; }
0051 
0052   /// set data object
0053   void SetData( const RooStats::HistFactory::Data& data ) { fData = data; }
0054   void SetData( std::string HistoName, std::string InputFile, std::string HistoPath="" );
0055   void SetData( double Val );
0056   void SetData( TH1* hData );
0057   /// get data object
0058   RooStats::HistFactory::Data& GetData() { return fData; }
0059   const RooStats::HistFactory::Data& GetData() const { return fData; }
0060 
0061   /// add additional data object
0062   void AddAdditionalData( const RooStats::HistFactory::Data& data ) { fAdditionalData.push_back(data); }
0063   /// retrieve vector of additional data objects
0064   std::vector<RooStats::HistFactory::Data>& GetAdditionalData() { return fAdditionalData; }
0065 
0066   void SetStatErrorConfig( double RelErrorThreshold, Constraint::Type ConstraintType );
0067   void SetStatErrorConfig( double RelErrorThreshold, std::string ConstraintType );
0068   /// define treatment of statistical uncertainties
0069   void SetStatErrorConfig( RooStats::HistFactory::StatErrorConfig Config ) { fStatErrorConfig = Config; }
0070   /// get information about threshold for statistical uncertainties and constraint term
0071   HistFactory::StatErrorConfig& GetStatErrorConfig() { return fStatErrorConfig; }
0072   const HistFactory::StatErrorConfig& GetStatErrorConfig() const { return fStatErrorConfig; }
0073 
0074   void AddSample( RooStats::HistFactory::Sample sample );
0075   /// get vector of samples for this channel
0076   std::vector< RooStats::HistFactory::Sample >& GetSamples() { return fSamples; }
0077   const std::vector< RooStats::HistFactory::Sample >& GetSamples() const { return fSamples; }
0078 
0079   void Print(std::ostream& = std::cout);
0080   void PrintXML( std::string const& directory, std::string const& prefix="" ) const;
0081 
0082   void CollectHistograms();
0083   bool CheckHistograms() const;
0084 
0085 protected:
0086 
0087   std::string fName;
0088   std::string fInputFile;
0089   std::string fHistoPath;
0090 
0091   HistFactory::Data fData;
0092 
0093   /// One can add additional datasets
0094   /// These are simply added to the xml under a different name
0095   std::vector<RooStats::HistFactory::Data> fAdditionalData;
0096 
0097   HistFactory::StatErrorConfig fStatErrorConfig;
0098 
0099   std::vector< RooStats::HistFactory::Sample > fSamples;
0100 
0101   TH1* GetHistogram( std::string InputFile, std::string HistoPath, std::string HistoName, std::map<std::string, std::unique_ptr<TFile>>& lsof);
0102 };
0103 
0104   extern Channel BadChannel;
0105 
0106 } // namespace HistFactory
0107 } // namespace RooStats
0108 
0109 #endif