CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonSimClassifier Class Reference
Inheritance diagram for MuonSimClassifier:
edm::stream::EDProducer<>

Public Member Functions

 MuonSimClassifier (const edm::ParameterSet &)
 
 ~MuonSimClassifier () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

int convertAndPush (const TrackingParticle &tp, reco::GenParticleCollection &out, const TrackingParticleRef &momRef, const edm::Handle< reco::GenParticleCollection > &genParticles) const
 
int flavour (int pdgId) const
 Returns the flavour given a pdg id code. More...
 
TrackingParticleRef getTpMother (TrackingParticleRef tp)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
template<typename T >
void writeValueMap (edm::Event &iEvent, const edm::Handle< edm::View< reco::Muon >> &handle, const std::vector< T > &values, const std::string &label) const
 Write a ValueMap<int> in the event. More...
 

Private Attributes

edm::InputTag associatorLabel_
 The Associations. More...
 
double decayAbsZ_
 
double decayRho_
 Cylinder to use to decide if a decay is early or late. More...
 
edm::InputTag genParticles_
 
edm::EDGetTokenT< reco::GenParticleCollectiongenParticlesToken_
 
bool linkToGenParticles_
 Create a link to the generator level particles. More...
 
edm::EDGetTokenT< reco::MuonToTrackingParticleAssociatormuAssocToken_
 
edm::EDGetTokenT< edm::View< reco::Muon > > muonsToken_
 The RECO objects. More...
 
edm::EDGetTokenT< TrackingParticleCollectiontrackingParticlesToken_
 The TrackingParticle objects. More...
 
reco::MuonTrackType trackType_
 Track to use. More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 70 of file MuonSimClassifier.cc.

Constructor & Destructor Documentation

◆ MuonSimClassifier()

MuonSimClassifier::MuonSimClassifier ( const edm::ParameterSet iConfig)
explicit

Definition at line 125 of file MuonSimClassifier.cc.

126  : muonsToken_(consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("muons"))),
128  consumes<TrackingParticleCollection>(iConfig.getParameter<edm::InputTag>("trackingParticles"))),
130  consumes<reco::MuonToTrackingParticleAssociator>(iConfig.getParameter<edm::InputTag>("associatorLabel"))),
131  decayRho_(iConfig.getParameter<double>("decayRho")),
132  decayAbsZ_(iConfig.getParameter<double>("decayAbsZ")),
133  linkToGenParticles_(iConfig.getParameter<bool>("linkToGenParticles")),
135 
136 {
137  std::string trackType = iConfig.getParameter<std::string>("trackType");
138  if (trackType == "inner")
140  else if (trackType == "outer")
142  else if (trackType == "global")
144  else if (trackType == "segments")
146  else if (trackType == "glb_or_trk")
148  else
149  throw cms::Exception("Configuration") << "Track type '" << trackType << "' not supported.\n";
150  if (linkToGenParticles_) {
151  genParticlesToken_ = consumes<reco::GenParticleCollection>(genParticles_);
152  }
153 
154  produces<edm::ValueMap<reco::MuonSimInfo>>();
155  if (linkToGenParticles_) {
156  produces<reco::GenParticleCollection>("secondaries");
157  produces<edm::Association<reco::GenParticleCollection>>("toPrimaries");
158  produces<edm::Association<reco::GenParticleCollection>>("toSecondaries");
159  }
160 }

References Exception, genParticles_, genParticlesToken_, edm::ParameterSet::getParameter(), reco::GlbOrTrk, reco::GlobalTk, reco::InnerTk, linkToGenParticles_, reco::OuterTk, reco::Segments, AlCaHLTBitMon_QueryRunRegistry::string, PbPb_ZMuSkimMuonDPG_cff::trackType, and trackType_.

◆ ~MuonSimClassifier()

MuonSimClassifier::~MuonSimClassifier ( )
override

Definition at line 162 of file MuonSimClassifier.cc.

162 {}

Member Function Documentation

◆ convertAndPush()

int MuonSimClassifier::convertAndPush ( const TrackingParticle tp,
reco::GenParticleCollection out,
const TrackingParticleRef momRef,
const edm::Handle< reco::GenParticleCollection > &  genParticles 
) const
private

Convert TrackingParticle into GenParticle, save into output collection, if mother is primary set reference to it, return index in output collection

Definition at line 577 of file MuonSimClassifier.cc.

580  {
581  out.push_back(reco::GenParticle(tp.charge(), tp.p4(), tp.vertex(), tp.pdgId(), tp.status(), true));
582  if (simMom.isNonnull() && !simMom->genParticles().empty()) {
583  if (genParticles.id() != simMom->genParticles().id()) {
584  throw cms::Exception("Configuration")
585  << "Product ID mismatch between the genParticle collection (" << genParticles_ << ", id " << genParticles.id()
586  << ") and the references in the TrackingParticles (id " << simMom->genParticles().id() << ")\n";
587  }
588  out.back().addMother(simMom->genParticles()[0]);
589  }
590  return out.size() - 1;
591 }

