ATLAS Offline Software
CscHitIdHelper.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 CscHitIdHelper helper;
26  return &helper;
27 }
28 
30 {
31  InitializeField("PhiSector",1,8);
32  InitializeField("ZSector",-1,1);
33  InitializeField("ChamberLayer",1,2);
34  InitializeField("WireLayer",1,4);
35 
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 }
44 
45 void CscHitIdHelper::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 
53  if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid);
54 }
55 
56 std::string CscHitIdHelper::GetStationName(const int& hid) const
57 {
58  char v[4];
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]='\0';
63  std::string temp=v;
64  return temp;
65 }
66 
67 int CscHitIdHelper::GetPhiSector(const int& hid) const
68 {
69  return this->GetFieldValue("PhiSector",hid);
70 }
71 
72 int CscHitIdHelper::GetZSector(const int& hid) const
73 {
74  return this->GetFieldValue("ZSector",hid);
75 }
76 
77 //----CSC
78 int CscHitIdHelper::GetChamberLayer(const int& hid) const
79 {
80  return this->GetFieldValue("ChamberLayer",hid);
81 }
82 
83 int CscHitIdHelper::GetWireLayer(const int& hid) const
84 {
85  return this->GetFieldValue("WireLayer",hid);
86 }
87 
88 //packing method
89 int CscHitIdHelper::BuildCscHitId(const std::string& statName, const int phiSect,
90  const int zSect, const int chamberLayer, int wireLayer) 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("ChamberLayer", chamberLayer, theID);
97  this->SetFieldValue("WireLayer", wireLayer, theID);
98  return theID;
99 }
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
CscHitIdHelper::GetChamberLayer
int GetChamberLayer(const int &hid) const
Definition: CscHitIdHelper.cxx:78
CscHitIdHelper::GetPhiSector
int GetPhiSector(const int &hid) const
Definition: CscHitIdHelper.cxx:67
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
CscHitIdHelper::GetHelper
static const CscHitIdHelper * GetHelper()
Definition: CscHitIdHelper.cxx:23
HitIdHelper::GetFieldValue
int GetFieldValue(const std::string &name, HitID targetID) const
Definition: HitIdHelper.cxx:48
CscHitIdHelper::BuildCscHitId
int BuildCscHitId(const std::string &, const int, const int, const int, const int) const
Definition: CscHitIdHelper.cxx:89
CscHitIdHelper::CscHitIdHelper
CscHitIdHelper()
Definition: CscHitIdHelper.cxx:17
lumiFormat.i
int i
Definition: lumiFormat.py:92
CscHitIdHelper
Definition: CscHitIdHelper.h:13
CscHitIdHelper::GetWireLayer
int GetWireLayer(const int &hid) const
Definition: CscHitIdHelper.cxx:83
CscHitIdHelper::SetStationName
void SetStationName(const std::string &name, int &hid) const
Definition: CscHitIdHelper.cxx:45
CscHitIdHelper.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HitIdHelper
Definition: HitIdHelper.h:23
CscHitIdHelper::GetStationName
std::string GetStationName(const int &hid) const
Definition: CscHitIdHelper.cxx:56
CscHitIdHelper::GetZSector
int GetZSector(const int &hid) const
Definition: CscHitIdHelper.cxx:72
CscHitIdHelper::Initialize
void Initialize()
Definition: CscHitIdHelper.cxx:29
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
python.PyAthena.v
v
Definition: PyAthena.py:157
CscHitIdHelper::InitializeStationName
void InitializeStationName()
Definition: CscHitIdHelper.cxx:38