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"));
115 produces< edm::ValueMap<bool> >(outid);
117 for (
const std::string &outid : outGsfElectronIds_) {
118 produces< edm::ValueMap<float> >(outid);
162 std::vector<edm::Handle<edm::ValueMap<bool> > > photonIdHandles(
photonIdTs_.size());
163 for (
unsigned int itok=0; itok<
photonIdTs_.size(); ++itok) {
167 std::vector<edm::Handle<edm::ValueMap<float> > > gsfElectronIdHandles(
gsfElectronIdTs_.size());
174 const CaloTopology *caloTopology = & (*theCaloTopology);
189 std::auto_ptr<edm::ValueMap<std::vector<reco::PFCandidateRef> > > photonPfCandMap(
new edm::ValueMap<std::vector<reco::PFCandidateRef> >);
190 std::auto_ptr<edm::ValueMap<std::vector<reco::PFCandidateRef> > > gsfElectronPfCandMap(
new edm::ValueMap<std::vector<reco::PFCandidateRef> >);
192 std::vector<std::auto_ptr<edm::ValueMap<bool> > > photonIds;
193 for (
unsigned int iid=0; iid<photonIdHandles.size(); ++iid) {
197 std::vector<std::auto_ptr<edm::ValueMap<float> > > gsfElectronIds;
198 for (
unsigned int iid=0; iid<gsfElectronIdHandles.size(); ++iid) {
203 std::map<reco::PhotonCoreRef, unsigned int> photonCoreMap;
204 std::map<reco::GsfElectronCoreRef, unsigned int> gsfElectronCoreMap;
205 std::map<reco::ConversionRef, unsigned int> conversionMap;
206 std::map<reco::ConversionRef, unsigned int> singleConversionMap;
207 std::map<reco::SuperClusterRef, unsigned int> superClusterMap;
208 std::map<reco::CaloClusterPtr, unsigned int> ebeeClusterMap;
209 std::map<reco::CaloClusterPtr, unsigned int> esClusterMap;
210 std::set<DetId> rechitMap;
212 std::set<unsigned int> superClusterFullRelinkMap;
215 std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecPho;
216 std::vector<std::vector<reco::PFCandidateRef>> pfCandIsoPairVecEle;
219 std::vector<std::vector<bool> > photonIdVals(photonIds.size());
220 std::vector<std::vector<float> > gsfElectronIdVals(gsfElectronIds.size());
223 for (
unsigned int ipho=0; ipho<photonHandle->size(); ++ipho) {
231 photons->push_back(photon);
234 pfCandIsoPairVecPho.push_back((*photonPfCandMapHandle)[photonref]);
237 for (
unsigned int iid=0; iid<photonIds.size(); ++iid) {
238 photonIdVals[iid].push_back( (*photonIdHandles[iid])[photonref] );
242 if (!photonCoreMap.count(photonCore)) {
243 photonCores->push_back(*photonCore);
244 photonCoreMap[
photonCore] = photonCores->size() - 1;
249 if (!slimRelink)
continue;
254 const auto &mappedsc = superClusterMap.find(superCluster);
257 unsigned int mappedscidx = 0;
258 if (mappedsc==superClusterMap.end()) {
259 superClusters->push_back(*superCluster);
260 mappedscidx = superClusters->size() - 1;
261 superClusterMap[superCluster] = mappedscidx;
264 mappedscidx = mappedsc->second;
268 if (relink) superClusterFullRelinkMap.insert(mappedscidx);
271 if (!relink)
continue;
275 if (!conversionMap.count(convref)) {
277 conversionMap[convref] = conversions->size() - 1;
284 if (!singleConversionMap.count(convref)) {
286 singleConversionMap[convref] = singleConversions->size() - 1;
293 for (
unsigned int iele = 0; iele<gsfElectronHandle->size(); ++iele) {
301 gsfElectrons->push_back(gsfElectron);
302 pfCandIsoPairVecEle.push_back((*gsfElectronPfCandMapHandle)[gsfElectronref]);
305 for (
unsigned int iid=0; iid<gsfElectronIds.size(); ++iid) {
306 gsfElectronIdVals[iid].push_back( (*gsfElectronIdHandles[iid])[gsfElectronref] );
310 if (!gsfElectronCoreMap.count(gsfElectronCore)) {
311 gsfElectronCores->push_back(*gsfElectronCore);
312 gsfElectronCoreMap[gsfElectronCore] = gsfElectronCores->size() - 1;
317 if (!slimRelink)
continue;
322 const auto &mappedsc = superClusterMap.find(superCluster);
325 unsigned int mappedscidx = 0;
326 if (mappedsc==superClusterMap.end()) {
327 superClusters->push_back(*superCluster);
328 mappedscidx = superClusters->size() - 1;
329 superClusterMap[superCluster] = mappedscidx;
332 mappedscidx = mappedsc->second;
336 if (relink) superClusterFullRelinkMap.insert(mappedscidx);
339 if (!relink)
continue;
343 if (!conversionMap.count(convref)) {
344 conversions->push_back(*convref);
345 conversionMap[convref] = conversions->size() - 1;
352 if (!singleConversionMap.count(convref)) {
353 singleConversions->push_back(*convref);
354 singleConversionMap[convref] = singleConversions->size() - 1;
359 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
364 if (!matched)
continue;
366 if (!conversionMap.count(convref)) {
367 conversions->push_back(conversion);
368 conversionMap[convref] = conversions->size() - 1;
374 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
379 if (!matched)
continue;
381 if (!singleConversionMap.count(convref)) {
382 singleConversions->push_back(conversion);
383 singleConversionMap[convref] = singleConversions->size() - 1;
391 for (
unsigned int isc = 0; isc<superClusters->size(); ++isc) {
395 if (!ebeeClusterMap.count(superCluster.
seed())) {
396 ebeeClusters->push_back(*superCluster.
seed());
397 ebeeClusterMap[superCluster.
seed()] = ebeeClusters->
size() - 1;
401 bool fullrelink = superClusterFullRelinkMap.count(isc);
409 if (!ebeeClusterMap.count(cluster)) {
410 ebeeClusters->push_back(*cluster);
411 ebeeClusterMap[cluster] = ebeeClusters->size() - 1;
413 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
414 rechitMap.insert(hitfrac.first);
417 bool barrel = cluster->hitsAndFractions().front().first.subdetId()==
EcalBarrel;
419 DetId seed = EcalClusterTools::getMaximum(*cluster, rhcol).first;
423 rechitMap.insert(
detid);
427 if (!esClusterMap.count(cluster)) {
428 esClusters->push_back(*cluster);
429 esClusterMap[cluster] = esClusters->size() - 1;
431 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
432 rechitMap.insert(hitfrac.first);
437 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
442 if (!matched)
continue;
444 if (!conversionMap.count(convref)) {
445 conversions->push_back(conversion);
446 conversionMap[convref] = conversions->size() - 1;
452 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
457 if (!matched)
continue;
459 if (!singleConversionMap.count(convref)) {
460 singleConversions->push_back(conversion);
461 singleConversionMap[convref] = singleConversions->size() - 1;
471 for (
const EcalRecHit &rechit : *barrelHitHandle) {
472 if (rechitMap.count(rechit.detid())) {
473 ebRecHits->push_back(rechit);
477 for (
const EcalRecHit &rechit : *endcapHitHandle) {
478 if (rechitMap.count(rechit.detid())) {
479 eeRecHits->push_back(rechit);
483 for (
const EcalRecHit &rechit : *preshowerHitHandle) {
484 if (rechitMap.count(rechit.detid())) {
485 esRecHits->push_back(rechit);
502 const auto &seedmapped = ebeeClusterMap.find(superCluster.seed());
503 if (seedmapped != ebeeClusterMap.end()) {
506 superCluster.setSeed(clusptr);
512 const auto &clustermapped = ebeeClusterMap.find(cluster);
513 if (clustermapped != ebeeClusterMap.end()) {
524 if (clusters.
size()) {
525 superCluster.setClusters(clusters);
531 const auto &clustermapped = esClusterMap.find(cluster);
532 if (clustermapped != esClusterMap.end()) {
543 if (esclusters.
size()) {
544 superCluster.setPreshowerClusters(esclusters);
556 const auto &scmapped = superClusterMap.find(
photonCore.superCluster());
557 if (scmapped != superClusterMap.end()) {
567 const auto &convmapped = conversionMap.find(convref);
568 if (convmapped != conversionMap.end()) {
578 if (outconvrefs.
size()) {
586 const auto &convmapped = singleConversionMap.find(convref);
587 if (convmapped != singleConversionMap.end()) {
593 outsingleconvrefs.
clear();
597 if (outsingleconvrefs.
size()) {
598 photonCore.setConversionsOneLeg(outsingleconvrefs);
605 const auto &scmapped = superClusterMap.find(gsfElectronCore.superCluster());
606 if (scmapped != superClusterMap.end()) {
609 gsfElectronCore.setSuperCluster(scref);
619 const auto &coremapped = photonCoreMap.find(photon.photonCore());
620 if (coremapped != photonCoreMap.end()) {
623 photon.setPhotonCore(coreref);
628 const auto &coremapped = gsfElectronCoreMap.find(gsfElectron.core());
629 if (coremapped != gsfElectronCoreMap.end()) {
632 gsfElectron.setCore(coreref);
644 fillerPhotons.insert(outPhotonHandle,pfCandIsoPairVecPho.begin(),pfCandIsoPairVecPho.end());
645 fillerPhotons.fill();
649 fillerGsfElectrons.insert(outGsfElectronHandle,pfCandIsoPairVecEle.begin(),pfCandIsoPairVecEle.end());
650 fillerGsfElectrons.fill();
656 for (
unsigned int iid=0; iid<photonIds.size(); ++iid) {
658 fillerPhotonId.
insert(outPhotonHandle,photonIdVals[iid].
begin(),photonIdVals[iid].
end());
659 fillerPhotonId.
fill();
664 for (
unsigned int iid=0; iid<gsfElectronIds.size(); ++iid) {
666 fillerGsfElectronId.
insert(outGsfElectronHandle,gsfElectronIdVals[iid].
begin(),gsfElectronIdVals[iid].
end());
667 fillerGsfElectronId.
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_
std::vector< std::string > outPhotonIds_
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)
void insert(const H &h, I begin, I end)
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
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
void clear()
Clear the vector.
std::vector< std::string > outGsfElectronIds_
std::string outConversions_
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
std::vector< Photon > PhotonCollection
collectin of Photon objects
StringCutObjectSelector< reco::GsfElectron > slimRelinkGsfElectronSel_
T const * product() const
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< edm::EDGetTokenT< edm::ValueMap< bool > > > photonIdTs_
std::string outEBRecHits_
std::string outESClusters_
StringCutObjectSelector< reco::GsfElectron > keepGsfElectronSel_
ReducedEGProducer(const edm::ParameterSet &ps)