4 #include <unordered_set> 51 return std::hash<uint32_t>()(
id.rawId());
63 doPreshowerEcalHits_(!config.getParameter<
edm::InputTag>(
"preshowerEcalHits").
label().
empty()),
65 photonPfCandMapT_(consumes<
edm::ValueMap<
std::vector<
reco::
PFCandidateRef> > >(config.getParameter<
edm::InputTag>(
"photonsPFValMap"))),
66 gsfElectronPfCandMapT_(consumes<
edm::ValueMap<
std::vector<
reco::
PFCandidateRef> > >(config.getParameter<
edm::InputTag>(
"gsfElectronsPFValMap"))),
68 outPhotons_(
"reducedGedPhotons"),
69 outPhotonCores_(
"reducedGedPhotonCores"),
70 outGsfElectrons_(
"reducedGedGsfElectrons"),
71 outGsfElectronCores_(
"reducedGedGsfElectronCores"),
72 outConversions_(
"reducedConversions"),
73 outSingleConversions_(
"reducedSingleLegConversions"),
74 outSuperClusters_(
"reducedSuperClusters"),
75 outEBEEClusters_(
"reducedEBEEClusters"),
76 outESClusters_(
"reducedESClusters"),
77 outEBRecHits_(
"reducedEBRecHits"),
78 outEERecHits_(
"reducedEERecHits"),
79 outESRecHits_(
"reducedESRecHits"),
80 outPhotonPfCandMap_(
"reducedPhotonPfCandMap"),
81 outGsfElectronPfCandMap_(
"reducedGsfElectronPfCandMap"),
82 outPhotonIds_(config.getParameter<
std::vector<
std::
string> >(
"photonIDOutput")),
83 outGsfElectronIds_(config.getParameter<
std::vector<
std::
string> >(
"gsfElectronIDOutput")),
84 outPhotonPFClusterIsos_(config.getParameter<
std::vector<
std::
string> >(
"photonPFClusterIsoOutput")),
85 outGsfElectronPFClusterIsos_(config.getParameter<
std::vector<
std::
string> >(
"gsfElectronPFClusterIsoOutput")),
86 keepPhotonSel_(config.getParameter<
std::
string>(
"keepPhotons")),
87 slimRelinkPhotonSel_(config.getParameter<
std::
string>(
"slimRelinkPhotons")),
88 relinkPhotonSel_(config.getParameter<
std::
string>(
"relinkPhotons")),
89 keepGsfElectronSel_(config.getParameter<
std::
string>(
"keepGsfElectrons")),
90 slimRelinkGsfElectronSel_(config.getParameter<
std::
string>(
"slimRelinkGsfElectrons")),
91 relinkGsfElectronSel_(config.getParameter<
std::
string>(
"relinkGsfElectrons"))
93 const std::vector<edm::InputTag>& photonidinputs =
94 config.
getParameter<std::vector<edm::InputTag> >(
"photonIDSources");
99 const std::vector<edm::InputTag>& gsfelectronidinputs =
100 config.
getParameter<std::vector<edm::InputTag> >(
"gsfElectronIDSources");
105 const std::vector<edm::InputTag>& photonpfclusterisoinputs =
106 config.
getParameter<std::vector<edm::InputTag> >(
"photonPFClusterIsoSources");
111 const std::vector<edm::InputTag>& gsfelectronpfclusterisoinputs =
112 config.
getParameter<std::vector<edm::InputTag> >(
"gsfElectronPFClusterIsoSources");
132 produces< edm::ValueMap<bool> >(outid);
135 produces< edm::ValueMap<float> >(outid);
138 produces< edm::ValueMap<float> >(outid);
141 produces< edm::ValueMap<float> >(outid);
184 std::vector<edm::Handle<edm::ValueMap<bool> > > photonIdHandles(
photonIdTs_.size());
185 for (
unsigned int itok=0; itok<
photonIdTs_.size(); ++itok) {
189 std::vector<edm::Handle<edm::ValueMap<float> > > gsfElectronIdHandles(
gsfElectronIdTs_.size());
199 std::vector<edm::Handle<edm::ValueMap<float> > > photonPFClusterIsoHandles(
photonPFClusterIsoTs_.size());
206 const CaloTopology *caloTopology = & (*theCaloTopology);
209 auto photons = std::make_unique<reco::PhotonCollection>();
210 auto photonCores = std::make_unique<reco::PhotonCoreCollection>();
211 auto gsfElectrons = std::make_unique<reco::GsfElectronCollection>();
212 auto gsfElectronCores = std::make_unique<reco::GsfElectronCoreCollection>();
213 auto conversions = std::make_unique<reco::ConversionCollection>();
215 auto superClusters = std::make_unique<reco::SuperClusterCollection>();
216 auto ebeeClusters = std::make_unique<reco::CaloClusterCollection>();
217 auto esClusters = std::make_unique<reco::CaloClusterCollection>();
218 auto ebRecHits = std::make_unique<EcalRecHitCollection>();
219 auto eeRecHits = std::make_unique<EcalRecHitCollection>();
220 auto esRecHits = std::make_unique<EcalRecHitCollection>();
221 auto photonPfCandMap = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
222 auto gsfElectronPfCandMap = std::make_unique<edm::ValueMap<std::vector<reco::PFCandidateRef>>>();
224 std::vector<std::unique_ptr<edm::ValueMap<bool> > > photonIds;
225 for (
unsigned int iid=0; iid<photonIdHandles.size(); ++iid) {
229 std::vector<std::unique_ptr<edm::ValueMap<float> > > gsfElectronIds;
230 for (
unsigned int iid=0; iid<gsfElectronIdHandles.size(); ++iid) {
234 std::vector<std::unique_ptr<edm::ValueMap<float> > > photonPFClusterIsos;
235 for (
unsigned int iid=0; iid<photonPFClusterIsoHandles.size(); ++iid) {
239 std::vector<std::unique_ptr<edm::ValueMap<float> > > gsfElectronPFClusterIsos;
240 for (
unsigned int iid=0; iid<gsfElectronPFClusterIsoHandles.size(); ++iid) {
245 std::map<reco::PhotonCoreRef, unsigned int> photonCoreMap;
246 std::map<reco::GsfElectronCoreRef, unsigned int> gsfElectronCoreMap;
247 std::map<reco::ConversionRef, unsigned int> conversionMap;
248 std::map<reco::ConversionRef, unsigned int> singleConversionMap;
249 std::map<reco::SuperClusterRef, unsigned int> superClusterMap;
250 std::map<reco::CaloClusterPtr, unsigned int> ebeeClusterMap;
251 std::map<reco::CaloClusterPtr, unsigned int> esClusterMap;
252 std::unordered_set<DetId> rechitMap;
254 std::unordered_set<unsigned int> superClusterFullRelinkMap;
257 std::vector<std::vector<reco::PFCandidateRef> > pfCandIsoPairVecPho;
258 std::vector<std::vector<reco::PFCandidateRef> > pfCandIsoPairVecEle;
261 std::vector<std::vector<bool> > photonIdVals(photonIds.size());
262 std::vector<std::vector<float> > gsfElectronIdVals(gsfElectronIds.size());
263 std::vector<std::vector<float> > photonPFClusterIsoVals(photonPFClusterIsos.size());
264 std::vector<std::vector<float> > gsfElectronPFClusterIsoVals(gsfElectronPFClusterIsos.size());
267 for (
unsigned int ipho=0; ipho<photonHandle->size(); ++ipho) {
278 pfCandIsoPairVecPho.push_back((*photonPfCandMapHandle)[photonref]);
281 for (
unsigned int iid=0; iid<photonIds.size(); ++iid) {
282 photonIdVals[iid].push_back( (*photonIdHandles[iid])[photonref] );
285 for (
unsigned int iid=0; iid<photonPFClusterIsos.size(); ++iid) {
286 photonPFClusterIsoVals[iid].push_back( (*photonPFClusterIsoHandles[iid])[photonref] );
290 if (!photonCoreMap.count(photonCore)) {
291 photonCores->push_back(*photonCore);
292 photonCoreMap[
photonCore] = photonCores->size() - 1;
297 if (!slimRelink)
continue;
302 const auto &mappedsc = superClusterMap.find(superCluster);
305 unsigned int mappedscidx = 0;
306 if (mappedsc==superClusterMap.end()) {
307 superClusters->push_back(*superCluster);
308 mappedscidx = superClusters->size() - 1;
309 superClusterMap[superCluster] = mappedscidx;
312 mappedscidx = mappedsc->second;
316 if (relink) superClusterFullRelinkMap.insert(mappedscidx);
319 if (!relink)
continue;
323 if (!conversionMap.count(convref)) {
325 conversionMap[convref] = conversions->size() - 1;
332 if (!singleConversionMap.count(convref)) {
334 singleConversionMap[convref] = singleConversions->size() - 1;
341 for (
unsigned int iele = 0; iele<gsfElectronHandle->size(); ++iele) {
349 gsfElectrons->push_back(gsfElectron);
350 pfCandIsoPairVecEle.push_back((*gsfElectronPfCandMapHandle)[gsfElectronref]);
353 for (
unsigned int iid=0; iid<gsfElectronIds.size(); ++iid) {
354 gsfElectronIdVals[iid].push_back( (*gsfElectronIdHandles[iid])[gsfElectronref] );
357 for (
unsigned int iid=0; iid<gsfElectronPFClusterIsos.size(); ++iid) {
358 gsfElectronPFClusterIsoVals[iid].push_back( (*gsfElectronPFClusterIsoHandles[iid])[gsfElectronref] );
362 if (!gsfElectronCoreMap.count(gsfElectronCore)) {
363 gsfElectronCores->push_back(*gsfElectronCore);
364 gsfElectronCoreMap[gsfElectronCore] = gsfElectronCores->size() - 1;
369 if (!slimRelink)
continue;
374 const auto &mappedsc = superClusterMap.find(superCluster);
377 unsigned int mappedscidx = 0;
378 if (mappedsc==superClusterMap.end()) {
379 superClusters->push_back(*superCluster);
380 mappedscidx = superClusters->size() - 1;
381 superClusterMap[superCluster] = mappedscidx;
384 mappedscidx = mappedsc->second;
388 if (relink) superClusterFullRelinkMap.insert(mappedscidx);
391 if (!relink)
continue;
395 if (!conversionMap.count(convref)) {
396 conversions->push_back(*convref);
397 conversionMap[convref] = conversions->size() - 1;
404 if (!singleConversionMap.count(convref)) {
405 singleConversions->push_back(*convref);
406 singleConversionMap[convref] = singleConversions->size() - 1;
411 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
416 if (!matched)
continue;
418 if (!conversionMap.count(convref)) {
419 conversions->push_back(conversion);
420 conversionMap[convref] = conversions->size() - 1;
426 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
431 if (!matched)
continue;
433 if (!singleConversionMap.count(convref)) {
434 singleConversions->push_back(conversion);
435 singleConversionMap[convref] = singleConversions->size() - 1;
443 for (
unsigned int isc = 0; isc<superClusters->size(); ++isc) {
447 if (!ebeeClusterMap.count(superCluster.
seed())) {
448 ebeeClusters->push_back(*superCluster.
seed());
449 ebeeClusterMap[superCluster.
seed()] = ebeeClusters->
size() - 1;
453 bool fullrelink = superClusterFullRelinkMap.count(isc);
461 if (!ebeeClusterMap.count(cluster)) {
462 ebeeClusters->push_back(*cluster);
463 ebeeClusterMap[cluster] = ebeeClusters->size() - 1;
465 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
466 rechitMap.insert(hitfrac.first);
469 bool barrel = cluster->hitsAndFractions().front().first.subdetId()==
EcalBarrel;
471 DetId seed = EcalClusterTools::getMaximum(*cluster, rhcol).first;
474 for (
const DetId &detid : dets5x5) {
475 rechitMap.insert(detid);
479 if (!esClusterMap.count(cluster)) {
480 esClusters->push_back(*cluster);
481 esClusterMap[cluster] = esClusters->size() - 1;
483 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
484 rechitMap.insert(hitfrac.first);
489 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
494 if (!matched)
continue;
496 if (!conversionMap.count(convref)) {
497 conversions->push_back(conversion);
498 conversionMap[convref] = conversions->size() - 1;
504 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
509 if (!matched)
continue;
511 if (!singleConversionMap.count(convref)) {
512 singleConversions->push_back(conversion);
513 singleConversionMap[convref] = singleConversions->size() - 1;
523 for (
const EcalRecHit &rechit : *barrelHitHandle) {
524 if (rechitMap.count(rechit.detid())) {
525 ebRecHits->push_back(rechit);
529 for (
const EcalRecHit &rechit : *endcapHitHandle) {
530 if (rechitMap.count(rechit.detid())) {
531 eeRecHits->push_back(rechit);
539 for (
const EcalRecHit &rechit : *preshowerHitHandle) {
540 if (rechitMap.count(rechit.detid())) {
541 esRecHits->push_back(rechit);
555 const auto &seedmapped = ebeeClusterMap.find(superCluster.seed());
556 if (seedmapped != ebeeClusterMap.end()) {
559 superCluster.setSeed(clusptr);
565 const auto &clustermapped = ebeeClusterMap.find(cluster);
566 if (clustermapped != ebeeClusterMap.end()) {
577 if (clusters.
size()) {
578 superCluster.setClusters(clusters);
584 const auto &clustermapped = esClusterMap.find(cluster);
585 if (clustermapped != esClusterMap.end()) {
596 if (esclusters.
size()) {
597 superCluster.setPreshowerClusters(esclusters);
609 const auto &scmapped = superClusterMap.find(
photonCore.superCluster());
610 if (scmapped != superClusterMap.end()) {
620 const auto &convmapped = conversionMap.find(convref);
621 if (convmapped != conversionMap.end()) {
631 if (outconvrefs.
size()) {
639 const auto &convmapped = singleConversionMap.find(convref);
640 if (convmapped != singleConversionMap.end()) {
646 outsingleconvrefs.
clear();
650 if (outsingleconvrefs.
size()) {
651 photonCore.setConversionsOneLeg(outsingleconvrefs);
658 const auto &scmapped = superClusterMap.find(gsfElectronCore.superCluster());
659 if (scmapped != superClusterMap.end()) {
662 gsfElectronCore.setSuperCluster(scref);
672 const auto &coremapped = photonCoreMap.find(
photon.photonCore());
673 if (coremapped != photonCoreMap.end()) {
676 photon.setPhotonCore(coreref);
681 const auto &coremapped = gsfElectronCoreMap.find(gsfElectron.core());
682 if (coremapped != gsfElectronCoreMap.end()) {
685 gsfElectron.setCore(coreref);
697 fillerPhotons.insert(outPhotonHandle,pfCandIsoPairVecPho.begin(),pfCandIsoPairVecPho.end());
698 fillerPhotons.fill();
702 fillerGsfElectrons.insert(outGsfElectronHandle,pfCandIsoPairVecEle.begin(),pfCandIsoPairVecEle.end());
703 fillerGsfElectrons.fill();
709 for (
unsigned int iid=0; iid<photonIds.size(); ++iid) {
711 fillerPhotonId.
insert(outPhotonHandle,photonIdVals[iid].
begin(),photonIdVals[iid].
end());
712 fillerPhotonId.
fill();
717 for (
unsigned int iid=0; iid<gsfElectronIds.size(); ++iid) {
719 fillerGsfElectronId.
insert(outGsfElectronHandle,gsfElectronIdVals[iid].
begin(),gsfElectronIdVals[iid].
end());
720 fillerGsfElectronId.
fill();
725 for (
unsigned int iid=0; iid<photonPFClusterIsos.size(); ++iid) {
727 fillerPhotonPFClusterIso.
insert(outPhotonHandle,photonPFClusterIsoVals[iid].
begin(),photonPFClusterIsoVals[iid].
end());
728 fillerPhotonPFClusterIso.
fill();
732 for (
unsigned int iid=0; iid<gsfElectronPFClusterIsos.size(); ++iid) {
734 fillerGsfElectronPFClusterIso.
insert(outGsfElectronHandle,gsfElectronPFClusterIsoVals[iid].
begin(),gsfElectronPFClusterIsoVals[iid].
end());
735 fillerGsfElectronPFClusterIso.
fill();
const bool doPreshowerEcalHits_
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectronT_
size_type size() const
Size of the RefVector.
const StringCutObjectSelector< reco::Photon > slimRelinkPhotonSel_
const edm::EDGetTokenT< reco::ConversionCollection > singleConversionT_
const std::vector< std::string > outPhotonIds_
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > photonPFClusterIsoTs_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
reco::ConversionRefVector conversionsOneLeg() const
vector of references to one leg Conversion's
void push_back(Ptr< T > const &iPtr)
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > gsfElectronPFClusterIsoTs_
void insert(const H &h, I begin, I end)
const StringCutObjectSelector< reco::GsfElectron > keepGsfElectronSel_
const std::string outEBEEClusters_
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
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
const StringCutObjectSelector< reco::GsfElectron > relinkGsfElectronSel_
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
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)
const edm::EDGetTokenT< EcalRecHitCollection > preshowerEcalHits_
reco::PhotonCoreRef photonCore() const
returns a reference to the core photon object
const std::vector< std::string > outGsfElectronIds_
const std::string outSingleConversions_
const std::string outESClusters_
reco::ConversionRefVector conversions() const
vector of references to Conversion's
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
const std::vector< std::string > outPhotonPFClusterIsos_
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
const std::string outPhotons_
const std::string outGsfElectronPfCandMap_
const std::string outGsfElectronCores_
const edm::EDGetTokenT< reco::PhotonCollection > photonT_
void clearHitsAndFractions()
void conversion(EventAux const &from, EventAuxiliary &to)
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
void clear()
Clear the vector.
std::vector< Photon > PhotonCollection
collectin of Photon objects
const std::string outGsfElectrons_
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
const StringCutObjectSelector< reco::GsfElectron > slimRelinkGsfElectronSel_
virtual GsfElectronCoreRef core() const
const std::string outPhotonCores_
void clear()
Clear the PtrVector.
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
const std::string outEERecHits_
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
size_type size() const
Size of the RefVector.
const std::string outPhotonPfCandMap_
const edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
const CaloClusterPtr & seed() const
seed BasicCluster
size_t operator()(const DetId &id) const
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > photonIdTs_
const edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
ReducedEGProducer(const edm::ParameterSet &ps)
const edm::EDGetTokenT< reco::ConversionCollection > conversionT_
virtual void produce(edm::Event &evt, const edm::EventSetup &es) override final