00001 #ifndef __TELECTRONEFFICIENCYCORRECTIONTOOL__
00002 #define __TELECTRONEFFICIENCYCORRECTIONTOOL__
00003
00018 #include <sstream>
00019
00020
00021 #include <vector>
00022 #include <string>
00023
00024
00025 #include <TString.h>
00026 #include "TKey.h"
00027 #include "TObjArray.h"
00028 #include "TH1.h"
00029 #include "TH2.h"
00030 #include "TRandom3.h"
00031
00032 #include "PATCore/TResult.h"
00033 #include "PATCore/TCalculatorToolBase.h"
00034 #include "PATCore/PATCoreEnums.h"
00035 #include "AsgTools/AsgMessaging.h"
00036
00037
00038 namespace Root {
00039 class TElectronEfficiencyCorrectionTool : public Root::TCalculatorToolBase,public asg::AsgMessaging
00040 {
00041
00042 public:
00044 TElectronEfficiencyCorrectionTool( const char* name="TElectronEfficiencyCorrectionTool" );
00045
00047 ~TElectronEfficiencyCorrectionTool();
00048
00049
00051 int initialize();
00052
00054 inline int finalize() { return 1; }
00055
00057 const Root::TResult& calculate( const PATCore::ParticleDataType::DataType dataType,
00058 const unsigned int runnumber,
00059 const double cluster_eta,
00060 const double et
00061 );
00062
00063
00065 inline void addFileName ( const std::string& val )
00066 { m_corrFileNameList.push_back(val); }
00067
00069 inline void setResultPrefix ( const std::string& val ) { m_resultPrefix = val; }
00070
00072 inline void setResultName ( const std::string& val ) { m_resultName = val; }
00073
00074 inline void bookToyMCScaleFactors(const int nToyMC) {
00075 m_doToyMC = kTRUE;
00076 m_nToyMC = nToyMC;
00077 }
00078
00079 inline void bookCombToyMCScaleFactors(const int nToyMC) {
00080 m_doCombToyMC = kTRUE;
00081 m_nToyMC = nToyMC;
00082 }
00083
00085 int getFirstToyMCPosition();
00086 int getLastToyMCPosition();
00087 int getFirstCorrSysPosition();
00088 int getLastCorrSysPosition();
00089 int getGlobalBinNumberPosition();
00090 int getNbins(std::map<float, std::vector<float> >&);
00091 int getNSyst() {return m_nSysMax;};
00092
00093 void printResultMap();
00094
00095 enum detailLevel{simple,medium,detailed};
00096
00098 inline void setDetailLevel ( const int input_detailLevel ) { m_detailLevel = input_detailLevel; }
00099
00100 inline void setSeed( const int seed) { m_seed = seed; }
00101
00103 inline const char* getName() const { return m_name; }
00104
00105
00106 private:
00108 int getHistograms();
00109 int getHistogramInDirectory( TKey *key );
00110 int setupHistogramsInFolder( const TObjArray& dirNameArray, int lastIdx );
00111
00112 void calcDetailLevels(TH1D *eig) ;
00113
00114 std::vector<TObjArray> buildToyMCTable (const TObjArray &sf, const TObjArray &eig,
00115 const TObjArray& stat, const TObjArray& uncorr, const std::vector<TObjArray> &corr);
00116
00117 std::vector<TH2D*> buildSingleToyMC(TH2D *sf, TH2D* stat, TH2D* uncorr, const TObjArray& corr);
00118
00119 TH2D* buildSingleCombToyMC(TH2D *sf, TH2D* stat, TH2D* uncorr, const TObjArray& corr);
00120
00122 int setup( const TObjArray& hist,
00123 std::vector< TObjArray >& histList,
00124 std::vector< unsigned int >& beginRunNumberList,
00125 std::vector< unsigned int >& endRunNumberList );
00126
00127 int setupSys( std::vector<TObjArray> & hist,
00128 std::vector< std::vector< TObjArray>> & histList);
00129
00130 void printDefaultReturnMessage(TString reason, int line);
00131
00132 TRandom3 m_Rndm;
00133 int m_randomCounter;
00134 bool m_isInitialized;
00136 int m_detailLevel;
00137 int m_toyMCSF;
00138
00140 int m_seed;
00141 bool m_doToyMC;
00142 bool m_doCombToyMC;
00143 int m_nToyMC;
00144 int m_sLevel[3];
00145 int m_nSys;
00146 int m_nSysMax;
00147 int m_runNumBegin;
00148 int m_runNumEnd;
00149
00151 std::string m_resultPrefix;
00152
00154 std::string m_resultName;
00155
00157 int m_position_eff;
00158
00160 int m_position_err;
00161
00163 int m_position_statErr;
00164
00166 int m_position_nSys;
00167
00169 int m_position_uncorrSys;
00170
00172 int m_nbins;
00173
00174 int m_nSimpleUncorrSyst;
00175
00177 int m_position_globalBinNumber;
00178
00179
00180
00181 std::vector< std::vector<TObjArray>> m_uncorrToyMCSystFull;
00182 std::vector< std::vector<TObjArray>> m_uncorrToyMCSystFast;
00184 std::vector< std::string > m_corrFileNameList;
00186 std::vector< unsigned int > m_begRunNumberList;
00188 std::vector< unsigned int > m_endRunNumberList;
00190 std::vector< unsigned int > m_begRunNumberListFastSim;
00192 std::vector< unsigned int > m_endRunNumberListFastSim;
00194 std::map<int, std::vector< TObjArray > > m_histList;
00195 std::vector< std::vector< TObjArray > > m_sysList;
00197 std::map<int, std::vector< TObjArray > > m_fastHistList;
00198 std::vector< std::vector< TObjArray > > m_fastSysList;
00200 std::vector<int> m_position_corrSys;
00202 std::vector<int> m_position_uncorrToyMCSF;
00204 std::vector<int> m_keys;
00205
00206 };
00207
00208 }
00209
00210 #endif
00211