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

#include <MdtHitIdHelper.h>

Inheritance diagram for MdtHitIdHelper:
Collaboration diagram for MdtHitIdHelper:

Public Member Functions

std::string GetStationName (const int &hid) const
void SetStationName (const std::string &name, int &hid) const
int GetPhiSector (const int &hid) const
int GetZSector (const int &hid) const
int GetMultiLayer (const int &hid) const
int GetLayer (const int &hid) const
int GetTube (const int &hid) const
int BuildMdtHitId (const std::string &, const int, const int, const int, const int, const int) const
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 Public Member Functions

static const MdtHitIdHelperGetHelper (unsigned int nTubes=78)
static void Print (int id)

Static Protected Member Functions

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)

Protected Attributes

IdFields m_IDs
int m_currentStorage

Private Member Functions

 MdtHitIdHelper (unsigned int nTubes)
void Initialize (unsigned int nTubes)
void InitializeStationName ()

Detailed Description

Definition at line 13 of file MdtHitIdHelper.h.

Constructor & Destructor Documentation

◆ MdtHitIdHelper()

MdtHitIdHelper::MdtHitIdHelper ( unsigned int nTubes)
private

Definition at line 18 of file MdtHitIdHelper.cxx.

18 : HitIdHelper()
19{
21 Initialize(nTubes);
22}
void InitializeStationName()
void Initialize(unsigned int nTubes)

Member Function Documentation

◆ BuildMdtHitId()

int MdtHitIdHelper::BuildMdtHitId ( const std::string & statName,
const int phiSect,
const int zSect,
const int multiLayer,
const int layer,
const int tube ) const

Definition at line 95 of file MdtHitIdHelper.cxx.

97{
98 int theID(0);
99 this->SetStationName(statName, theID);
100 this->SetFieldValue("PhiSector", phiSect, theID);
101 this->SetFieldValue("ZSector", zSect, theID);
102 this->SetFieldValue("MultiLayer", multiLayer, theID);
103 this->SetFieldValue("Layer", layer, theID);
104 this->SetFieldValue("Tube", tube, theID);
105 return theID;
106}
void SetFieldValue(const std::string &name, int n, HitID &targetID) const
void SetStationName(const std::string &name, int &hid) const

◆ 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 MdtHitIdHelper * MdtHitIdHelper::GetHelper ( unsigned int nTubes = 78)
static

Definition at line 24 of file MdtHitIdHelper.cxx.

25{
26 static const MdtHitIdHelper helper(nTubes);
27 return &helper;
28}
MdtHitIdHelper(unsigned int nTubes)

◆ GetLayer()

int MdtHitIdHelper::GetLayer ( const int & hid) const

Definition at line 84 of file MdtHitIdHelper.cxx.

85{
86 return this->GetFieldValue("Layer",hid);
87}
int GetFieldValue(const std::string &name, HitID targetID) const

◆ GetMultiLayer()

int MdtHitIdHelper::GetMultiLayer ( const int & hid) const

Definition at line 79 of file MdtHitIdHelper.cxx.

80{
81 return this->GetFieldValue("MultiLayer",hid);
82}

◆ GetPhiSector()

int MdtHitIdHelper::GetPhiSector ( const int & hid) const

Definition at line 68 of file MdtHitIdHelper.cxx.

69{
70 return this->GetFieldValue("PhiSector",hid);
71}

◆ GetStationName()

std::string MdtHitIdHelper::GetStationName ( const int & hid) const

Definition at line 57 of file MdtHitIdHelper.cxx.

58{
59 char v[4];
60 v[0]=v1[this->GetFieldValue("Station[1]",hid)];
61 v[1]=v2[this->GetFieldValue("Station[2]",hid)];
62 v[2]=v3[this->GetFieldValue("Station[3]",hid)];
63 v[3]='\0';
64 std::string temp=v;
65 return temp;
66}

◆ GetTube()

int MdtHitIdHelper::GetTube ( const int & hid) const

Definition at line 89 of file MdtHitIdHelper.cxx.

90{
91 return this->GetFieldValue("Tube",hid);
92}

◆ GetZSector()

int MdtHitIdHelper::GetZSector ( const int & hid) const

Definition at line 73 of file MdtHitIdHelper.cxx.

74{
75 return this->GetFieldValue("ZSector",hid);
76}

◆ Initialize()

void MdtHitIdHelper::Initialize ( unsigned int nTubes)
private

Definition at line 30 of file MdtHitIdHelper.cxx.

31{
32 InitializeField("PhiSector",1,8);
33 InitializeField("ZSector",-8,8);
34 InitializeField("MultiLayer",1,2);
35 InitializeField("Layer",1,4);
36 InitializeField("Tube",1,nTubes);
37}
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}

◆ InitializeStationName()

void MdtHitIdHelper::InitializeStationName ( )
private

Definition at line 39 of file MdtHitIdHelper.cxx.

40{
41 InitializeField("Station[1]",0,sizeof(v1));
42 InitializeField("Station[2]",0,sizeof(v2));
43 InitializeField("Station[3]",0,sizeof(v3));
44}

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

◆ SetStationName()

void MdtHitIdHelper::SetStationName ( const std::string & name,
int & hid ) const

Definition at line 46 of file MdtHitIdHelper.cxx.

47{
48 for (unsigned int i=0;i<sizeof(v1);i++)
49 if (v1[i]==name[0]) SetFieldValue("Station[1]",i,hid);
50 for (unsigned int i=0;i<sizeof(v2);i++)
51 if (v2[i]==name[1]) SetFieldValue("Station[2]",i,hid);
52 for (unsigned int i=0;i<sizeof(v3);i++)
53 if (v3[i]==name[2]) SetFieldValue("Station[3]",i,hid);
54
55
56}

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


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