CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PFClusterMatchedToPhotonsSelector Class Reference

#include <CommonTools/RecoAlgos/plugins/PFClusterMatchedToPhotonsSelector.cc>

Inheritance diagram for PFClusterMatchedToPhotonsSelector:
edm::stream::EDProducer<>

Public Member Functions

 PFClusterMatchedToPhotonsSelector (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociationassociationToken_
 
edm::EDGetTokenT< reco::GenParticleCollectiongenParticleToken_
 
double matchMaxDEDR2_
 
double matchMaxDR2_
 
edm::EDGetTokenT< reco::PFClusterCollectionparticleFlowClusterECALToken_
 
edm::EDGetTokenT< TrackingParticleCollectiontrackingParticleToken_
 
double volumeRadius_EB_
 
double volumeZ_EB_
 
double volumeZ_EE_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: Matches ECAL PF clusters to photons that do not convert

Implementation:

Definition at line 43 of file PFClusterMatchedToPhotonsSelector.cc.

Constructor & Destructor Documentation

◆ PFClusterMatchedToPhotonsSelector()

PFClusterMatchedToPhotonsSelector::PFClusterMatchedToPhotonsSelector ( const edm::ParameterSet iConfig)

Definition at line 63 of file PFClusterMatchedToPhotonsSelector.cc.

References associationToken_, genParticleToken_, edm::ParameterSet::getParameter(), matchMaxDEDR2_, matchMaxDR2_, particleFlowClusterECALToken_, trackingParticleToken_, volumeRadius_EB_, volumeZ_EB_, and volumeZ_EE_.

63  {
64  //now do what ever initialization is needed
66  consumes<reco::PFClusterCollection>(iConfig.getParameter<edm::InputTag>("pfClustersTag"));
68  consumes<reco::PFCluster::EEtoPSAssociation>(iConfig.getParameter<edm::InputTag>("pfClustersTag"));
70  consumes<TrackingParticleCollection>(iConfig.getParameter<edm::InputTag>("trackingParticleTag"));
71  genParticleToken_ = consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("genParticleTag"));
72 
73  matchMaxDR2_ = iConfig.getParameter<double>("maxDR2");
74  matchMaxDEDR2_ = iConfig.getParameter<double>("maxDEDR2");
75  volumeZ_EB_ = iConfig.getParameter<double>("volumeZ_EB");
76  volumeRadius_EB_ = iConfig.getParameter<double>("volumeRadius_EB");
77  volumeZ_EE_ = iConfig.getParameter<double>("volumeZ_EE");
78 
79  produces<reco::PFClusterCollection>();
80  produces<reco::PFCluster::EEtoPSAssociation>();
81  produces<edm::ValueMap<reco::GenParticleRef> >();
82 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
edm::EDGetTokenT< reco::PFClusterCollection > particleFlowClusterECALToken_
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > associationToken_

Member Function Documentation

◆ fillDescriptions()

void PFClusterMatchedToPhotonsSelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 84 of file PFClusterMatchedToPhotonsSelector.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_2022v15_cff::InputTag.

84  {
86  desc.add<edm::InputTag>("pfClustersTag", edm::InputTag("particleFlowClusterECAL"));
87  desc.add<edm::InputTag>("trackingParticleTag", edm::InputTag("mix", "MergedTrackTruth"));
88  desc.add<edm::InputTag>("genParticleTag", edm::InputTag("genParticles"));
89  desc.add<double>("maxDR2", 0.1 * 0.1);
90  desc.add<double>("maxDEDR2", 0.5 * 0.5);
91  desc.add<double>("volumeZ_EB", 304.5);
92  desc.add<double>("volumeRadius_EB", 123.8);
93  desc.add<double>("volumeZ_EE", 317.0);
94  descriptions.add("pfClusterMatchedToPhotonsSelector", desc);
95 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void PFClusterMatchedToPhotonsSelector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 97 of file PFClusterMatchedToPhotonsSelector.cc.

References funct::abs(), associationToken_, reco::deltaR2(), edm::helper::Filler< Map >::fill(), genParticleToken_, mps_fire::i, iEvent, edm::helper::Filler< Map >::insert(), trackerHitRTTI::isMatched(), matchMaxDEDR2_, matchMaxDR2_, eostools::move(), MillePedeFileConverter_cfg::out, particleFlowClusterECALToken_, edm::Handle< T >::product(), jetsAK4_CHS_cff::sort, sortByKey(), trackingParticleToken_, volumeRadius_EB_, volumeZ_EB_, and volumeZ_EE_.

97  {
98  edm::Handle<reco::PFClusterCollection> particleFlowClusterECALHandle_;
100  edm::Handle<TrackingParticleCollection> trackingParticleHandle_;
101  edm::Handle<reco::GenParticleCollection> genParticleHandle_;
102  iEvent.getByToken(particleFlowClusterECALToken_, particleFlowClusterECALHandle_);
103  iEvent.getByToken(trackingParticleToken_, trackingParticleHandle_);
104  iEvent.getByToken(genParticleToken_, genParticleHandle_);
105  iEvent.getByToken(associationToken_, associationHandle_);
106 
107  std::unique_ptr<reco::PFClusterCollection> out = std::make_unique<reco::PFClusterCollection>();
108  std::unique_ptr<reco::PFCluster::EEtoPSAssociation> association_out =
109  std::make_unique<reco::PFCluster::EEtoPSAssociation>();
110  std::unique_ptr<edm::ValueMap<reco::GenParticleRef> > genmatching_out =
111  std::make_unique<edm::ValueMap<reco::GenParticleRef> >();
112 
113  std::vector<reco::GenParticleRef> genmatching;
114 
115  size_t iN(0);
116  for (size_t iP = 0; iP < particleFlowClusterECALHandle_->size(); iP++) {
117  auto&& pfCluster = particleFlowClusterECALHandle_->at(iP);
118  bool isMatched = false;
120 
121  // Preselect PFclusters
122  if (pfCluster.energy() <= 0) {
123  continue;
124  }
125 
126  for (auto&& trackingParticle : *trackingParticleHandle_) {
127  if (trackingParticle.pdgId() != 22)
128  continue;
129  if (trackingParticle.status() != 1)
130  continue;
131  matchedKey = trackingParticle.genParticles().at(0).key();
132  float dR2 = reco::deltaR2(trackingParticle, pfCluster.position());
133  if (dR2 > matchMaxDR2_)
134  continue;
135  float dE = 1. - trackingParticle.genParticles().at(0)->energy() / pfCluster.energy();
136  if ((dR2 + dE * dE) > matchMaxDEDR2_)
137  continue;
138 
139  bool isConversion = false;
140  for (auto&& vertRef : trackingParticle.decayVertices()) {
141  if (vertRef->position().rho() > volumeRadius_EB_ && std::abs(vertRef->position().z()) < volumeZ_EB_)
142  continue;
143  if (std::abs(vertRef->position().z()) > volumeZ_EE_)
144  continue;
145 
146  for (auto&& tpRef : vertRef->daughterTracks()) {
147  if (std::abs(tpRef->pdgId()) == 11)
148  isConversion = true;
149  break;
150  }
151  if (isConversion)
152  break;
153  }
154  if (isConversion)
155  continue;
156 
157  isMatched = true;
158  break;
159  }
160 
161  if (isMatched) {
162  out->push_back(pfCluster);
163  for (size_t i = 0; i < associationHandle_.product()->size(); i++) {
164  if (associationHandle_.product()->at(i).first == iP) {
165  association_out->push_back(std::make_pair(iN, associationHandle_.product()->at(i).second));
166  }
167  }
168  genmatching.push_back(edm::Ref<reco::GenParticleCollection>(genParticleHandle_, matchedKey));
169  }
170  }
171 
172  std::sort(association_out->begin(), association_out->end(), sortByKey);
174  iEvent.put(std::move(association_out));
175 
176  edm::ValueMap<reco::GenParticleRef>::Filler mapFiller(*genmatching_out);
177  mapFiller.insert(pfClusterHandle, genmatching.begin(), genmatching.end());
178  mapFiller.fill();
179  iEvent.put(std::move(genmatching_out));
180 }
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
T const * product() const
Definition: Handle.h:70
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleToken_
bool isMatched(TrackingRecHit const &hit)
edm::EDGetTokenT< reco::PFClusterCollection > particleFlowClusterECALToken_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
bool sortByKey(const EEPSPair &a, const EEPSPair &b)
edm::EDGetTokenT< reco::PFCluster::EEtoPSAssociation > associationToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ associationToken_

edm::EDGetTokenT<reco::PFCluster::EEtoPSAssociation> PFClusterMatchedToPhotonsSelector::associationToken_
private

◆ genParticleToken_

edm::EDGetTokenT<reco::GenParticleCollection> PFClusterMatchedToPhotonsSelector::genParticleToken_
private

◆ matchMaxDEDR2_

double PFClusterMatchedToPhotonsSelector::matchMaxDEDR2_
private

◆ matchMaxDR2_

double PFClusterMatchedToPhotonsSelector::matchMaxDR2_
private

◆ particleFlowClusterECALToken_

edm::EDGetTokenT<reco::PFClusterCollection> PFClusterMatchedToPhotonsSelector::particleFlowClusterECALToken_
private

◆ trackingParticleToken_

edm::EDGetTokenT<TrackingParticleCollection> PFClusterMatchedToPhotonsSelector::trackingParticleToken_
private

◆ volumeRadius_EB_

double PFClusterMatchedToPhotonsSelector::volumeRadius_EB_
private

◆ volumeZ_EB_

double PFClusterMatchedToPhotonsSelector::volumeZ_EB_
private

◆ volumeZ_EE_

double PFClusterMatchedToPhotonsSelector::volumeZ_EE_
private