ATLAS Offline Software
Loading...
Searching...
No Matches
LArOnlineID_Base.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9#include "IdDict/IdDictMgr.h"
10#include "IdDict/IdDictRegion.h"
14#include <cmath>
15#include <set>
16#include <sstream>
17#include <string>
18
19/* MAY-17-04:*/
20/* AL added init_hashes for calib lines */
21/* */
22/* FEB-25-04: */
23/* AL removed H6_channel_vec, H8_channel_vec and associated methods/iterators*/
24/* replaced init_H8channelHashes by init_H8hashes */
25/* replaced init_H6channelHashes by init_H6hashes */
26/* removed init_H6febHashes and init_H8febHashes */
27/* Choice of the init_hashes method NOW based on the "version" ID taken from */
28/* the Dictionary */
29/* FEB-16-04: */
30/* AL added access to TestBeamH8 Channels via init_H8hashes */
31/* added access to TestBeamH6 Channels via init_H6hashes*/
32/* added access to TestBeamH8 febs via init_H8hashes */
33/* added access to TestBeamH6 febs via init_H6hashes*/
34/* */
35/* FEB-12-04: */
36/* FLG improved check_ids methods */
37/* */
38/* Set of instances developped in the following: */
39/* LAronline_ID::destructor & constructor */
40/* LArOnlineID::feedthroughContext() */
41/* LArOnlineID::channelContext() */
42/* LArOnlineID::initialize_from_dictionary(IdDictMgr&) */
43/* LArOnlineID::get_expanded_id(HWIdentifier, ExpandedIdentifier, IdContext)*/
44/* LArOnlineID::initLevelsFromDict() */
45/* LArOnlineID::init_hashes() */
46/* LArOnlineID::init_H8hashes() */
47/* LArOnlineID::init_H6hashes() */
48
49LArOnlineID_Base::LArOnlineID_Base(const std::string& name,
50 const std::string& group,
51 bool is_slar) :
55 m_lar_index(999),
57 m_bec_index(999),
58 m_side_index(999),
60 m_slot_index(999),
62 m_slar_index(999),
63 m_dict(nullptr),
65 m_febHashMax(0),
69{
70}
71
72
74
75
76//==================================================================
78//==================================================================
79 std::string result;
80 int ft = feedthrough(id);
81 if( barrel_ec(id)== 0 ){
82 // if BARREL
83 if( pos_neg(id) == 1 ){
84 // if EMBA
85 if( ft==31 ){result = "I01R";}
86 if( ft==0 ){result = "I01L";}
87 if( ft==1 ){result = "I02R";}
88 if( ft==2 ){result = "I02L";}
89 if( ft==3 ){result = "I03R";}
90 if( ft==4 ){result = "I03L";}
91 if( ft==5 ){result = "I04R";}
92 if( ft==6 ){result = "I04L";}
93 if( ft==7 ){result = "I05R";}
94 if( ft==8 ){result = "I05L";}
95 if( ft==9 ){result = "I06R";}
96 if( ft==10 ){result = "I06L";}
97 if( ft==11 ){result = "I07R";}
98 if( ft==12 ){result = "I07L";}
99 if( ft==13 ){result = "I08R";}
100 if( ft==14 ){result = "I08L";}
101 if( ft==15 ){result = "I09R";}
102 if( ft==16 ){result = "I09L";}
103 if( ft==17 ){result = "I10R";}
104 if( ft==18 ){result = "I10L";}
105 if( ft==19 ){result = "I11R";}
106 if( ft==20 ){result = "I11L";}
107 if( ft==21 ){result = "I12R";}
108 if( ft==22 ){result = "I12L";}
109 if( ft==23 ){result = "I13R";}
110 if( ft==24 ){result = "I13L";}
111 if( ft==25 ){result = "I14R";}
112 if( ft==26 ){result = "I14L";}
113 if( ft==27 ){result = "I15R";}
114 if( ft==28 ){result = "I15L";}
115 if( ft==29 ){result = "I16R";}
116 if( ft==30 ){result = "I16L";}
117 }
118 else{
119 // EMBC
120 if( ft==15 ){result = "H01R";}
121 if( ft==16 ){result = "H01L";}
122 if( ft==13 ){result = "H02R";}
123 if( ft==14 ){result = "H02L";}
124 if( ft==11 ){result = "H03R";}
125 if( ft==12 ){result = "H03L";}
126 if( ft==9 ){result = "H04R";}
127 if( ft==10){result = "H04L";}
128 if( ft==7 ){result = "H05R";}
129 if( ft==8 ){result = "H05L";}
130 if( ft==5 ){result = "H06R";}
131 if( ft==6 ){result = "H06L";}
132 if( ft==3 ){result = "H07R";}
133 if( ft==4 ){result = "H07L";}
134 if( ft==1 ){result = "H08R";}
135 if( ft==2 ){result = "H08L";}
136 if( ft==31){result = "H09R";}
137 if( ft==0 ){result = "H09L";}
138 if( ft==29 ){result = "H10R";}
139 if( ft==30 ){result = "H10L";}
140 if( ft==27 ){result = "H11R";}
141 if( ft==28 ){result = "H11L";}
142 if( ft==25 ){result = "H12R";}
143 if( ft==26 ){result = "H12L";}
144 if( ft==23 ){result = "H13R";}
145 if( ft==24 ){result = "H13L";}
146 if( ft==21 ){result = "H14R";}
147 if( ft==22 ){result = "H14L";}
148 if( ft==19 ){result = "H15R";}
149 if( ft==20 ){result = "H15L";}
150 if( ft==17 ){result = "H16R";}
151 if( ft==18 ){result = "H16L";}
152 }
153 }
154 if ( barrel_ec(id) == 1 ){
155 // ENDCAP
156 if( pos_neg(id) == 1 ){
157 // EMEC-A
158 if( ft==0 ){result = "A01R";}
159 if( ft==1 ){result = "A01L";}
160 if( ft==2 ){result = "A02R";}
161 if( ft==3 ){result = "A02L";}
162 if( ft==4 ){result = "A03R";}
163 if( ft==5 ){result = "A03L";}
164 if( ft==6 ){result = "A04R";}
165 if( ft==7 ){result = "A05R";}
166 if( ft==8 ){result = "A05L";}
167 if( ft==9 ){result = "A06R";}
168 if( ft==10){result = "A06L";}
169 if( ft==11){result = "A07R";}
170 if( ft==12){result = "A07L";}
171 if( ft==13){result = "A08R";}
172 if( ft==14){result = "A08L";}
173 if( ft==15){result = "A09R";}
174 if( ft==16){result = "A09L";}
175 if( ft==17){result = "A10R";}
176 if( ft==18){result = "A10L";}
177 if( ft==19){result = "A11R";}
178 if( ft==20){result = "A11L";}
179 if( ft==21){result = "A12R";}
180 if( ft==22){result = "A12L";}
181 if( ft==23){result = "A13R";}
182 if( ft==24){result = "A13L";}
183 if( ft==25){result = "A14R";} // ft25-27 are sFCal; A14R, A14L, A15L
184 if( ft==26){result = "A14L";} // will need to be replaced by actual
185 if( ft==27){result = "A15L";} // crate name once it exists
186 }
187 else{
188 // EMEC-C
189 if( ft==11 ){result = "C01R";}
190 if( ft==12 ){result = "C01L";}
191 if( ft==9 ){result = "C02R";}
192 if( ft==10 ){result = "C02L";}
193 if( ft==7 ){result = "C03R";}
194 if( ft==8 ){result = "C03L";}
195 if( ft==4 ){result = "C05R";}
196 if( ft==5 ){result = "C05L";}
197 if( ft==2 ){result = "C06R";}
198 if( ft==3 ){result = "C06L";}
199 if( ft==0 ){result = "C07R";}
200 if( ft==1 ){result = "C07L";}
201 if( ft==23 ){result = "C08R";}
202 if( ft==24 ){result = "C08L";}
203 if( ft==21 ){result = "C09R";}
204 if( ft==22 ){result = "C09L";}
205 if( ft==19 ){result = "C10R";}
206 if( ft==20 ){result = "C10L";}
207 if( ft==17 ){result = "C11R";}
208 if( ft==18 ){result = "C11L";}
209 if( ft==15 ){result = "C12R";}
210 if( ft==16 ){result = "C12L";}
211 if( ft==13 ){result = "C13R";}
212 if( ft==14 ){result = "C13L";}
213 if( ft==6 ){result = "C04L";}
214 if( ft==25 ){result = "C14R";} // ft25-27 are sFCal; C14R, C14L, C15L
215 if( ft==26 ){result = "C14L";} // will need to be replaced by actual
216 if( ft==27 ){result = "C15L";} // crate name once it exists
217 }
218 }
219 return result;
220}
221
222//==================================================================
223std::string LArOnlineID_Base::channel_name( const HWIdentifier id )const{
224//==================================================================
225 return std::format("{}/{}-SIDE/FT-{}/SLOT-{}/CHAN-{}",
226 barrel_ec(id)==0 ? "BARREL" : "ENDCAP", pos_neg(id)==1 ? "A" : "C",feedthrough(id),slot(id),channel(id));
227}
228
229
230
231/* =================================================================== */
233/* =================================================================== */
234{
236 return (IdContext(id, 0, m_side_index));
237}
238
239
240
241/* =================================================================== */
243/* =================================================================== */
244{
246 return (IdContext(id, 0, m_feedthrough_index));
247}
248
249
250
251
252/* =================================================================== */
254/* =================================================================== */
255{
257 return (IdContext(id, 0, m_channel_in_slot_index));
258}
259
260
261
262/* =================================================================== */
264/* =================================================================== */
265{
267 return (IdContext(id, 0, m_slot_index));
268}
269
270
271
272/* =================================================================== */
274/* =================================================================== */
275{
276
277 ExpandedIdentifier expId;
278 IdContext context = channelContext();
279 if(!get_expanded_id(channelId, expId, &context)) {
280 int result = -999;
281 for (unsigned int i = 0; i < m_full_laronline_range.size(); ++i) {
282 const Range& range = m_full_laronline_range[i];
283 if (range.match(expId)) {
284 const Range::field& channel_in_slot_field = range[m_channel_in_slot_index];
285 if (!channel_in_slot_field.empty()) {
286 int channel_in_slotmax = channel_in_slot_field.get_maximum();
287 if (result < channel_in_slotmax) result = channel_in_slotmax + 1;
288 }
289 }
290 }
291 return (result);
292 }
293 return (-999); // default
294}
295
296
297
298
299
300/* =================================================================== */
302/* =================================================================== */
303{
304 ATH_MSG_INFO("initialize_from_dictionary");
305
306 // Check whether this helper should be reinitialized
307 if (!reinitialize(dict_mgr)) {
308 ATH_MSG_DEBUG("Request to reinitialize not satisfied - tags have not changed");
309 return (0);
310 }
311 else {
312 ATH_MSG_DEBUG("(Re)initialize");
313 }
314
315 // init base object
316 if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1);
317 m_dict = dict_mgr.find_dictionary ("LArCalorimeter");
318 if(!m_dict) {
319 ATH_MSG_ERROR("initialize_from_dictionary - cannot access LArCalorimeter dictionary");
320 return 1;
321 }
322
323 // Register version of the dictionary used
324 if (register_dict_tag(dict_mgr, "LArCalorimeter")) return(1);
325
326 // initialize dictionary version
327 AtlasDetectorID::setDictVersion(dict_mgr, "LArCalorimeter");
328
329 /* Initialize the field indices */
330// if(initLevelsFromDict()) return (1);
331 if(initLevelsFromDict(group())) return (1);
332
333
334 /* Find value for the field LAr Calorimeter */
335 const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS");
336 int larField = -1;
337 if (atlasDict->get_label_value("subdet", "LArCalorimeter", larField)) {
338 ATH_MSG_ERROR("Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary "
339 << atlasDict->name());
340 return (1);
341 }
342
343 /* Find value for the field LArOnline */
344 int larOnlineField = -4;
345 if (m_dict->get_label_value("part", "LArOnline", larOnlineField)) {
346 ATH_MSG_ERROR("Could not get value for label 'LArOnline' of field 'part' in dictionary "
347 << m_dict->name());
348 return (1);
349 }
350
351 /* Find value for the field calibLArOnline */
352 int larOnlineCalibField = -5;
353 if (m_dict->get_label_value("part", "LArOnlineCalib", larOnlineCalibField)) {
354 ATH_MSG_ERROR("Could not get value for label 'LArOnlineCalib' of field 'part' in dictionary "
355 << m_dict->name());
356 return (1);
357 }
358
359 /* Set up id for Region and range prefix */
360 ExpandedIdentifier region_id;
361 region_id.add(larField);
362 region_id.add(larOnlineField);
363 Range prefix;
364 /* Calib Multirange */
365 ExpandedIdentifier region_id2;
366 region_id2.add(larField);
367 region_id2.add(larOnlineCalibField);
368 Range prefix2;
369
370 /*Full range for all channels*/
371 m_full_laronline_range = m_dict->build_multirange( region_id , group(), prefix);
372 m_full_feb_range = m_dict->build_multirange( region_id , group(), prefix, "slot");
373 m_full_feedthrough_range = m_dict->build_multirange( region_id , group(), prefix, "feedthrough");
374
375 ATH_MSG_DEBUG("initialize_from_dictionary :");
376 ATH_MSG_DEBUG("feedthrough range -> " << (std::string)m_full_feedthrough_range);
377 ATH_MSG_DEBUG("feedthrough slot range -> " << (std::string)m_full_feb_range);
378 ATH_MSG_DEBUG("channel range -> " << (std::string)m_full_laronline_range);
379
380 /* calib */
381 /* Full range for calib channels */
382 m_full_calib_laronline_range = m_dict->build_multirange( region_id2 , group(), prefix2);
383 m_full_calib_module_range = m_dict->build_multirange( region_id2 , group(), prefix2, "slot");
384
385 ATH_MSG_DEBUG("=> initialize_from_dictionary : ");
386 ATH_MSG_DEBUG("=> Calib module range -> " << (std::string)m_full_calib_module_range);
387 ATH_MSG_DEBUG("=> Calib channel range -> " << (std::string)m_full_calib_laronline_range);
388
389 /* Setup the hash tables */
390 ATH_MSG_DEBUG("[initialize_from_dictionary] version= " << dictionaryVersion());
391 if( dictionaryVersion() == "fullAtlas" ) {
392 if(init_hashes()) return (1);
393 }
394
395 // Setup for hash calculation for channels (febs is further below)
396
397 // Febs have a uniform number of channels
398 // The lookup table only needs to contain the
399 // hash offset for each feb
400
401 // The implementation requires:
402
403 // 1) a lookup table for each feb containing hash offset
404 // 2) a decoder to access the "index" corresponding to the
405 // bec/side/ft/slot fields. These fields use x bits, so the
406 // vector has a length of 2**x.
407
408 /* Create decoder for fields bec to slot */
410 m_bec_impl.bits() +
411 m_side_impl.bits() +
412 m_feedthrough_impl.bits() +
413 m_slot_impl.bits();
414 IdDictFieldImplementation::size_type bits_offset = m_bec_impl.bits_offset();
415 m_bec_slot_impl.set_bits(bits, bits_offset);
416 int size = (1 << bits);
417
418 // Set up vector as lookup table for hash calculation.
419 m_chan_hash_calcs.resize(size);
420
421 for (unsigned int i = 0; i < m_febHashMax; ++i) {
422
423 HWIdentifier febId = feb_Id(i) ;
424
425 HashCalc hc;
426
427 HWIdentifier min = channel_Id ( febId, 0);
428
430 hc.m_hash = min_hash;
432
433 if (m_bec_slot_impl.unpack(min) >= size) {
434 ATH_MSG_DEBUG("Min > " << size);
436 ATH_MSG_DEBUG(" " << std::to_string(m_bec_slot_impl.unpack(min)));
437 }
438 }
439
440 // Check channel hash calculation
441 for (unsigned int i = 0; i < m_channelHashMax; ++i) {
442 HWIdentifier id = channel_Id(i);
443 if (channel_Hash(id) != i) {
444 ATH_MSG_ERROR(" ***** Error channel ranges, id, hash, i = " << show_to_string(id));
445 ATH_MSG_ERROR(" , " << std::to_string(channel_Hash(id)));
446 ATH_MSG_ERROR(" , " << i);
447 }
448 }
449
450
451
452 // Setup for hash calculation for febs
453
454 // We calculate the feb hash by saving the hash of each
455 // feedthrough in a HashCalc object and then adding on the slot
456 // number for a particular feb
457
458 // The implementation requires:
459
460 // 1) a lookup table for each ft containing hash offset
461 // 2) a decoder to access the "index" corresponding to the
462 // bec/side/ft fields. These fields use x bits, so the
463 // vector has a length of 2**x.
464
465 /* Create decoder for fields bec to ft */
466 bits = m_bec_impl.bits() +
467 m_side_impl.bits() +
468 m_feedthrough_impl.bits();
469 bits_offset = m_bec_impl.bits_offset();
470 m_bec_ft_impl.set_bits(bits, bits_offset);
471 size = (1 << bits);
472
473 // Set up vector as lookup table for hash calculation.
474 m_feb_hash_calcs.resize(size);
475
476 // Get context for conversion to expanded ids
477 IdContext ftContext = feedthroughContext();
478 ExpandedIdentifier ftExpId;
479
480 for (unsigned int i = 0; i < m_feedthroughHashMax; ++i) {
481
483
484 HashCalcFeb hc;
485
486 // Set the hash id for each feedthrough, and then check if one
487 // needs to also save the slot values
489 hc.m_hash = min_hash;
490
491 // For each feedthrough we must check to see if the slot
492 // values are enumerated or not. If they are enumerate we must
493 // save the values in order to calculate the fed hash
494 if (get_expanded_id(min, ftExpId, &ftContext)) {
495 ATH_MSG_WARNING(" ***** Warning cannot get ft expanded id for " + show_to_string(min));
496 }
497 unsigned int nrangesFound = 0;
498 for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) {
499 if (m_full_feb_range[i].match(ftExpId)) {
500 nrangesFound += 1;
501 const Range::field& slotField = m_full_feb_range[i][m_slot_index];
502 if (slotField.isEnumerated()) {
503 // save values
504 hc.m_slot_values = slotField.get_values();
505 }
506 }
507 }
508
509 // Similarly, if there is more than one range per feedthrough,
510 // this means that slot values are not a continuous range. In
511 // this case, as well, we save all possible slot values
512 if (nrangesFound > 1) {
513 for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) {
514 if (m_full_feb_range[i].match(ftExpId)) {
515 const Range::field& slotField = m_full_feb_range[i][m_slot_index];
516 if (slotField.isBounded()) {
517 // save values
518 unsigned int nvalues = slotField.get_maximum() - slotField.get_minimum() + 1;
519 hc.m_slot_values.reserve(std::max(hc.m_slot_values.size()*3/2, hc.m_slot_values.size() + nvalues));
520 for (unsigned int j = 0; j < nvalues; ++j) {
521 hc.m_slot_values.push_back(j + slotField.get_minimum());
522 }
523 }
524 else {
525 ATH_MSG_WARNING(" ***** Warning feb range slot field is NOT both_bounded - id, slot mode: " +
526 show_to_string(min) + " enumerated");
527 }
528 }
529 }
530 }
531
532
533 // Set hash calculator
534 m_feb_hash_calcs[m_bec_ft_impl.unpack(min)] = std::move(hc);
535
536
537 if (m_bec_ft_impl.unpack(min) >= size) {
538 ATH_MSG_DEBUG("Min > " << size << " " << show_to_string(min) <<
539 " " << m_bec_ft_impl.unpack(min) << " " <<
540 min_hash);
541 }
542 }
543
544 // Check feb hash calculation
545 for (unsigned int i = 0; i < m_febHashMax; ++i) {
546 HWIdentifier id = feb_Id(i);
547 if (feb_Hash(id) != i) {
548 ATH_MSG_ERROR(" ***** Error feb ranges, id, hash, i = " <<
549 show_to_string(id) << " , " << feb_Hash(id) << " , " << i);
550 }
551 }
552
553 return 0;
554}
555
556
557
558/* ================================================================*/
560 int slot, int channel ) const
561/* ================================================================*/
562{
563 // Check that id is within allowed range
564 // Fill expanded id
567 if ( m_this_is_slar ) expId << 1;
568
569 if (!m_full_laronline_range.match(expId)) {
570 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks() result is not OK: ID, range = "
571 + std::string(expId) + " , " + (std::string)m_full_laronline_range;
572 LArOnlID_Exception except(errorMessage , 99);
573 throw except ;
574 }
575}
576
577/* ================================================================*/
579 int channel ) const
580/* ================================================================*/
581{
582 // Check that id is within allowed range
583 // Fill expanded id
584 ExpandedIdentifier expId;
585 IdContext context = febContext();
586 if (get_expanded_id(febId, expId, &context)) {
587 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks(febId) result is not OK: ID = "
588 + show_to_string(febId) ;
589 LArOnlID_Exception except(errorMessage , 99);
590 throw except ;
591 }
592
593 expId << channel;
594 if ( m_this_is_slar ) expId << 1;
595 if (!m_full_laronline_range.match(expId)) {
596 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks(febId) result is not OK: ID, range = "
597 + std::string(expId) + " , " + (std::string)m_full_laronline_range;
598 LArOnlID_Exception except(errorMessage , 99);
599 throw except ;
600 }
601}
602
603/* ================================================================*/
605 int slot, int channel ) const
606/* ================================================================*/
607{
608 // Check that id is within allowed range
609 // Fill expanded id
610 ExpandedIdentifier expId;
611 IdContext context = feedthroughContext();
612 if (get_expanded_id(feedthroughId, expId, &context)) {
613 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks(feedthroughId) result is not OK: ID = "
614 + show_to_string(feedthroughId) ;
615 LArOnlID_Exception except(errorMessage , 99);
616 throw except ;
617 }
618
619 expId << slot << channel;
620 if ( m_this_is_slar ) expId << 1;
621 if (!m_full_laronline_range.match(expId)) {
622 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks(feedthroughId) result is not OK: ID, range = "
623 + std::string(expId) + " , " + (std::string)m_full_laronline_range;
624 LArOnlID_Exception except(errorMessage , 99);
625 throw except ;
626 }
627}
628
629/* ================================================================*/
631/* ================================================================*/
632{
633 // Check that id is within allowed range
634 // Fill expanded id
637
638 if ( m_this_is_slar ) expId << 0 << 1;
639 if (!m_full_feedthrough_range.match(expId)) { std::string errorMessage = "LArOnlineID_Base::feb_Id_checks() result is not OK: ID, range = "
640 + std::string(expId) + " , " + (std::string)m_full_feb_range;
641 LArOnlID_Exception except(errorMessage , 99);
642 throw except ;
643 }
644}
645
646/* ================================================================*/
648/* ==============================================================================*/
649{
650 // Check that id is within allowed range
651 // Fill expanded id
653 expId << s_lar_online_field_value << barrel_ec << pos_neg << feedthrough << 0 << 0 << (int)m_this_is_slar;
654
655// if ( m_this_is_slar ) expId << 0 << 0 << 1;
656 if (!m_full_feedthrough_range.match(expId)) { std::string errorMessage = "LArOnlineID_Base::feedthrough_Id_checks() result is not OK: ID, range = "
657 + std::string(expId) + " , " + (std::string)m_full_feedthrough_range;
658 LArOnlID_Exception except(errorMessage , 99);
659 throw except ;
660 }
661}
662
663
664
665/* =================================================================================*/
667 const IdContext* context) const
668/*==================================================================================*/
669{
670 // We assume that the context is >= feedthrough
671 exp_id.clear();
672 exp_id << lar_field_value()
674 << barrel_ec(id)
675 << pos_neg(id);
676 if(context && context->end_index() >= m_feedthrough_index) {
677 exp_id << feedthrough(id);
678 if(context && context->end_index() >= m_slot_index) {
679 exp_id << slot(id);
680 if(context->end_index() >= m_channel_in_slot_index) {
681 exp_id << channel(id);
682 if(context->end_index() >= m_slar_index) {
683 exp_id << is_slar(id);
684 }
685 }
686 }
687 }
688 return (0);
689}
690
691
692/* =================================================================================*/
694 const IdContext* context) const
695/*==================================================================================*/
696{
697 // We assume that the context is >= feedthrough
698 exp_id.clear();
699 exp_id << lar_field_value()
701 << barrel_ec(id)
702 << pos_neg(id)
703 << feedthrough(id);
704 if(context && context->end_index() >= m_slot_index) {
705 exp_id << slot(id);
706 if(context->end_index() >= m_channel_in_slot_index) {
707 exp_id << channel(id);
708 if(context->end_index() >= m_slar_index) {
709 exp_id << is_slar(id);
710 }
711 }
712 }
713 return (0);
714}
715
716
717
718/*======================================*/
719int LArOnlineID_Base::initLevelsFromDict(const std::string& group_name)
720/*======================================*/
721{
722
723 if(!m_dict)
724 {
725 ATH_MSG_ERROR("initLevelsFromDict - dictionary NOT initialized");
726 return (1);
727 }
728
729 /* Find out which identifier field corresponds to each level.*/
730
731 m_lar_index = 999 ;
732 m_laronline_index = 999 ;
733 m_bec_index = 999 ;
734 m_side_index = 999 ;
735 m_feedthrough_index = 999 ;
736 m_slot_index = 999 ;
738 m_slar_index = 999 ;
739
740 // Save index to a DictionaryRegion for unpacking
741 const IdDictRegion* reg = m_dict->find_region("laronline-barrel");
742 if (reg)
743 {
744 m_laronlineRegion_index = reg->index();
745 }
746 else
747 {
748 ATH_MSG_ERROR("initLevelsFromDict - unable to find laronline region ");
749 return (1);
750 }
751 /* Find LAr field */
752 const IdDictField* field = m_dict->find_field("subdet") ;
753 if (field)
754 {
755 m_lar_index = field->index();
756 }
757 else
758 {
759 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'subdet' field ");
760 return (1);
761 }
762
763 /* Find LArOnline field */
764 field = m_dict->find_field("part") ;
765 if (field)
766 {
767 m_laronline_index = field->index();
768 }
769 else
770 {
771 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'part' field ");
772 return (1);
773 }
774
775 /* Find barrel-endcap field */
776 field = m_dict->find_field("barrel-ec") ;
777 if (field)
778 {
779 m_bec_index = field->index();
780 }
781 else
782 {
783 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'barrel-endcap' field ");
784 return (1);
785 }
786
787 /* Find detector-side field */
788 field = m_dict->find_field("pos_neg") ;
789 if (field)
790 {
791 m_side_index = field->index();
792 }
793 else
794 {
795 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'barrel-endcap' field ");
796 return (1);
797 }
798
799 /* Find feedthrough field */
800 std::string feedthrough_name;
801 if ( m_this_is_slar ){
802 feedthrough_name+="slar_feedthrough";
803 } else {
804 feedthrough_name+="feedthrough";
805 }
806 field = m_dict->find_field(feedthrough_name) ;
807 if (field) {
808 m_feedthrough_index = field->index();
809 }
810 else
811 {
812 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'feedthrough' field ");
813 return (1);
814 }
815
816 /* Find slot field */
817 std::string slot_name;
818 if ( m_this_is_slar ){
819 slot_name+="slar_slot";
820 } else {
821 slot_name+="slot";
822 }
823 field = m_dict->find_field(slot_name) ;
824 if (field)
825 {
826 m_slot_index = field->index();
827 }
828 else
829 {
830 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'slot' field ");
831 return (1);
832 }
833
834 /* Find channel_in_slot field */
835 std::string channel_name;
836 if ( m_this_is_slar ){
837 channel_name+="sch_in_slot";
838 } else {
839 channel_name+="channel_in_slot";
840 }
841 field = m_dict->find_field(channel_name) ;
842 if (field)
843 {
844 m_channel_in_slot_index = field->index();
845 }
846 else
847 {
848 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'channel_in_slot' field ");
849 return (1);
850 }
851
852 /* Find slar field */
853 if ( m_this_is_slar ) {
854 field = m_dict->find_field("is-slar") ;
855 if (field)
856 {
857 m_slar_index = field->index();
858 }
859 else
860 {
861 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'slar' field ");
862 return (1);
863 }
864 } // end of m_this_is_slar
865
866 /* Set the field implementations */
867
868 const IdDictGroup* group = m_dict->find_group(group_name);
869 if ( !group ) {
870 ATH_MSG_ERROR("initLevelsFromDict - cannot find " << group_name);
871 } else {
872 m_laronlineRegion_index = group->region(0).index();
873 }
874
875 const IdDictRegion& region = m_dict->region(m_laronlineRegion_index);
876
884 if ( m_this_is_slar )
886
887 ATH_MSG_DEBUG("decode index and bit fields for each level:");
888 ATH_MSG_DEBUG("lar " << m_lar_impl);
889 ATH_MSG_DEBUG("online " << m_laronline_impl);
890 ATH_MSG_DEBUG("bec " << m_bec_impl);
891 ATH_MSG_DEBUG("side " << m_side_impl);
893 ATH_MSG_DEBUG("slot " << m_slot_impl);
895 if ( m_this_is_slar )
896 ATH_MSG_DEBUG("is-slar " << m_slar_impl);
897
898 return(0) ;
899}
900
901
902
903/*======================================*/
905/*======================================*/
906{
907 /* channel hash */
910 unsigned int nids = 0;
911 std::set<HWIdentifier> ids;
912 for (unsigned int i = 0; i < m_full_laronline_range.size(); ++i)
913 {
914 const Range& range = m_full_laronline_range[i];
915 ConstRangeIterator rit(range);
916 for (const auto & exp_id : rit)
917 {
918 HWIdentifier id = this->channel_Id (exp_id[m_bec_index],
919 exp_id[m_side_index],
920 exp_id[m_feedthrough_index],
921 exp_id[m_slot_index],
923 if(!(ids.insert(id)).second)
924 {
925 ATH_MSG_ERROR("init_hashes: duplicated id for channel nb = " + std::to_string(nids));
926 ATH_MSG_ERROR("expanded Id= " + show_to_string(id));
927 }
928 nids++;
929 }
930 }
931 if(ids.size() != m_channelHashMax)
932 {
933 ATH_MSG_ERROR("init_hashes: set size NOT EQUAL to hash max. size " + std::to_string(ids.size()));
934 ATH_MSG_ERROR("hash max " + std::to_string(m_channelHashMax));
935 return (1);
936 }
937 nids=0;
938 std::set<HWIdentifier>::const_iterator first = ids.begin();
939 std::set<HWIdentifier>::const_iterator last = ids.end();
940 for (;first != last && nids < m_channel_vec.size(); ++first)
941 {
942 m_channel_vec[nids] = (*first) ;
943 nids++;
944 }
945
946 /* feedthrough hash */
949 nids = 0;
950 ids.clear();
951 for (unsigned int i = 0; i < m_full_feedthrough_range.size(); ++i)
952 {
953 const Range& range = m_full_feedthrough_range[i];
954 ConstRangeIterator rit(range);
955 for (const auto & exp_id: rit) {
956 HWIdentifier feedthroughId = feedthrough_Id( exp_id[m_bec_index],
957 exp_id[m_side_index],
958 exp_id[m_feedthrough_index] );
959 if(!(ids.insert(feedthroughId)).second){
960 ATH_MSG_ERROR("init_hashes: duplicated id for feedthrough nb = " + std::to_string(nids));
961 ATH_MSG_ERROR("expanded Id= " + show_to_string(feedthroughId));
962 }
963 nids++;
964 }
965 }
966 if(ids.size() != m_feedthroughHashMax)
967 {
968 ATH_MSG_ERROR("init_hashes: set size NOT EQUAL to feedthrough hash max. size " + std::to_string(ids.size()));
969 ATH_MSG_ERROR("hash max= " + std::to_string(m_feedthroughHashMax));
970 return (1);
971 }
972 nids=0;
973 first = ids.begin();
974 last = ids.end();
975 for (;first != last && nids < m_feedthrough_vec.size(); ++first)
976 {
977 m_feedthrough_vec[nids] = (*first) ;
978 nids++;
979 }
980
981 /* FEB hash */
982 /*==========*/
983 m_febHashMax = m_full_feb_range.cardinality();
984 m_feb_vec.resize(m_febHashMax);
985 nids = 0;
986 ids.clear();
987 for (unsigned int i = 0; i < m_full_feb_range.size(); ++i)
988 {
989 const Range& range = m_full_feb_range[i];
990 ConstRangeIterator rit(range);
991 for (const auto & exp_id :rit)
992 {
993 HWIdentifier febId = feb_Id( exp_id[m_bec_index],
994 exp_id[m_side_index],
995 exp_id[m_feedthrough_index],
996 exp_id[m_slot_index] );
997 if(!(ids.insert(febId)).second)
998 {
999 ATH_MSG_ERROR("init_hashes: duplicated id for FEB nb = " + std::to_string(nids));
1000 ATH_MSG_ERROR("expanded Id= " + show_to_string(febId));
1001 }
1002 nids++;
1003 }
1004 }
1005 if(ids.size() != m_febHashMax)
1006 {
1007 ATH_MSG_ERROR("init_hashes: set size NOT EQUAL to FEB hash max. size " + std::to_string(ids.size()));
1008 ATH_MSG_ERROR("hash max " + std::to_string(m_febHashMax));
1009 return (1);
1010 }
1011 nids=0;
1012 first = ids.begin();
1013 last = ids.end();
1014 for (;first != last && nids < m_feb_vec.size(); ++first)
1015 {
1016 m_feb_vec[nids] = (*first) ;
1017 nids++;
1018 }
1019
1020
1021 return (0);
1022}
1023
1024
1025
1026
1028
1029
1030 const int larid=m_lar_impl.unpack(id);
1031 const int laronlineid=m_laronline_impl.unpack(id);
1032 if (larid!=lar_field_value()) return false;
1033
1034 if (laronlineid!=s_lar_online_field_value && laronlineid!=s_lar_onlineCalib_field_value) return false;
1035
1036 const int channel=m_channel_in_slot_impl.unpack(id);
1037 if (channel<0 || channel>128) return false;
1038
1039 const int bec=m_bec_impl.unpack(id);
1040 const int ft=m_feedthrough_impl.unpack(id);
1041 const int slot=m_slot_impl.unpack(id);
1042 if (slot<1) return false;
1043 if (ft<0) return false;
1044 if (bec==0) { // Barrel case
1045 if (ft>31) return false;
1046 if (slot>14) return false;
1047 }
1048 else { //Endcap case
1049 if (ft>27) return false;
1050 if (ft==2 || ft==9 || ft==15 || ft==21){ //Special crate
1051 if (slot >15) return false;
1052 }
1053 else if (ft==6) { //FCAL
1054 if (slot>15) return false;
1055 }
1056 else if (ft>24 && ft<28) { //sFCAL
1057 if (slot>10) return false;
1058 }
1059 else if (ft==3 || ft==10 || ft==16 || ft==22) { //HEC
1060 if (slot==3 || slot==4 || slot>10) return false;
1061 }
1062 else //standard crate
1063 if (slot>13) return false;
1064 }//end endcap
1065 return true;
1066}
1067
1068//=====================
1069// Inline Definitions
1070//=====================
1071
1072
1073
1074
1077 bool checks) const
1078{
1079 HWIdentifier result(0);
1080
1081 /*Pack fields independently */
1082 m_lar_impl.pack (lar_field_value(), result);
1084 m_bec_impl.pack (barrel_ec , result);
1085 m_side_impl.pack (pos_neg , result);
1086 m_feedthrough_impl.pack(feedthrough , result);
1087 if ( m_this_is_slar )
1088 m_slar_impl.pack (1 , result);
1089
1090 /* Do checks */
1091 if(checks)
1092 {
1094 }
1095 return result;
1096}
1102
1103
1105/*=============================================================================== */
1106{
1107 return(m_feedthrough_vec[feedthroughHashId]);
1108}
1109
1111/*=============================================================================== */
1112{
1113 std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_feedthrough_vec.begin(),m_feedthrough_vec.end(),feedthroughId);
1114 if ( it != m_feedthrough_vec.end() ){
1115 return (it - m_feedthrough_vec.begin());
1116 }
1117 return (0);
1118}
1119
1121/*============================================================================== */
1122{
1123 HWIdentifier result(Id);
1124 m_slot_impl.reset(result);
1125 m_channel_in_slot_impl.reset(result);
1126 return(result);
1127}
1128
1130/*====================================================================*/
1131{
1132 return(m_feedthrough_vec.begin());
1133}
1134
1136/*==================================================================*/
1137{
1138 return(m_feedthrough_vec.end());
1139}
1140
1142/*==================================================================*/
1143{
1144 return {feedthrough_begin(), feedthrough_end()};
1145}
1146
1147
1148/* FEB id */
1149/*========*/
1150
1153 int feedthrough, int slot,
1154 bool checks ) const
1155/*==================================================================== */
1156{
1157 HWIdentifier result(0);
1158
1159 /*Pack fields independently */
1160 m_lar_impl.pack (lar_field_value(), result);
1162 m_bec_impl.pack (barrel_ec , result);
1163 m_side_impl.pack (pos_neg , result);
1164 m_feedthrough_impl.pack(feedthrough , result);
1165 m_slot_impl.pack (slot , result);
1166 if ( m_this_is_slar )
1167 m_slar_impl.pack (1 , result);
1168
1169 /* Do checks */
1170 if(checks) {
1172 }
1173 return result;
1174}
1175
1178 int feedthrough, int slot) const
1179{
1181}
1182
1184/*==================================================================================== */
1185{
1186 HWIdentifier result(feedthroughId);
1187 /* Pack fields independently */
1188 m_slot_impl.reset (result);
1189 m_slot_impl.pack (slot , result);
1190 if ( m_this_is_slar )
1191 m_slar_impl.pack (1 , result);
1192
1193 return(result);
1194}
1195
1197/*======================================================================= */
1198{
1199 HWIdentifier result(channelId);
1200 m_channel_in_slot_impl.reset(result);
1201 return(result);
1202}
1203
1205/*================================================================== */
1206{
1207 return(m_feb_vec[febHashId]);
1208}
1209
1211/*=============================================================================== */
1212{
1213 // Get the hash caculator for the febs
1214 const HashCalcFeb& hc = m_feb_hash_calcs[m_bec_ft_impl.unpack(febId)];
1215 // Two cases:
1216 // 1) slot values are enumerated and we must look for a matching
1217 // value to obtain the index
1218 // 2) slot values are a continuous range, then the slot index is
1219 // sufficient for the hash calculation
1220 if (!hc.m_slot_values.empty()) {
1221 // find matching value
1222 int slotValue = slot(febId);
1223 for (int i = 0; (unsigned int)i < hc.m_slot_values.size(); ++i) {
1224 if (slotValue == hc.m_slot_values[i]) return (hc.m_hash + i);
1225 }
1226 ATH_MSG_WARNING("LArOnlineID_Base::feb_Hash - ***** WARNING: could not match slot value for has calculation ");
1227 }
1228 size_type slotIndex = m_slot_impl.unpackToIndex(febId);
1229 return (hc.m_hash + slotIndex);
1230}
1231
1234 int slot, int channel,
1235 bool checks) const
1236/*============================================================================== */
1237{
1238 HWIdentifier result(0);
1239 /* Pack fields independently */
1240 m_lar_impl.pack (lar_field_value() , result);
1242 m_bec_impl.pack (barrel_ec , result);
1243 m_side_impl.pack (pos_neg , result);
1244 m_feedthrough_impl.pack (feedthrough , result);
1245 m_slot_impl.pack (slot , result);
1246 m_channel_in_slot_impl.pack(channel , result);
1247 if ( m_this_is_slar )
1248 m_slar_impl.pack (1 , result);
1249
1250 /* Do checks */
1251 if(checks) {
1253 }
1254 return result;
1255}
1256
1259 int slot, int channel) const
1260{
1262 do_checks());
1263}
1264
1266/*===================================================================*/
1267{
1268 return(m_channel_vec[channelHashId]);
1269}
1270
1271
1274 bool checks) const
1275/*==================================================================================================== */
1276{
1277 HWIdentifier result(feedthroughId);
1278 /* Pack fields independently */
1279 m_slot_impl.reset (result);
1280 m_channel_in_slot_impl.reset(result);
1281 m_slot_impl.pack (slot , result);
1282 m_channel_in_slot_impl.pack (channel, result);
1283 if ( m_this_is_slar )
1284 m_slar_impl.pack (1 , result);
1285
1286 /* Do checks */
1287 if(checks) {
1288 channel_Id_checks( feedthroughId, slot, channel );
1289 }
1290 return result;
1291}
1292
1294LArOnlineID_Base::channel_Id(const HWIdentifier feedthroughId,int slot,int channel) const
1295{
1296 return channel_Id (feedthroughId, slot, channel, do_checks());
1297}
1298
1301 bool checks) const
1302/*======================================================================================= */
1303{
1304 HWIdentifier result(febId);
1305 /* Pack fields independently */
1306 m_channel_in_slot_impl.reset(result);
1307 m_channel_in_slot_impl.pack (channel, result);
1308 if ( m_this_is_slar )
1309 m_slar_impl.pack (1, result);
1310
1311 /* Do checks */
1312 if(checks) {
1313 channel_Id_checks( febId, channel );
1314 }
1315 return result;
1316}
1317
1320{
1321 return channel_Id (febId, channel, do_checks());
1322}
1323
1324//----------------------------------------------------------------------------
1326{
1327 const HashCalc& hc = m_chan_hash_calcs[m_bec_slot_impl.unpack(channelId)];
1328 return (hc.m_hash + channel(channelId));
1329}
1330
1331/* BOOLEAN */
1332
1333/*
1334 *=============================================================
1335 *=============================================================
1336 * Recommended methods
1337 *=============================================================
1338 *=============================================================
1339 */
1340
1342/*========================================================*/
1343{
1344 return (barrel_ec(id)==0);
1345}
1347/*========================================================*/
1348{
1349 return ( barrel_ec(id)==1 && feedthrough(id) == 6 );
1350}
1351
1352
1353
1355/*=================================================================*/
1356{
1357 int bec= barrel_ec(id);
1358 int sl = slot(id);
1359 return (
1360 bec == 0 && sl == 1
1361 );
1362}
1363
1365/*=================================================================*/
1366{/* redefinition (bug fix) */
1367 return (isEMECOW(id) && slot(id)==1);
1368}
1369
1371/*=================================================================*/
1372{/* redefinition with isEMBPS and isEMECPS */
1373 return ( isEMBPS(id) || isEMECPS(id));
1374}
1375
1376
1378/*========================================================*/
1379{
1380 int ft = feedthrough(id);
1381 int sl = slot(id);
1382 int ch = channel(id);
1383 return (
1384 (
1385 isEMBchannel(id) &&
1386 ( (-1 < ft && ft < 32) &&
1387 ( sl == 14 ) &&
1388 ( 63 < ch && ch < 128 )
1389 )
1390 )
1391 ||
1392 (
1393 isEMECchannel(id) && sl == 1 &&
1394 (ft == 2 || ft == 9 || ft == 15 || ft == 21 ) &&
1395 (63 < ch && ch < 128)
1396 )
1397 );
1398}
1399
1400
1401/*
1402 *=============================================================
1403 *=============================================================
1404 * Obsolete methods
1405 *=============================================================
1406 *=============================================================
1407 */
1408
1410/*========================================================*/
1411{/* redefined to isEMBchannel() */
1412 return (isEMBchannel(id));
1413}
1414
1416/*========================================================*/
1417{
1418 return (barrel_ec(id)==1);
1419}
1420
1422/*========================================================*/
1423{/* redefinition (was redundant with isFCALchannel) */
1424 return isFCALchannel(id);
1425}
1427/*========================================================*/
1428{/* redefinition */
1429 return isEMECchannel(id);
1430}
1431
1432
1433/*
1434 *=============================================================
1435 *=============================================================
1436 * Specific UseCases
1437 *=============================================================
1438 *=============================================================
1439 */
1440
1442/*======================================================================*/
1443{
1444 int ft = feedthrough(id);
1445 return ( barrel_ec(id)==1 &&
1446 (ft==0 ||
1447 ft==1 ||
1448 ft==4 ||
1449 ft==5 ||
1450 ft==7 ||
1451 ft==8 ||
1452 ft==11 ||
1453 ft==12 ||
1454 ft==13 ||
1455 ft==14 ||
1456 ft==17 ||
1457 ft==18 ||
1458 ft==19 ||
1459 ft==20 ||
1460 ft==23 ||
1461 ft==24)
1462 );
1463}
1465/*======================================================================*/
1466{
1467 int ft = feedthrough(id);
1468 return ( barrel_ec(id)==1 &&
1469 (ft==2 ||
1470 ft==9 ||
1471 ft==15 ||
1472 ft==21 )
1473 );
1474}
1475
1477/*========================================================*/
1478{
1479 int bec= barrel_ec(id);
1480 int ft = feedthrough(id);
1481 int sl = slot(id);
1482 return ( (bec==0 && sl==15)
1483 ||
1484 ( bec==1 && sl==15 &&
1485 (ft==0 ||
1486 ft==1 ||
1487 ft==4 ||
1488 ft==5 ||
1489 ft==7 ||
1490 ft==8 ||
1491 ft==11 ||
1492 ft==12 ||
1493 ft==13 ||
1494 ft==14 ||
1495 ft==17 ||
1496 ft==18 ||
1497 ft==19 ||
1498 ft==20 ||
1499 ft==23 ||
1500 ft==24 )
1501 )
1502 ||
1503 ( barrel_ec(id)==1 &&
1504 (sl==3 || sl==4 || sl==12) &&
1505 (ft==3 ||
1506 ft==10 ||
1507 ft==16 ||
1508 ft==22 )
1509 )
1510 ||
1511 ( barrel_ec(id)==1 && sl==16 )
1512 ||
1513 ( barrel_ec(id)==1 && ft==27 && sl==11 )
1514 );
1515}
1516
1517
1518/*
1519 *================================================================
1520 *================================================================
1521 * The following methods should NOT be used for new applications:
1522 *================================================================
1523 *================================================================
1524 */
1525
1527/*========================================================*/
1528{
1529 /* Must be used with CARE !
1530 * This method returns true for all slots/channel in HEC crates,
1531 * thus including the EMEC slot/channels that are present
1532 * in slot 1 and slot 2 of HEC crates !
1533 * To access specifically EMEC in HEC slot/channel, you then
1534 * have to use isEMECinHECchannel()
1535 */
1536 int ft = feedthrough(id);
1537 return (
1538 //(slot(id)!=1 && slot(id)!= 2) &&
1539 barrel_ec(id)==1 &&
1540 (ft==3 ||
1541 ft==10 ||
1542 ft==16 ||
1543 ft==22 )
1544 );
1545}
1546
1548/*========================================================*/
1549{
1550 /* Must be used with CARE !
1551 * This method returns true for all slots/channel in HEC crates,
1552 * thus including the EMEC slot/channels that are present
1553 * in slot 1 and slot 2 of HEC crates !
1554 * To access specifically EMEC in HEC slot/channel, you then
1555 * have to use isEMECinHECchannel()
1556 */
1557 int ft = feedthrough(febId);
1558 return ( barrel_ec(febId)==1 &&
1559 (ft==3 ||
1560 ft==10 ||
1561 ft==16 ||
1562 ft==22 )
1563 );
1564}
1565
1567/*=================================================================*/
1568{/* re-definition with isEMECIW */
1569 return isEMECIW(id);
1570}
1571
1572
1573
1574
1575
1576
1577
1578
1579
1581 /*=======================================================================*/
1582{
1583 return m_feedthroughHashMax;
1584}
1586/*=======================================================================*/
1587{
1588 return m_febHashMax;
1589}
1591/*====================================================================*/
1592{
1593 return m_channelHashMax;
1594}
1595
1596
1597
1598
1600/*====================================================================*/
1601{
1602 return(m_feb_vec.begin());
1603}
1605/*==================================================================*/
1606{
1607 return(m_feb_vec.end());
1608}
1610/*==================================================================*/
1611{
1612 return {feb_begin(), feb_end()};
1613}
1614
1616/*======================================================================*/
1617{
1618 return(m_channel_vec.begin());
1619}
1621/*======================================================================*/
1622{
1623 return(m_channel_vec.end());
1624}
1626/*======================================================================*/
1627{
1628 return {channel_begin(), channel_end()};
1629}
1630
1632/*=========================================================*/
1633{
1634 return (m_bec_impl.unpack(id));
1635}
1636
1638/*===========================================================*/
1639{
1640 return (m_feedthrough_impl.unpack(id));
1641}
1642
1644/*===========================================================*/
1645{
1646 return (m_side_impl.unpack(id));
1647}
1648
1649
1651/*=====================================================*/
1652{
1653 return (m_slot_impl.unpack(id));
1654}
1655
1657/*=====================================================*/
1658{
1659 return (m_channel_in_slot_impl.unpack(id));
1660}
1661
1663/*=====================================================*/
1664{
1665 return (m_slar_impl.unpack(id));
1666}
1667
1668
1669/*========================================*/
1671/*========================================*/
1672{
1673 unsigned int nids=0;
1674 std::set<HWIdentifier> ids;
1675 for (unsigned int i = 0; i < m_full_calib_laronline_range.size(); ++i) {
1676 const Range& range = m_full_calib_laronline_range[i];
1677 ConstRangeIterator rit(range);
1678 for (const auto & exp_id : rit) {
1679 HWIdentifier id = this->calib_channel_Id(exp_id[m_bec_index],
1680 exp_id[m_side_index],
1681 exp_id[m_feedthrough_index],
1682 exp_id[m_slot_index],
1683 exp_id[m_channel_in_slot_index]);
1684 if(!(ids.insert(id)).second) {
1685 ATH_MSG_WARNING("LArOnlineID_Base::init_calib_Hashes: Error: duplicated id for channel id. nids= "
1686 + std::to_string(nids) + " compact Id " + std::string(exp_id) + " " + show_to_string(id));
1687 }
1688 nids++;
1689 }
1690 }
1691 unsigned int nidtb=0;
1692 std::set<HWIdentifier>::const_iterator first = ids.begin();
1693 std::set<HWIdentifier>::const_iterator last = ids.end();
1694 for (;first != last && nidtb < nids; ++first) {
1695 m_calib_channel_vec.push_back(*first);
1696 nidtb++;
1697 }
1699
1700 /* FEB hash */
1701 /*==========*/
1702 nids = 0;
1703 ids.clear();
1704 for (unsigned int i = 0; i < m_full_calib_module_range.size(); ++i) {
1705 const Range& range = m_full_calib_module_range[i];
1706 ConstRangeIterator rit(range);
1707 for (const auto & exp_id : rit) {
1708 HWIdentifier febId = calib_module_Id( exp_id[m_bec_index],
1709 exp_id[m_side_index],
1710 exp_id[m_feedthrough_index],
1711 exp_id[m_slot_index] );
1712 if(!(ids.insert(febId)).second){
1713 ATH_MSG_WARNING("LArOnlineID_Base::init_calibhashes: Warning: duplicated id for feb id. nids= "
1714 + std::to_string(nids) + " compact Id " + std::string(exp_id) + " " + show_to_string(febId));
1715 }
1716 nids++;
1717 }
1718 }
1719 nidtb=0;
1720 first = ids.begin();
1721 last = ids.end();
1722 for (;first != last && nidtb < nids; ++first)
1723 {
1724 m_calib_module_vec.push_back(*first);
1725 nidtb++;
1726 }
1728 return (0);
1729}
1730
1731
1732
1733
1734
1735
1736
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
static const int s_lar_online_field_value
static const int s_lar_onlineCalib_field_value
size_t size() const
Number of registered mappings.
#define min(a, b)
Definition cfImp.cxx:40
virtual std::string dictionaryVersion(void) const override
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
ExpandedIdentifier lar_exp(void) const
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
virtual bool do_checks(void) const override
Checks are performed by default in debug compilation and NOT in optimized compilation.
int lar_field_value() const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
const std::string & group() const
Group name for this helper.
AtlasDetectorID(const std::string &name, const std::string &group)
void add(element_type value)
Append a value into a new field.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
int get_label_value(const std::string &field, const std::string &label, int &value) const
const std::string & name() const
Dictionary name.
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
const IdDictFieldImplementation & implementation(size_t i) const
element_type get_minimum() const
Query the values.
bool empty() const
If true, this field does not have any constraints, and may hold any value representable by element_ty...
bool isEnumerated() const
const element_vector & get_values() const
bool isBounded() const
element_type get_maximum() const
This is a "hash" representation of an Identifier.
Exception class for LAr online Identifiers.
Define the Hash identifier for channels and febs.
bool isValidId(const HWIdentifier id) const
Returns false if the identifier is not a LAr-online id or any of the sub-fields is out of range.
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
bool isNotWarmCableConnected(const HWIdentifier id) const
MultiRange m_full_laronline_range
std::string feedthrough_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
std::ranges::subrange< id_iterator > id_range
Type for range over identifiers.
HWIdentifier feedthrough_Id(int barrel_ec, int pos_neg, int feedthrough) const
Create a feedthrough identifier from fields.
virtual bool isEMECchannel(const HWIdentifier id) const =0
std::vector< HWIdentifier > m_channel_vec
bool isHecOnline(const HWIdentifier id) const
bool isFcalOnline(const HWIdentifier id) const
size_type m_calibModuleHashMax
id_iterator feedthrough_begin() const
Return an iterator pointing to Feedthrough identifiers collection.
bool isPS(const HWIdentifier id) const
int get_expanded_calib_id(const HWIdentifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
bool isEndcapOnline(const HWIdentifier id) const
bool isEMBchannel(const HWIdentifier id) const
IdContext cryostatEndContext() const
Define context for cryostat (obsolete).
std::vector< HWIdentifier >::const_iterator id_iterator
Type for iterators over identifiers.
int slot(const HWIdentifier id) const
Return the slot number of a hardware cell identifier: slot = [1,15] Slot-ID in top part of the crat...
HWIdentifier calib_channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create calibration channel identifiers from fields
virtual bool isEMECIW(const HWIdentifier id) const =0
const IdDictDictionary * m_dict
size_type m_channel_in_slot_index
IdDictFieldImplementation m_channel_in_slot_impl
size_type m_feedthrough_index
bool isEmBarrelOnline(const HWIdentifier id) const
int barrel_ec(const HWIdentifier id) const
Return the position barrel or endcap of a hardware cell identifier: barrel_ec = [0,...
id_range channel_range() const
void feb_Id_checks(int barrel_ec, int pos_neg, int feedthrough, int slot) const
MultiRange m_full_calib_laronline_range
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
std::vector< HWIdentifier > m_calib_channel_vec
IdContext channelContext() const
Define context for channel.
int get_expanded_id(const HWIdentifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded HWIdentifier from HWIdentifier (return == 0 for OK)
IdContext febContext() const
Define context for feb.
id_iterator channel_end() const
virtual bool isEMECOW(const HWIdentifier id) const =0
IdentifierHash channel_Hash_binary_search(HWIdentifier channelId) const
HWIdentifier calib_module_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Build calibration module identifier from fields.
IdentifierHash feb_Hash_binary_search(HWIdentifier channelId) const
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
id_range feb_range() const
int is_slar(const HWIdentifier id) const
Return whether the channel is in slar or not is_ slar = [0,1] in all FEB.
id_iterator feb_begin() const
Returns an iterator pointing to a feb identifier collection.
size_type m_laronline_index
std::vector< HWIdentifier > m_calib_module_vec
id_iterator channel_begin() const
Returns an iterator pointing to a channel identifier collection.
MultiRange m_full_feb_range
IdDictFieldImplementation m_bec_ft_impl
size_type febHashMax() const
define feb hash tables max size
bool isEmEndcapStandardOnline(const HWIdentifier id) const
size_type channelHashMax() const
Define channel hash tables max size.
LArOnlineID_Base(const std::string &name, const std::string &group, bool is_slar)
Default constructor.
int pos_neg(const HWIdentifier id) const
Return the side of a hardware cell identifier pos_neg = [0,1] positive-side or negative-side Barrel...
bool isEmEndcapSpecialOnline(const HWIdentifier id) const
IdDictFieldImplementation m_feedthrough_impl
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
IdentifierHash feb_Hash(HWIdentifier febId) const
Create feb hash identifiers from feb identifiers.
IdContext feedthroughContext() const
Define context for feedthroughs.
IdDictFieldImplementation m_slot_impl
void channel_Id_checks(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
IdDictFieldImplementation m_laronline_impl
IdentifierHash feedthrough_Hash(HWIdentifier feedthroughId) const
Create hash id from feedthrough identifiers.
size_type m_feedthroughHashMax
virtual ~LArOnlineID_Base()
Default destructor.
IdDictFieldImplementation m_side_impl
id_iterator feb_end() const
size_type m_laronlineRegion_index
std::vector< HWIdentifier > m_feb_vec
std::vector< HashCalcFeb > m_feb_hash_calcs
int initLevelsFromDict(const std::string &group_name)
bool isEMECPS(const HWIdentifier id) const
Identifier::size_type size_type
IdDictFieldImplementation m_bec_impl
std::vector< HWIdentifier > m_feedthrough_vec
bool isCalibration(const HWIdentifier id) const
bool isHecOnlineFebId(const HWIdentifier febId) const
bool isFCALchannel(const HWIdentifier id) const
IdDictFieldImplementation m_bec_slot_impl
id_iterator feedthrough_end() const
bool isEMECinHECchannel(const HWIdentifier id) const
IdDictFieldImplementation m_lar_impl
Field Implementation.
size_type feedthroughHashMax() const
Define feedthrough hash tables max size.
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr)
initialization from the identifier dictionary
bool isEMBPS(const HWIdentifier id) const
MultiRange m_full_calib_module_range
id_range feedthrough_range() const
HWIdentifier feb_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Create feb_Id from fields.
size_type m_calibChannelHashMax
int channelInSlotMax(const HWIdentifier Id) const
Return the Maximum channel number of a given feb slot.
bool isEmEndcapOnline(const HWIdentifier id) const
IdDictFieldImplementation m_slar_impl
MultiRange m_full_feedthrough_range
std::vector< HashCalc > m_chan_hash_calcs
void feedthrough_Id_checks(int barrel_ec, int pos_neg, int feedthrough) const
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:359