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"
29
31// INITIALIZE:
32// The initialize method will create all the required algorithm objects
34
36{
37 m_evt=0;
38 m_mask=0;
39
40 m_errorToMask = 0;
54
55 ATH_MSG_INFO (" bit mask for errors to mask " << m_errorToMask);
56
57 // initialize read handle keys
59 ATH_CHECK( m_badFebKey.initialize());
60 ATH_CHECK( m_cablingKey.initialize());
61 ATH_CHECK(m_eventInfoKey.initialize());
62 ATH_CHECK(m_eventInfoDecorKey.initialize());
63
64 // retrieve identifier helpers
65 ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") );
66 ATH_CHECK( detStore()->retrieve(m_calo_id,"CaloCell_ID") );
67
68 return StatusCode::SUCCESS;
69
70}
71
73{
74 ATH_MSG_INFO (" ---- Summary from LArBadFebMaskingTool ");
75 ATH_MSG_INFO (" Number of events processed " << m_evt);
76 ATH_MSG_INFO (" Number of masked Feb total " << m_mask);
77 float ratio=0.;
78 if (m_evt>0) ratio=((float)(m_mask))/((float)(m_evt));
79 ATH_MSG_INFO (" Number of masked Feb per event " << ratio);
80
81 return StatusCode::SUCCESS;
82}
83
85 const EventContext& ctx) const
86{
87 m_evt++;
88
89 const std::map<unsigned int,uint16_t>* febMap = &m_dummyFebMap; //empty dummy map for MC case
90 if (!m_noFebErrors) {
91 ATH_MSG_DEBUG (" in LArBadFebMaskingTool::process ");
93 if (!larFebErrorSummary.isValid()) {
94 ATH_MSG_WARNING ("Cannot retrieve Feb error summary with key " << m_larFebErrorSummaryKey.key() <<". Skip LArBadFebMaskingTool::process ");
95 return StatusCode::SUCCESS;
96 }
97
98 // retrieve map of Feb-errors
99 febMap = &larFebErrorSummary->get_all_febs();
100 ATH_MSG_DEBUG (" Number of Febs " << febMap->size());
101 }//end if m_noFebErrors
102
103 // catch cases of empty LAR container => severe problem in decoding => flag event as in ERROR
104 unsigned int nLar = theCont->nCellsCalo(CaloCell_ID::LAREM)+theCont->nCellsCalo(CaloCell_ID::LARHEC)+theCont->nCellsCalo(CaloCell_ID::LARFCAL);
105 if (nLar==0) {
106 ATH_MSG_DEBUG (" empty lar cell container ");
108 ATH_MSG_DEBUG (" set error bit for LAr for this event ");
109 if (!eventInfo->updateErrorState(xAOD::EventInfo::LAr,xAOD::EventInfo::Error)) {
110 ATH_MSG_WARNING (" cannot set error state for LAr ");
111 }
112 if (!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::DATACORRUPTED)) {
113 ATH_MSG_WARNING (" cannot set event bit info for LAr ");
114 }
115 }
116
117
119 const LArOnOffIdMapping* cabling=*cablingHdl;
120
122 const LArBadFebCont* badFebs=*badFebHdl;
123
124// loop over all Febs
125
126 for (HWIdentifier febId : m_onlineID->feb_range()) {
127 bool toMask1 = false; // mask because of bad error
128 bool inError = false; // mask because Feb listed in database as being to mask
129
130// for debug
131 unsigned int ifeb = febId.get_identifier32().get_compact();
132 ATH_MSG_DEBUG (" process Feb: " << ifeb);
133
134 std::map<unsigned int,uint16_t>::const_iterator it1 = febMap->find(ifeb);
135 if (it1 != febMap->end()) {
136 uint16_t ierror = (*it1).second;
137 if (ierror & m_errorToMask) toMask1=true;
138 ATH_MSG_DEBUG (" ierror,toMask " << ierror << " " << toMask1 << " ");
139 }
140
141
142 LArBadFeb febstatus = badFebs->status(febId);
143 inError = febstatus.inError() || febstatus.deadAll();
144
145 if (toMask1 || inError) {
146 m_mask++;
147 const int nChanPerFeb=m_onlineID->channelInSlotMax(febId);
148 for (int ch=0; ch<nChanPerFeb; ++ch) {
149 HWIdentifier hwid = m_onlineID->channel_Id(febId, ch);
150 if (cabling->isOnlineConnected(hwid)) {
151 Identifier id = cabling->cnvToIdentifier( hwid);
152 IdentifierHash theCellHashID = m_calo_id->calo_cell_hash(id);
153 int index = theCont->findIndex(theCellHashID);
154 if (index<0) {
155 ATH_MSG_DEBUG (" cell " << hwid.get_compact() << " " << id.get_compact() << " is not in the container ");
156 continue;
157 }
158 CaloCell* aCell = theCont->at(index);
159
160 if (aCell) {
161 ATH_MSG_DEBUG (" mask cell hwid= " << hwid.get_compact() << " offlineid = " << id.get_compact()
162 << " " << aCell->ID().get_compact());
163 aCell->setEnergy(0.);
164 aCell->setTime(0.);
165 uint16_t qua=0;
166 aCell->setQuality(qua);
167 const uint16_t provenance = (aCell->provenance() | LArProv::MASKED | LArProv::DEADFEB);// 0x0800 | 0x4000
168 aCell->setProvenance(provenance);
169 }
170
171 } // isConnected
172 } // loop over channels in Feb
173 } // toMask
174
175 } // loop over Febs in error
176
177 return StatusCode::SUCCESS;
178}
#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