ATLAS Offline Software
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 
7 NAME: LArBadFebMaskingTool
8 PACKAGE: offline/Calorimeter/LArCellRec
9 
10 AUTHORS: G.Unal
11 CREATION: 23 april 2009
12 
13 PURPOSE:
14 
15 ********************************************************************/
16 
17 #include "LArBadFebMaskingTool.h"
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());
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 ");
111  ATH_MSG_WARNING (" cannot set error state for LAr ");
112  }
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArBadFebMaskingTool::m_maskScaOutOfRange
Gaudi::Property< bool > m_maskScaOutOfRange
Definition: LArBadFebMaskingTool.h:77
LArFebErrorSummary::CheckSum
@ CheckSum
Definition: LArFebErrorSummary.h:28
LArBadFebMaskingTool::m_eventInfoDecorKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition: LArBadFebMaskingTool.h:91
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:45
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
LArFebErrorSummary::get_all_febs
const std::map< unsigned int, uint16_t > & get_all_febs() const
get all febs with error
Definition: LArFebErrorSummary.cxx:47
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
SG::ReadCondHandle
Definition: ReadCondHandle.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArBadFebMaskingTool::m_maskParity
Gaudi::Property< bool > m_maskParity
flags to select which errors to mask
Definition: LArBadFebMaskingTool.h:73
CaloCell::setTime
virtual void setTime(float time)
set time
Definition: CaloCell.h:484
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
index
Definition: index.py:1
LArBadXCont
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
Definition: LArBadChannelCont.h:28
LArBadFebMaskingTool::m_maskEmptyDataBlock
Gaudi::Property< bool > m_maskEmptyDataBlock
Definition: LArBadFebMaskingTool.h:81
xAOD::EventInfo_v1::updateEventFlagBit
bool updateEventFlagBit(const EventFlagSubDet subDet, const size_t bit) const
Change detector flags with update semantics.
Definition: EventInfo_v1.cxx:746
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArBadFebMaskingTool::m_maskBadGain
Gaudi::Property< bool > m_maskBadGain
Definition: LArBadFebMaskingTool.h:85
LArEventBitInfo::DATACORRUPTED
@ DATACORRUPTED
Definition: LArEventBitInfo.h:14
LArBadFebMaskingTool::m_maskCheckSum
Gaudi::Property< bool > m_maskCheckSum
Definition: LArBadFebMaskingTool.h:83
Identifier::get_compact
value_type get_compact() const
Get the compact id.
LArBadFebMaskingTool::m_dummyFebMap
const std::map< unsigned int, uint16_t > m_dummyFebMap
Empty dummy map for MC case.
Definition: LArBadFebMaskingTool.h:111
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:45
LArBadFebMaskingTool::m_maskScacStatus
Gaudi::Property< bool > m_maskScacStatus
Definition: LArBadFebMaskingTool.h:76
LArProv::DEADFEB
@ DEADFEB
Definition: LArProvenance.h:35
LArBadFebMaskingTool::m_noFebErrors
Gaudi::Property< bool > m_noFebErrors
Definition: LArBadFebMaskingTool.h:87
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CaloCell::provenance
uint16_t provenance() const
get provenance (data member)
Definition: CaloCell.h:354
CaloCell::setEnergy
virtual void setEnergy(float energy)
set energy
Definition: CaloCell.h:472
HWIdentifier
Definition: HWIdentifier.h:13
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
LArBadXCont::status
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
LArFebErrorSummary::BadGain
@ BadGain
Definition: LArFebErrorSummary.h:28
LArEventBitInfo.h
CaloCell_ID.h
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
LArBadFebMaskingTool::initialize
virtual StatusCode initialize() override
initialize the tool
Definition: LArBadFebMaskingTool.cxx:36
LArFebErrorSummary::TypeMismatch
@ TypeMismatch
Definition: LArFebErrorSummary.h:28
LArOnlineID_Base::feb_range
id_range feb_range() const
Definition: LArOnlineID_Base.cxx:1920
LArBadFebMaskingTool::m_calo_id
const CaloCell_ID * m_calo_id
pointers to identifier helpers
Definition: LArBadFebMaskingTool.h:98
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
LArBadFebMaskingTool::finalize
virtual StatusCode finalize() override
finalize the tool
Definition: LArBadFebMaskingTool.cxx:73
LArBadFebMaskingTool::process
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
update theCellContainer, masking Feb with errors
Definition: LArBadFebMaskingTool.cxx:85
CaloCell::setQuality
void setQuality(uint16_t quality)
set quality
Definition: CaloCell.h:460
LArBadFeb.h
LArOnlineID_Base::channelInSlotMax
int channelInSlotMax(const HWIdentifier Id) const
Return the Maximum channel number of a given feb slot.
Definition: LArOnlineID_Base.cxx:293
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArBadFebMaskingTool.h
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArBadFeb::deadAll
bool deadAll() const
FEB is completely missing, e.g. powered off.
Definition: LArBadFeb.h:30
LArFebErrorSummary::ScacStatus
@ ScacStatus
Definition: LArFebErrorSummary.h:27
CaloCellContainer::nCellsCalo
int nCellsCalo(const CaloCell_ID::SUBCALO caloNum) const
get number of cels of given calorimeter
Definition: CaloCellContainer.cxx:145
WriteDecorHandle.h
Handle class for adding a decoration to an object.
LArOnlineID_Base::channel_Id
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
Definition: LArOnlineID_Base.cxx:1569
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CaloCell::setProvenance
void setProvenance(uint16_t prov)
set Provenance
Definition: CaloCell.h:490
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LArBadFebMaskingTool::m_maskMissingHeader
Gaudi::Property< bool > m_maskMissingHeader
Definition: LArBadFebMaskingTool.h:84
LArBadFebMaskingTool::m_maskNumOfSamples
Gaudi::Property< bool > m_maskNumOfSamples
Definition: LArBadFebMaskingTool.h:80
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
IdentifierHash.h
LArProv::MASKED
@ MASKED
Definition: LArProvenance.h:32
LArBadFeb
Definition: LArBadFeb.h:10
LArFebErrorSummary::EmptyDataBlock
@ EmptyDataBlock
Definition: LArFebErrorSummary.h:28
LArFebErrorSummary::EVTID
@ EVTID
Definition: LArFebErrorSummary.h:27
LArBadFebMaskingTool::m_maskSampleHeader
Gaudi::Property< bool > m_maskSampleHeader
Definition: LArBadFebMaskingTool.h:74
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCell::ID
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition: CaloCell.h:295
LArBadFeb::inError
bool inError() const
FEB has readout errors, cannot be used.
Definition: LArBadFeb.h:36
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
LArBadFebMaskingTool::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: LArBadFebMaskingTool.h:90
LArFebErrorSummary::DspBlockSize
@ DspBlockSize
Definition: LArFebErrorSummary.h:28
LArBadFebMaskingTool::m_maskTypeMismatch
Gaudi::Property< bool > m_maskTypeMismatch
Definition: LArBadFebMaskingTool.h:79
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
python.compareTCTs.ratio
ratio
Definition: compareTCTs.py:294
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
LArFebErrorSummary::Parity
@ Parity
Definition: LArFebErrorSummary.h:27
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArBadFebMaskingTool::m_maskEVTID
Gaudi::Property< bool > m_maskEVTID
Definition: LArBadFebMaskingTool.h:75
LArProvenance.h
CaloCellContainer::findIndex
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
Definition: CaloCellContainer.cxx:363
CaloIdManager.h
xAOD::EventInfo_v1::updateErrorState
bool updateErrorState(const EventFlagSubDet subDet, const EventFlagErrorState state) const
Update the error state for one particular sub-detector.
Definition: EventInfo_v1.cxx:856
LArFebErrorSummary::SampleHeader
@ SampleHeader
Definition: LArFebErrorSummary.h:27
LArFebErrorSummary::ScaOutOfRange
@ ScaOutOfRange
Definition: LArFebErrorSummary.h:27
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
LArBadFebMaskingTool::m_badFebKey
SG::ReadCondHandleKey< LArBadFebCont > m_badFebKey
handle to get bad febs
Definition: LArBadFebMaskingTool.h:66
LArBadFebMaskingTool::m_onlineID
const LArOnlineID * m_onlineID
Definition: LArBadFebMaskingTool.h:99
LArBadFebMaskingTool::m_maskDspBlockSize
Gaudi::Property< bool > m_maskDspBlockSize
Definition: LArBadFebMaskingTool.h:82
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:45
LArBadFebMaskingTool::m_mask
std::atomic< int > m_mask
Number of Feb masked.
Definition: LArBadFebMaskingTool.h:107
LArFebErrorSummary::NumOfSamples
@ NumOfSamples
Definition: LArFebErrorSummary.h:28
LArBadFebMaskingTool::m_maskGainMismatch
Gaudi::Property< bool > m_maskGainMismatch
Definition: LArBadFebMaskingTool.h:78
LArBadFebMaskingTool::m_larFebErrorSummaryKey
SG::ReadHandleKey< LArFebErrorSummary > m_larFebErrorSummaryKey
Definition: LArBadFebMaskingTool.h:89
LArBadFebMaskingTool::m_evt
std::atomic< int > m_evt
Number of events processed.
Definition: LArBadFebMaskingTool.h:103
LArOnlineID.h
LArFebErrorSummary::MissingHeader
@ MissingHeader
Definition: LArFebErrorSummary.h:28
LArBadFebMaskingTool::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
handle to LAr cabling
Definition: LArBadFebMaskingTool.h:69
LArFebErrorSummary::GainMismatch
@ GainMismatch
Definition: LArFebErrorSummary.h:28
LArBadFebMaskingTool::m_errorToMask
uint16_t m_errorToMask
compute bit mask of errors to mask
Definition: LArBadFebMaskingTool.h:94
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
Identifier
Definition: IdentifierFieldParser.cxx:14