CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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_
 
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
 
edm::EDGetTokenT< reco::GenParticleCollectiongenParticleToken_
 
double matchMaxDEDR2_
 
double matchMaxDR2_
 
edm::EDGetTokenT< reco::PFClusterCollectionparticleFlowClusterECALToken_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitsEB_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitsEE_
 
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 45 of file PFClusterMatchedToPhotonsSelector.cc.

Constructor & Destructor Documentation

◆ PFClusterMatchedToPhotonsSelector()

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

Definition at line 70 of file PFClusterMatchedToPhotonsSelector.cc.

71  : ecalClusterToolsESGetTokens_{consumesCollector()} {
72  //now do what ever initialization is needed
74  consumes<reco::PFClusterCollection>(iConfig.getParameter<edm::InputTag>("pfClustersTag"));
76  consumes<reco::PFCluster::EEtoPSAssociation>(iConfig.getParameter<edm::InputTag>("pfClustersTag"));
78  consumes<TrackingParticleCollection>(iConfig.getParameter<edm::InputTag>("trackingParticleTag"));
79  genParticleToken_ = consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("genParticleTag"));
80  recHitsEB_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsEBLabel"));
81  recHitsEE_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsEELabel"));
82 
83  matchMaxDR2_ = iConfig.getParameter<double>("maxDR2");
84  matchMaxDEDR2_ = iConfig.getParameter<double>("maxDEDR2");
85  volumeZ_EB_ = iConfig.getParameter<double>("volumeZ_EB");
86  volumeRadius_EB_ = iConfig.getParameter<double>("volumeRadius_EB");
87  volumeZ_EE_ = iConfig.getParameter<double>("volumeZ_EE");
88 
89  produces<reco::PFClusterCollection>();
90  produces<edm::ValueMap<reco::GenParticleRef> >();
91  produces<edm::ValueMap<int> >();
92  produces<edm::ValueMap<float> >("PS1");
93  produces<edm::ValueMap<float> >("PS2");
94 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitsEB_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
edm::EDGetTokenT< EcalRecHitCollection > recHitsEE_
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 96 of file PFClusterMatchedToPhotonsSelector.cc.

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

