ATLAS Offline Software
Loading...
Searching...
No Matches
DetailedHitInfo.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include <numeric>
8
9namespace{
10
11 template<typename InputIterator,typename AccumulateType,typename BinaryOperation,typename Predicate>
12 const AccumulateType
13 accumulate_if(InputIterator first,const InputIterator last,
14 AccumulateType init, BinaryOperation&& binary_op,Predicate&& predicate){
15 for (; first != last; ++first){
16 if (predicate(*first)) init = binary_op(init, *first);
17 }
18 return init;
19 }
20
21 enum TupleItem{ ThisLayer, NumLayers, NumHits};
22
23 using OneDetail = std::tuple<int, int, int>;
24 using DetailVector = std::vector<OneDetail>;
25
26 template<int q>
27 int addUp(int l, const std::pair < Trk::DetectorRegion, DetailVector > & p){
28 for (const auto &t:p.second){
29 l+=std::get<q>(t);
30 }
31 return l;
32 }
33
34 auto fromRegion=[](Trk::DetectorRegion r){
35 return [r](const std::pair < Trk::DetectorRegion, DetailVector > & p){
36 return p.first == r;
37 };
38 };
39
40 auto fromStrips ATLAS_THREAD_SAFE =[](const std::pair < Trk::DetectorRegion, DetailVector > & p) {
42 };
43
44 auto fromPixels ATLAS_THREAD_SAFE =[](const std::pair < Trk::DetectorRegion, DetailVector > & p) {
45 return (p.first==Trk::DetectorRegion::pixelBarrelFlat) or
48 };
49}
50
51
52
53const std::vector < std::pair < Trk::DetectorRegion, std::vector < std::tuple <int , int , int> > > > &
57
58void
59Trk::DetailedHitInfo::addHit(Trk::DetectorRegion region, int layer, int eta_module, int hit) {
60 for (auto& [thisRegion,thisHitInfoVector] : m_detailedHitInfo) {
61 if (thisRegion==region) {
62 for (auto& [thisLayer, nLayers, nHits] : thisHitInfoVector) {
63 if (thisLayer==layer) {
64 // increase the contributing layers only for inclined/endcap modules
65 if (region!=pixelBarrelFlat and region!=stripBarrel and eta_module!=m_prevEta) {
66 nLayers++;
67 m_prevEta = eta_module;
68 }
69 nHits+=hit;
70 return;
71 }
72 }
73 }
74 }
75 // if reaches this point the element is not found, then you add it to m_detailedHitInfo
76 m_prevEta = eta_module;
77 std::vector < std::tuple <int, int, int> > counts = {{layer, 1, hit}};
78 m_detailedHitInfo.emplace_back(region, counts);
79}
80
81int
83 for (auto& [thisRegion,thisHitInfoVector] : m_detailedHitInfo) {
84 if (thisRegion==region) {
85 for (auto& [thisLayer, nLayers, nHits] : thisHitInfoVector) {
86 if (thisLayer==layer) {
87 return nHits;
88 }
89 }
90 }
91 }
92 return 0;
93}
94
95int
97 return accumulate_if(m_detailedHitInfo.begin(), m_detailedHitInfo.end(), 0, addUp<NumLayers>, fromRegion(region));
98}
99
100int
102 return std::accumulate(m_detailedHitInfo.begin(), m_detailedHitInfo.end(), 0, addUp<NumLayers>);
103}
104
105int
107 return accumulate_if(m_detailedHitInfo.begin(), m_detailedHitInfo.end(), 0, addUp<NumHits>, fromRegion(region));
108}
109
110int
112 return std::accumulate(m_detailedHitInfo.begin(), m_detailedHitInfo.end(), 0, addUp<NumHits>);
113}
114
115int
117 return accumulate_if(m_detailedHitInfo.begin(), m_detailedHitInfo.end(), 0, addUp<NumLayers>, fromPixels);
118}
119
120int
122 return accumulate_if(m_detailedHitInfo.begin(), m_detailedHitInfo.end(), 0, addUp<NumHits>, fromPixels);
123
124}
125
126int
128 return accumulate_if(m_detailedHitInfo.begin(), m_detailedHitInfo.end(), 0, addUp<NumLayers>, fromStrips);
129}
130
131int
133 return accumulate_if(m_detailedHitInfo.begin(), m_detailedHitInfo.end(), 0, addUp<NumHits>, fromStrips);
134}
static const uint32_t nHits
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
int getContributionFromRegion(Trk::DetectorRegion region)
const std::vector< std::pair< Trk::DetectorRegion, std::vector< std::tuple< int, int, int > > > > & getHitInfo()
int getHits(Trk::DetectorRegion region, int layer)
void addHit(Trk::DetectorRegion region, int layer, int etaModule, int hit=1)
This class containes the detailed information on the contributing layers and regions to the hit count...
std::vector< std::pair< Trk::DetectorRegion, std::vector< std::tuple< int, int, int > > > > m_detailedHitInfo
int getHitsFromRegion(Trk::DetectorRegion region)
int r
Definition globals.cxx:22
bool first
Definition DeMoScan.py:534
l
Printing final latex table to .tex output file.
@ pixelBarrelInclined
@ stripEndcap
@ stripBarrel
@ pixelEndcap
@ pixelBarrelFlat
init(v_theApp, v_rootStream=None)
Definition PyKernel.py:45