CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
ReducedEGProducer Class Reference

#include <ReducedEGProducer.h>

Inheritance diagram for ReducedEGProducer:
edm::stream::EDProducer<>

Public Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es) final
 
 ReducedEGProducer (const edm::ParameterSet &ps)
 
 ~ReducedEGProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void linkCaloCluster (const reco::CaloClusterPtr &caloCluster, reco::CaloClusterCollection &caloClusters, std::map< reco::CaloClusterPtr, unsigned int > &caloClusterMap)
 
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 linkConversion (const reco::ConversionRef &convref, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
 
void linkConversions (const reco::ConversionRefVector &convrefs, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
 
void linkConversionsByTrackRef (const edm::Handle< reco::ConversionCollection > &conversionHandle, const reco::GsfElectron &gsfElectron, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
 
void linkConversionsByTrackRef (const edm::Handle< reco::ConversionCollection > &conversionHandle, const reco::SuperCluster &superCluster, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
 
template<typename T , typename U >
void linkCore (const T &core, U &cores, std::map< T, unsigned int > &coreMap)
 
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 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)
 
void relinkConversions (reco::PhotonCore &photonCore, const reco::ConversionRefVector &convrefs, const std::map< reco::ConversionRef, unsigned int > &conversionMap, const edm::OrphanHandle< reco::ConversionCollection > &outConversionHandle)
 
void relinkGsfElectronCore (reco::GsfElectron &gsfElectron, const std::map< reco::GsfElectronCoreRef, unsigned int > &gsfElectronCoreMap, const edm::OrphanHandle< reco::GsfElectronCoreCollection > &outGsfElectronCoreHandle)
 
void relinkGsfTrack (reco::GsfElectronCore &electroncore, const std::map< reco::GsfTrackRef, unsigned int > &gsfTrackMap, const edm::OrphanHandle< reco::GsfTrackCollection > &outGsfTrackHandle)
 
void relinkPhotonCore (reco::Photon &photon, const std::map< reco::PhotonCoreRef, unsigned int > &photonCoreMap, const edm::OrphanHandle< reco::PhotonCoreCollection > &outPhotonCoreHandle)
 
template<typename T >
void relinkSuperCluster (T &core, const std::map< reco::SuperClusterRef, unsigned int > &superClusterMap, const edm::OrphanHandle< reco::SuperClusterCollection > &outSuperClusterHandle)
 
template<typename T >
void setToken (edm::EDGetTokenT< T > &token, const edm::ParameterSet &config, const std::string &name)
 

Static Private Member Functions

static void calibrateElectron (reco::GsfElectron &gsfElectron, const reco::GsfElectronRef &oldEleRef, const edm::ValueMap< float > &energyMap, const edm::ValueMap< float > &energyErrMap, const edm::ValueMap< float > &ecalEnergyMap, const edm::ValueMap< float > &ecalEnergyErrMap)
 
static void calibratePhoton (reco::Photon &photon, const reco::PhotonRef &oldPhoRef, const edm::ValueMap< float > &energyMap, const edm::ValueMap< float > &energyErrMap)
 

Private Attributes

const bool applyGsfElectronCalibOnData_
 
const bool applyGsfElectronCalibOnMC_
 
const bool applyPhotonCalibOnData_
 
const bool applyPhotonCalibOnMC_
 
const edm::EDGetTokenT< EcalRecHitCollectionbarrelEcalHits_
 
const edm::EDGetTokenT< reco::ConversionCollectionconversionT_
 
const bool doPreshowerEcalHits_
 
const edm::EDGetTokenT< EcalRecHitCollectionendcapEcalHits_
 
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEcalEnergyErrT_
 
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEcalEnergyT_
 
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEnergyErrT_
 
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEnergyT_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > gsfElectronFloatValueMapTs_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > gsfElectronIdTs_
 
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > gsfElectronPfCandMapT_
 
const edm::EDGetTokenT< reco::GsfElectronCollectiongsfElectronT_
 
const edm::EDGetTokenT< reco::GsfTrackCollectiongsfTrackT_
 
const StringCutObjectSelector< reco::GsfElectronkeepGsfElectronSel_
 
const StringCutObjectSelector< reco::PhotonkeepOOTPhotonSel_
 
const StringCutObjectSelector< reco::PhotonkeepPhotonSel_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > ootPhotonFloatValueMapTs_
 
const edm::EDGetTokenT< reco::PhotonCollectionootPhotonT_
 
const std::string outConversions_
 
const std::string outEBEEClusters_
 
const std::string outEBRecHits_
 
const std::string outEERecHits_
 
const std::string outESClusters_
 
const std::string outESRecHits_
 
const std::string outGsfElectronCores_
 
const std::vector< std::string > outGsfElectronFloatValueMaps_
 
const std::vector< std::string > outGsfElectronIds_
 
const std::string outGsfElectronPfCandMap_
 
const std::string outGsfElectrons_
 
const std::string outGsfTracks_
 
const std::string outOOTEBEEClusters_
 
const std::string outOOTESClusters_
 
const std::string outOOTPhotonCores_
 
const std::vector< std::string > outOOTPhotonFloatValueMaps_
 
const std::string outOOTPhotons_
 
const std::string outOOTSuperClusters_
 
const std::string outPhotonCores_
 
const std::vector< std::string > outPhotonFloatValueMaps_
 
const std::vector< std::string > outPhotonIds_
 
const std::string outPhotonPfCandMap_
 
const std::string outPhotons_
 
const std::string outSingleConversions_
 
const std::string outSuperClusters_
 
edm::EDGetTokenT< edm::ValueMap< float > > photonCalibEnergyErrT_
 
edm::EDGetTokenT< edm::ValueMap< float > > photonCalibEnergyT_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > photonFloatValueMapTs_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > photonIdTs_
 
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > photonPfCandMapT_
 
const edm::EDGetTokenT< reco::PhotonCollectionphotonT_
 
const edm::EDGetTokenT< EcalRecHitCollectionpreshowerEcalHits_
 
const StringCutObjectSelector< reco::GsfElectronrelinkGsfElectronSel_
 
const StringCutObjectSelector< reco::PhotonrelinkOOTPhotonSel_
 
const StringCutObjectSelector< reco::PhotonrelinkPhotonSel_
 
const edm::EDGetTokenT< reco::ConversionCollectionsingleConversionT_
 
const StringCutObjectSelector< reco::GsfElectronslimRelinkGsfElectronSel_
 
const StringCutObjectSelector< reco::PhotonslimRelinkOOTPhotonSel_
 
const StringCutObjectSelector< reco::PhotonslimRelinkPhotonSel_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Select subset of electrons and photons from input collections and produced consistently relinked output collections including associated SuperClusters, CaloClusters and ecal RecHits

Author
J.Bendavid (CERN) : K. McDermott(Cornell) : refactored code + out of time photons

Definition at line 47 of file ReducedEGProducer.h.

Constructor & Destructor Documentation

ReducedEGProducer::ReducedEGProducer ( const edm::ParameterSet ps)

Definition at line 47 of file ReducedEGProducer.cc.

References applyGsfElectronCalibOnData_, applyGsfElectronCalibOnMC_, applyPhotonCalibOnData_, applyPhotonCalibOnMC_, doPreshowerEcalHits_, edm::ParameterSet::getParameter(), gsfElectronCalibEcalEnergyErrT_, gsfElectronCalibEcalEnergyT_, gsfElectronCalibEnergyErrT_, gsfElectronCalibEnergyT_, gsfElectronFloatValueMapTs_, gsfElectronIdTs_, ootPhotonFloatValueMapTs_, outConversions_, outEBEEClusters_, outEBRecHits_, outEERecHits_, outESClusters_, outESRecHits_, outGsfElectronCores_, outGsfElectronFloatValueMaps_, outGsfElectronIds_, outGsfElectronPfCandMap_, outGsfElectrons_, outGsfTracks_, outOOTEBEEClusters_, outOOTESClusters_, outOOTPhotonCores_, outOOTPhotonFloatValueMaps_, outOOTPhotons_, outOOTSuperClusters_, outPhotonCores_, outPhotonFloatValueMaps_, outPhotonIds_, outPhotonPfCandMap_, outPhotons_, outSingleConversions_, outSuperClusters_, photonCalibEnergyErrT_, photonCalibEnergyT_, photonFloatValueMapTs_, photonIdTs_, setToken(), AlCaHLTBitMon_QueryRunRegistry::string, and GlobalPosition_Frontier_DevDB_cff::tag.

47  :
48  photonT_(consumes<reco::PhotonCollection>(config.getParameter<edm::InputTag>("photons"))),
49  ootPhotonT_(consumes<reco::PhotonCollection>(config.getParameter<edm::InputTag>("ootPhotons"))),
50  gsfElectronT_(consumes<reco::GsfElectronCollection>(config.getParameter<edm::InputTag>("gsfElectrons"))),
51  gsfTrackT_(consumes<reco::GsfTrackCollection>(config.getParameter<edm::InputTag>("gsfTracks"))),
52  conversionT_(consumes<reco::ConversionCollection>(config.getParameter<edm::InputTag>("conversions"))),
53  singleConversionT_(consumes<reco::ConversionCollection>(config.getParameter<edm::InputTag>("singleConversions"))),
54  barrelEcalHits_(consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("barrelEcalHits"))),
55  endcapEcalHits_(consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("endcapEcalHits"))),
56  doPreshowerEcalHits_(!config.getParameter<edm::InputTag>("preshowerEcalHits").label().empty()),
57  preshowerEcalHits_(doPreshowerEcalHits_ ? consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("preshowerEcalHits")) : edm::EDGetTokenT<EcalRecHitCollection>()),
58  photonPfCandMapT_(consumes<edm::ValueMap<std::vector<reco::PFCandidateRef> > >(config.getParameter<edm::InputTag>("photonsPFValMap"))),
59  gsfElectronPfCandMapT_(consumes<edm::ValueMap<std::vector<reco::PFCandidateRef> > >(config.getParameter<edm::InputTag>("gsfElectronsPFValMap"))),
60  //calibration flags
61  applyPhotonCalibOnData_(config.getParameter<bool>("applyPhotonCalibOnData")),
62  applyPhotonCalibOnMC_(config.getParameter<bool>("applyPhotonCalibOnMC")),
63  applyGsfElectronCalibOnData_(config.getParameter<bool>("applyGsfElectronCalibOnData")),
64  applyGsfElectronCalibOnMC_(config.getParameter<bool>("applyGsfElectronCalibOnMC")),
65  //output collections
66  outPhotons_("reducedGedPhotons"),
67  outPhotonCores_("reducedGedPhotonCores"),
68  outOOTPhotons_("reducedOOTPhotons"),
69  outOOTPhotonCores_("reducedOOTPhotonCores"),
70  outGsfElectrons_("reducedGedGsfElectrons"),
71  outGsfElectronCores_("reducedGedGsfElectronCores"),
72  outGsfTracks_("reducedGsfTracks"),
73  outConversions_("reducedConversions"),
74  outSingleConversions_("reducedSingleLegConversions"),
75  outSuperClusters_("reducedSuperClusters"),
76  outEBEEClusters_("reducedEBEEClusters"),
77  outESClusters_("reducedESClusters"),
78  outOOTSuperClusters_("reducedOOTSuperClusters"),
79  outOOTEBEEClusters_("reducedOOTEBEEClusters"),
80  outOOTESClusters_("reducedOOTESClusters"),
81  outEBRecHits_("reducedEBRecHits"),
82  outEERecHits_("reducedEERecHits"),
83  outESRecHits_("reducedESRecHits"),
84  outPhotonPfCandMap_("reducedPhotonPfCandMap"),
85  outGsfElectronPfCandMap_("reducedGsfElectronPfCandMap"),
86  outPhotonIds_(config.getParameter<std::vector<std::string> >("photonIDOutput")),
87  outGsfElectronIds_(config.getParameter<std::vector<std::string> >("gsfElectronIDOutput")),
88  outPhotonFloatValueMaps_(config.getParameter<std::vector<std::string> >("photonFloatValueMapOutput")),
89  outOOTPhotonFloatValueMaps_(config.getParameter<std::vector<std::string> >("ootPhotonFloatValueMapOutput")),
90  outGsfElectronFloatValueMaps_(config.getParameter<std::vector<std::string> >("gsfElectronFloatValueMapOutput")),
91  keepPhotonSel_(config.getParameter<std::string>("keepPhotons")),
92  slimRelinkPhotonSel_(config.getParameter<std::string>("slimRelinkPhotons")),
93  relinkPhotonSel_(config.getParameter<std::string>("relinkPhotons")),
94  keepOOTPhotonSel_(config.getParameter<std::string>("keepOOTPhotons")),
95  slimRelinkOOTPhotonSel_(config.getParameter<std::string>("slimRelinkOOTPhotons")),
96  relinkOOTPhotonSel_(config.getParameter<std::string>("relinkOOTPhotons")),
97  keepGsfElectronSel_(config.getParameter<std::string>("keepGsfElectrons")),
98  slimRelinkGsfElectronSel_(config.getParameter<std::string>("slimRelinkGsfElectrons")),
99  relinkGsfElectronSel_(config.getParameter<std::string>("relinkGsfElectrons"))
100 {
101  const std::vector<edm::InputTag>& photonidinputs =
102  config.getParameter<std::vector<edm::InputTag> >("photonIDSources");
103  for (const edm::InputTag &tag : photonidinputs) {
104  photonIdTs_.emplace_back(consumes<edm::ValueMap<bool> >(tag));
105  }
106 
107  const std::vector<edm::InputTag>& gsfelectronidinputs =
108  config.getParameter<std::vector<edm::InputTag> >("gsfElectronIDSources");
109  for (const edm::InputTag &tag : gsfelectronidinputs) {
110  gsfElectronIdTs_.emplace_back(consumes<edm::ValueMap<float> >(tag));
111  }
112 
113  const std::vector<edm::InputTag>& photonpfclusterisoinputs =
114  config.getParameter<std::vector<edm::InputTag> >("photonFloatValueMapSources");
115  for (const edm::InputTag &tag : photonpfclusterisoinputs) {
116  photonFloatValueMapTs_.emplace_back(consumes<edm::ValueMap<float> >(tag));
117  }
118 
119  const std::vector<edm::InputTag>& ootphotonpfclusterisoinputs =
120  config.getParameter<std::vector<edm::InputTag> >("ootPhotonFloatValueMapSources");
121  for (const edm::InputTag &tag : ootphotonpfclusterisoinputs) {
122  ootPhotonFloatValueMapTs_.emplace_back(consumes<edm::ValueMap<float> >(tag));
123  }
124 
125  const std::vector<edm::InputTag>& gsfelectronpfclusterisoinputs =
126  config.getParameter<std::vector<edm::InputTag> >("gsfElectronFloatValueMapSources");
127  for (const edm::InputTag &tag : gsfelectronpfclusterisoinputs) {
128  gsfElectronFloatValueMapTs_.emplace_back(consumes<edm::ValueMap<float> >(tag));
129  }
130 
132  setToken(photonCalibEnergyT_,config,"photonCalibEnergySource");
133  setToken(photonCalibEnergyErrT_,config,"photonCalibEnergyErrSource");
134  }
136  setToken(gsfElectronCalibEnergyT_,config,"gsfElectronCalibEnergySource");
137  setToken(gsfElectronCalibEnergyErrT_,config,"gsfElectronCalibEnergyErrSource");
138  setToken(gsfElectronCalibEcalEnergyT_,config,"gsfElectronCalibEcalEnergySource");
139  setToken(gsfElectronCalibEcalEnergyErrT_,config,"gsfElectronCalibEcalEnergyErrSource");
140  }
141 
142  produces< reco::PhotonCollection >(outPhotons_);
143  produces< reco::PhotonCoreCollection >(outPhotonCores_);
144  produces< reco::PhotonCollection >(outOOTPhotons_);
145  produces< reco::PhotonCoreCollection >(outOOTPhotonCores_);
146  produces< reco::GsfElectronCollection >(outGsfElectrons_);
147  produces< reco::GsfElectronCoreCollection >(outGsfElectronCores_);
148  produces< reco::GsfTrackCollection >(outGsfTracks_);
149  produces< reco::ConversionCollection >(outConversions_);
150  produces< reco::ConversionCollection >(outSingleConversions_);
151  produces< reco::SuperClusterCollection >(outSuperClusters_);
152  produces< reco::CaloClusterCollection >(outEBEEClusters_);
153  produces< reco::CaloClusterCollection >(outESClusters_);
154  produces< reco::SuperClusterCollection >(outOOTSuperClusters_);
155  produces< reco::CaloClusterCollection >(outOOTEBEEClusters_);
156  produces< reco::CaloClusterCollection >(outOOTESClusters_);
157  produces< EcalRecHitCollection >(outEBRecHits_);
158  produces< EcalRecHitCollection >(outEERecHits_);
159  if (doPreshowerEcalHits_) produces< EcalRecHitCollection >(outESRecHits_);
160  produces< edm::ValueMap<std::vector<reco::PFCandidateRef> > >(outPhotonPfCandMap_);
161  produces< edm::ValueMap<std::vector<reco::PFCandidateRef> > >(outGsfElectronPfCandMap_);
162  for (const std::string &outid : outPhotonIds_) {
163  produces< edm::ValueMap<bool> >(outid);
164  }
165  for (const std::string &outid : outGsfElectronIds_) {
166  produces< edm::ValueMap<float> >(outid);
167  }
168  for (const std::string &outid : outPhotonFloatValueMaps_) {
169  produces< edm::ValueMap<float> >(outid);
170  }
171  for (const std::string &outid : outOOTPhotonFloatValueMaps_) {
172  produces< edm::ValueMap<float> >(outid);
173  }
174  for (const std::string &outid : outGsfElectronFloatValueMaps_) {
175  produces< edm::ValueMap<float> >(outid);
176  }
177 }
const bool doPreshowerEcalHits_
const StringCutObjectSelector< reco::Photon > relinkOOTPhotonSel_
const edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectronT_
const bool applyPhotonCalibOnData_
const edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackT_
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEnergyT_
const StringCutObjectSelector< reco::Photon > slimRelinkPhotonSel_
const edm::EDGetTokenT< reco::ConversionCollection > singleConversionT_
const std::vector< std::string > outPhotonIds_
const std::vector< std::string > outOOTPhotonFloatValueMaps_
edm::EDGetTokenT< edm::ValueMap< float > > photonCalibEnergyT_
const std::vector< std::string > outPhotonFloatValueMaps_
const std::string outGsfTracks_
void setToken(edm::EDGetTokenT< T > &token, const edm::ParameterSet &config, const std::string &name)
const StringCutObjectSelector< reco::GsfElectron > keepGsfElectronSel_
const std::string outOOTPhotons_
Definition: config.py:1
const std::string outEBEEClusters_
const StringCutObjectSelector< reco::Photon > keepPhotonSel_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > photonPfCandMapT_
const bool applyGsfElectronCalibOnData_
edm::EDGetTokenT< edm::ValueMap< float > > photonCalibEnergyErrT_
const StringCutObjectSelector< reco::GsfElectron > relinkGsfElectronSel_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > gsfElectronPfCandMapT_
const std::string outEBRecHits_
const std::string outESRecHits_
const edm::EDGetTokenT< EcalRecHitCollection > preshowerEcalHits_
const std::vector< std::string > outGsfElectronIds_
const std::string outSingleConversions_
const std::string outESClusters_
const std::string outOOTSuperClusters_
const StringCutObjectSelector< reco::Photon > keepOOTPhotonSel_
const std::string outOOTESClusters_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > gsfElectronFloatValueMapTs_
const std::string outOOTEBEEClusters_
const StringCutObjectSelector< reco::Photon > relinkPhotonSel_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > gsfElectronIdTs_
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEnergyErrT_
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
const bool applyPhotonCalibOnMC_
const std::string outPhotons_
const std::string outGsfElectronPfCandMap_
const std::string outGsfElectronCores_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > photonFloatValueMapTs_
const edm::EDGetTokenT< reco::PhotonCollection > photonT_
const std::string outSuperClusters_
const std::string outConversions_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > ootPhotonFloatValueMapTs_
const std::string outGsfElectrons_
const StringCutObjectSelector< reco::GsfElectron > slimRelinkGsfElectronSel_
std::string const & label() const
Definition: InputTag.h:36
const std::string outPhotonCores_
fixed size matrix
HLT enums.
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEcalEnergyErrT_
const std::string outEERecHits_
const StringCutObjectSelector< reco::Photon > slimRelinkOOTPhotonSel_
const std::vector< std::string > outGsfElectronFloatValueMaps_
const std::string outPhotonPfCandMap_
const edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > photonIdTs_
const std::string outOOTPhotonCores_
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEcalEnergyT_
const edm::EDGetTokenT< reco::PhotonCollection > ootPhotonT_
const edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
const bool applyGsfElectronCalibOnMC_
const edm::EDGetTokenT< reco::ConversionCollection > conversionT_
ReducedEGProducer::~ReducedEGProducer ( )
override