96  {
98  desc.add<edm::InputTag>("pfClustersTag", edm::InputTag("particleFlowClusterECAL"));
99  desc.add<edm::InputTag>("trackingParticleTag", edm::InputTag("mix", "MergedTrackTruth"));
100  desc.add<edm::InputTag>("genParticleTag", edm::InputTag("genParticles"));
101  desc.add<edm::InputTag>("recHitsEBLabel", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
102  desc.add<edm::InputTag>("recHitsEELabel", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
103  desc.add<double>("maxDR2", 0.1 * 0.1);
104  desc.add<double>("maxDEDR2", 0.5 * 0.5);
105  desc.add<double>("volumeZ_EB", 304.5);
106  desc.add<double>("volumeRadius_EB", 123.8);
107  desc.add<double>("volumeZ_EE", 317.0);
108  descriptions.add("pfClusterMatchedToPhotonsSelector", desc);
109 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 111 of file PFClusterMatchedToPhotonsSelector.cc.

References funct::abs(), associationToken_, reco::deltaR2(), ALPAKA_ACCELERATOR_NAMESPACE::dR2(), PFLayer::ECAL_BARREL, ecalClusterToolsESGetTokens_, reco::PFCluster::energy(), edm::helper::Filler< Map >::fill(), genParticleToken_, EcalClusterLazyToolsBase::ESGetTokens::get(), iEvent, edm::helper::Filler< Map >::insert(), trackerHitRTTI::isMatched(), reco::PFCluster::layer(), matchMaxDEDR2_, matchMaxDR2_, eostools::move(), MillePedeFileConverter_cfg::out, particleFlowClusterECALToken_, edm::Handle< T >::product(), PFLayer::PS1, PFLayer::PS2, recHitsEB_, recHitsEE_, sortByKey(), trackingParticleToken_, volumeRadius_EB_, volumeZ_EB_, and volumeZ_EE_.

111  {
112  edm::Handle<reco::PFClusterCollection> particleFlowClusterECALHandle_;
114  edm::Handle<TrackingParticleCollection> trackingParticleHandle_;
115  edm::Handle<reco::GenParticleCollection> genParticleHandle_;
116 
117  iEvent.getByToken(particleFlowClusterECALToken_, particleFlowClusterECALHandle_);
118  iEvent.getByToken(trackingParticleToken_, trackingParticleHandle_);
119  iEvent.getByToken(genParticleToken_, genParticleHandle_);
120  iEvent.getByToken(associationToken_, associationHandle_);
121 
122  std::unique_ptr<reco::PFClusterCollection> out = std::make_unique<reco::PFClusterCollection>();
123  std::unique_ptr<edm::ValueMap<reco::GenParticleRef> > genmatching_out =
124  std::make_unique<edm::ValueMap<reco::GenParticleRef> >();
125  std::unique_ptr<edm::ValueMap<int> > clustersize_out = std::make_unique<edm::ValueMap<int> >();
126  std::unique_ptr<edm::ValueMap<float> > energyPS1_out = std::make_unique<edm::ValueMap<float> >();
127  std::unique_ptr<edm::ValueMap<float> > energyPS2_out = std::make_unique<edm::ValueMap<float> >();
128 
129  std::vector<reco::GenParticleRef> genmatching;
130  std::vector<int> clustersize;
131  std::vector<float> energyPS1;
132  std::vector<float> energyPS2;
133 
135 
136  for (size_t iP = 0; iP < particleFlowClusterECALHandle_->size(); iP++) {
137  auto&& pfCluster = particleFlowClusterECALHandle_->at(iP);
138  bool isMatched = false;
140 
141  // Preselect PFclusters
142  if (pfCluster.energy() <= 0) {
143  continue;
144  }
145 
146  for (auto&& trackingParticle : *trackingParticleHandle_) {
147  if (trackingParticle.pdgId() != 22)
148  continue;
149  if (trackingParticle.status() != 1)
150  continue;
151  matchedKey = trackingParticle.genParticles().at(0).key();
152 
153  float dR2 = reco::deltaR2(trackingParticle, pfCluster.position());
154  if (dR2 > matchMaxDR2_)
155  continue;
156  float dE = 1. - trackingParticle.genParticles().at(0)->energy() / pfCluster.energy();
157  if ((dR2 + dE * dE) > matchMaxDEDR2_)
158  continue;
159 
160  bool isConversion = false;
161  for (auto&& vertRef : trackingParticle.decayVertices()) {
162  if (vertRef->position().rho() > volumeRadius_EB_ && std::abs(vertRef->position().z()) < volumeZ_EB_)
163  continue;
164  if (std::abs(vertRef->position().z()) > volumeZ_EE_)
165  continue;
166 
167  for (auto&& tpRef : vertRef->daughterTracks()) {
168  if (std::abs(tpRef->pdgId()) == 11)
169  isConversion = true;
170  break;
171  }
172  if (isConversion)
173  break;
174  }
175  if (isConversion)
176  continue;
177 
178  isMatched = true;
179  break;
180  }
181 
182  if (isMatched) {
183  out->push_back(pfCluster);
184  double ePS1 = 0, ePS2 = 0;
185  if (!(pfCluster.layer() == PFLayer::ECAL_BARREL)) {
186  auto ee_key_val = std::make_pair(iP, edm::Ptr<reco::PFCluster>());
187  const auto clustops = std::equal_range(
188  associationHandle_.product()->begin(), associationHandle_.product()->end(), ee_key_val, sortByKey);
189  for (auto i_ps = clustops.first; i_ps != clustops.second; ++i_ps) {
190  edm::Ptr<reco::PFCluster> psclus(i_ps->second);
191  switch (psclus->layer()) {
192  case PFLayer::PS1:
193  ePS1 += psclus->energy();
194  break;
195  case PFLayer::PS2:
196  ePS2 += psclus->energy();
197  break;
198  default:
199  break;
200  }
201  }
202  }
203 
204  genmatching.push_back(edm::Ref<reco::GenParticleCollection>(genParticleHandle_, matchedKey));
205  clustersize.push_back(lazyTool.n5x5(pfCluster));
206  energyPS1.push_back(ePS1);
207  energyPS2.push_back(ePS2);
208  }
209  }
210 
212 
213  edm::ValueMap<reco::GenParticleRef>::Filler mapFiller(*genmatching_out);
214  mapFiller.insert(pfClusterHandle, genmatching.begin(), genmatching.end());
215  mapFiller.fill();
216  iEvent.put(std::move(genmatching_out));
217 
218  edm::ValueMap<int>::Filler mapFiller_int(*clustersize_out);
219  mapFiller_int.insert(pfClusterHandle, clustersize.begin(), clustersize.end());
220  mapFiller_int.fill();
221  iEvent.put(std::move(clustersize_out));
222 
223  edm::ValueMap<float>::Filler mapFiller_energyPS1(*energyPS1_out);
224  mapFiller_energyPS1.insert(pfClusterHandle, energyPS1.begin(), energyPS1.end());
225  mapFiller_energyPS1.fill();
226  iEvent.put(std::move(energyPS1_out), "PS1");
227 
228  edm::ValueMap<float>::Filler mapFiller_energyPS2(*energyPS2_out);
229  mapFiller_energyPS2.insert(pfClusterHandle, energyPS2.begin(), energyPS2.end());
230  mapFiller_energyPS2.fill();
231  iEvent.put(std::move(energyPS2_out), "PS2");
232 }
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
ESData get(edm::EventSetup const &eventSetup) const
edm::EDGetTokenT< EcalRecHitCollection > recHitsEB_
int iEvent
Definition: GenABIO.cc:224
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)
edm::EDGetTokenT< EcalRecHitCollection > recHitsEE_
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

Definition at line 55 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ ecalClusterToolsESGetTokens_

const EcalClusterLazyTools::ESGetTokens PFClusterMatchedToPhotonsSelector::ecalClusterToolsESGetTokens_
private

Definition at line 60 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ genParticleToken_

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

Definition at line 53 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ matchMaxDEDR2_

double PFClusterMatchedToPhotonsSelector::matchMaxDEDR2_
private

Definition at line 63 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ matchMaxDR2_

double PFClusterMatchedToPhotonsSelector::matchMaxDR2_
private

Definition at line 62 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ particleFlowClusterECALToken_

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

Definition at line 54 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ recHitsEB_

edm::EDGetTokenT<EcalRecHitCollection> PFClusterMatchedToPhotonsSelector::recHitsEB_
private

Definition at line 57 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ recHitsEE_

edm::EDGetTokenT<EcalRecHitCollection> PFClusterMatchedToPhotonsSelector::recHitsEE_
private

Definition at line 58 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ trackingParticleToken_

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

Definition at line 56 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ volumeRadius_EB_

double PFClusterMatchedToPhotonsSelector::volumeRadius_EB_
private

Definition at line 66 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ volumeZ_EB_

double PFClusterMatchedToPhotonsSelector::volumeZ_EB_
private

Definition at line 65 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().

◆ volumeZ_EE_

double PFClusterMatchedToPhotonsSelector::volumeZ_EE_
private

Definition at line 67 of file PFClusterMatchedToPhotonsSelector.cc.

Referenced by produce().