00001
00002
00003
00004
00005
00006
00007
00008 #ifndef EFFICIENCYSCALEFACTOR_H_
00009 #define EFFICIENCYSCALEFACTOR_H_
00010
00011
00012 #include "xAODMuon/Muon.h"
00013
00014 #ifdef ROOTCORE
00015 # include "xAODRootAccess/Init.h"
00016 # include "xAODRootAccess/TEvent.h"
00017 #endif // ROOTCORE
00018
00019
00020 #include "xAODEventInfo/EventInfo.h"
00021 #include "xAODMuon/MuonContainer.h"
00022
00023 #include <PATInterfaces/CorrectionCode.h>
00024 #include <MuonEfficiencyCorrections/HistHandler.h>
00025 #include <MuonEfficiencyCorrections/MuonEfficiencyType.h>
00026 #include <MuonEfficiencyCorrections/KinematicSystHandler.h>
00027 #include <PATInterfaces/ISystematicsTool.h>
00028
00029
00030 #include <TFile.h>
00031 #include <TDirectory.h>
00032
00033
00034 #include <string>
00035 #include <iostream>
00036 #include <exception>
00037 #include <map>
00038 #include <cmath>
00039
00040 namespace CP {
00041 class SystematicSet;
00042 class EfficiencyScaleFactor {
00043
00050
00051 public:
00052
00054 EfficiencyScaleFactor();
00056 EfficiencyScaleFactor(std::string file, std::string time_unit, SystematicSet sys, CP::MuonEfficiencyType effType, bool is_lowpt = false, bool hasPtDepSys = false);
00057
00058 EfficiencyScaleFactor(const EfficiencyScaleFactor & other);
00059 EfficiencyScaleFactor & operator =(const EfficiencyScaleFactor & other);
00060
00062 bool ReadFromFile(std::string file, std::string time_unit);
00063 HistHandler* ReadHistFromFile(std::string name, TFile* f, std::string time_unit);
00064
00065
00066 void ApplySysVariation();
00067
00069 bool CheckConsistency();
00070
00072
00074 CorrectionCode ScaleFactor(const xAOD::Muon& mu, float & SF);
00075 CorrectionCode ScaleFactorReplicas(const xAOD::Muon& mu, std::vector<float> & SF);
00076
00078 CorrectionCode DataEfficiency(const xAOD::Muon& mu, float & Eff);
00079 CorrectionCode DataEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & eff);
00080
00081 CorrectionCode MCEfficiency(const xAOD::Muon& mu, float & Eff);
00082 CorrectionCode MCEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & eff);
00083
00085 void DebugPrint();
00086
00087 virtual ~EfficiencyScaleFactor();
00088
00089
00090 std::string sysname();
00091
00092
00093 HistHandler* get_sf() {
00094 return m_sf;
00095 }
00096 HistHandler* get_eff() {
00097 return m_eff;
00098 }
00099 HistHandler* get_sf_sys() {
00100 return m_sf_sys;
00101 }
00102 HistHandler* get_eff_sys() {
00103 return m_eff_sys;
00104 }
00105 HistHandler* get_mc_eff() {
00106 return m_mc_eff;
00107 }
00108 HistHandler* get_mc_eff_sys() {
00109 return m_mc_eff_sys;
00110 }
00111 private:
00112
00113
00114
00115 typedef std::vector<HistHandler*> SFvec;
00116 typedef std::vector<HistHandler*>::iterator iSFvec;
00117 typedef std::vector<HistHandler*>::const_iterator ciSFvec;
00118
00120 CorrectionCode GetContentFromHist(HistHandler* Hist, IKinematicSystHandler* PtDepHist, const xAOD::Muon& mu, float & SF, bool PtDepHistNeeded);
00122 CorrectionCode GetContentReplicasFromHist(EfficiencyScaleFactor::SFvec &replicas, const xAOD::Muon& mu, std::vector<float> & SF);
00123
00124
00125 void AddStatErrors(float weight);
00126 void AddStatErrors_histo(HistHandler* h, float weight);
00127
00128 void AddSysErrors(float weight);
00129 void AddSysErrors_histo(HistHandler* h, HistHandler* hsys, float weight);
00130 void AddSysErrors_vector(EfficiencyScaleFactor::SFvec &Vec, HistHandler* hsys, float weight);
00131
00132 HistHandler *package_histo(TH1* h);
00133
00136 void AddHistos(HistHandler* & add_to, HistHandler* add_this, float weight);
00137 void ScaleHisto(HistHandler* & h, float weight);
00138
00139
00140 void GenerateReplicas(int nrep, int seed);
00141 void GenerateReplicasFromHist(HistHandler* h, int nrep, int seed, EfficiencyScaleFactor::SFvec &repVector);
00142
00143
00144 void Clear();
00145 void DeleteOldReplicas(EfficiencyScaleFactor::SFvec &Vec, bool ClearVec = false);
00146 void CopyContent(const EfficiencyScaleFactor &other);
00147 void CopyHistHandler(HistHandler* &own, const HistHandler* other);
00148 void CopyReplicaVec(EfficiencyScaleFactor::SFvec &own, const EfficiencyScaleFactor::SFvec &other);
00150 HistHandler* m_sf;
00151 HistHandler* m_eff;
00152 HistHandler* m_mc_eff;
00153 HistHandler* m_sf_sys;
00154 HistHandler* m_eff_sys;
00155 HistHandler* m_mc_eff_sys;
00156
00157 IKinematicSystHandler* m_sf_KineDepsys;
00158 IKinematicSystHandler* m_eff_KineDepsys;
00159
00160
00161 SFvec m_sf_replicas;
00162 SFvec m_eff_replicas;
00163 SFvec m_mc_eff_replicas;
00164
00165
00166 fineEtaPhiBinning m_etaphi;
00167
00168
00169 SystematicSet m_sys;
00170
00171
00172 bool m_is_lowpt;
00173
00174 bool m_respond_to_kineDepSyst;
00175
00176 float m_default_eff;
00177
00178 float m_default_eff_ttva;
00179 CP::MuonEfficiencyType m_Type;
00180
00181 };
00182 }
00183
00184 #endif