Definition at line 179 of file ReducedEGProducer.cc.

180 {
181 }

Member Function Documentation

void ReducedEGProducer::calibrateElectron ( reco::GsfElectron gsfElectron,
const reco::GsfElectronRef oldEleRef,
const edm::ValueMap< float > &  energyMap,
const edm::ValueMap< float > &  energyErrMap,
const edm::ValueMap< float > &  ecalEnergyMap,
const edm::ValueMap< float > &  ecalEnergyErrMap 
)
staticprivate

Definition at line 1003 of file ReducedEGProducer.cc.

References corr, reco::GsfElectron::correctMomentum(), reco::GsfElectron::p4(), reco::GsfElectron::setCorrectedEcalEnergy(), reco::GsfElectron::setCorrectedEcalEnergyError(), and reco::GsfElectron::trackMomentumError().

Referenced by produce().

1009 {
1010  const float newEnergy = energyMap[oldEleRef];
1011  const float newEnergyErr = energyErrMap[oldEleRef];
1012  const float newEcalEnergy = ecalEnergyMap[oldEleRef];
1013  const float newEcalEnergyErr = ecalEnergyErrMap[oldEleRef];
1014 
1015  //make a copy of this as the setCorrectedEcalEnergy call with modifiy the electrons p4
1016  const math::XYZTLorentzVector oldP4 = electron.p4();
1017  const float corr = newEnergy / oldP4.E();
1018 
1019  electron.setCorrectedEcalEnergy(newEcalEnergy);
1020  electron.setCorrectedEcalEnergyError(newEcalEnergyErr);
1021 
1023  oldP4.y() * corr,
1024  oldP4.z() * corr,
1025  newEnergy);
1026  electron.correctMomentum(newP4, electron.trackMomentumError(), newEnergyErr);
1027 
1028 }
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
JetCorrectorParameters corr
Definition: classes.h:5
void ReducedEGProducer::calibratePhoton ( reco::Photon photon,
const reco::PhotonRef oldPhoRef,
const edm::ValueMap< float > &  energyMap,
const edm::ValueMap< float > &  energyErrMap 
)
staticprivate

