101{
103
104
107
108 SG::ReadCondHandle<TileEMScale> emScale(
m_emScaleKey, ctx);
110
113
114 const char *
part[5] = {
"AUX",
"LBA",
"LBC",
"EBA",
"EBC"};
115 const int nchan_dmu = 3;
116
118
120 TileRawChannelCollection* coll = rchCont.
indexFindPtr (hash);
121
123 ATH_MSG_DEBUG(
"drawer container does not contain all channels");
124 continue;
125 }
126
127
131
134 std::vector<int> bad_dmu;
135 if (
drawer_ok(ros, drawer, *badChannels, channel_time_ok, bad_dmu))
continue;
136 if (msgLvl(MSG::VERBOSE)) {
138 if (channel_time_ok[ch]!=0) {
140 << std::setw(2) << std::setfill('0') << drawer+1
141 << " channel " << std::setw(2) << std::setfill(' ') << ch );
142 }
143 }
144 }
145
146
147
148
149 for (int dmu : bad_dmu) {
151 int dmu_offset = dmu * nchan_dmu;
152
153
154
155
156
157
158
159 bool ch_status[nchan_dmu+1];
160 int ch_number[nchan_dmu+1];
161 float ch_amp[nchan_dmu+1];
162 float ch_time[nchan_dmu+1];
163 bool ch_mask[nchan_dmu+1];
164
165
166 int ch_p = -1, ch_0 = -1;
167 float ch_p_amp = -1000000;
168 for(
int i=0;
i < nchan_dmu; ++
i) {
169 int ch =
i+dmu_offset;
171 if ((ch_p_tmp >= 0) && (ch_p_tmp/nchan_dmu != dmu)) {
172 const TileRawChannel * rch = coll->
at(ch_p_tmp);
173 HWIdentifier adc_id = rch->
adc_HWID();
174 if (
m_tileHWID->channel(adc_id) != ch_p_tmp) {
175 ATH_MSG_ERROR(
"Channels in drawer collection are out of order");
176 continue;
177 }
180 if (channel_time_ok[ch_p_tmp]==0 &&
185 }
186 if (amp > ch_p_amp) {
187 ch_p = ch_p_tmp;
188 ch_p_amp = amp;
190 }
191 }
192 }
193 }
194 if (ch_p < 0) {
195 continue;
196 }
197
198 ch_number[0] = ch_p;
199 ch_status[0] = channel_time_ok[ch_p];
200 ch_number[1] = ch_0;
201 ch_status[1] = channel_time_ok[ch_0];
203 for(
int i=0;
i < nchan_dmu; ++
i) {
204 int ch =
i+dmu_offset;
205 if (ch != ch_0) {
207 ch_status[
index] = channel_time_ok[
ch];
209 }
210 }
211
212
213 int nprob = 0;
214 for(
int i=0;
i <= nchan_dmu; ++
i) {
215 int ch = ch_number[
i];
216 const TileRawChannel * rch = coll->
at(ch);
217 HWIdentifier adc_id = rch->
adc_HWID();
219 ATH_MSG_ERROR(
"Channels in drawer collection are out of order");
220 continue;
221 }
229 } else {
233 }
234 ch_time[
i] = rch->
time();
236 if ((i > 0) && (ch_status[i]!=0)) ++nprob;
237 }
238 }
239
240 ATH_MSG_VERBOSE(
"DMU " << dmu <<
" number of problems found " << nprob);
241 if (nprob == 0) continue;
242
243 float ene_threshold;
244 if (nprob == 1) {
246 } else {
248 }
249
250
251
252
253 bool ene_above = false;
254 for(
int i=0;
i <= nchan_dmu; ++
i) {
255 ene_above = ene_above || ((ch_number[
i] >= 0) && (std::abs(ch_amp[i]) > ene_threshold));
256 }
257 if (ene_above) {
258 ATH_MSG_VERBOSE(
"Absolute energy above threshold in at least one relevant channel");
259
260
261 bool time_dmu_same = true;
262 float time_dmu_aver = 0;
263 int n_dmu_aver = 0;
264 for(
int i=1; (
i <= nchan_dmu) && time_dmu_same; ++
i) {
266 time_dmu_aver += ch_time[
i];
267 ++n_dmu_aver;
268 for(
int j=i+1; (
j <= nchan_dmu) && time_dmu_same; ++
j) {
270 time_dmu_same = time_dmu_same &&
272 }
273 }
274 }
275 if (time_dmu_same && (n_dmu_aver != 0)) {
276 time_dmu_aver /= n_dmu_aver;
278
279 int expected_sign = 0;
280 for(
int i=1;
i <= nchan_dmu; ++
i) {
281 if (ch_number[i] >= 0) {
282 expected_sign = channel_time_ok[ch_number[
i]];
284 << std::setw(2) << std::setfill('0') << drawer+1
285 << ": " << expected_sign);
286 break;
287 }
288 }
289 bool time_offset = false;
290 switch (expected_sign)
291 {
292 case +1:
294 break;
295 case -1:
297 break;
298 }
299
301
303 << std::setw(2) << std::setfill('0') << drawer+1
304 << " ch " << std::setw(2) << std::setfill(' ') << ch_number[0]
305 << " run " << ctx.eventID().run_number()
306 << " evt " << ctx.eventID().event_number());
308
309 float sample_threshold;
310 const TileRawChannel * rch = coll->
at(ch_number[0]);
311 HWIdentifier adc_id = rch->
adc_HWID();
313 if (gain == 1) {
315 } else {
317 }
318 sample_threshold = sample_threshold - 0.5;
319 if (ref_maxmindiff > sample_threshold) {
320 for(
int i=1;
i <= nchan_dmu; ++
i) {
321 if (ch_number[i] >= 0) ch_mask[
i] =
true;
322 }
323 }
324 }
325 } else {
327 }
328 }
329
330 for(
int i=1;
i<= nchan_dmu;++
i) {
331 if ((ch_number[i] >= 0) && ch_mask[i]) {
333 << std::setw(2) << std::setfill('0') << drawer+1
334 << " ch " << std::setw(2) << std::setfill(' ') << ch_number[i]
335 << " ene " << ch_amp[i]
336 << " time " << ch_time[i]
337 << " ref_ene " << ch_amp[0]
338 << " ref_time " << ch_time[0]
339 << " run " << ctx.eventID().run_number()
340 << " evt " << ctx.eventID().event_number() );
341 coll->
at(ch_number[i])->setPedestal(fmod(coll->
at(ch_number[i])->pedestal(),10000.)+240000.0);
342 }
343 }
344 }
345 }
346
347 return StatusCode::SUCCESS;
348}
#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())
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)