ATLAS Offline Software
Loading...
Searching...
No Matches
SiHitIdHelper Class Reference

#include <SiHitIdHelper.h>

Inheritance diagram for SiHitIdHelper:
Collaboration diagram for SiHitIdHelper:

Public Member Functions

bool isPixel (const int &hid) const
bool isSCT (const int &hid) const
bool isHGTD (const int &hid) const
bool isPLR (const int &hid) const
int getBarrelEndcap (const int &hid) const
int getLayerDisk (const int &hid) const
int getEtaModule (const int &hid) const
int getPhiModule (const int &hid) const
int getSide (const int &hid) const
int buildHitId (const int, const int, const int, const int, const int, const int) const
int buildHitIdFromStringITk (int part, const std::string &) const
int buildHitIdFromStringHGTD (int part, const std::string &) const

Static Public Member Functions

static const SiHitIdHelperGetHelper ()

Private Member Functions

 SiHitIdHelper ()
void Initialize ()
void InitializeField (const std::string &n, int vmn, int vmx)
void InitializeField (const std::string &n, int nb)
void SetFieldValue (const std::string &name, int n, HitID &targetID) const
int GetFieldValue (const std::string &name, HitID targetID) const
void PrintFields ()

Static Private Member Functions

static void Print (int id)
static void SetBit (int &i, int bitpos)
static void UnsetBit (int &i, int bitpos)
static void Store (int &id, int value, int first, int field)
static int Retrieve (int id, int first, int field)

Private Attributes

bool m_isITkHGTD {}
IdFields m_IDs
int m_currentStorage

Detailed Description

Definition at line 25 of file SiHitIdHelper.h.

Constructor & Destructor Documentation

◆ SiHitIdHelper()

SiHitIdHelper::SiHitIdHelper ( )
private

Definition at line 15 of file SiHitIdHelper.cxx.

15 :HitIdHelper() {
16 Initialize();
17}

Member Function Documentation

◆ buildHitId()

int SiHitIdHelper::buildHitId ( const int Part,
const int BrlECap,
const int LayerDisk,
const int etaM,
const int phiM,
const int side ) const

Definition at line 118 of file SiHitIdHelper.cxx.

120{
121 int theID(0);
122 this->SetFieldValue("Part", Part, theID);
123 this->SetFieldValue("BarrelEndcap", BrlECap, theID);
124 this->SetFieldValue("LayerDisk", LayerDisk, theID);
125 this->SetFieldValue("EtaModule", etaM, theID);
126 this->SetFieldValue("PhiModule", phiM, theID);
127 this->SetFieldValue("Side", side, theID);
128 return theID;
129}
void SetFieldValue(const std::string &name, int n, HitID &targetID) const

◆ buildHitIdFromStringHGTD()

int SiHitIdHelper::buildHitIdFromStringHGTD ( int part,
const std::string & physVolName ) const

Definition at line 149 of file SiHitIdHelper.cxx.

150{
151 int endcap = 0;
152 int layer = 0;
153 int moduleInLayer = 0;
154 //Extract the indices from the name, and write them in to the matching int
155 std::map<std::string, int&> fields{{"endcap",endcap},{"layer",layer},{"moduleInLayer",moduleInLayer}};
156 for(const auto & field:fields){
157 size_t pos1 = (physVolName).find(field.first+"_");
158 size_t pos2 = (physVolName).find("_",pos1+field.first.size()+1);//start looking only after end of first delimiter (plus 1 for the "_" appended) ends
159 std::string strNew = (physVolName).substr(pos1+field.first.size()+1,pos2-(pos1+field.first.size()+1));
160 field.second = std::stoi(strNew);
161 }
162 return buildHitId(part,endcap,layer,0,moduleInLayer,0);
163}
int buildHitId(const int, const int, const int, const int, const int, const int) const
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
@ layer
Definition HitInfo.h:79

◆ buildHitIdFromStringITk()

int SiHitIdHelper::buildHitIdFromStringITk ( int part,
const std::string & physVolName ) const

Definition at line 131 of file SiHitIdHelper.cxx.

132{
133 int brlEcap = 0;
134 int layerDisk = 0;
135 int etaMod = 0;
136 int phiMod = 0;
137 int side = 0;
138 //Extract the indices from the name, and write them in to the matching int
139 std::map<std::string, int&> fields{{"barrel_endcap",brlEcap},{"layer_wheel",layerDisk},{"phi_module",phiMod},{"eta_module",etaMod},{"side",side}};
140 for(const auto & field:fields){
141 size_t pos1 = (physVolName).find(field.first+"_");
142 size_t pos2 = (physVolName).find("_",pos1+field.first.size()+1);//start looking only after end of first delimiter (plus 1 for the "_" appended) ends
143 std::string strNew = (physVolName).substr(pos1+field.first.size()+1,pos2-(pos1+field.first.size()+1));
144 field.second = std::stoi(strNew);
145 }
146 return buildHitId(part,brlEcap,layerDisk,etaMod,phiMod,side);
147}

◆ getBarrelEndcap()

