ATLAS Offline Software
TgcHitIdHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <iomanip>
8 #include <array>
9 
10 namespace {
11  constexpr std::array<char, 4> v1 = {'B','E','T','C'};
12  constexpr std::array<char, 9> v2 = {'I','M','O','E','1','2','3','4','S'};
13  constexpr std::array<char, 6> v3 = {'S','L','E','R','F','G'};
14 }
15 
16 //private constructor
18 {
20  Initialize();
21 }
22 
24 {
25  static const TgcHitIdHelper helper;
26  return &helper;
27 }
28 
30 {
31  InitializeField("StationPhi",1,48);
32  InitializeField("StationEta",-5,5);
33  InitializeField("GasGap",1,3);
34 }
35 
37 {
38  InitializeField("Station[1]",0,sizeof(v1));
39  InitializeField("Station[2]",0,sizeof(v2));
40  InitializeField("Station[3]",0,sizeof(v3));
41 }
42 
43 void TgcHitIdHelper::SetStationName(const std::string& name, int& hid) const
44 {
45  for (unsigned int i=0;i<sizeof(v1);i++)
46  if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid);
47  for (unsigned int i=0;i<sizeof(v2);i++)
48  if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid);
49  for (unsigned int i=0;i<sizeof(v3);i++)
50  if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid);
51 }
52 std::string TgcHitIdHelper::GetStationName(const int& hid) const
53 {
54  std::string temp;
55  temp+=v1[this->GetFieldValue("Station[1]",hid)];
56  temp+=v2[this->GetFieldValue("Station[2]",hid)];
57  temp+=v3[this->GetFieldValue("Station[3]",hid)];
58  return temp;
59 }
60 
61 int TgcHitIdHelper::GetStationPhi(const int& hid) const
62 {
63  return this->GetFieldValue("StationPhi",hid);
64 }
65 
66 int TgcHitIdHelper::GetStationEta(const int& hid) const
67 {
68  return this->GetFieldValue("StationEta",hid);
69 }
70 
71 int TgcHitIdHelper::GetGasGap(const int& hid) const
72 {
73  return this->GetFieldValue("GasGap",hid);
74 }
75 
76 //packing method
77 int TgcHitIdHelper::BuildTgcHitId(const std::string& statName, const int statPhi,
78  const int statEta, const int gasG) const
79 {
80  int theID(0);
81  this->SetStationName(statName, theID);
82  this->SetFieldValue("StationPhi", statPhi, theID);
83  this->SetFieldValue("StationEta", statEta, theID);
84  this->SetFieldValue("GasGap", gasG, theID);
85  return theID;
86 }
HitIdHelper::SetFieldValue
void SetFieldValue(const std::string &name, int n, HitID &targetID) const
Definition: HitIdHelper.cxx:31
TgcHitIdHelper::GetGasGap
int GetGasGap(const int &hid) const
Definition: TgcHitIdHelper.cxx:71
TgcHitIdHelper::TgcHitIdHelper
TgcHitIdHelper()
Definition: TgcHitIdHelper.cxx:17
HitIdHelper::InitializeField
void InitializeField(const std::string &n, int vmn, int vmx)
Definition: HitIdHelper.cxx:10
TgcHitIdHelper::InitializeStationName
void InitializeStationName()
Definition: TgcHitIdHelper.cxx:36
TgcHitIdHelper::Initialize
void Initialize()
Definition: TgcHitIdHelper.cxx:29
TgcHitIdHelper
Definition: TgcHitIdHelper.h:13
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
HitIdHelper::GetFieldValue
int GetFieldValue(const std::string &name, HitID targetID) const
Definition: HitIdHelper.cxx:48
lumiFormat.i
int i
Definition: lumiFormat.py:92
TgcHitIdHelper::GetStationName
std::string GetStationName(const int &hid) const
Definition: TgcHitIdHelper.cxx:52
TgcHitIdHelper::GetHelper
static const TgcHitIdHelper * GetHelper()
Definition: TgcHitIdHelper.cxx:23
TgcHitIdHelper::GetStationPhi
int GetStationPhi(const int &hid) const
Definition: TgcHitIdHelper.cxx:61
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HitIdHelper
Definition: HitIdHelper.h:23
TgcHitIdHelper::SetStationName
void SetStationName(const std::string &name, int &hid) const
Definition: TgcHitIdHelper.cxx:43
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
TgcHitIdHelper::GetStationEta
int GetStationEta(const int &hid) const
Definition: TgcHitIdHelper.cxx:66
TgcHitIdHelper::BuildTgcHitId
int BuildTgcHitId(const std::string &, const int, const int, const int) const
Definition: TgcHitIdHelper.cxx:77
TgcHitIdHelper.h