ATLAS Offline Software
Loading...
Searching...
No Matches
RpcHitIdHelper.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
10namespace {
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(nGasGaps);
21}
22
23const RpcHitIdHelper* RpcHitIdHelper::GetHelper(unsigned int nGasGaps)
24{
25 static const RpcHitIdHelper helper(nGasGaps);
26 return &helper;
27}
28
29void RpcHitIdHelper::Initialize(unsigned int nGasGaps)
30{
31 InitializeField("PhiSector",1,8);
32 InitializeField("ZSector",-8,8);
33 InitializeField("DoubletR",1,2);
34 InitializeField("GasGapLayer",1,nGasGaps);
35 InitializeField("DoubletPhi",1,2);
36 InitializeField("DoubletZ",1,3);
37 InitializeField("MeasuresPhi",0,1);
38
39}
40
42{
43 InitializeField("Station[1]",0,sizeof(v1));
44 InitializeField("Station[2]",0,sizeof(v2));
45 InitializeField("Station[3]",0,sizeof(v3));
46}
47
48void RpcHitIdHelper::SetStationName(const std::string& name, int& hid) const
49{
50 for (unsigned int i=0;i<sizeof(v1);i++)
51 if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid);
52 for (unsigned int i=0;i<sizeof(v2);i++)
53 if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid);
54 for (unsigned int i=0;i<sizeof(v3);i++)
55 if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid);
56}
57
58std::string RpcHitIdHelper::GetStationName(const int& hid) const
59{
60 char v[4];
61 v[0]=v1[this->GetFieldValue("Station[1]", hid)];
62 v[1]=v2[this->GetFieldValue("Station[2]", hid)];
63 v[2]=v3[this->GetFieldValue("Station[3]", hid)];
64 v[3]='\0';
65 std::string temp=v;
66 return temp;
67}
68
69int RpcHitIdHelper::GetPhiSector(const int& hid) const
70{
71 return this->GetFieldValue("PhiSector", hid);
72}
73
74int RpcHitIdHelper::GetZSector(const int& hid) const
75{
76 return this->GetFieldValue("ZSector", hid);
77}
78
79//----RPC
80int RpcHitIdHelper::GetDoubletR(const int& hid) const
81{
82 return this->GetFieldValue("DoubletR", hid);
83}
84int RpcHitIdHelper::GetGasGapLayer(const int& hid) const
85{
86 return this->GetFieldValue("GasGapLayer", hid);
87}
88int RpcHitIdHelper::GetDoubletPhi(const int& hid) const
89{
90 return this->GetFieldValue("DoubletPhi", hid);
91}
92int RpcHitIdHelper::GetDoubletZ(const int& hid) const
93{
94 return this->GetFieldValue("DoubletZ", hid);
95}
96int RpcHitIdHelper::GetMeasuresPhi(const int& hid) const
97{
98 return this->GetFieldValue("MeasuresPhi", hid);
99}
100
101//packing method
102int RpcHitIdHelper::BuildRpcHitId(const std::string& statName, const int phiSect,
103 const int zSect, const int doubZ, const int doubR, const int gasGap,
104 const int doubPhi, const int measPhi) const
105{
106
107 int theID(0);
108 this->SetStationName(statName, theID);
109 this->SetFieldValue("PhiSector", phiSect, theID);
110 this->SetFieldValue("ZSector", zSect, theID);
111 this->SetFieldValue("DoubletZ", doubZ, theID);
112 this->SetFieldValue("DoubletR", doubR, theID);
113 this->SetFieldValue("GasGapLayer", gasGap, theID);
114 this->SetFieldValue("DoubletPhi", doubPhi, theID);
115 this->SetFieldValue("MeasuresPhi", measPhi, theID);
116 return theID;
117}
int GetFieldValue(const std::string &name, HitID targetID) const
void InitializeField(const std::string &n, int vmn, int vmx)
void SetFieldValue(const std::string &name, int n, HitID &targetID) const
int GetDoubletPhi(const int &hid) const
static const RpcHitIdHelper * GetHelper(unsigned int nGasGaps=2)
void SetStationName(const std::string &name, int &hid) const
int GetPhiSector(const int &hid) const
int BuildRpcHitId(const std::string &, const int, const int, const int, const int, const int, const int, const int) const
void InitializeStationName()
int GetDoubletR(const int &hid) const
RpcHitIdHelper(unsigned int nGasGaps)
int GetGasGapLayer(const int &hid) const
int GetMeasuresPhi(const int &hid) const
std::string GetStationName(const int &hid) const
void Initialize(unsigned int nGasGaps)
int GetDoubletZ(const int &hid) const
int GetZSector(const int &hid) const