CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SimPFProducer Class Reference
Inheritance diagram for SimPFProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 SimPFProducer (const edm::ParameterSet &)
 
 ~SimPFProducer () override
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associators_
 
const edm::EDGetTokenT< CaloParticleCollectioncaloParticles_
 
const edm::EDGetTokenT< edm::View< reco::Track > > gsfTracks_
 
const edm::EDGetTokenT< reco::MuonCollectionmuons_
 
const double neutralEMThreshold_
 
const double neutralHADThreshold_
 
const edm::EDGetTokenT< edm::View< reco::PFRecTrack > > pfRecTracks_
 
const edm::EDGetTokenT< std::vector< reco::PFCluster > > simClusters_
 
const edm::EDGetTokenT< SimClusterCollectionsimClustersTruth_
 
const edm::EDGetTokenT< edm::ValueMap< float > > srcGsfTrackTime_
 
const edm::EDGetTokenT< edm::ValueMap< float > > srcGsfTrackTimeError_
 
const edm::EDGetTokenT< edm::ValueMap< float > > srcGsfTrackTimeQuality_
 
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
 
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
 
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
 
const double superClusterThreshold_
 
const double timingQualityThreshold_
 
const edm::EDGetTokenT< TrackingParticleCollectiontrackingParticles_
 
const edm::EDGetTokenT< edm::View< reco::Track > > tracks_
 
const bool useTiming_
 
const bool useTimingQuality_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 58 of file SimPFProducer.cc.

Constructor & Destructor Documentation

◆ SimPFProducer()

SimPFProducer::SimPFProducer ( const edm::ParameterSet conf)

Definition at line 99 of file SimPFProducer.cc.

100  : superClusterThreshold_(conf.getParameter<double>("superClusterThreshold")),
101  neutralEMThreshold_(conf.getParameter<double>("neutralEMThreshold")),
102  neutralHADThreshold_(conf.getParameter<double>("neutralHADThreshold")),
103  useTiming_(conf.existsAs<edm::InputTag>("trackTimeValueMap")),
104  useTimingQuality_(conf.existsAs<edm::InputTag>("trackTimeQualityMap")),
105  timingQualityThreshold_(useTimingQuality_ ? conf.getParameter<double>("timingQualityThreshold") : -99.),
109  muons_(consumes<reco::MuonCollection>(conf.getParameter<edm::InputTag>("muonSrc"))),
113  ? consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeErrorMap"))
116  ? consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("trackTimeQualityMap"))
119  ? consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("gsfTrackTimeValueMap"))
122  useTiming_ ? consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("gsfTrackTimeErrorMap"))
125  useTimingQuality_ ? consumes<edm::ValueMap<float>>(conf.getParameter<edm::InputTag>("gsfTrackTimeQualityMap"))
127  trackingParticles_(consumes<TrackingParticleCollection>(conf.getParameter<edm::InputTag>("trackingParticleSrc"))),
128  simClustersTruth_(consumes<SimClusterCollection>(conf.getParameter<edm::InputTag>("simClusterTruthSrc"))),
129  caloParticles_(consumes<CaloParticleCollection>(conf.getParameter<edm::InputTag>("caloParticlesSrc"))),
130  simClusters_(consumes<std::vector<reco::PFCluster>>(conf.getParameter<edm::InputTag>("simClustersSrc"))),
132  conf.getParameter<std::vector<edm::InputTag>>("associators"),
133  [this](const edm::InputTag& tag) { return this->consumes<reco::TrackToTrackingParticleAssociator>(tag); })) {
134  produces<reco::PFBlockCollection>();
135  produces<reco::SuperClusterCollection>("perfect");
136  produces<reco::PFCandidateCollection>();
137 }

References GlobalPosition_Frontier_DevDB_cff::tag.

◆ ~SimPFProducer()

SimPFProducer::~SimPFProducer ( )
inlineoverride

Definition at line 61 of file SimPFProducer.cc.

61 {}

Member Function Documentation

◆ produce()

void SimPFProducer::produce ( edm::StreamID  ,
edm::Event evt,
const edm::EventSetup es 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 139 of file SimPFProducer.cc.

139  {
140  //get associators
141  std::vector<edm::Handle<reco::TrackToTrackingParticleAssociator>> associators;
142  for (const auto& token : associators_) {
143  associators.emplace_back();
144  auto& back = associators.back();
145  evt.getByToken(token, back);
146  }
147 
148  //get PFRecTrack
149  edm::Handle<edm::View<reco::PFRecTrack>> PFTrackCollectionH;
150  evt.getByToken(pfRecTracks_, PFTrackCollectionH);
151  const edm::View<reco::PFRecTrack> PFTrackCollection = *PFTrackCollectionH;
152  std::unordered_set<unsigned> PFTrackToGeneralTrack;
153  for (unsigned i = 0; i < PFTrackCollection.size(); ++i) {
154  const auto ptr = PFTrackCollection.ptrAt(i);
155  PFTrackToGeneralTrack.insert(ptr->trackRef().key());
156  }
157 
158  //get track collections
159  edm::Handle<edm::View<reco::Track>> TrackCollectionH;
160  evt.getByToken(tracks_, TrackCollectionH);
161  const edm::View<reco::Track>& TrackCollection = *TrackCollectionH;
162 
164  evt.getByToken(muons_, muons);
165  std::unordered_set<unsigned> MuonTrackToGeneralTrack;
166  for (auto const& mu : *muons.product()) {
167  reco::TrackRef muTrkRef = mu.track();
168  if (muTrkRef.isNonnull())
169  MuonTrackToGeneralTrack.insert(muTrkRef.key());
170  }
171 
172  // get timing, if enabled
173  edm::Handle<edm::ValueMap<float>> trackTimeH, trackTimeErrH, trackTimeQualH, gsfTrackTimeH, gsfTrackTimeErrH,
174  gsfTrackTimeQualH;
175  if (useTiming_) {
176  evt.getByToken(srcTrackTime_, trackTimeH);
177  evt.getByToken(srcTrackTimeError_, trackTimeErrH);
178  evt.getByToken(srcGsfTrackTime_, gsfTrackTimeH);
179  evt.getByToken(srcGsfTrackTimeError_, gsfTrackTimeErrH);
180 
181  if (useTimingQuality_) {
182  evt.getByToken(srcTrackTimeQuality_, trackTimeQualH);
183  evt.getByToken(srcGsfTrackTimeQuality_, gsfTrackTimeQualH);
184  }
185  }
186 
187  //get tracking particle collections
189  evt.getByToken(trackingParticles_, TPCollectionH);
190  //const TrackingParticleCollection& TPCollection = *TPCollectionH;
191 
192  // grab phony clustering information
193  edm::Handle<SimClusterCollection> SimClustersTruthH;
194  evt.getByToken(simClustersTruth_, SimClustersTruthH);
195  const SimClusterCollection& SimClustersTruth = *SimClustersTruthH;
196 
198  evt.getByToken(caloParticles_, CaloParticlesH);
199  const CaloParticleCollection& CaloParticles = *CaloParticlesH;
200 
202  evt.getByToken(simClusters_, SimClustersH);
203  const std::vector<reco::PFCluster>& SimClusters = *SimClustersH;
204 
205  std::unordered_map<uint64_t, size_t> hashToSimCluster;
206 
207  for (unsigned i = 0; i < SimClustersTruth.size(); ++i) {
208  const auto& simTruth = SimClustersTruth[i];
209  hashToSimCluster[hashSimInfo(simTruth)] = i;
210  }
211 
212  // associate the reco tracks / gsf Tracks
213  std::vector<reco::RecoToSimCollection> associatedTracks, associatedTracksGsf;
214  for (const auto& associator : associators) {
215  associatedTracks.emplace_back(associator->associateRecoToSim(TrackCollectionH, TPCollectionH));
216  //associatedTracksGsf.emplace_back(associator->associateRecoToSim(GsfTrackCollectionH, TPCollectionH));
217  }
218 
219  // make blocks out of calo particles so we can have cluster references
220  // likewise fill out superclusters
221  auto superclusters = std::make_unique<reco::SuperClusterCollection>();
222  auto blocks = std::make_unique<reco::PFBlockCollection>();
223  std::unordered_map<size_t, size_t> simCluster2Block;
224  std::unordered_map<size_t, size_t> simCluster2BlockIndex;
225  std::unordered_multimap<size_t, size_t> caloParticle2SimCluster;
226  std::vector<int> caloParticle2SuperCluster;
227  for (unsigned icp = 0; icp < CaloParticles.size(); ++icp) {
228  blocks->emplace_back();
229  auto& block = blocks->back();
230  const auto& simclusters = CaloParticles[icp].simClusters();
231  double pttot = 0.0;
232  double etot = 0.0;
233  std::vector<size_t> good_simclusters;
234  for (unsigned isc = 0; isc < simclusters.size(); ++isc) {
235  auto simc = simclusters[isc];
236  auto pdgId = std::abs(simc->pdgId());
237  edm::Ref<std::vector<reco::PFCluster>> clusterRef(SimClustersH, simc.key());
238  if (((pdgId == 22 || pdgId == 11) && clusterRef->energy() > neutralEMThreshold_) ||
239  clusterRef->energy() > neutralHADThreshold_) {
240  good_simclusters.push_back(isc);
241  etot += clusterRef->energy();
242  pttot += clusterRef->pt();
243  auto bec = std::make_unique<reco::PFBlockElementCluster>(clusterRef, reco::PFBlockElement::HGCAL);
244  block.addElement(bec.get());
245  simCluster2Block[simc.key()] = icp;
246  simCluster2BlockIndex[simc.key()] = bec->index();
247  caloParticle2SimCluster.emplace(CaloParticles[icp].g4Tracks()[0].trackId(), simc.key());
248  }
249  }
250 
251  auto pdgId = std::abs(CaloParticles[icp].pdgId());
252 
253  caloParticle2SuperCluster.push_back(-1);
254  if ((pdgId == 22 || pdgId == 11) && pttot > superClusterThreshold_) {
255  caloParticle2SuperCluster[icp] = superclusters->size();
256 
257  math::XYZPoint seedpos; // take seed pos as supercluster point
260  for (auto idx : good_simclusters) {
261  edm::Ptr<reco::PFCluster> ptr(SimClustersH, simclusters[idx].key());
262  clusters.push_back(ptr);
263  if (seed.isNull() || seed->energy() < ptr->energy()) {
264  seed = ptr;
265  seedpos = ptr->position();
266  }
267  }
268  superclusters->emplace_back(etot, seedpos, seed, clusters);
269  }
270  }
271 
272  auto blocksHandle = evt.put(std::move(blocks));
273  auto superClustersHandle = evt.put(std::move(superclusters), "perfect");
274 
275  // list tracks so we can mark them as used and/or fight over them
276  std::vector<bool> usedTrack(TrackCollection.size(), false),
277  //usedGsfTrack(GsfTrackCollection.size(),false),
278  usedSimCluster(SimClusters.size(), false);
279 
280  auto candidates = std::make_unique<reco::PFCandidateCollection>();
281  // in good particle flow fashion, start from the tracks and go out
282  for (unsigned itk = 0; itk < TrackCollection.size(); ++itk) {
283  auto tkRef = TrackCollection.refAt(itk);
284  // skip tracks not selected by PF
285  if (PFTrackToGeneralTrack.count(itk) == 0)
286  continue;
287  reco::RecoToSimCollection::const_iterator assoc_tps = associatedTracks.back().end();
288  for (const auto& association : associatedTracks) {
289  assoc_tps = association.find(tkRef);
290  if (assoc_tps != association.end())
291  break;
292  }
293  if (assoc_tps == associatedTracks.back().end())
294  continue;
295  // assured now that we are matched to a set of tracks
296  const auto& matches = assoc_tps->val;
297 
298  const auto absPdgId = std::abs(matches[0].first->pdgId());
299  const auto charge = tkRef->charge();
300  const auto three_mom = tkRef->momentum();
301  constexpr double mpion2 = 0.13957 * 0.13957;
302  double energy = std::sqrt(three_mom.mag2() + mpion2);
303  math::XYZTLorentzVector trk_p4(three_mom.x(), three_mom.y(), three_mom.z(), energy);
304 
306 
307  switch (absPdgId) {
308  case 11:
309  part_type = reco::PFCandidate::e;
310  break;
311  case 13:
312  part_type = reco::PFCandidate::mu;
313  break;
314  default:
315  part_type = reco::PFCandidate::h;
316  }
317 
318  candidates->emplace_back(charge, trk_p4, part_type);
319  auto& candidate = candidates->back();
320 
321  candidate.setTrackRef(tkRef.castTo<reco::TrackRef>());
322 
323  if (useTiming_) {
324  // check if track-mtd match is of sufficient quality
325  const bool assocQuality = useTimingQuality_ ? (*trackTimeQualH)[tkRef] > timingQualityThreshold_ : true;
326  if (assocQuality) {
327  candidate.setTime((*trackTimeH)[tkRef], (*trackTimeErrH)[tkRef]);
328  } else {
329  candidate.setTime(0., -1.);
330  }
331  }
332 
333  // bind to cluster if there is one and try to gather conversions, etc
334  for (const auto& match : matches) {
335  uint64_t hash = hashSimInfo(*(match.first));
336  if (hashToSimCluster.count(hash)) {
337  auto simcHash = hashToSimCluster[hash];
338 
339  if (!usedSimCluster[simcHash]) {
340  if (simCluster2Block.count(simcHash) && simCluster2BlockIndex.count(simcHash)) {
341  size_t block = simCluster2Block.find(simcHash)->second;
342  size_t blockIdx = simCluster2BlockIndex.find(simcHash)->second;
343  edm::Ref<reco::PFBlockCollection> blockRef(blocksHandle, block);
344  candidate.addElementInBlock(blockRef, blockIdx);
345  usedSimCluster[simcHash] = true;
346  }
347  }
348  if (absPdgId == 11) { // collect brems/conv. brems
349  if (simCluster2Block.count(simcHash)) {
350  auto block_index = simCluster2Block.find(simcHash)->second;
351  auto supercluster_index = caloParticle2SuperCluster[block_index];
352  if (supercluster_index != -1) {
353  edm::Ref<reco::PFBlockCollection> blockRef(blocksHandle, block_index);
354  for (const auto& elem : blockRef->elements()) {
355  const auto& ref = elem.clusterRef();
356  if (!usedSimCluster[ref.key()]) {
357  candidate.addElementInBlock(blockRef, elem.index());
358  usedSimCluster[ref.key()] = true;
359  }
360  }
361 
362  //*TODO* cluster time is not reliable at the moment, so just keep time from the track if available
363  }
364  }
365  }
366  }
367  // Now try to include also electrons that have been reconstructed using
368  // the GraphCaloParticles. In particular, recover the cases in which the
369  // tracking particle associated to the CaloParticle has not left any hits
370  // in the calorimeters or, if it had, the cluster has been skipped due to
371  // threshold requirements.
372  if (caloParticle2SimCluster.count(match.first->g4Tracks()[0].trackId())) {
373  auto range = caloParticle2SimCluster.equal_range(match.first->g4Tracks()[0].trackId());
374  for (auto it = range.first; it != range.second; ++it) {
375  if (!usedSimCluster[it->second]) {
376  usedSimCluster[it->second] = true;
377  if (simCluster2Block.find(it->second) != simCluster2Block.end()) {
378  size_t block = simCluster2Block.find(it->second)->second;
379  size_t blockIdx = simCluster2BlockIndex.find(it->second)->second;
380  edm::Ref<reco::PFBlockCollection> blockRef(blocksHandle, block);
381  candidate.addElementInBlock(blockRef, blockIdx);
382  }
383  }
384  }
385  }
386  }
387  usedTrack[tkRef.key()] = true;
388  // remove tracks already used by muons
389  if (MuonTrackToGeneralTrack.count(itk) || absPdgId == 13)
390  candidates->pop_back();
391  }
392 
393  // now loop over the non-collected clusters in blocks
394  // and turn them into neutral hadrons or photons
395  const auto& theblocks = *blocksHandle;
396  for (unsigned ibl = 0; ibl < theblocks.size(); ++ibl) {
397  reco::PFBlockRef blref(blocksHandle, ibl);
398  const auto& elements = theblocks[ibl].elements();
399  for (const auto& elem : elements) {
400  const auto& ref = elem.clusterRef();
401  const auto& simtruth = SimClustersTruth[ref.key()];
403  if (!usedSimCluster[ref.key()]) {
404  auto absPdgId = std::abs(simtruth.pdgId());
405  switch (absPdgId) {
406  case 11:
407  case 22:
408  part_type = reco::PFCandidate::gamma;
409  break;
410  default:
411  part_type = reco::PFCandidate::h0;
412  }
413  const auto three_mom = (ref->position() - math::XYZPoint(0, 0, 0)).unit() * ref->correctedEnergy();
414  math::XYZTLorentzVector clu_p4(three_mom.x(), three_mom.y(), three_mom.z(), ref->correctedEnergy());
415  candidates->emplace_back(0, clu_p4, part_type);
416  auto& candidate = candidates->back();
417  candidate.addElementInBlock(blref, elem.index());
418  }
419  }
420  }
421 
422  evt.put(std::move(candidates));
423 }

References funct::abs(), ctfWithMaterialTrackMCMatch_cfi::associator, simPFProducer_cfi::associators, associators_, groupFilesInBlocks::block, cms::cudacompat::blockIdx, gather_cfg::blocks, caloParticles_, HLT_FULL_cff::candidates, ALCARECOTkAlJpsiMuMu_cff::charge, bsc_activity_cfg::clusters, edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >::const_iterator, reco::PFCandidate::e, bookConverter::elements, HCALHighEnergyHPDFilter_cfi::energy, reco::PFCluster::energy(), dqmdumpme::first, reco::PFCandidate::gamma, edm::Event::getByToken(), reco::PFCandidate::h, reco::PFCandidate::h0, cond::hash, reco::PFBlockElement::HGCAL, mps_fire::i, heavyIonCSV_trainingSettings::idx, edm::Ref< C, T, F >::index(), edm::Ref< C, T, F >::isNonnull(), crabWrapper::key, edm::Ref< C, T, F >::key(), match(), patCandidatesForDimuonsSequences_cff::matches, eostools::move(), amptDefaultParameters_cff::mu, reco::PFCandidate::mu, PDWG_BPHSkim_cff::muons, muons_, neutralEMThreshold_, neutralHADThreshold_, EgammaValidation_cff::pdgId, pfRecTracks_, reco::CaloCluster::position(), edm::Event::put(), FastTimerService_cff::range, fileCollector::seed, simClusters_, simClustersTruth_, mathSSE::sqrt(), srcGsfTrackTime_, srcGsfTrackTimeError_, srcGsfTrackTimeQuality_, srcTrackTime_, srcTrackTimeError_, srcTrackTimeQuality_, superClusterThreshold_, timingQualityThreshold_, unpackBuffers-CaloStage2::token, trackingParticles_, tracks_, unit(), useTiming_, and useTimingQuality_.

Member Data Documentation

◆ associators_

const std::vector<edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator> > SimPFProducer::associators_
private

Definition at line 84 of file SimPFProducer.cc.

Referenced by produce().

◆ caloParticles_

const edm::EDGetTokenT<CaloParticleCollection> SimPFProducer::caloParticles_
private

Definition at line 81 of file SimPFProducer.cc.

Referenced by produce().

◆ gsfTracks_

const edm::EDGetTokenT<edm::View<reco::Track> > SimPFProducer::gsfTracks_
private

Definition at line 75 of file SimPFProducer.cc.

◆ muons_

const edm::EDGetTokenT<reco::MuonCollection> SimPFProducer::muons_
private

Definition at line 76 of file SimPFProducer.cc.

Referenced by produce().

◆ neutralEMThreshold_

const double SimPFProducer::neutralEMThreshold_
private

Definition at line 67 of file SimPFProducer.cc.

Referenced by produce().

◆ neutralHADThreshold_

const double SimPFProducer::neutralHADThreshold_
private

Definition at line 67 of file SimPFProducer.cc.

Referenced by produce().

◆ pfRecTracks_

const edm::EDGetTokenT<edm::View<reco::PFRecTrack> > SimPFProducer::pfRecTracks_
private

Definition at line 73 of file SimPFProducer.cc.

Referenced by produce().

◆ simClusters_

const edm::EDGetTokenT<std::vector<reco::PFCluster> > SimPFProducer::simClusters_
private

Definition at line 82 of file SimPFProducer.cc.

Referenced by produce().

◆ simClustersTruth_

const edm::EDGetTokenT<SimClusterCollection> SimPFProducer::simClustersTruth_
private

Definition at line 80 of file SimPFProducer.cc.

Referenced by produce().

◆ srcGsfTrackTime_

const edm::EDGetTokenT<edm::ValueMap<float> > SimPFProducer::srcGsfTrackTime_
private

Definition at line 78 of file SimPFProducer.cc.

Referenced by produce().

◆ srcGsfTrackTimeError_

const edm::EDGetTokenT<edm::ValueMap<float> > SimPFProducer::srcGsfTrackTimeError_
private

Definition at line 78 of file SimPFProducer.cc.

Referenced by produce().

◆ srcGsfTrackTimeQuality_

const edm::EDGetTokenT<edm::ValueMap<float> > SimPFProducer::srcGsfTrackTimeQuality_
private

Definition at line 78 of file SimPFProducer.cc.

Referenced by produce().

◆ srcTrackTime_

const edm::EDGetTokenT<edm::ValueMap<float> > SimPFProducer::srcTrackTime_
private

Definition at line 77 of file SimPFProducer.cc.

Referenced by produce().

◆ srcTrackTimeError_

const edm::EDGetTokenT<edm::ValueMap<float> > SimPFProducer::srcTrackTimeError_
private

Definition at line 77 of file SimPFProducer.cc.

Referenced by produce().

◆ srcTrackTimeQuality_

const edm::EDGetTokenT<edm::ValueMap<float> > SimPFProducer::srcTrackTimeQuality_
private

Definition at line 77 of file SimPFProducer.cc.

Referenced by produce().

◆ superClusterThreshold_

const double SimPFProducer::superClusterThreshold_
private

Definition at line 67 of file SimPFProducer.cc.

Referenced by produce().

◆ timingQualityThreshold_

const double SimPFProducer::timingQualityThreshold_
private

Definition at line 70 of file SimPFProducer.cc.

Referenced by produce().

◆ trackingParticles_

const edm::EDGetTokenT<TrackingParticleCollection> SimPFProducer::trackingParticles_
private

Definition at line 79 of file SimPFProducer.cc.

Referenced by produce().

◆ tracks_

const edm::EDGetTokenT<edm::View<reco::Track> > SimPFProducer::tracks_
private

Definition at line 74 of file SimPFProducer.cc.

Referenced by produce().

◆ useTiming_

const bool SimPFProducer::useTiming_
private

Definition at line 68 of file SimPFProducer.cc.

Referenced by produce().

◆ useTimingQuality_

const bool SimPFProducer::useTimingQuality_
private

Definition at line 69 of file SimPFProducer.cc.

Referenced by produce().

SimPFProducer::srcTrackTimeError_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeError_
Definition: SimPFProducer.cc:77
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
SimPFProducer::gsfTracks_
const edm::EDGetTokenT< edm::View< reco::Track > > gsfTracks_
Definition: SimPFProducer.cc:75
SimClusterCollection
std::vector< SimCluster > SimClusterCollection
Definition: SimClusterFwd.h:8
mps_fire.i
i
Definition: mps_fire.py:428
reco::PFCandidate::e
Definition: PFCandidate.h:47
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
cond::hash
Definition: Time.h:19
SimPFProducer::simClusters_
const edm::EDGetTokenT< std::vector< reco::PFCluster > > simClusters_
Definition: SimPFProducer.cc:82
edm::EDGetTokenT
Definition: EDGetToken.h:33
simPFProducer_cfi.associators
associators
Definition: simPFProducer_cfi.py:16
hgcal::association
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
Definition: LayerClusterAssociatorByEnergyScoreImpl.h:44
reco::PFCandidate::h
Definition: PFCandidate.h:46
reco::PFBlockElement::HGCAL
Definition: PFBlockElement.h:43
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
edm::Handle
Definition: AssociativeIterator.h:50
dqmdumpme.first
first
Definition: dqmdumpme.py:55
SimPFProducer::tracks_
const edm::EDGetTokenT< edm::View< reco::Track > > tracks_
Definition: SimPFProducer.cc:74
edm::Ref< TrackCollection >
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
fileCollector.seed
seed
Definition: fileCollector.py:127
SimPFProducer::pfRecTracks_
const edm::EDGetTokenT< edm::View< reco::PFRecTrack > > pfRecTracks_
Definition: SimPFProducer.cc:73
SimPFProducer::srcTrackTimeQuality_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTimeQuality_
Definition: SimPFProducer.cc:77
reco::PFCandidate::mu
Definition: PFCandidate.h:48
SimPFProducer::neutralHADThreshold_
const double neutralHADThreshold_
Definition: SimPFProducer.cc:67
edm::PtrVector< CaloCluster >
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
SimPFProducer::srcGsfTrackTime_
const edm::EDGetTokenT< edm::ValueMap< float > > srcGsfTrackTime_
Definition: SimPFProducer.cc:78
SimPFProducer::useTimingQuality_
const bool useTimingQuality_
Definition: SimPFProducer.cc:69
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
SimPFProducer::simClustersTruth_
const edm::EDGetTokenT< SimClusterCollection > simClustersTruth_
Definition: SimPFProducer.cc:80
ctfWithMaterialTrackMCMatch_cfi.associator
associator
Definition: ctfWithMaterialTrackMCMatch_cfi.py:7
CaloParticleCollection
std::vector< CaloParticle > CaloParticleCollection
Definition: CaloParticleFwd.h:8
l1t::PFTrackCollection
std::vector< l1t::PFTrack > PFTrackCollection
Definition: PFTrack.h:84
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
SimPFProducer::associators_
const std::vector< edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > > associators_
Definition: SimPFProducer.cc:84
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >::const_iterator
friend struct const_iterator
Definition: AssociationMap.h:274
edm::View
Definition: CaloClusterFwd.h:14
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
SimPFProducer::caloParticles_
const edm::EDGetTokenT< CaloParticleCollection > caloParticles_
Definition: SimPFProducer.cc:81
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
SimPFProducer::muons_
const edm::EDGetTokenT< reco::MuonCollection > muons_
Definition: SimPFProducer.cc:76
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
reco::PFCandidate::gamma
Definition: PFCandidate.h:49
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
SimPFProducer::timingQualityThreshold_
const double timingQualityThreshold_
Definition: SimPFProducer.cc:70
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
SimPFProducer::srcGsfTrackTimeError_
const edm::EDGetTokenT< edm::ValueMap< float > > srcGsfTrackTimeError_
Definition: SimPFProducer.cc:78
SimPFProducer::superClusterThreshold_
const double superClusterThreshold_
Definition: SimPFProducer.cc:67
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
edm::Ptr< CaloCluster >
SimPFProducer::srcGsfTrackTimeQuality_
const edm::EDGetTokenT< edm::ValueMap< float > > srcGsfTrackTimeQuality_
Definition: SimPFProducer.cc:78
bookConverter.elements
elements
Definition: bookConverter.py:147
eostools.move
def move(src, dest)
Definition: eostools.py:511
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:55051
edm::ValueMap< float >
reco::PFCandidate::h0
Definition: PFCandidate.h:50
SimPFProducer::useTiming_
const bool useTiming_
Definition: SimPFProducer.cc:68
SimPFProducer::trackingParticles_
const edm::EDGetTokenT< TrackingParticleCollection > trackingParticles_
Definition: SimPFProducer.cc:79
SimPFProducer::neutralEMThreshold_
const double neutralEMThreshold_
Definition: SimPFProducer.cc:67
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SimPFProducer::srcTrackTime_
const edm::EDGetTokenT< edm::ValueMap< float > > srcTrackTime_
Definition: SimPFProducer.cc:77
patCandidatesForDimuonsSequences_cff.matches
matches
Definition: patCandidatesForDimuonsSequences_cff.py:131
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
reco::PFCandidate::ParticleType
ParticleType
particle types
Definition: PFCandidate.h:44
crabWrapper.key
key
Definition: crabWrapper.py:19
gather_cfg.blocks
blocks
Definition: gather_cfg.py:90
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
cms::cudacompat::blockIdx
thread_local dim3 blockIdx
Definition: cudaCompat.cc:5
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:318