ATLAS Offline Software
Loading...
Searching...
No Matches
LArConditionsContainerBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
14
16
17// Services/helpers
22
23// Gaudi/Athena
26#include <atomic>
27
35
43
44
47
48
49
50StatusCode
52{
53 //Get LArOnlineID....
54 ServiceHandle<StoreGateSvc> detStore("DetectorStore", "LArConditionsContainerBase");
55 CHECK( detStore.isValid() );
56
58 //Dealing with supercells, need supercell identifier helper
59 const LArOnline_SuperCellID* onlID = nullptr;
60 CHECK( detStore->retrieve(onlID,"LArOnline_SuperCellID") );
61 m_onlineHelper=onlID;//cast to base-class
62
63 const CaloCell_SuperCell_ID* oflID = nullptr;
64 CHECK( detStore->retrieve(oflID,"CaloCell_SuperCell_ID") );
65 m_offlineHelper=oflID; //cast to base-class
66 }
67 else {
68 //Regular readout
69 const LArOnlineID* onlID = nullptr;
70 CHECK( detStore->retrieve(onlID,"LArOnlineID") );
71 m_onlineHelper=onlID;//cast to base-class
72
73 const CaloCell_ID* oflID = nullptr;
74 CHECK( detStore->retrieve(oflID,"CaloCell_ID") );
75 m_offlineHelper=oflID; //cast to base-class
76 }
78 // initialize the grouping
81 // Set initialized to true
82 m_isInitialized = true;
84 return (StatusCode::SUCCESS);
85}
86
87void
93
94StatusCode
95LArConditionsContainerBase::setGroupingType(const std::string& groupingStr, MsgStream& logStr)
97 // Set grouping type - default is SubDet
98 if (groupingStr == "Single")
100 return StatusCode::SUCCESS;
101 }
102 else if (groupingStr == "SubDetector")
104 return StatusCode::SUCCESS;
105 }
106 else if (groupingStr == "ExtendedSubDetector")
108 return StatusCode::SUCCESS;
109 }
110 else if (groupingStr == "FeedThrough")
112 return StatusCode::SUCCESS;
113 }
114 else if (groupingStr == "ExtendedFeedThrough") {
116 return StatusCode::SUCCESS;
117 }
118 else if (groupingStr == "SuperCells") {
120 return StatusCode::SUCCESS;
121 }
122
123 logStr << MSG::ERROR << "Unknown COOL Channel Grouping '"<< groupingStr <<"'. Allowed values are:" << endmsg;
124 logStr << MSG::ERROR << "'Single','SubDetector', 'ExtendedSubDetector','FeedThrough','ExtendedFeedThrough'" << endmsg;
125 return StatusCode::FAILURE;
126}
127
128
129StatusCode
131{
132 MsgStream log(Athena::getMessageSvc(), "LArConditionsContainerBase");
133 log << MSG::DEBUG << "initGrouping "<< endmsg;
134
135 // We allow for different groupings
136
137 if (Unknown == m_groupType) {
138 log << MSG::ERROR << "Unknown grouping "<< endmsg;
139
140 // Not yet known
141 }
143
144 log << MSG::DEBUG << "Single group "<< endmsg;
145
146 // Only one group - add all feb ids to channel 0
147 std::vector<HWIdentifier>::const_iterator febIt = m_onlineHelper->feb_begin();
148 std::vector<HWIdentifier>::const_iterator febEnd = m_onlineHelper->feb_end();
150 for (; febIt != febEnd; ++febIt) {
151 febIds.push_back((*febIt).get_identifier32().get_compact());
152 }
153 // add for LArCondFEBIdChanMap
154 unsigned int nChanPerGain = 1;
155 unsigned int minGain = 0;
156 unsigned int nGains = 3;
157 m_febIdChanMap = LArCondFEBIdChanMap(nChanPerGain, minGain, nGains);
158 m_febIdChanMap.addFEBIdVector(0, febIds);
159 }
160 else if (SubDetectorGrouping == m_groupType) {
161
162 log << MSG::DEBUG << "Subdetector grouping "<< endmsg;
163
164 // Set up LArCondFEBIdChanMap for four groups: EM barrel, EMEM, HEC, FCal
165 std::vector<HWIdentifier>::const_iterator febIt = m_onlineHelper->feb_begin();
166 std::vector<HWIdentifier>::const_iterator febEnd = m_onlineHelper->feb_end();
167
172
173 for (; febIt != febEnd; ++febIt) {
174 unsigned int febId = (*febIt).get_identifier32().get_compact();
175 if (m_onlineHelper->isEMBchannel(*febIt)) {
176 emBarrel.push_back(febId);
177 }
178 else if (m_onlineHelper->isEMECchannel(*febIt)) {
179 emEndcap.push_back(febId);
180 }
181 else if (m_onlineHelper->isHECchannel(*febIt)) {
182 hec.push_back(febId);
183 }
184 else if (m_onlineHelper->isFCALchannel(*febIt)) {
185 fcal.push_back(febId);
186 }
187 else {
188 log << MSG::DEBUG << "Uassociated FEB id: "
189 << MSG::hex << (febId) << MSG::dec
190 << " isCalib " << m_onlineHelper->isCalibration(*febIt)
191 << " " << m_onlineHelper->show_to_string(*febIt)
192 << endmsg;
193 }
194 }
195 // add for LArCondFEBIdChanMap
196 unsigned int nChanPerGain = 4;
197 unsigned int minGain = 0;
198 unsigned int nGains = 3;
199 m_febIdChanMap = LArCondFEBIdChanMap(nChanPerGain, minGain, nGains);
200 m_febIdChanMap.addFEBIdVector(0, emBarrel);
201 m_febIdChanMap.addFEBIdVector(1, emEndcap);
202 m_febIdChanMap.addFEBIdVector(2, hec);
203 m_febIdChanMap.addFEBIdVector(3, fcal);
204
205// unsigned int coolChannel;
206// for (unsigned int gain = 0; gain < nGains; ++gain) {
207// for (unsigned int i = 0; i < emBarrel.size(); ++i) {
208// if (!m_febIdChanMap.getChannel(emBarrel[i], gain, coolChannel)) {
209// log << MSG::DEBUG << "Unable to get cool channel for em barrel - i = "
210// << i << endmsg;
211// return (StatusCode::FAILURE);
212// }
213// }
214// for (unsigned int i = 0; i < emEndcap.size(); ++i) {
215// if (!m_febIdChanMap.getChannel(emEndcap[i], gain, coolChannel)) {
216// log << MSG::DEBUG << "Unable to get cool channel for em endcap - i = "
217// << i << endmsg;
218// return (StatusCode::FAILURE);
219// }
220// }
221// for (unsigned int i = 0; i < hec.size(); ++i) {
222// if (!m_febIdChanMap.getChannel(hec[i], gain, coolChannel)) {
223// log << MSG::DEBUG << "Unable to get cool channel for hec - i = "
224// << i << endmsg;
225// return (StatusCode::FAILURE);
226// }
227// }
228// for (unsigned int i = 0; i < fcal.size(); ++i) {
229// if (!m_febIdChanMap.getChannel(fcal[i], gain, coolChannel)) {
230// log << MSG::DEBUG << "Unable to get cool channel for fcal - i = "
231// << i << endmsg;
232// return (StatusCode::FAILURE);
233// }
234// }
235// }
236 }
238 log << MSG::DEBUG << "Extended Subdetector grouping "<< endmsg;
239
240 // Set up LArCondFEBIdChanMap for four groups: EM barrel, EM barrel PS ,EMEC EMEC PS, HEC, FCal
241 std::vector<HWIdentifier>::const_iterator febIt = m_onlineHelper->feb_begin();
242 std::vector<HWIdentifier>::const_iterator febEnd = m_onlineHelper->feb_end();
243
244 LArCondFEBIdChanMap::FEBIdVector emBarrel[2] = {};
245 LArCondFEBIdChanMap::FEBIdVector emBarrelPS[2] = {};
246 LArCondFEBIdChanMap::FEBIdVector emEndcap[2] = {};
247 LArCondFEBIdChanMap::FEBIdVector emEndcapPS[2] = {};
250
251 for (; febIt != febEnd; ++febIt) {
252 int iside = m_onlineHelper->pos_neg(*febIt);
253 // Sanity check
254 if(iside <0 || iside > 1) {
255 log << MSG::ERROR << "Wrong side id: "<< iside <<" from: "
256 << MSG::hex << *febIt << MSG::dec << endmsg;
257 return (StatusCode::FAILURE);
258 }
259 unsigned int febId = (*febIt).get_identifier32().get_compact();
260 if (m_onlineHelper->isEMBPS(*febIt)) {
261 emBarrelPS[iside].push_back(febId);
262 }
263 else if (m_onlineHelper->isEMECPS(*febIt)) {
264 emEndcapPS[iside].push_back(febId);
265 }
266 else if (m_onlineHelper->isEMBchannel(*febIt)) {
267 emBarrel[iside].push_back(febId);
268 }
269 else if (m_onlineHelper->isEMECchannel(*febIt)) {
270 emEndcap[iside].push_back(febId);
271 }
272 else if (m_onlineHelper->isHECchannel(*febIt)) {
273 hec[iside].push_back(febId);
274 }
275 else if (m_onlineHelper->isFCALchannel(*febIt)) {
276 fcal[iside].push_back(febId);
277 }
278 else {
279 log << MSG::DEBUG << "Uassociated FEB id: "
280 << MSG::hex << (febId) << MSG::dec
281 << " isCalib " << m_onlineHelper->isCalibration(*febIt)
282 << " " << m_onlineHelper->show_to_string(*febIt)
283 << endmsg;
284 }
285 }
286 // add for LArCondFEBIdChanMap
287 unsigned int nChanPerGain = 12;
288 unsigned int minGain = 0;
289 unsigned int nGains = 3;
290 m_febIdChanMap = LArCondFEBIdChanMap(nChanPerGain, minGain, nGains);
291 for (int iside=0; iside<2; ++iside) {
292 m_febIdChanMap.addFEBIdVector(0+iside*6, emBarrel[iside]);
293 m_febIdChanMap.addFEBIdVector(1+iside*6, emBarrelPS[iside]);
294 m_febIdChanMap.addFEBIdVector(2+iside*6, emEndcap[iside]);
295 m_febIdChanMap.addFEBIdVector(3+iside*6, emEndcapPS[iside]);
296 m_febIdChanMap.addFEBIdVector(4+iside*6, hec[iside]);
297 m_febIdChanMap.addFEBIdVector(5+iside*6, fcal[iside]);
298 }
299
300 }
301 else if (FeedThroughGrouping == m_groupType) {
302 log << MSG::DEBUG << "FeedThrough grouping "<< endmsg;
303
304 // Set up LArCondFEBIdChanMap for four groups: EM barrel, EMEM, HEC, FCal
305 std::vector<HWIdentifier>::const_iterator febIt = m_onlineHelper->feb_begin();
306 std::vector<HWIdentifier>::const_iterator febEnd = m_onlineHelper->feb_end();
307
308 std::vector<LArCondFEBIdChanMap::FEBIdVector> ft(m_onlineHelper->feedthroughHashMax());
309
310
311 for (; febIt != febEnd; ++febIt) {
312 // Find the feedthru hash and add to vector
313 HWIdentifier febId = (*febIt);
314 int b_ec = m_onlineHelper->barrel_ec(febId);
315 int p_n = m_onlineHelper->pos_neg(febId);
316 int f_t = m_onlineHelper->feedthrough(febId);
317 HWIdentifier ftid = m_onlineHelper->feedthrough_Id(b_ec, p_n, f_t);
318 IdentifierHash fthash = m_onlineHelper->feedthrough_Hash(ftid);
319 if (fthash < ft.size()) {
320 ft[fthash].push_back(febId.get_identifier32().get_compact());
321 }
322 else {
323 log << MSG::ERROR << "Feedthru hash > channel map size: id, hash, size "
324 << MSG::hex << febId << MSG::dec << " "
325 << ftid << " " << ft.size()
326 << endmsg;
327 return (StatusCode::FAILURE);
328 }
329 }
330 // add for LArCondFEBIdChanMap
331 unsigned int nChanPerGain = ft.size();
332 unsigned int minGain = 0;
333 unsigned int nGains = 3;
334 m_febIdChanMap = LArCondFEBIdChanMap(nChanPerGain, minGain, nGains);
335 for (unsigned int i = 0; i < ft.size(); ++i) {
336 m_febIdChanMap.addFEBIdVector(i, ft[i]);
337 }
338 }
339 else if (ExtendedFTGrouping == m_groupType) {
340
341 log << MSG::DEBUG << "Extended FeedThrough grouping (PS goes seperatly, EMEC in HEC as well)"<< endmsg;
342
343 // Set up LArCondFEBIdChanMap for four groups: EM barrel, EMEM, HEC, FCal
344 std::vector<HWIdentifier>::const_iterator febIt = m_onlineHelper->feb_begin();
345 std::vector<HWIdentifier>::const_iterator febEnd = m_onlineHelper->feb_end();
346
347 //Vectors of groups
348 //Standard Febs (one group per FT)
349 std::vector<LArCondFEBIdChanMap::FEBIdVector> ft(m_onlineHelper->feedthroughHashMax());
350 //Presampler FEBs (one group per FT)
351 std::vector<LArCondFEBIdChanMap::FEBIdVector> ftPS(m_onlineHelper->feedthroughHashMax());
352 //EMEC channel in special crate:
353 std::vector<LArCondFEBIdChanMap::FEBIdVector> ftSpecial(8); //How many are there?
354
355 for (; febIt != febEnd; ++febIt) {
356 // Find the feedthru hash and add to vector
357 HWIdentifier febId = (*febIt);
358 int b_ec = m_onlineHelper->barrel_ec(febId);
359 int p_n = m_onlineHelper->pos_neg(febId);
360 int f_t = m_onlineHelper->feedthrough(febId);
361 HWIdentifier ftid = m_onlineHelper->feedthrough_Id(b_ec, p_n, f_t);
362 IdentifierHash fthash = m_onlineHelper->feedthrough_Hash(ftid);
363
364 //sanity check
365 if (fthash >= ft.size()) {
366 log << MSG::ERROR << "Feedthru hash > channel map size: id, hash, size "
367 << MSG::hex << febId << MSG::dec << " "
368 << ftid << " " << ft.size()
369 << endmsg;
370 return (StatusCode::FAILURE);
371 }
372
373 //Subdivide into specific cases:
374 if (!m_onlineHelper->isEMECinHECchannel(febId)) { //this is taken care of further down
375 if (m_onlineHelper->isPS(febId))
376 ftPS[fthash].push_back(febId.get_identifier32().get_compact()); //PS goes in separate channels
377 else
378 ft[fthash].push_back(febId.get_identifier32().get_compact());
379 }
380 }
381 //EMEC in HEC crate: Do 'by hand'
382 //FTs: 3,10,16,22 Slots: 1,2
383 //parameters: ec,pn,ft,slot
384 ftSpecial[0].push_back(m_onlineHelper->feb_Id(1,0,3,1).get_identifier32().get_compact());
385 ftSpecial[0].push_back(m_onlineHelper->feb_Id(1,0,3,2).get_identifier32().get_compact());
386
387 ftSpecial[1].push_back(m_onlineHelper->feb_Id(1,1,3,1).get_identifier32().get_compact());
388 ftSpecial[1].push_back(m_onlineHelper->feb_Id(1,1,3,2).get_identifier32().get_compact());
389
390 ftSpecial[2].push_back(m_onlineHelper->feb_Id(1,0,10,1).get_identifier32().get_compact());
391 ftSpecial[2].push_back(m_onlineHelper->feb_Id(1,0,10,2).get_identifier32().get_compact());
392
393 ftSpecial[3].push_back(m_onlineHelper->feb_Id(1,1,10,1).get_identifier32().get_compact());
394 ftSpecial[3].push_back(m_onlineHelper->feb_Id(1,1,10,2).get_identifier32().get_compact());
395
396 ftSpecial[4].push_back(m_onlineHelper->feb_Id(1,0,16,1).get_identifier32().get_compact());
397 ftSpecial[4].push_back(m_onlineHelper->feb_Id(1,0,16,2).get_identifier32().get_compact());
398
399 ftSpecial[5].push_back(m_onlineHelper->feb_Id(1,1,16,1).get_identifier32().get_compact());
400 ftSpecial[5].push_back(m_onlineHelper->feb_Id(1,1,16,2).get_identifier32().get_compact());
401
402 ftSpecial[6].push_back(m_onlineHelper->feb_Id(1,0,22,1).get_identifier32().get_compact());
403 ftSpecial[6].push_back(m_onlineHelper->feb_Id(1,0,22,2).get_identifier32().get_compact());
404
405 ftSpecial[7].push_back(m_onlineHelper->feb_Id(1,1,22,1).get_identifier32().get_compact());
406 ftSpecial[7].push_back(m_onlineHelper->feb_Id(1,1,22,2).get_identifier32().get_compact());
407
408
409 // add for LArCondFEBIdChanMap
410 unsigned int nChanPerGain = ft.size()+ftPS.size()+ftSpecial.size();
411 unsigned int minGain = 0;
412 unsigned int nGains = 3;
413 unsigned int iCoolChannel=0;
414 m_febIdChanMap = LArCondFEBIdChanMap(nChanPerGain, minGain, nGains);
415 for (unsigned int i = 0; i < ft.size(); ++i) {
416 m_febIdChanMap.addFEBIdVector(iCoolChannel++, ft[i]);
417 }
418 for (unsigned int i = 0; i < ftPS.size(); ++i) {
419 m_febIdChanMap.addFEBIdVector(iCoolChannel++, ftPS[i]);
420 }
421 for (unsigned int i = 0; i < ftSpecial.size(); ++i) {
422 m_febIdChanMap.addFEBIdVector(iCoolChannel++, ftSpecial[i]);
423 }
424 } else {
425 log << MSG::ERROR << "Unknown COOL Channel grouping " << m_groupType << endmsg;
426 return StatusCode::FAILURE;
427 }
428 // Resize the vector mapping the COOL channel to the
429 // DataVector.
430 m_channelToMultChanCollIndex = std::vector<unsigned int>(m_febIdChanMap.totalChannels(), 9999);
431
432 log << MSG::DEBUG << "Number of channels per gain "
433 << m_febIdChanMap.channelsPerGain()
434 << endmsg;
435
436 log << MSG::DEBUG << "Mininum gain value "
437 << m_febIdChanMap.minGain()
438 << endmsg;
439
440 log << MSG::DEBUG << "Number of gain values "
441 << m_febIdChanMap.nGains()
442 << endmsg;
443
444 log << MSG::DEBUG << "Number of offset channels "
445 << m_febIdChanMap.nOffsetChannels()
446 << endmsg;
447
448 log << MSG::DEBUG << "Total number of channels "
449 << m_febIdChanMap.totalChannels()
450 << endmsg;
451
452 return (StatusCode::SUCCESS);
453
454}
455
456std::string
458{
459 // Return grouping type in string form
460 switch (m_groupType){
461 case 0:
462 return ("Unknown");
463 case 1:
464 return ("SingleGroup");
465 case 2:
466 return ("SubDetectorGrouping");
467 case 3:
468 return ("FeedThroughGrouping");
469 case 4:
470 return ("ExtendedFTGrouping");
471 case 5:
472 return ("ExtendedSubDetGrouping");
473 case 6:
474 return ("SuperCells");
475 }
476 return ("Unknown");
477}
478
479const LArOnlineID_Base*
484
485const CaloCell_Base_ID*
490
491
494 unsigned int coolChannel) const
495{
496 return (m_febIdChanMap.febIdVector(gain, coolChannel));
497}
498
499void
501 unsigned int gain,
502 unsigned int& index,
503 unsigned int& coolChannel)
504{
505 MsgStream log(Athena::getMessageSvc(), "LArConditionsContainerBase");
506
507 index = 9999;
508 coolChannel = 0;
509 // First get cool channel number
510 if (!m_onlineHelper) {
511 log << MSG::ERROR << "correctionIndex> Could not get online id helper!" << endmsg;
512 return;
513 }
514
515 int p_n = m_onlineHelper->pos_neg(id);
516 if (m_onlineHelper->isEMBPS(id)) {
517 if (p_n) coolChannel = LArCondFEBIdChanMap::PSBA; // PS Barrel
518 else coolChannel = LArCondFEBIdChanMap::PSBC; // PS Barrel
519 }
520 else if (m_onlineHelper->isEMECPS(id)) {
521 if (p_n) coolChannel = LArCondFEBIdChanMap::PSECA; // PS Endcap
522 else coolChannel = LArCondFEBIdChanMap::PSECC; // PS Endcap
523 }
524 else if (m_onlineHelper->isEMBchannel(id)) {
525 if (p_n) coolChannel = LArCondFEBIdChanMap::EMBA; // EM Barrel
526 else coolChannel = LArCondFEBIdChanMap::EMBC; // EM Barrel
527 }
528 else if (m_onlineHelper->isEMECchannel(id)) {
529 if (p_n) coolChannel = LArCondFEBIdChanMap::EMECA; // EM Endcap
530 else coolChannel = LArCondFEBIdChanMap::EMECC; // EM Endcap
531 }
532 else if (m_onlineHelper->isHECchannel(id)) {
533 if (p_n) coolChannel = LArCondFEBIdChanMap::HECA; // HEC A
534 else coolChannel = LArCondFEBIdChanMap::HECC; // HEC C
535 }
536 else if (m_onlineHelper->isFCALchannel(id)) {
537 if (p_n) coolChannel = LArCondFEBIdChanMap::FCALA; // FCAL A
538 else coolChannel = LArCondFEBIdChanMap::FCALC; // FCAL C
539 }
540
541 if (!coolChannel) {
542 log << MSG::ERROR << "correctionIndex> coolChannel not found! Online ids: "
543 << " " << m_onlineHelper->show_to_string(id)
544 << endmsg;
545 return;
546 }
547
548 // add on offset for gain
549 unsigned int gainOffset = (gain - m_febIdChanMap.minGain())*LArCondFEBIdChanMap::NCORRTYPE;
550 coolChannel += gainOffset;
551
552 // look up the index in the table
553 if (coolChannel >= m_channelToMultChanCollIndex.size()) {
554 log << MSG::ERROR << "correctionIndex> coolChannel larger than lookup table: chan, size "
555 << coolChannel << " " << m_channelToMultChanCollIndex.size()
556 << endmsg;
557 }
558 else {
559 index = m_channelToMultChanCollIndex[coolChannel];
560 }
561}
562
563bool
565{
566 // If setFlag is true, change the value of static flag, otherwise
567 // return current value
568
569 // Default value is true
570 static std::atomic<bool> applyCorrs = true;
571
572 if (setFlag) applyCorrs = flag;
573
574 return (applyCorrs);
575}
576
#define endmsg
Helper class for offline supercell identifiers.
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
This file contain an implementation base class for LArConditionsContainer.
Helper base class for offline cell identifiers.
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
Helper class for offline supercell identifiers.
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
This class maps FEB IDs to/from COOL channel ids.
std::vector< FEBId > FEBIdVector
static bool applyCorrectionsAtInit(bool setFlag=false, bool flag=true)
provide access to flag which determines corrections are applied at initialize, i.e.
const LArOnlineID_Base * m_onlineHelper
std::vector< unsigned int > m_channelToMultChanCollIndex
LArCondFEBIdChanMap::FEBIdVector FEBIdVector
const FEBIdVector & febIdVector(unsigned int gain, unsigned int coolChannel) const
Access to a FEB ID vector for a given gain and COOL channel.
void setGroupingType(GroupingType type)
allow group type to be set externally - need to (re)initialize after setting grouping type
void correctionIndexAndCoolChannel(HWIdentifier id, unsigned int gain, unsigned int &index, unsigned int &coolChannel)
const CaloCell_Base_ID * offlineHelper() const
provide access to offline id helper
const LArOnlineID_Base * onlineHelper() const
provide access to online id helper
const CaloCell_Base_ID * m_offlineHelper
LArConditionsContainerBase()
Default constructor.
Helper for the Liquid Argon Calorimeter cell identifiers.
IMessageSvc * getMessageSvc(bool quiet=false)
Definition index.py:1