Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "Configuration/Skimming/interface/LeptonRecoSkim.h"
00023
00024
00025 using namespace edm;
00026 using namespace reco;
00027 using namespace std;
00028
00029
00030
00031
00032 LeptonRecoSkim::LeptonRecoSkim(const edm::ParameterSet& iConfig):
00033 hltLabel(iConfig.getParameter<edm::InputTag>("HltLabel")),
00034 filterName(iConfig.getParameter<std::string>("@module_label")),
00035 m_electronSrc(iConfig.getParameter<edm::InputTag>("electronCollection")),
00036 m_pfelectronSrc(iConfig.getParameter<edm::InputTag>("pfElectronCollection")),
00037 m_muonSrc(iConfig.getParameter<edm::InputTag>("muonCollection")),
00038 m_jetsSrc(iConfig.getParameter<edm::InputTag>("caloJetCollection")),
00039 m_pfjetsSrc(iConfig.getParameter<edm::InputTag>("PFJetCollection")),
00040 m_ebRecHitsSrc(iConfig.getParameter<edm::InputTag>("ecalBarrelRecHitsCollection")),
00041 m_eeRecHitsSrc(iConfig.getParameter<edm::InputTag>("ecalEndcapRecHitsCollection")),
00042 useElectronSelection(iConfig.getParameter<bool>("UseElectronSelection")),
00043 usePfElectronSelection(iConfig.getParameter<bool>("UsePfElectronSelection")),
00044 useMuonSelection(iConfig.getParameter<bool>("UseMuonSelection")),
00045 useHtSelection(iConfig.getParameter<bool>("UseHtSelection")),
00046 usePFHtSelection(iConfig.getParameter<bool>("UsePFHtSelection")),
00047 ptElecMin(iConfig.getParameter<double>("electronPtMin")),
00048 ptPfElecMin(iConfig.getParameter<double>("pfElectronPtMin")),
00049 nSelectedElectrons(iConfig.getParameter<int>("electronN")),
00050 nSelectedPfElectrons(iConfig.getParameter<int>("pfElectronN")),
00051 ptGlobalMuonMin(iConfig.getParameter<double>("globalMuonPtMin")),
00052 ptTrackerMuonMin(iConfig.getParameter<double>("trackerMuonPtMin")),
00053 nSelectedMuons(iConfig.getParameter<int>("muonN")),
00054 htMin(iConfig.getParameter<double>("HtMin")),
00055 pfHtMin(iConfig.getParameter<double>("PFHtMin")),
00056 htJetThreshold(iConfig.getParameter<double>("HtJetThreshold")),
00057 pfHtJetThreshold(iConfig.getParameter<double>("PFHtJetThreshold"))
00058 {
00059 NeventsTotal = 0;
00060 NeventsFiltered = 0;
00061 NHltMu9 = 0;
00062 NHltDiMu3 = 0;
00063
00064 NtotalElectrons = 0;
00065 NmvaElectrons = 0;
00066 }
00067
00068
00069 LeptonRecoSkim::~LeptonRecoSkim()
00070 {
00071
00072
00073
00074
00075 }
00076
00077
00078
00079
00080
00081
00082
00083 bool
00084 LeptonRecoSkim::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00085 {
00086
00087
00088 bool accept = false;
00089
00090 NeventsTotal++;
00091
00092 ElectronCutPassed = false;
00093 PfElectronCutPassed = false;
00094 MuonCutPassed = false;
00095 HtCutPassed = false;
00096 PFHtCutPassed = false;
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 this->handleObjects(iEvent,iSetup);
00107
00108 if(useElectronSelection) {
00109 int nElecPassingCut = 0;
00110 for(unsigned int i=0; i<theElectronCollection->size(); i++) {
00111 GsfElectron electron = (*theElectronCollection)[i];
00112
00113 float elpt = electron.pt();
00114
00115 if(elpt>ptElecMin) {
00116 NtotalElectrons++;
00117 nElecPassingCut++;
00118 if(electron.mva()>-0.1) NmvaElectrons++;
00119 }
00120 LogDebug("LeptonRecoSkim") << "elpt = " << elpt << endl;
00121
00122 }
00123 if(nElecPassingCut>=nSelectedElectrons) ElectronCutPassed = true;
00124 }
00125 else ElectronCutPassed = true;
00126
00127 if(usePfElectronSelection) {
00128 int nPfElecPassingCut = 0;
00129 for(unsigned int i=0; i<thePfCandidateCollection->size(); i++) {
00130 const reco::PFCandidate& thePfCandidate = (*thePfCandidateCollection)[i];
00131 if(thePfCandidate.particleId()!=reco::PFCandidate::e) continue;
00132 if(thePfCandidate.gsfTrackRef().isNull()) continue;
00133 float pfelpt = thePfCandidate.pt();
00134
00135 if(pfelpt>ptPfElecMin) nPfElecPassingCut++;
00136 LogDebug("LeptonRecoSkim") << "pfelpt = " << pfelpt << endl;
00137 }
00138 if(nPfElecPassingCut>=nSelectedPfElectrons) PfElectronCutPassed = true;
00139 }
00140 else PfElectronCutPassed = true;
00141
00142
00143
00144 if(useMuonSelection) {
00145 int nMuonPassingCut = 0;
00146 for(unsigned int i=0; i<theMuonCollection->size(); i++) {
00147 Muon muon = (*theMuonCollection)[i];
00148 if(! (muon.isGlobalMuon() || muon.isTrackerMuon()) ) continue;
00149 const TrackRef siTrack = muon.innerTrack();
00150 const TrackRef globalTrack = muon.globalTrack();
00151 float muonpt;
00152 float ptMuonMin;
00153
00154 if (muon.isGlobalMuon() && muon.isTrackerMuon()) {
00155 muonpt = max(siTrack->pt(), globalTrack->pt());
00156 ptMuonMin = ptGlobalMuonMin;
00157 }
00158 else if (muon.isGlobalMuon() && !(muon.isTrackerMuon())) {
00159 muonpt = globalTrack->pt();
00160 ptMuonMin = ptGlobalMuonMin;
00161 }
00162 else if (muon.isTrackerMuon() && !(muon.isGlobalMuon())) {
00163 muonpt = siTrack->pt();
00164 ptMuonMin = ptTrackerMuonMin;
00165 }
00166 else {
00167 muonpt = 0;
00168 ptMuonMin = 999999.;
00169 }
00170 if(muonpt>ptMuonMin) nMuonPassingCut++;
00171 LogDebug("RecoSelectorCuts") << "muonpt = " << muonpt << endl;
00172 }
00173 if(nMuonPassingCut>=nSelectedMuons) MuonCutPassed = true;
00174 }
00175 else MuonCutPassed = true;
00176
00177 if(useHtSelection) {
00178 double Ht = 0;
00179 for(unsigned int i=0; i<theCaloJetCollection->size(); i++) {
00180
00181 if((*theCaloJetCollection)[i].pt()>htJetThreshold) Ht += (*theCaloJetCollection)[i].pt();
00182 }
00183 if(Ht>htMin) HtCutPassed = true;
00184 }
00185 else HtCutPassed = true;
00186
00187 if(usePFHtSelection) {
00188 double PFHt = 0;
00189 for(unsigned int i=0; i<thePFJetCollection->size(); i++) {
00190 if((*thePFJetCollection)[i].pt()>pfHtJetThreshold) PFHt += (*thePFJetCollection)[i].pt();
00191 }
00192 if(PFHt>pfHtMin) PFHtCutPassed = true;
00193 }
00194 else PFHtCutPassed = true;
00195
00196
00197 if(PfElectronCutPassed &&
00198 ElectronCutPassed &&
00199 MuonCutPassed &&
00200 HtCutPassed &&
00201 PFHtCutPassed ) accept = true;
00202
00203 if(accept) NeventsFiltered++;
00204
00205 firstEvent = false;
00206 return accept;
00207
00208
00209
00210 }
00211
00212
00213 void
00214 LeptonRecoSkim::beginJob()
00215 {
00216 firstEvent = true;
00217 }
00218
00219
00220 void
00221 LeptonRecoSkim::endJob() {
00222 cout << "Filter Name = " << filterName << endl;
00223 cout << "Total number of events = " << NeventsTotal << endl;
00224 cout << "Total HLT_Mu9 = " << NHltMu9 << endl;
00225 cout << "Total HLT_DoubleMu3 = " << NHltDiMu3 << endl;
00226 cout << "Filtered events = " << NeventsFiltered << endl;
00227 cout << "Filter Efficiency = " << (float)NeventsFiltered / (float)NeventsTotal << endl;
00228 cout << endl;
00229 cout << "N total electrons = " << NtotalElectrons << endl;
00230 cout << "N mva>-0.1 electrons = " << NmvaElectrons << endl;
00231 cout << endl;
00232 cout << endl;
00233 }
00234
00235
00236
00237
00238 void LeptonRecoSkim::handleObjects(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00239 {
00240
00241 Handle<GsfElectronCollection> theElectronCollectionHandle;
00242 iEvent.getByLabel(m_electronSrc, theElectronCollectionHandle);
00243 theElectronCollection = theElectronCollectionHandle.product();
00244
00245
00246 Handle<reco::PFCandidateCollection> thePfCandidateHandle;
00247 iEvent.getByLabel(m_pfelectronSrc, thePfCandidateHandle);
00248 thePfCandidateCollection = thePfCandidateHandle.product();
00249
00250
00251 Handle<MuonCollection> theMuonCollectionHandle;
00252 iEvent.getByLabel(m_muonSrc, theMuonCollectionHandle);
00253 theMuonCollection = theMuonCollectionHandle.product();
00254
00255
00256 Handle<CaloJetCollection> theCaloJetCollectionHandle;
00257 iEvent.getByLabel(m_jetsSrc, theCaloJetCollectionHandle);
00258 theCaloJetCollection = theCaloJetCollectionHandle.product();
00259
00260
00261 Handle<PFJetCollection> thePFJetCollectionHandle;
00262 iEvent.getByLabel(m_pfjetsSrc, thePFJetCollectionHandle);
00263 thePFJetCollection = thePFJetCollectionHandle.product();
00264
00265
00266
00267 edm::Handle<EcalRecHitCollection> ebRecHitsHandle;
00268 iEvent.getByLabel(m_ebRecHitsSrc, ebRecHitsHandle);
00269 theEcalBarrelCollection = ebRecHitsHandle.product();
00270
00271 edm::Handle<EcalRecHitCollection> eeRecHitsHandle;
00272 iEvent.getByLabel(m_eeRecHitsSrc, eeRecHitsHandle);
00273 theEcalEndcapCollection = eeRecHitsHandle.product();
00274
00275
00276 edm::ESHandle<CaloGeometry> geometryHandle;
00277 iSetup.get<CaloGeometryRecord>().get(geometryHandle);
00278 theCaloGeometry = geometryHandle.product();
00279
00280
00281
00282 edm::ESHandle<CaloTopology> pTopology;
00283 iSetup.get<CaloTopologyRecord>().get(pTopology);
00284 theCaloTopology = pTopology.product();
00285
00286
00287
00288
00289 }
00290
00291
00292
00293
00294
00295 DEFINE_FWK_MODULE(LeptonRecoSkim);