102{
104
105
108
109 SG::ReadCondHandle<TileEMScale> emScale(
m_emScaleKey, ctx);
111
114
115 const char *
part[5] = {
"AUX",
"LBA",
"LBC",
"EBA",
"EBC"};
116 const int nchan_dmu = 3;
117
119
121 TileRawChannelCollection* coll = rchCont.
indexFindPtr (hash);
122
124 ATH_MSG_DEBUG(
"drawer container does not contain all channels");
125 continue;
126 }
127
128
132
135 std::vector<int> bad_dmu;
136 if (
drawer_ok(ros, drawer, *badChannels, channel_time_ok, bad_dmu))
continue;
137 if (msgLvl(MSG::VERBOSE)) {
139 if (channel_time_ok[ch]!=0) {
141 << std::setw(2) << std::setfill('0') << drawer+1
142 << " channel " << std::setw(2) << std::setfill(' ') << ch );
143 }
144 }
145 }
146
147
148
149
150 for (int dmu : bad_dmu) {
152 int dmu_offset = dmu * nchan_dmu;
153
154
155
156
157
158
159
160 bool ch_status[nchan_dmu+1];
161 int ch_number[nchan_dmu+1];
162 float ch_amp[nchan_dmu+1];
163 float ch_time[nchan_dmu+1];
164 bool ch_mask[nchan_dmu+1];
165
166
167 int ch_p = -1, ch_0 = -1;
168 float ch_p_amp = -1000000;
169 for(
int i=0;
i < nchan_dmu; ++
i) {
170 int ch =
i+dmu_offset;
172 if ((ch_p_tmp >= 0) && (ch_p_tmp/nchan_dmu != dmu)) {
173 const TileRawChannel * rch = coll->
at(ch_p_tmp);
174 HWIdentifier adc_id = rch->
adc_HWID();
175 if (
m_tileHWID->channel(adc_id) != ch_p_tmp) {
176 ATH_MSG_ERROR(
"Channels in drawer collection are out of order");
177 continue;
178 }
181 if (channel_time_ok[ch_p_tmp]==0 &&
186 }
187 if (amp > ch_p_amp) {
188 ch_p = ch_p_tmp;
189 ch_p_amp = amp;
191 }
192 }
193 }
194 }
195 if (ch_p < 0) {
196 continue;
197 }
198
199 ch_number[0] = ch_p;
200 ch_status[0] = channel_time_ok[ch_p];
201 ch_number[1] = ch_0;
202 ch_status[1] = channel_time_ok[ch_0];
204 for(
int i=0;
i < nchan_dmu; ++
i) {
205 int ch =
i+dmu_offset;
206 if (ch != ch_0) {
208 ch_status[
index] = channel_time_ok[
ch];
210 }
211 }
212
213
214 int nprob = 0;
215 for(
int i=0;
i <= nchan_dmu; ++
i) {
216 int ch = ch_number[
i];
217 const TileRawChannel * rch = coll->
at(ch);
218 HWIdentifier adc_id = rch->
adc_HWID();
220 ATH_MSG_ERROR(
"Channels in drawer collection are out of order");
221 continue;
222 }
230 } else {
234 }
235 ch_time[
i] = rch->
time();
237 if ((i > 0) && (ch_status[i]!=0)) ++nprob;
238 }
239 }
240
241 ATH_MSG_VERBOSE(
"DMU " << dmu <<
" number of problems found " << nprob);
242 if (nprob == 0) continue;
243
244 float ene_threshold;
245 if (nprob == 1) {
247 } else {
249 }
250
251
252
253
254 bool ene_above = false;
255 for(
int i=0;
i <= nchan_dmu; ++
i) {
256 ene_above = ene_above || ((ch_number[
i] >= 0) && (std::abs(ch_amp[i]) > ene_threshold));
257 }
258 if (ene_above) {
259 ATH_MSG_VERBOSE(
"Absolute energy above threshold in at least one relevant channel");
260
261
262 bool time_dmu_same = true;
263 float time_dmu_aver = 0;
264 int n_dmu_aver = 0;
265 for(
int i=1; (
i <= nchan_dmu) && time_dmu_same; ++
i) {
267 time_dmu_aver += ch_time[
i];
268 ++n_dmu_aver;
269 for(int j=i+1; (j <= nchan_dmu) && time_dmu_same; ++j) {
271 time_dmu_same = time_dmu_same &&
273 }
274 }
275 }
276 if (time_dmu_same && (n_dmu_aver != 0)) {
277 time_dmu_aver /= n_dmu_aver;
279
280 int expected_sign = 0;
281 for(
int i=1;
i <= nchan_dmu; ++
i) {
282 if (ch_number[i] >= 0) {
283 expected_sign = channel_time_ok[ch_number[
i]];
285 << std::setw(2) << std::setfill('0') << drawer+1
286 << ": " << expected_sign);
287 break;
288 }
289 }
290 bool time_offset = false;
291 switch (expected_sign)
292 {
293 case +1:
295 break;
296 case -1:
298 break;
299 }
300
302
304 << std::setw(2) << std::setfill('0') << drawer+1
305 << " ch " << std::setw(2) << std::setfill(' ') << ch_number[0]
306 << " run " << ctx.eventID().run_number()
307 << " evt " << ctx.eventID().event_number());
309
310 float sample_threshold;
311 const TileRawChannel * rch = coll->
at(ch_number[0]);
312 HWIdentifier adc_id = rch->
adc_HWID();
314 if (gain == 1) {
316 } else {
318 }
319 sample_threshold = sample_threshold - 0.5;
320 if (ref_maxmindiff > sample_threshold) {
321 for(
int i=1;
i <= nchan_dmu; ++
i) {
322 if (ch_number[i] >= 0) ch_mask[
i] =
true;
323 }
324 }
325 }
326 } else {
328 }
329 }
330
331 for(
int i=1;
i<= nchan_dmu;++
i) {
332 if ((ch_number[i] >= 0) && ch_mask[i]) {
334 << std::setw(2) << std::setfill('0') << drawer+1
335 << " ch " << std::setw(2) << std::setfill(' ') << ch_number[i]
336 << " ene " << ch_amp[i]
337 << " time " << ch_time[i]
338 << " ref_ene " << ch_amp[0]
339 << " ref_time " << ch_time[0]
340 << " run " << ctx.eventID().run_number()
341 << " evt " << ctx.eventID().event_number() );
342 coll->
at(ch_number[i])->setPedestal(fmod(coll->
at(ch_number[i])->pedestal(),10000.)+240000.0);
343 }
344 }
345 }
346 }
347
348 return StatusCode::SUCCESS;
349}
#define ATH_MSG_VERBOSE(x)
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
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.
Collection * indexFindPtr(IdentifierHash hash)
Look up a (non-const) collection via hash.
@ OnlineMegaElectronVolts
float time(int ind=0) const
float amplitude(int ind=0) const
HWIdentifier adc_HWID(void) const
bool ch_masked_or_empty(int ros, int drawer, int channel, int gain, const TileBchStatus &chStatus, const TileDQstatus *DQstatus, const TileDCSState *dcsState) const
float ref_digits_maxmindiff(int ros, int drawer, int ref_channel) const
bool drawer_ok(int ros, int drawer, const TileBadChannels *badChannels, std::vector< int > &channel_time_ok, std::vector< int > &bad_dmu) const
int find_partner(int ros, int channel) const
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())