ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
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
45void 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
56std::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
67int CscHitIdHelper::GetPhiSector(const int& hid) const
68{
69 return this->GetFieldValue("PhiSector",hid);
70}
71
72int CscHitIdHelper::GetZSector(const int& hid) const
73{
74 return this->GetFieldValue("ZSector",hid);
75}
76
77//----CSC
78int CscHitIdHelper::GetChamberLayer(const int& hid) const
79{
80 return this->GetFieldValue("ChamberLayer",hid);
81}
82
83int CscHitIdHelper::GetWireLayer(const int& hid) const
84{
85 return this->GetFieldValue("WireLayer",hid);
86}
87
88//packing method
89int 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}
void SetStationName(const std::string &name, int &hid) const
int GetWireLayer(const int &hid) const
int GetZSector(const int &hid) const
void InitializeStationName()
int GetPhiSector(const int &hid) const
std::string GetStationName(const int &hid) const
int GetChamberLayer(const int &hid) const
int BuildCscHitId(const std::string &, const int, const int, const int, const int) const
static const CscHitIdHelper * GetHelper()
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