EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrintHits.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PrintHits.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include "PrintHits.hpp"
10 
18 
19 #include <vector>
20 
23  : BareAlgorithm("PrintHits", level), m_cfg(cfg) {}
24 
26  const ActsExamples::AlgorithmContext& ctx) const {
29  using HitIds = std::vector<size_t>;
30 
31  const auto& clusters = ctx.eventStore.get<Clusters>(m_cfg.inputClusters);
32  const auto& hitParticlesMap =
33  ctx.eventStore.get<HitParticlesMap>(m_cfg.inputHitParticlesMap);
34  const auto& hitIds = ctx.eventStore.get<HitIds>(m_cfg.inputHitIds);
35 
36  // print hits selected by id
37  ACTS_INFO("Hits by id selection")
38  size_t hitIdEnd = m_cfg.hitIdStart + m_cfg.hitIdLength;
39  for (size_t ihit = m_cfg.hitIdStart; ihit < hitIdEnd; ++ihit) {
40  auto hitId = hitIds[ihit];
41  auto ic = clusters.nth(ihit);
42  if (ic == clusters.end()) {
43  break;
44  }
45  Acts::GeometryIdentifier geoId = ic->first;
46  const Acts::PlanarModuleCluster& c = ic->second;
47  ACTS_INFO(" Cluster " << ihit << " hitId " << hitId << " geoId " << geoId
48  << " size " << c.digitizationCells().size());
49  // get all contributing particles
50  for (const auto& p : makeRange(hitParticlesMap.equal_range(ihit))) {
51  ACTS_INFO(" generating particle " << p.first);
52  }
53  }
54 
55  // print hits within geometry selection
56  auto numVolume = selectVolume(clusters, m_cfg.volumeId).size();
57  auto numLayer = selectLayer(clusters, m_cfg.volumeId, m_cfg.layerId).size();
58  auto rangeModule =
59  selectModule(clusters, m_cfg.volumeId, m_cfg.layerId, m_cfg.moduleId);
60 
61  ACTS_INFO("Hits total: " << clusters.size());
62  ACTS_INFO("Hits in volume " << m_cfg.volumeId << ": " << numVolume);
63  ACTS_INFO("Hits in volume " << m_cfg.volumeId << " layer " << m_cfg.layerId
64  << ": " << numLayer);
65  ACTS_INFO("Hits in volume " << m_cfg.volumeId << " layer " << m_cfg.layerId
66  << " module " << m_cfg.moduleId << ": "
67  << rangeModule.size());
68  // we could also use for (const Acts::PlanarModuleCluster& c : rangeModule)
69  // for simplicity, but then we could not get the hit index.
70  ACTS_INFO("Hits by geometry selection")
71  for (auto ic = rangeModule.begin(); ic != rangeModule.end(); ++ic) {
72  auto ihit = clusters.index_of(ic);
73  auto hitId = hitIds[ihit];
74 
75  Acts::GeometryIdentifier geoId = ic->first;
76  const Acts::PlanarModuleCluster& c = ic->second;
77  ACTS_INFO(" Cluster " << ihit << " hitId " << hitId << " geoId " << geoId
78  << " size " << c.digitizationCells().size());
79  }
80 
81  return ProcessCode::SUCCESS;
82 }