81{
83
85 std::string
units[8] = {
"ADC counts",
"pC",
"CspC",
"MeV",
86 "online ADC counts", "online pC", "online CspC", "online MeV" };
87
90
92 ATH_MSG_ERROR(
"Due to non-linear CIS constants noise filter is possible only with ADC counts ");
93 ATH_MSG_ERROR(
"Please, disable CIS calibration in optimal filter " );
94
95 return StatusCode::FAILURE;
96 }
97
100
101
103
104 SG::ReadCondHandle<TileEMScale> emScale(
m_emScaleKey, ctx);
106
109
112
114 TileRawChannelCollection* coll = rchCont.
indexFindPtr (hash);
115
116
123 bool ebNsp = !ebspD4 && eb;
125
126 static const int maxChannelDrawer = 48;
127 static const int maxChannel = 12;
128 static const int maxMOB = 4;
129
130 float calib[maxChannelDrawer];
131 float commonmode[maxMOB];
132 int nemptychan[maxMOB];
133 int ngoodchan[maxMOB];
134 int chanmap[maxChannelDrawer];
135 memset(calib, 0, sizeof(calib));
136 memset(commonmode, 0, sizeof(commonmode));
137 memset(nemptychan, 0, sizeof(nemptychan));
138 memset(ngoodchan, 0, sizeof(ngoodchan));
139 memset(chanmap, 0, sizeof(chanmap));
140
141
142 for (const TileRawChannel* rch : *coll) {
143 HWIdentifier adc_id = rch->adc_HWID();
144
145
146
147
148
151 int mob =
chan / maxChannel;
153
154
155 float ped=rch->pedestal();
157 || badChannels->getAdcStatus(adc_id).isBad()
158 || (!DQstatus->
isAdcDQgood(ros, drawer, chan, gain)))
continue;
159
160
163 ( ebspC10 && (
chan==4 ||
chan==5)) ||
165
167
168 if (chanmap[chan] < 2 && usechan) ++ngoodchan[mob];
169
171
172 float amp = rch->amplitude();
173 if (undoOnlCalib) {
174 calib[
chan] = emScale->undoOnlineChannelCalibration(drawerIdx, chan, gain, 1.0, rChUnit);
176 } else {
178 }
179
180
181 if (usechan) {
182
183 float noise_sigma = 1.5;
185
186
187
188
189
190 } else {
191
192 noise_sigma = sampleNoise->getHfn(drawerIdx, chan, gain);
193 }
194
195 float significance = 999.999;
196 if ((noise_sigma != 0.0)
198 ) {
199
200 significance = fabs(amp / noise_sigma);
201 } else {
202 --ngoodchan[mob];
203 }
204
206 << " calib " << 1. / calib[chan]
207 << " amp " << amp
208 << " noise " << noise_sigma
209 << " significance " << significance );
210
212
213 commonmode[mob] += amp;
214 ++nemptychan[mob];
215
216 } else {
217
219 << " calib " << 1. / calib[chan]
220 << " amp " << amp
221 << " channel is not used" );
222 }
223
224 }
225
226 int ncorr = 0;
228
229 for (
int k = 0;
k < maxMOB;
k++) {
230
233 if (nchmin < 2) nchmin = 2;
234 }
235
236 if (nemptychan[k] >= nchmin) {
237 commonmode[
k] /= nemptychan[
k];
238 ++ncorr;
239
241 << " drawer " << std::setw(2) << drawer
242 << " mb " << k << " mean " << commonmode[k]
243 << " taken from " << nemptychan[k] << " channels"
244 << " nchgood " << ngoodchan[k]
245 << " nchmin " << nchmin );
246
247 } else {
248 if (msgLvl(MSG::VERBOSE)) {
249 if (commonmode[k] != 0.0) {
250 msg(MSG::VERBOSE) <<
"ros " <<
ros
251 <<
" drawer " << std::setw(2) <<
drawer
253 <<
" mean is zero instead of " << commonmode[
k] <<
" / " << nemptychan[
k]
254 <<
" nchgood " << ngoodchan[
k]
255 << " nchmin " << nchmin
257 } else {
258 msg(MSG::VERBOSE) <<
"ros "
259 <<
ros <<
" drawer " << std::setw(2) <<
drawer
261 << " mean is zero - nothing to correct"
262 <<
" nchgood " << ngoodchan[
k]
263 << " nchmin " << nchmin
265 }
266 }
268 }
269 }
270
271 if (ncorr == 0) continue;
272
273
274 for (TileRawChannel* rch : *coll) {
277
278
280
281
282 int mob =
chan/maxChannel;
283 if (undoOnlCalib)
284 rch->setAmplitude (rch->amplitude() - commonmode[mob] / calib[chan]);
285 else
286 rch->setAmplitude (rch->amplitude() - commonmode[mob]);
287 rch->setPedestal (rch->pedestal() + commonmode[mob]);
288 }
289 }
290 }
291
292 return StatusCode::SUCCESS;
293}
#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())