ATLAS Offline Software
FPGATrackSimRoad.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
11 #include <vector>
12 
15 
16 using namespace std;
17 
19 {
20  size_t n = 0;
21  for (const auto& l : m_hits) n += l.size();
22  return n;
23 }
24 
25 std::vector<size_t> FPGATrackSimRoad::getNHits_layer() const
26 {
27  std::vector<size_t> out;
28  for (const auto& l : m_hits) out.push_back(l.size());
29  return out;
30 }
31 
33 {
34  size_t combos = 1;
35  size_t l = m_hits.size();
36  std::vector<unsigned int> skipindices;
37 
38  // figure out indices of outer layers of stereo layers, where inner layer is also present to not
39  // double count spacepoints
40  for (size_t i = 1; i < l; ++i) {
41  if (m_hits[i - 1].size() > 0 && m_hits[i].size() > 0) {
42  if ((m_hits[i - 1][0]->isStrip() && m_hits[i][0]->isStrip()) &&
43  (m_hits[i - 1][0]->getPhysLayer() % 2 == 0) &&
44  (m_hits[i][0]->getPhysLayer() - m_hits[i - 1][0]->getPhysLayer() == 1)) {
45  skipindices.push_back(i);
46  ++i;
47  }
48  }
49  }
50 
51  // calculate number of combinations
52  for (size_t i = 0; i < l; ++i) {
53  size_t n = 0;
54  for (size_t j = 0; j < m_hits[i].size(); ++j) {
55  // extra handling of spacepoints in combination calculation
56  if (m_hits[i][j]->getHitType() == HitType::spacepoint) {
57  bool skip = false;
58  size_t skipsize = skipindices.size();
59  for (size_t k = 0; k < skipsize; ++k)
60  if (i == skipindices[k]) skip = true;
61 
62  if (skip) continue;
63  }
64  ++n;
65  }
66  if (n > 0) combos *= n;
67  }
68 
69  return combos;
70 }
71 
72 
74 {
75  // get number of pixel layers from hits. Assumes strips follow pixels,
76  // and all hits in a layer share the same det type
77  unsigned nPixel;
78  for (nPixel = 0; nPixel < m_hits.size(); nPixel++)
79  if (!m_hits[nPixel].empty() && m_hits[nPixel].front()->isStrip())
80  break;
81 
82  std::map<FPGATrackSimMultiTruth::Barcode, layer_bitmask_t> layer_map;
83 
84  for (auto const& hits : m_hits)
85  for (FPGATrackSimHit const* h : hits)
86  for (auto const& x : h->getTruth())
87  layer_map[x.first] |= (1 << h->getLayer());
88 
90  for (auto const& x : layer_map)
91  {
92  int w = 0, n = 0;
93  for (unsigned i = 0; i < m_hits.size(); i++)
94  {
95  if (!m_hits[i].empty())
96  n += (i < nPixel) ? 2 : 1; // double weight pixels
97  if (x.second & (1 << i))
98  w += (i < nPixel) ? 2 : 1; // double weight pixels
99  }
100  if (n == 0){
101  throw "divide by zero in FPGATrackSimRoad::getTruth";
102  }
103  mt.add(x.first, static_cast<float>(w) / n);
104  }
105 
106  return mt;
107 }
108 
109 ostream& operator<<(ostream& os, const FPGATrackSimRoad& road)
110 {
111  os << "road " << road.m_roadID
112  << ": PID " << road.m_pid
113  << ", sector " << road.m_sector
114  << " hitLayers " << std::showbase << std::hex << road.m_hit_layers
115  << " wcLayers " << std::showbase << std::hex << road.m_wildcard_layers
116  << ", nHits " << road.getNHits();
117  /*
118  for (size_t l=0; l < road.m_hits.size(); l++)
119  {
120  for (FPGATrackSimHit const * hit : road.m_hits[l])
121  os << "\n\t" << *hit;
122  }
123  */
124 
125  return os;
126 }
127 
FPGATrackSimRoad::getTruth
FPGATrackSimMultiTruth getTruth() const
Definition: FPGATrackSimRoad.cxx:73
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
HitType::spacepoint
@ spacepoint
FPGATrackSimRoad::m_pid
pid_t m_pid
Definition: FPGATrackSimRoad.h:113
x
#define x
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
FPGATrackSimRoad::m_wildcard_layers
layer_bitmask_t m_wildcard_layers
Definition: FPGATrackSimRoad.h:118
FPGATrackSimRoad::getNHits_layer
std::vector< size_t > getNHits_layer() const
Definition: FPGATrackSimRoad.cxx:25
FPGATrackSimRoad::getNHits
size_t getNHits() const
Definition: FPGATrackSimRoad.cxx:18
operator<<
ostream & operator<<(ostream &os, const FPGATrackSimRoad &road)
Definition: FPGATrackSimRoad.cxx:109
FPGATrackSimConstants.h
FPGATrackSimHit
Definition: FPGATrackSimHit.h:38
FPGATrackSimRoad::m_hit_layers
layer_bitmask_t m_hit_layers
Definition: FPGATrackSimRoad.h:117
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
lumiFormat.i
int i
Definition: lumiFormat.py:92
h
beamspotman.n
n
Definition: beamspotman.py:731
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
FPGATrackSimMultiTruth::add
void add(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
dumpTgcDigiThreshold.isStrip
list isStrip
Definition: dumpTgcDigiThreshold.py:33
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimRoad::m_roadID
int m_roadID
Definition: FPGATrackSimRoad.h:112
FPGATrackSimRoad::getNHitCombos
size_t getNHitCombos() const
Definition: FPGATrackSimRoad.cxx:32
FPGATrackSimRoad.h
Defines a class for roads.
skip
bool skip
Definition: TrigGlobEffCorrValidation.cxx:190
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
FPGATrackSimRoad::m_sector
sector_t m_sector
Definition: FPGATrackSimRoad.h:114
FPGATrackSimRoad
Definition: FPGATrackSimRoad.h:29
fitman.k
k
Definition: fitman.py:528