int SiHitIdHelper::getBarrelEndcap ( const int & hid) const

Definition at line 86 of file SiHitIdHelper.cxx.

87{
88 return this->GetFieldValue("BarrelEndcap", hid);
89}
int GetFieldValue(const std::string &name, HitID targetID) const

◆ getEtaModule()

int SiHitIdHelper::getEtaModule ( const int & hid) const

Definition at line 98 of file SiHitIdHelper.cxx.

99{
100 return this->GetFieldValue("EtaModule", hid);
101}

◆ GetFieldValue()

int HitIdHelper::GetFieldValue ( const std::string & name,
HitID targetID ) const
inherited

Definition at line 47 of file HitIdHelper.cxx.

48{
49 for (unsigned int i=0;i<m_IDs.size();i++)
50 {
51 if (m_IDs[i].fieldName==name)
52 {
53 int n=Retrieve(targetID,m_IDs[i].firstBit,m_IDs[i].nBits);
54 return n+m_IDs[i].vMin;
55 }
56 }
57 std::cout<<"HitIdHelper: field "<<name<<" not found: returning 0"<<
58 std::endl;
59 return 0;
60}
IdFields m_IDs
Definition HitIdHelper.h:34
static int Retrieve(int id, int first, int field)

◆ GetHelper()

const SiHitIdHelper * SiHitIdHelper::GetHelper ( )
static

Definition at line 19 of file SiHitIdHelper.cxx.

◆ getLayerDisk()

int SiHitIdHelper::getLayerDisk ( const int & hid) const

Definition at line 92 of file SiHitIdHelper.cxx.

93{
94 return this->GetFieldValue("LayerDisk", hid);
95}

◆ getPhiModule()

int SiHitIdHelper::getPhiModule ( const int & hid) const

Definition at line 104 of file SiHitIdHelper.cxx.

105{
106 return this->GetFieldValue("PhiModule", hid);
107}

◆ getSide()

int SiHitIdHelper::getSide ( const int & hid) const

Definition at line 110 of file SiHitIdHelper.cxx.

111{
112 return this->GetFieldValue("Side", hid);
113}

◆ Initialize()

void SiHitIdHelper::Initialize ( )
private

Definition at line 24 of file SiHitIdHelper.cxx.

24 {
25
26 const PixelID* pix = nullptr;
27 ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "SiHitIdHelper");
28 if (detStore.retrieve().isSuccess()) {
29 if (detStore->retrieve(pix, "PixelID").isFailure()) { pix = nullptr; }
30 }
31
32 bool isDBM = (pix != nullptr && pix->dictionaryVersion() == "IBL-DBM");
33 // check for ITk and HGTD
34 bool isITkHGTD = (pix !=nullptr && pix->dictionaryVersion() == "ITkHGTD");
35 // we might include PLR as well, then we have to increase endcap range to +/- 4
36 bool isITkHGTDPLR = (pix !=nullptr && pix->dictionaryVersion() == "ITkHGTDPLR");
37 // new identification scheme for HGTD (endcap-layer-moduleinlayer)
38 bool isITk_HGTD_NewID_PLR = (pix !=nullptr && pix->dictionaryVersion() == "P2-RUN4");
39 // cache the HL-LHC decision
40 m_isITkHGTD = isITkHGTD || isITkHGTDPLR || isITk_HGTD_NewID_PLR;
41
42 if (isITkHGTD) InitializeField("Part",0,2);
43 else if (isITkHGTDPLR || isITk_HGTD_NewID_PLR) InitializeField("Part",0,3);
44 else InitializeField("Part",0,1);
45 if (isDBM || isITkHGTDPLR || isITk_HGTD_NewID_PLR) InitializeField("BarrelEndcap",-4,4);
46 else InitializeField("BarrelEndcap",-2,2);
47 InitializeField("LayerDisk",0,20);
48 if (m_isITkHGTD) InitializeField("EtaModule",-100,100);
49 else InitializeField("EtaModule",-20,20);
50 if (isITk_HGTD_NewID_PLR) InitializeField("PhiModule",0,1022);
51 else InitializeField("PhiModule",0,200);
52 InitializeField("Side",0,3);
53
54}
bool isDBM(uint32_t robId)
virtual std::string dictionaryVersion(void) const override
void InitializeField(const std::string &n, int vmn, int vmx)

◆ InitializeField() [1/2]

void HitIdHelper::InitializeField ( const std::string & n,
int nb )
inherited

Definition at line 20 of file HitIdHelper.cxx.

21{
22 int vmn=0;
23 int vmx = (1 << nb) - 1;
24 IdField id={n,vmn,vmx,nb,m_currentStorage+1};
25 m_IDs.push_back(std::move(id));
27 assert (m_currentStorage<33);
28}
int m_currentStorage
Definition HitIdHelper.h:35

◆ InitializeField() [2/2]

void HitIdHelper::InitializeField ( const std::string & n,
int vmn,
int vmx )
inherited

Definition at line 10 of file HitIdHelper.cxx.

