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;
342 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
347 if (!matched)
continue;
349 if (!conversionMap.count(convref)) {
350 conversions->push_back(conversion);
351 conversionMap[convref] = conversions->size() - 1;
357 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
362 if (!matched)
continue;
364 if (!singleConversionMap.count(convref)) {
365 singleConversions->push_back(conversion);
366 singleConversionMap[convref] = singleConversions->size() - 1;
374 for (
unsigned int isc = 0; isc<superClusters->size(); ++isc) {
378 if (!ebeeClusterMap.count(superCluster.
seed())) {
379 ebeeClusters->push_back(*superCluster.
seed());
380 ebeeClusterMap[superCluster.
seed()] = ebeeClusters->
size() - 1;
384 bool fullrelink = superClusterFullRelinkMap.count(isc);
392 if (!ebeeClusterMap.count(cluster)) {
393 ebeeClusters->push_back(*cluster);
394 ebeeClusterMap[cluster] = ebeeClusters->size() - 1;
396 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
397 rechitMap.insert(hitfrac.first);
400 bool barrel = cluster->hitsAndFractions().front().first.subdetId()==
EcalBarrel;
402 DetId seed = EcalClusterTools::getMaximum(*cluster, rhcol).first;
406 rechitMap.insert(
detid);
410 if (!esClusterMap.count(cluster)) {
411 esClusters->push_back(*cluster);
412 esClusterMap[cluster] = esClusters->size() - 1;
414 for (std::pair<DetId,float> hitfrac : cluster->hitsAndFractions()) {
415 rechitMap.insert(hitfrac.first);
420 for (
unsigned int iconv = 0; iconv<conversionHandle->size(); ++iconv) {
425 if (!matched)
continue;
427 if (!conversionMap.count(convref)) {
428 conversions->push_back(conversion);
429 conversionMap[convref] = conversions->size() - 1;
435 for (
unsigned int iconv = 0; iconv<singleConversionHandle->size(); ++iconv) {
440 if (!matched)
continue;
442 if (!singleConversionMap.count(convref)) {
443 singleConversions->push_back(conversion);
444 singleConversionMap[convref] = singleConversions->size() - 1;
454 for (
const EcalRecHit &rechit : *barrelHitHandle) {
455 if (rechitMap.count(rechit.detid())) {
456 ebRecHits->push_back(rechit);
460 for (
const EcalRecHit &rechit : *endcapHitHandle) {
461 if (rechitMap.count(rechit.detid())) {
462 eeRecHits->push_back(rechit);
466 for (
const EcalRecHit &rechit : *preshowerHitHandle) {
467 if (rechitMap.count(rechit.detid())) {
468 esRecHits->push_back(rechit);
485 const auto &seedmapped = ebeeClusterMap.find(superCluster.seed());
486 if (seedmapped != ebeeClusterMap.end()) {
489 superCluster.setSeed(clusptr);
495 const auto &clustermapped = ebeeClusterMap.find(cluster);
496 if (clustermapped != ebeeClusterMap.end()) {
507 if (clusters.
size()) {
508 superCluster.setClusters(clusters);
514 const auto &clustermapped = esClusterMap.find(cluster);
515 if (clustermapped != esClusterMap.end()) {
526 if (esclusters.
size()) {
527 superCluster.setPreshowerClusters(esclusters);
539 const auto &scmapped = superClusterMap.find(
photonCore.superCluster());
540 if (scmapped != superClusterMap.end()) {
550 const auto &convmapped = conversionMap.find(convref);
551 if (convmapped != conversionMap.end()) {
561 if (outconvrefs.
size()) {
569 const auto &convmapped = singleConversionMap.find(convref);
570 if (convmapped != singleConversionMap.end()) {
576 outsingleconvrefs.
clear();
580 if (outsingleconvrefs.
size()) {
581 photonCore.setConversionsOneLeg(outsingleconvrefs);
588 const auto &scmapped = superClusterMap.find(gsfElectronCore.superCluster());
589 if (scmapped != superClusterMap.end()) {
592 gsfElectronCore.setSuperCluster(scref);
602 const auto &coremapped = photonCoreMap.find(photon.photonCore());
603 if (coremapped != photonCoreMap.end()) {
606 photon.setPhotonCore(coreref);
611 const auto &coremapped = gsfElectronCoreMap.find(gsfElectron.core());
612 if (coremapped != gsfElectronCoreMap.end()) {
615 gsfElectron.setCore(coreref);
627 fillerPhotons.insert(outPhotonHandle,pfCandIsoPairVecPho.begin(),pfCandIsoPairVecPho.end());
628 fillerPhotons.fill();
632 fillerGsfElectrons.insert(outGsfElectronHandle,pfCandIsoPairVecEle.begin(),pfCandIsoPairVecEle.end());
633 fillerGsfElectrons.fill();
639 for (
unsigned int iid=0; iid<photonIds.size(); ++iid) {
641 fillerPhotonId.
insert(outPhotonHandle,photonIdVals[iid].
begin(),photonIdVals[iid].
end());
642 fillerPhotonId.
fill();
647 for (
unsigned int iid=0; iid<gsfElectronIds.size(); ++iid) {
649 fillerGsfElectronId.
insert(outGsfElectronHandle,gsfElectronIdVals[iid].
begin(),gsfElectronIdVals[iid].
end());
650 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)