ATLAS Offline Software
MdtHitIdHelper.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 <iostream>
8 #include <iomanip>
9 #include <array>
10 
11 namespace {
12  constexpr std::array<char, 4> v1 = {'B','E','T','C'};
13  constexpr std::array<char, 9> v2 = {'I','M','O','E','1','2','3','4','S'};
14  constexpr std::array<char, 7> v3 = {'S','L','E','R','F','G','M'};
15 }
16 
17 //private constructor
18 MdtHitIdHelper::MdtHitIdHelper(const unsigned int nTubes) : HitIdHelper()
19 {
21  Initialize(nTubes);
22 }
23 
24 const MdtHitIdHelper* MdtHitIdHelper::GetHelper(const unsigned int nTubes)
25 {
26  static const MdtHitIdHelper helper(nTubes);
27  return &helper;
28 }
29 
30 void MdtHitIdHelper::Initialize(const unsigned int nTubes)
31 {
32  InitializeField("PhiSector",1,8);
33  InitializeField("ZSector",-8,8);
34  InitializeField("MultiLayer",1,2);
35  InitializeField("Layer",1,4);
36  InitializeField("Tube",1,nTubes);
37 }
38 
40 {
41  InitializeField("Station[1]",0,sizeof(v1));
42  InitializeField("Station[2]",0,sizeof(v2));
43  InitializeField("Station[3]",0,sizeof(v3));
44 }
45 
46 void MdtHitIdHelper::SetStationName(const std::string& name, int& hid) const
47 {
48  for (unsigned int i=0;i<sizeof(v1);i++)
49  if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid);
50  for (unsigned int i=0;i<sizeof(v2);i++)
51  if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid);
52  for (unsigned int i=0;i<sizeof(v3);i++)
53  if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid);
54 
55 
56 }
57 std::string MdtHitIdHelper::GetStationName(const int& hid) const
58 {
59  char v[4];
60  v[0]=v1[this->GetFieldValue("Station[1]",hid)];
61  v[1]=v2[this->GetFieldValue("Station[2]",hid)];
62  v[2]=v3[this->GetFieldValue("Station[3]",hid)];
63  v[3]='\0';
64  std::string temp=v;
65  return temp;
66 }
67 
68 int MdtHitIdHelper::GetPhiSector(const int& hid) const
69 {
70  return this->GetFieldValue("PhiSector",hid);
71 }
72 
73 int MdtHitIdHelper::GetZSector(const int& hid) const
74 {
75  return this->GetFieldValue("ZSector",hid);
76 }
77 
78 //----MDT
79 int MdtHitIdHelper::GetMultiLayer(const int& hid) const
80 {
81  return this->GetFieldValue("MultiLayer",hid);
82 }
83 
84 int MdtHitIdHelper::GetLayer(const int& hid) const
85 {
86  return this->GetFieldValue("Layer",hid);
87 }
88 
89 int MdtHitIdHelper::GetTube(const int& hid) const
90 {
91  return this->GetFieldValue("Tube",hid);
92 }
93 
94 //packing method
95 int MdtHitIdHelper::BuildMdtHitId(const std::string& statName, const int phiSect,
96  const int zSect, const int multiLayer, const int layer, const int tube) const
97 {
98  int theID(0);
99  this->SetStationName(statName, theID);
100  this->SetFieldValue("PhiSector", phiSect, theID);
101  this->SetFieldValue("ZSector", zSect, theID);
102  this->SetFieldValue("MultiLayer", multiLayer, theID);
103  this->SetFieldValue("Layer", layer, theID);
104  this->SetFieldValue("Tube", tube, theID);
105  return theID;
106 }
MdtHitIdHelper::GetMultiLayer
int GetMultiLayer(const int &hid) const
Definition: MdtHitIdHelper.cxx:79
HitIdHelper::SetFieldValue
void SetFieldValue(const std::string &name, int n, HitID &targetID) const
Definition: HitIdHelper.cxx:31
MdtHitIdHelper
Definition: MdtHitIdHelper.h:13
HitIdHelper::InitializeField
void InitializeField(const std::string &n, int vmn, int vmx)
Definition: HitIdHelper.cxx:10
MdtHitIdHelper::Initialize
void Initialize(unsigned int nTubes)
Definition: MdtHitIdHelper.cxx:30
MdtHitIdHelper::SetStationName
void SetStationName(const std::string &name, int &hid) const
Definition: MdtHitIdHelper.cxx:46
MdtHitIdHelper::GetZSector
int GetZSector(const int &hid) const
Definition: MdtHitIdHelper.cxx:73
MdtHitIdHelper::GetHelper
static const MdtHitIdHelper * GetHelper(unsigned int nTubes=78)
Definition: MdtHitIdHelper.cxx:24
MdtHitIdHelper::MdtHitIdHelper
MdtHitIdHelper(unsigned int nTubes)
Definition: MdtHitIdHelper.cxx:18
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
MdtHitIdHelper::GetPhiSector
int GetPhiSector(const int &hid) const
Definition: MdtHitIdHelper.cxx:68
MdtHitIdHelper::GetStationName
std::string GetStationName(const int &hid) const
Definition: MdtHitIdHelper.cxx:57
HitIdHelper::GetFieldValue
int GetFieldValue(const std::string &name, HitID targetID) const
Definition: HitIdHelper.cxx:48
lumiFormat.i
int i
Definition: lumiFormat.py:92
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
MdtHitIdHelper::GetLayer
int GetLayer(const int &hid) const
Definition: MdtHitIdHelper.cxx:84
MdtHitIdHelper::InitializeStationName
void InitializeStationName()
Definition: MdtHitIdHelper.cxx:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HitIdHelper
Definition: HitIdHelper.h:23
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
python.PyAthena.v
v
Definition: PyAthena.py:157
MdtHitIdHelper.h
MdtHitIdHelper::GetTube
int GetTube(const int &hid) const
Definition: MdtHitIdHelper.cxx:89
sTgcDigitEffiDump.multiLayer
int multiLayer
Definition: sTgcDigitEffiDump.py:36
calibdata.tube
tube
Definition: calibdata.py:31
MdtHitIdHelper::BuildMdtHitId
int BuildMdtHitId(const std::string &, const int, const int, const int, const int, const int) const
Definition: MdtHitIdHelper.cxx:95