ATLAS Offline Software
FPGATrackSimLorentzAngleTool.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
4 
9 #include <TrkSurfaces/Surface.h>
10 
12  const std::string& name, const IInterface* ifc)
13  : AthAlgTool(algname, name, ifc) {
14 }
15 
17  ATH_MSG_DEBUG("Initializing FPGATrackSimLorentzAngleTool");
18 
19  // Retrieve managers and ID helpers
20  ATH_CHECK(detStore()->retrieve(m_pixelId, "PixelID"));
21  ATH_CHECK(detStore()->retrieve(m_SCTId, "SCT_ID"));
22  ATH_CHECK(detStore()->retrieve(m_pixelManager, "ITkPixel"));
23  ATH_CHECK(detStore()->retrieve(m_SCTManager, "ITkStrip"));
24 
25  ATH_CHECK(m_lorentzAngleToolPixel.retrieve(EnableTool{m_useAthenaLorentzAngleTools}));
26  ATH_CHECK(m_lorentzAngleToolStrip.retrieve(EnableTool{m_useAthenaLorentzAngleTools}));
27 
28  return StatusCode::SUCCESS;
29 }
30 
32 
33  // do nothing in this case, just return!
34  if (correctionType < 0)
35  return StatusCode::SUCCESS;
36 
37  float shift = 0.0;
38  const IdentifierHash& hash = hit.getIdentifierHash();
39  if(hit.isPixel()){
40  Amg::Vector2D localPos(hit.getPhiCoord(), hit.getEtaCoord());
41  // Get the shift value
42  if (m_useAthenaLorentzAngleTools) {
43  shift = m_lorentzAngleToolPixel->getLorentzShift(hash, Gaudi::Hive::currentContext());
44  }
45  else {
46  shift = getLorentzAngleShift(hit, correctionType);
47  }
48  if (m_shiftGlobalPosition) {
49  // Get the pixel detector element
50  const InDetDD::SiDetectorElement* siDE = m_pixelManager->getDetectorElement(hash);
51  Identifier wafer_id = m_pixelId->wafer_id(hash);
52  Identifier hit_id = m_pixelId->pixel_id(wafer_id, hit.getPhiIndex(), hit.getEtaIndex());
53  // Get the cell from the ID
55  if (!cell.isValid()) {
56  ATH_MSG_DEBUG("Pixel cell not valid for hitID " << hit_id);
57  return StatusCode::FAILURE;
58  }
59 
60  localPos[Trk::locX] += shift; // apply the Lorentz angle shift
61  InDetDD::SiCellId newCell = siDE->cellIdOfPosition(localPos); // find the new cell corresponding to the shifted position
62  Amg::Vector3D newGlobalPos = siDE->globalPosition(localPos); // get the new global position
63  if (newCell.phiIndex() < 0) {
64  ATH_MSG_ERROR("Pixel new cell not valid for hitID " << hit_id << " with shift " << shift << " and localPosX " << localPos[Trk::locX] << " and localPosY " << localPos[Trk::locY] << " and stripIndex " << newCell.phiIndex() << ". Setting hit to module's edge.");
65  return StatusCode::FAILURE;
66  }
67  // Update the hit's global position
68  hit.setX(newGlobalPos[Amg::x]);
69  hit.setY(newGlobalPos[Amg::y]);
70  hit.setZ(newGlobalPos[Amg::z]);
71  }
72 
73  // update the hit's local position
74  hit.setPhiCoord(hit.getPhiCoord()+shift);
75  }
76  else{
77  Amg::Vector2D localPos(hit.getPhiCoord(), hit.getEtaCoord());
78 
79 
80  // Get the shift value
81  if (m_useAthenaLorentzAngleTools) {
82  shift = m_lorentzAngleToolStrip->getLorentzShift(hash, Gaudi::Hive::currentContext());
83  }
84  else {
85  shift = getLorentzAngleShift(hit, correctionType);
86  }
87 
88  if (m_shiftGlobalPosition) { // TODO: more tests, debugging and validation needed for this in case we actually want it
89  // Get the Strip detector element
90  const InDetDD::SiDetectorElement* siDE = m_SCTManager->getDetectorElement(hash);
91 
92  localPos[Trk::locX] += shift; // apply the Lorentz angle shift
93 
94  // Update the hit's global position
95  Amg::Vector3D newGlobalPos = siDE->surface().localToGlobal(localPos);
96  hit.setX(newGlobalPos[Amg::x]);
97  hit.setY(newGlobalPos[Amg::y]);
98  hit.setZ(newGlobalPos[Amg::z]);
99 
100  }
101  // update the hit's local position
102  hit.setPhiCoord(hit.getPhiCoord()+shift);
103  }
104  return StatusCode::SUCCESS;
105 }
106 
107 
108 float FPGATrackSim::LorentzAngleTool::getLorentzAngleShift(const FPGATrackSimHit & hit, int correctionType) const {
109  if (correctionType == 0) { // full default first version correction)
110  if (hit.isPixel()) {
111  if(hit.isBarrel()){
112  return getPixelBarrelShift_v0(hit.getLayerDisk(true), hit.getEtaModule());
113  }
114  else{
115  return getPixelEndcapShift_v0(hit.getLayerDisk(true), hit.getPhiModule(), hit.getEtaModule());
116  }
117  } else if (hit.isStrip()) {
118  if (hit.isBarrel()) {
119  const InDetDD::SiDetectorElement* sielement = m_SCTManager->getDetectorElement(hit.getIdentifierHash());
120  return getStripBarrelShift_v0(sielement->isStereo(), hit.getLayerDisk(true), hit.getEtaModule());
121  } else {
122  return getStripEndcapShift_v0(hit.getLayerDisk(true), hit.getEtaModule(), hit.getZ());
123  }
124  } else {
125  throw std::runtime_error( std::string(typeid(*this).name()) + ": Invalid hit type: neither Pixel nor Strip.");
126  }
127  }
128  else if (correctionType == 1) {
129  if (hit.isPixel()) {
130  if(hit.isBarrel()){
131  return getPixelBarrelShift_v1(hit.getLayerDisk(true), hit.getEtaModule());
132  }
133  else{
134  return getPixelEndcapShift_v1(hit.getLayerDisk(true), hit.getPhiModule(), hit.getEtaModule());
135  }
136  } else if (hit.isStrip()) {
137  if (hit.isBarrel()) {
138  const InDetDD::SiDetectorElement* sielement = m_SCTManager->getDetectorElement(hit.getIdentifierHash());
139  return getStripBarrelShift_v1(sielement->isStereo(), hit.getEtaModule());
140  } else {
141  return getStripEndcapShift_v1(hit.getLayerDisk(true), hit.getEtaModule(), hit.getZ());
142  }
143  } else {
144  throw std::runtime_error( std::string(typeid(*this).name()) + ": Invalid hit type: neither Pixel nor Strip.");
145  }
146  }
147  else if (correctionType == 2) {
148  if (hit.isPixel()) {
149  if(hit.isBarrel()){
150  return getPixelBarrelShift_v2(hit.getLayerDisk(true));
151  }
152  else{
153  return getPixelEndcapShift_v2(hit.getLayerDisk(true), hit.getPhiModule(), hit.getEtaModule());
154  }
155  } else if (hit.isStrip()) {
156  if (hit.isBarrel()) {
157  const InDetDD::SiDetectorElement* sielement = m_SCTManager->getDetectorElement(hit.getIdentifierHash());
158  return getStripBarrelShift_v2(sielement->isStereo());
159  } else {
160  return getStripEndcapShift_v2(hit.getLayerDisk(true), hit.getEtaModule(), hit.getZ());
161  }
162  } else {
163  throw std::runtime_error( std::string(typeid(*this).name()) + ": Invalid hit type: neither Pixel nor Strip.");
164  }
165  }
166  else {
167  throw std::runtime_error( std::string(typeid(*this).name()) + ": Invalid correctionType = " + std::to_string(correctionType));
168  }
169 }
170 
171 float FPGATrackSim::LorentzAngleTool::getPixelEndcapShift_v0(unsigned layerDisk, unsigned phiModule, int etaModule) const{
172  const float endcapShiftTable[23][9] = {
173 //layers: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
174  {0.0, 0.0, -0.000006, 0.004646, -0.000112, 0.006308, -0.000151, 0.006828, -0.000189}, // etaModule 0
175  {0.0, 0.0, -0.000006, 0.004627, -0.000129, 0.006291, -0.000185, 0.006811, -0.000226}, // etaModule 1
176  {0.0, 0.0, -0.000007, 0.004601, -0.000151, 0.006268, -0.000233, 0.006789, -0.000275}, // etaModule 2
177  {0.0, 0.0, -0.000008, 0.004562, -0.000178, 0.006240, -0.000301, 0.006764, -0.000342}, // etaModule 3
178  {0.0, 0.0, -0.000009, 0.004503, -0.000212, 0.006202, -0.000394, 0.006731, -0.000432}, // etaModule 4
179  {0.0, 0.0, -0.000010, 0.004409, -0.000256, 0.006153, -0.000511, 0.006689, -0.000549}, // etaModule 5
180  {0.0, NAN, -0.000011, NAN, -0.000309, 0.006087, -0.000610, 0.006636, -0.000682}, // etaModule 6
181  {0.0, NAN, -0.000012, NAN, -0.000370, 0.005995, -0.000607, 0.006569, -0.000781}, // etaModule 7
182  {0.0, NAN, -0.000014, NAN, -0.000427, NAN, NAN, 0.006483, -0.000764}, // etaModule 8
183  {0.0, NAN, -0.000016, NAN, -0.000459, NAN, NAN, NAN, NAN}, // etaModule 9
184  {0.0, NAN, -0.000018, NAN, -0.000454, NAN, NAN, NAN, NAN}, // etaModule 10
185  {0.0, NAN, -0.000021, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 11
186  {0.0, NAN, -0.000024, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 12
187  {0.0, NAN, -0.000028, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 13
188  {0.0, NAN, -0.000033, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 14
189  {NAN, NAN, -0.000039, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 15
190  {NAN, NAN, -0.000047, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 16
191  {NAN, NAN, -0.000056, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 17
192  {NAN, NAN, -0.000069, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 18
193  {NAN, NAN, -0.000085, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 19
194  {NAN, NAN, -0.000105, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 20
195  {NAN, NAN, -0.000124, NAN, NAN, NAN, NAN, NAN, NAN}, // etaModule 21
196  {NAN, NAN, -0.000134, NAN, NAN, NAN, NAN, NAN, NAN} // etaModule 22
197  };
198  if (etaModule > 22 || layerDisk > 8) {
199  throw std::domain_error("Pixel Endcap invalid layerDisk or etaModule value: " + std::to_string(layerDisk) + ", " + std::to_string(etaModule));
200  }
201  float shift = endcapShiftTable[etaModule][layerDisk];
202  if (std::isnan(shift)) {
203  throw std::domain_error("Pixel Endcap invalid shift value: NAN for layerDisk " + std::to_string(layerDisk) + " and etaModule " + std::to_string(etaModule));
204  }
205  const bool evenPhi = phiModule % 2 == 0;
206  switch (layerDisk) {
207  case 2:
208  return evenPhi ? -shift : shift;
209  case 3:
210  case 5:
211  case 7:
212  return evenPhi ? shift : -shift;
213  case 4:
214  if (phiModule <= 15)
215  return evenPhi ? shift : -shift;
216  else
217  return evenPhi ? -shift : shift;
218  case 6:
219  if (phiModule <= 21)
220  return evenPhi ? shift : -shift;
221  else
222  return evenPhi ? -shift : shift;
223  case 8:
224  if (phiModule <= 25)
225  return evenPhi ? shift : -shift;
226  else
227  return evenPhi ? -shift : shift;
228  default:
229  return shift;
230  }
231 }
232 
233 float FPGATrackSim::LorentzAngleTool::getPixelBarrelShift_v0(unsigned layerDisk, int etaModule) const {
234  const float pixelBarrelShiftTable[25][5] = {
235 //layers: 0 | 1 | 2 | 3 | 4
236  {0.0, NAN, NAN, NAN, NAN}, // etaModule -12
237  {0.0, NAN, NAN, NAN, NAN}, // etaModule -11
238  {0.0, NAN, NAN, NAN, NAN}, // etaModule -10
239  {0.0, NAN, -0.011976, -0.011982, -0.011989}, // etaModule -9
240  {0.0, NAN, -0.011989, -0.011995, -0.012002}, // etaModule -8
241  {0.0, NAN, -0.011998, -0.012004, -0.012011}, // etaModule -7
242  {0.0, -0.006069, -0.012008, -0.012013, -0.012020}, // etaModule -6
243  {0.0, -0.006073, -0.012015, -0.012021, -0.012027}, // etaModule -5
244  {0.0, -0.006076, -0.012021, -0.012026, -0.012033}, // etaModule -4
245  {0.0, -0.006078, -0.012026, -0.012031, -0.012038}, // etaModule -3
246  {0.0, -0.006080, -0.012029, -0.012034, -0.012041}, // etaModule -2
247  {0.0, -0.006081, -0.012030, -0.012036, -0.012042}, // etaModule -1
248  {NAN, NAN, NAN, NAN, NAN}, // etaModule 0
249  {0.0, -0.006081, -0.012030, -0.012036, -0.012042}, // etaModule 1
250  {0.0, -0.006080, -0.012029, -0.012034, -0.012041}, // etaModule 2
251  {0.0, -0.006078, -0.012026, -0.012031, -0.012038}, // etaModule 3
252  {0.0, -0.006076, -0.012021, -0.012026, -0.012033}, // etaModule 4
253  {0.0, -0.006073, -0.012015, -0.012021, -0.012027}, // etaModule 5
254  {0.0, -0.006069, -0.012008, -0.012013, -0.012020}, // etaModule 6
255  {0.0, NAN, -0.011998, -0.012004, -0.012011}, // etaModule 7
256  {0.0, NAN, -0.011989, -0.011995, -0.012002}, // etaModule 8
257  {0.0, NAN, -0.011976, -0.011982, -0.011989}, // etaModule 9
258  {0.0, NAN, NAN, NAN, NAN}, // etaModule 10
259  {0.0, NAN, NAN, NAN, NAN}, // etaModule 11
260  {0.0, NAN, NAN, NAN, NAN} // etaModule 12
261  };
262 
263  if (layerDisk >= 5 || std::abs(etaModule) >= 13 || std::isnan(pixelBarrelShiftTable[etaModule + 12][layerDisk])) {
264  throw std::domain_error("Invalid pixel barrel layerDisk or etaModule value: " + std::to_string(layerDisk) + ", " + std::to_string(etaModule));
265  }
266 
267  return pixelBarrelShiftTable[etaModule + 12][layerDisk];
268 }
269 
270 
271 
272 float FPGATrackSim::LorentzAngleTool::getStripBarrelShift_v0(bool isStereo, unsigned layerDisk, int etaModule) const {
273  const float shiftTable[57][4] = {
274 //layers: 0 | 1 | 2 | 3
275  {NAN, NAN, NAN, NAN}, // Invalid data for etaModule 0
276  {0.045516, 0.045631, 0.045813, 0.046054}, // etaModule 1
277  {0.045514, 0.045629, 0.045809, 0.046058}, // etaModule 2
278  {0.045512, 0.045628, 0.045803, 0.046068}, // etaModule 3
279  {0.045506, 0.045623, 0.045788, 0.046069}, // etaModule 4
280  {0.045501, 0.045618, 0.045770, 0.046068}, // etaModule 5
281  {0.045492, 0.045611, 0.045744, 0.046054}, // etaModule 6
282  {0.045481, 0.045600, 0.045715, 0.046040}, // etaModule 7
283  {0.045470, 0.045590, 0.045672, 0.046007}, // etaModule 8
284  {0.045459, 0.045580, 0.045627, 0.045975}, // etaModule 9
285  {0.045442, 0.045563, 0.045572, 0.045932}, // etaModule 10
286  {0.045423, 0.045547, 0.045509, 0.045879}, // etaModule 11
287  {0.045405, 0.045531, 0.045445, 0.045829}, // etaModule 12
288  {0.045387, 0.045514, 0.045361, 0.045756}, // etaModule 13
289  {0.045362, 0.045491, 0.045277, 0.045687}, // etaModule 14
290  {0.045334, 0.045466, 0.045177, 0.045602}, // etaModule 15
291  {0.045308, 0.045441, 0.045072, 0.045514}, // etaModule 16
292  {0.045279, 0.045414, 0.044956, 0.045417}, // etaModule 17
293  {0.045252, 0.045389, 0.044831, 0.045310}, // etaModule 18
294  {0.045217, 0.045357, 0.044694, 0.045193}, // etaModule 19
295  {0.045180, 0.045321, 0.044547, 0.045066}, // etaModule 20
296  {0.045140, 0.045285, 0.044390, 0.044928}, // etaModule 21
297  {0.045102, 0.045250, 0.044219, 0.044775}, // etaModule 22
298  {0.045063, 0.045214, 0.044038, 0.044615}, // etaModule 23
299  {0.045019, 0.045171, 0.043846, 0.044438}, // etaModule 24
300  {0.044968, 0.045123, 0.043635, 0.044247}, // etaModule 25
301  {0.044919, 0.045077, 0.043423, 0.044054}, // etaModule 26
302  {0.044869, 0.045031, 0.043186, 0.043849}, // etaModule 27
303  {0.044821, 0.044985, 0.042944, 0.043647}, // etaModule 28
304  {0.044757, 0.044925, NAN, NAN}, // etaModule 29
305  {0.044697, 0.044868, NAN, NAN}, // etaModule 30
306  {0.044636, 0.044811, NAN, NAN}, // etaModule 31
307  {0.044576, 0.044754, NAN, NAN}, // etaModule 32
308  {0.044508, 0.044689, NAN, NAN}, // etaModule 33
309  {0.044435, 0.044620, NAN, NAN}, // etaModule 34
310  {0.044362, 0.044551, NAN, NAN}, // etaModule 35
311  {0.044290, 0.044482, NAN, NAN}, // etaModule 36
312  {0.044212, 0.044408, NAN, NAN}, // etaModule 37
313  {0.044126, 0.044327, NAN, NAN}, // etaModule 38
314  {0.044041, 0.044246, NAN, NAN}, // etaModule 39
315  {0.043956, 0.044166, NAN, NAN}, // etaModule 40
316  {0.043866, 0.044082, NAN, NAN}, // etaModule 41
317  {0.043768, 0.043989, NAN, NAN}, // etaModule 42
318  {0.043670, 0.043895, NAN, NAN}, // etaModule 43
319  {0.043572, 0.043801, NAN, NAN}, // etaModule 44
320  {0.043467, 0.043703, NAN, NAN}, // etaModule 45
321  {0.043356, 0.043597, NAN, NAN}, // etaModule 46
322  {0.043244, 0.043492, NAN, NAN}, // etaModule 47
323  {0.043134, 0.043387, NAN, NAN}, // etaModule 48
324  {0.043007, 0.043268, NAN, NAN}, // etaModule 49
325  {0.042883, 0.043151, NAN, NAN}, // etaModule 50
326  {0.042760, 0.043033, NAN, NAN}, // etaModule 51
327  {0.042629, 0.042911, NAN, NAN}, // etaModule 52
328  {0.042485, 0.042775, NAN, NAN}, // etaModule 53
329  {0.042347, 0.042646, NAN, NAN}, // etaModule 54
330  {0.042205, 0.042511, NAN, NAN}, // etaModule 55
331  {0.042056, 0.042370, NAN, NAN}, // etaModule 56
332  };
333 
334  if (layerDisk >= 4 || std::abs(etaModule) >= 57 || std::isnan(shiftTable[std::abs(etaModule)][layerDisk]) ) {
335  throw std::domain_error("Invalid strip layerDisk or etaModule value in barrel: " + std::to_string(layerDisk) + ", " + std::to_string(etaModule));
336  }
337 
338  return isStereo ? -shiftTable[std::abs(etaModule)][layerDisk] : shiftTable[std::abs(etaModule)][layerDisk];
339 }
340 
341 float FPGATrackSim::LorentzAngleTool::getStripEndcapShift_v0(unsigned layerDisk, int etaModule, float z) const {
342  float shiftTable[18][6] = {
343 //layers: 0 | 1 | 2 | 3 | 4 | 5
344  {0.001532, 0.001943, 0.002601, 0.003425, 0.004022, 0.003900}, // etaModule 0
345  {0.001611, 0.002046, 0.002741, 0.003622, 0.004256, 0.004117}, // etaModule 1
346  {0.001706, 0.002165, 0.002916, 0.003855, 0.004553, 0.004404}, // etaModule 2
347  {0.001813, 0.002305, 0.003109, 0.004136, 0.004905, 0.004738}, // etaModule 3
348  {0.001908, 0.002428, 0.003275, 0.004384, 0.005211, 0.005028}, // etaModule 4
349  {0.001990, 0.002529, 0.003421, 0.004591, 0.005480, 0.005278}, // etaModule 5
350  {0.002073, 0.002635, 0.003582, 0.004824, 0.005791, 0.005558}, // etaModule 6
351  {0.002143, 0.002732, 0.003699, 0.005004, 0.006037, 0.005801}, // etaModule 7
352  {0.002217, 0.002832, 0.003855, 0.005236, 0.006343, 0.006094}, // etaModule 8
353  {0.002317, 0.002960, 0.004039, 0.005527, 0.006743, 0.006465}, // etaModule 9
354  {0.002422, 0.003088, 0.004240, 0.005842, 0.007188, 0.006864}, // etaModule 10
355  {0.002510, 0.003202, 0.004413, 0.006121, 0.007592, 0.007247}, // etaModule 11
356  {0.002586, 0.003308, 0.004562, 0.006376, 0.007972, 0.007595}, // etaModule 12
357  {0.002671, 0.003424, 0.004734, 0.006648, 0.008408, 0.007988}, // etaModule 13
358  {0.002788, 0.003581, 0.004976, 0.007081, 0.009110, 0.008616}, // etaModule 14
359  {0.002927, 0.003757, 0.005252, 0.007604, 0.010043, 0.009421}, // etaModule 15
360  {0.003025, 0.003911, 0.005482, 0.008059, 0.010959, 0.010173}, // etaModule 16
361  {0.003139, 0.004051, 0.005707, 0.008498, 0.011985, 0.010993} // etaModule 17
362  };
363 
364  if (layerDisk >= 6 || etaModule >= 18 || etaModule<0 || std::isnan(shiftTable[etaModule][layerDisk]) ) {
365  throw std::domain_error("Invalid strip layerDisk or etaModule value on endcaps: " + std::to_string(layerDisk) + ", " + std::to_string(etaModule));
366  }
367 
368  return z > 0.0 ? shiftTable[std::abs(etaModule)][layerDisk] : -shiftTable[std::abs(etaModule)][layerDisk];
369 }
370 
371 float FPGATrackSim::LorentzAngleTool::getPixelEndcapShift_v1(unsigned layerDisk, unsigned phiModule, int etaModule) const{
372  const float endcapShiftTable[11][7] = {
373 //layers: 0-2 | 3 | 4 | 5 | 6 | 7 | 8
374  {-0.000003, 0.004646, -0.000112, 0.006308, -0.000151, 0.006828, -0.000189}, // etaModule 0
375  {-0.000003, 0.004627, -0.000129, 0.006291, -0.000185, 0.006811, -0.000226}, // etaModule 1
376  {-0.000003, 0.004601, -0.000151, 0.006268, -0.000233, 0.006789, -0.000275}, // etaModule 2
377  {-0.000004, 0.004562, -0.000178, 0.006240, -0.000301, 0.006764, -0.000342}, // etaModule 3
378  {-0.000004, 0.004503, -0.000212, 0.006202, -0.000394, 0.006731, -0.000432}, // etaModule 4
379  {-0.000005, 0.004409, -0.000256, 0.006153, -0.000511, 0.006689, -0.000549}, // etaModule 5
380  {-0.000005, NAN, -0.000309, 0.006087, -0.000610, 0.006636, -0.000682}, // etaModule 6
381  {-0.000006, NAN, -0.000370, 0.005995, -0.000607, 0.006569, -0.000781}, // etaModule 7
382  {-0.000007, NAN, -0.000427, NAN, NAN, 0.006483, -0.000764}, // etaModule 8
383  {-0.000008, NAN, -0.000459, NAN, NAN, NAN, NAN}, // etaModule 9
384  {-0.000009, NAN, -0.000454, NAN, NAN, NAN, NAN}, // etaModule 10
385  };
386  // for eta module 11-22
387  const float endcapShiftTable2[12] = {
388  -0.000021, // etaModule 11
389  -0.000024, // etaModule 12
390  -0.000028, // etaModule 13
391  -0.000033, // etaModule 14
392  -0.000039, // etaModule 15
393  -0.000047, // etaModule 16
394  -0.000056, // etaModule 17
395  -0.000069, // etaModule 18
396  -0.000085, // etaModule 19
397  -0.000105, // etaModule 20
398  -0.000124, // etaModule 21
399  -0.000134 // etaModule 22
400  };
401 
402 
403  float shift = 0;
404  if (etaModule > 22 || layerDisk > 8) {
405  throw std::domain_error("Pixel Endcap invalid layerDisk or etaModule value: " + std::to_string(layerDisk) + ", " + std::to_string(etaModule));
406  }
407  else if (etaModule > 10 && etaModule < 23) {
408  shift = endcapShiftTable2[etaModule-11];
409  }
410  else {
411  unsigned layerDisktoUse = ((layerDisk <= 2) ? 0 : (layerDisk - 2));
412  shift = endcapShiftTable[etaModule][layerDisktoUse];
413  }
414 
415  if (std::isnan(shift)) {
416  throw std::domain_error("Pixel Endcap invalid shift value: NAN for layerDisk " + std::to_string(layerDisk) + " and etaModule " + std::to_string(etaModule));
417  }
418  const bool evenPhi = phiModule % 2 == 0;
419  switch (layerDisk) {
420  case 2:
421  return evenPhi ? -shift : shift;
422  case 3:
423  case 5:
424  case 7:
425  return evenPhi ? shift : -shift;
426  case 4:
427  if (phiModule <= 15)
428  return evenPhi ? shift : -shift;
429  else
430  return evenPhi ? -shift : shift;
431  case 6:
432  if (phiModule <= 21)
433  return evenPhi ? shift : -shift;
434  else
435  return evenPhi ? -shift : shift;
436  case 8:
437  if (phiModule <= 25)
438  return evenPhi ? shift : -shift;
439  else
440  return evenPhi ? -shift : shift;
441  default:
442  return shift;
443  }
444 }
445 
446 float FPGATrackSim::LorentzAngleTool::getPixelBarrelShift_v1(unsigned layerDisk, int etaModule) const {
447  const float pixelBarrelShiftTable[9][5] = {
448 //layers: 0 | 1 | 2 | 3 | 4
449  {0.0, -0.006081, -0.012030, -0.012036, -0.012042}, // etaModule 1
450  {0.0, -0.006080, -0.012029, -0.012034, -0.012041}, // etaModule 2
451  {0.0, -0.006078, -0.012026, -0.012031, -0.012038}, // etaModule 3
452  {0.0, -0.006076, -0.012021, -0.012026, -0.012033}, // etaModule 4
453  {0.0, -0.006073, -0.012015, -0.012021, -0.012027}, // etaModule 5
454  {0.0, -0.006069, -0.012008, -0.012013, -0.012020}, // etaModule 6
455  {0.0, NAN, -0.011998, -0.012004, -0.012011}, // etaModule 7
456  {0.0, NAN, -0.011989, -0.011995, -0.012002}, // etaModule 8
457  {0.0, NAN, -0.011976, -0.011982, -0.011989}, // etaModule 9
458  };
459 
460  if (layerDisk >= 5 || std::abs(etaModule) >= 13) {
461  throw std::domain_error("Invalid pixel barrel layerDisk or etaModule value: " + std::to_string(layerDisk) + ", " + std::to_string(etaModule));
462  }
463  if (abs(etaModule) >= 10 || etaModule == 0) return 0;
464  else return pixelBarrelShiftTable[abs(etaModule) - 1][layerDisk];
465 }
466 
467 
468 
469 float FPGATrackSim::LorentzAngleTool::getStripBarrelShift_v1(bool isStereo, int etaModule) const {
470 
471  const float shiftTable[56] = { // etaModule 0 is not valid
472  0.0457535, // etaModule 1
473  0.0457525, // etaModule 2
474  0.04575275, // etaModule 3
475  0.04574650, // etaModule 4
476  0.04573925, // etaModule 5
477  0.04572525, // etaModule 6
478  0.0457090, // etaModule 7
479  0.04568475, // etaModule 8
480  0.04566025, // etaModule 9
481  0.04562725, // etaModule 10
482  0.0455895, // etaModule 11
483  0.0455525, // etaModule 12
484  0.0455045, // etaModule 13
485  0.04545425, // etaModule 14
486  0.04539475, // etaModule 15
487  0.04533375, // etaModule 16
488  0.0452665, // etaModule 17
489  0.0451955, // etaModule 18
490  0.04511525, // etaModule 19
491  0.0450285, // etaModule 20
492  0.04493575, // etaModule 21
493  0.0448365, // etaModule 22
494  0.0447325, // etaModule 23
495  0.04461850, // etaModule 24
496  0.04449325, // etaModule 25
497  0.04436825, // etaModule 26
498  0.04423375, // etaModule 27
499  0.04409925, // etaModule 28
500  0.044841, // etaModule 29
501  0.0447825, // etaModule 30
502  0.0447235, // etaModule 31
503  0.044665, // etaModule 32
504  0.0445985, // etaModule 33
505  0.0445275, // etaModule 34
506  0.0444565, // etaModule 35
507  0.044386, // etaModule 36
508  0.04431, // etaModule 37
509  0.0442265, // etaModule 38
510  0.0441435, // etaModule 39
511  0.044061, // etaModule 40
512  0.043974, // etaModule 41
513  0.0438785, // etaModule 42
514  0.0437825, // etaModule 43
515  0.0436865, // etaModule 44
516  0.043585, // etaModule 45
517  0.0434765, // etaModule 46
518  0.0433680, // etaModule 47
519  0.0432605, // etaModule 48
520  0.0431375, // etaModule 49
521  0.043017, // etaModule 50
522  0.0428965, // etaModule 51
523  0.042770, // etaModule 52
524  0.042630, // etaModule 53
525  0.0424965, // etaModule 54
526  0.042358, // etaModule 55
527  0.042213 // etaModule 56
528  };
529 
530  if (std::abs(etaModule) >= 57 || etaModule == 0) {
531  throw std::domain_error("Invalid strip etaModule value in barrel: " + std::to_string(etaModule));
532  }
533 
534  return isStereo ? -shiftTable[std::abs(etaModule)-1] : shiftTable[std::abs(etaModule)-1];
535 }
536 
537 float FPGATrackSim::LorentzAngleTool::getStripEndcapShift_v1(unsigned layerDisk, int etaModule, float z) const {
538  float shiftTable[6][6] = {
539 //layers: 0 | 1 | 2 | 3 | 4 | 5
540  {0.001611, 0.002046, 0.002741, 0.003622, 0.004256, 0.004117}, // etaModule 0-2
541  {0.001908, 0.002428, 0.003275, 0.004384, 0.005211, 0.005028}, // etaModule 3-5
542  {0.002143, 0.002732, 0.003699, 0.005004, 0.006037, 0.005801}, // etaModule 6-8
543  {0.002422, 0.003088, 0.004240, 0.005842, 0.007188, 0.006864}, // etaModule 9-11
544  {0.002671, 0.003424, 0.004734, 0.006648, 0.008408, 0.007988}, // etaModule 12-14
545  {0.003025, 0.003911, 0.005482, 0.008059, 0.010959, 0.010173}, // etaModule 15-17
546  };
547 
548  if (layerDisk >= 6 || abs(etaModule) >= 18 || abs(etaModule)<0) {
549  throw std::domain_error("Invalid strip layerDisk or etaModule value on endcaps: " + std::to_string(layerDisk) + ", " + std::to_string(etaModule));
550  }
551 
552  int etaModuleToUse = std::floor(abs(etaModule)/3);
553  return z > 0.0 ? shiftTable[std::abs(etaModuleToUse)][layerDisk] : -shiftTable[std::abs(etaModuleToUse)][layerDisk];
554 }
555 
556 float FPGATrackSim::LorentzAngleTool::getPixelEndcapShift_v2(unsigned layerDisk, unsigned phiModule, int etaModule) const{
557  const float endcapShiftTable[5][7] = {
558 //layers: 0-2 | 3 | 4 | 5 | 6 | 7 | 8
559  {-0.000003, 0.004636, -0.000120, 0.006300, -0.000168, 0.006820, -0.000208}, // etaModule 0-1
560  {-0.000004, 0.004582, -0.000164, 0.006258, -0.000267, 0.006776, -0.000309}, // etaModule 2-3
561  {-0.000005, 0.004456, -0.000234, 0.006178, -0.000453, 0.006710, -0.000491}, // etaModule 4-5
562  {-0.000006, NAN, -0.000340, 0.006041, -0.000608, 0.006603, -0.000731}, // etaModule 6-7
563  {-0.000008, NAN, -0.000447, NAN, NAN, 0.006483, -0.000764}, // etaModule 8-10
564  };
565 
566  // for eta module 11-22
567  const float endcapShiftTable2[12] = {
568  -0.000021, // etaModule 11
569  -0.000024, // etaModule 12
570  -0.000028, // etaModule 13
571  -0.000033, // etaModule 14
572  -0.000039, // etaModule 15
573  -0.000047, // etaModule 16
574  -0.000056, // etaModule 17
575  -0.000069, // etaModule 18
576  -0.000085, // etaModule 19
577  -0.000105, // etaModule 20
578  -0.000124, // etaModule 21
579  -0.000134 // etaModule 22
580  };
581 
582 
583  float shift = 0;
584  if (etaModule > 22 || layerDisk > 8) {
585  throw std::domain_error("Pixel Endcap invalid layerDisk or etaModule value: " + std::to_string(layerDisk) + ", " + std::to_string(etaModule));
586  }
587  else if (etaModule > 10 && etaModule < 23) {
588  shift = endcapShiftTable2[etaModule-11];
589  }
590  else {
591  unsigned layerDisktoUse = ((layerDisk <= 2) ? 0 : (layerDisk - 2));
592  unsigned etaModuleToUse = ((etaModule >= 8) ? 4 : std::floor(etaModule/2));
593  shift = endcapShiftTable[etaModuleToUse][layerDisktoUse];
594  }
595 
596  if (std::isnan(shift)) {
597  throw std::domain_error("Pixel Endcap invalid shift value: NAN for layerDisk " + std::to_string(layerDisk) + " and etaModule " + std::to_string(etaModule));
598  }
599  const bool evenPhi = phiModule % 2 == 0;
600  switch (layerDisk) {
601  case 2:
602  return evenPhi ? -shift : shift;
603  case 3:
604  case 5:
605  case 7:
606  return evenPhi ? shift : -shift;
607  case 4:
608  if (phiModule <= 15)
609  return evenPhi ? shift : -shift;
610  else
611  return evenPhi ? -shift : shift;
612  case 6:
613  if (phiModule <= 21)
614  return evenPhi ? shift : -shift;
615  else
616  return evenPhi ? -shift : shift;
617  case 8:
618  if (phiModule <= 25)
619  return evenPhi ? shift : -shift;
620  else
621  return evenPhi ? -shift : shift;
622  default:
623  return shift;
624  }
625 }
626 
628  const float pixelBarrelShiftTable[3] = {
629  //layers: 0 | 1 | 2+
630  0.0, -0.006077, -0.012021
631  };
632 
633  if (layerDisk >= 5) {
634  throw std::domain_error("Invalid pixel barrel layerDisk value: " + std::to_string(layerDisk));
635  }
636  unsigned layerDiskToUse = ((layerDisk <= 2) ? layerDisk : 2);
637  return pixelBarrelShiftTable[layerDiskToUse];
638 
639 }
640 
641 
642 
644 
645  const float shift = 0.0441;
646  return isStereo ? -shift : shift;
647 }
648 
649 float FPGATrackSim::LorentzAngleTool::getStripEndcapShift_v2(unsigned layerDisk, int etaModule, float z) const {
650  float shiftTable[6][6] = {
651 //layers: 0 | 1 | 2 | 3 | 4 | 5
652  {0.001611, 0.002046, 0.002741, 0.003622, 0.004256, 0.004117}, // etaModule 0-2
653  {0.001908, 0.002428, 0.003275, 0.004384, 0.005211, 0.005028}, // etaModule 3-5
654  {0.002143, 0.002732, 0.003699, 0.005004, 0.006037, 0.005801}, // etaModule 6-8
655  {0.002422, 0.003088, 0.004240, 0.005842, 0.007188, 0.006864}, // etaModule 9-11
656  {0.002671, 0.003424, 0.004734, 0.006648, 0.008408, 0.007988}, // etaModule 12-14
657  {0.003025, 0.003911, 0.005482, 0.008059, 0.010959, 0.010173}, // etaModule 15-17
658  };
659 
660 
661  if (layerDisk >= 6 || abs(etaModule) >= 18 || abs(etaModule)<0) {
662  throw std::domain_error("Invalid strip layerDisk or etaModule value on endcaps: " + std::to_string(layerDisk) + ", " + std::to_string(etaModule));
663  }
664 
665  int etaModuleToUse = std::floor(abs(etaModule)/3);
666  return z > 0.0 ? shiftTable[std::abs(etaModuleToUse)][layerDisk] : -shiftTable[std::abs(etaModuleToUse)][layerDisk];
667 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
FPGATrackSimHit::getPhiModule
unsigned getPhiModule() const
Definition: FPGATrackSimHit.h:88
FPGATrackSim::LorentzAngleTool::getStripBarrelShift_v2
float getStripBarrelShift_v2(bool isStereo) const
Definition: FPGATrackSimLorentzAngleTool.cxx:643
getMenu.algname
algname
Definition: getMenu.py:54
InDetDD::SolidStateDetectorElementBase::cellIdOfPosition
SiCellId cellIdOfPosition(const Amg::Vector2D &localPos) const
As in previous method but returns SiCellId.
Definition: SolidStateDetectorElementBase.cxx:224
FPGATrackSim::LorentzAngleTool::updateHitPosition
StatusCode updateHitPosition(FPGATrackSimHit &hit, int correctionType) const
Definition: FPGATrackSimLorentzAngleTool.cxx:31
FPGATrackSimHit::getEtaModule
int getEtaModule(bool old=false) const
Definition: FPGATrackSimHit.h:87
FPGATrackSimHit::isStrip
bool isStrip() const
Definition: FPGATrackSimHit.h:65
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
Surface.h
SCT_ModuleSideDesign.h
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
FPGATrackSimHit::setPhiCoord
void setPhiCoord(float v)
Definition: FPGATrackSimHit.h:105
FPGATrackSimHit::getLayerDisk
unsigned getLayerDisk(bool old=false) const
Definition: FPGATrackSimHit.h:82
FPGATrackSim::LorentzAngleTool::getStripBarrelShift_v1
float getStripBarrelShift_v1(bool isStereo, int etaModule) const
Definition: FPGATrackSimLorentzAngleTool.cxx:469
Amg::y
@ y
Definition: GeoPrimitives.h:35
InDetDD::SolidStateDetectorElementBase::surface
Trk::Surface & surface()
Element Surface.
InDetDD::SiCellId::phiIndex
int phiIndex() const
Get phi index. Equivalent to strip().
Definition: SiCellId.h:122
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:147
FPGATrackSim::LorentzAngleTool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimLorentzAngleTool.cxx:16
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
FPGATrackSimHit::getPhiCoord
float getPhiCoord() const
Definition: FPGATrackSimHit.h:111
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:146
Amg::z
@ z
Definition: GeoPrimitives.h:36
InDetDD::SiDetectorElement::cellIdFromIdentifier
virtual SiCellId cellIdFromIdentifier(const Identifier &identifier) const override final
SiCellId from Identifier.
Definition: SiDetectorElement.cxx:120
FPGATrackSim::LorentzAngleTool::getPixelEndcapShift_v1
float getPixelEndcapShift_v1(unsigned layerDisk, unsigned phiModule, int etaModule) const
Definition: FPGATrackSimLorentzAngleTool.cxx:371
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FPGATrackSimHit::getPhiIndex
unsigned getPhiIndex() const
Definition: FPGATrackSimHit.h:107
z
#define z
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::x
@ x
Definition: GeoPrimitives.h:34
FPGATrackSim::LorentzAngleTool::getPixelEndcapShift_v0
float getPixelEndcapShift_v0(unsigned layerDisk, unsigned phiModule, int etaModule) const
Definition: FPGATrackSimLorentzAngleTool.cxx:171
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FPGATrackSim::LorentzAngleTool::getStripEndcapShift_v0
float getStripEndcapShift_v0(unsigned layerDisk, int etaModule, float z) const
Definition: FPGATrackSimLorentzAngleTool.cxx:341
FPGATrackSim::LorentzAngleTool::getPixelBarrelShift_v1
float getPixelBarrelShift_v1(unsigned layerDisk, int etaModule) const
Definition: FPGATrackSimLorentzAngleTool.cxx:446
FPGATrackSim::LorentzAngleTool::getStripBarrelShift_v0
float getStripBarrelShift_v0(bool isStereo, unsigned layerDisk, int etaModule) const
Definition: FPGATrackSimLorentzAngleTool.cxx:272
FPGATrackSimHit::getEtaIndex
unsigned getEtaIndex() const
Definition: FPGATrackSimHit.h:108
FPGATrackSimHit::getIdentifierHash
unsigned getIdentifierHash() const
Definition: FPGATrackSimHit.h:81
FPGATrackSimHit::isPixel
bool isPixel() const
Definition: FPGATrackSimHit.h:64
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:151
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
FPGATrackSim::LorentzAngleTool::getStripEndcapShift_v2
float getStripEndcapShift_v2(unsigned layerDisk, int etaModule, float z) const
Definition: FPGATrackSimLorentzAngleTool.cxx:649
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
FPGATrackSimLorentzAngleTool.h
FPGATrackSim::LorentzAngleTool::getPixelEndcapShift_v2
float getPixelEndcapShift_v2(unsigned layerDisk, unsigned phiModule, int etaModule) const
Definition: FPGATrackSimLorentzAngleTool.cxx:556
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
SiDetectorElement.h
FPGATrackSim::LorentzAngleTool::getPixelBarrelShift_v2
float getPixelBarrelShift_v2(unsigned layerDisk) const
Definition: FPGATrackSimLorentzAngleTool.cxx:627
FPGATrackSimHit::getEtaCoord
float getEtaCoord() const
Definition: FPGATrackSimHit.h:112
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:148
InDetDD::SiCellId
Definition: SiCellId.h:29
StripStereoAnnulusDesign.h
TRT::Hit::phiModule
@ phiModule
Definition: HitInfo.h:80
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
PixelModuleDesign.h
InDetDD::SolidStateDetectorElementBase::globalPosition
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
FPGATrackSim::LorentzAngleTool::LorentzAngleTool
LorentzAngleTool(const std::string &, const std::string &, const IInterface *)
Definition: FPGATrackSimLorentzAngleTool.cxx:11
FPGATrackSim::LorentzAngleTool::getStripEndcapShift_v1
float getStripEndcapShift_v1(unsigned layerDisk, int etaModule, float z) const
Definition: FPGATrackSimLorentzAngleTool.cxx:537
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
InDetDD::SiDetectorElement::isStereo
bool isStereo() const
Check if it is the stereo side (useful for SCT)
Definition: SiDetectorElement.cxx:300
FPGATrackSimHit::isBarrel
bool isBarrel() const
Definition: FPGATrackSimHit.h:66
FPGATrackSim::LorentzAngleTool::getPixelBarrelShift_v0
float getPixelBarrelShift_v0(unsigned layerDisk, int etaModule) const
Definition: FPGATrackSimLorentzAngleTool.cxx:233
Trk::Surface::localToGlobal
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
FPGATrackSim::LorentzAngleTool::getLorentzAngleShift
float getLorentzAngleShift(const FPGATrackSimHit &hit, int correctionType) const
Definition: FPGATrackSimLorentzAngleTool.cxx:108
Identifier
Definition: IdentifierFieldParser.cxx:14