CMS 3D CMS Logo

ReducedEGProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <memory>
4 #include <unordered_set>
5 
6 // Framework
9 
11 
16 
17 
29 
30 
33 
36 
39 
44 
46 
47 namespace std {
48  template<>
49  struct hash<DetId> {
50  size_t operator()(const DetId& id) const {
51  return std::hash<uint32_t>()(id.rawId());
52  }
53  };
54 }
55 
57  photonT_(consumes<reco::PhotonCollection>(config.getParameter<edm::InputTag>("photons"))),
58  ootPhotonT_(consumes<reco::PhotonCollection>(config.getParameter<edm::InputTag>("ootPhotons"))),
59  gsfElectronT_(consumes<reco::GsfElectronCollection>(config.getParameter<edm::InputTag>("gsfElectrons"))),
60  gsfTrackT_(consumes<reco::GsfTrackCollection>(config.getParameter<edm::InputTag>("gsfTracks"))),
61  conversionT_(consumes<reco::ConversionCollection>(config.getParameter<edm::InputTag>("conversions"))),
62  singleConversionT_(consumes<reco::ConversionCollection>(config.getParameter<edm::InputTag>("singleConversions"))),
63  barrelEcalHits_(consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("barrelEcalHits"))),
64  endcapEcalHits_(consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("endcapEcalHits"))),
65  doPreshowerEcalHits_(!config.getParameter<edm::InputTag>("preshowerEcalHits").label().empty()),
66  preshowerEcalHits_(doPreshowerEcalHits_ ? consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("preshowerEcalHits")) : edm::EDGetTokenT<EcalRecHitCollection>()),
67  photonPfCandMapT_(consumes<edm::ValueMap<std::vector<reco::PFCandidateRef> > >(config.getParameter<edm::InputTag>("photonsPFValMap"))),
68  gsfElectronPfCandMapT_(consumes<edm::ValueMap<std::vector<reco::PFCandidateRef> > >(config.getParameter<edm::InputTag>("gsfElectronsPFValMap"))),
69  //output collections
70  outPhotons_("reducedGedPhotons"),
71  outPhotonCores_("reducedGedPhotonCores"),
72  outOOTPhotons_("reducedOOTPhotons"),
73  outOOTPhotonCores_("reducedOOTPhotonCores"),
74  outGsfElectrons_("reducedGedGsfElectrons"),
75  outGsfElectronCores_("reducedGedGsfElectronCores"),
76  outGsfTracks_("reducedGsfTracks"),
77  outConversions_("reducedConversions"),
78  outSingleConversions_("reducedSingleLegConversions"),
79  outSuperClusters_("reducedSuperClusters"),
80  outEBEEClusters_("reducedEBEEClusters"),
81  outESClusters_("reducedESClusters"),
82  outOOTSuperClusters_("reducedOOTSuperClusters"),
83  outOOTEBEEClusters_("reducedOOTEBEEClusters"),
84  outOOTESClusters_("reducedOOTESClusters"),
85  outEBRecHits_("reducedEBRecHits"),
86  outEERecHits_("reducedEERecHits"),
87  outESRecHits_("reducedESRecHits"),
88  outPhotonPfCandMap_("reducedPhotonPfCandMap"),
89  outGsfElectronPfCandMap_("reducedGsfElectronPfCandMap"),
90  outPhotonIds_(config.getParameter<std::vector<std::string> >("photonIDOutput")),
91  outGsfElectronIds_(config.getParameter<std::vector<std::string> >("gsfElectronIDOutput")),
92  outPhotonPFClusterIsos_(config.getParameter<std::vector<std::string> >("photonPFClusterIsoOutput")),
93  outOOTPhotonPFClusterIsos_(config.getParameter<std::vector<std::string> >("ootPhotonPFClusterIsoOutput")),
94  outGsfElectronPFClusterIsos_(config.getParameter<std::vector<std::string> >("gsfElectronPFClusterIsoOutput")),
95  keepPhotonSel_(config.getParameter<std::string>("keepPhotons")),
96  slimRelinkPhotonSel_(config.getParameter<std::string>("slimRelinkPhotons")),
97  relinkPhotonSel_(config.getParameter<std::string>("relinkPhotons")),
98  keepOOTPhotonSel_(config.getParameter<std::string>("keepOOTPhotons")),
99  slimRelinkOOTPhotonSel_(config.getParameter<std::string>("slimRelinkOOTPhotons")),
100  relinkOOTPhotonSel_(config.getParameter<std::string>("relinkOOTPhotons")),
101  keepGsfElectronSel_(config.getParameter<std::string>("keepGsfElectrons")),
102  slimRelinkGsfElectronSel_(config.getParameter<std::string>("slimRelinkGsfElectrons")),
103  relinkGsfElectronSel_(config.getParameter<std::string>("relinkGsfElectrons"))
104 {
105  const std::vector<edm::InputTag>& photonidinputs =
106  config.getParameter<std::vector<edm::InputTag> >("photonIDSources");
107  for (const edm::InputTag &tag : photonidinputs) {
108  photonIdTs_.emplace_back(consumes<edm::ValueMap<bool> >(tag));
109  }
110 
111  const std::vector<edm::InputTag>& gsfelectronidinputs =
112  config.getParameter<std::vector<edm::InputTag> >("gsfElectronIDSources");
113  for (const edm::InputTag &tag : gsfelectronidinputs) {
115  }
116 
117  const std::vector<edm::InputTag>& photonpfclusterisoinputs =
118  config.getParameter<std::vector<edm::InputTag> >("photonPFClusterIsoSources");
119  for (const edm::InputTag &tag : photonpfclusterisoinputs) {
121  }
122 
123  const std::vector<edm::InputTag>& ootphotonpfclusterisoinputs =
124  config.getParameter<std::vector<edm::InputTag> >("ootPhotonPFClusterIsoSources");
125  for (const edm::InputTag &tag : ootphotonpfclusterisoinputs) {
127  }
128 
129  const std::vector<edm::InputTag>& gsfelectronpfclusterisoinputs =
130  config.getParameter<std::vector<edm::InputTag> >("gsfElectronPFClusterIsoSources");
131  for (const edm::InputTag &tag : gsfelectronpfclusterisoinputs) {
133  }
134 
135  produces< reco::PhotonCollection >(outPhotons_);
136  produces< reco::PhotonCoreCollection >(outPhotonCores_);
137  produces< reco::PhotonCollection >(outOOTPhotons_);
138  produces< reco::PhotonCoreCollection >(outOOTPhotonCores_);
139  produces< reco::GsfElectronCollection >(outGsfElectrons_);
140  produces< reco::GsfElectronCoreCollection >(outGsfElectronCores_);
141  produces< reco::GsfTrackCollection >(outGsfTracks_);
142  produces< reco::ConversionCollection >(outConversions_);
143  produces< reco::ConversionCollection >(outSingleConversions_);
144  produces< reco::SuperClusterCollection >(outSuperClusters_);
145  produces< reco::CaloClusterCollection >(outEBEEClusters_);
146  produces< reco::CaloClusterCollection >(outESClusters_);
147  produces< reco::SuperClusterCollection >(outOOTSuperClusters_);
148  produces< reco::CaloClusterCollection >(outOOTEBEEClusters_);
149  produces< reco::CaloClusterCollection >(outOOTESClusters_);
150  produces< EcalRecHitCollection >(outEBRecHits_);
151  produces< EcalRecHitCollection >(outEERecHits_);
152  if (doPreshowerEcalHits_) produces< EcalRecHitCollection >(outESRecHits_);
153  produces< edm::ValueMap<std::vector<reco::PFCandidateRef> > >(outPhotonPfCandMap_);
154  produces< edm::ValueMap<std::vector<reco::PFCandidateRef> > >(outGsfElectronPfCandMap_);
155  for (const std::string &outid : outPhotonIds_) {
156  produces< edm::ValueMap<bool> >(outid);
157  }
158  for (const std::string &outid : outGsfElectronIds_) {
159  produces< edm::ValueMap<float> >(outid);
160  }
161  for (const std::string &outid : outPhotonPFClusterIsos_) {
162  produces< edm::ValueMap<float> >(outid);
163  }
164  for (const std::string &outid : outOOTPhotonPFClusterIsos_) {
165  produces< edm::ValueMap<float> >(outid);
166  }
167  for (const std::string &outid : outGsfElectronPFClusterIsos_) {
168  produces< edm::ValueMap<float> >(outid);
169  }
170 }
171 
173 {
174 }
175 
176 void ReducedEGProducer::produce(edm::Event& theEvent, const edm::EventSetup& theEventSetup) {
177 
178  //get input collections
179 
180 
182  theEvent.getByToken(photonT_, photonHandle);
183 
184  edm::Handle<reco::PhotonCollection> ootPhotonHandle;
185  theEvent.getByToken(ootPhotonT_, ootPhotonHandle);
186 
188  theEvent.getByToken(gsfElectronT_, gsfElectronHandle);
189 
191  theEvent.getByToken(gsfTrackT_, gsfTrackHandle);
192 
194  theEvent.getByToken(conversionT_, conversionHandle);
195 
196  edm::Handle<reco::ConversionCollection> singleConversionHandle;
197  theEvent.getByToken(singleConversionT_, singleConversionHandle);
198 
199  edm::Handle<EcalRecHitCollection> barrelHitHandle;
200  theEvent.getByToken(barrelEcalHits_, barrelHitHandle);
201 
202  edm::Handle<EcalRecHitCollection> endcapHitHandle;
203  theEvent.getByToken(endcapEcalHits_, endcapHitHandle);
204 
205  edm::Handle<EcalRecHitCollection> preshowerHitHandle;
206  if (doPreshowerEcalHits_) theEvent.getByToken(preshowerEcalHits_, preshowerHitHandle);
207 
209  theEvent.getByToken(photonPfCandMapT_, photonPfCandMapHandle);
210 
212  theEvent.getByToken(gsfElectronPfCandMapT_, gsfElectronPfCandMapHandle);
213 
214  std::vector<edm::Handle<edm::ValueMap<bool> > > photonIdHandles(photonIdTs_.size());
215  int index = 0; // universal index for range based loops
216  for (const auto& photonIdT : photonIdTs_) {
217  theEvent.getByToken(photonIdT,photonIdHandles[index++]);
218  }
219 
220  std::vector<edm::Handle<edm::ValueMap<float> > > gsfElectronIdHandles(gsfElectronIdTs_.size());
221  index = 0;
222  for (const auto& gsfElectronIdT : gsfElectronIdTs_) {
223  theEvent.getByToken(gsfElectronIdT,gsfElectronIdHandles[index++]);
224  }
225 
226  std::vector<edm::Handle<edm::ValueMap<float> > > photonPFClusterIsoHandles(photonPFClusterIsoTs_.size());
227  index = 0;
228  for (const auto& photonPFClusterIsoT : photonPFClusterIsoTs_) {
229  theEvent.getByToken(photonPFClusterIsoT,photonPFClusterIsoHandles[index++]);
230  }
231 
232  std::vector<edm::Handle<edm::ValueMap<float> > > ootPhotonPFClusterIsoHandles(ootPhotonPFClusterIsoTs_.size());
233  index = 0;
234  for (const auto& ootPhotonPFClusterIsoT : ootPhotonPFClusterIsoTs_) {
235  theEvent.getByToken(ootPhotonPFClusterIsoT,ootPhotonPFClusterIsoHandles[index++]);
236  }
237 
238  std::vector<edm::Handle<edm::ValueMap<float> > > gsfElectronPFClusterIsoHandles(gsfElectronPFClusterIsoTs_.size());
239  index = 0;
240  for (const auto& gsfElectronPFClusterIsoT : gsfElectronPFClusterIsoTs_) {
241  theEvent.getByToken(gsfElectronPFClusterIsoT,gsfElectronPFClusterIsoHandles[index++]);
242  }
243 
244  edm::ESHandle<CaloTopology> theCaloTopology;
245  theEventSetup.get<CaloTopologyRecord>().get(theCaloTopology);
246  const CaloTopology *caloTopology = & (*theCaloTopology);
247 
248  //initialize output collections
249  auto photons = std::make_unique<reco::PhotonCollection>();
250  auto photonCores = std::make_unique<reco::PhotonCoreCollection>();
251  auto ootPhotons = std::make_unique<reco::PhotonCollection>();
252  auto ootPhotonCores = std::make_unique<reco::PhotonCoreCollection>();
253  auto gsfElectrons = std::make_unique<reco::GsfElectronCollection>();
254  auto gsfElectronCores = std::make_unique<reco::GsfElectronCoreCollection>();
255  auto gsfTracks = std::make_unique<reco::GsfTrackCollection>();
256  auto conversions = std::make_unique<reco::ConversionCollection>();
257  auto singleConversions = std::make_unique<reco::ConversionCollection>();
258  auto superClusters = std::make_unique<reco::SuperClusterCollection>();
259  auto ebeeClusters = std::make_unique<reco::CaloClusterCollection>();
260  auto esClusters = std::make_unique<reco::CaloClusterCollection>();
261  auto ootSuperClusters = std::make_unique<reco::SuperClusterCollection>();
262  auto ootEbeeClusters = std::make_unique<reco::CaloClusterCollection>();
263  auto ootEsClusters = std::make_unique<reco::CaloClusterCollection>();
264  auto ebRecHits = std::make_unique<EcalRecHitCollection>();
265  auto eeRecHits = std::make_unique<EcalRecHitCollection>();
266  auto esRecHits = std::make_unique<EcalRecHitCollection>();
267  auto photonPfCandMap = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
268  auto gsfElectronPfCandMap = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
269 
270  //maps to collection indices of output objects
271  std::map<reco::PhotonCoreRef, unsigned int> photonCoreMap;
272  std::map<reco::PhotonCoreRef, unsigned int> ootPhotonCoreMap;
273  std::map<reco::GsfElectronCoreRef, unsigned int> gsfElectronCoreMap;
274  std::map<reco::GsfTrackRef, unsigned int> gsfTrackMap;
275  std::map<reco::ConversionRef, unsigned int> conversionMap;
276  std::map<reco::ConversionRef, unsigned int> singleConversionMap;
277  std::map<reco::SuperClusterRef, unsigned int> superClusterMap;
278  std::map<reco::CaloClusterPtr, unsigned int> ebeeClusterMap;
279  std::map<reco::CaloClusterPtr, unsigned int> esClusterMap;
280  std::map<reco::SuperClusterRef, unsigned int> ootSuperClusterMap;
281  std::map<reco::CaloClusterPtr, unsigned int> ootEbeeClusterMap;
282  std::map<reco::CaloClusterPtr, unsigned int> ootEsClusterMap;
283  std::unordered_set<DetId> rechitMap;
284 
285  std::unordered_set<unsigned int> superClusterFullRelinkMap;
286  std::unordered_set<unsigned int> ootSuperClusterFullRelinkMap;
287 
288  //vectors for pfcandidate valuemaps
289  std::vector<std::vector<reco::PFCandidateRef> > pfCandIsoPairVecPho;
290  std::vector<std::vector<reco::PFCandidateRef> > pfCandIsoPairVecEle;
291 
292  //vectors for id valuemaps
293  std::vector<std::vector<bool> > photonIdVals(photonIdHandles.size());
294  std::vector<std::vector<float> > gsfElectronIdVals(gsfElectronIdHandles.size());
295  std::vector<std::vector<float> > photonPFClusterIsoVals(photonPFClusterIsoHandles.size());
296  std::vector<std::vector<float> > ootPhotonPFClusterIsoVals(ootPhotonPFClusterIsoHandles.size());
297  std::vector<std::vector<float> > gsfElectronPFClusterIsoVals(gsfElectronPFClusterIsoHandles.size());
298 
299  //loop over photons and fill maps
300  index = -1;
301  for (const auto& photon : *photonHandle) {
302  index++;
303 
304  bool keep = keepPhotonSel_(photon);
305  if (!keep) continue;
306 
307  reco::PhotonRef photonref(photonHandle,index);
308 
309  photons->push_back(photon);
310 
311  //fill pf candidate value map vector
312  pfCandIsoPairVecPho.push_back((*photonPfCandMapHandle)[photonref]);
313 
314  //fill photon id valuemap vectors
315  int subindex = 0;
316  for (const auto& photonIdHandle : photonIdHandles) {
317  photonIdVals[subindex++].push_back((*photonIdHandle)[photonref]);
318  }
319 
320  subindex = 0;
321  for (const auto& photonPFClusterIsoHandle : photonPFClusterIsoHandles) {
322  photonPFClusterIsoVals[subindex++].push_back((*photonPFClusterIsoHandle)[photonref]);
323  }
324 
325  //link photon core
326  const reco::PhotonCoreRef &photonCore = photon.photonCore();
327  linkCore(photonCore, *photonCores, photonCoreMap);
328 
329  bool slimRelink = slimRelinkPhotonSel_(photon);
330  //no supercluster relinking unless slimRelink selection is satisfied
331  if (!slimRelink) continue;
332 
333  bool relink = relinkPhotonSel_(photon);
334 
335  //link supercluster
336  const reco::SuperClusterRef &superCluster = photon.superCluster();
337  linkSuperCluster(superCluster, superClusterMap, *superClusters, relink, superClusterFullRelinkMap);
338 
339  //conversions only for full relinking
340  if (!relink) continue;
341 
342  const reco::ConversionRefVector &convrefs = photon.conversions();
343  linkConversions(convrefs, *conversions, conversionMap);
344 
345  //explicitly references conversions
346  const reco::ConversionRefVector &singleconvrefs = photon.conversionsOneLeg();
347  linkConversions(singleconvrefs, *singleConversions, singleConversionMap);
348  }
349 
350  //loop over oot photons and fill maps
351  //special note1: since not PFCand --> no PF isolation, IDs (but we do have PFClusterIso!)
352  //special note2: conversion sequence not run over bcs from oot phos, so skip relinking of oot phos
353  //special note3: clusters and superclusters in own collections!
354  index = -1;
355  for (const auto& ootPhoton : *ootPhotonHandle) {
356  index++;
357 
358  bool keep = keepOOTPhotonSel_(ootPhoton);
359  if (!keep) continue;
360 
361  reco::PhotonRef ootPhotonref(ootPhotonHandle,index);
362 
363  ootPhotons->push_back(ootPhoton);
364 
365  //fill photon pfclusteriso valuemap vectors
366  int subindex = 0;
367  for (const auto& ootPhotonPFClusterIsoHandle : ootPhotonPFClusterIsoHandles) {
368  ootPhotonPFClusterIsoVals[subindex++].push_back((*ootPhotonPFClusterIsoHandle)[ootPhotonref]);
369  }
370 
371  //link photon core
372  const reco::PhotonCoreRef &ootPhotonCore = ootPhoton.photonCore();
373  linkCore(ootPhotonCore, *ootPhotonCores, ootPhotonCoreMap);
374 
375  bool slimRelink = slimRelinkOOTPhotonSel_(ootPhoton);
376  //no supercluster relinking unless slimRelink selection is satisfied
377  if (!slimRelink) continue;
378 
379  bool relink = relinkOOTPhotonSel_(ootPhoton);
380 
381  const reco::SuperClusterRef &ootSuperCluster = ootPhoton.superCluster();
382  linkSuperCluster(ootSuperCluster, ootSuperClusterMap, *ootSuperClusters, relink, ootSuperClusterFullRelinkMap);
383  }
384 
385  //loop over electrons and fill maps
386  index = -1;
387  for (const auto& gsfElectron : *gsfElectronHandle) {
388  index++;
389 
390  bool keep = keepGsfElectronSel_(gsfElectron);
391  if (!keep) continue;
392 
393  reco::GsfElectronRef gsfElectronref(gsfElectronHandle,index);
394 
395  gsfElectrons->push_back(gsfElectron);
396  pfCandIsoPairVecEle.push_back((*gsfElectronPfCandMapHandle)[gsfElectronref]);
397 
398  //fill electron id valuemap vectors
399  int subindex = 0;
400  for (const auto& gsfElectronIdHandle : gsfElectronIdHandles) {
401  gsfElectronIdVals[subindex++].push_back((*gsfElectronIdHandle)[gsfElectronref]);
402  }
403 
404  subindex = 0;
405  for (const auto& gsfElectronPFClusterIsoHandle : gsfElectronPFClusterIsoHandles) {
406  gsfElectronPFClusterIsoVals[subindex++].push_back((*gsfElectronPFClusterIsoHandle)[gsfElectronref]);
407  }
408 
409  const reco::GsfElectronCoreRef &gsfElectronCore = gsfElectron.core();
410  linkCore(gsfElectronCore, *gsfElectronCores, gsfElectronCoreMap);
411 
412  const reco::GsfTrackRef &gsfTrack = gsfElectron.gsfTrack();
413 
414  // Save the main gsfTrack
415  if (!gsfTrackMap.count(gsfTrack)) {
416  gsfTracks->push_back(*gsfTrack);
417  gsfTrackMap[gsfTrack] = gsfTracks->size() - 1;
418  }
419 
420  // Save additional ambiguous gsf tracks in a map:
421  for (reco::GsfTrackRefVector::const_iterator igsf = gsfElectron.ambiguousGsfTracksBegin(); igsf != gsfElectron.ambiguousGsfTracksEnd(); ++igsf) {
422  const reco::GsfTrackRef &ambigGsfTrack = *igsf;
423  if (!gsfTrackMap.count(ambigGsfTrack)) {
424  gsfTracks->push_back(*ambigGsfTrack);
425  gsfTrackMap[ambigGsfTrack] = gsfTracks->size() - 1;
426  }
427  }
428 
429  bool slimRelink = slimRelinkGsfElectronSel_(gsfElectron);
430  //no supercluster relinking unless slimRelink selection is satisfied
431  if (!slimRelink) continue;
432 
433  bool relink = relinkGsfElectronSel_(gsfElectron);
434 
435  const reco::SuperClusterRef &superCluster = gsfElectron.superCluster();
436  linkSuperCluster(superCluster, superClusterMap, *superClusters, relink, superClusterFullRelinkMap);
437 
438  //conversions only for full relinking
439  if (!relink) continue;
440 
441  const reco::ConversionRefVector &convrefs = gsfElectron.core()->conversions();
442  linkConversions(convrefs, *conversions, conversionMap);
443 
444  //explicitly references conversions
445  const reco::ConversionRefVector &singleconvrefs = gsfElectron.core()->conversionsOneLeg();
446  linkConversions(singleconvrefs, *singleConversions, singleConversionMap);
447 
448  //conversions matched by trackrefs
449  linkConversionsByTrackRef(conversionHandle, gsfElectron, *conversions, conversionMap);
450 
451  //single leg conversions matched by trackrefs
452  linkConversionsByTrackRef(singleConversionHandle, gsfElectron, *singleConversions, singleConversionMap);
453  }
454 
455  //loop over output SuperClusters and fill maps
456  index = 0;
457  for (auto& superCluster : *superClusters) {
458 
459  //link seed cluster no matter what
460  const reco::CaloClusterPtr &seedCluster = superCluster.seed();
461  linkCaloCluster(seedCluster, *ebeeClusters, ebeeClusterMap);
462 
463  //only proceed if superCluster is marked for full relinking
464  bool fullrelink = superClusterFullRelinkMap.count(index++);
465  if (!fullrelink) {
466  //zero detid vector which is anyways not useful without stored rechits
467  superCluster.clearHitsAndFractions();
468  continue;
469  }
470 
471  // link calo clusters
472  linkCaloClusters(superCluster, *ebeeClusters, ebeeClusterMap, rechitMap, barrelHitHandle, endcapHitHandle, caloTopology, *esClusters, esClusterMap);
473 
474  //conversions matched geometrically
475  linkConversionsByTrackRef(conversionHandle, superCluster, *conversions, conversionMap);
476 
477  //single leg conversions matched by trackrefs
478  linkConversionsByTrackRef(singleConversionHandle, superCluster, *singleConversions, singleConversionMap);
479  }
480 
481  //loop over output OOTSuperClusters and fill maps
482  index = 0;
483  for (auto& ootSuperCluster : *ootSuperClusters) {
484 
485  //link seed cluster no matter what
486  const reco::CaloClusterPtr &ootSeedCluster = ootSuperCluster.seed();
487  linkCaloCluster(ootSeedCluster, *ootEbeeClusters, ootEbeeClusterMap);
488 
489  //only proceed if ootSuperCluster is marked for full relinking
490  bool fullrelink = ootSuperClusterFullRelinkMap.count(index++);
491  if (!fullrelink) {
492  //zero detid vector which is anyways not useful without stored rechits
493  ootSuperCluster.clearHitsAndFractions();
494  continue;
495  }
496 
497  // link calo clusters
498  linkCaloClusters(ootSuperCluster, *ootEbeeClusters, ootEbeeClusterMap, rechitMap, barrelHitHandle, endcapHitHandle, caloTopology, *ootEsClusters, ootEsClusterMap);
499  }
500 
501  //now finalize and add to the event collections in "reverse" order
502 
503  //rechits (fill output collections of rechits to be stored)
504  for (const EcalRecHit &rechit : *barrelHitHandle) {
505  if (rechitMap.count(rechit.detid())) {
506  ebRecHits->push_back(rechit);
507  }
508  }
509 
510  for (const EcalRecHit &rechit : *endcapHitHandle) {
511  if (rechitMap.count(rechit.detid())) {
512  eeRecHits->push_back(rechit);
513  }
514  }
515 
516  theEvent.put(std::move(ebRecHits),outEBRecHits_);
517  theEvent.put(std::move(eeRecHits),outEERecHits_);
518 
519  if (doPreshowerEcalHits_) {
520  for (const EcalRecHit &rechit : *preshowerHitHandle) {
521  if (rechitMap.count(rechit.detid())) {
522  esRecHits->push_back(rechit);
523  }
524  }
525  theEvent.put(std::move(esRecHits),outESRecHits_);
526  }
527 
528  //CaloClusters
529  //put calocluster output collections in event and get orphan handles to create ptrs
530  const edm::OrphanHandle<reco::CaloClusterCollection> &outEBEEClusterHandle = theEvent.put(std::move(ebeeClusters),outEBEEClusters_);
531  const edm::OrphanHandle<reco::CaloClusterCollection> &outESClusterHandle = theEvent.put(std::move(esClusters),outESClusters_);;
532 
533  //Loop over SuperClusters and relink GEDPhoton + GSFElectron CaloClusters
534  for (reco::SuperCluster &superCluster : *superClusters) {
535  relinkCaloClusters(superCluster, ebeeClusterMap, esClusterMap, outEBEEClusterHandle, outESClusterHandle);
536  }
537 
538  //OOTCaloClusters
539  //put ootcalocluster output collections in event and get orphan handles to create ptrs
540  const edm::OrphanHandle<reco::CaloClusterCollection> &outOOTEBEEClusterHandle = theEvent.put(std::move(ootEbeeClusters),outOOTEBEEClusters_);
541  const edm::OrphanHandle<reco::CaloClusterCollection> &outOOTESClusterHandle = theEvent.put(std::move(ootEsClusters),outOOTESClusters_);;
542 
543  //Loop over OOTSuperClusters and relink OOTPhoton CaloClusters
544  for (reco::SuperCluster &ootSuperCluster : *ootSuperClusters) {
545  relinkCaloClusters(ootSuperCluster, ootEbeeClusterMap, ootEsClusterMap, outOOTEBEEClusterHandle, outOOTESClusterHandle);
546  }
547 
548  //put superclusters and conversions in the event
549  const edm::OrphanHandle<reco::SuperClusterCollection> &outSuperClusterHandle = theEvent.put(std::move(superClusters),outSuperClusters_);
550  const edm::OrphanHandle<reco::ConversionCollection> &outConversionHandle = theEvent.put(std::move(conversions),outConversions_);
551  const edm::OrphanHandle<reco::ConversionCollection> &outSingleConversionHandle = theEvent.put(std::move(singleConversions),outSingleConversions_);
552  const edm::OrphanHandle<reco::GsfTrackCollection> &outGsfTrackHandle = theEvent.put(std::move(gsfTracks),outGsfTracks_);
553 
554  //Loop over PhotonCores and relink GEDPhoton SuperClusters (and conversions)
555  for (reco::PhotonCore &photonCore : *photonCores) {
556  // superclusters
557  relinkSuperCluster(photonCore, superClusterMap, outSuperClusterHandle);
558 
559  //conversions
560  const reco::ConversionRefVector &convrefs = photonCore.conversions();
561  relinkConversions(photonCore, convrefs, conversionMap, outConversionHandle);
562 
563  //single leg conversions
564  const reco::ConversionRefVector &singleconvrefs = photonCore.conversionsOneLeg();
565  relinkConversions(photonCore, singleconvrefs, singleConversionMap, outSingleConversionHandle);
566  }
567 
568  //Relink GSFElectron SuperClusters and main GSF Tracks
569  for (reco::GsfElectronCore &gsfElectronCore : *gsfElectronCores) {
570  relinkSuperCluster(gsfElectronCore, superClusterMap, outSuperClusterHandle);
571  relinkGsfTrack(gsfElectronCore, gsfTrackMap, outGsfTrackHandle);
572  }
573 
574  //put ootsuperclusters in the event
575  const edm::OrphanHandle<reco::SuperClusterCollection> &outOOTSuperClusterHandle = theEvent.put(std::move(ootSuperClusters),outOOTSuperClusters_);
576 
577  //Relink OOTPhoton SuperClusters
578  for (reco::PhotonCore &ootPhotonCore : *ootPhotonCores) {
579  relinkSuperCluster(ootPhotonCore, ootSuperClusterMap, outOOTSuperClusterHandle);
580  }
581 
582  //put photoncores and gsfelectroncores into the event
583  const edm::OrphanHandle<reco::PhotonCoreCollection> &outPhotonCoreHandle = theEvent.put(std::move(photonCores),outPhotonCores_);
584  const edm::OrphanHandle<reco::PhotonCoreCollection> &outOOTPhotonCoreHandle = theEvent.put(std::move(ootPhotonCores),outOOTPhotonCores_);
585  const edm::OrphanHandle<reco::GsfElectronCoreCollection> &outgsfElectronCoreHandle = theEvent.put(std::move(gsfElectronCores),outGsfElectronCores_);
586 
587  //loop over photons, oot photons, and electrons and relink the cores
588  for (reco::Photon &photon : *photons) {
589  relinkPhotonCore(photon, photonCoreMap, outPhotonCoreHandle);
590  }
591 
592  for (reco::Photon &ootPhoton : *ootPhotons) {
593  relinkPhotonCore(ootPhoton, ootPhotonCoreMap, outOOTPhotonCoreHandle);
594  }
595 
596  for (reco::GsfElectron &gsfElectron : *gsfElectrons) {
597  relinkGsfElectronCore(gsfElectron, gsfElectronCoreMap, outgsfElectronCoreHandle);
598 
599  // -----
600  // Also in this loop let's relink ambiguous tracks
601  std::vector<reco::GsfTrackRef> ambigTracksInThisElectron;
602  // Here we loop over the ambiguous tracks and save them in a vector
603  for (reco::GsfTrackRefVector::const_iterator igsf = gsfElectron.ambiguousGsfTracksBegin(); igsf != gsfElectron.ambiguousGsfTracksEnd(); ++igsf) {
604  const reco::GsfTrackRef &ambGsfTrack = *igsf;
605  ambigTracksInThisElectron.push_back(*igsf);
606  }
607 
608  // Now we need to clear them (they are the refs to original collection):
609  gsfElectron.clearAmbiguousGsfTracks();
610 
611  // And here we add them back, now from a new reduced collection:
612  for (const auto &it : ambigTracksInThisElectron) {
613  const auto &gsftkmapped = gsfTrackMap.find(it);
614 
615  if (gsftkmapped != gsfTrackMap.end()) {
616  reco::GsfTrackRef gsftkref(outGsfTrackHandle, gsftkmapped->second);
617  gsfElectron.addAmbiguousGsfTrack(gsftkref);
618  }
619  else
620  throw cms::Exception("There must be a problem with linking and mapping of ambiguous gsf tracks...");
621  }
622 
623  if (gsfElectron.ambiguousGsfTracksSize() > 0)
624  gsfElectron.setAmbiguous(true); // Set the flag
625 
626  ambigTracksInThisElectron.clear();
627 
628  }
629 
630  //(finally) store the output photon and electron collections
631  const edm::OrphanHandle<reco::PhotonCollection> &outPhotonHandle = theEvent.put(std::move(photons),outPhotons_);
632  const edm::OrphanHandle<reco::PhotonCollection> &outOOTPhotonHandle = theEvent.put(std::move(ootPhotons),outOOTPhotons_);
633  const edm::OrphanHandle<reco::GsfElectronCollection> &outGsfElectronHandle = theEvent.put(std::move(gsfElectrons),outGsfElectrons_);
634 
635  //still need to output relinked valuemaps
636 
637  //photon pfcand isolation valuemap
638  edm::ValueMap<std::vector<reco::PFCandidateRef>>::Filler fillerPhotons(*photonPfCandMap);
639  fillerPhotons.insert(outPhotonHandle,pfCandIsoPairVecPho.begin(),pfCandIsoPairVecPho.end());
640  fillerPhotons.fill();
641 
642  //electron pfcand isolation valuemap
643  edm::ValueMap<std::vector<reco::PFCandidateRef>>::Filler fillerGsfElectrons(*gsfElectronPfCandMap);
644  fillerGsfElectrons.insert(outGsfElectronHandle,pfCandIsoPairVecEle.begin(),pfCandIsoPairVecEle.end());
645  fillerGsfElectrons.fill();
646 
647  theEvent.put(std::move(photonPfCandMap),outPhotonPfCandMap_);
648  theEvent.put(std::move(gsfElectronPfCandMap),outGsfElectronPfCandMap_);
649 
650  auto fillMap = [](auto refH, auto& vec, edm::Event& ev, const std::string& cAl = ""){
652  auto oMap = std::make_unique<MapType>();
653  {
654  typename MapType::Filler filler(*oMap);
655  filler.insert(refH, vec.begin(), vec.end());
656  filler.fill();
657  }
658  ev.put(std::move(oMap), cAl);
659  };
660 
661  //photon id value maps
662  index = 0;
663  for (auto const& vals : photonIdVals){
664  fillMap(outPhotonHandle, vals, theEvent, outPhotonIds_[index++]);
665  }
666 
667  //electron id value maps
668  index = 0;
669  for (auto const& vals : gsfElectronIdVals){
670  fillMap(outGsfElectronHandle, vals, theEvent, outGsfElectronIds_[index++]);
671  }
672 
673  // photon iso value maps
674  index = 0;
675  for (auto const& vals : photonPFClusterIsoVals){
676  fillMap(outPhotonHandle, vals, theEvent, outPhotonPFClusterIsos_[index++]);
677  }
678 
679  //oot photon iso value maps
680  index = 0;
681  for (auto const& vals : ootPhotonPFClusterIsoVals){
682  fillMap(outOOTPhotonHandle, vals, theEvent, outOOTPhotonPFClusterIsos_[index++]);
683  }
684 
685  //electron iso value maps
686  index = 0;
687  for (auto const& vals : gsfElectronPFClusterIsoVals){
688  fillMap(outGsfElectronHandle, vals, theEvent, outGsfElectronPFClusterIsos_[index++]);
689  }
690 }
691 
692 template <typename T, typename U>
693 void ReducedEGProducer::linkCore(const T& core, U& cores, std::map<T, unsigned int>& coreMap)
694 {
695  if (!coreMap.count(core)) {
696  cores.push_back(*core);
697  coreMap[core] = cores.size() - 1;
698  }
699 }
700 
702  std::map<reco::SuperClusterRef, unsigned int>& superClusterMap,
703  reco::SuperClusterCollection& superClusters,
704  const bool relink,
705  std::unordered_set<unsigned int>& superClusterFullRelinkMap)
706 {
707  const auto &mappedsc = superClusterMap.find(superCluster);
708  //get index in output collection in order to keep track whether superCluster
709  //will be subject to full relinking
710  unsigned int mappedscidx = 0;
711  if (mappedsc==superClusterMap.end()) {
712  superClusters.push_back(*superCluster);
713  mappedscidx = superClusters.size() - 1;
714  superClusterMap[superCluster] = mappedscidx;
715  }
716  else {
717  mappedscidx = mappedsc->second;
718  }
719 
720  //additionally mark supercluster for full relinking
721  if (relink) superClusterFullRelinkMap.insert(mappedscidx);
722 }
723 
726  std::map<reco::ConversionRef, unsigned int>& conversionMap)
727 {
728  for (const auto& convref : convrefs) {
729  linkConversion(convref, conversions, conversionMap);
730  }
731 }
732 
734  const reco::GsfElectron& gsfElectron,
736  std::map<reco::ConversionRef, unsigned int>& conversionMap)
737 {
738  int index = 0;
739  for (const auto& conversion : *conversionHandle) {
740 
741  reco::ConversionRef convref(conversionHandle,index++);
742 
743  bool matched = ConversionTools::matchesConversion(gsfElectron,conversion,true,true);
744  if (!matched) continue;
745 
746  linkConversion(convref, conversions, conversionMap);
747  }
748 }
749 
751  const reco::SuperCluster& superCluster,
753  std::map<reco::ConversionRef, unsigned int>& conversionMap)
754 {
755  int index = 0;
756  for (const auto& conversion : *conversionHandle) {
757 
758  reco::ConversionRef convref(conversionHandle,index++);
759 
760  bool matched = ConversionTools::matchesConversion(superCluster,conversion,0.2);
761  if (!matched) continue;
762 
763  linkConversion(convref, conversions, conversionMap);
764  }
765 }
766 
769  std::map<reco::ConversionRef, unsigned int>& conversionMap)
770 {
771  if (!conversionMap.count(convref)) {
772  conversions.push_back(*convref);
773  conversionMap[convref] = conversions.size() - 1;
774  }
775 }
776 
778  reco::CaloClusterCollection& caloClusters,
779  std::map<reco::CaloClusterPtr, unsigned int>& caloClusterMap)
780 {
781  if (!caloClusterMap.count(caloCluster)) {
782  caloClusters.push_back(*caloCluster);
783  caloClusterMap[caloCluster] = caloClusters.size() - 1;
784  }
785 }
786 
788  reco::CaloClusterCollection& ebeeClusters,
789  std::map<reco::CaloClusterPtr, unsigned int>& ebeeClusterMap,
790  std::unordered_set<DetId>& rechitMap,
791  const edm::Handle<EcalRecHitCollection>& barrelHitHandle,
792  const edm::Handle<EcalRecHitCollection>& endcapHitHandle,
793  const CaloTopology *caloTopology,
794  reco::CaloClusterCollection& esClusters,
795  std::map<reco::CaloClusterPtr, unsigned int>& esClusterMap)
796 {
797  for (const auto& cluster : superCluster.clusters()) {
798  linkCaloCluster(cluster, ebeeClusters, ebeeClusterMap);
799 
800  for (const auto& hitfrac : cluster->hitsAndFractions()) {
801  rechitMap.insert(hitfrac.first);
802  }
803  //make sure to also take all hits in the 5x5 around the max energy xtal
804  bool barrel = cluster->hitsAndFractions().front().first.subdetId()==EcalBarrel;
805  const EcalRecHitCollection *rhcol = barrel ? barrelHitHandle.product() : endcapHitHandle.product();
806  DetId seed = EcalClusterTools::getMaximum(*cluster, rhcol).first;
807 
808  std::vector<DetId> dets5x5 = caloTopology->getSubdetectorTopology(DetId::Ecal, barrel ? EcalBarrel : EcalEndcap)->getWindow(seed,5,5);
809  for (const auto& detid : dets5x5) {
810  rechitMap.insert(detid);
811  }
812  }
813  for (const auto& cluster : superCluster.preshowerClusters()) {
814  linkCaloCluster(cluster, esClusters, esClusterMap);
815 
816  for (const auto& hitfrac : cluster->hitsAndFractions()) {
817  rechitMap.insert(hitfrac.first);
818  }
819  }
820 }
821 
822 
824  const std::map<reco::CaloClusterPtr, unsigned int>& ebeeClusterMap,
825  const std::map<reco::CaloClusterPtr, unsigned int>& esClusterMap,
826  const edm::OrphanHandle<reco::CaloClusterCollection>& outEBEEClusterHandle,
827  const edm::OrphanHandle<reco::CaloClusterCollection>& outESClusterHandle)
828 {
829  //remap seed cluster
830  const auto &seedmapped = ebeeClusterMap.find(superCluster.seed());
831  if (seedmapped != ebeeClusterMap.end()) {
832  //make new ptr
833  reco::CaloClusterPtr clusptr(outEBEEClusterHandle,seedmapped->second);
834  superCluster.setSeed(clusptr);
835  }
836 
837  //remap all clusters
839  for (const auto &cluster : superCluster.clusters()) {
840  const auto &clustermapped = ebeeClusterMap.find(cluster);
841  if (clustermapped != ebeeClusterMap.end()) {
842  //make new ptr
843  reco::CaloClusterPtr clusptr(outEBEEClusterHandle,clustermapped->second);
844  clusters.push_back(clusptr);
845  }
846  else {
847  //can only relink if all clusters are being relinked, so if one is missing, then skip the relinking completely
848  clusters.clear();
849  break;
850  }
851  }
852  if (!clusters.empty()) {
853  superCluster.setClusters(clusters);
854  }
855 
856  //remap preshower clusters
857  reco::CaloClusterPtrVector esclusters;
858  for (const auto& cluster : superCluster.preshowerClusters()) {
859  const auto &clustermapped = esClusterMap.find(cluster);
860  if (clustermapped != esClusterMap.end()) {
861  //make new ptr
862  reco::CaloClusterPtr clusptr(outESClusterHandle,clustermapped->second);
863  esclusters.push_back(clusptr);
864  }
865  else {
866  //can only relink if all clusters are being relinked, so if one is missing, then skip the relinking completely
867  esclusters.clear();
868  break;
869  }
870  }
871  if (!esclusters.empty()) {
872  superCluster.setPreshowerClusters(esclusters);
873  }
874 }
875 
876 template <typename T>
878  const std::map<reco::SuperClusterRef, unsigned int>& superClusterMap,
879  const edm::OrphanHandle<reco::SuperClusterCollection>& outSuperClusterHandle)
880 {
881  const auto &scmapped = superClusterMap.find(core.superCluster());
882  if (scmapped != superClusterMap.end()) {
883  //make new ref
884  reco::SuperClusterRef scref(outSuperClusterHandle,scmapped->second);
885  core.setSuperCluster(scref);
886  }
887 }
888 
890  const std::map<reco::GsfTrackRef, unsigned int>& gsfTrackMap,
891  const edm::OrphanHandle<reco::GsfTrackCollection>& outGsfTrackHandle)
892 {
893  const auto &gsftkmapped = gsfTrackMap.find(gsfElectronCore.gsfTrack());
894  if (gsftkmapped != gsfTrackMap.end()) {
895  reco::GsfTrackRef gsftkref(outGsfTrackHandle, gsftkmapped->second);
896  gsfElectronCore.setGsfTrack(gsftkref);
897  }
898 }
899 
901  const reco::ConversionRefVector& convrefs,
902  const std::map<reco::ConversionRef, unsigned int>& conversionMap,
903  const edm::OrphanHandle<reco::ConversionCollection> &outConversionHandle)
904 {
905  reco::ConversionRefVector outconvrefs;
906  for (const auto& convref : convrefs) {
907  const auto &convmapped = conversionMap.find(convref);
908  if (convmapped != conversionMap.end()) {
909  //make new ref
910  reco::ConversionRef outref(outConversionHandle,convmapped->second);
911  }
912  else {
913  //can only relink if all conversions are being relinked, so if one is missing, then skip the relinking completely
914  outconvrefs.clear();
915  break;
916  }
917  }
918  if (!outconvrefs.empty()) {
919  photonCore.setConversions(outconvrefs);
920  }
921 }
922 
924  const std::map<reco::PhotonCoreRef, unsigned int>& photonCoreMap,
925  const edm::OrphanHandle<reco::PhotonCoreCollection>& outPhotonCoreHandle)
926 {
927  const auto &coremapped = photonCoreMap.find(photon.photonCore());
928  if (coremapped != photonCoreMap.end()) {
929  //make new ref
930  reco::PhotonCoreRef coreref(outPhotonCoreHandle,coremapped->second);
931  photon.setPhotonCore(coreref);
932  }
933 }
934 
936  const std::map<reco::GsfElectronCoreRef, unsigned int>& gsfElectronCoreMap,
937  const edm::OrphanHandle<reco::GsfElectronCoreCollection>& outgsfElectronCoreHandle)
938 {
939  const auto &coremapped = gsfElectronCoreMap.find(gsfElectron.core());
940  if (coremapped != gsfElectronCoreMap.end()) {
941  //make new ref
942  reco::GsfElectronCoreRef coreref(outgsfElectronCoreHandle,coremapped->second);
943  gsfElectron.setCore(coreref);
944  }
945 }
const bool doPreshowerEcalHits_
void setPreshowerClusters(const CaloClusterPtrVector &clusters)
Definition: SuperCluster.h:105
void linkCaloClusters(const reco::SuperCluster &superCluster, reco::CaloClusterCollection &ebeeClusters, std::map< reco::CaloClusterPtr, unsigned int > &ebeeClusterMap, std::unordered_set< DetId > &rechitMap, const edm::Handle< EcalRecHitCollection > &barrelHitHandle, const edm::Handle< EcalRecHitCollection > &endcapHitHandle, const CaloTopology *caloTopology, reco::CaloClusterCollection &esClusters, std::map< reco::CaloClusterPtr, unsigned int > &esClusterMap)
void relinkGsfTrack(reco::GsfElectronCore &electroncore, const std::map< reco::GsfTrackRef, unsigned int > &gsfTrackMap, const edm::OrphanHandle< reco::GsfTrackCollection > &outGsfTrackHandle)
T getParameter(std::string const &) const
const StringCutObjectSelector< reco::Photon > relinkOOTPhotonSel_
static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectronT_
void setCore(const reco::GsfElectronCoreRef &core)
Definition: GsfElectron.h:181
const edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackT_
const StringCutObjectSelector< reco::Photon > slimRelinkPhotonSel_
void setGsfTrack(const GsfTrackRef &gsfTrack)
const edm::EDGetTokenT< reco::ConversionCollection > singleConversionT_
const std::vector< std::string > outPhotonIds_
~ReducedEGProducer() override
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > photonPFClusterIsoTs_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > gsfElectronPFClusterIsoTs_
bool empty() const
Is the RefVector empty.
Definition: PtrVectorBase.h:71
Definition: __init__.py:1
const GsfTrackRef & gsfTrack() const
const std::string outGsfTracks_
const StringCutObjectSelector< reco::GsfElectron > keepGsfElectronSel_
const std::string outOOTPhotons_
bool ev
Definition: config.py:1
const std::string outEBEEClusters_
void setSeed(const CaloClusterPtr &r)
list of used xtals by DetId // now inherited by CaloCluster
Definition: SuperCluster.h:96
const StringCutObjectSelector< reco::Photon > keepPhotonSel_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > photonPfCandMapT_
const CaloClusterPtrVector & clusters() const
const access to the cluster list itself
Definition: SuperCluster.h:69
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:104
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
const StringCutObjectSelector< reco::GsfElectron > relinkGsfElectronSel_
void setClusters(const CaloClusterPtrVector &clusters)
Definition: SuperCluster.h:99
void linkConversion(const reco::ConversionRef &convref, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > gsfElectronPfCandMapT_
const std::string outEBRecHits_
const std::string outESRecHits_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void relinkConversions(reco::PhotonCore &photonCore, const reco::ConversionRefVector &convrefs, const std::map< reco::ConversionRef, unsigned int > &conversionMap, const edm::OrphanHandle< reco::ConversionCollection > &outConversionHandle)
const edm::EDGetTokenT< EcalRecHitCollection > preshowerEcalHits_
void linkConversions(const reco::ConversionRefVector &convrefs, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
reco::PhotonCoreRef photonCore() const
returns a reference to the core photon object
Definition: Photon.h:50
const int keep
const std::vector< std::string > outGsfElectronIds_
void setPhotonCore(const reco::PhotonCoreRef &photonCore)
Definition: Photon.h:51
const std::string outSingleConversions_
const std::string outESClusters_
const std::string outOOTSuperClusters_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
const StringCutObjectSelector< reco::Photon > keepOOTPhotonSel_
const std::string outOOTESClusters_
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
void relinkGsfElectronCore(reco::GsfElectron &gsfElectron, const std::map< reco::GsfElectronCoreRef, unsigned int > &gsfElectronCoreMap, const edm::OrphanHandle< reco::GsfElectronCoreCollection > &outGsfElectronCoreHandle)
void linkConversionsByTrackRef(const edm::Handle< reco::ConversionCollection > &conversionHandle, const reco::GsfElectron &gsfElectron, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
void setConversions(const reco::ConversionRefVector &conversions)
Definition: PhotonCore.h:79
const std::string outOOTEBEEClusters_
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
const std::vector< std::string > outPhotonPFClusterIsos_
void linkSuperCluster(const reco::SuperClusterRef &superCluster, std::map< reco::SuperClusterRef, unsigned int > &superClusterMap, reco::SuperClusterCollection &superClusters, const bool relink, std::unordered_set< unsigned int > &superClusterFullRelinkMap)
void linkCore(const T &core, U &cores, std::map< T, unsigned int > &coreMap)
const StringCutObjectSelector< reco::Photon > relinkPhotonSel_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > gsfElectronIdTs_
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
const CaloClusterPtrVector & preshowerClusters() const
const access to the preshower cluster list itself
Definition: SuperCluster.h:72
void relinkCaloClusters(reco::SuperCluster &superCluster, const std::map< reco::CaloClusterPtr, unsigned int > &ebeeClusterMap, const std::map< reco::CaloClusterPtr, unsigned int > &esClusterMap, const edm::OrphanHandle< reco::CaloClusterCollection > &outEBEEClusterHandle, const edm::OrphanHandle< reco::CaloClusterCollection > &outESClusterHandle)
const std::string outPhotons_
const std::string outGsfElectronPfCandMap_
void relinkSuperCluster(T &core, const std::map< reco::SuperClusterRef, unsigned int > &superClusterMap, const edm::OrphanHandle< reco::SuperClusterCollection > &outSuperClusterHandle)
const std::string outGsfElectronCores_
Definition: DetId.h:18
const edm::EDGetTokenT< reco::PhotonCollection > photonT_
void relinkPhotonCore(reco::Photon &photon, const std::map< reco::PhotonCoreRef, unsigned int > &photonCoreMap, const edm::OrphanHandle< reco::PhotonCoreCollection > &outPhotonCoreHandle)
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
const std::vector< std::string > outGsfElectronPFClusterIsos_
const std::string outSuperClusters_
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
const std::string outConversions_
T const * product() const
Definition: Handle.h:81
void clear()
Clear the vector.
Definition: RefVector.h:147
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
const T & get() const
Definition: EventSetup.h:55
const std::string outGsfElectrons_
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:25
const StringCutObjectSelector< reco::GsfElectron > slimRelinkGsfElectronSel_
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
const std::string outPhotonCores_
void clear()
Clear the PtrVector.
Definition: PtrVectorBase.h:80
fixed size matrix
HLT enums.
void linkCaloCluster(const reco::CaloClusterPtr &caloCluster, reco::CaloClusterCollection &caloClusters, std::map< reco::CaloClusterPtr, unsigned int > &caloClusterMap)
const std::string outEERecHits_
const StringCutObjectSelector< reco::Photon > slimRelinkOOTPhotonSel_
void produce(edm::Event &evt, const edm::EventSetup &es) final
const std::string outPhotonPfCandMap_
const std::vector< std::string > outOOTPhotonPFClusterIsos_
const edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > ootPhotonPFClusterIsoTs_
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
size_t operator()(const DetId &id) const
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > photonIdTs_
const std::string outOOTPhotonCores_
long double T
const edm::EDGetTokenT< reco::PhotonCollection > ootPhotonT_
const edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
def move(src, dest)
Definition: eostools.py:510
ReducedEGProducer(const edm::ParameterSet &ps)
const edm::EDGetTokenT< reco::ConversionCollection > conversionT_