Definition at line 992 of file ReducedEGProducer.cc.

References reco::Photon::setCorrectedEnergy().

Referenced by produce().

996 {
997  float newEnergy = energyMap[oldPhoRef];
998  float newEnergyErr = energyErrMap[oldPhoRef];
999  photon.setCorrectedEnergy(reco::Photon::P4type::regression2, newEnergy, newEnergyErr, true);
1000 
1001 }
void setCorrectedEnergy(P4type type, float E, float dE, bool toCand=true)
void ReducedEGProducer::linkCaloCluster ( const reco::CaloClusterPtr caloCluster,
reco::CaloClusterCollection caloClusters,
std::map< reco::CaloClusterPtr, unsigned int > &  caloClusterMap 
)
private

Definition at line 822 of file ReducedEGProducer.cc.

Referenced by linkCaloClusters(), and produce().

825 {
826  if (!caloClusterMap.count(caloCluster)) {
827  caloClusters.push_back(*caloCluster);
828  caloClusterMap[caloCluster] = caloClusters.size() - 1;
829  }
830 }
void ReducedEGProducer::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 
)
private

Definition at line 832 of file ReducedEGProducer.cc.

References Reference_intrackfit_cff::barrel, reco::SuperCluster::clusters(), DetId::Ecal, EcalBarrel, EcalEndcap, CaloTopology::getSubdetectorTopology(), CaloSubdetectorTopology::getWindow(), linkCaloCluster(), reco::SuperCluster::preshowerClusters(), edm::Handle< T >::product(), and SurveyInfoScenario_cff::seed.

Referenced by produce().

841 {
842  for (const auto& cluster : superCluster.clusters()) {
843  linkCaloCluster(cluster, ebeeClusters, ebeeClusterMap);
844 
845  for (const auto& hitfrac : cluster->hitsAndFractions()) {
846  rechitMap.insert(hitfrac.first);
847  }
848  //make sure to also take all hits in the 5x5 around the max energy xtal
849  bool barrel = cluster->hitsAndFractions().front().first.subdetId()==EcalBarrel;
850  const EcalRecHitCollection *rhcol = barrel ? barrelHitHandle.product() : endcapHitHandle.product();
851  DetId seed = EcalClusterTools::getMaximum(*cluster, rhcol).first;
852 
853  std::vector<DetId> dets5x5 = caloTopology->getSubdetectorTopology(DetId::Ecal, barrel ? EcalBarrel : EcalEndcap)->getWindow(seed,5,5);
854  for (const auto& detid : dets5x5) {
855  rechitMap.insert(detid);
856  }
857  }
858  for (const auto& cluster : superCluster.preshowerClusters()) {
859  linkCaloCluster(cluster, esClusters, esClusterMap);
860 
861  for (const auto& hitfrac : cluster->hitsAndFractions()) {
862  rechitMap.insert(hitfrac.first);
863  }
864  }
865 }
const CaloClusterPtrVector & clusters() const
const access to the cluster list itself
Definition: SuperCluster.h:69
const CaloClusterPtrVector & preshowerClusters() const
const access to the preshower cluster list itself
Definition: SuperCluster.h:72
Definition: DetId.h:18
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
T const * product() const
Definition: Handle.h:81
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:25
void linkCaloCluster(const reco::CaloClusterPtr &caloCluster, reco::CaloClusterCollection &caloClusters, std::map< reco::CaloClusterPtr, unsigned int > &caloClusterMap)
void ReducedEGProducer::linkConversion ( const reco::ConversionRef convref,
reco::ConversionCollection conversions,
std::map< reco::ConversionRef, unsigned int > &  conversionMap 
)
private

Definition at line 812 of file ReducedEGProducer.cc.

Referenced by linkConversions(), and linkConversionsByTrackRef().

815 {
816  if (!conversionMap.count(convref)) {
817  conversions.push_back(*convref);
818  conversionMap[convref] = conversions.size() - 1;
819  }
820 }
void ReducedEGProducer::linkConversions ( const reco::ConversionRefVector convrefs,
reco::ConversionCollection conversions,
std::map< reco::ConversionRef, unsigned int > &  conversionMap 
)
private

Definition at line 769 of file ReducedEGProducer.cc.

References linkConversion().

Referenced by produce().

