80{
82
84 std::string
units[8] = {
"ADC counts",
"pC",
"CspC",
"MeV",
85 "online ADC counts", "online pC", "online CspC", "online MeV" };
86
89
91 ATH_MSG_ERROR(
"Due to non-linear CIS constants noise filter is possible only with ADC counts ");
92 ATH_MSG_ERROR(
"Please, disable CIS calibration in optimal filter " );
93
94 return StatusCode::FAILURE;
95 }
96
99
100
102
103 SG::ReadCondHandle<TileEMScale> emScale(
m_emScaleKey, ctx);
105
108
111
113 TileRawChannelCollection* coll = rchCont.
indexFindPtr (hash);
114
115
122 bool ebNsp = !ebspD4 && eb;
124
125 static const int maxChannelDrawer = 48;
126 static const int maxChannel = 12;
127 static const int maxMOB = 4;
128
129 float calib[maxChannelDrawer];
130 float commonmode[maxMOB];
131 int nemptychan[maxMOB];
132 int ngoodchan[maxMOB];
133 int chanmap[maxChannelDrawer];
134 memset(calib, 0, sizeof(calib));
135 memset(commonmode, 0, sizeof(commonmode));
136 memset(nemptychan, 0, sizeof(nemptychan));
137 memset(ngoodchan, 0, sizeof(ngoodchan));
138 memset(chanmap, 0, sizeof(chanmap));
139
140
141 for (const TileRawChannel* rch : *coll) {
142 HWIdentifier adc_id = rch->adc_HWID();
143
144
145
146
147
150 int mob =
chan / maxChannel;
152
153
154 float ped=rch->pedestal();
156 || badChannels->getAdcStatus(adc_id).isBad()
157 || (!DQstatus->
isAdcDQgood(ros, drawer, chan, gain)))
continue;
158
159
162 ( ebspC10 && (
chan==4 ||
chan==5)) ||
164
166
167 if (chanmap[chan] < 2 && usechan) ++ngoodchan[mob];
168
170
171 float amp = rch->amplitude();
172 if (undoOnlCalib) {
173 calib[
chan] = emScale->undoOnlineChannelCalibration(drawerIdx, chan, gain, 1.0, rChUnit);
175 } else {
177 }
178
179
180 if (usechan) {
181
182 float noise_sigma = 1.5;
184
185
186
187
188
189 } else {
190
191 noise_sigma = sampleNoise->getHfn(drawerIdx, chan, gain);
192 }
193
194 float significance = 999.999;
195 if ((noise_sigma != 0.0)
197 ) {
198
199 significance = fabs(amp / noise_sigma);
200 } else {
201 --ngoodchan[mob];
202 }
203
205 << " calib " << 1. / calib[chan]
206 << " amp " << amp
207 << " noise " << noise_sigma
208 << " significance " << significance );
209
211
212 commonmode[mob] += amp;
213 ++nemptychan[mob];
214
215 } else {
216
218 << " calib " << 1. / calib[chan]
219 << " amp " << amp
220 << " channel is not used" );
221 }
222
223 }
224
225 int ncorr = 0;
227
228 for (
int k = 0;
k < maxMOB;
k++) {
229
232 if (nchmin < 2) nchmin = 2;
233 }
234
235 if (nemptychan[k] >= nchmin) {
236 commonmode[
k] /= nemptychan[
k];
237 ++ncorr;
238
240 << " drawer " << std::setw(2) << drawer
241 << " mb " << k << " mean " << commonmode[k]
242 << " taken from " << nemptychan[k] << " channels"
243 << " nchgood " << ngoodchan[k]
244 << " nchmin " << nchmin );
245
246 } else {
247 if (msgLvl(MSG::VERBOSE)) {
248 if (commonmode[k] != 0.0) {
249 msg(MSG::VERBOSE) <<
"ros " <<
ros
250 <<
" drawer " << std::setw(2) <<
drawer
252 <<
" mean is zero instead of " << commonmode[
k] <<
" / " << nemptychan[
k]
253 <<
" nchgood " << ngoodchan[
k]
254 << " nchmin " << nchmin
256 } else {
257 msg(MSG::VERBOSE) <<
"ros "
258 <<
ros <<
" drawer " << std::setw(2) <<
drawer
260 << " mean is zero - nothing to correct"
261 <<
" nchgood " << ngoodchan[
k]
262 << " nchmin " << nchmin
264 }
265 }
267 }
268 }
269
270 if (ncorr == 0) continue;
271
272
273 for (TileRawChannel* rch : *coll) {
276
277
279
280
281 int mob =
chan/maxChannel;
282 if (undoOnlCalib)
283 rch->setAmplitude (rch->amplitude() - commonmode[mob] / calib[chan]);
284 else
285 rch->setAmplitude (rch->amplitude() - commonmode[mob]);
286 rch->setPedestal (rch->pedestal() + commonmode[mob]);
287 }
288 }
289 }
290
291 return StatusCode::SUCCESS;
292}
#define ATH_MSG_VERBOSE(x)
static const Attributes_t empty
virtual std::vector< IdentifierHash > GetAllCurrentHashes() const override final
Returns a collection of all hashes availiable in this IDC.
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
bool isAdcDQgood(int partition, int drawer, int ch, int gain) const
returns status of single ADC returns False if there are any errors
Collection * indexFindPtr(IdentifierHash hash)
Look up a (non-const) collection via hash.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())