11{
12 int field = vmx - vmn + 1;
13 int nb = std::bit_width(static_cast<unsigned>(field - 1));
14 IdField id={n,vmn,vmx,nb,m_currentStorage+1};
15 m_IDs.push_back(std::move(id));
17 assert (m_currentStorage<33);
18}

◆ isHGTD()

bool SiHitIdHelper::isHGTD ( const int & hid) const

Definition at line 70 of file SiHitIdHelper.cxx.

71{
72 int psh = this->GetFieldValue("Part", hid);
73 return psh ==2;
74}

◆ isPixel()

bool SiHitIdHelper::isPixel ( const int & hid) const

Definition at line 58 of file SiHitIdHelper.cxx.

59{
60 int psh = this->GetFieldValue("Part", hid);
61 return psh ==0;
62}

◆ isPLR()

bool SiHitIdHelper::isPLR ( const int & hid) const

Definition at line 76 of file SiHitIdHelper.cxx.

77{
78 if (!m_isITkHGTD) return false;
79
80 int psh = this->GetFieldValue("BarrelEndcap", hid);
81 return std::abs(psh) == 4;
82}

◆ isSCT()

bool SiHitIdHelper::isSCT ( const int & hid) const

Definition at line 64 of file SiHitIdHelper.cxx.

65{
66 int psh = this->GetFieldValue("Part", hid);
67 return psh ==1;
68}

◆ Print()

void HitIdHelper::Print ( int id)
staticinherited

Definition at line 72 of file HitIdHelper.cxx.

73{
74 for (unsigned int i=0;i<8*sizeof(int);i++)
75 {
76 if ((id & (1u<<i))) std::cout<<"1";
77 else std::cout<<"0";
78 }
79 std::cout<<std::endl;
80}

◆ PrintFields()

void HitIdHelper::PrintFields ( )
inherited

Definition at line 62 of file HitIdHelper.cxx.

63{
64 for (unsigned int i=0;i<m_IDs.size();i++)
65 {
66 std::cout<<"-- Field "<<m_IDs[i].fieldName<<"\t["<<m_IDs[i].vMin
67 <<","<<m_IDs[i].vMax<<"]\tnBits "<<m_IDs[i].nBits
68 <<"\tfirst Bit "<<m_IDs[i].firstBit<<std::endl;
69 }
70}

◆ Retrieve()

int HitIdHelper::Retrieve ( int id,
int first,
int field )
staticprotectedinherited

Definition at line 105 of file HitIdHelper.cxx.

106{
107 int j=0;
108 for (int i=0;i<field;i++)
109 SetBit(j,(i+first));
110 int l=id&j;
111 return l>>(first-1);
112}
static void SetBit(int &i, int bitpos)
bool first
Definition DeMoScan.py:534
l
Printing final latex table to .tex output file.

◆ SetBit()

void HitIdHelper::SetBit ( int & i,
int bitpos )
staticprotectedinherited

Definition at line 82 of file HitIdHelper.cxx.

83{
84 int l=1;
85 l<<=(bitpos-1);
86 i|=l;
87}

◆ SetFieldValue()

void HitIdHelper::SetFieldValue ( const std::string & name,
int n,
HitID & targetID ) const
inherited

Definition at line 30 of file HitIdHelper.cxx.

31{
32 for (unsigned int i=0;i<m_IDs.size();i++)
33 {
34 if (m_IDs[i].fieldName==name)
35 {
36 if (n<m_IDs[i].vMin || n>m_IDs[i].vMax)
37 std::cout<<"HitIdHelper: field "<<name<<": supplied value "<<n<<
38 " is not within the allowed range ["<<m_IDs[i].vMin<<","<<m_IDs[i].vMax
39 <<"] : the result of this action is unpredictable "<<std::endl;
40 n-=m_IDs[i].vMin;
41 Store(targetID,n,m_IDs[i].firstBit,m_IDs[i].nBits);
42 break;
43 }
44 }
45}
static void Store(int &id, int value, int first, int field)

◆ Store()

void HitIdHelper::Store ( int & id,
int value,
int first,
int field )
staticprotectedinherited

Definition at line 96 of file HitIdHelper.cxx.

97{
98 int l=0;
99 for (int i=0;i<field;i++)
100 UnsetBit(id,i+firstbit);
101 l=value<<(firstbit-1);
102 id |= l;
103}
static void UnsetBit(int &i, int bitpos)

◆ UnsetBit()

void HitIdHelper::UnsetBit ( int & i,
int bitpos )
staticprotectedinherited

Definition at line 88 of file HitIdHelper.cxx.

89{
90 int l=0;
91 SetBit(l,bitpos);
92 int k=~l;
93 i&=k;
94}

Member Data Documentation

◆ m_currentStorage

int HitIdHelper::m_currentStorage
protectedinherited

Definition at line 35 of file HitIdHelper.h.

◆ m_IDs

IdFields HitIdHelper::m_IDs
protectedinherited

Definition at line 34 of file HitIdHelper.h.

◆ m_isITkHGTD

bool SiHitIdHelper::m_isITkHGTD {}
private

Definition at line 69 of file SiHitIdHelper.h.

69{};

The documentation for this class was generated from the following files: