ATLAS Offline Software
Loading...
Searching...
No Matches
sTgcHitIdHelper.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 = {'Q'};
13 constexpr std::array<char, 2> v2 = {'S','L'};
14 constexpr std::array<char, 5> v3 = {'0','1','2','3','4'};
15 constexpr std::array<char, 2> v4 = {'P','C'};
16}
17
18//private constructor
23
25 static const sTgcHitIdHelper helper;
26 return &helper;
27}
28
30
31 InitializeField("PhiSector",1,16);
32 InitializeField("ZSector",0,4);
33 InitializeField("MultiLayer",1,2);
34 InitializeField("Layer",1,4);
35 InitializeField("Side",-1,1);
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 InitializeField("Station[4]",0,sizeof(v4));
44}
45void sTgcHitIdHelper::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 if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid);
53 for (unsigned int i=0;i<sizeof(v4);i++)
54 if (v4[i]==name[3]) SetFieldValue("Station[4]",i,hid);
55}
56std::string sTgcHitIdHelper::GetStationName(const int& hid) const
57{
58 char v[5];
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]=v4[this->GetFieldValue("Station[4]", hid)];
63 v[4]='\0';
64 std::string temp=v;
65 return temp;
66}
67
68int sTgcHitIdHelper::GetPhiSector(const int& hid) const {
69 return this->GetFieldValue("PhiSector", hid);
70}
71
72int sTgcHitIdHelper::GetZSector(const int& hid) const {
73 return this->GetFieldValue("ZSector", hid);
74}
75
76//----sTgc
77int sTgcHitIdHelper::GetMultiLayer(const int& hid) const {
78 return this->GetFieldValue("MultiLayer", hid);
79}
80int sTgcHitIdHelper::GetLayer(const int& hid) const {
81 return this->GetFieldValue("Layer", hid);
82}
83int sTgcHitIdHelper::GetSide(const int& hid) const {
84 return this->GetFieldValue("Side", hid);
85}
86
87
88//packing method
89int sTgcHitIdHelper::BuildsTgcHitId(const std::string& statName, const int phiSect,
90 const int zSect, const int multiLayer, const int layer, const int side) 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("MultiLayer", multiLayer, theID);
97 this->SetFieldValue("Layer", layer, theID);
98 this->SetFieldValue("Side", side, theID);
99 return theID;
100}
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 BuildsTgcHitId(const std::string &, const int, const int, const int, const int, const int) const
int GetZSector(const int &hid) const
int GetMultiLayer(const int &hid) const
int GetSide(const int &hid) const
std::string GetStationName(const int &hid) const
int GetPhiSector(const int &hid) const
void SetStationName(const std::string &name, int &hid) const
int GetLayer(const int &hid) const
static const sTgcHitIdHelper * GetHelper()