ATLAS Offline Software
Loading...
Searching...
No Matches
LArOnlineID_Base.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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 std::ostringstream s1;
226 int Nchan = channel(id);
227 int Nslot = slot(id);
228 int Nft = feedthrough(id);
229 std::string det_barrel_endcap = "NODETE";
230 std::string det_side = "/X-SIDE";
231
232 if( barrel_ec(id) == 0 ) det_barrel_endcap = "BARREL";
233 if( barrel_ec(id) == 1 ) det_barrel_endcap = "ENDCAP";
234 if( pos_neg(id) == 1 ) det_side = "/A-SIDE";
235 if( pos_neg(id) == 0 ) det_side = "/C-SIDE";
236
237 s1 << det_barrel_endcap
238 << det_side
239 << "/FT-" << Nft
240 << "/SLOT-" << Nslot
241 << "/CHAN-" << Nchan;
242 return s1.str();
243 //return s2;
244}
245
246
247
248/* =================================================================== */
250/* =================================================================== */
251{
253 return (IdContext(id, 0, m_side_index));
254}
255
256
257
258/* =================================================================== */
260/* =================================================================== */
261{
263 return (IdContext(id, 0, m_feedthrough_index));
264}
265
266
267
268
269/* =================================================================== */
271/* =================================================================== */
272{
274 return (IdContext(id, 0, m_channel_in_slot_index));
275}
276
277
278
279/* =================================================================== */
281/* =================================================================== */
282{
284 return (IdContext(id, 0, m_slot_index));
285}
286
287
288
289/* =================================================================== */
291/* =================================================================== */
292{
293
294 ExpandedIdentifier expId;
295 IdContext context = channelContext();
296 if(!get_expanded_id(channelId, expId, &context)) {
297 int result = -999;
298 for (unsigned int i = 0; i < m_full_laronline_range.size(); ++i) {
299 const Range& range = m_full_laronline_range[i];
300 if (range.match(expId)) {
301 const Range::field& channel_in_slot_field = range[m_channel_in_slot_index];
302 if (!channel_in_slot_field.empty()) {
303 int channel_in_slotmax = channel_in_slot_field.get_maximum();
304 if (result < channel_in_slotmax) result = channel_in_slotmax + 1;
305 }
306 }
307 }
308 return (result);
309 }
310 return (-999); // default
311}
312
313
314
315
316
317/* =================================================================== */
319/* =================================================================== */
320{
321 ATH_MSG_INFO("initialize_from_dictionary");
322
323 // Check whether this helper should be reinitialized
324 if (!reinitialize(dict_mgr)) {
325 ATH_MSG_DEBUG("Request to reinitialize not satisfied - tags have not changed");
326 return (0);
327 }
328 else {
329 ATH_MSG_DEBUG("(Re)initialize");
330 }
331
332 // init base object
333 if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1);
334 m_dict = dict_mgr.find_dictionary ("LArCalorimeter");
335 if(!m_dict) {
336 ATH_MSG_ERROR("initialize_from_dictionary - cannot access LArCalorimeter dictionary");
337 return 1;
338 }
339
340 // Register version of the dictionary used
341 if (register_dict_tag(dict_mgr, "LArCalorimeter")) return(1);
342
343 // initialize dictionary version
344 AtlasDetectorID::setDictVersion(dict_mgr, "LArCalorimeter");
345
346 /* Initialize the field indices */
347// if(initLevelsFromDict()) return (1);
348 if(initLevelsFromDict(group())) return (1);
349
350
351 /* Find value for the field LAr Calorimeter */
352 const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS");
353 int larField = -1;
354 if (atlasDict->get_label_value("subdet", "LArCalorimeter", larField)) {
355 ATH_MSG_ERROR("Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary "
356 << atlasDict->name());
357 return (1);
358 }
359
360 /* Find value for the field LArOnline */
361 int larOnlineField = -4;
362 if (m_dict->get_label_value("part", "LArOnline", larOnlineField)) {
363 ATH_MSG_ERROR("Could not get value for label 'LArOnline' of field 'part' in dictionary "
364 << m_dict->name());
365 return (1);
366 }
367
368 /* Find value for the field calibLArOnline */
369 int larOnlineCalibField = -5;
370 if (m_dict->get_label_value("part", "LArOnlineCalib", larOnlineCalibField)) {
371 ATH_MSG_ERROR("Could not get value for label 'LArOnlineCalib' of field 'part' in dictionary "
372 << m_dict->name());
373 return (1);
374 }
375
376 /* Set up id for Region and range prefix */
377 ExpandedIdentifier region_id;
378 region_id.add(larField);
379 region_id.add(larOnlineField);
380 Range prefix;
381 /* Calib Multirange */
382 ExpandedIdentifier region_id2;
383 region_id2.add(larField);
384 region_id2.add(larOnlineCalibField);
385 Range prefix2;
386
387 /*Full range for all channels*/
388 m_full_laronline_range = m_dict->build_multirange( region_id , group(), prefix);
389 m_full_feb_range = m_dict->build_multirange( region_id , group(), prefix, "slot");
390 m_full_feedthrough_range = m_dict->build_multirange( region_id , group(), prefix, "feedthrough");
391
392 ATH_MSG_DEBUG("initialize_from_dictionary :");
393 ATH_MSG_DEBUG("feedthrough range -> " << (std::string)m_full_feedthrough_range);
394 ATH_MSG_DEBUG("feedthrough slot range -> " << (std::string)m_full_feb_range);
395 ATH_MSG_DEBUG("channel range -> " << (std::string)m_full_laronline_range);
396
397 /* calib */
398 /* Full range for calib channels */
399 m_full_calib_laronline_range = m_dict->build_multirange( region_id2 , group(), prefix2);
400 m_full_calib_module_range = m_dict->build_multirange( region_id2 , group(), prefix2, "slot");
401
402 ATH_MSG_DEBUG("=> initialize_from_dictionary : ");
403 ATH_MSG_DEBUG("=> Calib module range -> " << (std::string)m_full_calib_module_range);
404 ATH_MSG_DEBUG("=> Calib channel range -> " << (std::string)m_full_calib_laronline_range);
405
406 /* Setup the hash tables */
407 ATH_MSG_DEBUG("[initialize_from_dictionary] version= " << dictionaryVersion());
408 if( dictionaryVersion() == "fullAtlas" ) {
409 if(init_hashes()) return (1);
410 }
411
412 // Setup for hash calculation for channels (febs is further below)
413
414 // Febs have a uniform number of channels
415 // The lookup table only needs to contain the
416 // hash offset for each feb
417
418 // The implementation requires:
419
420 // 1) a lookup table for each feb containing hash offset
421 // 2) a decoder to access the "index" corresponding to the
422 // bec/side/ft/slot fields. These fields use x bits, so the
423 // vector has a length of 2**x.
424
425 /* Create decoder for fields bec to slot */
427 m_bec_impl.bits() +
428 m_side_impl.bits() +
429 m_feedthrough_impl.bits() +
430 m_slot_impl.bits();
431 IdDictFieldImplementation::size_type bits_offset = m_bec_impl.bits_offset();
432 m_bec_slot_impl.set_bits(bits, bits_offset);
433 int size = (1 << bits);
434
435 // Set up vector as lookup table for hash calculation.
436 m_chan_hash_calcs.resize(size);
437
438 for (unsigned int i = 0; i < m_febHashMax; ++i) {
439
440 HWIdentifier febId = feb_Id(i) ;
441
442 HashCalc hc;
443
444 HWIdentifier min = channel_Id ( febId, 0);
445
447 hc.m_hash = min_hash;
449
450 if (m_bec_slot_impl.unpack(min) >= size) {
451 ATH_MSG_DEBUG("Min > " << size);
453 ATH_MSG_DEBUG(" " << std::to_string(m_bec_slot_impl.unpack(min)));
454 }
455 }
456
457 // Check channel hash calculation
458 for (unsigned int i = 0; i < m_channelHashMax; ++i) {
459 HWIdentifier id = channel_Id(i);
460 if (channel_Hash(id) != i) {
461 ATH_MSG_ERROR(" ***** Error channel ranges, id, hash, i = " << show_to_string(id));
462 ATH_MSG_ERROR(" , " << std::to_string(channel_Hash(id)));
463 ATH_MSG_ERROR(" , " << i);
464 }
465 }
466
467
468
469 // Setup for hash calculation for febs
470
471 // We calculate the feb hash by saving the hash of each
472 // feedthrough in a HashCalc object and then adding on the slot
473 // number for a particular feb
474
475 // The implementation requires:
476
477 // 1) a lookup table for each ft containing hash offset
478 // 2) a decoder to access the "index" corresponding to the
479 // bec/side/ft fields. These fields use x bits, so the
480 // vector has a length of 2**x.
481
482 /* Create decoder for fields bec to ft */
483 bits = m_bec_impl.bits() +
484 m_side_impl.bits() +
485 m_feedthrough_impl.bits();
486 bits_offset = m_bec_impl.bits_offset();
487 m_bec_ft_impl.set_bits(bits, bits_offset);
488 size = (1 << bits);
489
490 // Set up vector as lookup table for hash calculation.
491 m_feb_hash_calcs.resize(size);
492
493 // Get context for conversion to expanded ids
494 IdContext ftContext = feedthroughContext();
495 ExpandedIdentifier ftExpId;
496
497 for (unsigned int i = 0; i < m_feedthroughHashMax; ++i) {
498
500
501 HashCalcFeb hc;
502
503 // Set the hash id for each feedthrough, and then check if one
504 // needs to also save the slot values
506 hc.m_hash = min_hash;
507
508 // For each feedthrough we must check to see if the slot
509 // values are enumerated or not. If they are enumerate we must
510 // save the values in order to calculate the fed hash
511 if (get_expanded_id(min, ftExpId, &ftContext)) {
512 ATH_MSG_WARNING(" ***** Warning cannot get ft expanded id for " + show_to_string(min));
513 }
514 unsigned int nrangesFound = 0;
515 for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) {
516 if (m_full_feb_range[i].match(ftExpId)) {
517 nrangesFound += 1;
518 const Range::field& slotField = m_full_feb_range[i][m_slot_index];
519 if (slotField.isEnumerated()) {
520 // save values
521 hc.m_slot_values = slotField.get_values();
522 }
523 }
524 }
525
526 // Similarly, if there is more than one range per feedthrough,
527 // this means that slot values are not a continuous range. In
528 // this case, as well, we save all possible slot values
529 if (nrangesFound > 1) {
530 for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) {
531 if (m_full_feb_range[i].match(ftExpId)) {
532 const Range::field& slotField = m_full_feb_range[i][m_slot_index];
533 if (slotField.isBounded()) {
534 // save values
535 unsigned int nvalues = slotField.get_maximum() - slotField.get_minimum() + 1;
536 hc.m_slot_values.reserve(std::max(hc.m_slot_values.size()*3/2, hc.m_slot_values.size() + nvalues));
537 for (unsigned int j = 0; j < nvalues; ++j) {
538 hc.m_slot_values.push_back(j + slotField.get_minimum());
539 }
540 }
541 else {
542 ATH_MSG_WARNING(" ***** Warning feb range slot field is NOT both_bounded - id, slot mode: " +
543 show_to_string(min) + " enumerated");
544 }
545 }
546 }
547 }
548
549
550 // Set hash calculator
551 m_feb_hash_calcs[m_bec_ft_impl.unpack(min)] = std::move(hc);
552
553
554 if (m_bec_ft_impl.unpack(min) >= size) {
555 ATH_MSG_DEBUG("Min > " << size << " " << show_to_string(min) <<
556 " " << m_bec_ft_impl.unpack(min) << " " <<
557 min_hash);
558 }
559 }
560
561 // Check feb hash calculation
562 for (unsigned int i = 0; i < m_febHashMax; ++i) {
563 HWIdentifier id = feb_Id(i);
564 if (feb_Hash(id) != i) {
565 ATH_MSG_ERROR(" ***** Error feb ranges, id, hash, i = " <<
566 show_to_string(id) << " , " << feb_Hash(id) << " , " << i);
567 }
568 }
569
570 return 0;
571}
572
573
574
575/* ================================================================*/
577 int slot, int channel ) const
578/* ================================================================*/
579{
580 // Check that id is within allowed range
581 // Fill expanded id
584 if ( m_this_is_slar ) expId << 1;
585
586 if (!m_full_laronline_range.match(expId)) {
587 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks() result is not OK: ID, range = "
588 + std::string(expId) + " , " + (std::string)m_full_laronline_range;
589 LArOnlID_Exception except(errorMessage , 99);
590 throw except ;
591 }
592}
593
594/* ================================================================*/
596 int channel ) const
597/* ================================================================*/
598{
599 // Check that id is within allowed range
600 // Fill expanded id
601 ExpandedIdentifier expId;
602 IdContext context = febContext();
603 if (get_expanded_id(febId, expId, &context)) {
604 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks(febId) result is not OK: ID = "
605 + show_to_string(febId) ;
606 LArOnlID_Exception except(errorMessage , 99);
607 throw except ;
608 }
609
610 expId << channel;
611 if ( m_this_is_slar ) expId << 1;
612 if (!m_full_laronline_range.match(expId)) {
613 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks(febId) result is not OK: ID, range = "
614 + std::string(expId) + " , " + (std::string)m_full_laronline_range;
615 LArOnlID_Exception except(errorMessage , 99);
616 throw except ;
617 }
618}
619
620/* ================================================================*/
622 int slot, int channel ) const
623/* ================================================================*/
624{
625 // Check that id is within allowed range
626 // Fill expanded id
627 ExpandedIdentifier expId;
628 IdContext context = feedthroughContext();
629 if (get_expanded_id(feedthroughId, expId, &context)) {
630 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks(feedthroughId) result is not OK: ID = "
631 + show_to_string(feedthroughId) ;
632 LArOnlID_Exception except(errorMessage , 99);
633 throw except ;
634 }
635
636 expId << slot << channel;
637 if ( m_this_is_slar ) expId << 1;
638 if (!m_full_laronline_range.match(expId)) {
639 std::string errorMessage = "LArOnlineID_Base::channel_Id_checks(feedthroughId) result is not OK: ID, range = "
640 + std::string(expId) + " , " + (std::string)m_full_laronline_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
654
655 if ( m_this_is_slar ) expId << 0 << 1;
656 if (!m_full_feedthrough_range.match(expId)) { std::string errorMessage = "LArOnlineID_Base::feb_Id_checks() result is not OK: ID, range = "
657 + std::string(expId) + " , " + (std::string)m_full_feb_range;
658 LArOnlID_Exception except(errorMessage , 99);
659 throw except ;
660 }
661}
662
663/* ================================================================*/
665/* ==============================================================================*/
666{
667 // Check that id is within allowed range
668 // Fill expanded id
670 expId << s_lar_online_field_value << barrel_ec << pos_neg << feedthrough << 0 << 0 << (int)m_this_is_slar;
671
672// if ( m_this_is_slar ) expId << 0 << 0 << 1;
673 if (!m_full_feedthrough_range.match(expId)) { std::string errorMessage = "LArOnlineID_Base::feedthrough_Id_checks() result is not OK: ID, range = "
674 + std::string(expId) + " , " + (std::string)m_full_feedthrough_range;
675 LArOnlID_Exception except(errorMessage , 99);
676 throw except ;
677 }
678}
679
680
681
682/* =================================================================================*/
684 const IdContext* context) const
685/*==================================================================================*/
686{
687 // We assume that the context is >= feedthrough
688 exp_id.clear();
689 exp_id << lar_field_value()
691 << barrel_ec(id)
692 << pos_neg(id);
693 if(context && context->end_index() >= m_feedthrough_index) {
694 exp_id << feedthrough(id);
695 if(context && context->end_index() >= m_slot_index) {
696 exp_id << slot(id);
697 if(context->end_index() >= m_channel_in_slot_index) {
698 exp_id << channel(id);
699 if(context->end_index() >= m_slar_index) {
700 exp_id << is_slar(id);
701 }
702 }
703 }
704 }
705 return (0);
706}
707
708
709/* =================================================================================*/
711 const IdContext* context) const
712/*==================================================================================*/
713{
714 // We assume that the context is >= feedthrough
715 exp_id.clear();
716 exp_id << lar_field_value()
718 << barrel_ec(id)
719 << pos_neg(id)
720 << feedthrough(id);
721 if(context && context->end_index() >= m_slot_index) {
722 exp_id << slot(id);
723 if(context->end_index() >= m_channel_in_slot_index) {
724 exp_id << channel(id);
725 if(context->end_index() >= m_slar_index) {
726 exp_id << is_slar(id);
727 }
728 }
729 }
730 return (0);
731}
732
733
734
735/*======================================*/
736int LArOnlineID_Base::initLevelsFromDict(const std::string& group_name)
737/*======================================*/
738{
739
740 if(!m_dict)
741 {
742 ATH_MSG_ERROR("initLevelsFromDict - dictionary NOT initialized");
743 return (1);
744 }
745
746 /* Find out which identifier field corresponds to each level.*/
747
748 m_lar_index = 999 ;
749 m_laronline_index = 999 ;
750 m_bec_index = 999 ;
751 m_side_index = 999 ;
752 m_feedthrough_index = 999 ;
753 m_slot_index = 999 ;
755 m_slar_index = 999 ;
756
757 // Save index to a DictionaryRegion for unpacking
758 const IdDictRegion* reg = m_dict->find_region("laronline-barrel");
759 if (reg)
760 {
761 m_laronlineRegion_index = reg->index();
762 }
763 else
764 {
765 ATH_MSG_ERROR("initLevelsFromDict - unable to find laronline region ");
766 return (1);
767 }
768 /* Find LAr field */
769 const IdDictField* field = m_dict->find_field("subdet") ;
770 if (field)
771 {
772 m_lar_index = field->index();
773 }
774 else
775 {
776 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'subdet' field ");
777 return (1);
778 }
779
780 /* Find LArOnline field */
781 field = m_dict->find_field("part") ;
782 if (field)
783 {
784 m_laronline_index = field->index();
785 }
786 else
787 {
788 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'part' field ");
789 return (1);
790 }
791
792 /* Find barrel-endcap field */
793 field = m_dict->find_field("barrel-ec") ;
794 if (field)
795 {
796 m_bec_index = field->index();
797 }
798 else
799 {
800 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'barrel-endcap' field ");
801 return (1);
802 }
803
804 /* Find detector-side field */
805 field = m_dict->find_field("pos_neg") ;
806 if (field)
807 {
808 m_side_index = field->index();
809 }
810 else
811 {
812 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'barrel-endcap' field ");
813 return (1);
814 }
815
816 /* Find feedthrough field */
817 std::string feedthrough_name;
818 if ( m_this_is_slar ){
819 feedthrough_name+="slar_feedthrough";
820 } else {
821 feedthrough_name+="feedthrough";
822 }
823 field = m_dict->find_field(feedthrough_name) ;
824 if (field) {
825 m_feedthrough_index = field->index();
826 }
827 else
828 {
829 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'feedthrough' field ");
830 return (1);
831 }
832
833 /* Find slot field */
834 std::string slot_name;
835 if ( m_this_is_slar ){
836 slot_name+="slar_slot";
837 } else {
838 slot_name+="slot";
839 }
840 field = m_dict->find_field(slot_name) ;
841 if (field)
842 {
843 m_slot_index = field->index();
844 }
845 else
846 {
847 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'slot' field ");
848 return (1);
849 }
850
851 /* Find channel_in_slot field */
852 std::string channel_name;
853 if ( m_this_is_slar ){
854 channel_name+="sch_in_slot";
855 } else {
856 channel_name+="channel_in_slot";
857 }
858 field = m_dict->find_field(channel_name) ;
859 if (field)
860 {
861 m_channel_in_slot_index = field->index();
862 }
863 else
864 {
865 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'channel_in_slot' field ");
866 return (1);
867 }
868
869 /* Find slar field */
870 if ( m_this_is_slar ) {
871 field = m_dict->find_field("is-slar") ;
872 if (field)
873 {
874 m_slar_index = field->index();
875 }
876 else
877 {
878 ATH_MSG_ERROR("initLevelsFromDict - unable to find 'slar' field ");
879 return (1);
880 }
881 } // end of m_this_is_slar
882
883 /* Set the field implementations */
884
885 const IdDictGroup* group = m_dict->find_group(group_name);
886 if ( !group ) {
887 ATH_MSG_ERROR("initLevelsFromDict - cannot find " << group_name);
888 } else {
889 m_laronlineRegion_index = group->region(0).index();
890 }
891
892 const IdDictRegion& region = m_dict->region(m_laronlineRegion_index);
893
901 if ( m_this_is_slar )
903
904 ATH_MSG_DEBUG("decode index and bit fields for each level:");
905 ATH_MSG_DEBUG("lar " << m_lar_impl.show_to_string());
906 ATH_MSG_DEBUG("online " << m_laronline_impl.show_to_string());
907 ATH_MSG_DEBUG("bec " << m_bec_impl.show_to_string());
908 ATH_MSG_DEBUG("side " << m_side_impl.show_to_string());
909 ATH_MSG_DEBUG("ft " << m_feedthrough_impl.show_to_string());
910 ATH_MSG_DEBUG("slot " << m_slot_impl.show_to_string());
911 ATH_MSG_DEBUG("channel " << m_channel_in_slot_impl.show_to_string());
912 if ( m_this_is_slar )
913 ATH_MSG_DEBUG("is-slar " << m_slar_impl.show_to_string());
914
915 return(0) ;
916}
917
918
919
920/*======================================*/
922/*======================================*/
923{
924 /* channel hash */
927 unsigned int nids = 0;
928 std::set<HWIdentifier> ids;
929 for (unsigned int i = 0; i < m_full_laronline_range.size(); ++i)
930 {
931 const Range& range = m_full_laronline_range[i];
932 ConstRangeIterator rit(range);
933 for (const auto & exp_id : rit)
934 {
935 HWIdentifier id = this->channel_Id (exp_id[m_bec_index],
936 exp_id[m_side_index],
937 exp_id[m_feedthrough_index],
938 exp_id[m_slot_index],
940 if(!(ids.insert(id)).second)
941 {
942 ATH_MSG_ERROR("init_hashes: duplicated id for channel nb = " + std::to_string(nids));
943 ATH_MSG_ERROR("expanded Id= " + show_to_string(id));
944 }
945 nids++;
946 }
947 }
948 if(ids.size() != m_channelHashMax)
949 {
950 ATH_MSG_ERROR("init_hashes: set size NOT EQUAL to hash max. size " + std::to_string(ids.size()));
951 ATH_MSG_ERROR("hash max " + std::to_string(m_channelHashMax));
952 return (1);
953 }
954 nids=0;
955 std::set<HWIdentifier>::const_iterator first = ids.begin();
956 std::set<HWIdentifier>::const_iterator last = ids.end();
957 for (;first != last && nids < m_channel_vec.size(); ++first)
958 {
959 m_channel_vec[nids] = (*first) ;
960 nids++;
961 }
962
963 /* feedthrough hash */
966 nids = 0;
967 ids.clear();
968 for (unsigned int i = 0; i < m_full_feedthrough_range.size(); ++i)
969 {
970 const Range& range = m_full_feedthrough_range[i];
971 ConstRangeIterator rit(range);
972 for (const auto & exp_id: rit) {
973 HWIdentifier feedthroughId = feedthrough_Id( exp_id[m_bec_index],
974 exp_id[m_side_index],
975 exp_id[m_feedthrough_index] );
976 if(!(ids.insert(feedthroughId)).second){
977 ATH_MSG_ERROR("init_hashes: duplicated id for feedthrough nb = " + std::to_string(nids));
978 ATH_MSG_ERROR("expanded Id= " + show_to_string(feedthroughId));
979 }
980 nids++;
981 }
982 }
983 if(ids.size() != m_feedthroughHashMax)
984 {
985 ATH_MSG_ERROR("init_hashes: set size NOT EQUAL to feedthrough hash max. size " + std::to_string(ids.size()));
986 ATH_MSG_ERROR("hash max= " + std::to_string(m_feedthroughHashMax));
987 return (1);
988 }
989 nids=0;
990 first = ids.begin();
991 last = ids.end();
992 for (;first != last && nids < m_feedthrough_vec.size(); ++first)
993 {
994 m_feedthrough_vec[nids] = (*first) ;
995 nids++;
996 }
997
998 /* FEB hash */
999 /*==========*/
1000 m_febHashMax = m_full_feb_range.cardinality();
1001 m_feb_vec.resize(m_febHashMax);
1002 nids = 0;
1003 ids.clear();
1004 for (unsigned int i = 0; i < m_full_feb_range.size(); ++i)
1005 {
1006 const Range& range = m_full_feb_range[i];
1007 ConstRangeIterator rit(range);
1008 for (const auto & exp_id :rit)
1009 {
1010 HWIdentifier febId = feb_Id( exp_id[m_bec_index],
1011 exp_id[m_side_index],
1012 exp_id[m_feedthrough_index],
1013 exp_id[m_slot_index] );
1014 if(!(ids.insert(febId)).second)
1015 {
1016 ATH_MSG_ERROR("init_hashes: duplicated id for FEB nb = " + std::to_string(nids));
1017 ATH_MSG_ERROR("expanded Id= " + show_to_string(febId));
1018 }
1019 nids++;
1020 }
1021 }
1022 if(ids.size() != m_febHashMax)
1023 {
1024 ATH_MSG_ERROR("init_hashes: set size NOT EQUAL to FEB hash max. size " + std::to_string(ids.size()));
1025 ATH_MSG_ERROR("hash max " + std::to_string(m_febHashMax));
1026 return (1);
1027 }
1028 nids=0;
1029 first = ids.begin();
1030 last = ids.end();
1031 for (;first != last && nids < m_feb_vec.size(); ++first)
1032 {
1033 m_feb_vec[nids] = (*first) ;
1034 nids++;
1035 }
1036
1037
1038 return (0);
1039}
1040
1041
1042
1043
1045
1046
1047 const int larid=m_lar_impl.unpack(id);
1048 const int laronlineid=m_laronline_impl.unpack(id);
1049 if (larid!=lar_field_value()) return false;
1050
1051 if (laronlineid!=s_lar_online_field_value && laronlineid!=s_lar_onlineCalib_field_value) return false;
1052
1053 const int channel=m_channel_in_slot_impl.unpack(id);
1054 if (channel<0 || channel>128) return false;
1055
1056 const int bec=m_bec_impl.unpack(id);
1057 const int ft=m_feedthrough_impl.unpack(id);
1058 const int slot=m_slot_impl.unpack(id);
1059 if (slot<1) return false;
1060 if (ft<0) return false;
1061 if (bec==0) { // Barrel case
1062 if (ft>31) return false;
1063 if (slot>14) return false;
1064 }
1065 else { //Endcap case
1066 if (ft>27) return false;
1067 if (ft==2 || ft==9 || ft==15 || ft==21){ //Special crate
1068 if (slot >15) return false;
1069 }
1070 else if (ft==6) { //FCAL
1071 if (slot>15) return false;
1072 }
1073 else if (ft>24 && ft<28) { //sFCAL
1074 if (slot>10) return false;
1075 }
1076 else if (ft==3 || ft==10 || ft==16 || ft==22) { //HEC
1077 if (slot==3 || slot==4 || slot>10) return false;
1078 }
1079 else //standard crate
1080 if (slot>13) return false;
1081 }//end endcap
1082 return true;
1083}
1084
1085//=====================
1086// Inline Definitions
1087//=====================
1088
1089
1090
1091
1094 bool checks) const
1095{
1097
1098 /*Pack fields independently */
1101 m_bec_impl.pack (barrel_ec , result);
1102 m_side_impl.pack (pos_neg , result);
1104 if ( m_this_is_slar )
1105 m_slar_impl.pack (1 , result);
1106
1107 /* Do checks */
1108 if(checks)
1109 {
1111 }
1112 return result;
1113}
1119
1120
1122/*=============================================================================== */
1123{
1124 return(m_feedthrough_vec[feedthroughHashId]);
1125}
1126
1128/*=============================================================================== */
1129{
1130 std::vector<HWIdentifier>::const_iterator it = std::lower_bound(m_feedthrough_vec.begin(),m_feedthrough_vec.end(),feedthroughId);
1131 if ( it != m_feedthrough_vec.end() ){
1132 return (it - m_feedthrough_vec.begin());
1133 }
1134 return (0);
1135}
1136
1138/*============================================================================== */
1139{
1140 HWIdentifier result(Id);
1141 m_slot_impl.reset(result);
1143 return(result);
1144}
1145
1147/*====================================================================*/
1148{
1149 return(m_feedthrough_vec.begin());
1150}
1151
1153/*==================================================================*/
1154{
1155 return(m_feedthrough_vec.end());
1156}
1157
1159/*==================================================================*/
1160{
1161 return {feedthrough_begin(), feedthrough_end()};
1162}
1163
1164
1165/* FEB id */
1166/*========*/
1167
1170 int feedthrough, int slot,
1171 bool checks ) const
1172/*==================================================================== */
1173{
1175
1176 /*Pack fields independently */
1179 m_bec_impl.pack (barrel_ec , result);
1180 m_side_impl.pack (pos_neg , result);
1182 m_slot_impl.pack (slot , result);
1183 if ( m_this_is_slar )
1184 m_slar_impl.pack (1 , result);
1185
1186 /* Do checks */
1187 if(checks) {
1189 }
1190 return result;
1191}
1192
1195 int feedthrough, int slot) const
1196{
1198}
1199
1201/*==================================================================================== */
1202{
1203 HWIdentifier result(feedthroughId);
1204 /* Pack fields independently */
1205 m_slot_impl.reset (result);
1206 m_slot_impl.pack (slot , result);
1207 if ( m_this_is_slar )
1208 m_slar_impl.pack (1 , result);
1209
1210 return(result);
1211}
1212
1214/*======================================================================= */
1215{
1216 HWIdentifier result(channelId);
1218 return(result);
1219}
1220
1222/*================================================================== */
1223{
1224 return(m_feb_vec[febHashId]);
1225}
1226
1228/*=============================================================================== */
1229{
1230 // Get the hash caculator for the febs
1231 const HashCalcFeb& hc = m_feb_hash_calcs[m_bec_ft_impl.unpack(febId)];
1232 // Two cases:
1233 // 1) slot values are enumerated and we must look for a matching
1234 // value to obtain the index
1235 // 2) slot values are a continuous range, then the slot index is
1236 // sufficient for the hash calculation
1237 if (!hc.m_slot_values.empty()) {
1238 // find matching value
1239 int slotValue = slot(febId);
1240 for (int i = 0; (unsigned int)i < hc.m_slot_values.size(); ++i) {
1241 if (slotValue == hc.m_slot_values[i]) return (hc.m_hash + i);
1242 }
1243 ATH_MSG_WARNING("LArOnlineID_Base::feb_Hash - ***** WARNING: could not match slot value for has calculation ");
1244 }
1245 size_type slotIndex = m_slot_impl.unpackToIndex(febId);
1246 return (hc.m_hash + slotIndex);
1247}
1248
1251 int slot, int channel,
1252 bool checks) const
1253/*============================================================================== */
1254{
1256 /* Pack fields independently */
1259 m_bec_impl.pack (barrel_ec , result);
1260 m_side_impl.pack (pos_neg , result);
1262 m_slot_impl.pack (slot , result);
1264 if ( m_this_is_slar )
1265 m_slar_impl.pack (1 , result);
1266
1267 /* Do checks */
1268 if(checks) {
1270 }
1271 return result;
1272}
1273
1276 int slot, int channel) const
1277{
1279 do_checks());
1280}
1281
1283/*===================================================================*/
1284{
1285 return(m_channel_vec[channelHashId]);
1286}
1287
1288
1291 bool checks) const
1292/*==================================================================================================== */
1293{
1294 HWIdentifier result(feedthroughId);
1295 /* Pack fields independently */
1296 m_slot_impl.reset (result);
1298 m_slot_impl.pack (slot , result);
1300 if ( m_this_is_slar )
1301 m_slar_impl.pack (1 , result);
1302
1303 /* Do checks */
1304 if(checks) {
1305 channel_Id_checks( feedthroughId, slot, channel );
1306 }
1307 return result;
1308}
1309
1311LArOnlineID_Base::channel_Id(const HWIdentifier feedthroughId,int slot,int channel) const
1312{
1313 return channel_Id (feedthroughId, slot, channel, do_checks());
1314}
1315
1318 bool checks) const
1319/*======================================================================================= */
1320{
1321 HWIdentifier result(febId);
1322 /* Pack fields independently */
1325 if ( m_this_is_slar )
1326 m_slar_impl.pack (1, result);
1327
1328 /* Do checks */
1329 if(checks) {
1330 channel_Id_checks( febId, channel );
1331 }
1332 return result;
1333}
1334
1337{
1338 return channel_Id (febId, channel, do_checks());
1339}
1340
1341//----------------------------------------------------------------------------
1343{
1344 const HashCalc& hc = m_chan_hash_calcs[m_bec_slot_impl.unpack(channelId)];
1345 return (hc.m_hash + channel(channelId));
1346}
1347
1348/* BOOLEAN */
1349
1350/*
1351 *=============================================================
1352 *=============================================================
1353 * Recommended methods
1354 *=============================================================
1355 *=============================================================
1356 */
1357
1359/*========================================================*/
1360{
1361 return (barrel_ec(id)==0);
1362}
1364/*========================================================*/
1365{
1366 return ( barrel_ec(id)==1 && feedthrough(id) == 6 );
1367}
1368
1369
1370
1372/*=================================================================*/
1373{
1374 int bec= barrel_ec(id);
1375 int sl = slot(id);
1376 return (
1377 bec == 0 && sl == 1
1378 );
1379}
1380
1382/*=================================================================*/
1383{/* redefinition (bug fix) */
1384 return (isEMECOW(id) && slot(id)==1);
1385}
1386
1388/*=================================================================*/
1389{/* redefinition with isEMBPS and isEMECPS */
1390 return ( isEMBPS(id) || isEMECPS(id));
1391}
1392
1393
1395/*========================================================*/
1396{
1397 int ft = feedthrough(id);
1398 int sl = slot(id);
1399 int ch = channel(id);
1400 return (
1401 (
1402 isEMBchannel(id) &&
1403 ( (-1 < ft && ft < 32) &&
1404 ( sl == 14 ) &&
1405 ( 63 < ch && ch < 128 )
1406 )
1407 )
1408 ||
1409 (
1410 isEMECchannel(id) && sl == 1 &&
1411 (ft == 2 || ft == 9 || ft == 15 || ft == 21 ) &&
1412 (63 < ch && ch < 128)
1413 )
1414 );
1415}
1416
1417
1418/*
1419 *=============================================================
1420 *=============================================================
1421 * Obsolete methods
1422 *=============================================================
1423 *=============================================================
1424 */
1425
1427/*========================================================*/
1428{/* redefined to isEMBchannel() */
1429 return (isEMBchannel(id));
1430}
1431
1433/*========================================================*/
1434{
1435 return (barrel_ec(id)==1);
1436}
1437
1439/*========================================================*/
1440{/* redefinition (was redundant with isFCALchannel) */
1441 return isFCALchannel(id);
1442}
1444/*========================================================*/
1445{/* redefinition */
1446 return isEMECchannel(id);
1447}
1448
1449
1450/*
1451 *=============================================================
1452 *=============================================================
1453 * Specific UseCases
1454 *=============================================================
1455 *=============================================================
1456 */
1457
1459/*======================================================================*/
1460{
1461 int ft = feedthrough(id);
1462 return ( barrel_ec(id)==1 &&
1463 (ft==0 ||
1464 ft==1 ||
1465 ft==4 ||
1466 ft==5 ||
1467 ft==7 ||
1468 ft==8 ||
1469 ft==11 ||
1470 ft==12 ||
1471 ft==13 ||
1472 ft==14 ||
1473 ft==17 ||
1474 ft==18 ||
1475 ft==19 ||
1476 ft==20 ||
1477 ft==23 ||
1478 ft==24)
1479 );
1480}
1482/*======================================================================*/
1483{
1484 int ft = feedthrough(id);
1485 return ( barrel_ec(id)==1 &&
1486 (ft==2 ||
1487 ft==9 ||
1488 ft==15 ||
1489 ft==21 )
1490 );
1491}
1492
1494/*========================================================*/
1495{
1496 int bec= barrel_ec(id);
1497 int ft = feedthrough(id);
1498 int sl = slot(id);
1499 return ( (bec==0 && sl==15)
1500 ||
1501 ( bec==1 && sl==15 &&
1502 (ft==0 ||
1503 ft==1 ||
1504 ft==4 ||
1505 ft==5 ||
1506 ft==7 ||
1507 ft==8 ||
1508 ft==11 ||
1509 ft==12 ||
1510 ft==13 ||
1511 ft==14 ||
1512 ft==17 ||
1513 ft==18 ||
1514 ft==19 ||
1515 ft==20 ||
1516 ft==23 ||
1517 ft==24 )
1518 )
1519 ||
1520 ( barrel_ec(id)==1 &&
1521 (sl==3 || sl==4 || sl==12) &&
1522 (ft==3 ||
1523 ft==10 ||
1524 ft==16 ||
1525 ft==22 )
1526 )
1527 ||
1528 ( barrel_ec(id)==1 && sl==16 )
1529 ||
1530 ( barrel_ec(id)==1 && ft==27 && sl==11 )
1531 );
1532}
1533
1534
1535/*
1536 *================================================================
1537 *================================================================
1538 * The following methods should NOT be used for new applications:
1539 *================================================================
1540 *================================================================
1541 */
1542
1544/*========================================================*/
1545{
1546 /* Must be used with CARE !
1547 * This method returns true for all slots/channel in HEC crates,
1548 * thus including the EMEC slot/channels that are present
1549 * in slot 1 and slot 2 of HEC crates !
1550 * To access specifically EMEC in HEC slot/channel, you then
1551 * have to use isEMECinHECchannel()
1552 */
1553 int ft = feedthrough(id);
1554 return (
1555 //(slot(id)!=1 && slot(id)!= 2) &&
1556 barrel_ec(id)==1 &&
1557 (ft==3 ||
1558 ft==10 ||
1559 ft==16 ||
1560 ft==22 )
1561 );
1562}
1563
1565/*========================================================*/
1566{
1567 /* Must be used with CARE !
1568 * This method returns true for all slots/channel in HEC crates,
1569 * thus including the EMEC slot/channels that are present
1570 * in slot 1 and slot 2 of HEC crates !
1571 * To access specifically EMEC in HEC slot/channel, you then
1572 * have to use isEMECinHECchannel()
1573 */
1574 int ft = feedthrough(febId);
1575 return ( barrel_ec(febId)==1 &&
1576 (ft==3 ||
1577 ft==10 ||
1578 ft==16 ||
1579 ft==22 )
1580 );
1581}
1582
1584/*=================================================================*/
1585{/* re-definition with isEMECIW */
1586 return isEMECIW(id);
1587}
1588
1589
1590
1591
1592
1593
1594
1595
1596
1598 /*=======================================================================*/
1599{
1600 return m_feedthroughHashMax;
1601}
1603/*=======================================================================*/
1604{
1605 return m_febHashMax;
1606}
1608/*====================================================================*/
1609{
1610 return m_channelHashMax;
1611}
1612
1613
1614
1615
1617/*====================================================================*/
1618{
1619 return(m_feb_vec.begin());
1620}
1622/*==================================================================*/
1623{
1624 return(m_feb_vec.end());
1625}
1627/*==================================================================*/
1628{
1629 return {feb_begin(), feb_end()};
1630}
1631
1633/*======================================================================*/
1634{
1635 return(m_channel_vec.begin());
1636}
1638/*======================================================================*/
1639{
1640 return(m_channel_vec.end());
1641}
1643/*======================================================================*/
1644{
1645 return {channel_begin(), channel_end()};
1646}
1647
1649/*=========================================================*/
1650{
1651 return (m_bec_impl.unpack(id));
1652}
1653
1655/*===========================================================*/
1656{
1657 return (m_feedthrough_impl.unpack(id));
1658}
1659
1661/*===========================================================*/
1662{
1663 return (m_side_impl.unpack(id));
1664}
1665
1666
1668/*=====================================================*/
1669{
1670 return (m_slot_impl.unpack(id));
1671}
1672
1674/*=====================================================*/
1675{
1676 return (m_channel_in_slot_impl.unpack(id));
1677}
1678
1680/*=====================================================*/
1681{
1682 return (m_slar_impl.unpack(id));
1683}
1684
1685
1686/*========================================*/
1688/*========================================*/
1689{
1690 unsigned int nids=0;
1691 std::set<HWIdentifier> ids;
1692 for (unsigned int i = 0; i < m_full_calib_laronline_range.size(); ++i) {
1693 const Range& range = m_full_calib_laronline_range[i];
1694 ConstRangeIterator rit(range);
1695 for (const auto & exp_id : rit) {
1696 HWIdentifier id = this->calib_channel_Id(exp_id[m_bec_index],
1697 exp_id[m_side_index],
1698 exp_id[m_feedthrough_index],
1699 exp_id[m_slot_index],
1700 exp_id[m_channel_in_slot_index]);
1701 if(!(ids.insert(id)).second) {
1702 ATH_MSG_WARNING("LArOnlineID_Base::init_calib_Hashes: Error: duplicated id for channel id. nids= "
1703 + std::to_string(nids) + " compact Id " + std::string(exp_id) + " " + show_to_string(id));
1704 }
1705 nids++;
1706 }
1707 }
1708 unsigned int nidtb=0;
1709 std::set<HWIdentifier>::const_iterator first = ids.begin();
1710 std::set<HWIdentifier>::const_iterator last = ids.end();
1711 for (;first != last && nidtb < nids; ++first) {
1712 m_calib_channel_vec.push_back(*first);
1713 nidtb++;
1714 }
1716
1717 /* FEB hash */
1718 /*==========*/
1719 nids = 0;
1720 ids.clear();
1721 for (unsigned int i = 0; i < m_full_calib_module_range.size(); ++i) {
1722 const Range& range = m_full_calib_module_range[i];
1723 ConstRangeIterator rit(range);
1724 for (const auto & exp_id : rit) {
1725 HWIdentifier febId = calib_module_Id( exp_id[m_bec_index],
1726 exp_id[m_side_index],
1727 exp_id[m_feedthrough_index],
1728 exp_id[m_slot_index] );
1729 if(!(ids.insert(febId)).second){
1730 ATH_MSG_WARNING("LArOnlineID_Base::init_calibhashes: Warning: duplicated id for feb id. nids= "
1731 + std::to_string(nids) + " compact Id " + std::string(exp_id) + " " + show_to_string(febId));
1732 }
1733 nids++;
1734 }
1735 }
1736 nidtb=0;
1737 first = ids.begin();
1738 last = ids.end();
1739 for (;first != last && nidtb < nids; ++first)
1740 {
1741 m_calib_module_vec.push_back(*first);
1742 nidtb++;
1743 }
1745 return (0);
1746}
1747
1748
1749
1750
1751
1752
1753
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static const int s_lar_online_field_value
static const int s_lar_onlineCalib_field_value
#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:357