CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LeptonRecoSkim.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 //
4 // Package: LeptonRecoSkim
5 // Class: LeptonRecoSkim
6 //
14 //
15 // Original Author: Massimiliano Chiorboli,40 4-A01,+41227671535,
16 // Created: Wed Mar 31 21:49:08 CEST 2010
17 // $Id: LeptonRecoSkim.cc,v 1.1 2010/11/05 18:37:51 torimoto Exp $
18 //
19 //
20 
22 
23 using namespace edm;
24 using namespace reco;
25 using namespace std;
26 
27 //
28 // constructors and destructor
29 //
31  : hltLabel(iConfig.getParameter<edm::InputTag>("HltLabel")),
32  filterName(iConfig.getParameter<std::string>("@module_label")),
33  m_electronSrc(iConfig.getParameter<edm::InputTag>("electronCollection")),
34  m_pfelectronSrc(iConfig.getParameter<edm::InputTag>("pfElectronCollection")),
35  m_muonSrc(iConfig.getParameter<edm::InputTag>("muonCollection")),
36  m_jetsSrc(iConfig.getParameter<edm::InputTag>("caloJetCollection")),
37  m_pfjetsSrc(iConfig.getParameter<edm::InputTag>("PFJetCollection")),
38  m_ebRecHitsSrc(iConfig.getParameter<edm::InputTag>("ecalBarrelRecHitsCollection")),
39  m_eeRecHitsSrc(iConfig.getParameter<edm::InputTag>("ecalEndcapRecHitsCollection")),
40  useElectronSelection(iConfig.getParameter<bool>("UseElectronSelection")),
41  usePfElectronSelection(iConfig.getParameter<bool>("UsePfElectronSelection")),
42  useMuonSelection(iConfig.getParameter<bool>("UseMuonSelection")),
43  useHtSelection(iConfig.getParameter<bool>("UseHtSelection")),
44  usePFHtSelection(iConfig.getParameter<bool>("UsePFHtSelection")),
45  ptElecMin(iConfig.getParameter<double>("electronPtMin")),
46  ptPfElecMin(iConfig.getParameter<double>("pfElectronPtMin")),
47  nSelectedElectrons(iConfig.getParameter<int>("electronN")),
48  nSelectedPfElectrons(iConfig.getParameter<int>("pfElectronN")),
49  ptGlobalMuonMin(iConfig.getParameter<double>("globalMuonPtMin")),
50  ptTrackerMuonMin(iConfig.getParameter<double>("trackerMuonPtMin")),
51  nSelectedMuons(iConfig.getParameter<int>("muonN")),
52  htMin(iConfig.getParameter<double>("HtMin")),
53  pfHtMin(iConfig.getParameter<double>("PFHtMin")),
54  htJetThreshold(iConfig.getParameter<double>("HtJetThreshold")),
55  pfHtJetThreshold(iConfig.getParameter<double>("PFHtJetThreshold")) {
56  NeventsTotal = 0;
57  NeventsFiltered = 0;
58  NHltMu9 = 0;
59  NHltDiMu3 = 0;
60 
61  NtotalElectrons = 0;
62  NmvaElectrons = 0;
63 }
64 
66  // do anything here that needs to be done at desctruction time
67  // (e.g. close files, deallocate resources etc.)
68 }
69 
70 //
71 // member functions
72 //
73 
74 // ------------ method called on each new Event ------------
76  bool accept = false;
77 
78  NeventsTotal++;
79 
80  ElectronCutPassed = false;
81  PfElectronCutPassed = false;
82  MuonCutPassed = false;
83  HtCutPassed = false;
84  PFHtCutPassed = false;
85 
86  // edm::Handle<TriggerResults> trhv;
87  // iEvent.getByLabel(hltLabel,trhv);
88 
89  // const edm::TriggerNames& triggerNames_ = iEvent.triggerNames(*trhv);
90 
91  // if(trhv->at(triggerNames_.triggerIndex("HLT_Mu9")).accept()) NHltMu9++;
92  // if(trhv->at(triggerNames_.triggerIndex("HLT_DoubleMu3")).accept()) NHltDiMu3++;
93 
94  this->handleObjects(iEvent, iSetup);
95 
97  int nElecPassingCut = 0;
98  for (unsigned int i = 0; i < theElectronCollection->size(); i++) {
99  GsfElectron electron = (*theElectronCollection)[i];
100  // if (electron.ecalDrivenSeed()) {
101  float elpt = electron.pt();
102  // if (electron.sigmaIetaIeta() < 0.002) continue;
103  if (elpt > ptElecMin) {
104  NtotalElectrons++;
105  nElecPassingCut++;
106  if (electron.mva_e_pi() > -0.1)
107  NmvaElectrons++;
108  }
109  LogDebug("LeptonRecoSkim") << "elpt = " << elpt << endl;
110  // } // closes if (electron.ecalDrivenSeed()) {
111  }
112  if (nElecPassingCut >= nSelectedElectrons)
113  ElectronCutPassed = true;
114  } else
115  ElectronCutPassed = true;
116 
118  int nPfElecPassingCut = 0;
119  for (unsigned int i = 0; i < thePfCandidateCollection->size(); i++) {
120  const reco::PFCandidate& thePfCandidate = (*thePfCandidateCollection)[i];
121  if (thePfCandidate.particleId() != reco::PFCandidate::e)
122  continue;
123  if (thePfCandidate.gsfTrackRef().isNull())
124  continue;
125  float pfelpt = thePfCandidate.pt();
126  // if (electron.sigmaIetaIeta() < 0.002) continue;
127  if (pfelpt > ptPfElecMin)
128  nPfElecPassingCut++;
129  LogDebug("LeptonRecoSkim") << "pfelpt = " << pfelpt << endl;
130  }
131  if (nPfElecPassingCut >= nSelectedPfElectrons)
132  PfElectronCutPassed = true;
133  } else
134  PfElectronCutPassed = true;
135 
136  if (useMuonSelection) {
137  int nMuonPassingCut = 0;
138  for (unsigned int i = 0; i < theMuonCollection->size(); i++) {
139  Muon muon = (*theMuonCollection)[i];
140  if (!(muon.isGlobalMuon() || muon.isTrackerMuon()))
141  continue;
142  const TrackRef siTrack = muon.innerTrack();
143  const TrackRef globalTrack = muon.globalTrack();
144  float muonpt;
145  float ptMuonMin;
146  // if (siTrack.isNonnull() && globalTrack.isNonnull()) {
147  if (muon.isGlobalMuon() && muon.isTrackerMuon()) {
148  muonpt = max(siTrack->pt(), globalTrack->pt());
149  ptMuonMin = ptGlobalMuonMin;
150  } else if (muon.isGlobalMuon() && !(muon.isTrackerMuon())) {
151  muonpt = globalTrack->pt();
152  ptMuonMin = ptGlobalMuonMin;
153  } else if (muon.isTrackerMuon() && !(muon.isGlobalMuon())) {
154  muonpt = siTrack->pt();
155  ptMuonMin = ptTrackerMuonMin;
156  } else {
157  muonpt = 0; // if we get here this is a STA only muon
158  ptMuonMin = 999999.;
159  }
160  if (muonpt > ptMuonMin)
161  nMuonPassingCut++;
162  LogDebug("RecoSelectorCuts") << "muonpt = " << muonpt << endl;
163  }
164  if (nMuonPassingCut >= nSelectedMuons)
165  MuonCutPassed = true;
166  } else
167  MuonCutPassed = true;
168 
169  if (useHtSelection) {
170  double Ht = 0;
171  for (unsigned int i = 0; i < theCaloJetCollection->size(); i++) {
172  // if((*theCaloJetCollection)[i].eta()<2.6 && (*theCaloJetCollection)[i].emEnergyFraction() <= 0.01) continue;
173  if ((*theCaloJetCollection)[i].pt() > htJetThreshold)
174  Ht += (*theCaloJetCollection)[i].pt();
175  }
176  if (Ht > htMin)
177  HtCutPassed = true;
178  } else
179  HtCutPassed = true;
180 
181  if (usePFHtSelection) {
182  double PFHt = 0;
183  for (unsigned int i = 0; i < thePFJetCollection->size(); i++) {
184  if ((*thePFJetCollection)[i].pt() > pfHtJetThreshold)
185  PFHt += (*thePFJetCollection)[i].pt();
186  }
187  if (PFHt > pfHtMin)
188  PFHtCutPassed = true;
189  } else
190  PFHtCutPassed = true;
191 
193  accept = true;
194 
195  if (accept)
196  NeventsFiltered++;
197 
198  firstEvent = false;
199  return accept;
200 }
201 
202 // ------------ method called once each job just before starting event loop ------------
204 
205 // ------------ method called once each job just after ending the event loop ------------
207  cout << "Filter Name = " << filterName << endl;
208  cout << "Total number of events = " << NeventsTotal << endl;
209  cout << "Total HLT_Mu9 = " << NHltMu9 << endl;
210  cout << "Total HLT_DoubleMu3 = " << NHltDiMu3 << endl;
211  cout << "Filtered events = " << NeventsFiltered << endl;
212  cout << "Filter Efficiency = " << (float)NeventsFiltered / (float)NeventsTotal << endl;
213  cout << endl;
214  cout << "N total electrons = " << NtotalElectrons << endl;
215  cout << "N mva>-0.1 electrons = " << NmvaElectrons << endl;
216  cout << endl;
217  cout << endl;
218 }
219 
221  //Get the electrons
222  Handle<GsfElectronCollection> theElectronCollectionHandle;
223  iEvent.getByLabel(m_electronSrc, theElectronCollectionHandle);
224  theElectronCollection = theElectronCollectionHandle.product();
225 
226  //Get the pf electrons
227  Handle<reco::PFCandidateCollection> thePfCandidateHandle;
228  iEvent.getByLabel(m_pfelectronSrc, thePfCandidateHandle);
229  thePfCandidateCollection = thePfCandidateHandle.product();
230 
231  //Get the Muons
232  Handle<MuonCollection> theMuonCollectionHandle;
233  iEvent.getByLabel(m_muonSrc, theMuonCollectionHandle);
234  theMuonCollection = theMuonCollectionHandle.product();
235 
236  //Get the CaloJets
237  Handle<CaloJetCollection> theCaloJetCollectionHandle;
238  iEvent.getByLabel(m_jetsSrc, theCaloJetCollectionHandle);
239  theCaloJetCollection = theCaloJetCollectionHandle.product();
240 
241  //Get the PfJets
242  Handle<PFJetCollection> thePFJetCollectionHandle;
243  iEvent.getByLabel(m_pfjetsSrc, thePFJetCollectionHandle);
244  thePFJetCollection = thePFJetCollectionHandle.product();
245 
246  //Get the ECAL rechhits to clean the spikes
247  // Get EB RecHits
248  edm::Handle<EcalRecHitCollection> ebRecHitsHandle;
249  iEvent.getByLabel(m_ebRecHitsSrc, ebRecHitsHandle);
250  theEcalBarrelCollection = ebRecHitsHandle.product();
251  // Get EE RecHits
252  edm::Handle<EcalRecHitCollection> eeRecHitsHandle;
253  iEvent.getByLabel(m_eeRecHitsSrc, eeRecHitsHandle);
254  theEcalEndcapCollection = eeRecHitsHandle.product();
255 
256  // Get topology for spike cleaning
257  edm::ESHandle<CaloGeometry> geometryHandle;
258  iSetup.get<CaloGeometryRecord>().get(geometryHandle);
259  theCaloGeometry = geometryHandle.product();
260  // theCaloBarrelSubdetTopology = new EcalBarrelTopology(geometryHandle);
261  // theCaloEndcapSubdetTopology = new EcalEndcapTopology(geometryHandle);
262 
263  edm::ESHandle<CaloTopology> pTopology;
264  iSetup.get<CaloTopologyRecord>().get(pTopology);
265  theCaloTopology = pTopology.product();
266 }
267 
268 //define this as a plug-in
LeptonRecoSkim::ptTrackerMuonMin
double ptTrackerMuonMin
Definition: LeptonRecoSkim.h:108
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
cutBasedMuonId_MuonPOG_V0_cff.globalTrack
globalTrack
Definition: cutBasedMuonId_MuonPOG_V0_cff.py:135
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
LeptonRecoSkim::usePfElectronSelection
bool usePfElectronSelection
Definition: LeptonRecoSkim.h:92
LeptonRecoSkim::theCaloTopology
const CaloTopology * theCaloTopology
Definition: LeptonRecoSkim.h:86
LeptonRecoSkim::firstEvent
bool firstEvent
Definition: LeptonRecoSkim.h:89
edm::Handle::product
T const * product() const
Definition: Handle.h:70
LeptonRecoSkim::PFHtCutPassed
bool PFHtCutPassed
Definition: LeptonRecoSkim.h:101
reco::PFCandidate::e
Definition: PFCandidate.h:47
muon
Definition: MuonCocktails.h:17
LeptonRecoSkim::pfHtMin
double pfHtMin
Definition: LeptonRecoSkim.h:111
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
edm
HLT enums.
Definition: AlignableModifier.h:19
LeptonRecoSkim::endJob
void endJob() override
Definition: LeptonRecoSkim.cc:206
gather_cfg.cout
cout
Definition: gather_cfg.py:144
LeptonRecoSkim::NHltMu9
int NHltMu9
Definition: LeptonRecoSkim.h:117
LeptonRecoSkim::NtotalElectrons
int NtotalElectrons
Definition: LeptonRecoSkim.h:120
CaloTopologyRecord
Definition: CaloTopologyRecord.h:10
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
LeptonRecoSkim::m_eeRecHitsSrc
edm::InputTag m_eeRecHitsSrc
Definition: LeptonRecoSkim.h:77
edm::Handle
Definition: AssociativeIterator.h:50
LeptonRecoSkim.h
Muon
Definition: Muon.py:1
edm::Ref< TrackCollection >
LeptonRecoSkim::ElectronCutPassed
bool ElectronCutPassed
Definition: LeptonRecoSkim.h:97
LeptonRecoSkim::theCaloGeometry
const CaloGeometry * theCaloGeometry
Definition: LeptonRecoSkim.h:87
LeptonRecoSkim::pfHtJetThreshold
double pfHtJetThreshold
Definition: LeptonRecoSkim.h:113
LeptonRecoSkim::~LeptonRecoSkim
~LeptonRecoSkim() override
Definition: LeptonRecoSkim.cc:65
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
LeptonRecoSkim::thePFJetCollection
const reco::PFJetCollection * thePFJetCollection
Definition: LeptonRecoSkim.h:83
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
LeptonRecoSkim::MuonCutPassed
bool MuonCutPassed
Definition: LeptonRecoSkim.h:99
metsig::electron
Definition: SignAlgoResolutions.h:48
edm::ESHandle< CaloGeometry >
reco::GsfElectron
Definition: GsfElectron.h:34
LeptonRecoSkim::filterName
std::string filterName
Definition: LeptonRecoSkim.h:70
LeptonRecoSkim::nSelectedMuons
int nSelectedMuons
Definition: LeptonRecoSkim.h:109
LeptonRecoSkim::handleObjects
void handleObjects(const edm::Event &, const edm::EventSetup &iSetup)
Definition: LeptonRecoSkim.cc:220
LeptonRecoSkim::theElectronCollection
const reco::GsfElectronCollection * theElectronCollection
Definition: LeptonRecoSkim.h:79
LeptonRecoSkim::m_muonSrc
edm::InputTag m_muonSrc
Definition: LeptonRecoSkim.h:73
LeptonRecoSkim::beginJob
void beginJob() override
Definition: LeptonRecoSkim.cc:203
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LeptonRecoSkim::useMuonSelection
bool useMuonSelection
Definition: LeptonRecoSkim.h:93
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
reco::PFCandidate::gsfTrackRef
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:440
LeptonRecoSkim::thePfCandidateCollection
const reco::PFCandidateCollection * thePfCandidateCollection
Definition: LeptonRecoSkim.h:80
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
reco::PFCandidate::particleId
virtual ParticleType particleId() const
Definition: PFCandidate.h:367
LeptonRecoSkim::htJetThreshold
double htJetThreshold
Definition: LeptonRecoSkim.h:112
LeptonRecoSkim::useHtSelection
bool useHtSelection
Definition: LeptonRecoSkim.h:94
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
LeptonRecoSkim::nSelectedPfElectrons
int nSelectedPfElectrons
Definition: LeptonRecoSkim.h:106
LeptonRecoSkim::theCaloJetCollection
const reco::CaloJetCollection * theCaloJetCollection
Definition: LeptonRecoSkim.h:82
LeptonRecoSkim::NeventsFiltered
int NeventsFiltered
Definition: LeptonRecoSkim.h:116
edm::EventSetup
Definition: EventSetup.h:58
LeptonRecoSkim::ptPfElecMin
double ptPfElecMin
Definition: LeptonRecoSkim.h:104
get
#define get
LeptonRecoSkim::PfElectronCutPassed
bool PfElectronCutPassed
Definition: LeptonRecoSkim.h:98
LeptonRecoSkim::m_pfjetsSrc
edm::InputTag m_pfjetsSrc
Definition: LeptonRecoSkim.h:75
LeptonRecoSkim::NeventsTotal
int NeventsTotal
Definition: LeptonRecoSkim.h:115
LeptonRecoSkim::NHltDiMu3
int NHltDiMu3
Definition: LeptonRecoSkim.h:118
pdwgDoubleElectron_cfi.filterName
filterName
Definition: pdwgDoubleElectron_cfi.py:7
LeptonRecoSkim::theEcalEndcapCollection
const EcalRecHitCollection * theEcalEndcapCollection
Definition: LeptonRecoSkim.h:85
std
Definition: JetResolutionObject.h:76
LeptonRecoSkim
Definition: LeptonRecoSkim.h:57
LeptonRecoSkim::LeptonRecoSkim
LeptonRecoSkim(const edm::ParameterSet &)
Definition: LeptonRecoSkim.cc:30
LeptonRecoSkim::m_pfelectronSrc
edm::InputTag m_pfelectronSrc
Definition: LeptonRecoSkim.h:72
LeptonRecoSkim::ptElecMin
double ptElecMin
Definition: LeptonRecoSkim.h:103
LeptonRecoSkim::m_jetsSrc
edm::InputTag m_jetsSrc
Definition: LeptonRecoSkim.h:74
LeptonRecoSkim::usePFHtSelection
bool usePFHtSelection
Definition: LeptonRecoSkim.h:95
LeptonRecoSkim::htMin
double htMin
Definition: LeptonRecoSkim.h:110
LeptonRecoSkim::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: LeptonRecoSkim.cc:75
LeptonRecoSkim::theEcalBarrelCollection
const EcalRecHitCollection * theEcalBarrelCollection
Definition: LeptonRecoSkim.h:84
LeptonRecoSkim::NmvaElectrons
int NmvaElectrons
Definition: LeptonRecoSkim.h:121
LeptonRecoSkim::nSelectedElectrons
int nSelectedElectrons
Definition: LeptonRecoSkim.h:105
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
LeptonRecoSkim::useElectronSelection
bool useElectronSelection
Definition: LeptonRecoSkim.h:91
LeptonRecoSkim::HtCutPassed
bool HtCutPassed
Definition: LeptonRecoSkim.h:100
edm::Event
Definition: Event.h:73
LeptonRecoSkim::ptGlobalMuonMin
double ptGlobalMuonMin
Definition: LeptonRecoSkim.h:107
edm::InputTag
Definition: InputTag.h:15
LeptonRecoSkim::m_ebRecHitsSrc
edm::InputTag m_ebRecHitsSrc
Definition: LeptonRecoSkim.h:76
LeptonRecoSkim::m_electronSrc
edm::InputTag m_electronSrc
Definition: LeptonRecoSkim.h:71
LeptonRecoSkim::theMuonCollection
const reco::MuonCollection * theMuonCollection
Definition: LeptonRecoSkim.h:81