772 {
773  for (const auto& convref : convrefs) {
774  linkConversion(convref, conversions, conversionMap);
775  }
776 }
void linkConversion(const reco::ConversionRef &convref, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
void ReducedEGProducer::linkConversionsByTrackRef ( const edm::Handle< reco::ConversionCollection > &  conversionHandle,
const reco::GsfElectron gsfElectron,
reco::ConversionCollection conversions,
std::map< reco::ConversionRef, unsigned int > &  conversionMap 
)
private

Definition at line 778 of file ReducedEGProducer.cc.

References edm::conversion(), linkConversion(), electrons_cff::matched, and ConversionTools::matchesConversion().

Referenced by produce().

782 {
783  int index = 0;
784  for (const auto& conversion : *conversionHandle) {
785 
786  reco::ConversionRef convref(conversionHandle,index++);
787 
788  bool matched = ConversionTools::matchesConversion(gsfElectron,conversion,true,true);
789  if (!matched) continue;
790 
791  linkConversion(convref, conversions, conversionMap);
792  }
793 }
static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false)
void linkConversion(const reco::ConversionRef &convref, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
void ReducedEGProducer::linkConversionsByTrackRef ( const edm::Handle< reco::ConversionCollection > &  conversionHandle,
const reco::SuperCluster superCluster,
reco::ConversionCollection conversions,
std::map< reco::ConversionRef, unsigned int > &  conversionMap 
)
private

Definition at line 795 of file ReducedEGProducer.cc.

References edm::conversion(), linkConversion(), electrons_cff::matched, and ConversionTools::matchesConversion().

799 {
800  int index = 0;
801  for (const auto& conversion : *conversionHandle) {
802 
803  reco::ConversionRef convref(conversionHandle,index++);
804 
805  bool matched = ConversionTools::matchesConversion(superCluster,conversion,0.2);
806  if (!matched) continue;
807 
808  linkConversion(convref, conversions, conversionMap);
809  }
810 }
static bool matchesConversion(const reco::GsfElectron &ele, const reco::Conversion &conv, bool allowCkfMatch=true, bool allowAmbiguousGsfMatch=false)
void linkConversion(const reco::ConversionRef &convref, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
template<typename T , typename U >
void ReducedEGProducer::linkCore ( const T core,
U &  cores,
std::map< T, unsigned int > &  coreMap 
)
private

Definition at line 738 of file ReducedEGProducer.cc.

Referenced by produce().

739 {
740  if (!coreMap.count(core)) {
741  cores.push_back(*core);
742  coreMap[core] = cores.size() - 1;
743  }
744 }
Definition: __init__.py:1
void ReducedEGProducer::linkSuperCluster ( const reco::SuperClusterRef superCluster,
std::map< reco::SuperClusterRef, unsigned int > &  superClusterMap,
reco::SuperClusterCollection superClusters,
const bool  relink,
std::unordered_set< unsigned int > &  superClusterFullRelinkMap 
)
private

Definition at line 746 of file ReducedEGProducer.cc.

Referenced by produce().

751 {
752  const auto &mappedsc = superClusterMap.find(superCluster);
753  //get index in output collection in order to keep track whether superCluster
754  //will be subject to full relinking
755  unsigned int mappedscidx = 0;
756  if (mappedsc==superClusterMap.end()) {
757  superClusters.push_back(*superCluster);
758  mappedscidx = superClusters.size() - 1;
759  superClusterMap[superCluster] = mappedscidx;
760  }
761  else {
762  mappedscidx = mappedsc->second;
763  }
764 
765  //additionally mark supercluster for full relinking
766  if (relink) superClusterFullRelinkMap.insert(mappedscidx);
767 }
void ReducedEGProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
final

Definition at line 183 of file ReducedEGProducer.cc.

References applyGsfElectronCalibOnData_, applyGsfElectronCalibOnMC_, applyPhotonCalibOnData_, applyPhotonCalibOnMC_, barrelEcalHits_, calibrateElectron(), calibratePhoton(), printConversionInfo::conversionHandle, conversions_cfi::conversions, conversionT_, doPreshowerEcalHits_, endcapEcalHits_, ev, Exception, objects.autophobj::filler, edm::EventSetup::get(), edm::Event::getByToken(), gsfElectronCalibEcalEnergyErrT_, gsfElectronCalibEcalEnergyT_, gsfElectronCalibEnergyErrT_, gsfElectronCalibEnergyT_, gsfElectronCores_cfi::gsfElectronCores, gsfElectronFloatValueMapTs_, gsfElectronIdTs_, gsfElectronPfCandMapT_, gsfElectrons_cfi::gsfElectrons, gsfElectronT_, gedGsfElectronCores_cfi::gsfTracks, gsfTrackT_, edm::EventBase::isRealData(), keep, keepGsfElectronSel_, keepOOTPhotonSel_, keepPhotonSel_, linkCaloCluster(), linkCaloClusters(), linkConversions(), linkConversionsByTrackRef(), linkCore(), linkSuperCluster(), eostools::move(), ootPhotonCore_cff::ootPhotonCore, ootPhotonFloatValueMapTs_, ootPhotons_cff::ootPhotons, ootPhotonT_, outConversions_, outEBEEClusters_, outEBRecHits_, outEERecHits_, outESClusters_, outESRecHits_, outGsfElectronCores_, outGsfElectronFloatValueMaps_, outGsfElectronIds_, outGsfElectronPfCandMap_, outGsfElectrons_, outGsfTracks_, outOOTEBEEClusters_, outOOTESClusters_, outOOTPhotonCores_, outOOTPhotonFloatValueMaps_, outOOTPhotons_, outOOTSuperClusters_, outPhotonCores_, outPhotonFloatValueMaps_, outPhotonIds_, outPhotonPfCandMap_, outPhotons_, outSingleConversions_, outSuperClusters_, muons2muons_cfi::photon, photonCalibEnergyErrT_, photonCalibEnergyT_, photonCore_cfi::photonCore, photonFloatValueMapTs_, photonIdTs_, photonPfCandMapT_, nano_cff::photons, photonT_, preshowerEcalHits_, edm::Event::put(), relinkCaloClusters(), relinkConversions(), relinkGsfElectronCore(), relinkGsfElectronSel_, relinkGsfTrack(), relinkOOTPhotonSel_, relinkPhotonCore(), relinkPhotonSel_, relinkSuperCluster(), reducedEgamma_cfi::singleConversions, singleConversionT_, slimRelinkGsfElectronSel_, slimRelinkOOTPhotonSel_, slimRelinkPhotonSel_, AlCaHLTBitMon_QueryRunRegistry::string, and create_public_pileup_plots::vals.

183  {
184 
185  //get input collections
186 
187 
189  theEvent.getByToken(photonT_, photonHandle);
190 
191  edm::Handle<reco::PhotonCollection> ootPhotonHandle;
192  theEvent.getByToken(ootPhotonT_, ootPhotonHandle);
193 
195  theEvent.getByToken(gsfElectronT_, gsfElectronHandle);
196 
198  theEvent.getByToken(gsfTrackT_, gsfTrackHandle);
199 
201  theEvent.getByToken(conversionT_, conversionHandle);
202 
203  edm::Handle<reco::ConversionCollection> singleConversionHandle;
204  theEvent.getByToken(singleConversionT_, singleConversionHandle);
205 
206  edm::Handle<EcalRecHitCollection> barrelHitHandle;
207  theEvent.getByToken(barrelEcalHits_, barrelHitHandle);
208 
209  edm::Handle<EcalRecHitCollection> endcapHitHandle;
210  theEvent.getByToken(endcapEcalHits_, endcapHitHandle);
211 
212  edm::Handle<EcalRecHitCollection> preshowerHitHandle;
213  if (doPreshowerEcalHits_) theEvent.getByToken(preshowerEcalHits_, preshowerHitHandle);
214 
216  theEvent.getByToken(photonPfCandMapT_, photonPfCandMapHandle);
217 
219  theEvent.getByToken(gsfElectronPfCandMapT_, gsfElectronPfCandMapHandle);
220 
221  std::vector<edm::Handle<edm::ValueMap<bool> > > photonIdHandles(photonIdTs_.size());
222  int index = 0; // universal index for range based loops
223  for (const auto& photonIdT : photonIdTs_) {
224  theEvent.getByToken(photonIdT,photonIdHandles[index++]);
225  }
226 
227  std::vector<edm::Handle<edm::ValueMap<float> > > gsfElectronIdHandles(gsfElectronIdTs_.size());
228  index = 0;
229  for (const auto& gsfElectronIdT : gsfElectronIdTs_) {
230  theEvent.getByToken(gsfElectronIdT,gsfElectronIdHandles[index++]);
231  }
232 
233  std::vector<edm::Handle<edm::ValueMap<float> > > photonFloatValueMapHandles(photonFloatValueMapTs_.size());
234  index = 0;
235  for (const auto& photonFloatValueMapT : photonFloatValueMapTs_) {
236  theEvent.getByToken(photonFloatValueMapT,photonFloatValueMapHandles[index++]);
237  }
238 
239  std::vector<edm::Handle<edm::ValueMap<float> > > ootPhotonFloatValueMapHandles(ootPhotonFloatValueMapTs_.size());
240  index = 0;
241  for (const auto& ootPhotonFloatValueMapT : ootPhotonFloatValueMapTs_) {
242  theEvent.getByToken(ootPhotonFloatValueMapT,ootPhotonFloatValueMapHandles[index++]);
243  }
244 
245  std::vector<edm::Handle<edm::ValueMap<float> > > gsfElectronFloatValueMapHandles(gsfElectronFloatValueMapTs_.size());
246  index = 0;
247  for (const auto& gsfElectronFloatValueMapT : gsfElectronFloatValueMapTs_) {
248  theEvent.getByToken(gsfElectronFloatValueMapT,gsfElectronFloatValueMapHandles[index++]);
249  }
250 
251 
252  edm::Handle<edm::ValueMap<float> > gsfElectronCalibEnergyHandle;
253  edm::Handle<edm::ValueMap<float> > gsfElectronCalibEnergyErrHandle;
254  edm::Handle<edm::ValueMap<float> > gsfElectronCalibEcalEnergyHandle;
255  edm::Handle<edm::ValueMap<float> > gsfElectronCalibEcalEnergyErrHandle;
257  theEvent.getByToken(gsfElectronCalibEnergyT_,gsfElectronCalibEnergyHandle);
258  theEvent.getByToken(gsfElectronCalibEnergyErrT_,gsfElectronCalibEnergyErrHandle);
259  theEvent.getByToken(gsfElectronCalibEcalEnergyT_,gsfElectronCalibEcalEnergyHandle);
260  theEvent.getByToken(gsfElectronCalibEcalEnergyErrT_,gsfElectronCalibEcalEnergyErrHandle);
261  }
262  edm::Handle<edm::ValueMap<float> > photonCalibEnergyHandle;
263  edm::Handle<edm::ValueMap<float> > photonCalibEnergyErrHandle;
265  theEvent.getByToken(photonCalibEnergyT_,photonCalibEnergyHandle);
266  theEvent.getByToken(photonCalibEnergyErrT_,photonCalibEnergyErrHandle);
267  }
268 
269  edm::ESHandle<CaloTopology> theCaloTopology;
270  theEventSetup.get<CaloTopologyRecord>().get(theCaloTopology);
271  const CaloTopology *caloTopology = & (*theCaloTopology);
272 
273  //initialize output collections
274  auto photons = std::make_unique<reco::PhotonCollection>();
275  auto photonCores = std::make_unique<reco::PhotonCoreCollection>();
276  auto ootPhotons = std::make_unique<reco::PhotonCollection>();
277  auto ootPhotonCores = std::make_unique<reco::PhotonCoreCollection>();
278  auto gsfElectrons = std::make_unique<reco::GsfElectronCollection>();
279  auto gsfElectronCores = std::make_unique<reco::GsfElectronCoreCollection>();
280  auto gsfTracks = std::make_unique<reco::GsfTrackCollection>();
281  auto conversions = std::make_unique<reco::ConversionCollection>();
282  auto singleConversions = std::make_unique<reco::ConversionCollection>();
283  auto superClusters = std::make_unique<reco::SuperClusterCollection>();
284  auto ebeeClusters = std::make_unique<reco::CaloClusterCollection>();
285  auto esClusters = std::make_unique<reco::CaloClusterCollection>();
286  auto ootSuperClusters = std::make_unique<reco::SuperClusterCollection>();
287  auto ootEbeeClusters = std::make_unique<reco::CaloClusterCollection>();
288  auto ootEsClusters = std::make_unique<reco::CaloClusterCollection>();
289  auto ebRecHits = std::make_unique<EcalRecHitCollection>();
290  auto eeRecHits = std::make_unique<EcalRecHitCollection>();
291  auto esRecHits = std::make_unique<EcalRecHitCollection>();
292  auto photonPfCandMap = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
293  auto gsfElectronPfCandMap = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
294 
295  //maps to collection indices of output objects
296  std::map<reco::PhotonCoreRef, unsigned int> photonCoreMap;
297  std::map<reco::PhotonCoreRef, unsigned int> ootPhotonCoreMap;
298  std::map<reco::GsfElectronCoreRef, unsigned int> gsfElectronCoreMap;
299  std::map<reco::GsfTrackRef, unsigned int> gsfTrackMap;
300  std::map<reco::ConversionRef, unsigned int> conversionMap;
301  std::map<reco::ConversionRef, unsigned int> singleConversionMap;
302  std::map<reco::SuperClusterRef, unsigned int> superClusterMap;
303  std::map<reco::CaloClusterPtr, unsigned int> ebeeClusterMap;
304  std::map<reco::CaloClusterPtr, unsigned int> esClusterMap;
305  std::map<reco::SuperClusterRef, unsigned int> ootSuperClusterMap;
306  std::map<reco::CaloClusterPtr, unsigned int> ootEbeeClusterMap;
307  std::map<reco::CaloClusterPtr, unsigned int> ootEsClusterMap;
308  std::unordered_set<DetId> rechitMap;
309 
310  std::unordered_set<unsigned int> superClusterFullRelinkMap;
311  std::unordered_set<unsigned int> ootSuperClusterFullRelinkMap;
312 
313  //vectors for pfcandidate valuemaps
314  std::vector<std::vector<reco::PFCandidateRef> > pfCandIsoPairVecPho;
315  std::vector<std::vector<reco::PFCandidateRef> > pfCandIsoPairVecEle;
316 
317  //vectors for id valuemaps
318  std::vector<std::vector<bool> > photonIdVals(photonIdHandles.size());
319  std::vector<std::vector<float> > gsfElectronIdVals(gsfElectronIdHandles.size());
320  std::vector<std::vector<float> > photonFloatValueMapVals(photonFloatValueMapHandles.size());
321  std::vector<std::vector<float> > ootPhotonFloatValueMapVals(ootPhotonFloatValueMapHandles.size());
322  std::vector<std::vector<float> > gsfElectronFloatValueMapVals(gsfElectronFloatValueMapHandles.size());
323 
324  //loop over photons and fill maps
325  index = -1;
326  for (const auto& photon : *photonHandle) {
327  index++;
328 
329  reco::PhotonRef photonref(photonHandle,index);
330  photons->push_back(photon);
331  auto& newPhoton = photons->back();
332 
333  if( (applyPhotonCalibOnData_ && theEvent.isRealData()) ||
334  (applyPhotonCalibOnMC_ && !theEvent.isRealData()) ){
335  calibratePhoton(newPhoton,photonref,
336  *photonCalibEnergyHandle,*photonCalibEnergyErrHandle);
337  }
338 
339  //we do this after calibration
340  bool keep = keepPhotonSel_(newPhoton);
341  if (!keep){
342  photons->pop_back();
343  continue;
344  }
345 
346  //fill pf candidate value map vector
347  pfCandIsoPairVecPho.push_back((*photonPfCandMapHandle)[photonref]);
348 
349  //fill photon id valuemap vectors
350  int subindex = 0;
351  for (const auto& photonIdHandle : photonIdHandles) {
352  photonIdVals[subindex++].push_back((*photonIdHandle)[photonref]);
353  }
354 
355  subindex = 0;
356  for (const auto& photonFloatValueMapHandle : photonFloatValueMapHandles) {
357  photonFloatValueMapVals[subindex++].push_back((*photonFloatValueMapHandle)[photonref]);
358  }
359 
360  //link photon core
361  const reco::PhotonCoreRef &photonCore = photon.photonCore();
362  linkCore(photonCore, *photonCores, photonCoreMap);
363 
364  bool slimRelink = slimRelinkPhotonSel_(newPhoton);
365  //no supercluster relinking unless slimRelink selection is satisfied
366  if (!slimRelink) continue;
367 
368  bool relink = relinkPhotonSel_(newPhoton);
369 
370  //link supercluster
371  const reco::SuperClusterRef &superCluster = photon.superCluster();
372  linkSuperCluster(superCluster, superClusterMap, *superClusters, relink, superClusterFullRelinkMap);
373 
374  //conversions only for full relinking
375  if (!relink) continue;
376 
377  const reco::ConversionRefVector &convrefs = photon.conversions();
378  linkConversions(convrefs, *conversions, conversionMap);
379 
380  //explicitly references conversions
381  const reco::ConversionRefVector &singleconvrefs = photon.conversionsOneLeg();
382  linkConversions(singleconvrefs, *singleConversions, singleConversionMap);
383  }
384 
385  //loop over oot photons and fill maps
386  //special note1: since not PFCand --> no PF isolation, IDs (but we do have FloatValueMap!)
387  //special note2: conversion sequence not run over bcs from oot phos, so skip relinking of oot phos
388  //special note3: clusters and superclusters in own collections!
389  index = -1;
390  for (const auto& ootPhoton : *ootPhotonHandle) {
391  index++;
392 
393  bool keep = keepOOTPhotonSel_(ootPhoton);
394  if (!keep) continue;
395 
396  reco::PhotonRef ootPhotonref(ootPhotonHandle,index);
397 
398  ootPhotons->push_back(ootPhoton);
399 
400  //fill photon pfclusteriso valuemap vectors
401  int subindex = 0;
402  for (const auto& ootPhotonFloatValueMapHandle : ootPhotonFloatValueMapHandles) {
403  ootPhotonFloatValueMapVals[subindex++].push_back((*ootPhotonFloatValueMapHandle)[ootPhotonref]);
404  }
405 
406  //link photon core
407  const reco::PhotonCoreRef &ootPhotonCore = ootPhoton.photonCore();
408  linkCore(ootPhotonCore, *ootPhotonCores, ootPhotonCoreMap);
409 
410  bool slimRelink = slimRelinkOOTPhotonSel_(ootPhoton);
411  //no supercluster relinking unless slimRelink selection is satisfied
412  if (!slimRelink) continue;
413 
414  bool relink = relinkOOTPhotonSel_(ootPhoton);
415 
416  const reco::SuperClusterRef &ootSuperCluster = ootPhoton.superCluster();
417  linkSuperCluster(ootSuperCluster, ootSuperClusterMap, *ootSuperClusters, relink, ootSuperClusterFullRelinkMap);
418  }
419 
420  //loop over electrons and fill maps
421  index = -1;
422  for (const auto& gsfElectron : *gsfElectronHandle) {
423  index++;
424 
425  reco::GsfElectronRef gsfElectronref(gsfElectronHandle,index);
426  gsfElectrons->push_back(gsfElectron);
427  auto& newGsfElectron = gsfElectrons->back();
428  if( (applyGsfElectronCalibOnData_ && theEvent.isRealData()) ||
429  (applyGsfElectronCalibOnMC_ && !theEvent.isRealData()) ){
430  calibrateElectron(newGsfElectron, gsfElectronref,
431  *gsfElectronCalibEnergyHandle,*gsfElectronCalibEnergyErrHandle,
432  *gsfElectronCalibEcalEnergyHandle,*gsfElectronCalibEcalEnergyErrHandle);
433 
434  }
435 
436  bool keep = keepGsfElectronSel_(newGsfElectron);
437  if (!keep) {
438  gsfElectrons->pop_back();
439  continue;
440  }
441 
442  pfCandIsoPairVecEle.push_back((*gsfElectronPfCandMapHandle)[gsfElectronref]);
443 
444  //fill electron id valuemap vectors
445  int subindex = 0;
446  for (const auto& gsfElectronIdHandle : gsfElectronIdHandles) {
447  gsfElectronIdVals[subindex++].push_back((*gsfElectronIdHandle)[gsfElectronref]);
448  }
449 
450  subindex = 0;
451  for (const auto& gsfElectronFloatValueMapHandle : gsfElectronFloatValueMapHandles) {
452  gsfElectronFloatValueMapVals[subindex++].push_back((*gsfElectronFloatValueMapHandle)[gsfElectronref]);
453  }
454 
455  const reco::GsfElectronCoreRef &gsfElectronCore = gsfElectron.core();
456  linkCore(gsfElectronCore, *gsfElectronCores, gsfElectronCoreMap);
457 
458  const reco::GsfTrackRef &gsfTrack = gsfElectron.gsfTrack();
459 
460  // Save the main gsfTrack
461  if (!gsfTrackMap.count(gsfTrack)) {
462  gsfTracks->push_back(*gsfTrack);
463  gsfTrackMap[gsfTrack] = gsfTracks->size() - 1;
464  }
465 
466  // Save additional ambiguous gsf tracks in a map:
467  for (reco::GsfTrackRefVector::const_iterator igsf = gsfElectron.ambiguousGsfTracksBegin(); igsf != gsfElectron.ambiguousGsfTracksEnd(); ++igsf) {
468  const reco::GsfTrackRef &ambigGsfTrack = *igsf;
469  if (!gsfTrackMap.count(ambigGsfTrack)) {
470  gsfTracks->push_back(*ambigGsfTrack);
471  gsfTrackMap[ambigGsfTrack] = gsfTracks->size() - 1;
472  }
473  }
474 
475  bool slimRelink = slimRelinkGsfElectronSel_(newGsfElectron);
476  //no supercluster relinking unless slimRelink selection is satisfied
477  if (!slimRelink) continue;
478 
479  bool relink = relinkGsfElectronSel_(newGsfElectron);
480 
481  const reco::SuperClusterRef &superCluster = gsfElectron.superCluster();
482  linkSuperCluster(superCluster, superClusterMap, *superClusters, relink, superClusterFullRelinkMap);
483 
484  //conversions only for full relinking
485  if (!relink) continue;
486 
487  const reco::ConversionRefVector &convrefs = gsfElectron.core()->conversions();
488  linkConversions(convrefs, *conversions, conversionMap);
489 
490  //explicitly references conversions
491  const reco::ConversionRefVector &singleconvrefs = gsfElectron.core()->conversionsOneLeg();
492  linkConversions(singleconvrefs, *singleConversions, singleConversionMap);
493 
494  //conversions matched by trackrefs
495  linkConversionsByTrackRef(conversionHandle, gsfElectron, *conversions, conversionMap);
496 
497  //single leg conversions matched by trackrefs
498  linkConversionsByTrackRef(singleConversionHandle, gsfElectron, *singleConversions, singleConversionMap);
499  }
500 
501  //loop over output SuperClusters and fill maps
502  index = 0;
503  for (auto& superCluster : *superClusters) {
504 
505  //link seed cluster no matter what
506  const reco::CaloClusterPtr &seedCluster = superCluster.seed();
507  linkCaloCluster(seedCluster, *ebeeClusters, ebeeClusterMap);
508 
509  //only proceed if superCluster is marked for full relinking
510  bool fullrelink = superClusterFullRelinkMap.count(index++);
511  if (!fullrelink) {
512  //zero detid vector which is anyways not useful without stored rechits
513  superCluster.clearHitsAndFractions();
514  continue;
515  }
516 
517  // link calo clusters
518  linkCaloClusters(superCluster, *ebeeClusters, ebeeClusterMap, rechitMap, barrelHitHandle, endcapHitHandle, caloTopology, *esClusters, esClusterMap);
519 
520  //conversions matched geometrically
521  linkConversionsByTrackRef(conversionHandle, superCluster, *conversions, conversionMap);
522 
523  //single leg conversions matched by trackrefs
524  linkConversionsByTrackRef(singleConversionHandle, superCluster, *singleConversions, singleConversionMap);
525  }
526 
527  //loop over output OOTSuperClusters and fill maps
528  index = 0;
529  for (auto& ootSuperCluster : *ootSuperClusters) {
530 
531  //link seed cluster no matter what
532  const reco::CaloClusterPtr &ootSeedCluster = ootSuperCluster.seed();
533  linkCaloCluster(ootSeedCluster, *ootEbeeClusters, ootEbeeClusterMap);
534 
535  //only proceed if ootSuperCluster is marked for full relinking
536  bool fullrelink = ootSuperClusterFullRelinkMap.count(index++);
537  if (!fullrelink) {
538  //zero detid vector which is anyways not useful without stored rechits
539  ootSuperCluster.clearHitsAndFractions();
540  continue;
541  }
542 
543  // link calo clusters
544  linkCaloClusters(ootSuperCluster, *ootEbeeClusters, ootEbeeClusterMap, rechitMap, barrelHitHandle, endcapHitHandle, caloTopology, *ootEsClusters, ootEsClusterMap);
545  }
546 
547  //now finalize and add to the event collections in "reverse" order
548 
549  //rechits (fill output collections of rechits to be stored)
550  for (const EcalRecHit &rechit : *barrelHitHandle) {
551  if (rechitMap.count(rechit.detid())) {
552  ebRecHits->push_back(rechit);
553  }
554  }
555 
556  for (const EcalRecHit &rechit : *endcapHitHandle) {
557  if (rechitMap.count(rechit.detid())) {
558  eeRecHits->push_back(rechit);
559  }
560  }
561 
562  theEvent.put(std::move(ebRecHits),outEBRecHits_);
563  theEvent.put(std::move(eeRecHits),outEERecHits_);
564 
565  if (doPreshowerEcalHits_) {
566  for (const EcalRecHit &rechit : *preshowerHitHandle) {
567  if (rechitMap.count(rechit.detid())) {
568  esRecHits->push_back(rechit);
569  }
570  }
571  theEvent.put(std::move(esRecHits),outESRecHits_);
572  }
573 
574  //CaloClusters
575  //put calocluster output collections in event and get orphan handles to create ptrs
576  const edm::OrphanHandle<reco::CaloClusterCollection> &outEBEEClusterHandle = theEvent.put(std::move(ebeeClusters),outEBEEClusters_);
577  const edm::OrphanHandle<reco::CaloClusterCollection> &outESClusterHandle = theEvent.put(std::move(esClusters),outESClusters_);;
578 
579  //Loop over SuperClusters and relink GEDPhoton + GSFElectron CaloClusters
580  for (reco::SuperCluster &superCluster : *superClusters) {
581  relinkCaloClusters(superCluster, ebeeClusterMap, esClusterMap, outEBEEClusterHandle, outESClusterHandle);
582  }
583 
584  //OOTCaloClusters
585  //put ootcalocluster output collections in event and get orphan handles to create ptrs
586  const edm::OrphanHandle<reco::CaloClusterCollection> &outOOTEBEEClusterHandle = theEvent.put(std::move(ootEbeeClusters),outOOTEBEEClusters_);
587  const edm::OrphanHandle<reco::CaloClusterCollection> &outOOTESClusterHandle = theEvent.put(std::move(ootEsClusters),outOOTESClusters_);;
588 
589  //Loop over OOTSuperClusters and relink OOTPhoton CaloClusters
590  for (reco::SuperCluster &ootSuperCluster : *ootSuperClusters) {
591  relinkCaloClusters(ootSuperCluster, ootEbeeClusterMap, ootEsClusterMap, outOOTEBEEClusterHandle, outOOTESClusterHandle);
592  }
593 
594  //put superclusters and conversions in the event
595  const edm::OrphanHandle<reco::SuperClusterCollection> &outSuperClusterHandle = theEvent.put(std::move(superClusters),outSuperClusters_);
596  const edm::OrphanHandle<reco::ConversionCollection> &outConversionHandle = theEvent.put(std::move(conversions),outConversions_);
597  const edm::OrphanHandle<reco::ConversionCollection> &outSingleConversionHandle = theEvent.put(std::move(singleConversions),outSingleConversions_);
598  const edm::OrphanHandle<reco::GsfTrackCollection> &outGsfTrackHandle = theEvent.put(std::move(gsfTracks),outGsfTracks_);
599 
600  //Loop over PhotonCores and relink GEDPhoton SuperClusters (and conversions)
601  for (reco::PhotonCore &photonCore : *photonCores) {
602  // superclusters
603  relinkSuperCluster(photonCore, superClusterMap, outSuperClusterHandle);
604 
605  //conversions
606  const reco::ConversionRefVector &convrefs = photonCore.conversions();
607  relinkConversions(photonCore, convrefs, conversionMap, outConversionHandle);
608 
609  //single leg conversions
610  const reco::ConversionRefVector &singleconvrefs = photonCore.conversionsOneLeg();
611  relinkConversions(photonCore, singleconvrefs, singleConversionMap, outSingleConversionHandle);
612  }
613 
614  //Relink GSFElectron SuperClusters and main GSF Tracks
615  for (reco::GsfElectronCore &gsfElectronCore : *gsfElectronCores) {
616  relinkSuperCluster(gsfElectronCore, superClusterMap, outSuperClusterHandle);
617  relinkGsfTrack(gsfElectronCore, gsfTrackMap, outGsfTrackHandle);
618  }
619 
620  //put ootsuperclusters in the event
621  const edm::OrphanHandle<reco::SuperClusterCollection> &outOOTSuperClusterHandle = theEvent.put(std::move(ootSuperClusters),outOOTSuperClusters_);
622 
623  //Relink OOTPhoton SuperClusters
624  for (reco::PhotonCore &ootPhotonCore : *ootPhotonCores) {
625  relinkSuperCluster(ootPhotonCore, ootSuperClusterMap, outOOTSuperClusterHandle);
626  }
627 
628  //put photoncores and gsfelectroncores into the event
629  const edm::OrphanHandle<reco::PhotonCoreCollection> &outPhotonCoreHandle = theEvent.put(std::move(photonCores),outPhotonCores_);
630  const edm::OrphanHandle<reco::PhotonCoreCollection> &outOOTPhotonCoreHandle = theEvent.put(std::move(ootPhotonCores),outOOTPhotonCores_);
631  const edm::OrphanHandle<reco::GsfElectronCoreCollection> &outgsfElectronCoreHandle = theEvent.put(std::move(gsfElectronCores),outGsfElectronCores_);
632 
633  //loop over photons, oot photons, and electrons and relink the cores
634  for (reco::Photon &photon : *photons) {
635  relinkPhotonCore(photon, photonCoreMap, outPhotonCoreHandle);
636  }
637 
638  for (reco::Photon &ootPhoton : *ootPhotons) {
639  relinkPhotonCore(ootPhoton, ootPhotonCoreMap, outOOTPhotonCoreHandle);
640  }
641 
642  for (reco::GsfElectron &gsfElectron : *gsfElectrons) {
643  relinkGsfElectronCore(gsfElectron, gsfElectronCoreMap, outgsfElectronCoreHandle);
644 
645  // -----
646  // Also in this loop let's relink ambiguous tracks
647  std::vector<reco::GsfTrackRef> ambigTracksInThisElectron;
648  // Here we loop over the ambiguous tracks and save them in a vector
649  for (reco::GsfTrackRefVector::const_iterator igsf = gsfElectron.ambiguousGsfTracksBegin(); igsf != gsfElectron.ambiguousGsfTracksEnd(); ++igsf) {
650  ambigTracksInThisElectron.push_back(*igsf);
651  }
652 
653  // Now we need to clear them (they are the refs to original collection):
654  gsfElectron.clearAmbiguousGsfTracks();
655 
656  // And here we add them back, now from a new reduced collection:
657  for (const auto &it : ambigTracksInThisElectron) {
658  const auto &gsftkmapped = gsfTrackMap.find(it);
659 
660  if (gsftkmapped != gsfTrackMap.end()) {
661  reco::GsfTrackRef gsftkref(outGsfTrackHandle, gsftkmapped->second);
662  gsfElectron.addAmbiguousGsfTrack(gsftkref);
663  }
664  else
665  throw cms::Exception("There must be a problem with linking and mapping of ambiguous gsf tracks...");
666  }
667 
668  if (gsfElectron.ambiguousGsfTracksSize() > 0)
669  gsfElectron.setAmbiguous(true); // Set the flag
670 
671  ambigTracksInThisElectron.clear();
672 
673  }
674 
675  //(finally) store the output photon and electron collections
676  const edm::OrphanHandle<reco::PhotonCollection> &outPhotonHandle = theEvent.put(std::move(photons),outPhotons_);
677  const edm::OrphanHandle<reco::PhotonCollection> &outOOTPhotonHandle = theEvent.put(std::move(ootPhotons),outOOTPhotons_);
678  const edm::OrphanHandle<reco::GsfElectronCollection> &outGsfElectronHandle = theEvent.put(std::move(gsfElectrons),outGsfElectrons_);
679 
680  //still need to output relinked valuemaps
681 
682  //photon pfcand isolation valuemap
683  edm::ValueMap<std::vector<reco::PFCandidateRef>>::Filler fillerPhotons(*photonPfCandMap);
684  fillerPhotons.insert(outPhotonHandle,pfCandIsoPairVecPho.begin(),pfCandIsoPairVecPho.end());
685  fillerPhotons.fill();
686 
687  //electron pfcand isolation valuemap
688  edm::ValueMap<std::vector<reco::PFCandidateRef>>::Filler fillerGsfElectrons(*gsfElectronPfCandMap);
689  fillerGsfElectrons.insert(outGsfElectronHandle,pfCandIsoPairVecEle.begin(),pfCandIsoPairVecEle.end());
690  fillerGsfElectrons.fill();
691 
692  theEvent.put(std::move(photonPfCandMap),outPhotonPfCandMap_);
693  theEvent.put(std::move(gsfElectronPfCandMap),outGsfElectronPfCandMap_);
694 
695  auto fillMap = [](auto refH, auto& vec, edm::Event& ev, const std::string& cAl = ""){
697  auto oMap = std::make_unique<MapType>();
698  {
699  typename MapType::Filler filler(*oMap);
700  filler.insert(refH, vec.begin(), vec.end());
701  filler.fill();
702  }
703  ev.put(std::move(oMap), cAl);
704  };
705 
706  //photon id value maps
707  index = 0;
708  for (auto const& vals : photonIdVals){
709  fillMap(outPhotonHandle, vals, theEvent, outPhotonIds_[index++]);
710  }
711 
712  //electron id value maps
713  index = 0;
714  for (auto const& vals : gsfElectronIdVals){
715  fillMap(outGsfElectronHandle, vals, theEvent, outGsfElectronIds_[index++]);
716  }
717 
718  // photon iso value maps
719  index = 0;
720  for (auto const& vals : photonFloatValueMapVals){
721  fillMap(outPhotonHandle, vals, theEvent, outPhotonFloatValueMaps_[index++]);
722  }
723 
724  //oot photon iso value maps
725  index = 0;
726  for (auto const& vals : ootPhotonFloatValueMapVals){
727  fillMap(outOOTPhotonHandle, vals, theEvent, outOOTPhotonFloatValueMaps_[index++]);
728  }
729 
730  //electron iso value maps
731  index = 0;
732  for (auto const& vals : gsfElectronFloatValueMapVals){
733  fillMap(outGsfElectronHandle, vals, theEvent, outGsfElectronFloatValueMaps_[index++]);
734  }
735 }
const bool doPreshowerEcalHits_
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)
const StringCutObjectSelector< reco::Photon > relinkOOTPhotonSel_
const edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectronT_
const bool applyPhotonCalibOnData_
const edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackT_
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEnergyT_
const StringCutObjectSelector< reco::Photon > slimRelinkPhotonSel_
const edm::EDGetTokenT< reco::ConversionCollection > singleConversionT_
const std::vector< std::string > outPhotonIds_
const std::vector< std::string > outOOTPhotonFloatValueMaps_
static void calibratePhoton(reco::Photon &photon, const reco::PhotonRef &oldPhoRef, const edm::ValueMap< float > &energyMap, const edm::ValueMap< float > &energyErrMap)
edm::EDGetTokenT< edm::ValueMap< float > > photonCalibEnergyT_
const std::vector< std::string > outPhotonFloatValueMaps_
const std::string outGsfTracks_
const StringCutObjectSelector< reco::GsfElectron > keepGsfElectronSel_
const std::string outOOTPhotons_
bool ev
const std::string outEBEEClusters_
const StringCutObjectSelector< reco::Photon > keepPhotonSel_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > photonPfCandMapT_
const bool applyGsfElectronCalibOnData_
edm::EDGetTokenT< edm::ValueMap< float > > photonCalibEnergyErrT_
const StringCutObjectSelector< reco::GsfElectron > relinkGsfElectronSel_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > gsfElectronPfCandMapT_
const std::string outEBRecHits_
const std::string outESRecHits_
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)
const int keep
const std::vector< std::string > outGsfElectronIds_
const std::string outSingleConversions_
const std::string outESClusters_
const std::string outOOTSuperClusters_
const StringCutObjectSelector< reco::Photon > keepOOTPhotonSel_
const std::string outOOTESClusters_
static void calibrateElectron(reco::GsfElectron &gsfElectron, const reco::GsfElectronRef &oldEleRef, const edm::ValueMap< float > &energyMap, const edm::ValueMap< float > &energyErrMap, const edm::ValueMap< float > &ecalEnergyMap, const edm::ValueMap< float > &ecalEnergyErrMap)
void relinkGsfElectronCore(reco::GsfElectron &gsfElectron, const std::map< reco::GsfElectronCoreRef, unsigned int > &gsfElectronCoreMap, const edm::OrphanHandle< reco::GsfElectronCoreCollection > &outGsfElectronCoreHandle)
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > gsfElectronFloatValueMapTs_
void linkConversionsByTrackRef(const edm::Handle< reco::ConversionCollection > &conversionHandle, const reco::GsfElectron &gsfElectron, reco::ConversionCollection &conversions, std::map< reco::ConversionRef, unsigned int > &conversionMap)
const std::string outOOTEBEEClusters_
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::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEnergyErrT_
const bool applyPhotonCalibOnMC_
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_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > photonFloatValueMapTs_
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)
const std::string outSuperClusters_
const std::string outConversions_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > ootPhotonFloatValueMapTs_
const std::string outGsfElectrons_
const StringCutObjectSelector< reco::GsfElectron > slimRelinkGsfElectronSel_
const std::string outPhotonCores_
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEcalEnergyErrT_
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_
const std::vector< std::string > outGsfElectronFloatValueMaps_
const std::string outPhotonPfCandMap_
const edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > photonIdTs_
const std::string outOOTPhotonCores_
edm::EDGetTokenT< edm::ValueMap< float > > gsfElectronCalibEcalEnergyT_
const edm::EDGetTokenT< reco::PhotonCollection > ootPhotonT_
const edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
def move(src, dest)
Definition: eostools.py:510
const bool applyGsfElectronCalibOnMC_
const edm::EDGetTokenT< reco::ConversionCollection > conversionT_
void ReducedEGProducer::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 
)
private

