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(const std::string &file, const std::string &time_unit, SystematicSet sys, CP::MuonEfficiencyType effType, bool is_lowpt = false, bool hasPtDepSys = false);
00057
00058 EfficiencyScaleFactor(EfficiencyScaleFactor* Nominal, const std::string &file, const std::string &time_unit, SystematicSet sys, CP::MuonEfficiencyType effType, bool is_lowpt = false, bool hasPtDepSys = false);
00059
00060 EfficiencyScaleFactor(const EfficiencyScaleFactor & other);
00061 EfficiencyScaleFactor & operator =(const EfficiencyScaleFactor & other);
00062
00064 bool ReadFromFile(std::string file, std::string time_unit);
00065 HistHandler* ReadHistFromFile(std::string name, TFile* f, std::string time_unit);
00066
00067
00068 void ApplySysVariation();
00069
00071 bool CheckConsistency();
00072
00073 int nBinsSF() const;
00074 int nBinsEfficiency() const;
00075
00076
00077 bool SetSystematicBin(int bin);
00079
00081 CorrectionCode ScaleFactor(const xAOD::Muon& mu, float & SF) const;
00082 CorrectionCode ScaleFactorReplicas(const xAOD::Muon& mu, std::vector<float> & SF);
00083
00085 CorrectionCode DataEfficiency(const xAOD::Muon& mu, float & Eff) const;
00086 CorrectionCode DataEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & eff);
00087
00088 CorrectionCode MCEfficiency(const xAOD::Muon& mu, float & Eff) const;
00089 CorrectionCode MCEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & eff);
00090
00092 void DebugPrint();
00093
00094 virtual ~EfficiencyScaleFactor();
00095
00096
00097 std::string sysname() const;
00098
00099 private:
00100
00101
00102
00103 typedef std::vector<HistHandler*> SFvec;
00104 typedef std::vector<HistHandler*>::iterator iSFvec;
00105 typedef std::vector<HistHandler*>::const_iterator ciSFvec;
00106
00108 CorrectionCode GetContentFromHist(HistHandler* Hist, IKinematicSystHandler* PtDepHist, const xAOD::Muon& mu, float & SF, bool PtDepHistNeeded) const;
00110 CorrectionCode GetContentReplicasFromHist(EfficiencyScaleFactor::SFvec &replicas, const xAOD::Muon& mu, std::vector<float> & SF);
00111
00112
00113 void AddStatErrors(float weight);
00114 void AddStatErrors_histo(HistHandler* h, float weight);
00115
00116 void AddSysErrors(float weight);
00117 void AddSysErrors_histo(HistHandler* h, HistHandler* hsys, float weight);
00118 void AddSysErrors_vector(EfficiencyScaleFactor::SFvec &Vec, HistHandler* hsys, float weight);
00119
00120 HistHandler *package_histo(TH1* h);
00121
00124 void AddHistos(HistHandler* & add_to, HistHandler* add_this, float weight);
00125 void ScaleHisto(HistHandler* & h, float weight);
00126
00127
00128 void GenerateReplicas(int nrep, int seed);
00129 void GenerateReplicasFromHist(HistHandler* h, int nrep, int seed, EfficiencyScaleFactor::SFvec &repVector);
00130
00131
00132 void Clear();
00133 void DeleteOldReplicas(EfficiencyScaleFactor::SFvec &Vec, bool ClearVec = false);
00134 void CopyContent(const EfficiencyScaleFactor &other);
00135 void CopyHistHandler(HistHandler* &own, const HistHandler* other);
00136 void CopyReplicaVec(EfficiencyScaleFactor::SFvec &own, const EfficiencyScaleFactor::SFvec &other);
00138 HistHandler* m_sf;
00139 HistHandler* m_eff;
00140 HistHandler* m_mc_eff;
00141 HistHandler* m_sf_sys;
00142 HistHandler* m_eff_sys;
00143 HistHandler* m_mc_eff_sys;
00144
00145 IKinematicSystHandler* m_sf_KineDepsys;
00146 IKinematicSystHandler* m_eff_KineDepsys;
00147
00148
00149 SFvec m_sf_replicas;
00150 SFvec m_eff_replicas;
00151 SFvec m_mc_eff_replicas;
00152
00153
00154 fineEtaPhiBinning m_etaphi;
00155
00156
00157 SystematicSet m_sys;
00158
00159
00160 bool m_is_lowpt;
00161
00162 bool m_respond_to_kineDepSyst;
00163
00164 float m_default_eff;
00165
00166 float m_default_eff_ttva;
00167 CP::MuonEfficiencyType m_Type;
00168
00169 EfficiencyScaleFactor* m_NominalFallBack;
00170 int m_SystematicBin;
00171
00172 };
00173 }
00174
00175 #endif