ATLAS Offline Software
MuonTrackTruthTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <iostream>
8 
9 #include "AtlasHepMC/GenEvent.h"
10 #include "AtlasHepMC/GenParticle.h"
19 #include "TrkTrack/Track.h"
22 
23 namespace Muon {
24 
25  MuonTrackTruthTool::MuonTrackTruthTool(const std::string& ty, const std::string& na, const IInterface* pa) :
26  AthAlgTool(ty, na, pa), m_detMgr(nullptr) {
27  declareInterface<IMuonTrackTruthTool>(this);
28  }
29 
32  ATH_CHECK(m_idHelperSvc.retrieve());
33  ATH_CHECK(m_printer.retrieve());
35 
36  // add muons
37  if (m_pdgsToBeConsidered.value().empty()) {
38  m_selectedPdgs.insert(13);
39  m_selectedPdgs.insert(-13);
40  } else {
41  // add pdgs
42  for (auto pdg : m_pdgsToBeConsidered.value()) { m_selectedPdgs.insert(pdg); }
43  ATH_MSG_DEBUG(" PDG codes used for matching");
44  for (auto val : m_selectedPdgs) { ATH_MSG_DEBUG(" " << val); }
45  }
46  return StatusCode::SUCCESS;
47  }
48 
50  if (m_manipulateBarCode) return barcode % 10000;
51  return barcode;
52  }
53 
55  const MuonTrackTruthTool::MatchResult& r2) const {
56  return operator()(r1.second, r2.second);
57  }
58 
61  return operator()(r1.second, r2.second);
62  }
63 
65  // if not from same track sort by address (should be unique)
66  if (t1.truthTrack && !t2.truthTrack) return true;
67  if (!t1.truthTrack && t2.truthTrack) return false;
68  if (!t1.truthTrack && !t2.truthTrack) return false;
69  if (t1.truthTrack->barcode() == t2.truthTrack->barcode()) return t1.numberOfMatchedHits() > t2.numberOfMatchedHits(); // FIXME barcode-based
70  return t1.truthTrack->barcode() < t2.truthTrack->barcode(); // FIXME barcode-based
71  }
72 
75  result.reserve(tracks.size());
76 
77  // loop over tracks and match each of them with truth
79  TrackCollection::const_iterator tit_end = tracks.end();
80  for (; tit != tit_end; ++tit) {
82  if (!match.truthTrack) continue;
83 
84  if (match.numberOfMatchedHits() == 0) continue;
85 
86  // create truth association
87  result.emplace_back(*tit, match);
88  }
89 
90  // sort result per muon and per number of matched hits
91  std::stable_sort(result.begin(), result.end(), SortResultByMatchedHits());
92 
93  return result;
94  }
95 
97  const std::vector<const MuonSegment*>& segments) const {
99  result.reserve(segments.size());
100 
101  // loop over tracks and match each of them with truth
102  std::vector<const MuonSegment*>::const_iterator sit = segments.begin();
103  std::vector<const MuonSegment*>::const_iterator sit_end = segments.end();
104  for (; sit != sit_end; ++sit) {
105  // create truth association
106  result.emplace_back(*sit, getTruth(truth_tree, **sit));
107  }
108 
109  // sort result per muon and per number of matched hits
110  std::stable_sort(result.begin(), result.end(), SortResultByMatchedHits());
111 
112  return result;
113  }
114 
116  const McEventCollection* mcEventCollection,
117  const std::vector<const MuonSimDataCollection*>& muonSimData,
118  const CscSimDataCollection* cscSimDataMap) const {
119  std::map<int, int> barcode_map;
121  if (truthTrackCol->empty()) {
122  ATH_MSG_WARNING(" TrackRecordCollection is empty ");
123  return truth_tree;
124  }
125 
126  const HepMC::GenEvent* genEvent = nullptr;
127  if (!mcEventCollection->empty()) {
128  ATH_MSG_VERBOSE("McEventCollection size " << mcEventCollection->size());
129  if (mcEventCollection->size() == 1) genEvent = mcEventCollection->front();
130  }
131 
132  ATH_MSG_VERBOSE(" creating truth tree from track record " << truthTrackCol->size());
133 
134  TrackRecordConstIterator tr_it = truthTrackCol->begin();
135  TrackRecordConstIterator tr_it_end = truthTrackCol->end();
136  for (; tr_it != tr_it_end; ++tr_it) {
137  int PDGCode((*tr_it).GetPDGCode());
138  int barcode = (*tr_it).barcode(); // FIXME barcode-based
139  if (!m_matchAllParticles && !selectPdg(PDGCode)) {
140  ATH_MSG_VERBOSE(" discarding truth track: pdg " << PDGCode << " barcode " << barcode);
141  continue;
142  }
143 
144  // check whether barcode is already in, skip if that is the case
145  if (barcode_map.count(barcode)) {
146  ATH_MSG_VERBOSE(" barcode " << barcode << " already in map, final state barcode " << barcode_map[barcode]);
147  continue;
148  }
149  ATH_MSG_VERBOSE(" found new particle with pdgid " << PDGCode << " in truth record, barcode " << barcode);
150 
151  std::unique_ptr<TruthTrajectory> truthTrajectory;
152  // associate the muon truth with the gen event info
153  if (genEvent) {
154  HepMC::ConstGenParticlePtr genParticle = HepMC::barcode_to_particle(genEvent, (*tr_it).barcode()); // FIXME barcode-based
155  if (genParticle) {
156  truthTrajectory = std::make_unique<TruthTrajectory>();
157  m_truthTrajectoryBuilder->buildTruthTrajectory(truthTrajectory.get(), genParticle);
158  if (!truthTrajectory->empty()) {
159  // always use barcode of the 'final' particle in chain in map
160  barcode = truthTrajectory->front().barcode();
161 
162  if (msgLvl(MSG::VERBOSE)) {
163  auto particle = truthTrajectory->front().cptr();
164  ATH_MSG_VERBOSE(" found GenParticle: size " << truthTrajectory->size() << " fs barcode " << barcode << "particle "<< particle);
165  if (particle->production_vertex()) {
166  ATH_MSG_VERBOSE(" vertex: r " << particle->production_vertex()->position().perp() << " z "
167  << particle->production_vertex()->position().z());
168  }
169  }
170 
171  // now collect all barcodes beloning to this TruthTrajectory
172  std::vector<HepMcParticleLink>::const_iterator pit = truthTrajectory->begin();
173  std::vector<HepMcParticleLink>::const_iterator pit_end = truthTrajectory->end();
174  for (; pit != pit_end; ++pit) {
175  int code = (*pit).barcode();
176 
177  if (msgLvl(MSG::VERBOSE) && code != barcode) {
178  auto particle = (*pit).cptr();
179  ATH_MSG_VERBOSE(" secondary barcode: " << code << "particle "<< particle);
180  if (particle->production_vertex())
181  ATH_MSG_VERBOSE(" vertex: r " <<particle->production_vertex()->position().perp() << " z "
182  << particle->production_vertex()->position().z());
183  // sanity check
184  if (barcode_map.count(code)) ATH_MSG_VERBOSE(" pre-existing barcode " << code);
185  }
186 
187  // enter barcode
188  barcode_map[code] = barcode;
189  }
190  } else {
191  ATH_MSG_WARNING(" empty truth trajectory " << barcode);
192  }
193  }
194  } else {
195  // add one to one relation
196  barcode_map[barcode] = barcode;
197  }
198 
199  if (truth_tree.count(barcode)) {
200  ATH_MSG_WARNING(" found muon barcode twice in truth record: " << barcode);
201  continue;
202  }
203 
205  entry.truthTrack = &(*tr_it);
206  // entry.truthTrajectory = truthTrajectory.get();
207  entry.truthTrajectory = std::move(truthTrajectory);
208  // m_truthTrajectoriesToBeDeleted.push_back(std::move(truthTrajectory));
209  }
210 
211  // add sim data collections
212  for (const MuonSimDataCollection* simDataMap : muonSimData) { addSimDataToTree(truth_tree, barcode_map, simDataMap); }
213  if (cscSimDataMap) { addCscSimDataToTree(truth_tree, barcode_map, cscSimDataMap); }
214 
215  unsigned int ngood(0);
216  std::vector<int> badBarcodes;
217  // erase entries with too few hits or no track record
218  TruthTreeIt it = truth_tree.begin();
219  for (; it != truth_tree.end(); ++it) {
220  bool erase = false;
221  unsigned int nhits = it->second.mdtHits.size() + it->second.rpcHits.size() + it->second.tgcHits.size() +
222  it->second.cscHits.size() + it->second.stgcHits.size() + it->second.mmHits.size();
223  if (!it->second.truthTrack) erase = true;
224  if (nhits < m_minHits) erase = true;
225 
226  if (erase) {
227  ATH_MSG_VERBOSE(" Erasing entry: barcode " << it->second.truthTrack->barcode() << " manip "
228  << manipulateBarCode(it->second.truthTrack->barcode()) << " hits " << nhits); // FIXME barcode-based
229  badBarcodes.push_back(it->first);
230  } else {
231  ++ngood;
232  ATH_MSG_VERBOSE(" Keeping entry: barcode " << it->second.truthTrack->barcode() << " manip "
233  << manipulateBarCode(it->second.truthTrack->barcode()) << " hits " << nhits); // FIXME barcode-based
234  }
235  }
236 
237  std::vector<int>::iterator badIt = badBarcodes.begin();
238  std::vector<int>::iterator badIt_end = badBarcodes.end();
239  for (; badIt != badIt_end; ++badIt) truth_tree.erase(*badIt);
240 
241  if (ngood != truth_tree.size()) {
242  ATH_MSG_WARNING(" Problem cleaning map: size " << truth_tree.size() << " accepted entries " << ngood);
243  }
244 
245  if (m_doSummary || msgLvl(MSG::DEBUG)) {
246  ATH_MSG_INFO(" summarizing truth tree: number of particles " << truth_tree.size());
247  TruthTreeIt it = truth_tree.begin();
248  TruthTreeIt it_end = truth_tree.end();
249  for (; it != it_end; ++it) {
250  if (!it->second.truthTrack)
251  ATH_MSG_INFO(" no TrackRecord ");
252  else {
253  ATH_MSG_INFO(" PDG " << it->second.truthTrack->GetPDGCode() << " barcode " << it->second.truthTrack->barcode()
254  << " manip " << manipulateBarCode(it->second.truthTrack->barcode())); // FIXME barcode-based
255  }
256  if (!it->second.mdtHits.empty()) ATH_MSG_INFO(" mdt " << it->second.mdtHits.size());
257  if (!it->second.rpcHits.empty()) ATH_MSG_INFO(" rpc " << it->second.rpcHits.size());
258  if (!it->second.tgcHits.empty()) ATH_MSG_INFO(" tgc " << it->second.tgcHits.size());
259  if (!it->second.cscHits.empty()) ATH_MSG_INFO(" csc " << it->second.cscHits.size());
260  if (!it->second.stgcHits.empty()) ATH_MSG_INFO(" stgc " << it->second.stgcHits.size());
261  if (!it->second.mmHits.empty()) ATH_MSG_INFO(" mm " << it->second.mmHits.size());
262  if (it->second.mdtHits.empty() && it->second.rpcHits.empty() && it->second.tgcHits.empty() && it->second.cscHits.empty() &&
263  it->second.stgcHits.empty() && it->second.mmHits.empty())
264  ATH_MSG_INFO(" no hits ");
265  }
266  }
267 
268  return truth_tree;
269  }
270 
271  void MuonTrackTruthTool::addSimDataToTree(TruthTree& truth_tree, std::map<int, int>& barcode_map,
272  const MuonSimDataCollection* simDataCol) const {
273  // loop over sim collection and check whether identifiers are on track
274  MuonSimDataCollection::const_iterator it = simDataCol->begin();
275  MuonSimDataCollection::const_iterator it_end = simDataCol->end();
276  for (; it != it_end; ++it) {
277  Identifier id = it->first;
278 
279  // loop over deposits
280  std::vector<MuonSimData::Deposit>::const_iterator dit = it->second.getdeposits().begin();
281  std::vector<MuonSimData::Deposit>::const_iterator dit_end = it->second.getdeposits().end();
282  for (; dit != dit_end; ++dit) {
283  int barcodeIn = dit->first.barcode();
284  std::map<int, int>::const_iterator bit = barcode_map.find(barcodeIn);
285  if (bit == barcode_map.end()) {
286  ATH_MSG_VERBOSE(" discarding "
287  << " " << m_idHelperSvc->toString(id) << " barcode " << barcodeIn);
288  continue;
289  }
290  // replace barcode with barcode from map
291  int barcode = bit->second;
292 
293  TruthTreeIt eit = truth_tree.find(barcode);
294  if (eit == truth_tree.end()) {
295  ATH_MSG_VERBOSE(" discarding "
296  << " " << m_idHelperSvc->toString(id) << " barcode " << barcode);
297  continue;
298  }
299 
300  if (m_idHelperSvc->isMdt(id)) {
301  if (m_detMgr && !m_detMgr->getMdtReadoutElement(id)) {
302  ATH_MSG_VERBOSE(" discarding: no detEl "
303  << " " << m_idHelperSvc->toString(id) << " barcode " << barcode);
304  continue;
305  }
306  eit->second.mdtHits.insert(*it);
307  } else if (m_idHelperSvc->isRpc(id)) {
308  if (m_detMgr && !m_detMgr->getRpcReadoutElement(id)) {
309  ATH_MSG_VERBOSE(" discarding: no detEl "
310  << " " << m_idHelperSvc->toString(id) << " barcode " << barcode);
311  continue;
312  }
313 
314  if (m_idHelperSvc->stationIndex(id) == MuonStationIndex::BO && m_idHelperSvc->rpcIdHelper().doubletR(id) == 2) {
315  ATH_MSG_VERBOSE(" Discarding non existing RPC hit " << m_idHelperSvc->toString(id));
316  continue;
317  }
318 
319  eit->second.rpcHits.insert(*it);
320  } else if (m_idHelperSvc->isTgc(id)) {
321  if (m_detMgr && !m_detMgr->getTgcReadoutElement(id)) {
322  ATH_MSG_VERBOSE(" discarding: no detEl "
323  << " " << m_idHelperSvc->toString(id) << " barcode " << barcode);
324  continue;
325  }
326  eit->second.tgcHits.insert(*it);
327  } else if (m_idHelperSvc->issTgc(id)) {
328  if (m_detMgr && !m_detMgr->getsTgcReadoutElement(id)) {
329  ATH_MSG_VERBOSE(" discarding: no detEl "
330  << " " << m_idHelperSvc->toString(id) << " barcode " << barcode);
331  continue;
332  }
333  eit->second.stgcHits.insert(*it);
334  } else if (m_idHelperSvc->isMM(id)) {
335  if (m_detMgr && !m_detMgr->getMMReadoutElement(id)) {
336  ATH_MSG_VERBOSE(" discarding: no detEl "
337  << " " << m_idHelperSvc->toString(id) << " barcode " << barcode);
338  continue;
339  }
340  eit->second.mmHits.insert(*it);
341  }
342  if (msgLvl(MSG::VERBOSE)) {
343  ATH_MSG_VERBOSE(" adding hit " << m_idHelperSvc->toString(id) << " barcode " << barcode);
344  if (barcode != barcodeIn) ATH_MSG_VERBOSE(" hit barcode " << barcodeIn);
345  }
346  }
347  }
348  }
349 
350  void MuonTrackTruthTool::addCscSimDataToTree(TruthTree& truth_tree, std::map<int, int>& barcode_map,
351  const CscSimDataCollection* simDataCol) const {
352  // loop over sim collection and check whether identifiers are on track
353  CscSimDataCollection::const_iterator it = simDataCol->begin();
354  CscSimDataCollection::const_iterator it_end = simDataCol->end();
355  for (; it != it_end; ++it) {
356  Identifier id = it->first;
357 
358  // loop over deposits
359  std::vector<CscSimData::Deposit>::const_iterator dit = it->second.getdeposits().begin();
360  std::vector<CscSimData::Deposit>::const_iterator dit_end = it->second.getdeposits().end();
361  for (; dit != dit_end; ++dit) {
362  int barcodeIn = manipulateBarCode(dit->first.barcode());
363  std::map<int, int>::const_iterator bit = barcode_map.find(barcodeIn);
364  if (bit == barcode_map.end()) {
365  ATH_MSG_VERBOSE(" discarding "
366  << " " << m_idHelperSvc->toString(id) << " barcode " << barcodeIn);
367  continue;
368  }
369  // replace barcode with barcode from map
370  int barcode = bit->second;
371 
372  TruthTreeIt eit = truth_tree.find(barcode);
373  if (eit == truth_tree.end()) {
374  ATH_MSG_VERBOSE(" discarding "
375  << " " << m_idHelperSvc->toString(id) << " barcode " << barcode);
376  continue;
377  }
378 
379  if (msgLvl(MSG::VERBOSE)) {
380  ATH_MSG_VERBOSE(" adding hit " << m_idHelperSvc->toString(id) << " barcode " << barcode);
381  if (barcode != barcodeIn) ATH_MSG_VERBOSE(" hit barcode " << barcodeIn);
382  }
383  eit->second.cscHits.insert(*it);
384  }
385  }
386  }
387 
389  return getTruth(truth_tree, segment.containedMeasurements(), true);
390  }
391 
392  MuonTrackTruth MuonTrackTruthTool::getTruth(const TruthTree& truth_tree, const Trk::Track& track, bool restrictedTruth) const {
393  if (track.measurementsOnTrack()) return getTruth(truth_tree, track.measurementsOnTrack()->stdcont(), restrictedTruth);
394  return {};
395  }
396 
397  MuonTrackTruth MuonTrackTruthTool::getTruth(const TruthTree& truth_tree, const std::vector<const MuonSegment*>& segments,
398  bool restrictedTruth) const {
399  std::set<Identifier> ids;
400  std::vector<const Trk::MeasurementBase*> measurements;
401  std::vector<const MuonSegment*>::const_iterator sit = segments.begin();
402  std::vector<const MuonSegment*>::const_iterator sit_end = segments.end();
403  for (; sit != sit_end; ++sit) {
404  std::vector<const Trk::MeasurementBase*>::const_iterator mit = (*sit)->containedMeasurements().begin();
405  std::vector<const Trk::MeasurementBase*>::const_iterator mit_end = (*sit)->containedMeasurements().end();
406  for (; mit != mit_end; ++mit) {
407  const Trk::MeasurementBase* meas = *mit;
408  const Trk::RIO_OnTrack* rot = nullptr;
409  Trk::RoT_Extractor::extract(rot, meas);
410  if (!rot) {
411  if (!dynamic_cast<const Trk::PseudoMeasurementOnTrack*>(meas)) ATH_MSG_WARNING(" Could not get rot from measurement ");
412  continue;
413  }
414  Identifier id = rot->identify();
415  if (!id.is_valid() || !m_idHelperSvc->mdtIdHelper().is_muon(id)) continue;
416  if (ids.count(id)) continue;
417  measurements.push_back(meas);
418  ids.insert(id);
419  }
420  }
421  return getTruth(truth_tree, measurements, restrictedTruth);
422  }
423 
424  MuonTrackTruth MuonTrackTruthTool::getTruth(const TruthTree& truth_tree, const std::vector<const Trk::MeasurementBase*>& measurements,
425  bool restrictedTruth) const {
426  MuonTrackTruth bestMatch;
427  bestMatch.truthTrack = nullptr;
428  bestMatch.truthTrajectory = nullptr;
429 
430  unsigned int nmatchedHitsBest = 0;
431  // loop over muons and match hits
432  TruthTreeConstIt tit = truth_tree.begin();
433  TruthTreeConstIt tit_end = truth_tree.end();
434  for (; tit != tit_end; ++tit) {
435  unsigned int nhits = tit->second.mdtHits.size() + tit->second.cscHits.size() + tit->second.rpcHits.size() +
436  tit->second.tgcHits.size() + tit->second.stgcHits.size() + tit->second.mmHits.size();
437  if (nhits == 0) continue;
438 
439  MuonTrackTruth trackTruth = getTruth(measurements, tit->second, restrictedTruth);
440  unsigned int nmatchedHits = trackTruth.numberOfMatchedHits();
441  ATH_MSG_DEBUG(" performed truth match for particle with barcode: " << tit->first << " overlap " << nmatchedHits << " fraction "
442  << (double)nmatchedHits / (double)nhits);
443  if (nmatchedHits > 0 && nmatchedHits > nmatchedHitsBest) {
444  bestMatch = trackTruth;
445  nmatchedHitsBest = nmatchedHits;
446  }
447  }
448 
449  return bestMatch;
450  }
451 
452  MuonTrackTruth MuonTrackTruthTool::getTruth(const std::vector<const Trk::MeasurementBase*>& measurements,
453  const TruthTreeEntry& truthEntry, bool restrictedTruth) const {
454  MuonTrackTruth trackTruth;
455  trackTruth.truthTrack = truthEntry.truthTrack;
456  trackTruth.truthTrajectory = truthEntry.truthTrajectory;
457 
458  std::vector<const Trk::MeasurementBase*>::const_iterator mit = measurements.begin();
459  std::vector<const Trk::MeasurementBase*>::const_iterator mit_end = measurements.end();
460  for (; mit != mit_end; ++mit) {
461  // check whether state is a measurement
462  const Trk::MeasurementBase* meas = *mit;
463  if (!meas) { continue; }
464 
465  const Trk::RIO_OnTrack* rot = nullptr;
466  Trk::RoT_Extractor::extract(rot, meas);
467  if (!rot) {
468  if (!dynamic_cast<const Trk::PseudoMeasurementOnTrack*>(meas)) ATH_MSG_WARNING(" Could not get rot from measurement ");
469  continue;
470  }
471  Identifier id = rot->identify();
472  if (!id.is_valid() || !m_idHelperSvc->mdtIdHelper().is_muon(id)) continue;
473 
474  if (m_idHelperSvc->isMdt(id)) {
475  addMdtTruth(trackTruth.mdts, id, *meas, truthEntry.mdtHits);
476  } else if (m_idHelperSvc->isCsc(id)) {
477  addClusterTruth(trackTruth.cscs, id, *meas, truthEntry.cscHits);
478  } else if (m_idHelperSvc->isRpc(id)) {
479  addClusterTruth(trackTruth.rpcs, id, *meas, truthEntry.rpcHits);
480  } else if (m_idHelperSvc->isTgc(id)) {
481  addClusterTruth(trackTruth.tgcs, id, *meas, truthEntry.tgcHits);
482  } else if (m_idHelperSvc->issTgc(id)) {
483  addClusterTruth(trackTruth.stgcs, id, *meas, truthEntry.stgcHits);
484  } else if (m_idHelperSvc->isMM(id)) {
485  addClusterTruth(trackTruth.mms, id, *meas, truthEntry.mmHits);
486  }
487  }
488 
489  addMissedHits(trackTruth.mdts, trackTruth.mdts.matchedHits, trackTruth.mdts.matchedChambers, truthEntry.mdtHits, restrictedTruth);
490  addMissedHits(trackTruth.cscs, trackTruth.cscs.matchedHits, trackTruth.cscs.matchedChambers, truthEntry.cscHits, restrictedTruth);
491  addMissedHits(trackTruth.rpcs, trackTruth.rpcs.matchedHits, trackTruth.rpcs.matchedChambers, truthEntry.rpcHits, restrictedTruth);
492  addMissedHits(trackTruth.tgcs, trackTruth.tgcs.matchedHits, trackTruth.tgcs.matchedChambers, truthEntry.tgcHits, restrictedTruth);
493  addMissedHits(trackTruth.stgcs, trackTruth.stgcs.matchedHits, trackTruth.stgcs.matchedChambers, truthEntry.stgcHits,
494  restrictedTruth);
495  addMissedHits(trackTruth.mms, trackTruth.mms.matchedHits, trackTruth.mms.matchedChambers, truthEntry.mmHits, restrictedTruth);
496 
497  return trackTruth;
498  }
499 
500  void MuonTrackTruthTool::addMissedHits(MuonTechnologyTruth& truth, const std::set<Identifier>& ids, const std::set<Identifier>& chids,
501  const MuonSimDataCollection& simCol, bool restrictedTruth) const {
502  // loop over sim collection and check whether identifiers are on track
503  MuonSimDataCollection::const_iterator it = simCol.begin();
504  MuonSimDataCollection::const_iterator it_end = simCol.end();
505  for (; it != it_end; ++it) {
506  Identifier id = it->first;
507  // for trigger chambers use layer id
508  if (m_idHelperSvc->isTrigger(id) || m_idHelperSvc->isCsc(id)) id = m_idHelperSvc->layerId(id);
509 
510  int isOnTrack = ids.count(id);
511  if (isOnTrack) continue;
512 
513  // if restricted truth mode, skip if chamber has not hits
514  Identifier chid = m_idHelperSvc->chamberId(id);
515  bool chamberHasHits = chids.count(chid);
516  if (restrictedTruth && !chamberHasHits) continue;
517 
518  // loop over deposits
519  std::vector<MuonSimData::Deposit>::const_iterator dit = it->second.getdeposits().begin();
520  std::vector<MuonSimData::Deposit>::const_iterator dit_end = it->second.getdeposits().end();
521  for (; dit != dit_end; ++dit) {
522  truth.missedHits.insert(id);
523  // only fill a missed chamber if the chamber had no hits
524  if (!chamberHasHits) truth.missedChambers.insert(chid);
525  }
526  }
527  }
528 
529  void MuonTrackTruthTool::addMissedHits(MuonTechnologyTruth& truth, const std::set<Identifier>& ids, const std::set<Identifier>& chids,
530  const CscSimDataCollection& simCol, bool restrictedTruth) const {
531  // loop over sim collection and check whether identifiers are on track
532  CscSimDataCollection::const_iterator it = simCol.begin();
533  CscSimDataCollection::const_iterator it_end = simCol.end();
534  for (; it != it_end; ++it) {
535  Identifier id = m_idHelperSvc->layerId(it->first);
536 
537  int isOnTrack = ids.count(id);
538  if (isOnTrack) continue;
539 
540  // if restricted truth mode, skip if chamber has not hits
541  Identifier chid = m_idHelperSvc->chamberId(id);
542  bool chamberHasHits = chids.count(chid);
543  if (restrictedTruth && !chamberHasHits) continue;
544 
545  // loop over deposits
546  std::vector<CscSimData::Deposit>::const_iterator dit = it->second.getdeposits().begin();
547  std::vector<CscSimData::Deposit>::const_iterator dit_end = it->second.getdeposits().end();
548  for (; dit != dit_end; ++dit) {
549  truth.missedHits.insert(id);
550  // only fill a missed chamber if the chamber had no hits
551  if (!chamberHasHits) truth.missedChambers.insert(chid);
552  }
553  }
554  }
555 
557  const MuonSimDataCollection& simCol) const {
558  const MdtDriftCircleOnTrack* mdt = dynamic_cast<const MdtDriftCircleOnTrack*>(&meas);
559  if (!mdt) {
560  ATH_MSG_WARNING(" dynamic_cast to MdtDriftCircleOnTrack failed for measurement with id " << m_idHelperSvc->toString(id));
561  return;
562  }
563 
564  Identifier chid = m_idHelperSvc->chamberId(id);
565 
566  // find SimData corresponding to identifier
567  MuonSimDataCollection::const_iterator it = simCol.find(id);
568  if (it == simCol.end()) {
569  truth.wrongHits.insert(id);
570  truth.wrongChambers.insert(chid);
571  return;
572  }
573 
574  std::vector<MuonSimData::Deposit>::const_iterator dit = it->second.getdeposits().begin();
575  std::vector<MuonSimData::Deposit>::const_iterator dit_end = it->second.getdeposits().end();
576  for (; dit != dit_end; ++dit) {
577  double radius = dit->second.firstEntry();
578 
579  // check whether SDO and hit have same sign, don't check sign if drift radius < 0.3 mm as it will be badly determined
580  double checkSign = fabs(mdt->driftRadius()) > 0.3 ? radius * mdt->driftRadius() : 1;
581  if (checkSign >= 0) {
582  truth.matchedHits.insert(id);
583  truth.matchedChambers.insert(chid);
584  } else {
585  truth.wrongHits.insert(id);
586  truth.wrongChambers.insert(chid);
587  }
588  }
589  }
590 
592  const MuonSimDataCollection& simCol) const {
593  Identifier layid = m_idHelperSvc->layerId(id);
594  Identifier chid = m_idHelperSvc->chamberId(id);
595 
596  MuonSimDataCollection::const_iterator it = simCol.end();
597 
598  bool goodCluster = false;
599  const CompetingMuonClustersOnTrack* crot = dynamic_cast<const CompetingMuonClustersOnTrack*>(&meas);
600  if (crot) {
601  for (unsigned int i = 0; i < crot->numberOfContainedROTs(); ++i) {
602  const MuonClusterOnTrack* cluster = &crot->rioOnTrack(i);
603  if (!cluster) continue;
604  // find SimData corresponding to identifier
605  it = simCol.find(cluster->identify());
606  if (it != simCol.end()) {
607  goodCluster = true;
608  break;
609  }
610  }
611  } else {
612  // Find SimData corresponding to identifier
613  const Trk::RIO_OnTrack* rot = nullptr;
614  Trk::RoT_Extractor::extract(rot, &meas);
615  const Trk::PrepRawData* prd = rot->prepRawData();
616  if (prd) {
617  // check if an identifier from the list of RDOs is matched to that in the SDO collection
618  const std::vector<Identifier> &rdoList = prd->rdoList();
619  std::vector<Identifier>::const_iterator rit = rdoList.begin();
620  std::vector<Identifier>::const_iterator rit_end = rdoList.end();
621  for (; rit != rit_end; ++rit) {
622  it = simCol.find(*rit);
623  if (it != simCol.end()) {
624  goodCluster = true;
625  break;
626  }
627  }
628  } else {
629  it = simCol.find(id);
630  if (it != simCol.end()) goodCluster = true;
631  }
632  }
633 
634  if (!goodCluster || it == simCol.end()) {
635  truth.wrongHits.insert(id);
636  return;
637  }
638 
639  std::vector<MuonSimData::Deposit>::const_iterator dit = it->second.getdeposits().begin();
640  std::vector<MuonSimData::Deposit>::const_iterator dit_end = it->second.getdeposits().end();
641  for (; dit != dit_end; ++dit) {
642  truth.matchedHits.insert(layid);
643  truth.matchedChambers.insert(chid);
644  }
645  }
646 
648  const CscSimDataCollection& simCol) const {
649  Identifier layid = m_idHelperSvc->layerId(id);
650  Identifier chid = m_idHelperSvc->chamberId(id);
651  // find SimData corresponding to identifier
652  CscSimDataCollection::const_iterator it = simCol.find(id);
653  if (it == simCol.end()) {
654  truth.wrongHits.insert(layid);
655  truth.wrongChambers.insert(chid);
656  return;
657  }
658 
659  std::vector<CscSimData::Deposit>::const_iterator dit = it->second.getdeposits().begin();
660  std::vector<CscSimData::Deposit>::const_iterator dit_end = it->second.getdeposits().end();
661  for (; dit != dit_end; ++dit) {
662  truth.matchedHits.insert(layid);
663  truth.matchedChambers.insert(chid);
664  }
665  }
666 
668  ATH_MSG_DEBUG("getMother() : size = " << traj.size());
669  int pdgFinal = ((traj.empty()) ? -999 : traj.front().cptr()->pdg_id());
670  bool foundBC = false;
671  for (const auto& pit : traj) {
672  if (!pit) continue;
673  if (pit.barcode() == barcodeIn || foundBC) {
674  foundBC = true;
675  ATH_MSG_DEBUG("getMother() : " << pit );
676 #ifdef HEPMC3
677  auto particle = pit.scptr();
678 #else
679  auto particle = pit.cptr();
680 #endif
681  if (particle->pdg_id() != pdgFinal) { // the first case a track had a different flavour
682  break;
683  }
684  }
685  }
686  return nullptr;
687  }
688 
690  bool foundBC = false;
691  for (const auto& pit : traj) {
692  if (!pit) continue;
693  if (pit.barcode() == barcodeIn || foundBC) {
694  foundBC = true;
695 #ifdef HEPMC3
696  auto particle = pit.scptr();
697 #else
698  auto particle = pit.cptr();
699 #endif
700  if (!MC::isStable(particle)) { // first non final state particle
701  return particle;
702  }
703  }
704  }
705  return nullptr;
706  }
707 
708  const std::pair<HepMC::ConstGenParticlePtr, unsigned int> MuonTrackTruthTool::getInitialPair(const TruthTrajectory& traj,
709  const int barcodeIn) const {
710  std::pair<HepMC::ConstGenParticlePtr, unsigned int> thePair(nullptr, 0);
711  unsigned int scat = 0;
712  ATH_MSG_DEBUG("getFirst() : size = " << traj.size());
713  bool foundBC = false;
714  int pdgFinal = 0;
715  double ePrev = 0.;
716  HepMC::ConstGenParticlePtr theFirst{nullptr};
717  for (auto pit = traj.begin(); pit != traj.end(); ++pit) {
718  if ((*pit).barcode() == barcodeIn || foundBC) {
719  auto particle = (*pit).scptr();
720 #ifdef HEPMC3
721  if (!foundBC) {
722  foundBC = true;
723  theFirst = particle;
724  pdgFinal = particle->pdg_id();
725  } else {
726  if (particle->pdg_id() == pdgFinal) {
727  const auto& pit_p = *pit;
728  if ((theFirst != pit_p.scptr()) && (particle->momentum().t() != ePrev))
729  ++scat; // if the particle has not changed pdgid after the first step count as scatter. also avoid counting
730  // pure interface changes as scatter
731  } else { // the first time this particle appears
732  --pit; // AV This is confusing
733  theFirst = (*pit).scptr();
734  break;
735  }
736  }
737 #else
738  if (!foundBC) {
739  foundBC = true;
740  theFirst = (*pit).cptr();
741  pdgFinal = (*pit)->pdg_id();
742  } else {
743  if ((*pit)->pdg_id() == pdgFinal) {
744  auto pit_p = *pit;
745  if ((theFirst != pit_p.cptr()) && ((*pit).cptr()->momentum().t() != ePrev))
746  ++scat; // if the particle has not changed pdgid after the first step count as scatter. also avoid counting
747  // pure interface changes as scatter
748  } else { // the first time this particle appears
749  --pit;
750  theFirst = (*pit).cptr();
751  break;
752  }
753  }
754 #endif
755  ATH_MSG_DEBUG("getFirst() : pt = " << particle->momentum().perp() << " scat = " << scat);
756  ePrev = particle->momentum().t(); // prepare for comparing this entry with the next one
757  }
758  }
759  // sanity check
760  if (theFirst && theFirst->pdg_id() != pdgFinal) ATH_MSG_ERROR("Wrong pdgId association in getFirst()");
761  ATH_MSG_DEBUG("Number of scatters = " << scat << " pdgId = " << pdgFinal);
762 
763  thePair.first = theFirst;
764  thePair.second = scat;
765  return thePair;
766  }
767 
769  return getInitialPair(traj, barcodeIn).first;
770  }
771 
772  unsigned int MuonTrackTruthTool::getNumberOfScatters(const TruthTrajectory& traj, const int barcodeIn) const {
773  return (getInitialPair(traj, barcodeIn)).second;
774  }
775 } // namespace Muon
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
MuonGM::MuonDetectorManager::getRpcReadoutElement
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:168
Muon::MuonTechnologyTruth
Definition: IMuonTrackTruthTool.h:30
Muon::MuonTrackTruthTool::SortResultByMatchedHits::operator()
bool operator()(const MatchResult &r1, const MatchResult &r2) const
Definition: MuonTrackTruthTool.cxx:54
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
GenEvent.h
get_generator_info.result
result
Definition: get_generator_info.py:21
MeasurementBase.h
Muon::MuonTrackTruthTool::m_printer
ToolHandle< Muon::MuonEDMPrinterTool > m_printer
Definition: MuonTrackTruthTool.h:143
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
Muon::MuonTrackTruthTool::getAncestor
HepMC::ConstGenParticlePtr getAncestor(const TruthTrajectory &traj, const int barcodeIn) const
Returns the ancestor particle of the particle with barcodeIn if it is found in the truth trajectory.
Definition: MuonTrackTruthTool.cxx:689
Muon::MuonTrackTruthTool::getInitial
HepMC::ConstGenParticlePtr getInitial(const TruthTrajectory &traj, const int barcodeIn) const
Returns the initial particle of the particle with barcodeIn if it is found in the truth trajectory.
Definition: MuonTrackTruthTool.cxx:768
Muon::MuonTrackTruth::truthTrajectory
std::shared_ptr< const TruthTrajectory > truthTrajectory
Definition: IMuonTrackTruthTool.h:43
Muon::MuonTrackTruthTool::MuonTrackTruthTool
MuonTrackTruthTool(const std::string &, const std::string &, const IInterface *)
constructor
Definition: MuonTrackTruthTool.cxx:25
Muon::MuonTrackTruth::stgcs
MuonTechnologyTruth stgcs
Definition: IMuonTrackTruthTool.h:50
Muon::MuonTrackTruthTool::m_selectedPdgs
std::set< int > m_selectedPdgs
Definition: MuonTrackTruthTool.h:153
Muon::MuonTechnologyTruth::matchedHits
std::set< Identifier > matchedHits
Definition: IMuonTrackTruthTool.h:32
AtlasHitsVector
Definition: AtlasHitsVector.h:33
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
skel.it
it
Definition: skel.GENtoEVGEN.py:423
Muon::MuonTechnologyTruth::wrongHits
std::set< Identifier > wrongHits
Definition: IMuonTrackTruthTool.h:36
Muon::IMuonTrackTruthTool::TruthTreeIt
TruthTree::iterator TruthTreeIt
Definition: IMuonTrackTruthTool.h:94
CompetingMuonClustersOnTrack.h
Muon::IMuonTrackTruthTool::TruthTreeEntry::cscHits
CscSimDataCollection cscHits
Definition: IMuonTrackTruthTool.h:79
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
Muon::IMuonTrackTruthTool::TruthTreeEntry::mmHits
MuonSimDataCollection mmHits
Definition: IMuonTrackTruthTool.h:83
Muon::MuonTrackTruth
Definition: IMuonTrackTruthTool.h:40
Muon::MuonTrackTruthTool::createTruthTree
const TruthTree createTruthTree(const TrackRecordCollection *truthTrackCol, const McEventCollection *mcEventCollection, const std::vector< const MuonSimDataCollection * > &muonSimData, const CscSimDataCollection *cscSimDataMap) const
create truth tree from sim data
Definition: MuonTrackTruthTool.cxx:115
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
Muon::MuonTrackTruthTool::addClusterTruth
void addClusterTruth(MuonTechnologyTruth &trackTruth, const Identifier &id, const Trk::MeasurementBase &meas, const MuonSimDataCollection &simCol) const
Definition: MuonTrackTruthTool.cxx:591
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Muon::CompetingMuonClustersOnTrack
Definition: CompetingMuonClustersOnTrack.h:54
TrackRecordConstIterator
AtlasHitsVector< TrackRecord >::const_iterator TrackRecordConstIterator
Definition: TrackRecordCollection.h:14
MdtDriftCircleOnTrack.h
MuonTrackTruthTool.h
Muon::MuonTrackTruth::mms
MuonTechnologyTruth mms
Definition: IMuonTrackTruthTool.h:51
Muon::MuonTrackTruthTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonTrackTruthTool.h:141
Muon::IMuonTrackTruthTool::TruthTreeEntry::stgcHits
MuonSimDataCollection stgcHits
Definition: IMuonTrackTruthTool.h:82
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
Muon::MuonTechnologyTruth::missedHits
std::set< Identifier > missedHits
Definition: IMuonTrackTruthTool.h:34
GenParticle.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
Trk::RoT_Extractor::extract
static void extract(std::vector< const RIO_OnTrack * > &rots, const std::vector< const MeasurementBase * > &measurements)
AtlasHitsVector::empty
bool empty() const
Definition: AtlasHitsVector.h:129
Muon::MuonTrackTruth::mdts
MuonTechnologyTruth mdts
Definition: IMuonTrackTruthTool.h:46
Track.h
MuonGM::MuonDetectorManager::getTgcReadoutElement
const TgcReadoutElement * getTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:247
RoT_Extractor.h
inspect_truth_file.truth_tree
truth_tree
Definition: inspect_truth_file.py:75
Trk::PseudoMeasurementOnTrack
Class to handle pseudo-measurements in fitters and on track objects.
Definition: PseudoMeasurementOnTrack.h:44
TileDCSDataPlotter.tit
tit
Definition: TileDCSDataPlotter.py:890
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Muon::IMuonTrackTruthTool::MatchResult
std::pair< const Trk::Track *, MuonTrackTruth > MatchResult
Definition: IMuonTrackTruthTool.h:86
Muon::MuonTrackTruthTool::getMother
HepMC::ConstGenParticlePtr getMother(const TruthTrajectory &traj, const int barcodeIn) const
Returns the mother particle of the particle with barcodeIn if it is found in the truth trajectory.
Definition: MuonTrackTruthTool.cxx:667
MuonGM::MuonDetectorManager::getMdtReadoutElement
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:204
HepMC::barcode_to_particle
GenParticle * barcode_to_particle(const GenEvent *e, int id)
Definition: GenEvent.h:506
Muon::IMuonTrackTruthTool::TruthTreeEntry::tgcHits
MuonSimDataCollection tgcHits
Definition: IMuonTrackTruthTool.h:81
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
Muon::MuonTrackTruthTool::SortResultByMatchedHits
Definition: MuonTrackTruthTool.h:49
MuonSimDataCollection
Definition: MuonSimDataCollection.h:21
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
Muon::MuonTrackTruthTool::m_manipulateBarCode
Gaudi::Property< bool > m_manipulateBarCode
Definition: MuonTrackTruthTool.h:147
PseudoMeasurementOnTrack.h
Muon::MuonTechnologyTruth::matchedChambers
std::set< Identifier > matchedChambers
Definition: IMuonTrackTruthTool.h:33
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CscSimDataCollection
Definition: CscSimDataCollection.h:29
Muon::MuonTrackTruthTool::getTruth
MuonTrackTruth getTruth(const TruthTree &truth_tree, const Trk::Track &track, bool restrictedTruth=false) const
get track truth
Definition: MuonTrackTruthTool.cxx:392
Muon::MdtDriftCircleOnTrack::driftRadius
double driftRadius() const
Returns the value of the drift radius.
Definition: MdtDriftCircleOnTrack.h:277
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
Muon::MuonTrackTruthTool::initialize
StatusCode initialize()
AlgTool initilize.
Definition: MuonTrackTruthTool.cxx:30
DataVector< Trk::Track >
Muon::MuonTrackTruthTool::m_truthTrajectoryBuilder
ToolHandle< Trk::ITruthTrajectoryBuilder > m_truthTrajectoryBuilder
Definition: MuonTrackTruthTool.h:144
Muon::IMuonTrackTruthTool::TruthTreeEntry::truthTrajectory
std::shared_ptr< const TruthTrajectory > truthTrajectory
Definition: IMuonTrackTruthTool.h:77
Muon::MuonTrackTruthTool::m_matchAllParticles
Gaudi::Property< bool > m_matchAllParticles
Definition: MuonTrackTruthTool.h:149
Muon::MuonTrackTruthTool::addSimDataToTree
void addSimDataToTree(TruthTree &truth_tree, std::map< int, int > &barcode_map, const MuonSimDataCollection *simDataCol) const
Definition: MuonTrackTruthTool.cxx:271
Muon::IMuonTrackTruthTool::TruthTreeConstIt
TruthTree::const_iterator TruthTreeConstIt
Definition: IMuonTrackTruthTool.h:95
Muon::MuonTrackTruthTool::m_detMgr
const MuonGM::MuonDetectorManager * m_detMgr
Definition: MuonTrackTruthTool.h:139
Muon::MuonTechnologyTruth::missedChambers
std::set< Identifier > missedChambers
Definition: IMuonTrackTruthTool.h:35
Trk::PrepRawData
Definition: PrepRawData.h:62
Trk::MeasurementBase
Definition: MeasurementBase.h:58
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
Muon::CompetingMuonClustersOnTrack::numberOfContainedROTs
unsigned int numberOfContainedROTs() const
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
Definition: CompetingMuonClustersOnTrack.h:178
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
TruthTrajectory
Definition: TruthTrajectory.h:26
Muon::MuonTrackTruthTool::m_pdgsToBeConsidered
Gaudi::Property< std::vector< int > > m_pdgsToBeConsidered
Definition: MuonTrackTruthTool.h:151
Muon::MuonTrackTruth::tgcs
MuonTechnologyTruth tgcs
Definition: IMuonTrackTruthTool.h:49
pmontree.code
code
Definition: pmontree.py:443
Muon::IMuonTrackTruthTool::TruthTreeEntry::rpcHits
MuonSimDataCollection rpcHits
Definition: IMuonTrackTruthTool.h:80
Muon::MuonTrackTruthTool::m_minHits
Gaudi::Property< unsigned int > m_minHits
Definition: MuonTrackTruthTool.h:150
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
Muon::MdtDriftCircleOnTrack
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
Definition: MdtDriftCircleOnTrack.h:37
Muon::MuonTrackTruthTool::selectPdg
bool selectPdg(int pdg) const
Definition: MuonTrackTruthTool.h:132
Muon::IMuonTrackTruthTool::SegmentResultVec
std::vector< SegmentMatchResult > SegmentResultVec
Definition: IMuonTrackTruthTool.h:90
Muon::MuonTrackTruthTool::addMissedHits
void addMissedHits(MuonTechnologyTruth &truth, const std::set< Identifier > &ids, const std::set< Identifier > &chids, const MuonSimDataCollection &simCol, bool restrictedTruth) const
Definition: MuonTrackTruthTool.cxx:500
Muon::MuonTrackTruthTool::manipulateBarCode
int manipulateBarCode(int barcode) const
Definition: MuonTrackTruthTool.cxx:49
Trk::RIO_OnTrack::prepRawData
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
MuonDetectorManager.h
Muon::MuonTrackTruthTool::getInitialPair
const std::pair< HepMC::ConstGenParticlePtr, unsigned int > getInitialPair(const TruthTrajectory &traj, const int barcodeIn) const
Returns the initial particle of the particle with barcodeIn if it is found in the truth trajectory.
Definition: MuonTrackTruthTool.cxx:708
Muon::IMuonTrackTruthTool::TruthTreeEntry
Definition: IMuonTrackTruthTool.h:75
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
Muon::IMuonTrackTruthTool::TruthTree
std::map< int, TruthTreeEntry > TruthTree
Definition: IMuonTrackTruthTool.h:93
Muon::MuonTechnologyTruth::wrongChambers
std::set< Identifier > wrongChambers
Definition: IMuonTrackTruthTool.h:37
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
Muon::IMuonTrackTruthTool::TruthTreeEntry::mdtHits
MuonSimDataCollection mdtHits
Definition: IMuonTrackTruthTool.h:78
Muon::CompetingMuonClustersOnTrack::rioOnTrack
const MuonClusterOnTrack & rioOnTrack(unsigned int) const
returns the RIO_OnTrack (also known as ROT) objects depending on the integer
Definition: CompetingMuonClustersOnTrack.h:190
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
Muon::MuonStationIndex::BO
@ BO
Definition: MuonStationIndex.h:25
Muon::MuonTrackTruthTool::match
ResultVec match(const TruthTree &truth_tree, const TrackCollection &tracks) const
perform truth matching for a given set of tracks
Definition: MuonTrackTruthTool.cxx:73
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Muon::MuonTrackTruthTool::m_doSummary
Gaudi::Property< bool > m_doSummary
Definition: MuonTrackTruthTool.h:148
MuonGM::MuonDetectorManager::getMMReadoutElement
const MMReadoutElement * getMMReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:255
DEBUG
#define DEBUG
Definition: page_access.h:11
Trk::RIO_OnTrack::identify
virtual Identifier identify() const final
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:155
Muon::IMuonTrackTruthTool::SegmentMatchResult
std::pair< const Muon::MuonSegment *, MuonTrackTruth > SegmentMatchResult
Definition: IMuonTrackTruthTool.h:89
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:143
MuonSegment.h
Muon::MuonTrackTruthTool::getNumberOfScatters
unsigned int getNumberOfScatters(const TruthTrajectory &traj, const int barcodeIn) const
Returns the number of steps a particle took while maintaining its PDG ID.
Definition: MuonTrackTruthTool.cxx:772
TruthTrajectory.h
Muon::IMuonTrackTruthTool::ResultVec
std::vector< MatchResult > ResultVec
Definition: IMuonTrackTruthTool.h:87
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
MuonGM::MuonDetectorManager::getsTgcReadoutElement
const sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:259
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
AthAlgTool
Definition: AthAlgTool.h:26
Muon::MuonTrackTruth::rpcs
MuonTechnologyTruth rpcs
Definition: IMuonTrackTruthTool.h:48
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Muon::MuonTrackTruth::numberOfMatchedHits
unsigned int numberOfMatchedHits() const
Definition: IMuonTrackTruthTool.h:52
Muon::MuonTrackTruth::cscs
MuonTechnologyTruth cscs
Definition: IMuonTrackTruthTool.h:47
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
Muon::MuonTrackTruthTool::addCscSimDataToTree
void addCscSimDataToTree(TruthTree &truth_tree, std::map< int, int > &barcode_map, const CscSimDataCollection *simDataCol) const
Definition: MuonTrackTruthTool.cxx:350
HepMCHelpers.h
Muon::IMuonTrackTruthTool::TruthTreeEntry::truthTrack
const TrackRecord * truthTrack
Definition: IMuonTrackTruthTool.h:76
Muon::MuonClusterOnTrack
Base class for Muon cluster RIO_OnTracks.
Definition: MuonClusterOnTrack.h:34
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
MuonSimData.h
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
Muon::MuonTrackTruthTool::addMdtTruth
void addMdtTruth(MuonTechnologyTruth &trackTruth, const Identifier &id, const Trk::MeasurementBase &meas, const MuonSimDataCollection &simCol) const
Definition: MuonTrackTruthTool.cxx:556
Muon::MuonTrackTruth::truthTrack
const TrackRecord * truthTrack
Definition: IMuonTrackTruthTool.h:42