Definition at line 868 of file ReducedEGProducer.cc.

References edm::PtrVectorBase::clear(), fastPrimaryVertexProducer_cfi::clusters, reco::SuperCluster::clusters(), edm::PtrVectorBase::empty(), reco::SuperCluster::preshowerClusters(), edm::PtrVector< T >::push_back(), reco::SuperCluster::seed(), reco::SuperCluster::setClusters(), reco::SuperCluster::setPreshowerClusters(), and reco::SuperCluster::setSeed().

Referenced by produce().

873 {
874  //remap seed cluster
875  const auto &seedmapped = ebeeClusterMap.find(superCluster.seed());
876  if (seedmapped != ebeeClusterMap.end()) {
877  //make new ptr
878  reco::CaloClusterPtr clusptr(outEBEEClusterHandle,seedmapped->second);
879  superCluster.setSeed(clusptr);
880  }
881 
882  //remap all clusters
884  for (const auto &cluster : superCluster.clusters()) {
885  const auto &clustermapped = ebeeClusterMap.find(cluster);
886  if (clustermapped != ebeeClusterMap.end()) {
887  //make new ptr
888  reco::CaloClusterPtr clusptr(outEBEEClusterHandle,clustermapped->second);
889  clusters.push_back(clusptr);
890  }
891  else {
892  //can only relink if all clusters are being relinked, so if one is missing, then skip the relinking completely
893  clusters.clear();
894  break;
895  }
896  }
897  if (!clusters.empty()) {
898  superCluster.setClusters(clusters);
899  }
900 
901  //remap preshower clusters
902  reco::CaloClusterPtrVector esclusters;
903  for (const auto& cluster : superCluster.preshowerClusters()) {
904  const auto &clustermapped = esClusterMap.find(cluster);
905  if (clustermapped != esClusterMap.end()) {
906  //make new ptr
907  reco::CaloClusterPtr clusptr(outESClusterHandle,clustermapped->second);
908  esclusters.push_back(clusptr);
909  }
910  else {
911  //can only relink if all clusters are being relinked, so if one is missing, then skip the relinking completely
912  esclusters.clear();
913  break;
914  }
915  }
916  if (!esclusters.empty()) {
917  superCluster.setPreshowerClusters(esclusters);
918  }
919 }
void setPreshowerClusters(const CaloClusterPtrVector &clusters)
Definition: SuperCluster.h:105
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
bool empty() const
Is the RefVector empty.
Definition: PtrVectorBase.h:71
void setSeed(const CaloClusterPtr &r)
list of used xtals by DetId // now inherited by CaloCluster
Definition: SuperCluster.h:96
const CaloClusterPtrVector & clusters() const
const access to the cluster list itself
Definition: SuperCluster.h:69
void setClusters(const CaloClusterPtrVector &clusters)
Definition: SuperCluster.h:99
const CaloClusterPtrVector & preshowerClusters() const
const access to the preshower cluster list itself
Definition: SuperCluster.h:72
void clear()
Clear the PtrVector.
Definition: PtrVectorBase.h:80
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
void ReducedEGProducer::relinkConversions ( reco::PhotonCore photonCore,
const reco::ConversionRefVector convrefs,
const std::map< reco::ConversionRef, unsigned int > &  conversionMap,
const edm::OrphanHandle< reco::ConversionCollection > &  outConversionHandle 
)
private

