ATLAS Offline Software
GlobalUtilities.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  global stuff
7  -----------------------------------------
8  ***************************************************************************/
9 
11 
12 #include <charconv>
13 #include <cmath>
14 #include <cstdlib>
15 #include <iostream>
16 #include <sstream>
17 
18 namespace MuonGM {
19 
20  std::string buildString(int i, int ncha) {
21  if (ncha <= 0) {
22  return std::to_string(i);
23  } else {
24  int ij = i;
25  std::ostringstream ostigg;
26  for (int j = ncha - 1; j >= 0; j--) {
27  ostigg << int(ij / std::pow(10.0, j));
28  ij = int(ij % int(std::pow(10.0, j)));
29  }
30  return ostigg.str();
31  }
32  }
33 
34  int strtoint(std::string_view str, unsigned int istart, unsigned int length) {
35  std::string_view s(str.substr(istart, length));
36  int result = -999;
37  std::from_chars(s.data(), s.data() + s.size(), result);
38  return result;
39  }
40 
41  int stationPhiTGC(std::string_view stName, int fi, int zi_input) {
42  // fi and zi_imput are the amdb indices (1, ... 8) and (-8, 8) are their ranges
43  std::string_view stName3 = stName.substr(0, 3);
44  int stphi = 0;
45 
46  int zi = std::abs(zi_input);
47  --fi; // start from 0
48 
49  if (stName3 == "T4E") {
50  switch (fi) {
51  case 0: stphi = zi; break;
52  case 1: stphi = zi + 3; break;
53  case 2: stphi = zi + 6; break;
54  case 3:
55  stphi = zi + 9; // zi are numbered in order, i.e. 1 and 2
56  break;
57  case 4: stphi = zi + 11; break;
58  case 5: stphi = zi + 14; break;
59  case 6: stphi = zi + 16; break;
60  case 7: stphi = zi + 19; break;
61  default: stphi = 0;
62  }
63  // minumum stPhi at phi 0
64  stphi = stphi - 1;
65  if (stphi < 1) stphi = stphi + 21;
66  } else {
67  int nch = 3;
68  if (stName[2] == 'E') nch = 6;
69  int fioff = std::abs(zi);
70  if (fioff > 3 && stName[2] == 'F') fioff = fioff - 3;
71  // minumum stPhi at phi 0
72  if (stName[2] == 'F')
73  fioff = fioff - 1;
74  else
75  fioff = fioff - 2;
76  stphi = fi * nch + fioff;
77  if (stphi < 1) {
78  if (stName[2] == 'F')
79  stphi = stphi + 24;
80  else
81  stphi = stphi + 48;
82  }
83  }
84  return stphi;
85  }
86  int amdbPhiTGC(std::string_view stName, int phiIndex, int eta_index) {
87  if (stName != "T4E") {
88  const int nch = 3*( stName[2] == 'E' ? 2 : 1);
89  int fioff = std::abs(eta_index);
90  if (fioff > 3 && stName[2] == 'F') fioff -= 3;
91  if (stName[2] == 'F') fioff -=1;
92  else fioff-=2;
93  int amdbPhi = ( (phiIndex - fioff) / nch + 1 ) % 8;
94  if (amdbPhi <= 0) amdbPhi = 8;
95  return amdbPhi;
96  }
99  switch (phiIndex) {
100  case 21: return 1;
101  case 3 : return 2;
102  case 6: return 3;
103  case 9: return 4;
104  case 11: return 5;
105  case 14: return 6;
106  case 16: return 7;
107  case 19: return 8;
108  default: return 0;
109  }
110  return 0;
111  }
112 
113 
114 } // namespace MuonGM
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
get_generator_info.result
result
Definition: get_generator_info.py:21
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
lumiFormat.i
int i
Definition: lumiFormat.py:92
createCablingJSON.eta_index
int eta_index
Definition: createCablingJSON.py:9
GlobalUtilities.h
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
MuonGM::amdbPhiTGC
int amdbPhiTGC(std::string_view stName, int phiIndex, int eta_index)
Converts the Identifier phi index to the AMDB phi index.
Definition: GlobalUtilities.cxx:89
MuonGM::strtoint
int strtoint(std::string_view str, unsigned int istart, unsigned int length)
Definition: GlobalUtilities.cxx:37
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
MuonGM::stationPhiTGC
int stationPhiTGC(std::string_view stName, int fi, int zi_input)
Converts the AMDB phi index to the Identifier phi Index.
Definition: GlobalUtilities.cxx:44
checkFileSG.fi
fi
Definition: checkFileSG.py:65
str
Definition: BTagTrackIpAccessor.cxx:11
MuonGM::buildString
std::string buildString(int i, int ncha)
Definition: GlobalUtilities.cxx:23
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26