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"
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());
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 
90  ATH_MSG_DEBUG (" in LArBadFebMaskingTool::process ");
92  if (!larFebErrorSummary.isValid()) {
93  ATH_MSG_WARNING ("Cannot retrieve Feb error summary with key " << m_larFebErrorSummaryKey.key() <<". Skip LArBadFebMaskingTool::process ");
94  return StatusCode::SUCCESS;
95  }
96 
97  // retrieve map of Feb-errors
98  const std::map<unsigned int,uint16_t>& febMap = larFebErrorSummary->get_all_febs();
99 
100  ATH_MSG_DEBUG (" Number of Febs " << febMap.size());
101 
102  // catch cases of empty LAR container => severe problem in decoding => flag event as in ERROR
103  unsigned int nLar = theCont->nCellsCalo(CaloCell_ID::LAREM)+theCont->nCellsCalo(CaloCell_ID::LARHEC)+theCont->nCellsCalo(CaloCell_ID::LARFCAL);
104  if (nLar==0) {
105  ATH_MSG_DEBUG (" empty lar cell container ");
107  ATH_MSG_DEBUG (" set error bit for LAr for this event ");
109  ATH_MSG_WARNING (" cannot set error state for LAr ");
110  }
112  ATH_MSG_WARNING (" cannot set event bit info for LAr ");
113  }
114  }
115 
116 
118  const LArOnOffIdMapping* cabling=*cablingHdl;
119 
121  const LArBadFebCont* badFebs=*badFebHdl;
122 
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();
144 
145  if (toMask1 || inError) {
146  m_mask++;
147  for (int ch=0; ch<128; ++ch) {
148  HWIdentifier hwid = m_onlineID->channel_Id(febId, ch);
149  if (cabling->isOnlineConnected(hwid)) {
150  Identifier id = cabling->cnvToIdentifier( hwid);
151  IdentifierHash theCellHashID = m_calo_id->calo_cell_hash(id);
152  int index = theCont->findIndex(theCellHashID);
153  if (index<0) {
154  ATH_MSG_DEBUG (" cell " << hwid.get_compact() << " " << id.get_compact() << " is not in the container ");
155  continue;
156  }
157  CaloCell* aCell = theCont->at(index);
158 
159  if (aCell) {
160  ATH_MSG_DEBUG (" mask cell hwid= " << hwid.get_compact() << " offlineid = " << id.get_compact()
161  << " " << aCell->ID().get_compact());
162  aCell->setEnergy(0.);
163  aCell->setTime(0.);
164  uint16_t qua=0;
165  aCell->setQuality(qua);
166  uint16_t provenance = (aCell->provenance() | 0x0800);
167  aCell->setProvenance(provenance);
168  }
169 
170  } // isConnected
171  } // loop over channels in Feb
172  } // toMask
173 
174  } // loop over Febs in error
175 
176  return StatusCode::SUCCESS;
177 }
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:89
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:46
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:44
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.cxx:151
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
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.
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:46
LArBadFebMaskingTool::m_maskScacStatus
Gaudi::Property< bool > m_maskScacStatus
Definition: LArBadFebMaskingTool.h:76
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:338
CaloCell::setEnergy
virtual void setEnergy(float energy)
set energy
Definition: CaloCell.cxx:136
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:35
LArFebErrorSummary::TypeMismatch
@ TypeMismatch
Definition: LArFebErrorSummary.h:28
LArOnlineID_Base::feb_range
id_range feb_range() const
Definition: LArOnlineID_Base.cxx:1916
LArBadFebMaskingTool::m_calo_id
const CaloCell_ID * m_calo_id
pointers to identifier helpers
Definition: LArBadFebMaskingTool.h:96
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
LArBadFebMaskingTool::finalize
virtual StatusCode finalize() override
finalize the tool
Definition: LArBadFebMaskingTool.cxx:72
LArBadFebMaskingTool::process
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
update theCellContainer, masking Feb with errors
Definition: LArBadFebMaskingTool.cxx:84
CaloCell::setQuality
virtual void setQuality(uint16_t quality)
set quality
Definition: CaloCell.cxx:156
LArBadFeb.h
DetDescrDictionaryDict::it1
std::vector< HWIdentifier >::iterator it1
Definition: DetDescrDictionaryDict.h:17
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
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:1565
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.cxx:167
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
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:279
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:88
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:295
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
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:97
LArBadFebMaskingTool::m_maskDspBlockSize
Gaudi::Property< bool > m_maskDspBlockSize
Definition: LArBadFebMaskingTool.h:82
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
LArBadFebMaskingTool::m_mask
std::atomic< int > m_mask
Number of Feb masked.
Definition: LArBadFebMaskingTool.h:105
LArFebErrorSummary::NumOfSamples
@ NumOfSamples
Definition: LArFebErrorSummary.h:28
readCCLHist.float
float
Definition: readCCLHist.py:83
LArBadFebMaskingTool::m_maskGainMismatch
Gaudi::Property< bool > m_maskGainMismatch
Definition: LArBadFebMaskingTool.h:78
LArBadFebMaskingTool::m_larFebErrorSummaryKey
SG::ReadHandleKey< LArFebErrorSummary > m_larFebErrorSummaryKey
Definition: LArBadFebMaskingTool.h:87
LArBadFebMaskingTool::m_evt
std::atomic< int > m_evt
Number of events processed.
Definition: LArBadFebMaskingTool.h:101
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:92
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
Identifier
Definition: IdentifierFieldParser.cxx:14