Definition at line 945 of file ReducedEGProducer.cc.

References edm::RefVector< C, T, F >::clear(), edm::RefVector< C, T, F >::empty(), and reco::PhotonCore::setConversions().

Referenced by produce().

949 {
950  reco::ConversionRefVector outconvrefs;
951  for (const auto& convref : convrefs) {
952  const auto &convmapped = conversionMap.find(convref);
953  if (convmapped != conversionMap.end()) {
954  //make new ref
955  reco::ConversionRef outref(outConversionHandle,convmapped->second);
956  }
957  else {
958  //can only relink if all conversions are being relinked, so if one is missing, then skip the relinking completely
959  outconvrefs.clear();
960  break;
961  }
962  }
963  if (!outconvrefs.empty()) {
964  photonCore.setConversions(outconvrefs);
965  }
966 }
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:104
void setConversions(const reco::ConversionRefVector &conversions)
Definition: PhotonCore.h:79
void clear()
Clear the vector.
Definition: RefVector.h:147
void ReducedEGProducer::relinkGsfElectronCore ( reco::GsfElectron gsfElectron,
const std::map< reco::GsfElectronCoreRef, unsigned int > &  gsfElectronCoreMap,
const edm::OrphanHandle< reco::GsfElectronCoreCollection > &  outGsfElectronCoreHandle 
)
private

