ATLAS Offline Software
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 
27 class SiHelper
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 
67 inline 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 
75 inline 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 
84 inline 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 
93 inline 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 
102 inline 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 
111 inline 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 
121 inline 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 
129 inline 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 
139 inline 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 
149 inline 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 
161 inline 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 
167 inline bool SiHelper::isNoise(SiChargedDiode& chDiode) {
168  return (chDiode.m_word & NOISE_SET);
169 }
170 
171 inline bool SiHelper::isMaskOut(SiChargedDiode& chDiode) {
172  return (chDiode.m_word & MASKOUT_SET);
173 }
174 
176  return (chDiode.m_word & BT_SET);
177 }
178 
179 inline bool SiHelper::isDisabled(SiChargedDiode& chDiode) {
180  return (chDiode.m_word & DISABLED_SET);
181 }
182 
183 inline 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 
195 inline int SiHelper::GetBunch(SiChargedDiode& chDiode) {
196 return ( (chDiode.m_word >> 8) & 0xff );
197 }
198 
199 inline int SiHelper::GetStripNum(SiChargedDiode& chDiode) {
200  return ( (chDiode.m_word >> 16) & 0xfff );
201 }
202 
203 inline int SiHelper::GetTimeBin(SiChargedDiode& chDiode) {
204 return ( (chDiode.m_word >> 28) & 0xf );
205 }
206 
207 
208 #endif
SiHelper::DISABLED_SET
@ DISABLED_SET
Definition: SiHelper.h:71
SiChargedDiode
Definition: SiChargedDiode.h:30
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
SiHelper::BT_SET
@ BT_SET
Definition: SiHelper.h:70
SiHelper::isDisabled
static bool isDisabled(SiChargedDiode &chDiode)
Definition: SiHelper.h:179
SiHelper::noise
static void noise(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition: SiHelper.h:75
SiHelper::CLUSTERUSED_SET
@ CLUSTERUSED_SET
Definition: SiHelper.h:74
SiHelper::maskOut
static void maskOut(SiChargedDiode &chDiode, bool flag)
Definition: SiHelper.h:67
SiHelper::disabled
static void disabled(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition: SiHelper.h:93
SiChargedDiode.h
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
SiHelper::isClusterUsed
static bool isClusterUsed(SiChargedDiode &chDiode)
Definition: SiHelper.h:191
SiHelper
Definition: SiHelper.h:28
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
SiHelper::SetTimeBin
static void SetTimeBin(SiChargedDiode &chDiode, int time, MsgStream *log=nullptr)
Definition: SiHelper.h:149
SiHelper::belowThreshold
static void belowThreshold(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition: SiHelper.h:84
master.flag
bool flag
Definition: master.py:29
SiHelper::isBadToT
static bool isBadToT(SiChargedDiode &chDiode)
Definition: SiHelper.h:183
SiHelper::SetBunch
static void SetBunch(SiChargedDiode &chDiode, int bunch, MsgStream *log=nullptr)
Definition: SiHelper.h:129
SiHelper::GetTimeBin
static int GetTimeBin(SiChargedDiode &chDiode)
Definition: SiHelper.h:203
SiHelper::GetBunch
static int GetBunch(SiChargedDiode &chDiode)
Definition: SiHelper.h:195
SiHelper::isMaskOut
static bool isMaskOut(SiChargedDiode &chDiode)
Definition: SiHelper.h:171
SiHelper::ClusterUsed
static void ClusterUsed(SiChargedDiode &chDiode, bool flag)
Definition: SiHelper.h:121
SiHelper::DISCONNECTED_SET
@ DISCONNECTED_SET
Definition: SiHelper.h:73
SiChargedDiode::m_word
int m_word
Definition: SiChargedDiode.h:90
SiHelper::isNoise
static bool isNoise(SiChargedDiode &chDiode)
Definition: SiHelper.h:167
SiHelper::GetStripNum
static int GetStripNum(SiChargedDiode &chDiode)
Definition: SiHelper.h:199
SiHelper::isUsable
static bool isUsable(SiChargedDiode &chDiode)
Definition: SiHelper.h:161
SiHelper::disconnected
static void disconnected(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition: SiHelper.h:111
SiHelper::badToT
static void badToT(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition: SiHelper.h:102
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
SiHelper::MASKOUT_SET
@ MASKOUT_SET
Definition: SiHelper.h:75
SiHelper::SetStripNum
static void SetStripNum(SiChargedDiode &chDiode, int nstrip, MsgStream *log=nullptr)
Definition: SiHelper.h:139
SiHelper::isDisconnected
static bool isDisconnected(SiChargedDiode &chDiode)
Definition: SiHelper.h:187
SiHelper::BADTOT_SET
@ BADTOT_SET
Definition: SiHelper.h:72
SiHelper::isBelowThreshold
static bool isBelowThreshold(SiChargedDiode &chDiode)
Definition: SiHelper.h:175
SiHelper::NOISE_SET
@ NOISE_SET
Definition: SiHelper.h:69