ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
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 }

◆ 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(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 }

◆ 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(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 }

◆ 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 48 of file HitIdHelper.cxx.

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

◆ GetHelper()

const SiHitIdHelper * SiHitIdHelper::GetHelper ( )
static

Definition at line 19 of file SiHitIdHelper.cxx.

19  {
20  static const SiHitIdHelper helper;
21  return &helper;
22 }

◆ 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 }

◆ InitializeField() [1/2]

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

Definition at line 21 of file HitIdHelper.cxx.

22 {
23  int vmn=0;
24  int vmx=int(pow(2,nb))-1;
25  IdField id={n,vmn,vmx,nb,m_currentStorage+1};
26  m_IDs.push_back(id);
28  assert (m_currentStorage<33);
29 }

◆ 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=1;
14  while (field>pow(2,nb)) nb++;
15  IdField id={n,vmn,vmx,nb,m_currentStorage+1};
16  m_IDs.push_back(id);
18  assert (m_currentStorage<33);
19 }

◆ 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 73 of file HitIdHelper.cxx.

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

◆ PrintFields()

void HitIdHelper::PrintFields ( )
inherited

Definition at line 63 of file HitIdHelper.cxx.

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

◆ Retrieve()

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

Definition at line 106 of file HitIdHelper.cxx.

107 {
108  int j=0;
109  for (int i=0;i<field;i++)
110  SetBit(j,(i+first));
111  int l=id&j;
112  return l>>(first-1);
113 }

◆ SetBit()

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

Definition at line 83 of file HitIdHelper.cxx.

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

◆ SetFieldValue()

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

Definition at line 31 of file HitIdHelper.cxx.

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

◆ Store()

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

Definition at line 97 of file HitIdHelper.cxx.

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

◆ UnsetBit()

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

Definition at line 89 of file HitIdHelper.cxx.

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

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.


The documentation for this class was generated from the following files:
HitIdHelper::m_IDs
IdFields m_IDs
Definition: HitIdHelper.h:34
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
IdField
Definition: HitIdHelper.h:13
HitIdHelper::SetFieldValue
void SetFieldValue(const std::string &name, int n, HitID &targetID) const
Definition: HitIdHelper.cxx:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
SiHitIdHelper::m_isITkHGTD
bool m_isITkHGTD
Definition: SiHitIdHelper.h:69
HitIdHelper::InitializeField
void InitializeField(const std::string &n, int vmn, int vmx)
Definition: HitIdHelper.cxx:10
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
athena.value
value
Definition: athena.py:124
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
HitIdHelper::SetBit
static void SetBit(int &i, int bitpos)
Definition: HitIdHelper.cxx:83
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
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
LayerDisk
Definition: WaferTree.h:57
lumiFormat.i
int i
Definition: lumiFormat.py:85
HitIdHelper::Store
static void Store(int &id, int value, int first, int field)
Definition: HitIdHelper.cxx:97
beamspotman.n
n
Definition: beamspotman.py:731
HitIdHelper::UnsetBit
static void UnsetBit(int &i, int bitpos)
Definition: HitIdHelper.cxx:89
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
HitIdHelper::Retrieve
static int Retrieve(int id, int first, int field)
Definition: HitIdHelper.cxx:106
taskman.fieldName
fieldName
Definition: taskman.py:492
SiHitIdHelper
Definition: SiHitIdHelper.h:25
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
isDBM
bool isDBM(uint32_t robId)
Definition: PixelRodDecoder.cxx:45
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
HitIdHelper::HitIdHelper
HitIdHelper()
Definition: HitIdHelper.h:25
SiHitIdHelper::Initialize
void Initialize()
Definition: SiHitIdHelper.cxx:24
DeMoScan.first
bool first
Definition: DeMoScan.py:536
DetType::Part
Part
Definition: DetType.h:14
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:106
HitIdHelper::m_currentStorage
int m_currentStorage
Definition: HitIdHelper.h:35
fillSCTHists.etaMod
etaMod
Definition: fillSCTHists.py:23
pix
Definition: PixelMapping.cxx:16
SiHitIdHelper::buildHitId
int buildHitId(const int, const int, const int, const int, const int, const int) const
Definition: SiHitIdHelper.cxx:118
hotSpotInTAG.nb
nb
Definition: hotSpotInTAG.py:164
PixelID
Definition: PixelID.h:67
fitman.k
k
Definition: fitman.py:528
ServiceHandle< StoreGateSvc >