Definition at line 980 of file ReducedEGProducer.cc.

References reco::GsfElectron::core(), and reco::GsfElectron::setCore().

Referenced by produce().

983 {
984  const auto &coremapped = gsfElectronCoreMap.find(gsfElectron.core());
985  if (coremapped != gsfElectronCoreMap.end()) {
986  //make new ref
987  reco::GsfElectronCoreRef coreref(outgsfElectronCoreHandle,coremapped->second);
988  gsfElectron.setCore(coreref);
989  }
990 }
void setCore(const reco::GsfElectronCoreRef &core)
Definition: GsfElectron.h:181
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
void ReducedEGProducer::relinkGsfTrack ( reco::GsfElectronCore electroncore,
const std::map< reco::GsfTrackRef, unsigned int > &  gsfTrackMap,
const edm::OrphanHandle< reco::GsfTrackCollection > &  outGsfTrackHandle 
)
private

Definition at line 934 of file ReducedEGProducer.cc.

References reco::GsfElectronCore::gsfTrack(), and reco::GsfElectronCore::setGsfTrack().

Referenced by produce().

937 {
938  const auto &gsftkmapped = gsfTrackMap.find(gsfElectronCore.gsfTrack());
939  if (gsftkmapped != gsfTrackMap.end()) {
940  reco::GsfTrackRef gsftkref(outGsfTrackHandle, gsftkmapped->second);
941  gsfElectronCore.setGsfTrack(gsftkref);
942  }
943 }
void ReducedEGProducer::relinkPhotonCore ( reco::Photon photon,
const std::map< reco::PhotonCoreRef, unsigned int > &  photonCoreMap,
const edm::OrphanHandle< reco::PhotonCoreCollection > &  outPhotonCoreHandle 
)
private