References Exception, genParticles2HepMC_cfi::genParticles, genParticles_, edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNonnull(), MillePedeFileConverter_cfg::out, and cmsswSequenceInfo::tp.

Referenced by produce().

◆ flavour()

int MuonSimClassifier::flavour ( int  pdgId) const
private

Returns the flavour given a pdg id code.

Definition at line 558 of file MuonSimClassifier.cc.

558  {
559  int flav = std::abs(pdgId);
560  // for quarks, leptons and bosons except gluons, take their pdgId
561  // muons and taus have themselves as flavour
562  if (flav <= 37 && flav != 21)
563  return flav;
564  // look for barions
565  int bflav = ((flav / 1000) % 10);
566  if (bflav != 0)
567  return bflav;
568  // look for mesons
569  int mflav = ((flav / 100) % 10);
570  if (mflav != 0)
571  return mflav;
572  return 0;
573 }

References funct::abs(), and EgammaValidation_cff::pdgId.

Referenced by produce().

◆ getTpMother()

TrackingParticleRef MuonSimClassifier::getTpMother ( TrackingParticleRef  tp)
inlineprivate

Definition at line 108 of file MuonSimClassifier.cc.

108  {
109  if (tp.isNonnull() && tp->parentVertex().isNonnull() && !tp->parentVertex()->sourceTracks().empty()) {
110  return tp->parentVertex()->sourceTracks()[0];
111  } else {
112  return TrackingParticleRef();
113  }
114  }

References cmsswSequenceInfo::tp.

Referenced by produce().

◆ produce()

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

Definition at line 175 of file MuonSimClassifier.cc.

175  {
177  iEvent.getByToken(muonsToken_, muons);
178 
181 
183  if (linkToGenParticles_) {
185  }
186 
188  iEvent.getByToken(muAssocToken_, associatorBase);
189  const reco::MuonToTrackingParticleAssociator *assoByHits = associatorBase.product();
190 
191  reco::MuonToSimCollection recSimColl;
192  reco::SimToMuonCollection simRecColl;
193  LogTrace("MuonSimClassifier") << "\n "
194  "***************************************************************** ";
195  LogTrace("MuonSimClassifier") << " RECO MUON association, type: " << trackType_;
196  LogTrace("MuonSimClassifier") << " ******************************************"
197  "*********************** \n";
198 
200  for (size_t i = 0, n = muons->size(); i < n; ++i) {
201  allMuons.push_back(muons->refAt(i));
202  }
203 
205  for (size_t i = 0, n = trackingParticles->size(); i < n; ++i) {
207  }
208 
209  assoByHits->associateMuons(recSimColl, simRecColl, allMuons, trackType_, allTPs);
210 
211  // for global muons without hits on muon detectors, look at the linked
212  // standalone muon
213  reco::MuonToSimCollection updSTA_recSimColl;
214  reco::SimToMuonCollection updSTA_simRecColl;
215  if (trackType_ == reco::GlobalTk) {
216  LogTrace("MuonSimClassifier") << "\n "
217  "***************************************************************** ";
218  LogTrace("MuonSimClassifier") << " STANDALONE (UpdAtVtx) MUON association ";
219  LogTrace("MuonSimClassifier") << " ****************************************"
220  "************************* \n";
221  assoByHits->associateMuons(updSTA_recSimColl, updSTA_simRecColl, allMuons, reco::OuterTk, allTPs);
222  }
223 
224  typedef reco::MuonToSimCollection::const_iterator r2s_it;
225  typedef reco::SimToMuonCollection::const_iterator s2r_it;
226 
227  size_t nmu = muons->size();
228  LogTrace("MuonSimClassifier") << "\n There are " << nmu << " reco::Muons.";
229 
230  std::vector<reco::MuonSimInfo> simInfo;
231 
232  std::unique_ptr<reco::GenParticleCollection> secondaries; // output collection of secondary muons
233  std::map<TrackingParticleRef, int> tpToSecondaries; // map from tp to (index+1) in output collection
234  std::vector<int> muToPrimary(nmu, -1), muToSecondary(nmu,
235  -1); // map from input into (index) in output, -1 for null
237  secondaries.reset(new reco::GenParticleCollection());
238 
239  // loop on reco muons
240  for (size_t i = 0; i < nmu; ++i) {
241  simInfo.push_back(reco::MuonSimInfo());
242  LogTrace("MuonSimClassifier") << "\n reco::Muon # " << i;
243 
245  edm::RefToBase<reco::Muon> muMatchBack;
246  r2s_it match = recSimColl.find(allMuons.at(i));
247  s2r_it matchback;
248  if (match != recSimColl.end()) {
249  // match->second is vector, front is first element, first is the ref
250  // (second would be the quality)
251  tp = match->second.front().first;
252  simInfo[i].tpId = tp.isNonnull() ? tp.key() : -1; // we check, even if null refs should not appear here at all
253  simInfo[i].tpAssoQuality = match->second.front().second;
254  s2r_it matchback = simRecColl.find(tp);
255  if (matchback != simRecColl.end()) {
256  muMatchBack = matchback->second.front().first;
257  } else {
258  LogTrace("MuonSimClassifier") << "\n***WARNING: This I do NOT understand: why no match back? "
259  "*** \n";
260  }
261  } else {
262  if ((trackType_ == reco::GlobalTk) && allMuons.at(i)->isGlobalMuon()) {
263  // perform a second attempt, matching with the standalone muon
264  r2s_it matchSta = updSTA_recSimColl.find(allMuons.at(i));
265  if (matchSta != updSTA_recSimColl.end()) {
266  tp = matchSta->second.front().first;
267  simInfo[i].tpId = tp.isNonnull() ? tp.key() : -1; // we check, even if null refs
268  // should not appear here at all
269  simInfo[i].tpAssoQuality = matchSta->second.front().second;
270  s2r_it matchback = updSTA_simRecColl.find(tp);
271  if (matchback != updSTA_simRecColl.end()) {
272  muMatchBack = matchback->second.front().first;
273  } else {
274  LogTrace("MuonSimClassifier") << "\n***WARNING: This I do NOT understand: why no match back "
275  "in updSTA? *** \n";
276  }
277  }
278  } else {
279  LogTrace("MuonSimClassifier") << "\t No matching TrackingParticle is found ";
280  }
281  }
282 
283  if (tp.isNonnull()) {
284  bool isGhost = muMatchBack != allMuons.at(i);
285  if (isGhost)
286  LogTrace("MuonSimClassifier") << "\t *** This seems a Duplicate muon ! "
287  "classif[i] will be < 0 ***";
288 
289  // identify signal and pileup TP
290  simInfo[i].tpBX = tp->eventId().bunchCrossing();
291  simInfo[i].tpEvent = tp->eventId().event();
292 
293  simInfo[i].pdgId = tp->pdgId();
294  simInfo[i].vertex = tp->vertex();
295 
296  // added info on GEANT process producing the TrackingParticle
297  const std::vector<SimVertex> &g4Vs = tp->parentVertex()->g4Vertices();
298  simInfo[i].g4processType = g4Vs[0].processType();
299 
300  simInfo[i].charge = tp->charge();
301  simInfo[i].p4 = tp->p4();
302 
303  // Try to extract mother and grand mother of this muon.
304  // Unfortunately, SIM and GEN histories require diffent code :-(
305  if (!tp->genParticles().empty()) { // Muon is in GEN
306  reco::GenParticleRef genp = tp->genParticles()[0];
307  reco::GenParticleRef genMom = genp->numberOfMothers() > 0 ? genp->motherRef() : reco::GenParticleRef();
308  reco::GenParticleRef mMom = genMom;
309 
310  if (genMom.isNonnull()) {
311  if (genMom->pdgId() != tp->pdgId()) {
312  simInfo[i].motherPdgId = genMom->pdgId();
313  simInfo[i].motherStatus = genMom->status();
314  simInfo[i].motherVertex = genMom->vertex();
315  } else {
316  // if mother has the same identity look backwards for the real
317  // mother (it may happen in radiative decays)
318  int jm = 0;
319  while (mMom->pdgId() == tp->pdgId()) {
320  jm++;
321  if (mMom->numberOfMothers() > 0) {
322  mMom = mMom->motherRef();
323  } else {
324  LogTrace("MuonSimClassifier") << "\t No Mother is found ";
325  break;
326  }
327 
328  LogTrace("MuonSimClassifier") << "\t\t backtracking mother " << jm << ", pdgId = " << mMom->pdgId()
329  << ", status= " << mMom->status();
330  }
331  genMom = mMom; // redefine genMom
332  simInfo[i].motherPdgId = genMom->pdgId();
333  simInfo[i].motherStatus = genMom->status();
334  simInfo[i].motherVertex = genMom->vertex();
335  }
336  dumpFormatedInfo(simInfo[i]);
337  LogTrace("MuonSimClassifier") << "\t has GEN mother pdgId = " << simInfo[i].motherPdgId
338  << " (status = " << simInfo[i].motherStatus << ")";
339 
340  reco::GenParticleRef genGMom = genMom->numberOfMothers() > 0 ? genMom->motherRef() : reco::GenParticleRef();
341 
342  if (genGMom.isNonnull()) {
343  simInfo[i].grandMotherPdgId = genGMom->pdgId();
344  LogTrace("MuonSimClassifier")
345  << "\t\t mother prod. vertex rho = " << simInfo[i].motherVertex.Rho()
346  << ", z = " << simInfo[i].motherVertex.Z() << ", grand-mom pdgId = " << simInfo[i].grandMotherPdgId;
347  }
348  // in this case, we might want to know the heaviest mom flavour
349  for (reco::GenParticleRef nMom = genMom;
350  nMom.isNonnull() && std::abs(nMom->pdgId()) >= 100; // stop when we're no longer
351  // looking at hadrons or mesons
352  nMom = nMom->numberOfMothers() > 0 ? nMom->motherRef() : reco::GenParticleRef()) {
353  int flav = flavour(nMom->pdgId());
354  if (simInfo[i].heaviestMotherFlavour < flav)
355  simInfo[i].heaviestMotherFlavour = flav;
356  LogTrace("MuonSimClassifier")
357  << "\t\t backtracking flavour: mom pdgId = " << nMom->pdgId() << ", flavour = " << flav
358  << ", heaviest so far = " << simInfo[i].heaviestMotherFlavour;
359  }
360  } else { // mother is null ??
361  dumpFormatedInfo(simInfo[i]);
362  LogTrace("MuonSimClassifier") << "\t has NO mother!";
363  }
364  } else { // Muon is in SIM Only
366  if (simMom.isNonnull()) {
367  simInfo[i].motherPdgId = simMom->pdgId();
368  simInfo[i].motherVertex = simMom->vertex();
369  dumpFormatedInfo(simInfo[i]);
370  LogTrace("MuonSimClassifier") << "\t has SIM mother pdgId = " << simInfo[i].motherPdgId
371  << " produced at rho = " << simMom->vertex().Rho()
372  << ", z = " << simMom->vertex().Z();
373 
374  if (!simMom->genParticles().empty()) {
375  simInfo[i].motherStatus = simMom->genParticles()[0]->status();
376  reco::GenParticleRef genGMom =
377  (simMom->genParticles()[0]->numberOfMothers() > 0 ? simMom->genParticles()[0]->motherRef()
379  if (genGMom.isNonnull())
380  simInfo[i].grandMotherPdgId = genGMom->pdgId();
381  LogTrace("MuonSimClassifier") << "\t\t SIM mother is in GEN (status " << simInfo[i].motherStatus
382  << "), grand-mom id = " << simInfo[i].grandMotherPdgId;
383  } else {
384  simInfo[i].motherStatus = -1;
385  TrackingParticleRef simGMom = getTpMother(simMom);
386  if (simGMom.isNonnull())
387  simInfo[i].grandMotherPdgId = simGMom->pdgId();
388  LogTrace("MuonSimClassifier")
389  << "\t\t SIM mother is in SIM only, grand-mom id = " << simInfo[i].grandMotherPdgId;
390  }
391  } else {
392  dumpFormatedInfo(simInfo[i]);
393  LogTrace("MuonSimClassifier") << "\t has NO mother!";
394  }
395  }
396  simInfo[i].motherFlavour = flavour(simInfo[i].motherPdgId);
397  simInfo[i].grandMotherFlavour = flavour(simInfo[i].grandMotherPdgId);
398 
399  // Check first IF this is a muon at all
400  if (std::abs(tp->pdgId()) != 13) {
401  if (std::abs(tp->pdgId()) == 11) {
402  simInfo[i].primaryClass = isGhost ? reco::MuonSimType::GhostElectron : reco::MuonSimType::MatchedElectron;
403  simInfo[i].extendedClass =
405  LogTrace("MuonSimClassifier") << "\t This is electron/positron. classif[i] = " << simInfo[i].primaryClass;
406  } else {
407  simInfo[i].primaryClass =
409  simInfo[i].extendedClass = isGhost ? reco::ExtendedMuonSimType::ExtGhostPunchthrough
411  LogTrace("MuonSimClassifier") << "\t This is not a muon. Sorry. classif[i] = " << simInfo[i].primaryClass;
412  }
413  continue;
414  }
415 
416  // Is this SIM muon also a GEN muon, with a mother?
417  if (!tp->genParticles().empty() && (simInfo[i].motherPdgId != 0)) {
418  if (std::abs(simInfo[i].motherPdgId) < 100 && (std::abs(simInfo[i].motherPdgId) != 15)) {
419  simInfo[i].primaryClass =
421  simInfo[i].flavour = 13;
422  simInfo[i].extendedClass = isGhost ? reco::ExtendedMuonSimType::GhostMuonFromGaugeOrHiggsBoson
424  LogTrace("MuonSimClassifier") << "\t This seems PRIMARY MUON ! classif[i] = " << simInfo[i].primaryClass;
425  } else if (simInfo[i].motherFlavour == 4 || simInfo[i].motherFlavour == 5 || simInfo[i].motherFlavour == 15) {
426  simInfo[i].primaryClass =
428  simInfo[i].flavour = simInfo[i].motherFlavour;
429  if (simInfo[i].motherFlavour == 15)
430  simInfo[i].extendedClass =
432  else if (simInfo[i].motherFlavour == 5)
433  simInfo[i].extendedClass =
435  else if (simInfo[i].heaviestMotherFlavour == 5)
436  simInfo[i].extendedClass =
438  else
439  simInfo[i].extendedClass =
441  LogTrace("MuonSimClassifier") << "\t This seems HEAVY FLAVOUR ! classif[i] = " << simInfo[i].primaryClass;
442  } else {
443  simInfo[i].primaryClass =
445  simInfo[i].flavour = simInfo[i].motherFlavour;
446  LogTrace("MuonSimClassifier") << "\t This seems LIGHT FLAVOUR ! classif[i] = " << simInfo[i].primaryClass;
447  }
448  } else {
449  simInfo[i].primaryClass =
451  simInfo[i].flavour = simInfo[i].motherFlavour;
452  LogTrace("MuonSimClassifier") << "\t This seems LIGHT FLAVOUR ! classif[i] = " << simInfo[i].primaryClass;
453  }
454 
455  // extended classification
456  // don't we override previous decisions?
457  if (simInfo[i].motherPdgId == 0)
458  // if it has no mom, it's not a primary particle so it won't be in ppMuX
459  simInfo[i].extendedClass = isGhost ? reco::ExtendedMuonSimType::GhostMuonFromNonPrimaryParticle
461  else if (std::abs(simInfo[i].motherPdgId) < 100) {
462  if (simInfo[i].motherFlavour == 15)
463  simInfo[i].extendedClass =
465  else
466  simInfo[i].extendedClass = isGhost ? reco::ExtendedMuonSimType::GhostMuonFromGaugeOrHiggsBoson
468  } else if (simInfo[i].motherFlavour == 5)
469  simInfo[i].extendedClass =
471  else if (simInfo[i].motherFlavour == 4) {
472  if (simInfo[i].heaviestMotherFlavour == 5)
473  simInfo[i].extendedClass =
475  else
476  simInfo[i].extendedClass =
478  } else if (simInfo[i].motherStatus != -1) { // primary light particle
479  int id = std::abs(simInfo[i].motherPdgId);
480  if (id != /*pi+*/ 211 && id != /*K+*/ 321 && id != 130 /*K0L*/)
481  // other light particle, possibly short-lived
482  simInfo[i].extendedClass = isGhost ? reco::ExtendedMuonSimType::GhostMuonFromOtherLight
484  else if (simInfo[i].vertex.Rho() < decayRho_ && std::abs(simInfo[i].vertex.Z()) < decayAbsZ_)
485  // decay a la ppMuX (primary pi/K within a cylinder)
486  simInfo[i].extendedClass = isGhost ? reco::ExtendedMuonSimType::GhostMuonFromPiKppMuX
488  else
489  // late decay that wouldn't be in ppMuX
490  simInfo[i].extendedClass = isGhost ? reco::ExtendedMuonSimType::GhostMuonFromPiKNotppMuX
492  } else
493  // decay of non-primary particle, would not be in ppMuX
494  simInfo[i].extendedClass = isGhost ? reco::ExtendedMuonSimType::GhostMuonFromNonPrimaryParticle
496 
497  if (linkToGenParticles_ && std::abs(simInfo[i].extendedClass) >= 2) {
498  // Link to the genParticle if possible, but not decays in flight (in
499  // ppMuX they're in GEN block, but they have wrong parameters)
500  if (!tp->genParticles().empty() && std::abs(simInfo[i].extendedClass) >= 5) {
501  if (genParticles.id() != tp->genParticles().id()) {
502  throw cms::Exception("Configuration")
503  << "Product ID mismatch between the genParticle collection (" << genParticles_ << ", id "
504  << genParticles.id() << ") and the references in the TrackingParticles (id " << tp->genParticles().id()
505  << ")\n";
506  }
507  muToPrimary[i] = tp->genParticles()[0].key();
508  } else {
509  // Don't put the same trackingParticle twice!
510  int &indexPlus1 = tpToSecondaries[tp]; // will create a 0 if the tp is
511  // not in the list already
512  if (indexPlus1 == 0)
513  indexPlus1 = convertAndPush(*tp, *secondaries, getTpMother(tp), genParticles) + 1;
514  muToSecondary[i] = indexPlus1 - 1;
515  }
516  }
517  LogTrace("MuonSimClassifier") << "\t Extended classification code = " << simInfo[i].extendedClass;
518  } else { // if (tp.isNonnull())
519  simInfo[i].primaryClass = reco::MuonSimType::NotMatched;
520  simInfo[i].extendedClass = reco::ExtendedMuonSimType::ExtNotMatched;
521  }
522  } // end loop on reco muons
523 
524  writeValueMap(iEvent, muons, simInfo, "");
525 
526  if (linkToGenParticles_) {
527  edm::OrphanHandle<reco::GenParticleCollection> secHandle = iEvent.put(std::move(secondaries), "secondaries");
530  std::unique_ptr<edm::Association<reco::GenParticleCollection>> outPri(
532  std::unique_ptr<edm::Association<reco::GenParticleCollection>> outSec(
534  edm::Association<reco::GenParticleCollection>::Filler fillPri(*outPri), fillSec(*outSec);
535  fillPri.insert(muons, muToPrimary.begin(), muToPrimary.end());
536  fillSec.insert(muons, muToSecondary.begin(), muToSecondary.end());
537  fillPri.fill();
538  fillSec.fill();
539  iEvent.put(std::move(outPri), "toPrimaries");
540  iEvent.put(std::move(outSec), "toSecondaries");
541  }
542 }

References funct::abs(), allMuons_cfi::allMuons, reco::MuonToTrackingParticleAssociator::associateMuons(), convertAndPush(), decayAbsZ_, decayRho_, dumpFormatedInfo(), Exception, reco::ExtGhostElectron, reco::ExtGhostPunchthrough, reco::ExtMatchedElectron, reco::ExtMatchedPunchthrough, reco::ExtNotMatched, edm::helper::Filler< Map >::fill(), flavour(), EgammaValidation_cff::genp, genParticles2HepMC_cfi::genParticles, genParticles_, genParticlesToken_, getTpMother(), reco::GhostElectron, reco::GhostMuonFromB, reco::GhostMuonFromBtoC, reco::GhostMuonFromC, reco::GhostMuonFromGaugeOrHiggsBoson, reco::GhostMuonFromHeavyFlavour, reco::GhostMuonFromLightFlavour, reco::GhostMuonFromNonPrimaryParticle, reco::GhostMuonFromOtherLight, reco::GhostMuonFromPiKNotppMuX, reco::GhostMuonFromPiKppMuX, reco::GhostMuonFromTau, reco::GhostPrimaryMuon, reco::GhostPunchthrough, reco::GlobalTk, mps_fire::i, iEvent, edm::helper::Filler< Map >::insert(), edm::Ref< C, T, F >::isNonnull(), linkToGenParticles_, LogTrace, match(), reco::MatchedElectron, reco::MatchedMuonFromB, reco::MatchedMuonFromBtoC, reco::MatchedMuonFromC, reco::MatchedMuonFromGaugeOrHiggsBoson, reco::MatchedMuonFromHeavyFlavour, reco::MatchedMuonFromLightFlavour, reco::MatchedMuonFromNonPrimaryParticle, reco::MatchedMuonFromOtherLight, reco::MatchedMuonFromPiKNotppMuX, reco::MatchedMuonFromPiKppMuX, reco::MatchedMuonFromTau, reco::MatchedPrimaryMuon, reco::MatchedPunchthrough, eostools::move(), muAssocToken_, PDWG_BPHSkim_cff::muons, muonsToken_, dqmiodumpmetadata::n, reco::NotMatched, reco::OuterTk, edm::Handle< T >::product(), edm::RefVector< C, T, F >::push_back(), cmsswSequenceInfo::tp, muonClassificationByHits_cfi::trackingParticles, trackingParticlesToken_, trackType_, bphysicsOniaDQM_cfi::vertex, and writeValueMap().

◆ writeValueMap()

template<typename T >
void MuonSimClassifier::writeValueMap ( edm::Event iEvent,
const edm::Handle< edm::View< reco::Muon >> &  handle,
const std::vector< T > &  values,
const std::string &  label 
) const
private

Write a ValueMap<int> in the event.

Definition at line 545 of file MuonSimClassifier.cc.

548  {
549  using namespace edm;
550  using namespace std;
551  unique_ptr<ValueMap<T>> valMap(new ValueMap<T>());
552  typename edm::ValueMap<T>::Filler filler(*valMap);
553  filler.insert(handle, values.begin(), values.end());
554  filler.fill();
555  iEvent.put(std::move(valMap), label);
556 }

References trigObjTnPSource_cfi::filler, patZpeak::handle, iEvent, label, eostools::move(), and contentValuesCheck::values.

Referenced by produce().

Member Data Documentation

◆ associatorLabel_

edm::InputTag MuonSimClassifier::associatorLabel_
private

The Associations.

Definition at line 87 of file MuonSimClassifier.cc.

◆ decayAbsZ_

double MuonSimClassifier::decayAbsZ_
private

Definition at line 91 of file MuonSimClassifier.cc.

Referenced by produce().

◆ decayRho_

double MuonSimClassifier::decayRho_
private

Cylinder to use to decide if a decay is early or late.

Definition at line 91 of file MuonSimClassifier.cc.

Referenced by produce().

◆ genParticles_

edm::InputTag MuonSimClassifier::genParticles_
private

Definition at line 95 of file MuonSimClassifier.cc.

Referenced by convertAndPush(), MuonSimClassifier(), and produce().

◆ genParticlesToken_

edm::EDGetTokenT<reco::GenParticleCollection> MuonSimClassifier::genParticlesToken_
private

Definition at line 96 of file MuonSimClassifier.cc.

Referenced by MuonSimClassifier(), and produce().

◆ linkToGenParticles_

bool MuonSimClassifier::linkToGenParticles_
private

Create a link to the generator level particles.

Definition at line 94 of file MuonSimClassifier.cc.

Referenced by MuonSimClassifier(), and produce().

◆ muAssocToken_

edm::EDGetTokenT<reco::MuonToTrackingParticleAssociator> MuonSimClassifier::muAssocToken_
private

Definition at line 88 of file MuonSimClassifier.cc.

Referenced by produce().

◆ muonsToken_

edm::EDGetTokenT<edm::View<reco::Muon> > MuonSimClassifier::muonsToken_
private

The RECO objects.

Definition at line 78 of file MuonSimClassifier.cc.

Referenced by produce().

◆ trackingParticlesToken_

edm::EDGetTokenT<TrackingParticleCollection> MuonSimClassifier::trackingParticlesToken_
private

The TrackingParticle objects.

Definition at line 84 of file MuonSimClassifier.cc.

Referenced by produce().

◆ trackType_

reco::MuonTrackType MuonSimClassifier::trackType_
private

Track to use.

Definition at line 81 of file MuonSimClassifier.cc.

Referenced by MuonSimClassifier(), and produce().

edm::RefProd< reco::GenParticleCollection >
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
reco::GenParticleRef
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
Definition: GenParticleFwd.h:17
reco::GhostElectron
Definition: MuonSimInfo.h:40
mps_fire.i
i
Definition: mps_fire.py:355
edm::Association::Filler
Definition: Association.h:78
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
reco::MatchedMuonFromOtherLight
Definition: MuonSimInfo.h:56
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::Handle::product
T const * product() const
Definition: Handle.h:70
reco::GhostMuonFromHeavyFlavour
Definition: MuonSimInfo.h:42
reco::MuonToTrackingParticleAssociator
Definition: MuonToTrackingParticleAssociator.h:15
reco::MuonToSimCollection
std::map< edm::RefToBase< reco::Muon >, std::vector< std::pair< TrackingParticleRef, double > >, RefToBaseSort > MuonToSimCollection
Definition: MuonTrackType.h:37
reco::GenParticle
Definition: GenParticle.h:21
EgammaValidation_cff.genp
genp
produce generated paricles in acceptance #
Definition: EgammaValidation_cff.py:115
patZpeak.handle
handle
Definition: patZpeak.py:23
reco::MatchedMuonFromB
Definition: MuonSimInfo.h:53
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::ExtGhostElectron
Definition: MuonSimInfo.h:61
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
reco::ExtGhostPunchthrough
Definition: MuonSimInfo.h:60
reco::OuterTk
Definition: MuonTrackType.h:28
MuonSimClassifier::muonsToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonsToken_
The RECO objects.
Definition: MuonSimClassifier.cc:78
reco::MatchedMuonFromNonPrimaryParticle
Definition: MuonSimInfo.h:59
reco::GhostMuonFromNonPrimaryParticle
Definition: MuonSimInfo.h:70
MuonSimClassifier::trackType_
reco::MuonTrackType trackType_
Track to use.
Definition: MuonSimClassifier.cc:81
reco::InnerTk
Definition: MuonTrackType.h:28
edm::RefVector< TrackingParticleCollection >
edm::Handle
Definition: AssociativeIterator.h:50
reco::ExtNotMatched
Definition: MuonSimInfo.h:48
reco::ExtMatchedElectron
Definition: MuonSimInfo.h:50
MuonSimClassifier::getTpMother
TrackingParticleRef getTpMother(TrackingParticleRef tp)
Definition: MuonSimClassifier.cc:108
edm::Ref< TrackingParticleCollection >
reco::GhostMuonFromB
Definition: MuonSimInfo.h:64
reco::MatchedMuonFromLightFlavour
Definition: MuonSimInfo.h:38
MuonSimClassifier::genParticles_
edm::InputTag genParticles_
Definition: MuonSimClassifier.cc:95
reco::GhostMuonFromLightFlavour
Definition: MuonSimInfo.h:43
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
reco::MatchedMuonFromTau
Definition: MuonSimInfo.h:52
reco::SimToMuonCollection
std::map< TrackingParticleRef, std::vector< std::pair< edm::RefToBase< reco::Muon >, double > > > SimToMuonCollection
Definition: MuonTrackType.h:38
reco::GlbOrTrk
Definition: MuonTrackType.h:28
reco::GlobalTk
Definition: MuonTrackType.h:28
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonSimClassifier::genParticlesToken_
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken_
Definition: MuonSimClassifier.cc:96
dumpFormatedInfo
void dumpFormatedInfo(const reco::MuonSimInfo &simInfo)
Definition: MuonSimClassifier.cc:164
edm::View
Definition: CaloClusterFwd.h:14
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
allMuons_cfi.allMuons
allMuons
Definition: allMuons_cfi.py:3
MuonSimClassifier::decayAbsZ_
double decayAbsZ_
Definition: MuonSimClassifier.cc:91
reco::MatchedMuonFromGaugeOrHiggsBoson
Definition: MuonSimInfo.h:51
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
muonClassificationByHits_cfi.trackingParticles
trackingParticles
Definition: muonClassificationByHits_cfi.py:28
reco::GhostMuonFromTau
Definition: MuonSimInfo.h:63
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
reco::GhostMuonFromPiKppMuX
Definition: MuonSimInfo.h:68
reco::NotMatched
Definition: MuonSimInfo.h:33
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::ExtMatchedPunchthrough
Definition: MuonSimInfo.h:49
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
edm::Association
Definition: Association.h:18
edm::RefVector::push_back
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
edm::RefToBaseVector
Definition: EDProductfwd.h:29
reco::MatchedPrimaryMuon
Definition: MuonSimInfo.h:36
PbPb_ZMuSkimMuonDPG_cff.trackType
trackType
Definition: PbPb_ZMuSkimMuonDPG_cff.py:36
reco::MatchedMuonFromC
Definition: MuonSimInfo.h:55
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
MuonSimClassifier::muAssocToken_
edm::EDGetTokenT< reco::MuonToTrackingParticleAssociator > muAssocToken_
Definition: MuonSimClassifier.cc:88
MuonSimClassifier::trackingParticlesToken_
edm::EDGetTokenT< TrackingParticleCollection > trackingParticlesToken_
The TrackingParticle objects.
Definition: MuonSimClassifier.cc:84
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::OrphanHandle
Definition: EDProductfwd.h:39
reco::GhostMuonFromPiKNotppMuX
Definition: MuonSimInfo.h:69
reco::MuonSimInfo
Definition: MuonSimInfo.h:74
edm::ValueMap
Definition: ValueMap.h:107
reco::GhostMuonFromOtherLight
Definition: MuonSimInfo.h:67
reco::MuonToTrackingParticleAssociator::associateMuons
void associateMuons(MuonToSimCollection &recoToSim, SimToMuonCollection &simToReco, const edm::RefToBaseVector< reco::Muon > &muons, MuonTrackType type, const edm::RefVector< TrackingParticleCollection > &tpColl) const
Definition: MuonToTrackingParticleAssociator.h:25
Exception
Definition: hltDiff.cc:246
MuonSimClassifier::writeValueMap
void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::Muon >> &handle, const std::vector< T > &values, const std::string &label) const
Write a ValueMap<int> in the event.
Definition: MuonSimClassifier.cc:545
reco::GhostPunchthrough
Definition: MuonSimInfo.h:39
MuonSimClassifier::flavour
int flavour(int pdgId) const
Returns the flavour given a pdg id code.
Definition: MuonSimClassifier.cc:558
edm::RefToBase
Definition: AssociativeIterator.h:54
reco::MatchedMuonFromBtoC
Definition: MuonSimInfo.h:54
MuonSimClassifier::decayRho_
double decayRho_
Cylinder to use to decide if a decay is early or late.
Definition: MuonSimClassifier.cc:91
reco::MatchedElectron
Definition: MuonSimInfo.h:35
reco::MatchedMuonFromPiKNotppMuX
Definition: MuonSimInfo.h:58
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::MatchedMuonFromPiKppMuX
Definition: MuonSimInfo.h:57
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
reco::GhostMuonFromGaugeOrHiggsBoson
Definition: MuonSimInfo.h:62
MuonSimClassifier::linkToGenParticles_
bool linkToGenParticles_
Create a link to the generator level particles.
Definition: MuonSimClassifier.cc:94
MuonSimClassifier::convertAndPush
int convertAndPush(const TrackingParticle &tp, reco::GenParticleCollection &out, const TrackingParticleRef &momRef, const edm::Handle< reco::GenParticleCollection > &genParticles) const
Definition: MuonSimClassifier.cc:577
TrackingParticleRef
edm::Ref< TrackingParticleCollection > TrackingParticleRef
Definition: TrackingParticleFwd.h:10
reco::GhostPrimaryMuon
Definition: MuonSimInfo.h:41
reco::GhostMuonFromC
Definition: MuonSimInfo.h:66
reco::Segments
Definition: MuonTrackType.h:28
reco::MatchedMuonFromHeavyFlavour
Definition: MuonSimInfo.h:37
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
reco::GhostMuonFromBtoC
Definition: MuonSimInfo.h:65
reco::MatchedPunchthrough
Definition: MuonSimInfo.h:34