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