ATLAS Offline Software
Loading...
Searching...
No Matches
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
11namespace {
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
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
49void 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
61std::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
73int MicromegasHitIdHelper::GetPhiSector(const int& hid) const
74{
75 return this->GetFieldValue("PhiSector",hid);
76}
77
78int MicromegasHitIdHelper::GetZSector(const int& hid) const
79{
80 return this->GetFieldValue("ZSector",hid);
81}
82
83//----Micromegas
84int MicromegasHitIdHelper::GetMultiLayer(const int& hid) const
85{
86 return this->GetFieldValue("MultiLayer",hid);
87}
88
89int MicromegasHitIdHelper::GetLayer(const int& hid) const
90{
91 return this->GetFieldValue("Layer",hid);
92}
93
94int MicromegasHitIdHelper::GetSide(const int& hid) const
95{
96 return this->GetFieldValue("Side",hid);
97}
98
99
100//packing method
101int 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}
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 GetLayer(const int &hid) const
void SetStationName(const std::string &name, int &hid) const
static const MicromegasHitIdHelper * GetHelper()
int GetSide(const int &hid) const
int GetPhiSector(const int &hid) const
int GetMultiLayer(const int &hid) const
int GetZSector(const int &hid) const
int BuildMicromegasHitId(const std::string &, const int, const int, const int, const int, const int) const
std::string GetStationName(const int &hid) const