ATLAS Offline Software
Loading...
Searching...
No Matches
LArBadFebMaskingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6
7NAME: LArBadFebMaskingTool
8PACKAGE: offline/Calorimeter/LArCellRec
9
10AUTHORS: G.Unal
11CREATION: 23 april 2009
12
13PURPOSE:
14
15********************************************************************/
16
18
20#include "Identifier/Identifier.h"
27#include "GaudiKernel/ThreadLocalContext.h"
30
32// INITIALIZE:
33// The initialize method will create all the required algorithm objects
35
37{
38 m_evt=0;
39 m_mask=0;
40
41 m_errorToMask = 0;
55
56 ATH_MSG_INFO (" bit mask for errors to mask " << m_errorToMask);
57
58 // initialize read handle keys
60 ATH_CHECK( m_badFebKey.initialize());
61 ATH_CHECK( m_cablingKey.initialize());
62 ATH_CHECK(m_eventInfoKey.initialize());
63 ATH_CHECK(m_eventInfoDecorKey.initialize());
64
65 // retrieve identifier helpers
66 ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") );
67 ATH_CHECK( detStore()->retrieve(m_calo_id,"CaloCell_ID") );
68
69 return StatusCode::SUCCESS;
70
71}
72
74{
75 ATH_MSG_INFO (" ---- Summary from LArBadFebMaskingTool ");
76 ATH_MSG_INFO (" Number of events processed " << m_evt);
77 ATH_MSG_INFO (" Number of masked Feb total " << m_mask);
78 float ratio=0.;
79 if (m_evt>0) ratio=((float)(m_mask))/((float)(m_evt));
80 ATH_MSG_INFO (" Number of masked Feb per event " << ratio);
81
82 return StatusCode::SUCCESS;
83}
84
86 const EventContext& ctx) const
87{
88 m_evt++;
89
90 const std::map<unsigned int,uint16_t>* febMap = &m_dummyFebMap; //empty dummy map for MC case
91 if (!m_noFebErrors) {
92 ATH_MSG_DEBUG (" in LArBadFebMaskingTool::process ");
94 if (!larFebErrorSummary.isValid()) {
95 ATH_MSG_WARNING ("Cannot retrieve Feb error summary with key " << m_larFebErrorSummaryKey.key() <<". Skip LArBadFebMaskingTool::process ");
96 return StatusCode::SUCCESS;
97 }
98
99 // retrieve map of Feb-errors
100 febMap = &larFebErrorSummary->get_all_febs();
101 ATH_MSG_DEBUG (" Number of Febs " << febMap->size());
102 }//end if m_noFebErrors
103
104 // catch cases of empty LAR container => severe problem in decoding => flag event as in ERROR
105 unsigned int nLar = theCont->nCellsCalo(CaloCell_ID::LAREM)+theCont->nCellsCalo(CaloCell_ID::LARHEC)+theCont->nCellsCalo(CaloCell_ID::LARFCAL);
106 if (nLar==0) {
107 ATH_MSG_DEBUG (" empty lar cell container ");
109 ATH_MSG_DEBUG (" set error bit for LAr for this event ");
110 if (!eventInfo->updateErrorState(xAOD::EventInfo::LAr,xAOD::EventInfo::Error)) {
111 ATH_MSG_WARNING (" cannot set error state for LAr ");
112 }
113 if (!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::DATACORRUPTED)) {
114 ATH_MSG_WARNING (" cannot set event bit info for LAr ");
115 }
116 }
117
118
120 const LArOnOffIdMapping* cabling=*cablingHdl;
121
123 const LArBadFebCont* badFebs=*badFebHdl;
124
125// loop over all Febs
126
127 for (HWIdentifier febId : m_onlineID->feb_range()) {
128 bool toMask1 = false; // mask because of bad error
129 bool inError = false; // mask because Feb listed in database as being to mask
130
131// for debug
132 unsigned int ifeb = febId.get_identifier32().get_compact();
133 ATH_MSG_DEBUG (" process Feb: " << ifeb);
134
135 std::map<unsigned int,uint16_t>::const_iterator it1 = febMap->find(ifeb);
136 if (it1 != febMap->end()) {
137 uint16_t ierror = (*it1).second;
138 if (ierror & m_errorToMask) toMask1=true;
139 ATH_MSG_DEBUG (" ierror,toMask " << ierror << " " << toMask1 << " ");
140 }
141
142
143 LArBadFeb febstatus = badFebs->status(febId);
144 inError = febstatus.inError() || febstatus.deadAll();
145
146 if (toMask1 || inError) {
147 m_mask++;
148 const int nChanPerFeb=m_onlineID->channelInSlotMax(febId);
149 for (int ch=0; ch<nChanPerFeb; ++ch) {
150 HWIdentifier hwid = m_onlineID->channel_Id(febId, ch);
151 if (cabling->isOnlineConnected(hwid)) {
152 Identifier id = cabling->cnvToIdentifier( hwid);
153 IdentifierHash theCellHashID = m_calo_id->calo_cell_hash(id);
154 int index = theCont->findIndex(theCellHashID);
155 if (index<0) {
156 ATH_MSG_DEBUG (" cell " << hwid.get_compact() << " " << id.get_compact() << " is not in the container ");
157 continue;
158 }
159 CaloCell* aCell = theCont->at(index);
160
161 if (aCell) {
162 ATH_MSG_DEBUG (" mask cell hwid= " << hwid.get_compact() << " offlineid = " << id.get_compact()
163 << " " << aCell->ID().get_compact());
164 aCell->setEnergy(0.);
165 aCell->setTime(0.);
166 uint16_t qua=0;
167 aCell->setQuality(qua);
168 const uint16_t provenance = (aCell->provenance() | LArProv::MASKED | LArProv::DEADFEB);// 0x0800 | 0x4000
169 aCell->setProvenance(provenance);
170 }
171
172 } // isConnected
173 } // loop over channels in Feb
174 } // toMask
175
176 } // loop over Febs in error
177
178 return StatusCode::SUCCESS;
179}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
LArBadXCont< LArBadFeb > LArBadFebCont
Handle class for adding a decoration to an object.
Container class for CaloCell.
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
int nCellsCalo(const CaloCell_ID::SUBCALO caloNum) const
get number of cels of given calorimeter
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
virtual void setTime(float time)
set time
Definition CaloCell.h:484
uint16_t provenance() const
get provenance (data member)
Definition CaloCell.h:354
virtual void setEnergy(float energy)
set energy
Definition CaloCell.h:472
void setQuality(uint16_t quality)
set quality
Definition CaloCell.h:460
void setProvenance(uint16_t prov)
set Provenance
Definition CaloCell.h:490
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
const T * at(size_type n) const
Access an element, as an rvalue.
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Gaudi::Property< bool > m_maskTypeMismatch
Gaudi::Property< bool > m_maskDspBlockSize
SG::ReadHandleKey< LArFebErrorSummary > m_larFebErrorSummaryKey
Gaudi::Property< bool > m_maskScacStatus
Gaudi::Property< bool > m_maskGainMismatch
Gaudi::Property< bool > m_maskParity
flags to select which errors to mask
const std::map< unsigned int, uint16_t > m_dummyFebMap
Empty dummy map for MC case.
Gaudi::Property< bool > m_maskSampleHeader
Gaudi::Property< bool > m_maskMissingHeader
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
handle to LAr cabling
Gaudi::Property< bool > m_noFebErrors
Gaudi::Property< bool > m_maskScaOutOfRange
std::atomic< int > m_evt
Number of events processed.
Gaudi::Property< bool > m_maskNumOfSamples
virtual StatusCode finalize() override
finalize the tool
Gaudi::Property< bool > m_maskBadGain
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
update theCellContainer, masking Feb with errors
std::atomic< int > m_mask
Number of Feb masked.
uint16_t m_errorToMask
compute bit mask of errors to mask
SG::ReadCondHandleKey< LArBadFebCont > m_badFebKey
handle to get bad febs
Gaudi::Property< bool > m_maskEmptyDataBlock
const LArOnlineID * m_onlineID
Gaudi::Property< bool > m_maskCheckSum
Gaudi::Property< bool > m_maskEVTID
virtual StatusCode initialize() override
initialize the tool
const CaloCell_ID * m_calo_id
pointers to identifier helpers
bool deadAll() const
FEB is completely missing, e.g. powered off.
Definition LArBadFeb.h:30
bool inError() const
FEB has readout errors, cannot be used.
Definition LArBadFeb.h:36
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ LAr
The LAr calorimeter.
@ Error
The sub-detector issued an error.
Definition index.py:1