4 #include <unordered_set>
51 return std::hash<uint32_t>()(
id.rawId());
64 photonPfCandMapT_(consumes<edm::ValueMap<std::vector<
reco::
PFCandidateRef> > >(config.getParameter<edm::
InputTag>(
"photonsPFValMap"))),
65 gsfElectronPfCandMapT_(consumes<edm::ValueMap<std::vector<
reco::
PFCandidateRef> > >(config.getParameter<edm::
InputTag>(
"gsfElectronsPFValMap"))),
67 outPhotons_(
"reducedGedPhotons"),
68 outPhotonCores_(
"reducedGedPhotonCores"),
69 outGsfElectrons_(
"reducedGedGsfElectrons"),
70 outGsfElectronCores_(
"reducedGedGsfElectronCores"),
71 outConversions_(
"reducedConversions"),
72 outSingleConversions_(
"reducedSingleLegConversions"),
73 outSuperClusters_(
"reducedSuperClusters"),
74 outEBEEClusters_(
"reducedEBEEClusters"),
75 outESClusters_(
"reducedESClusters"),
76 outEBRecHits_(
"reducedEBRecHits"),
77 outEERecHits_(
"reducedEERecHits"),
78 outESRecHits_(
"reducedESRecHits"),
79 outPhotonPfCandMap_(
"reducedPhotonPfCandMap"),
80 outGsfElectronPfCandMap_(
"reducedGsfElectronPfCandMap"),
81 outPhotonIds_(config.getParameter<std::vector<std::
string> >(
"photonIDOutput")),
82 outGsfElectronIds_(config.getParameter<std::vector<std::
string> >(
"gsfElectronIDOutput")),
83 outPhotonPFClusterIsos_(config.getParameter<std::vector<std::
string> >(
"photonPFClusterIsoOutput")),
84 outGsfElectronPFClusterIsos_(config.getParameter<std::vector<std::
string> >(
"gsfElectronPFClusterIsoOutput")),
85 keepPhotonSel_(config.getParameter<std::
string>(
"keepPhotons")),
86 slimRelinkPhotonSel_(config.getParameter<std::
string>(
"slimRelinkPhotons")),
87 relinkPhotonSel_(config.getParameter<std::
string>(
"relinkPhotons")),
88 keepGsfElectronSel_(config.getParameter<std::
string>(
"keepGsfElectrons")),
89 slimRelinkGsfElectronSel_(config.getParameter<std::
string>(
"slimRelinkGsfElectrons")),
90 relinkGsfElectronSel_(config.getParameter<std::
string>(
"relinkGsfElectrons"))
92 const std::vector<edm::InputTag>& photonidinputs =
93 config.
getParameter<std::vector<edm::InputTag> >(
"photonIDSources");
98 const std::vector<edm::InputTag>& gsfelectronidinputs =
99 config.
getParameter<std::vector<edm::InputTag> >(
"gsfElectronIDSources");
104 const std::vector<edm::InputTag>& photonpfclusterisoinputs =
105 config.
getParameter<std::vector<edm::InputTag> >(
"photonPFClusterIsoSources");
110 const std::vector<edm::InputTag>& gsfelectronpfclusterisoinputs =
111 config.
getParameter<std::vector<edm::InputTag> >(
"gsfElectronPFClusterIsoSources");
131 produces< edm::ValueMap<bool> >(outid);
134 produces< edm::ValueMap<float> >(outid);
137 produces< edm::ValueMap<float> >(outid);
140 produces< edm::ValueMap<float> >(outid);
183 std::vector<edm::Handle<edm::ValueMap<bool> > > photonIdHandles(
photonIdTs_.size());
184 for (
unsigned int itok=0; itok<
photonIdTs_.size(); ++itok) {
188 std::vector<edm::Handle<edm::ValueMap<float> > > gsfElectronIdHandles(
gsfElectronIdTs_.size());
198 std::vector<edm::Handle<edm::ValueMap<float> > > photonPFClusterIsoHandles(
photonPFClusterIsoTs_.size());
205 const CaloTopology *caloTopology = & (*theCaloTopology);
220 std::auto_ptr<edm::ValueMap<std::vector<reco::PFCandidateRef> > > photonPfCandMap(
new edm::ValueMap<std::vector<reco::PFCandidateRef> >);
221 std::auto_ptr<edm::ValueMap<std::vector<reco::PFCandidateRef> > > gsfElectronPfCandMap(
new edm::ValueMap<std::vector<reco::PFCandidateRef> >);
223 std::vector<std::auto_ptr<edm::ValueMap<bool> > > photonIds;
224 for (
unsigned int iid=0; iid<photonIdHandles.size(); ++iid) {
228 std::vector<std::auto_ptr<edm::ValueMap<float> > > gsfElectronIds;
229 for (
unsigned int iid=0; iid<gsfElectronIdHandles.size(); ++iid) {
233 std::vector<std::auto_ptr<edm::ValueMap<float> > > photonPFClusterIsos;
234 for (
unsigned int iid=0; iid<photonPFClusterIsoHandles.size(); ++iid) {
238 std::vector<std::auto_ptr<edm::ValueMap<float> > > gsfElectronPFClusterIsos;
239 for (
unsigned int iid=0; iid<gsfElectronPFClusterIsoHandles.size(); ++iid) {
244 std::map<reco::PhotonCoreRef, unsigned int> photonCoreMap;
245 std::map<reco::GsfElectronCoreRef, unsigned int> gsfElectronCoreMap;
246 std::map<reco::ConversionRef, unsigned int> conversionMap;
247 std::map<reco::ConversionRef, unsigned int> singleConversionMap;
248 std::map<reco::SuperClusterRef, unsigned int> superClusterMap;
249 std::map<reco::CaloClusterPtr, unsigned int> ebeeClusterMap;
250 std::map<reco::CaloClusterPtr, unsigned int> esClusterMap;
251 std::unordered_set<DetId> rechitMap;
253 std::unordered_set<unsigned int> superClusterFullRelinkMap;
256 std::vector<std::vector<reco::PFCandidateRef> > pfCandIsoPairVecPho;
257 std::vector<std::vector<reco::PFCandidateRef> > pfCandIsoPairVecEle;
260 std::vector<std::vector<bool> > photonIdVals(photonIds.size());
261 std::vector<std::vector<float> > gsfElectronIdVals(gsfElectronIds.size());
262 std::vector<std::vector<float> > photonPFClusterIsoVals(photonPFClusterIsos.size());
263 std::vector<std::vector<float> > gsfElectronPFClusterIsoVals(gsfElectronPFClusterIsos.size());
266 for (
unsigned int ipho=0; ipho<photonHandle->size(); ++ipho) {
274 photons->push_back(photon);
277 pfCandIsoPairVecPho.push_back((*photonPfCandMapHandle)[photonref]);
280 for (
unsigned int iid=0; iid<photonIds.size(); ++iid) {
281 photonIdVals[iid].push_back( (*photonIdHandles[iid])[photonref] );
284 for (
unsigned int iid=0; iid<photonPFClusterIsos.size(); ++iid) {
285 photonPFClusterIsoVals[iid].push_back( (*photonPFClusterIsoHandles[iid])[photonref] );
289 if (!photonCoreMap.count(photonCore)) {
290 photonCores->push_back(*photonCore);
291 photonCoreMap[
photonCore] = photonCores->size() - 1;
296 if (!slimRelink)
continue;
301 const auto &mappedsc = superClusterMap.find(superCluster);
304 unsigned int mappedscidx = 0;
305 if (mappedsc==superClusterMap.end()) {
306 superClusters->push_back(*superCluster);
307 mappedscidx = superClusters->size() - 1;
308 superClusterMap[superCluster] = mappedscidx;
311 mappedscidx = mappedsc->second;
315 if (relink) superClusterFullRelinkMap.insert(mappedscidx);
318 if (!relink)
continue;
322 if (!conversionMap.count(convref)) {
324 conversionMap[convref] = conversions->size() - 1;
331 if (!singleConversionMap.count(convref)) {
333 singleConversionMap[convref] = singleConversions->size() - 1;
340 for (
unsigned int iele = 0; iele<gsfElectronHandle->size(); ++iele) {
348 gsfElectrons->push_back(gsfElectron);
349 pfCandIsoPairVecEle.push_back((*gsfElectronPfCandMapHandle)[gsfElectronref]);
352 for (
unsigned int iid=0; iid<gsfElectronIds.size(); ++iid) {
353 gsfElectronIdVals[iid].push_back( (*gsfElectronIdHandles[iid])[gsfElectronref] );
356 for (
unsigned int iid=0; iid<gsfElectronPFClusterIsos.size(); ++iid) {
357 gsfElectronPFClusterIsoVals[iid].push_back( (*gsfElectronPFClusterIsoHandles[iid])[gsfElectronref] );
361 if (!gsfElectronCoreMap.count(gsfElectronCore)) {
362 gsfElectronCores->push_back(*gsfElectronCore);
363 gsfElectronCoreMap[gsfElectronCore] = gsfElectronCores->size() - 1;
368 if (!slimRelink)
continue;
373 const auto &mappedsc = superClusterMap.find(superCluster);
376 unsigned int mappedscidx = 0;
377 if (mappedsc==superClusterMap.end()) {
378 superClusters->push_back(*superCluster);
379 mappedscidx = superClusters->size() - 1;
380 superClusterMap[superCluster] = mappedscidx;
383 mappedscidx = mappedsc->second;
387 if (relink) superClusterFullRelinkMap.insert(mappedscidx);
390 if (!relink)
continue;
394 if (!conversionMap.count(convref)) {
395 conversions->push_back(*convref);
396 conversionMap[convref] = conversions->size() - 1;
403 if (!singleConversionMap.count(convref)) {
404 singleConversions->push_back(*convref);
405 singleConversionMap[convref] = singleConversions->size() - 1;
410 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
415 if (!matched)
continue;
417 if (!conversionMap.count(convref)) {
418 conversions->push_back(conversion);
419 conversionMap[convref] = conversions->size() - 1;
425 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
430 if (!matched)
continue;
432 if (!singleConversionMap.count(convref)) {
433 singleConversions->push_back(conversion);
434 singleConversionMap[convref] = singleConversions->size() - 1;
442 for (
unsigned int isc = 0; isc<superClusters->size(); ++isc) {
446 if (!ebeeClusterMap.count(superCluster.
seed())) {
447 ebeeClusters->push_back(*superCluster.
seed());
448 ebeeClusterMap[superCluster.
seed()] = ebeeClusters->
size() - 1;
452 bool fullrelink = superClusterFullRelinkMap.count(isc);
460 if (!ebeeClusterMap.count(cluster)) {
461 ebeeClusters->push_back(*cluster);
462 ebeeClusterMap[cluster] = ebeeClusters->size() - 1;
464 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
465 rechitMap.insert(hitfrac.first);
468 bool barrel = cluster->hitsAndFractions().front().first.subdetId()==
EcalBarrel;
470 DetId seed = EcalClusterTools::getMaximum(*cluster, rhcol).first;
474 rechitMap.insert(
detid);
478 if (!esClusterMap.count(cluster)) {
479 esClusters->push_back(*cluster);
480 esClusterMap[cluster] = esClusters->size() - 1;
482 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
483 rechitMap.insert(hitfrac.first);
488 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
493 if (!matched)
continue;
495 if (!conversionMap.count(convref)) {
496 conversions->push_back(conversion);
497 conversionMap[convref] = conversions->size() - 1;
503 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
508 if (!matched)
continue;
510 if (!singleConversionMap.count(convref)) {
511 singleConversions->push_back(conversion);
512 singleConversionMap[convref] = singleConversions->size() - 1;
522 for (
const EcalRecHit &rechit : *barrelHitHandle) {
523 if (rechitMap.count(rechit.detid())) {
524 ebRecHits->push_back(rechit);
528 for (
const EcalRecHit &rechit : *endcapHitHandle) {
529 if (rechitMap.count(rechit.detid())) {
530 eeRecHits->push_back(rechit);
534 for (
const EcalRecHit &rechit : *preshowerHitHandle) {
535 if (rechitMap.count(rechit.detid())) {
536 esRecHits->push_back(rechit);
553 const auto &seedmapped = ebeeClusterMap.find(superCluster.seed());
554 if (seedmapped != ebeeClusterMap.end()) {
557 superCluster.setSeed(clusptr);
563 const auto &clustermapped = ebeeClusterMap.find(cluster);
564 if (clustermapped != ebeeClusterMap.end()) {
575 if (clusters.
size()) {
576 superCluster.setClusters(clusters);
582 const auto &clustermapped = esClusterMap.find(cluster);
583 if (clustermapped != esClusterMap.end()) {
594 if (esclusters.
size()) {
595 superCluster.setPreshowerClusters(esclusters);
607 const auto &scmapped = superClusterMap.find(
photonCore.superCluster());
608 if (scmapped != superClusterMap.end()) {
618 const auto &convmapped = conversionMap.find(convref);
619 if (convmapped != conversionMap.end()) {
629 if (outconvrefs.
size()) {
637 const auto &convmapped = singleConversionMap.find(convref);
638 if (convmapped != singleConversionMap.end()) {
644 outsingleconvrefs.
clear();
648 if (outsingleconvrefs.
size()) {
649 photonCore.setConversionsOneLeg(outsingleconvrefs);
656 const auto &scmapped = superClusterMap.find(gsfElectronCore.superCluster());
657 if (scmapped != superClusterMap.end()) {
660 gsfElectronCore.setSuperCluster(scref);
670 const auto &coremapped = photonCoreMap.find(photon.photonCore());
671 if (coremapped != photonCoreMap.end()) {
674 photon.setPhotonCore(coreref);
679 const auto &coremapped = gsfElectronCoreMap.find(gsfElectron.core());
680 if (coremapped != gsfElectronCoreMap.end()) {
683 gsfElectron.setCore(coreref);
695 fillerPhotons.insert(outPhotonHandle,pfCandIsoPairVecPho.begin(),pfCandIsoPairVecPho.end());
696 fillerPhotons.fill();
700 fillerGsfElectrons.insert(outGsfElectronHandle,pfCandIsoPairVecEle.begin(),pfCandIsoPairVecEle.end());
701 fillerGsfElectrons.fill();
707 for (
unsigned int iid=0; iid<photonIds.size(); ++iid) {
709 fillerPhotonId.
insert(outPhotonHandle,photonIdVals[iid].
begin(),photonIdVals[iid].
end());
710 fillerPhotonId.
fill();
715 for (
unsigned int iid=0; iid<gsfElectronIds.size(); ++iid) {
717 fillerGsfElectronId.
insert(outGsfElectronHandle,gsfElectronIdVals[iid].
begin(),gsfElectronIdVals[iid].
end());
718 fillerGsfElectronId.
fill();
723 for (
unsigned int iid=0; iid<photonPFClusterIsos.size(); ++iid) {
725 fillerPhotonPFClusterIso.
insert(outPhotonHandle,photonPFClusterIsoVals[iid].
begin(),photonPFClusterIsoVals[iid].
end());
726 fillerPhotonPFClusterIso.
fill();
730 for (
unsigned int iid=0; iid<gsfElectronPFClusterIsos.size(); ++iid) {
732 fillerGsfElectronPFClusterIso.
insert(outGsfElectronHandle,gsfElectronPFClusterIsoVals[iid].
begin(),gsfElectronPFClusterIsoVals[iid].
end());
733 fillerGsfElectronPFClusterIso.
fill();
T getParameter(std::string const &) const
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_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
reco::ConversionRefVector conversions() const
vector of references to Conversion's
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
std::vector< GsfElectronCore > GsfElectronCoreCollection
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
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()
virtual void produce(edm::Event &evt, const edm::EventSetup &es) overridefinal
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
std::vector< PhotonCore > PhotonCoreCollection
collectin of PhotonCore objects
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_