00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef MUONTRIGGERSCALEFACTORS_H_
00012 #define MUONTRIGGERSCALEFACTORS_H_
00013
00014 #include "MuonEfficiencyCorrections/IMuonTriggerScaleFactors.h"
00015 #include "AsgTools/AsgTool.h"
00016 #include "AsgTools/ToolHandle.h"
00017 #include "PATInterfaces/ISystematicsTool.h"
00018 #include "PATInterfaces/SystematicRegistry.h"
00019 #include <stdexcept>
00020 #include <iostream>
00021 #include <string>
00022 #include <sstream>
00023
00024
00025 #include "TTree.h"
00026 #include "TLorentzVector.h"
00027 #include "TFile.h"
00028 #include "TSystem.h"
00029 #include "TROOT.h"
00030 #include "TRandom.h"
00031 #include "TDirectory.h"
00032 #include "TH2.h"
00033 class TLorentzVector;
00034 class TH2;
00035 class TFile;
00036 class TDirectory;
00037
00038 #include <boost/unordered_map.hpp>
00039
00040 namespace CP {
00041
00042 class MuonTriggerScaleFactors: public asg::AsgTool, public CP::IMuonTriggerScaleFactors{
00043 ASG_TOOL_CLASS( MuonTriggerScaleFactors, CP::IMuonTriggerScaleFactors )
00044
00045 public:
00046
00047 struct Storage {
00048 const std::vector<std::string> *type;
00049 const std::vector<std::string> *region;
00050 const std::vector<std::string> *quality;
00051 const std::vector<std::string> *isolation;
00052 const std::vector<std::string> *bins;
00053 const std::vector<std::string> *trigger;
00054 const std::vector<std::string> *period;
00055 const std::vector<std::string> *systematic;
00056
00057 Storage(const std::vector<std::string> *type_=0,
00058 const std::vector<std::string> *region_=0,
00059 const std::vector<std::string> *quality_=0,
00060 const std::vector<std::string> *isolation_=0,
00061 const std::vector<std::string> *bins_=0,
00062 const std::vector<std::string> *trigger_=0,
00063 const std::vector<std::string> *period_=0,
00064 const std::vector<std::string> *systematic_=0) :
00065 type(type_),
00066 region(region_),
00067 quality(quality_),
00068 isolation(isolation_),
00069 bins(bins_),
00070 trigger(trigger_),
00071 period(period_),
00072 systematic(systematic_){}
00073 };
00074
00075 MuonTriggerScaleFactors( const std::string& name);
00076
00077 virtual ~MuonTriggerScaleFactors();
00078
00079 virtual StatusCode initialize(void);
00080
00081 virtual CorrectionCode setRunNumber(Int_t runNumber);
00082
00083
00084 virtual CorrectionCode getTriggerScaleFactor(const xAOD::MuonContainer& mucont,
00085 Double_t& triggersf,
00086 const std::string& trigger);
00087
00088 virtual CorrectionCode getTriggerEfficiency(const xAOD::Muon& mu,
00089 Double_t& efficiency,
00090 const std::string& trigger,
00091 Bool_t dataType);
00092
00093 virtual bool isAffectedBySystematic( const CP::SystematicVariation& systematic ) const ;
00094
00095 virtual CP::SystematicSet affectingSystematics() const ;
00096
00097 virtual CP::SystematicSet recommendedSystematics() const ;
00098
00099 virtual CP::SystematicCode applySystematicVariation ( const CP::SystematicSet& systConfig ) ;
00100
00101 virtual bool maskFeetRegions(const xAOD::Muon& mu, double dR);
00102
00103 virtual bool inFeetRegion(unsigned int SectorAddress, unsigned int RoI);
00104
00105 virtual double dR(const double eta1, const double phi1, const double eta2, const double phi2);
00106
00107
00108 virtual int getReplica_index(std::string sysBaseName, const std::string trigStr);
00109 private:
00110
00111 virtual CorrectionCode getMuonEfficiency(Double_t& eff,
00112 const TrigMuonEff::Configuration& configuration,
00113 const xAOD::Muon& muon,
00114 const std::string& trigger,
00115 const std::string& systematic);
00116
00117 virtual CorrectionCode GetTriggerSF_dimu(Double_t& TriggerSF,
00118 TrigMuonEff::Configuration& configuration,
00119 const xAOD::MuonContainer& mucont,
00120 const std::string& trigger);
00121
00122
00123 virtual CorrectionCode GetTriggerSF(Double_t& TriggerSF,
00124 TrigMuonEff::Configuration& configuration,
00125 const xAOD::MuonContainer& mucont,
00126 const std::string& trigger);
00127
00128 virtual CorrectionCode getSingleOrDimuonEfficiency(Double_t& eff,
00129 const TrigMuonEff::Configuration& config,
00130 const xAOD::MuonContainer& mucont,
00131 const std::string& chain,
00132 const std::string& systematic);
00133
00134 virtual CorrectionCode getDimuonEfficiency(Double_t& eff,
00135 const TrigMuonEff::Configuration& configuration,
00136 const xAOD::MuonContainer& mucont,
00137 const std::string& chain,
00138 const std::string& systematic);
00139
00140 virtual CorrectionCode setMaxPeriod(const TrigMuonEff::DataPeriod x);
00141
00142 const CP::SystematicSet& appliedSystematics() const {
00143 return *m_appliedSystematics;
00144 }
00145
00146 CP::SystematicCode registerSystematics();
00147
00148 boost::unordered_map<CP::SystematicSet, CP::SystematicSet> m_systFilter;
00149
00150 CP::SystematicSet* m_appliedSystematics;
00151
00152 std::string m_fileName;
00153 Int_t m_runNumber;
00154 const char* m_classname;
00155
00156 typedef std::map<std::string, TH2*> EfficiencyMap;
00157 EfficiencyMap m_efficiencyMap;
00158 typedef std::pair<std::string, TH2*> EfficiencyPair;
00159 mutable std::map<int, std::string> m_fileNameMap;
00160
00161 std::map<std::string, std::vector<TH2*> > m_efficiencyMapReplicaArray;
00162
00163 Double_t getThresholds(const std::string& trigger);
00164
00165 bool setConfiguration(TrigMuonEff::Configuration& config,
00166 TrigMuonEff::DataPeriod period = TrigMuonEff::period_undefined) const;
00167
00168 struct DileptonThresholds {
00169 double mu6;
00170 double mu10;
00171 double mu14;
00172 double mu18;
00173 double mu20;
00174 double mu22;
00175 double mu24;
00176 double mu26;
00177 double mu8noL1;
00178 DileptonThresholds(const double mu6_ = 7,
00179 const double mu10_ = 11,
00180 const double mu14_ = 15,
00181 const double mu18_ = 19,
00182 const double mu20_ = 21,
00183 const double mu22_ = 23,
00184 const double mu24_ = 25,
00185 const double mu26_ = 27,
00186 const double mu8noL1_ = 10) :
00187 mu6(mu6_), mu10(mu10_), mu14(mu14_), mu18(mu18_), mu20(mu20_), mu22(mu22_), mu24(mu24_), mu26(mu26_), mu8noL1(mu8noL1_){}
00188 };
00189
00190 static void getDileptonThresholds(DileptonThresholds& thresholds);
00191
00192 struct DileptonTrigger {
00193 std::string leg1;
00194 std::string leg2;
00195 std::string bothLegs;
00196 DileptonTrigger(const std::string& leg1_ = std::string(),
00197 const std::string& leg2_ = std::string(),
00198 const std::string& bothLegs_ = std::string()) :
00199 leg1(leg1_), leg2(leg2_), bothLegs(bothLegs_) {}
00200 };
00201
00202 static void getDileptonLegs(const std::string& chain,
00203 DileptonTrigger& legs);
00204
00205 static TrigMuonEff::DataPeriod getDataPeriod(int runNumber);
00206
00207 void setStorage(Storage& storage) const;
00208
00209 TDirectory* getTemporaryDirectory(void) const;
00210
00211 TrigMuonEff::DataPeriod m_max_period;
00212
00213 std::string m_muonquality;
00214
00215 std::string m_year;
00216 std::string m_mc;
00217
00218
00219 std::string m_calibration_version;
00220 std::string m_custom_dir;
00221 std::string m_isolation;
00222 std::string m_binning;
00223
00224 bool m_allowZeroSF;
00225
00226 std::vector< std::string > m_replicaTriggerList;
00227 std::set<std::string> m_replicaSet;
00228 int m_nReplicas;
00229 int m_ReplicaRandomSeed = 1234;
00230
00231
00232
00233 std::vector<TH2*> generateReplicas(TH2* h, int nrep, int seed);
00234
00235 };
00236
00237 }
00238
00239 #endif