ECCE @ 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 
11 #include <vector>
12 
20 
23  : BareAlgorithm("PrintHits", level), m_cfg(cfg) {}
24 
27  using HitParticlesMap = FW::IndexMultimap<ActsFatras::Barcode>;
28  using HitIds = std::vector<size_t>;
29 
30  const auto& clusters = ctx.eventStore.get<Clusters>(m_cfg.inputClusters);
31  const auto& hitParticlesMap =
32  ctx.eventStore.get<HitParticlesMap>(m_cfg.inputHitParticlesMap);
33  const auto& hitIds = ctx.eventStore.get<HitIds>(m_cfg.inputHitIds);
34 
35  // print hits selected by id
36  ACTS_INFO("Hits by id selection")
37  size_t hitIdEnd = m_cfg.hitIdStart + m_cfg.hitIdLength;
38  for (size_t ihit = m_cfg.hitIdStart; ihit < hitIdEnd; ++ihit) {
39  auto hitId = hitIds[ihit];
40  auto ic = clusters.nth(ihit);
41  if (ic == clusters.end()) {
42  break;
43  }
44  Acts::GeometryID geoId = ic->first;
45  const Acts::PlanarModuleCluster& c = ic->second;
46  ACTS_INFO(" Cluster " << ihit << " hitId " << hitId << " geoId " << geoId
47  << " size " << c.digitizationCells().size());
48  // get all contributing particles
49  for (const auto& p : makeRange(hitParticlesMap.equal_range(ihit))) {
50  ACTS_INFO(" generating particle " << p.first);
51  }
52  }
53 
54  // print hits within geometry selection
55  auto numVolume = selectVolume(clusters, m_cfg.volumeId).size();
56  auto numLayer = selectLayer(clusters, m_cfg.volumeId, m_cfg.layerId).size();
57  auto rangeModule =
58  selectModule(clusters, m_cfg.volumeId, m_cfg.layerId, m_cfg.moduleId);
59 
60  ACTS_INFO("Hits total: " << clusters.size());
61  ACTS_INFO("Hits in volume " << m_cfg.volumeId << ": " << numVolume);
62  ACTS_INFO("Hits in volume " << m_cfg.volumeId << " layer " << m_cfg.layerId
63  << ": " << numLayer);
64  ACTS_INFO("Hits in volume " << m_cfg.volumeId << " layer " << m_cfg.layerId
65  << " module " << m_cfg.moduleId << ": "
66  << rangeModule.size());
67  // we could also use for (const Acts::PlanarModuleCluster& c : rangeModule)
68  // for simplicity, but then we could not get the hit index.
69  ACTS_INFO("Hits by geometry selection")
70  for (auto ic = rangeModule.begin(); ic != rangeModule.end(); ++ic) {
71  auto ihit = clusters.index_of(ic);
72  auto hitId = hitIds[ihit];
73 
74  Acts::GeometryID geoId = ic->first;
75  const Acts::PlanarModuleCluster& c = ic->second;
76  ACTS_INFO(" Cluster " << ihit << " hitId " << hitId << " geoId " << geoId
77  << " size " << c.digitizationCells().size());
78  }
79 
80  return ProcessCode::SUCCESS;
81 }