219{
221 const EventContext& ctx = Gaudi::Hive::currentContext();
225 return StatusCode::SUCCESS;
226 }
227
229
232
236 int bunchId = eventInfo->
bcid();
237
238
242 return StatusCode::SUCCESS;
243 }
244
245
246 SG::ReadCondHandle<BunchCrossingCondData> bccd (
m_bcDataKey,ctx);
247 const BunchCrossingCondData* bunchCrossing=*bccd;
248 if (!bunchCrossing) {
250 return StatusCode::FAILURE;
251 }
252
253 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{
m_caloMgrKey};
255 const CaloDetDescrManager* caloMgr = *caloMgrHandle;
256
258 if (!bccd->isFilled(bunchId)) {
261 return StatusCode::SUCCESS;
262 }
263 }
264
265
270 if (eventIndex < 0) return StatusCode::FAILURE;
271 }
272
273 SG::ReadHandle<LArDigitContainer> hdlDigit(
m_digitsKey, ctx);
274 if(!hdlDigit.isValid()) {
276 return StatusCode::SUCCESS;
277 } else
279 const LArDigitContainer* larDigitContainer = &(*hdlDigit);
280
281 if (larDigitContainer->
empty()) {
284 return StatusCode::SUCCESS;
285 }
286
287 SG::ReadHandle<LArRawChannelContainer> hdlRaw(
m_channelsKey, ctx);
288 if(!hdlRaw.isValid()) {
290 return StatusCode::SUCCESS;
291 } else
294
298 return StatusCode::SUCCESS;
299 }
300
301
302
303 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
m_cablingKey};
304 const LArOnOffIdMapping*
cabling=*cablingHdl;
305 if(!cabling) {
306 ATH_MSG_ERROR(
"Do not have cabling object LArOnOffIdMapping" );
307 return StatusCode::FAILURE;
308 }
309
310 SG::ReadCondHandle<LArADC2MeV> adc2mevHdl(
m_adc2mevKey, ctx);
311 const LArADC2MeV* adc2MeV=*adc2mevHdl;
312 if(!adc2MeV) {
314 return StatusCode::FAILURE;
315 }
316
318 const ILArPedestal* pedestals=*pedHdl;
319 if (!pedestals) {
321 return StatusCode::FAILURE;
322 }
323
324 const ILArAutoCorr* aCorr=nullptr;
326 SG::ReadCondHandle<ILArAutoCorr> acorrHdl(
m_acorrKey, ctx);
327 aCorr=*acorrHdl;
328 if (!aCorr) {
330 return StatusCode::FAILURE;
331 }
332 }
333
334 SG::ReadCondHandle<LArBadChannelCont> readHandle{
m_BCKey};
336 if(!bcCont) {
338 return StatusCode::FAILURE;
339 }
340
341 const LArOFIterResultsContainer* ofIterResult = nullptr;
345 } else {
347 }
348 }
349
352 const std::map<unsigned int,uint16_t>& febErrorMap = larFebErrorSummary->
get_all_febs();
353 std::map<unsigned int, const LArRawChannel*> channelsToKeep;
354
357 {
359 if (
m_bcMask.cellShouldBeMasked(bcCont,
channel->channelID()))
continue;
360
362
363 if (!
hash.is_valid()) {
365 << ") does not correspond to a valid hash -- returning StatusCode::FAILURE." );
366 return StatusCode::FAILURE;
367 }
370 HistoryContainer* histCont =
m_samples->hist_cont(hash);
371 CellInfo*
info =
nullptr;
372 if (!histCont) {
373 HWIdentifier channelID =
channel->hardwareID();
374 const Identifier
id =
cabling->cnvToIdentifier(channelID);
375 const CaloDetDescrElement* caloDetElement = caloMgr->
get_element(
id);
377 if (!info) continue;
379 }
380 }
381 }
382
383 std::map<HWIdentifier, LArOFIterResultsContainer::const_iterator> ofcResultPosition;
385 for (LArOFIterResultsContainer::const_iterator ofResult = ofIterResult->begin();
386 ofResult != ofIterResult->end(); ++ofResult)
387 ofcResultPosition[ofResult->getChannelID()] = ofResult;
388
390 << " " << (ofIterResult ? ofIterResult->size() : 0) << " "
392 }
394 const CaloNoise* noiseCDO=*noiseHdl;
395
397 digit != larDigitContainer->
end(); ++digit)
398 {
399
401
402 std::map<unsigned int, const LArRawChannel*>::const_iterator findChannel = channelsToKeep.find(hash);
403 if (findChannel == channelsToKeep.end()) continue;
404 const LArRawChannel* rawChannel = findChannel->second;
405
406
407 HWIdentifier channelID = (*digit)->hardwareID();
411
412
415
416
417 const bool connected =
cabling->isOnlineConnected(channelID);
419
420
421 float pedestal = pedestals->
pedestal(channelID, gain);
422 float pedestalRMS = pedestals->
pedestalRMS(channelID, gain);
424 const std::vector<short>& samples = (*digit)->samples();
426 for (short sample : samples)
430 }
431
432 const Identifier
id =
cabling->cnvToIdentifier(channelID);
433 const CaloDetDescrElement* caloDetElement = nullptr;
434
435 HistoryContainer* histCont =
m_samples->hist_cont(hash);
436 CellInfo*
info =
nullptr;
437 if (!histCont) {
438 if (!caloDetElement) caloDetElement = caloMgr->
get_element(
id);
440 if (!info) continue;
441 histCont =
m_samples->makeNewHistory(hash, info);
442 }
443 else
445
447 unsigned int status = 0xFFFFFFFF;
448 if (connected) {
449 if (!caloDetElement) caloDetElement = caloMgr->
get_element(
id);
454 if (findError != febErrorMap.end()) {
455 unsigned int febErrWord = findError->second;
457 }
458 }
459
460
463 const LArAutoCorrComplete* autoCorrObj = dynamic_cast<const LArAutoCorrComplete*>(aCorr);
464 if (!autoCorrObj)
465 ATH_MSG_WARNING (
"AutoCorr object is not of type LArAutoCorrComplete!" );
466 else
467 autoCorr = autoCorrObj->
autoCorr(channelID, gain);
468 }
469
470 if (!
info->shape((*digit)->gain()))
471 info->setShape((*digit)->gain(),
m_dumperTool->retrieveShape(channelID, gain));
472
473 if (!eventData) {
475 if (eventIndex < 0) return StatusCode::FAILURE;
476 }
477
478 DataContainer*
data =
479 new DataContainer((*digit)->gain(), (*digit)->samples(),
481 rawChannel->
time()/
double(1000),
483 eventIndex,
484 autoCorr,
485 noise, pedestal, pedestalRMS, status);
486
487
488
489
490
491
492
493
494
495
496
497
498 const auto ramp=adc2MeV->
ADC2MEV(channelID,gain);
499 data->setADCMax(rawChannel->
energy()/ramp[1]);
500
501
503 }
504
506 std::map<unsigned int, const LArRawSC*> scToKeep;
507
508 SG::ReadHandle<LArRawSCContainer> hdlSC(
m_rawscKey, ctx);
509 if(!hdlSC.isValid()) {
511 return StatusCode::SUCCESS;
512 } else
514
515 if (hdlSC->empty()) {
517 return StatusCode::SUCCESS;
518 }
519
521 if(!hdlrecoSC.isValid()) {
523 return StatusCode::SUCCESS;
524 } else
526
527 if (hdlrecoSC->empty()) {
529 return StatusCode::SUCCESS;
530 }
531
532 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
m_cablingKeySC, ctx};
533 const LArOnOffIdMapping* cablingSC=*cablingHdl;
534 if(!cablingSC) {
535 ATH_MSG_ERROR(
"Do not have cabling object LArOnOffIdMapping" );
536 return StatusCode::FAILURE;
537 }
538
541 const CaloSuperCellDetDescrManager* caloMgrSC = *caloMgrHandle;
542
544 const ILArPedestal* pedestalsSC=*pedHdl;
545 if (!pedestals) {
546 ATH_MSG_ERROR(
"Failed to retrieve pedestal cond obj for SC");
547 return StatusCode::FAILURE;
548 }
549
550 std::map<unsigned int, std::pair<float, std::pair<float,float> > > channelsToKeepSC;
551
552 for (const LArRawSC* rawSC : *hdlSC) {
553
554
555 if (
m_bcMaskSC.cellShouldBeMasked(bcCont,rawSC->hardwareID()))
continue;
556
557 const std::vector<unsigned short>& bcids = rawSC->bcids();
558 const std::vector<int>& energies = rawSC->energies();
559 const std::vector<bool>& satur = rawSC->satur();
560
561
562 float scEne = 0;
563 float defValue = -99999999.;
564
565 const size_t nBCIDs = bcids.size();
567 for (i = 0;
i < nBCIDs && bcids[
i] != bunchId;
i++)
568 ;
569 if(i==nBCIDs) continue;
570 if (satur[i]) continue;
571
574 if (
m_bcMaskSC.cellShouldBeMasked(bcCont,rawSC->hardwareID()))
continue;
575
577
578 if (!
hash.is_valid()) {
579 ATH_MSG_FATAL (
"Found a LArRawSC whose HWIdentifier (" << rawSC->hardwareID()
580 << ") does not correspond to a valid hash -- returning StatusCode::FAILURE." );
581 return StatusCode::FAILURE;
582 }
583
584 channelsToKeepSC[
hash] = std::make_pair(scEne, std::make_pair(defValue,defValue));
585
587 HistoryContainer* histCont =
m_samples->hist_cont_sc(hash);
588 CellInfo*
info =
nullptr;
589 if (!histCont) {
590 HWIdentifier channelID = rawSC->hardwareID();
592 const CaloDetDescrElement* caloDetElement = caloMgrSC->
get_element(
id);
594 if (!info) continue;
596 }
597 }
598 }
599 ATH_MSG_INFO(
"SC to keep in this event: "<<channelsToKeepSC.size());
600
601 for (const LArRawSC* rawSC : *hdlrecoSC) {
602
603 if (
m_bcMaskSC.cellShouldBeMasked(bcCont,rawSC->hardwareID()))
continue;
605 if (!
hash.is_valid()) {
606 ATH_MSG_FATAL (
"Found a LArRawSC whose HWIdentifier (" << rawSC->hardwareID()
607 << ") does not correspond to a valid hash -- returning StatusCode::FAILURE." );
608 return StatusCode::FAILURE;
609 }
610
611
612 if (channelsToKeepSC.find(hash) == channelsToKeepSC.end()) continue;
613
614 const std::vector<unsigned short>& bcids = rawSC->bcids();
615 const std::vector<int>& energies = rawSC->energies();
616 const std::vector<int>& tauenergies = rawSC->tauEnergies();
617
618
619 float scEne = 0;
620 float scTim = -99999999.;
621
622 const size_t nBCIDs = bcids.size();
624 for (i = 0;
i < nBCIDs && bcids[
i] != bunchId;
i++)
625 ;
626 if(i==nBCIDs) continue;
627
629
630 if(tauenergies.size() && scEne != 0) scTim = tauenergies[
i] / scEne;
631
632 channelsToKeepSC[
hash].second = std::make_pair(scEne, scTim);
633
635 HistoryContainer* histCont =
m_samples->hist_cont_sc(hash);
636 CellInfo*
info =
nullptr;
637 if (!histCont) {
638 HWIdentifier channelID = rawSC->hardwareID();
640 const CaloDetDescrElement* caloDetElement = caloMgrSC->
get_element(
id);
642 if (!info) continue;
644 }
645 }
646 }
647
648 SG::ReadHandle<LArDigitContainer> hdlSCDigit(
m_digitsKeySC, ctx);
649 if(!hdlSCDigit.isValid()) {
651 return StatusCode::SUCCESS;
652 } else
654 const LArDigitContainer* larSCDigitContainer = &(*hdlSCDigit);
655
656 if (larSCDigitContainer->
empty()) {
659 return StatusCode::SUCCESS;
660 }
661
663 digit != larSCDigitContainer->
end(); ++digit)
664 {
665
667
668 std::map<unsigned int, std::pair<float, std::pair<float,float> > >::const_iterator findChannel = channelsToKeepSC.find(hash);
669 if (findChannel == channelsToKeepSC.end()) continue;
670
671
672 float pedestal = pedestalsSC->
pedestal((*digit)->channelID(), 0);
674 const std::vector<short>& samples = (*digit)->samples();
676 for (short sample : samples)
679 }
680
681 const Identifier
id = cablingSC->
cnvToIdentifier((*digit)->channelID());
682 const CaloDetDescrElement* caloDetElement = nullptr;
683
684 HistoryContainer* histCont =
m_samples->hist_cont_sc(hash);
685 CellInfo*
info =
nullptr;
686 if (!histCont) {
687 if (!caloDetElement) caloDetElement = caloMgrSC->
get_element(
id);
689 if (!info) continue;
690 histCont =
m_samples->makeNewHistorySC(hash, info);
691 }
692 else
694
695 if (!eventData) {
697 if (eventIndex < 0) return StatusCode::FAILURE;
698 }
699
700 DataContainer*
data =
701 new DataContainer((*digit)->gain(), (*digit)->samples(),
702 findChannel->second.first,
703 findChannel->second.second.second,
704 findChannel->second.second.first,
705 eventIndex,
706 LArVectorProxy(),
707 -1, pedestal, 0, 0);
708
709
711 }
712
713 }
714
715 return StatusCode::SUCCESS;
716}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define maxValue(current, test)
char data[hepevt_bytes_allocation_ATLAS]
LArBadXCont< LArBadChannel > LArBadChannelCont
Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old LArRawChannelContainer
ServiceHandle< StoreGateSvc > & evtStore()
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
LArVectorProxy AutoCorrRef_t
virtual float pedestal(const HWIdentifier &id, int gain) const =0
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
virtual AutoCorrRef_t autoCorr(const HWIdentifier &CellID, int gain) const
BitWord packedData() const
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
const std::map< unsigned int, uint16_t > & get_all_febs() const
get all febs with error
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
void add(const DataContainer *data)
append data (takes ownership)
CellInfo * cell_info() const
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevKey
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKeySC
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
SG::ReadHandleKey< LArRawSCContainer > m_rawscKey
ToolHandle< ILArShapeDumperTool > m_dumperToolSC
SG::ReadHandleKey< LArRawSCContainer > m_rawRecomputedscKey
SG::ReadCondHandleKey< LArBadChannelCont > m_BCKey
int makeEvent(LArSamples::EventData *&eventData, int run, int event, int lumiBlock, int bunchXing) const
ToolHandle< ILArShapeDumperTool > m_dumperTool
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
LArBadChannelMask m_bcMask
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
SG::ReadCondHandleKey< ILArAutoCorr > m_acorrKey
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
bool m_gains[CaloGain::LARNGAIN]
SG::ReadHandleKey< LArRawChannelContainer > m_channelsKey
SG::ReadCondHandleKey< BunchCrossingCondData > m_bcDataKey
SG::ReadHandleKey< LArDigitContainer > m_digitsKeySC
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
SG::ReadHandleKey< LArDigitContainer > m_digitsKey
uint32_t lumiBlock() const
The current event's luminosity block number.
uint32_t bcid() const
The bunch crossing ID of the event.
@ LAr
The LAr calorimeter.
@ Error
The sub-detector issued an error.
uint32_t runNumber() const
The current event's run number.
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
uint64_t eventNumber() const
The current event's event number.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
thread_local event_number_t eventIndex
retrieve(aClass, aKey=None)
EventInfo_v1 EventInfo
Definition of the latest event info version.