47 keepPhotonSel_(config.getParameter<std::
string>(
"keepPhotons")),
48 slimRelinkPhotonSel_(config.getParameter<std::
string>(
"slimRelinkPhotons")),
49 relinkPhotonSel_(config.getParameter<std::
string>(
"relinkPhotons")),
50 keepGsfElectronSel_(config.getParameter<std::
string>(
"keepGsfElectrons")),
51 slimRelinkGsfElectronSel_(config.getParameter<std::
string>(
"slimRelinkGsfElectrons")),
52 relinkGsfElectronSel_(config.getParameter<std::
string>(
"relinkGsfElectrons"))
71 std::vector<edm::InputTag> photonidinputs(config.
getParameter<std::vector<edm::InputTag> >(
"photonIDSources"));
76 std::vector<edm::InputTag> gsfelectronidinputs(config.
getParameter<std::vector<edm::InputTag> >(
"gsfElectronIDSources"));
81 std::vector<edm::InputTag> photonpfclusterisoinputs(config.
getParameter<std::vector<edm::InputTag> >(
"photonPFClusterIsoSources"));
86 std::vector<edm::InputTag> gsfelectronpfclusterisoinputs(config.
getParameter<std::vector<edm::InputTag> >(
"gsfElectronPFClusterIsoSources"));
126 produces< edm::ValueMap<bool> >(outid);
128 for (
const std::string &outid : outGsfElectronIds_) {
129 produces< edm::ValueMap<float> >(outid);
131 for (
const std::string &outid : outPhotonPFClusterIsos_) {
132 produces< edm::ValueMap<float> >(outid);
134 for (
const std::string &outid : outGsfElectronPFClusterIsos_) {
135 produces< edm::ValueMap<float> >(outid);
178 std::vector<edm::Handle<edm::ValueMap<bool> > > photonIdHandles(
photonIdTs_.size());
179 for (
unsigned int itok=0; itok<
photonIdTs_.size(); ++itok) {
183 std::vector<edm::Handle<edm::ValueMap<float> > > gsfElectronIdHandles(
gsfElectronIdTs_.size());
193 std::vector<edm::Handle<edm::ValueMap<float> > > photonPFClusterIsoHandles(
photonPFClusterIsoTs_.size());
202 const CaloTopology *caloTopology = & (*theCaloTopology);
217 std::auto_ptr<edm::ValueMap<std::vector<reco::PFCandidateRef> > > photonPfCandMap(
new edm::ValueMap<std::vector<reco::PFCandidateRef> >);
218 std::auto_ptr<edm::ValueMap<std::vector<reco::PFCandidateRef> > > gsfElectronPfCandMap(
new edm::ValueMap<std::vector<reco::PFCandidateRef> >);
220 std::vector<std::auto_ptr<edm::ValueMap<bool> > > photonIds;
221 for (
unsigned int iid=0; iid<photonIdHandles.size(); ++iid) {
225 std::vector<std::auto_ptr<edm::ValueMap<float> > > gsfElectronIds;
226 for (
unsigned int iid=0; iid<gsfElectronIdHandles.size(); ++iid) {
230 std::vector<std::auto_ptr<edm::ValueMap<float> > > photonPFClusterIsos;
231 for (
unsigned int iid=0; iid<photonPFClusterIsoHandles.size(); ++iid) {
235 std::vector<std::auto_ptr<edm::ValueMap<float> > > gsfElectronPFClusterIsos;
236 for (
unsigned int iid=0; iid<gsfElectronPFClusterIsoHandles.size(); ++iid) {
241 std::map<reco::PhotonCoreRef, unsigned int> photonCoreMap;
242 std::map<reco::GsfElectronCoreRef, unsigned int> gsfElectronCoreMap;
243 std::map<reco::ConversionRef, unsigned int> conversionMap;
244 std::map<reco::ConversionRef, unsigned int> singleConversionMap;
245 std::map<reco::SuperClusterRef, unsigned int> superClusterMap;
246 std::map<reco::CaloClusterPtr, unsigned int> ebeeClusterMap;
247 std::map<reco::CaloClusterPtr, unsigned int> esClusterMap;
248 std::set<DetId> rechitMap;
250 std::set<unsigned int> superClusterFullRelinkMap;
253 std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecPho;
254 std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecEle;
257 std::vector<std::vector<bool> > photonIdVals(photonIds.size());
258 std::vector<std::vector<float> > gsfElectronIdVals(gsfElectronIds.size());
259 std::vector<std::vector<float> > photonPFClusterIsoVals(photonPFClusterIsos.size());
260 std::vector<std::vector<float> > gsfElectronPFClusterIsoVals(gsfElectronPFClusterIsos.size());
263 for (
unsigned int ipho=0; ipho<photonHandle->size(); ++ipho) {
271 photons->push_back(photon);
274 pfCandIsoPairVecPho.push_back((*photonPfCandMapHandle)[photonref]);
277 for (
unsigned int iid=0; iid<photonIds.size(); ++iid) {
278 photonIdVals[iid].push_back( (*photonIdHandles[iid])[photonref] );
281 for (
unsigned int iid=0; iid<photonPFClusterIsos.size(); ++iid) {
282 photonPFClusterIsoVals[iid].push_back( (*photonPFClusterIsoHandles[iid])[photonref] );
286 if (!photonCoreMap.count(photonCore)) {
287 photonCores->push_back(*photonCore);
288 photonCoreMap[
photonCore] = photonCores->size() - 1;
293 if (!slimRelink)
continue;
298 const auto &mappedsc = superClusterMap.find(superCluster);
301 unsigned int mappedscidx = 0;
302 if (mappedsc==superClusterMap.end()) {
303 superClusters->push_back(*superCluster);
304 mappedscidx = superClusters->size() - 1;
305 superClusterMap[superCluster] = mappedscidx;
308 mappedscidx = mappedsc->second;
312 if (relink) superClusterFullRelinkMap.insert(mappedscidx);
315 if (!relink)
continue;
319 if (!conversionMap.count(convref)) {
321 conversionMap[convref] = conversions->size() - 1;
328 if (!singleConversionMap.count(convref)) {
330 singleConversionMap[convref] = singleConversions->size() - 1;
337 for (
unsigned int iele = 0; iele<gsfElectronHandle->size(); ++iele) {
345 gsfElectrons->push_back(gsfElectron);
346 pfCandIsoPairVecEle.push_back((*gsfElectronPfCandMapHandle)[gsfElectronref]);
349 for (
unsigned int iid=0; iid<gsfElectronIds.size(); ++iid) {
350 gsfElectronIdVals[iid].push_back( (*gsfElectronIdHandles[iid])[gsfElectronref] );
353 for (
unsigned int iid=0; iid<gsfElectronPFClusterIsos.size(); ++iid) {
354 gsfElectronPFClusterIsoVals[iid].push_back( (*gsfElectronPFClusterIsoHandles[iid])[gsfElectronref] );
358 if (!gsfElectronCoreMap.count(gsfElectronCore)) {
359 gsfElectronCores->push_back(*gsfElectronCore);
360 gsfElectronCoreMap[gsfElectronCore] = gsfElectronCores->size() - 1;
365 if (!slimRelink)
continue;
370 const auto &mappedsc = superClusterMap.find(superCluster);
373 unsigned int mappedscidx = 0;
374 if (mappedsc==superClusterMap.end()) {
375 superClusters->push_back(*superCluster);
376 mappedscidx = superClusters->size() - 1;
377 superClusterMap[superCluster] = mappedscidx;
380 mappedscidx = mappedsc->second;
384 if (relink) superClusterFullRelinkMap.insert(mappedscidx);
387 if (!relink)
continue;
391 if (!conversionMap.count(convref)) {
392 conversions->push_back(*convref);
393 conversionMap[convref] = conversions->size() - 1;
400 if (!singleConversionMap.count(convref)) {
401 singleConversions->push_back(*convref);
402 singleConversionMap[convref] = singleConversions->size() - 1;
407 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
412 if (!matched)
continue;
414 if (!conversionMap.count(convref)) {
415 conversions->push_back(conversion);
416 conversionMap[convref] = conversions->size() - 1;
422 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
427 if (!matched)
continue;
429 if (!singleConversionMap.count(convref)) {
430 singleConversions->push_back(conversion);
431 singleConversionMap[convref] = singleConversions->size() - 1;
439 for (
unsigned int isc = 0; isc<superClusters->size(); ++isc) {
443 if (!ebeeClusterMap.count(superCluster.
seed())) {
444 ebeeClusters->push_back(*superCluster.
seed());
445 ebeeClusterMap[superCluster.
seed()] = ebeeClusters->
size() - 1;
449 bool fullrelink = superClusterFullRelinkMap.count(isc);
457 if (!ebeeClusterMap.count(cluster)) {
458 ebeeClusters->push_back(*cluster);
459 ebeeClusterMap[cluster] = ebeeClusters->size() - 1;
461 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
462 rechitMap.insert(hitfrac.first);
465 bool barrel = cluster->hitsAndFractions().front().first.subdetId()==
EcalBarrel;
467 DetId seed = EcalClusterTools::getMaximum(*cluster, rhcol).first;
471 rechitMap.insert(
detid);
475 if (!esClusterMap.count(cluster)) {
476 esClusters->push_back(*cluster);
477 esClusterMap[cluster] = esClusters->size() - 1;
479 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
480 rechitMap.insert(hitfrac.first);
485 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
490 if (!matched)
continue;
492 if (!conversionMap.count(convref)) {
493 conversions->push_back(conversion);
494 conversionMap[convref] = conversions->size() - 1;
500 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
505 if (!matched)
continue;
507 if (!singleConversionMap.count(convref)) {
508 singleConversions->push_back(conversion);
509 singleConversionMap[convref] = singleConversions->size() - 1;
519 for (
const EcalRecHit &rechit : *barrelHitHandle) {
520 if (rechitMap.count(rechit.detid())) {
521 ebRecHits->push_back(rechit);
525 for (
const EcalRecHit &rechit : *endcapHitHandle) {
526 if (rechitMap.count(rechit.detid())) {
527 eeRecHits->push_back(rechit);
531 for (
const EcalRecHit &rechit : *preshowerHitHandle) {
532 if (rechitMap.count(rechit.detid())) {
533 esRecHits->push_back(rechit);
550 const auto &seedmapped = ebeeClusterMap.find(superCluster.seed());
551 if (seedmapped != ebeeClusterMap.end()) {
554 superCluster.setSeed(clusptr);
560 const auto &clustermapped = ebeeClusterMap.find(cluster);
561 if (clustermapped != ebeeClusterMap.end()) {
572 if (clusters.
size()) {
573 superCluster.setClusters(clusters);
579 const auto &clustermapped = esClusterMap.find(cluster);
580 if (clustermapped != esClusterMap.end()) {
591 if (esclusters.
size()) {
592 superCluster.setPreshowerClusters(esclusters);
604 const auto &scmapped = superClusterMap.find(
photonCore.superCluster());
605 if (scmapped != superClusterMap.end()) {
615 const auto &convmapped = conversionMap.find(convref);
616 if (convmapped != conversionMap.end()) {
626 if (outconvrefs.
size()) {
634 const auto &convmapped = singleConversionMap.find(convref);
635 if (convmapped != singleConversionMap.end()) {
641 outsingleconvrefs.
clear();
645 if (outsingleconvrefs.
size()) {
646 photonCore.setConversionsOneLeg(outsingleconvrefs);
653 const auto &scmapped = superClusterMap.find(gsfElectronCore.superCluster());
654 if (scmapped != superClusterMap.end()) {
657 gsfElectronCore.setSuperCluster(scref);
667 const auto &coremapped = photonCoreMap.find(photon.photonCore());
668 if (coremapped != photonCoreMap.end()) {
671 photon.setPhotonCore(coreref);
676 const auto &coremapped = gsfElectronCoreMap.find(gsfElectron.core());
677 if (coremapped != gsfElectronCoreMap.end()) {
680 gsfElectron.setCore(coreref);
692 fillerPhotons.insert(outPhotonHandle,pfCandIsoPairVecPho.begin(),pfCandIsoPairVecPho.end());
693 fillerPhotons.fill();
697 fillerGsfElectrons.insert(outGsfElectronHandle,pfCandIsoPairVecEle.begin(),pfCandIsoPairVecEle.end());
698 fillerGsfElectrons.fill();
704 for (
unsigned int iid=0; iid<photonIds.size(); ++iid) {
706 fillerPhotonId.
insert(outPhotonHandle,photonIdVals[iid].
begin(),photonIdVals[iid].
end());
707 fillerPhotonId.
fill();
712 for (
unsigned int iid=0; iid<gsfElectronIds.size(); ++iid) {
714 fillerGsfElectronId.
insert(outGsfElectronHandle,gsfElectronIdVals[iid].
begin(),gsfElectronIdVals[iid].
end());
715 fillerGsfElectronId.
fill();
720 for (
unsigned int iid=0; iid<photonPFClusterIsos.size(); ++iid) {
722 fillerPhotonPFClusterIso.
insert(outPhotonHandle,photonPFClusterIsoVals[iid].
begin(),photonPFClusterIsoVals[iid].
end());
723 fillerPhotonPFClusterIso.
fill();
727 for (
unsigned int iid=0; iid<gsfElectronPFClusterIsos.size(); ++iid) {
729 fillerGsfElectronPFClusterIso.
insert(outGsfElectronHandle,gsfElectronPFClusterIsoVals[iid].
begin(),gsfElectronPFClusterIsoVals[iid].
end());
730 fillerGsfElectronPFClusterIso.
fill();
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectronT_
edm::EDGetTokenT< reco::ConversionCollection > conversionT_
std::string outPhotonCores_
std::string outGsfElectronCores_
size_type size() const
Size of the RefVector.
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
std::vector< std::string > outPhotonIds_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > photonPFClusterIsoTs_
std::string outPhotonPfCandMap_
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)
StringCutObjectSelector< reco::Photon > keepPhotonSel_
const CaloClusterPtrVector & clusters() const
const access to the cluster list itself
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > photonPfCandMapT_
std::string outGsfElectrons_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::PhotonCollection > photonT_
reco::PhotonCoreRef photonCore() const
returns a reference to the core photon object
std::string outGsfElectronPfCandMap_
std::string outEERecHits_
edm::EDGetTokenT< EcalRecHitCollection > preshowerEcalHits_
std::string outSingleConversions_
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > gsfElectronPfCandMapT_
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
StringCutObjectSelector< reco::Photon > slimRelinkPhotonSel_
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > gsfElectronIdTs_
const CaloClusterPtrVector & preshowerClusters() const
const access to the preshower cluster list itself
StringCutObjectSelector< reco::Photon > relinkPhotonSel_
edm::EDGetTokenT< reco::ConversionCollection > singleConversionT_
StringCutObjectSelector< reco::GsfElectron > relinkGsfElectronSel_
void clearHitsAndFractions()
void conversion(EventAux const &from, EventAuxiliary &to)
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
T const * product() const
void clear()
Clear the vector.
std::vector< std::string > outGsfElectronIds_
std::vector< Photon > PhotonCollection
collectin of Photon objects
std::string outConversions_
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
StringCutObjectSelector< reco::GsfElectron > slimRelinkGsfElectronSel_
virtual GsfElectronCoreRef core() const
std::vector< PhotonCore > PhotonCoreCollection
collectin of PhotonCore objects
std::string outESRecHits_
void clear()
Clear the PtrVector.
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
std::string outSuperClusters_
size_type size() const
Size of the RefVector.
std::string outEBEEClusters_
const CaloClusterPtr & seed() const
seed BasicCluster
std::vector< std::string > outPhotonPFClusterIsos_
std::vector< edm::EDGetTokenT< edm::ValueMap< bool > > > photonIdTs_
std::string outEBRecHits_
std::string outESClusters_
StringCutObjectSelector< reco::GsfElectron > keepGsfElectronSel_
ReducedEGProducer(const edm::ParameterSet &ps)
std::vector< std::string > outGsfElectronPFClusterIsos_