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