Definition at line 968 of file ReducedEGProducer.cc.

References reco::Photon::photonCore(), and reco::Photon::setPhotonCore().

Referenced by produce().

971 {
972  const auto &coremapped = photonCoreMap.find(photon.photonCore());
973  if (coremapped != photonCoreMap.end()) {
974  //make new ref
975  reco::PhotonCoreRef coreref(outPhotonCoreHandle,coremapped->second);
976  photon.setPhotonCore(coreref);
977  }
978 }
reco::PhotonCoreRef photonCore() const
returns a reference to the core photon object
Definition: Photon.h:50
void setPhotonCore(const reco::PhotonCoreRef &photonCore)
Definition: Photon.h:51
template<typename T >
void ReducedEGProducer::relinkSuperCluster ( T core,
const std::map< reco::SuperClusterRef, unsigned int > &  superClusterMap,
const edm::OrphanHandle< reco::SuperClusterCollection > &  outSuperClusterHandle 
)
private

Definition at line 922 of file ReducedEGProducer.cc.

Referenced by produce().

925 {
926  const auto &scmapped = superClusterMap.find(core.superCluster());
927  if (scmapped != superClusterMap.end()) {
928  //make new ref
929  reco::SuperClusterRef scref(outSuperClusterHandle,scmapped->second);
930  core.setSuperCluster(scref);
931  }
932 }
Definition: __init__.py:1
template<typename T >
void ReducedEGProducer::setToken ( edm::EDGetTokenT< T > &  token,
const edm::ParameterSet config,
const std::string &  name 
)
inlineprivate

Definition at line 141 of file ReducedEGProducer.h.

References edm::ParameterSet::getParameter(), and dataset::name.

Referenced by ReducedEGProducer().

141  {
142  token = consumes<T>(config.getParameter<edm::InputTag>(name));
143  }
T getParameter(std::string const &) const

Member Data Documentation

const bool ReducedEGProducer::applyGsfElectronCalibOnData_
private

Definition at line 171 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const bool ReducedEGProducer::applyGsfElectronCalibOnMC_
private

Definition at line 172 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const bool ReducedEGProducer::applyPhotonCalibOnData_
private

Definition at line 169 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const bool ReducedEGProducer::applyPhotonCalibOnMC_
private

Definition at line 170 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const edm::EDGetTokenT<EcalRecHitCollection> ReducedEGProducer::barrelEcalHits_
private

Definition at line 154 of file ReducedEGProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::ConversionCollection> ReducedEGProducer::conversionT_
private

Definition at line 151 of file ReducedEGProducer.h.

Referenced by produce().

const bool ReducedEGProducer::doPreshowerEcalHits_
private

Definition at line 156 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const edm::EDGetTokenT<EcalRecHitCollection> ReducedEGProducer::endcapEcalHits_
private

Definition at line 155 of file ReducedEGProducer.h.

Referenced by produce().

edm::EDGetTokenT<edm::ValueMap<float> > ReducedEGProducer::gsfElectronCalibEcalEnergyErrT_
private

Definition at line 178 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

edm::EDGetTokenT<edm::ValueMap<float> > ReducedEGProducer::gsfElectronCalibEcalEnergyT_
private

Definition at line 177 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

edm::EDGetTokenT<edm::ValueMap<float> > ReducedEGProducer::gsfElectronCalibEnergyErrT_
private

Definition at line 176 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

edm::EDGetTokenT<edm::ValueMap<float> > ReducedEGProducer::gsfElectronCalibEnergyT_
private

Definition at line 175 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > ReducedEGProducer::gsfElectronFloatValueMapTs_
private

Definition at line 167 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > ReducedEGProducer::gsfElectronIdTs_
private

Definition at line 163 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef> > > ReducedEGProducer::gsfElectronPfCandMapT_
private

Definition at line 160 of file ReducedEGProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::GsfElectronCollection> ReducedEGProducer::gsfElectronT_
private

Definition at line 149 of file ReducedEGProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::GsfTrackCollection> ReducedEGProducer::gsfTrackT_
private

Definition at line 150 of file ReducedEGProducer.h.

Referenced by produce().

const StringCutObjectSelector<reco::GsfElectron> ReducedEGProducer::keepGsfElectronSel_
private

Definition at line 213 of file ReducedEGProducer.h.

Referenced by produce().

const StringCutObjectSelector<reco::Photon> ReducedEGProducer::keepOOTPhotonSel_
private

Definition at line 210 of file ReducedEGProducer.h.

Referenced by produce().

const StringCutObjectSelector<reco::Photon> ReducedEGProducer::keepPhotonSel_
private

Definition at line 207 of file ReducedEGProducer.h.

Referenced by produce().

std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > ReducedEGProducer::ootPhotonFloatValueMapTs_
private

Definition at line 166 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const edm::EDGetTokenT<reco::PhotonCollection> ReducedEGProducer::ootPhotonT_
private

Definition at line 148 of file ReducedEGProducer.h.

Referenced by produce().

const std::string ReducedEGProducer::outConversions_
private

Definition at line 188 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outEBEEClusters_
private

Definition at line 191 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outEBRecHits_
private

Definition at line 196 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outEERecHits_
private

Definition at line 197 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outESClusters_
private

Definition at line 192 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outESRecHits_
private

Definition at line 198 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outGsfElectronCores_
private

Definition at line 186 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::vector<std::string> ReducedEGProducer::outGsfElectronFloatValueMaps_
private

Definition at line 205 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::vector<std::string> ReducedEGProducer::outGsfElectronIds_
private

Definition at line 202 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outGsfElectronPfCandMap_
private

Definition at line 200 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outGsfElectrons_
private

Definition at line 185 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outGsfTracks_
private

Definition at line 187 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outOOTEBEEClusters_
private

Definition at line 194 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outOOTESClusters_
private

Definition at line 195 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outOOTPhotonCores_
private

Definition at line 184 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::vector<std::string> ReducedEGProducer::outOOTPhotonFloatValueMaps_
private

Definition at line 204 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outOOTPhotons_
private

Definition at line 183 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outOOTSuperClusters_
private

Definition at line 193 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outPhotonCores_
private

Definition at line 182 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::vector<std::string> ReducedEGProducer::outPhotonFloatValueMaps_
private

Definition at line 203 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::vector<std::string> ReducedEGProducer::outPhotonIds_
private

Definition at line 201 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outPhotonPfCandMap_
private

Definition at line 199 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outPhotons_
private

Definition at line 181 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outSingleConversions_
private

Definition at line 189 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const std::string ReducedEGProducer::outSuperClusters_
private

Definition at line 190 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

edm::EDGetTokenT<edm::ValueMap<float> > ReducedEGProducer::photonCalibEnergyErrT_
private

Definition at line 174 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

edm::EDGetTokenT<edm::ValueMap<float> > ReducedEGProducer::photonCalibEnergyT_
private

Definition at line 173 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > ReducedEGProducer::photonFloatValueMapTs_
private

Definition at line 165 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

std::vector<edm::EDGetTokenT<edm::ValueMap<bool> > > ReducedEGProducer::photonIdTs_
private

Definition at line 162 of file ReducedEGProducer.h.

Referenced by produce(), and ReducedEGProducer().

const edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef> > > ReducedEGProducer::photonPfCandMapT_
private

Definition at line 159 of file ReducedEGProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::PhotonCollection> ReducedEGProducer::photonT_
private

Definition at line 147 of file ReducedEGProducer.h.

Referenced by produce().

const edm::EDGetTokenT<EcalRecHitCollection> ReducedEGProducer::preshowerEcalHits_
private

Definition at line 157 of file ReducedEGProducer.h.

Referenced by produce().

const StringCutObjectSelector<reco::GsfElectron> ReducedEGProducer::relinkGsfElectronSel_
private

Definition at line 215 of file ReducedEGProducer.h.

Referenced by produce().

const StringCutObjectSelector<reco::Photon> ReducedEGProducer::relinkOOTPhotonSel_
private

Definition at line 212 of file ReducedEGProducer.h.

Referenced by produce().

const StringCutObjectSelector<reco::Photon> ReducedEGProducer::relinkPhotonSel_
private

Definition at line 209 of file ReducedEGProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::ConversionCollection> ReducedEGProducer::singleConversionT_
private

Definition at line 152 of file ReducedEGProducer.h.

Referenced by produce().

const StringCutObjectSelector<reco::GsfElectron> ReducedEGProducer::slimRelinkGsfElectronSel_
private

Definition at line 214 of file ReducedEGProducer.h.

Referenced by produce().

const StringCutObjectSelector<reco::Photon> ReducedEGProducer::slimRelinkOOTPhotonSel_
private

Definition at line 211 of file ReducedEGProducer.h.

Referenced by produce().

const StringCutObjectSelector<reco::Photon> ReducedEGProducer::slimRelinkPhotonSel_
private

Definition at line 208 of file ReducedEGProducer.h.

Referenced by produce().