ATLAS Offline Software
MuonHoughTransformTester.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "GaudiKernel/SystemOfUnits.h"
14 #include "Acts/Utilities/Enumerate.hpp"
15 #include "GaudiKernel/PhysicalConstants.h"
16 
18 
19 
20 namespace {
21  constexpr double c_inv = 1. /Gaudi::Units::c_light;
22 }
23 
24 
25 namespace MuonValR4 {
26  using namespace MuonR4;
27  using namespace MuonVal;
29  using simHitSet = std::unordered_set<const xAOD::MuonSimHit*>;
30  unsigned int countMatched(const simHitSet& truthHits,
31  const simHitSet& recoHits) {
32  unsigned int matched{0};
33  for (const xAOD::MuonSimHit* reco : recoHits) {
34  matched += truthHits.count(reco);
35  }
36  return matched;
37  }
38  unsigned int countMatched(const xAOD::MuonSegment* truthSeg,
39  const MuonR4::SegmentSeed* seed) {
40  return truthSeg ? countMatched(getMatchingSimHits(*truthSeg), getMatchingSimHits(*seed)) : 0;
41  }
42  unsigned int countMatched(const xAOD::MuonSegment* truthSeg,
43  const MuonR4::Segment* segment) {
44  return truthSeg ? countMatched(getMatchingSimHits(*truthSeg), getMatchingSimHits(*segment)) : 0;
45  }
47  template <class SpType>
48  bool isPrecHit(const SpType& sp) {
49  return sp.type() == xAOD::UncalibMeasType::MdtDriftCircleType ||
51  (sp.type() == xAOD::UncalibMeasType::sTgcStripType && sp.measuresEta());
52  }
53 
55  ATH_CHECK(m_geoCtxKey.initialize());
56 
57  {
58  int infoOpts = 0;
59  if (m_isMC) infoOpts = EventInfoBranch::isMC;
60  m_tree.addBranch(std::make_unique<EventInfoBranch>(m_tree, infoOpts));
61  }
62 
63  ATH_CHECK(m_truthSegmentKey.initialize(!m_truthSegmentKey.empty()));
65  ATH_CHECK(m_inSegmentKeys.initialize());
66  ATH_CHECK(m_inHoughSegmentSeedKeys.initialize());
67  ATH_CHECK(m_spKey.initialize(m_writeSpacePoints));
68  if (m_writeSpacePoints) {
69  m_spTester = std::make_unique<SpacePointTesterModule>(m_tree, m_spKey.key(), msgLevel());
70  m_tree.addBranch(m_spTester);
71  } else {
72  m_tree.disableBranch(m_spMatchedToPattern.name());
73  m_tree.disableBranch(m_spMatchedToSegment.name());
74  }
75  ATH_CHECK(m_tree.init(this));
76  ATH_CHECK(m_idHelperSvc.retrieve());
77  ATH_CHECK(detStore()->retrieve(m_detMgr));
78 
79  ATH_CHECK(m_visionTool.retrieve(EnableTool{!m_visionTool.empty()}));
80  ATH_MSG_DEBUG("Succesfully initialised");
81  return StatusCode::SUCCESS;
82  }
83 
84 
86  const xAOD::MuonSegment& truthSeg,
87  const MuonR4::Segment& recoSeg) const{
88  unsigned int same{0};
89  using namespace SegmentFit;
90  const auto[truePos, trueDir] = makeLine(localSegmentPars(truthSeg));
91  const auto[recoPos, recoDir] = makeLine(localSegmentPars(gctx, recoSeg));
92  const std::vector<int> truthSigns = SeedingAux::strawSigns(truePos, trueDir, recoSeg.measurements());
93  const std::vector<int> recoSigns = SeedingAux::strawSigns(recoPos, recoDir, recoSeg.measurements());
94  for (unsigned int s = 0 ; s < truthSigns.size(); ++s) {
95  same += (truthSigns[s] != 0) && truthSigns[s] == recoSigns[s];
96  }
97  return same;
98  }
99  std::vector<ObjectMatching>
101  const xAOD::MuonSegmentContainer* truthSegments,
102  const SegmentSeedContainer* seedContainer,
103  const SegmentContainer* segmentContainer) const {
104  std::vector<ObjectMatching> allAssociations{};
105  std::unordered_set<const SegmentSeed*> usedSeeds{};
106  std::unordered_set<const Segment*> usedSegs{};
107 
110  if (m_isMC) {
111  // collect the sim hits that contributed to our segments and seeds.
112  std::vector<simHitSet> truthHitsVec{}, seedSimHitVec{}, segmentSimHitVec{};
113  for (const SegmentSeed* seed: *seedContainer) {
114  seedSimHitVec.emplace_back(getMatchingSimHits(*seed));
115  }
116  for (const Segment* segment: *segmentContainer){
117  segmentSimHitVec.emplace_back(getMatchingSimHits(*segment));
118  }
119 
120  // Now look at the truth segments, collecting their sim hits.
121  // Compare these to the sim hits on our reco objects
122  for (const xAOD::MuonSegment* truth: *truthSegments) {
123  const simHitSet& truthHits{truthHitsVec.emplace_back(getMatchingSimHits(*truth))};
124  ObjectMatching & matchedWithTruth = allAssociations.emplace_back();
125  matchedWithTruth.truthSegment = truth;
126  matchedWithTruth.chamber = m_detMgr->getSectorEnvelope((*truthHits.begin())->identify());
127 
128  std::vector<std::pair<const SegmentSeed*, unsigned>> matchedSeeds{};
129 
130  // Find seeds sharing at least one simHit with our truth segment
131  // can't wait for views::enumerate
132  int seedIdx{-1};
133  for (const SegmentSeed* seed : *seedContainer) {
134  ++seedIdx;
135  if (seed->msSector() != matchedWithTruth.chamber) {
136  continue;
137  }
138  const simHitSet& seedHits{seedSimHitVec[seedIdx]};
139  unsigned int matchedHits = countMatched(truthHits, seedHits);
140  if (!matchedHits) {
141  continue;
142  }
143  matchedSeeds.emplace_back(std::make_pair(seed, matchedHits));
144  }
145  // Find segments sharing at least one simHit with our truth segment
146  std::vector<std::pair<const Segment*, unsigned>> matchedSegs{};
147  int segmentIdx{-1};
148  for (const Segment* segment : *segmentContainer) {
149  ++segmentIdx;
150  if (segment->msSector() != matchedWithTruth.chamber) {
151  continue;
152  }
153  const simHitSet& segmentHits{segmentSimHitVec[segmentIdx]};
154  unsigned int matchedHits = countMatched(truthHits, segmentHits);
155  if (!matchedHits) {
156  continue;
157  }
158  matchedSegs.emplace_back(std::make_pair(segment,matchedHits));
159  }
160 
161  // sort by quality of match
162 
163  // for segments (by hit count and same-side hits)
164  std::ranges::sort(matchedSegs,
165  [this, &truth, &gctx](const std::pair<const Segment*, unsigned>& segA,
166  const std::pair<const Segment*, unsigned>& segB){
167  if (segA.second != segB.second) return segA.second > segB.second;
168  return countOnSameSide(gctx, *truth, *segA.first) > countOnSameSide(gctx, *truth, *segB.first);
169  });
170  // and for seeds (by raw hit count)
171  std::ranges::sort(matchedSeeds, [](const std::pair<const SegmentSeed*, unsigned>& seedA,
172  const std::pair<const SegmentSeed*, unsigned>& seedB) {
173  return seedA.second > seedB.second;
174  });
175 
176 
177  // now we can populate our association object
178 
179  // first, we handle the segments and any seeds connected with them
180  for (const auto& [matched, nMatchedHits] : matchedSegs) {
181  // add segment to the list of all segments
182  matchedWithTruth.matchedSegments.push_back(matched);
183  // and update our book-keeping to record that this segment and its seed have already been written
184  usedSeeds.insert(matched->parent());
185  usedSegs.insert(matched);
186  }
187 
188  // now, we add the seeds
189  for (const auto& [seed , nHits] : matchedSeeds) {
190  // add seed to the list of all seeds
191  ATH_MSG_VERBOSE("Seed with "<<nHits);
192  matchedWithTruth.matchedSeeds.push_back(seed);
193  matchedWithTruth.matchedSeedFoundSegment.push_back(usedSeeds.count(seed));
194  usedSeeds.insert(seed);
195  }
196  } // end of loop over truth segments
197  }
198 
202 
203  // start with segments, and also collect "their" seeds in a common entry
204  for (const Segment* seg: *segmentContainer) {
205  // skip segments that were previously seen and written in the truth loop
206  if (usedSegs.count(seg)) {
207  continue;
208  }
209  ObjectMatching & match = allAssociations.emplace_back();
210  match.chamber = seg->msSector();
211  match.matchedSegments = {seg};
212  match.matchedSeeds = {seg->parent()};
213  // this seed has been written as well - do not write it in the following loop
214  usedSeeds.insert(seg->parent());
215  match.matchedSeedFoundSegment.push_back(1);
216  }
217  for (const SegmentSeed* seed: *seedContainer) {
218  // skip seeds that are on segments or seen in the truth loop so these will be seeds without segment
219  if (usedSeeds.count(seed)) {
220  continue;
221  }
222  ObjectMatching & match = allAssociations.emplace_back();
223  match.chamber = seed->msSector();
224  match.matchedSeeds = {seed};
225  match.matchedSeedFoundSegment.push_back(0);
226  }
227  return allAssociations;
228  }
229 
231  ATH_CHECK(m_tree.write());
232  return StatusCode::SUCCESS;
233  }
235 
236  const EventContext & ctx = Gaudi::Hive::currentContext();
237  const ActsTrk::GeometryContext* gctxPtr{nullptr};
238  ATH_CHECK(SG::get(gctxPtr, m_geoCtxKey, ctx));
239  const ActsTrk::GeometryContext& gctx{*gctxPtr};
240 
241 
244 
245  for (const SG::ReadHandleKey<SegmentSeedContainer>& key : m_inHoughSegmentSeedKeys) {
246  const SegmentSeedContainer* readSegmentSeeds{nullptr};
247  ATH_CHECK(SG::get(readSegmentSeeds, key, ctx));
248  segmentSeeds.insert(segmentSeeds.end(),readSegmentSeeds->begin(), readSegmentSeeds->end());
249  }
250  for (const SG::ReadHandleKey<SegmentContainer>& key : m_inSegmentKeys) {
251  const SegmentContainer* readSegments{nullptr};
252  ATH_CHECK(SG::get(readSegments, key, ctx));
253  segments.insert(segments.end(),readSegments->begin(), readSegments->end());
254  }
255  const xAOD::MuonSegmentContainer* readTruthSegments{nullptr};
256 
257  if(m_isMC){
258  ATH_CHECK(SG::get(readTruthSegments , m_truthSegmentKey, ctx));
259  }
260 
261  ATH_MSG_DEBUG("Succesfully retrieved input collections. Seeds: "<<segmentSeeds.size()
262  <<", segments: "<<segments.size() <<", truth segments: "<<(readTruthSegments? readTruthSegments->size() : -1)<<".");
263  std::vector<ObjectMatching> objects = matchWithTruth(gctx, readTruthSegments, segmentSeeds.asDataVector(),
264  segments.asDataVector());
265  for (const ObjectMatching& obj : objects) {
266  fillChamberInfo(obj.chamber);
267  fillSeedInfo(obj);
268  fillSegmentInfo(gctx, obj);
269  if(m_isMC) fillTruthInfo(gctx, obj.truthSegment);
270  ATH_CHECK(m_tree.fill(ctx));
271  }
272  return StatusCode::SUCCESS;
273  }
275  m_out_chamberIndex = Acts::toUnderlying(msSector->chamberIndex());
276  m_out_stationSide = msSector->side();
277  m_out_stationPhi = msSector->stationPhi();
278  }
280  const xAOD::MuonSegment* segment) {
281  if (!segment) return;
282  m_out_hasTruth = true;
283 
284  const Amg::Vector3D segDir{segment->direction()};
285  static const SG::Accessor<float> acc_pt{"pt"};
286  static const SG::Accessor<float> acc_charge{"charge"};
287  // eta is interpreted as the eta-location
288  m_out_gen_Eta = segDir.eta();
289  m_out_gen_Phi = segDir.phi();
290  m_out_gen_Pt = acc_pt(*segment);
291  m_out_gen_Q = acc_charge(*segment);
292 
293  const auto [chamberPos, chamberDir] = SegmentFit::makeLine(SegmentFit::localSegmentPars(*segment));
294  m_out_gen_nHits = segment->nPrecisionHits()+segment->nPhiLayers() + segment->nTrigEtaLayers();
295  using namespace Muon::MuonStationIndex;
296  m_out_gen_nMDTHits = segment->nPrecisionHits() * (segment->technology() == TechnologyIndex::MDT);
297  m_out_gen_nNswHits = segment->nPrecisionHits() * (segment->technology() != TechnologyIndex::MDT);
298  m_out_gen_nTGCHits = (segment->nPhiLayers() + segment->nTrigEtaLayers()) * !isBarrel(segment->chamberIndex());
299  m_out_gen_nRPCHits = (segment->nPhiLayers() + segment->nTrigEtaLayers()) * isBarrel(segment->chamberIndex());
300 
301  m_out_gen_tantheta = houghTanBeta(chamberDir);
302  m_out_gen_tanphi = houghTanAlpha(chamberDir);
303  m_out_gen_y0 = chamberPos.y();
304  m_out_gen_x0 = chamberPos.x();
305  m_out_gen_time = segment->t0();
306 
307  double minYhit = std::numeric_limits<double>::max();
308  double maxYhit = -1 * std::numeric_limits<double>::max();
309  for (const xAOD::MuonSimHit* hit : getMatchingSimHits(*segment)){
310  const Identifier hitId = hit->identify();
311  const MuonGMR4::MuonReadoutElement* RE = m_detMgr->getReadoutElement(hitId);
312  const IdentifierHash hash{m_idHelperSvc->isMdt(hitId) ? RE->measurementHash(hitId)
313  : RE->layerHash(hitId) };
314  const Amg::Transform3D localToChamber = RE->msSector()->globalToLocalTrans(gctx) * RE->localToGlobalTrans(gctx, hash);
315  const Amg::Vector3D chamberPos = localToChamber * xAOD::toEigen(hit->localPosition());
316  minYhit = std::min(chamberPos.y(), minYhit);
317  maxYhit = std::max(chamberPos.y(), maxYhit);
318  }
319  m_out_gen_minYhit = minYhit;
320  m_out_gen_maxYhit = maxYhit;
321 
322  ATH_MSG_DEBUG("A true max on chamber index "<<m_out_chamberIndex.getVariable()<<" side "<<m_out_stationSide.getVariable()<<" phi "<<m_out_stationPhi.getVariable()<<" with "
323  <<m_out_gen_nMDTHits.getVariable()<<" MDT and "<<m_out_gen_nRPCHits.getVariable()+m_out_gen_nTGCHits.getVariable()<< " trigger hits is at "
324  <<m_out_gen_tantheta.getVariable()<<" and "<<m_out_gen_y0.getVariable());
325  }
327  m_out_bucketEnd = bucket.coveredMax();
328  m_out_bucketStart = bucket.coveredMin();
329  m_out_nSpacePoints = bucket.size();
330  m_out_nPrecSpacePoints = std::ranges::count_if(bucket, [](const SpacePointBucket::value_type& sp){
331  return isPrecHit(*sp);
332  });
333  m_out_nPhiSpacePoints = std::ranges::count_if(bucket, [](const SpacePointBucket::value_type& sp){
334  return sp->measuresPhi();
335  });
336  if (!m_visionTool.isEnabled()){
337  return;
338  }
339  m_out_nTrueSpacePoints = std::ranges::count_if(bucket,[this](const SpacePointBucket::value_type& sp){
340  return m_visionTool->isLabeled(*sp);
341  });
342  m_out_nTruePrecSpacePoints = std::ranges::count_if(bucket,[this](const SpacePointBucket::value_type& sp){
343  return isPrecHit(*sp) && m_visionTool->isLabeled(*sp);
344  });
345  m_out_nTruePhiSpacePoints = std::ranges::count_if(bucket,[this](const SpacePointBucket::value_type& sp){
346  return sp->measuresPhi() && m_visionTool->isLabeled(*sp);
347  });
348  }
350 
351  m_out_seed_n = obj.matchedSeeds.size();
352  for (const auto [iseed, seed] : Acts::enumerate(obj.matchedSeeds)){
353  if (iseed ==0) {
354  fillBucketInfo(*seed->parentBucket());
355  }
356  double minYhit = m_out_bucketEnd.getVariable();
357  double maxYhit = m_out_bucketStart.getVariable();
358  for (const SpacePoint* hit : seed->getHitsInMax()){
359  minYhit = std::min(hit->localPosition().y(),minYhit);
360  maxYhit = std::max(hit->localPosition().y(),maxYhit);
361  }
362  m_out_seed_minYhit.push_back(minYhit);
363  m_out_seed_maxYhit.push_back(maxYhit);
364 
365  m_out_seed_hasPhiExtension.push_back(seed->hasPhiExtension());
366  m_out_seed_nMatchedHits.push_back(countMatched(obj.truthSegment, seed));
367  m_out_seed_y0.push_back(seed->interceptY());
368  m_out_seed_tantheta.push_back(seed->tanBeta());
369  if (seed->hasPhiExtension()){
370  m_out_seed_x0.push_back(seed->interceptX());
371  m_out_seed_tanphi.push_back(seed->tanAlpha());
372  } else{
373  m_out_seed_x0.push_back(-999);
374  m_out_seed_tanphi.push_back(-999);
375  }
376 
377  m_out_seed_nHits.push_back(seed->getHitsInMax().size());
378  unsigned nMdtSeed{0}, nRpcSeed{0}, nTgcSeed{0}, nMmSeed{0}, nsTgcSeed{0};
379  unsigned nPrecHits{0}, nEtaHits{0}, nPhiHits{0}, nTrueHits{0}, nTruePrecHits{0}, nTrueEtaHits{0}, nTruePhiHits{0};
380  std::vector<unsigned char> treeIdxs{};
381 
382  for (const HoughHitType & houghSP: seed->getHitsInMax()){
383  if (m_writeSpacePoints){
384  unsigned treeIdx = m_spTester->push_back(*houghSP);
385  treeIdxs.push_back(treeIdx);
386  }
387  nPrecHits += isPrecHit(*houghSP);
388  nPhiHits += houghSP->measuresPhi();
389  nEtaHits += houghSP->measuresEta();
390 
391  if (m_visionTool.isEnabled()) {
392  nTrueHits += m_visionTool->isLabeled(*houghSP);
393  nTruePrecHits += m_visionTool->isLabeled(*houghSP) && isPrecHit(*houghSP);
394  nTruePhiHits += m_visionTool->isLabeled(*houghSP) && houghSP->measuresPhi();
395  nTrueEtaHits += m_visionTool->isLabeled(*houghSP) && houghSP->measuresEta();
396  }
397  switch (houghSP->type()) {
399  ++nMdtSeed;
400  break;
402  nRpcSeed+=houghSP->measuresEta();
403  nRpcSeed+=houghSP->measuresPhi();
404  break;
406  nTgcSeed+=houghSP->measuresEta();
407  nTgcSeed+=houghSP->measuresPhi();
408  break;
410  nsTgcSeed += houghSP->measuresEta();
411  nsTgcSeed += houghSP->measuresPhi();
412  break;
414  ++nMmSeed;
415  break;
416  default:
417  ATH_MSG_WARNING("Technology "<<houghSP->identify() <<" not yet implemented");
418  }
419  }
420  m_out_seed_nMdt.push_back(nMdtSeed);
421  m_out_seed_nRpc.push_back(nRpcSeed);
422  m_out_seed_nTgc.push_back(nTgcSeed);
423  m_out_seed_nsTgc.push_back(nsTgcSeed);
424  m_out_seed_nMm.push_back(nMmSeed);
425 
426  m_out_seed_nPrecHits.push_back(nPrecHits);
427  m_out_seed_nEtaHits.push_back(nEtaHits);
428  m_out_seed_nPhiHits.push_back(nPhiHits);
429 
430  m_out_seed_nTrueHits.push_back(nTrueHits);
431  m_out_seed_nTruePrecHits.push_back(nTruePrecHits);
432  m_out_seed_nTrueEtaHits.push_back(nTrueEtaHits);
433  m_out_seed_nTruePhiHits.push_back(nTruePhiHits);
434 
435  m_out_seed_ledToSegment.push_back(obj.matchedSeedFoundSegment.at(iseed));
436  if (m_writeSpacePoints) {
437  m_spMatchedToPattern[iseed] = std::move(treeIdxs);
438 
439  }
440  }
441  }
442 
444  const ObjectMatching& obj){
445  using namespace SegmentFit;
446 
447  m_out_segment_n = obj.matchedSegments.size();
448  for (auto & segment : obj.matchedSegments){
449  m_out_segment_hasPhi.push_back(std::ranges::find_if(segment->measurements(), [](const auto& meas){ return meas->measuresPhi();})
450  !=segment->measurements().end());
451  m_out_segment_fitIter.push_back(segment->nFitIterations());
452  m_out_segment_truthMatchedHits.push_back(countMatched(obj.truthSegment, segment));
453  m_out_segment_chi2.push_back(segment->chi2());
454  m_out_segment_nDoF.push_back(segment->nDoF());
455  m_out_segment_hasTimeFit.push_back(segment->hasTimeFit());
456 
457  m_out_segment_err_x0.push_back(segment->covariance()(Acts::toUnderlying(ParamDefs::x0), Acts::toUnderlying(ParamDefs::x0)));
458  m_out_segment_err_y0.push_back(segment->covariance()(Acts::toUnderlying(ParamDefs::y0), Acts::toUnderlying(ParamDefs::y0)));
459  m_out_segment_err_tantheta.push_back(segment->covariance()(Acts::toUnderlying(ParamDefs::theta), Acts::toUnderlying(ParamDefs::theta)));
460  m_out_segment_err_tanphi.push_back(segment->covariance()(Acts::toUnderlying(ParamDefs::phi), Acts::toUnderlying(ParamDefs::phi)));
461  m_out_segment_err_time.push_back(segment->covariance()(Acts::toUnderlying(ParamDefs::t0), Acts::toUnderlying(ParamDefs::t0)));
462  const auto [locPos, locDir] = makeLine(localSegmentPars(gctx, *segment));
463  m_out_segment_tanphi.push_back(houghTanAlpha(locDir));
464  m_out_segment_tantheta.push_back(houghTanBeta(locDir));
465  m_out_segment_y0.push_back(locPos.y());
466  m_out_segment_x0.push_back(locPos.x());
467  m_out_segment_time.push_back(segment->segementT0() + segment->position().mag() * c_inv);
468 
469  unsigned nMdtHits{0}, nRpcEtaHits{0}, nRpcPhiHits{0}, nTgcEtaHits{0}, nTgcPhiHits{0},
470  nMmEtaHits{0}, nMmStereoHits{0}, nStgcStripHits{0},nStgcWireHits{0}, nStgcPadHits{0};
471  unsigned nTrueHits{0}, nTruePrecHits{0}, nTrueEtaHits{0}, nTruePhiHits{0};
472 
473  double minYhit = std::numeric_limits<double>::max();
474  double maxYhit = -1 * std::numeric_limits<double>::max();
475 
476  std::vector<unsigned char> matched;
477  for (const auto & meas : segment->measurements()){
478  // skip dummy measurement from beam spot constraint
479  if (meas->type() == xAOD::UncalibMeasType::Other) continue;
480  minYhit = std::min(meas->localPosition().y(),minYhit);
481  maxYhit = std::max(meas->localPosition().y(),maxYhit);
482  if (m_writeSpacePoints) {
483  unsigned treeIdx = m_spTester->push_back(*meas->spacePoint());
484  if (treeIdx >= matched.size()){
485  matched.resize(treeIdx +1);
486  }
487  matched[treeIdx] = true;
488  }
489  if (m_visionTool.isEnabled()) {
490  nTrueHits += m_visionTool->isLabeled(*meas->spacePoint());
491  nTruePrecHits += isPrecHit(*meas) && m_visionTool->isLabeled(*meas->spacePoint());
492  nTrueEtaHits += meas->measuresEta() && m_visionTool->isLabeled(*meas->spacePoint());
493  nTruePhiHits += meas->measuresPhi() && m_visionTool->isLabeled(*meas->spacePoint());
494  }
495  switch (meas->type()) {
497  ++nMdtHits;
498  break;
500  nRpcEtaHits += meas->measuresEta();
501  nRpcPhiHits += meas->measuresPhi();
502  break;
504  nTgcEtaHits += meas->measuresEta();
505  nTgcPhiHits += meas->measuresPhi();
506  break;
508  const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
509  nMmEtaHits += !idHelper.isStereo(meas->spacePoint()->identify());
510  nMmStereoHits += !idHelper.isStereo(meas->spacePoint()->identify());
511  break;
513  const auto* prd = static_cast<const xAOD::sTgcMeasurement*>(meas->spacePoint()->primaryMeasurement());
514  nStgcStripHits += prd->channelType() == sTgcIdHelper::sTgcChannelTypes::Strip;
515  nStgcWireHits += prd->channelType() == sTgcIdHelper::sTgcChannelTypes::Wire;
516  nStgcPadHits += prd->channelType() == sTgcIdHelper::sTgcChannelTypes::Pad;
517  prd = dynamic_cast<const xAOD::sTgcMeasurement*>(meas->spacePoint()->secondaryMeasurement());
518  if (prd) {
519  nStgcWireHits += prd->channelType() == sTgcIdHelper::sTgcChannelTypes::Wire;
520  nStgcPadHits += prd->channelType() == sTgcIdHelper::sTgcChannelTypes::Pad;
521  }
522  break;
523  } default:
524  break;
525  }
526  }
527  m_out_segment_nMdtHits.push_back(nMdtHits);
528  m_out_segment_nRpcEtaHits.push_back(nRpcEtaHits);
529  m_out_segment_nRpcPhiHits.push_back(nRpcPhiHits);
530  m_out_segment_nTgcEtaHits.push_back(nTgcEtaHits);
531  m_out_segment_nTgcPhiHits.push_back(nTgcPhiHits);
532 
533  m_out_segment_nMmEtaHits.push_back(nMmEtaHits);
534  m_out_segment_nMmStereoHits.push_back(nMmStereoHits);
535  m_out_segment_nsTgcStripHits.push_back(nStgcStripHits);
536  m_out_segment_nsTgcWireHits.push_back(nStgcWireHits);
537  m_out_segment_nsTgcPadpHits.push_back(nStgcPadHits);
538 
539 
540  m_out_segment_nTrueHits.push_back(nTrueHits);
541  m_out_segment_nTruePrecHits.push_back(nTruePrecHits);
542  m_out_segment_nTruePhiHits.push_back(nTruePhiHits);
543  m_out_segment_nTrueEtaHits.push_back(nTrueEtaHits);
544 
545  m_out_segment_minYhit.push_back(minYhit);
546  m_out_segment_maxYhit.push_back(maxYhit);
547  if (m_writeSpacePoints) {
548  m_spMatchedToSegment.push_back(std::move(matched));
549  }
550  }
551  }
552 } // namespace MuonValR4
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
MuonValR4::MuonHoughTransformTester::fillSegmentInfo
void fillSegmentInfo(const ActsTrk::GeometryContext &gctx, const ObjectMatching &obj)
Fill the info assciated to the segment.
Definition: MuonHoughTransformTester.cxx:443
MuonSimHitHelpers.h
xAOD::MuonSimHit_v1
Definition: MuonSimHit_v1.h:18
UtilFunctions.h
MuonValR4::MuonHoughTransformTester::countOnSameSide
unsigned int countOnSameSide(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &truthSeg, const MuonR4::Segment &recoSeg) const
Calculates how many measurements from the segment fit have the same drift sign as when evaluated with...
Definition: MuonHoughTransformTester.cxx:85
MuonGMR4::SpectrometerSector::side
int8_t side() const
Returns the side of the MS-sector 1 -> A side ; -1 -> C side.
Definition: SpectrometerSector.cxx:57
MuonValR4::MuonHoughTransformTester::finalize
virtual StatusCode finalize() override
Definition: MuonHoughTransformTester.cxx:230
MuonGMR4::MuonReadoutElement::msSector
const SpectrometerSector * msSector() const
Returns the pointer to the envelope volume enclosing all chambers in the sector.
MuonValR4::countMatched
unsigned int countMatched(const simHitSet &truthHits, const simHitSet &recoHits)
Definition: MuonHoughTransformTester.cxx:30
MuonGMR4::SpectrometerSector
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
Definition: SpectrometerSector.h:40
LArConditions2Ntuple.objects
objects
Definition: LArConditions2Ntuple.py:64
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
xAOD::MuonSegment_v1::direction
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
Definition: MuonSegment_v1.cxx:18
MuonR4::SpacePointBucket
: The muon space point bucket represents a collection of points that will bre processed together in t...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:21
MuonGMR4::SpectrometerSector::stationPhi
int stationPhi() const
: Returns the station phi of the sector
Definition: SpectrometerSector.cxx:63
SG::Accessor< float >
Muon::MuonStationIndex
Definition: MuonStationIndex.h:13
MuonR4::SpacePointBucket::coveredMin
double coveredMin() const
lower interval value covered by the bucket
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:29
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
MuonVal::EventInfoBranch::isMC
@ isMC
Flag determining whether the branch is simulation.
Definition: EventInfoBranch.h:20
xAOD::MuonSegment_v1::nTrigEtaLayers
int nTrigEtaLayers() const
Returns the number of trigger eta layers.
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
MuonR4::Segment
Placeholder for what will later be the muon segment EDM representation.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:19
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
xAOD::UncalibMeasType::MMClusterType
@ MMClusterType
MuonR4::Segment::measurements
const MeasVec & measurements() const
Returns the associated measurements.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:49
MuonValR4::MuonHoughTransformTester::ObjectMatching
Definition: MuonHoughTransformTester.h:48
MuonGMR4::MuonReadoutElement
The MuonReadoutElement is an abstract class representing the geometry representing the muon detector.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonReadoutElement.h:38
HoughHelperFunctions.h
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
EventInfoBranch.h
MuonGMR4::MuonReadoutElement::layerHash
virtual IdentifierHash layerHash(const Identifier &measId) const =0
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
xAOD::UncalibMeasType::sTgcStripType
@ sTgcStripType
SpectrometerSector.h
MuonR4::SegmentFit::makeLine
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
Definition: SegmentFitterEventData.cxx:35
python.TrigEgammaFastCaloHypoTool.same
def same(val, tool)
Definition: TrigEgammaFastCaloHypoTool.py:10
Muon::MuonStationIndex::TechnologyIndex::MDT
@ MDT
MuonValR4::simHitSet
std::unordered_set< const xAOD::MuonSimHit * > simHitSet
Definition: MuonHoughTransformTester.cxx:29
MuonValR4::MuonHoughTransformTester::ObjectMatching::matchedSeedFoundSegment
std::vector< char > matchedSeedFoundSegment
Definition: MuonHoughTransformTester.h:57
xAOD::UncalibMeasType::TgcStripType
@ TgcStripType
MuonValR4::MuonHoughTransformTester::ObjectMatching::matchedSeeds
std::vector< const MuonR4::SegmentSeed * > matchedSeeds
All seeds matched to this object.
Definition: MuonHoughTransformTester.h:56
MuonR4::SpacePointBucket::coveredMax
double coveredMax() const
upper interval value covered by the bucket
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:31
MuonGMR4::SpectrometerSector::chamberIndex
Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index scheme.
Definition: SpectrometerSector.cxx:62
MuonR4::houghTanBeta
double houghTanBeta(const Amg::Vector3D &v)
Returns the hough tanBeta [y] / [z].
Definition: SegmentFitterEventData.cxx:26
xAOD::MuonSegment_v1::t0
float t0() const
xAOD::sTgcMeasurement_v1::channelType
virtual sTgcChannelTypes channelType() const =0
Returns the channel type of the measurement (Pad/Wire/Strip)
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
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
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonGMR4::MuonReadoutElement::localToGlobalTrans
const Amg::Transform3D & localToGlobalTrans(const ActsTrk::GeometryContext &ctx) const
Returns the local to global transformation into the ATLAS coordinate system.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonReadoutElement.cxx:81
xAOD::Other
@ Other
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonValR4::isPrecHit
bool isPrecHit(const SpType &sp)
Define a spacepoint as precision hit if it's a Mdt or NSW eta hit.
Definition: MuonHoughTransformTester.cxx:48
ActsTrk::GeometryContext
Definition: GeometryContext.h:28
xAOD::MuonSegment_v1::technology
::Muon::MuonStationIndex::TechnologyIndex technology() const
Returns the main technology of the segment.
MuonValR4::MuonHoughTransformTester::fillBucketInfo
void fillBucketInfo(const MuonR4::SpacePointBucket &bucket)
Fill the hit summary info of the associated bucket.
Definition: MuonHoughTransformTester.cxx:326
DataVector
Derived DataVector<T>.
Definition: DataVector.h:795
xAOD::MuonSegment_v1::nPhiLayers
int nPhiLayers() const
Returns the number of phi layers.
MuonR4::SpacePoint
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePoint.h:24
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: IPatternVisualizationTool.h:23
MuonValR4::MuonHoughTransformTester::ObjectMatching::truthSegment
const xAOD::MuonSegment * truthSegment
Truth segment for reference.
Definition: MuonHoughTransformTester.h:52
MuonGMR4::SpectrometerSector::globalToLocalTrans
Amg::Transform3D globalToLocalTrans(const ActsTrk::GeometryContext &gctx) const
Returns the global -> local transformation from the ATLAS global.
Definition: SpectrometerSector.cxx:78
MuonValR4::MuonHoughTransformTester::matchWithTruth
std::vector< ObjectMatching > matchWithTruth(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegmentContainer *truthSegments, const MuonR4::SegmentSeedContainer *seedContainer, const MuonR4::SegmentContainer *segmentContainer) const
Definition: MuonHoughTransformTester.cxx:100
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
xAOD::MuonSegment_v1::nPrecisionHits
int nPrecisionHits() const
MuonVal
Class to store array like branches into the n-tuples.
Definition: HitValAlg.cxx:19
MuonHoughDefs.h
sTgcMeasurement.h
MuonValR4::MuonHoughTransformTester::ObjectMatching::chamber
const MuonGMR4::SpectrometerSector * chamber
Associated chamber.
Definition: MuonHoughTransformTester.h:50
python.ElectronD3PDObject.matched
matched
Definition: ElectronD3PDObject.py:138
python.PhysicalConstants.c_light
float c_light
Definition: PhysicalConstants.py:73
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonValR4::MuonHoughTransformTester::initialize
virtual StatusCode initialize() override
Definition: MuonHoughTransformTester.cxx:54
python.copyTCTOutput.locDir
locDir
Definition: copyTCTOutput.py:110
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonValR4::MuonHoughTransformTester::execute
virtual StatusCode execute() override
Definition: MuonHoughTransformTester.cxx:234
MuonValR4::MuonHoughTransformTester::ObjectMatching::matchedSegments
std::vector< const MuonR4::Segment * > matchedSegments
All segments matched to this object.
Definition: MuonHoughTransformTester.h:54
MuonValR4::MuonHoughTransformTester::fillSeedInfo
void fillSeedInfo(const ObjectMatching &obj)
Fill the info associated to the seed.
Definition: MuonHoughTransformTester.cxx:349
MmIdHelper
Definition: MmIdHelper.h:54
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
MuonR4::SegmentSeed
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
Definition: SegmentSeed.h:14
MuonGMR4::MuonReadoutElement::measurementHash
virtual IdentifierHash measurementHash(const Identifier &measId) const =0
Constructs the identifier hash from the full measurement Identifier.
python.LArCondContChannels.isBarrel
isBarrel
Definition: LArCondContChannels.py:659
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
MuonHoughTransformTester.h
MuonR4::SegmentFit::localSegmentPars
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
Definition: SegmentFitterEventData.cxx:42
MuonValR4::MuonHoughTransformTester::fillChamberInfo
void fillChamberInfo(const MuonGMR4::SpectrometerSector *chamber)
Fill the current chamber info into the output.
Definition: MuonHoughTransformTester.cxx:274
python.PyAthena.obj
obj
Definition: PyAthena.py:132
MmIdHelper::isStereo
bool isStereo(const Identifier &id) const
Definition: MmIdHelper.cxx:849
MuonR4::houghTanAlpha
double houghTanAlpha(const Amg::Vector3D &v)
: Returns the hough tanAlpha [x] / [z]
Definition: SegmentFitterEventData.cxx:30
xAOD::UncalibMeasType::RpcStripType
@ RpcStripType
xAOD::UncalibMeasType::MdtDriftCircleType
@ MdtDriftCircleType
xAOD::MuonSegment_v1::chamberIndex
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
MuonR4::getMatchingSimHits
std::unordered_set< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment
Definition: MuonSimHitHelpers.cxx:38
MuonSegmentReaderConfig.reco
reco
Definition: MuonSegmentReaderConfig.py:133
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356
MuonValR4::ObjectMatching
MuonHoughTransformTester::ObjectMatching ObjectMatching
Definition: MuonHoughTransformTester.cxx:28
MuonValR4::MuonHoughTransformTester::fillTruthInfo
void fillTruthInfo(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment *truthSegment)
Fill the associated truth information into the tree.
Definition: MuonHoughTransformTester.cxx:279
xAOD::sTgcMeasurement_v1
Definition: sTgcMeasurement_v1.h:21
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Identifier
Definition: IdentifierFieldParser.cxx:14