ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
MicromegasHitIdHelper Class Reference

#include <MicromegasHitIdHelper.h>

Inheritance diagram for MicromegasHitIdHelper:
Collaboration diagram for MicromegasHitIdHelper:

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 GetSide (const int &hid) const
 
int BuildMicromegasHitId (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 MicromegasHitIdHelperGetHelper ()
 
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

 MicromegasHitIdHelper ()
 
void Initialize ()
 
void InitializeStationName ()
 

Detailed Description

Definition at line 13 of file MicromegasHitIdHelper.h.

Constructor & Destructor Documentation

◆ MicromegasHitIdHelper()

MicromegasHitIdHelper::MicromegasHitIdHelper ( )
private

Definition at line 19 of file MicromegasHitIdHelper.cxx.

19  : HitIdHelper()
20 {
22  Initialize();
23 }

Member Function Documentation

◆ BuildMicromegasHitId()

int MicromegasHitIdHelper::BuildMicromegasHitId ( const std::string &  statName,
const int  phiSect,
const int  zSect,
const int  multiLayer,
const int  layer,
const int  side 
) const

Definition at line 101 of file MicromegasHitIdHelper.cxx.

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 }

◆ 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 MicromegasHitIdHelper * MicromegasHitIdHelper::GetHelper ( )
static

Definition at line 25 of file MicromegasHitIdHelper.cxx.

26 {
27  static const MicromegasHitIdHelper helper;
28  return &helper;
29 }

◆ GetLayer()

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

Definition at line 89 of file MicromegasHitIdHelper.cxx.

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

◆ GetMultiLayer()

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

Definition at line 84 of file MicromegasHitIdHelper.cxx.

85 {
86  return this->GetFieldValue("MultiLayer",hid);
87 }

◆ GetPhiSector()

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

Definition at line 73 of file MicromegasHitIdHelper.cxx.

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

◆ GetSide()

int MicromegasHitIdHelper::GetSide ( const int &  hid) const

Definition at line 94 of file MicromegasHitIdHelper.cxx.

95 {
96  return this->GetFieldValue("Side",hid);
97 }

◆ GetStationName()

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

Definition at line 61 of file MicromegasHitIdHelper.cxx.

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 }

◆ GetZSector()

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

Definition at line 78 of file MicromegasHitIdHelper.cxx.

79 {
80  return this->GetFieldValue("ZSector",hid);
81 }

◆ Initialize()

void MicromegasHitIdHelper::Initialize ( )
private

Definition at line 31 of file MicromegasHitIdHelper.cxx.

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 }

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

◆ InitializeStationName()

void MicromegasHitIdHelper::InitializeStationName ( )
private

Definition at line 41 of file MicromegasHitIdHelper.cxx.

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 }

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

◆ SetStationName()

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

Definition at line 49 of file MicromegasHitIdHelper.cxx.

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 }

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


The documentation for this class was generated from the following files:
HitIdHelper::m_IDs
IdFields m_IDs
Definition: HitIdHelper.h:34
IdField
Definition: HitIdHelper.h:13
HitIdHelper::SetFieldValue
void SetFieldValue(const std::string &name, int n, HitID &targetID) const
Definition: HitIdHelper.cxx:31
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MicromegasHitIdHelper::Initialize
void Initialize()
Definition: MicromegasHitIdHelper.cxx:31
MicromegasHitIdHelper::InitializeStationName
void InitializeStationName()
Definition: MicromegasHitIdHelper.cxx:41
HitIdHelper::InitializeField
void InitializeField(const std::string &n, int vmn, int vmx)
Definition: HitIdHelper.cxx:10
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
MicromegasHitIdHelper::SetStationName
void SetStationName(const std::string &name, int &hid) const
Definition: MicromegasHitIdHelper.cxx:49
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
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
MicromegasHitIdHelper
Definition: MicromegasHitIdHelper.h:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
HitIdHelper::HitIdHelper
HitIdHelper()
Definition: HitIdHelper.h:25
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
python.PyAthena.v
v
Definition: PyAthena.py:154
DeMoScan.first
bool first
Definition: DeMoScan.py:536
HitIdHelper::m_currentStorage
int m_currentStorage
Definition: HitIdHelper.h:35
hotSpotInTAG.nb
nb
Definition: hotSpotInTAG.py:164
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
sTgcDigitEffiDump.multiLayer
int multiLayer
Definition: sTgcDigitEffiDump.py:36
fitman.k
k
Definition: fitman.py:528