ATLAS Offline Software
Loading...
Searching...
No Matches
SiHelper.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*************************************************************************
6 SiHelper for Silicons
7 This is used by the SiDigitization
8 ---------------------------------
9 ATLAS Collaboration
10
11
12 This is a short copy of the PixelSimHelper used by the SDO.
13 It is needed to set the word of the Charged Diodes in the same
14 way as it will be registered in the SDO.
15
16 D. Costanzo 4-3-03
17***************************************************************************/
18
19
20#ifndef SIDIGITIZATION_SIHELPER_H
21#define SIDIGITIZATION_SIHELPER_H
22
23#include "GaudiKernel/MsgStream.h"
26
28{
29 public:
30 // methods to set characteristics of a new object
31
32 static void noise(SiChargedDiode& chDiode, bool flag, bool mask=false);
33 static void belowThreshold(SiChargedDiode& chDiode, bool flag, bool mask=false);
34 static void disabled(SiChargedDiode& chDiode, bool flag, bool mask=false);
35 static void badToT(SiChargedDiode& chDiode, bool flag, bool mask=false);
36 static void disconnected(SiChargedDiode& chDiode, bool flag, bool mask=false);
37 static void maskOut(SiChargedDiode& chDiode, bool flag);
38 static void ClusterUsed(SiChargedDiode& chDiode, bool flag);
39 static void SetBunch(SiChargedDiode& chDiode, int bunch, MsgStream* log=nullptr);
40 static void SetStripNum(SiChargedDiode& chDiode, int nstrip, MsgStream* log=nullptr);
41 static void SetTimeBin(SiChargedDiode& chDiode, int time, MsgStream* log=nullptr);
42
43 static bool isUsable(SiChargedDiode& chDiode);
44 static bool isNoise(SiChargedDiode& chDiode);
45 static bool isBelowThreshold(SiChargedDiode& chDiode);
46 static bool isDisabled(SiChargedDiode& chDiode);
47 static bool isBadToT(SiChargedDiode& chDiode);
48 static bool isDisconnected(SiChargedDiode& chDiode);
49 static bool isMaskOut(SiChargedDiode& chDiode);
50 static bool isClusterUsed(SiChargedDiode &chDiode);
51 static int GetBunch(SiChargedDiode& chDiode);
52 static int GetStripNum(SiChargedDiode& chDiode);
53 static int GetTimeBin(SiChargedDiode& chDiode);
54
55 private:
56 enum {
57 NOISE_SET = 0x1, // main charge is noise
58 BT_SET = 0x2, // below threshold
59 DISABLED_SET = 0x4, // disabled
60 BADTOT_SET = 0x8, // bad TOT
61 DISCONNECTED_SET = 0x10, // disconnected
62 CLUSTERUSED_SET = 0x20, // used in cluster - used by anyone???
63 MASKOUT_SET = 0x40 // charge diode is masked out, not to be used for RDO creation
64 };
65};
66
67inline void SiHelper::maskOut(SiChargedDiode& chDiode, bool flag) {
68 if (flag) {
69 chDiode.m_word |= MASKOUT_SET;
70 } else {
71 chDiode.m_word &= ~MASKOUT_SET;
72 }
73}
74
75inline void SiHelper::noise(SiChargedDiode& chDiode, bool flag, bool mask) {
76 if (flag) {
77 chDiode.m_word |= NOISE_SET;
78 } else {
79 chDiode.m_word &= ~NOISE_SET;
80 }
81 if (mask) SiHelper::maskOut(chDiode,true);
82}
83
84inline void SiHelper::belowThreshold(SiChargedDiode& chDiode, bool flag, bool mask) {
85 if (flag) {
86 chDiode.m_word |= BT_SET;
87 } else {
88 chDiode.m_word &= ~BT_SET;
89 }
90 if (mask) SiHelper::maskOut(chDiode,true);
91}
92
93inline void SiHelper::disabled(SiChargedDiode& chDiode, bool flag, bool mask) {
94 if (flag) {
95 chDiode.m_word |= DISABLED_SET;
96 } else {
97 chDiode.m_word &= ~DISABLED_SET;
98 }
99 if (mask) SiHelper::maskOut(chDiode,true);
100}
101
102inline void SiHelper::badToT(SiChargedDiode& chDiode, bool flag, bool mask) {
103 if (flag) {
104 chDiode.m_word |= BADTOT_SET;
105 } else {
106 chDiode.m_word &= ~BADTOT_SET;
107 }
108 if (mask) SiHelper::maskOut(chDiode,true);
109}
110
111inline void SiHelper::disconnected(SiChargedDiode& chDiode, bool flag, bool mask) {
112 if (flag) {
113 chDiode.m_word |= DISCONNECTED_SET;
114 } else {
115 chDiode.m_word &= ~DISCONNECTED_SET;
116 }
117 if (mask) SiHelper::maskOut(chDiode,true);
118}
119
120
121inline void SiHelper::ClusterUsed(SiChargedDiode& chDiode, bool flag) {
122 if (flag) {
123 chDiode.m_word |= CLUSTERUSED_SET;
124 } else {
125 chDiode.m_word &= ~CLUSTERUSED_SET;
126 }
127}
128
129inline void SiHelper::SetBunch(SiChargedDiode& chDiode, int bunch, MsgStream* log) {
130 //
131 // Code the bunch number in the 8 bits set corresponding to xx in xx00
132 //
133 if (bunch > 0xff) {
134 if (log) (*log) << MSG::ERROR << "Bunch Number not allowed" << endmsg;
135 }
136 chDiode.m_word = chDiode.m_word | ( (bunch&0xff) <<8 ) ;
137}
138
139inline void SiHelper::SetStripNum(SiChargedDiode& chDiode, int nstrip, MsgStream* log) {
140 //
141 // Code the number of strips in the 12 bits set corresponding to xxx in 0xxx0000
142 //
143 if (nstrip > 0xfff) {
144 if (log) (*log) << MSG::ERROR << "Number of strips not allowed" << endmsg;
145 }
146 chDiode.m_word = chDiode.m_word | ((nstrip&0xfff) << 16 ) ;
147}
148
149inline void SiHelper::SetTimeBin(SiChargedDiode& chDiode, int time, MsgStream* log) {
150 //
151 // Code the SCT Timebin number in the 3 bits set corresponding to x in x0000000
152 //
153 if (time > 0xf) {
154 if (log) (*log) << MSG::ERROR << "TimeBin not allowed" << endmsg;
155 }
156 chDiode.m_word = chDiode.m_word | ( (static_cast<unsigned int>(time)&0xf) <<28 ) ;
157}
158
160
161inline bool SiHelper::isUsable(SiChargedDiode& chDiode) {
162 return !SiHelper::isMaskOut(chDiode);
163 // return (((chDiode.m_word & 0xff) == 0) || // no special status bits sets, either track, xtalk or random noise
164 // (SiHelper::isClusterUsed(chDiode)) ); // cluster used - whatever that means - not set in digitization
165}
166
167inline bool SiHelper::isNoise(SiChargedDiode& chDiode) {
168 return (chDiode.m_word & NOISE_SET);
169}
170
171inline bool SiHelper::isMaskOut(SiChargedDiode& chDiode) {
172 return (chDiode.m_word & MASKOUT_SET);
173}
174
176 return (chDiode.m_word & BT_SET);
177}
178
180 return (chDiode.m_word & DISABLED_SET);
181}
182
183inline bool SiHelper::isBadToT(SiChargedDiode& chDiode) {
184 return (chDiode.m_word & BADTOT_SET);
185}
186
188 return (chDiode.m_word & DISCONNECTED_SET);
189}
190
192 return (chDiode.m_word & CLUSTERUSED_SET);
193}
194
195inline int SiHelper::GetBunch(SiChargedDiode& chDiode) {
196return ( (chDiode.m_word >> 8) & 0xff );
197}
198
200 return ( (chDiode.m_word >> 16) & 0xfff );
201}
202
204return ( (chDiode.m_word >> 28) & 0xf );
205}
206
207
208#endif
#define endmsg
static bool isMaskOut(SiChargedDiode &chDiode)
Definition SiHelper.h:171
static bool isBelowThreshold(SiChargedDiode &chDiode)
Definition SiHelper.h:175
static void SetBunch(SiChargedDiode &chDiode, int bunch, MsgStream *log=nullptr)
Definition SiHelper.h:129
static void disabled(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition SiHelper.h:93
static void ClusterUsed(SiChargedDiode &chDiode, bool flag)
Definition SiHelper.h:121
static bool isDisconnected(SiChargedDiode &chDiode)
Definition SiHelper.h:187
static void disconnected(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition SiHelper.h:111
static void SetTimeBin(SiChargedDiode &chDiode, int time, MsgStream *log=nullptr)
Definition SiHelper.h:149
static bool isUsable(SiChargedDiode &chDiode)
Definition SiHelper.h:161
static bool isClusterUsed(SiChargedDiode &chDiode)
Definition SiHelper.h:191
static void noise(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition SiHelper.h:75
@ NOISE_SET
Definition SiHelper.h:57
@ DISCONNECTED_SET
Definition SiHelper.h:61
@ CLUSTERUSED_SET
Definition SiHelper.h:62
@ DISABLED_SET
Definition SiHelper.h:59
@ MASKOUT_SET
Definition SiHelper.h:63
@ BADTOT_SET
Definition SiHelper.h:60
static void badToT(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition SiHelper.h:102
static void maskOut(SiChargedDiode &chDiode, bool flag)
Definition SiHelper.h:67
static int GetBunch(SiChargedDiode &chDiode)
Definition SiHelper.h:195
static void SetStripNum(SiChargedDiode &chDiode, int nstrip, MsgStream *log=nullptr)
Definition SiHelper.h:139
static int GetStripNum(SiChargedDiode &chDiode)
Definition SiHelper.h:199
static bool isNoise(SiChargedDiode &chDiode)
Definition SiHelper.h:167
static bool isBadToT(SiChargedDiode &chDiode)
Definition SiHelper.h:183
static void belowThreshold(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition SiHelper.h:84
static int GetTimeBin(SiChargedDiode &chDiode)
Definition SiHelper.h:203
static bool isDisabled(SiChargedDiode &chDiode)
Definition SiHelper.h:179
singleton-like access to IMessageSvc via open function and helper