Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-18 10:35:17

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_MEASUREMENT_H
0012 #define HISTFACTORY_MEASUREMENT_H
0013 
0014 #include <string>
0015 #include <map>
0016 #include <fstream>
0017 #include <iostream>
0018 #include <vector>
0019 
0020 #include "TNamed.h"
0021 
0022 #include "PreprocessFunction.h"
0023 #include "RooStats/HistFactory/Channel.h"
0024 #include "RooStats/HistFactory/Asimov.h"
0025 
0026 class TFile;
0027 
0028 namespace RooStats{
0029 namespace HistFactory {
0030 
0031 class Measurement : public TNamed {
0032 
0033 public:
0034 
0035   Measurement();
0036   ///  Measurement( const Measurement& other ); // Copy
0037   Measurement(const char* Name, const char* Title="");
0038 
0039   ///  set output prefix
0040   void SetOutputFilePrefix( const std::string& prefix ) { fOutputFilePrefix = prefix; }
0041   /// retrieve prefix for output files
0042   std::string GetOutputFilePrefix() { return fOutputFilePrefix; }
0043 
0044   /// insert PoI at beginning of vector of PoIs
0045   void SetPOI( const std::string& POI ) { fPOI.insert( fPOI.begin(), POI ); }
0046   /// append parameter to vector of PoIs
0047   void AddPOI( const std::string& POI ) { fPOI.push_back(POI); }
0048   /// get name of PoI at given index
0049   std::string GetPOI(unsigned int i=0) { return fPOI.at(i); }
0050   /// get vector of PoI names
0051   std::vector<std::string>& GetPOIList() { return fPOI; }
0052 
0053 
0054   /// Add a parameter to be set as constant
0055   /// (Similar to ParamSetting method below)
0056   void AddConstantParam( const std::string& param );
0057   /// empty vector of constant parameters
0058   void ClearConstantParams() { fConstantParams.clear(); }
0059   /// get vector of all constant parameters
0060   std::vector< std::string >& GetConstantParams() { return fConstantParams; }
0061 
0062   /// Set a parameter to a specific value
0063   /// (And optionally fix it)
0064   void SetParamValue( const std::string& param, double value);
0065   /// get map: parameter name <--> parameter value
0066   std::map<std::string, double>& GetParamValues() { return fParamValues; }
0067   /// clear map of parameter values
0068   void ClearParamValues() { fParamValues.clear(); }
0069 
0070   void AddPreprocessFunction( std::string name, std::string expression, std::string dependencies );
0071   /// add a preprocess function object
0072   void AddFunctionObject( const RooStats::HistFactory::PreprocessFunction function) { fFunctionObjects.push_back( function ); }
0073   void SetFunctionObjects( std::vector< RooStats::HistFactory::PreprocessFunction > objects ) { fFunctionObjects = objects; }
0074   /// get vector of defined function objects
0075   std::vector< RooStats::HistFactory::PreprocessFunction >& GetFunctionObjects() { return fFunctionObjects; }
0076   const std::vector< RooStats::HistFactory::PreprocessFunction >& GetFunctionObjects() const { return fFunctionObjects; }
0077   std::vector< std::string > GetPreprocessFunctions() const;
0078 
0079   /// get vector of defined Asimov Datasets
0080   std::vector< RooStats::HistFactory::Asimov >& GetAsimovDatasets() { return fAsimovDatasets; }
0081   /// add an Asimov Dataset
0082   void AddAsimovDataset( RooStats::HistFactory::Asimov dataset ) { fAsimovDatasets.push_back(dataset); }
0083 
0084   /// set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
0085   void SetLumi(double Lumi ) { fLumi = Lumi; }
0086   /// set relative uncertainty on luminosity
0087   void SetLumiRelErr( double RelErr ) { fLumiRelErr = RelErr; }
0088   /// retrieve integrated luminosity
0089   double GetLumi() { return fLumi; }
0090   /// retrieve relative uncertainty on luminosity
0091   double GetLumiRelErr() { return fLumiRelErr; }
0092 
0093   void SetBinLow( int BinLow ) { fBinLow = BinLow; }
0094   void SetBinHigh ( int BinHigh ) { fBinHigh = BinHigh; }
0095   int GetBinLow() { return fBinLow; }
0096   int GetBinHigh() { return fBinHigh; }
0097 
0098   void PrintTree( std::ostream& = std::cout ); /// Print to a stream
0099   void PrintXML( std::string Directory="", std::string NewOutputPrefix="" );
0100 
0101   std::vector< RooStats::HistFactory::Channel >& GetChannels() { return fChannels; }
0102   const std::vector< RooStats::HistFactory::Channel >& GetChannels() const { return fChannels; }
0103   RooStats::HistFactory::Channel& GetChannel( std::string );
0104   /// add a completely configured channel
0105   void AddChannel( RooStats::HistFactory::Channel chan ) { fChannels.push_back( chan ); }
0106 
0107   bool HasChannel( std::string );
0108   void writeToFile( TFile* file );
0109 
0110   void CollectHistograms();
0111 
0112 
0113   void AddGammaSyst(std::string syst, double uncert);
0114   void AddLogNormSyst(std::string syst, double uncert);
0115   void AddUniformSyst(std::string syst);
0116   void AddNoSyst(std::string syst);
0117 
0118   std::map< std::string, double >& GetGammaSyst() { return fGammaSyst; }
0119   std::map< std::string, double >& GetUniformSyst() { return fUniformSyst; }
0120   std::map< std::string, double >& GetLogNormSyst() { return fLogNormSyst; }
0121   std::map< std::string, double >& GetNoSyst() { return fNoSyst; }
0122 
0123   std::map< std::string, double > const& GetGammaSyst() const { return fGammaSyst; }
0124   std::map< std::string, double > const& GetUniformSyst() const { return fUniformSyst; }
0125   std::map< std::string, double > const& GetLogNormSyst() const { return fLogNormSyst; }
0126   std::map< std::string, double > const& GetNoSyst() const { return fNoSyst; }
0127 
0128   std::string GetInterpolationScheme() { return fInterpolationScheme; }
0129 
0130 private:
0131 
0132   /// Configurables of this measurement
0133   std::string fOutputFilePrefix;
0134   std::vector<std::string> fPOI;
0135   double fLumi;
0136   double fLumiRelErr;
0137   int fBinLow;
0138   int fBinHigh;
0139   bool fExportOnly = true;
0140   std::string fInterpolationScheme;
0141 
0142   /// Channels that make up this measurement
0143   std::vector< RooStats::HistFactory::Channel > fChannels;
0144 
0145   /// List of Parameters to be set constant
0146   std::vector< std::string > fConstantParams;
0147 
0148   /// Map of parameter names to initial values to be set
0149   std::map< std::string, double > fParamValues;
0150 
0151   /// List of Preprocess Function objects
0152   std::vector< RooStats::HistFactory::PreprocessFunction > fFunctionObjects;
0153 
0154   /// List of Asimov datasets to generate
0155   std::vector< RooStats::HistFactory::Asimov > fAsimovDatasets;
0156 
0157   /// List of Alternate constraint terms
0158   std::map< std::string, double > fGammaSyst;
0159   std::map< std::string, double > fUniformSyst;
0160   std::map< std::string, double > fLogNormSyst;
0161   std::map< std::string, double > fNoSyst;
0162 
0163   std::string GetDirPath( TDirectory* dir );
0164 
0165   ClassDefOverride(RooStats::HistFactory::Measurement, 3);
0166 
0167 };
0168 
0169 } // namespace HistFactory
0170 } // namespace RooStats
0171 
0172 #endif