ATLAS Offline Software
LArNoisyROAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "LArNoisyROAlg.h"
7 
9 #include "CaloEvent/CaloCell.h"
10 #include "Identifier/Identifier.h"
17 
18 #include <cmath>
19 
20 LArNoisyROAlg::LArNoisyROAlg(const std::string &name,ISvcLocator *pSvcLocator):
21  AthReentrantAlgorithm (name, pSvcLocator),
22  m_noisyROTool("LArNoisyROTool",this)
23 {
25 }
26 
28  ATH_CHECK(m_noisyROTool.retrieve());
33  ATH_CHECK(m_knownBadFEBsVecKey.initialize(!m_isMC) );
34  ATH_CHECK(m_knownMNBFEBsVecKey.initialize(!m_isMC) );
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 StatusCode LArNoisyROAlg::execute (const EventContext& ctx) const
40 {
42  if (!cellContainer.isValid()) {
43  ATH_MSG_WARNING( " Can not retrieve CaloCellContainer: " << m_CaloCellContainerName.key());
44  ATH_MSG_WARNING( " Empty object recorded !");
45 
46  const std::set<unsigned int> knownBadFEBs;
47  const std::vector<HWIdentifier> knownMNBFEBs;
49  ATH_CHECK(noisyRO.record(m_noisyROTool->process(nullptr, &knownBadFEBs, &knownMNBFEBs)));
50 
51  return StatusCode::SUCCESS;
52  }
53 
54  const EventIDBase& EIHandle = ctx.eventID();
55  long int thisTimeStamp = (EIHandle).time_stamp();
56  long int thisTimeStampns = (EIHandle).time_stamp_ns_offset();
57  uint32_t thisLB = (EIHandle).lumi_block();
58  unsigned long long thisEv = (EIHandle).event_number();
59  ATH_MSG_DEBUG ( name() << " processing EN : " << thisEv << " in LB : " << thisLB << " TS : " << thisTimeStamp << " TSNS : " << thisTimeStampns );
60 
61  std::set<unsigned int> bf;
62  std::vector<HWIdentifier> MNBfeb;
63  if (! m_isMC) {
65  const LArBadFebCont* badCont=*badHdl;
66  if(badCont) {
67  for(LArBadFebCont::BadChanVec::const_iterator i = badCont->begin(); i!=badCont->end(); ++i) {
68  bf.insert(i->first);
69  }
70  }
71 
73  const LArBadFebCont* MNBCont=*MNBHdl;
74  if(MNBCont) {
75  for(LArBadFebCont::BadChanVec::const_iterator i = MNBCont->begin(); i!=MNBCont->end(); ++i) {
76  MNBfeb.emplace_back(i->first);
77  }
78  }
79  }
80 
81  ATH_MSG_DEBUG("Number of known Bad FEBs: "<<bf.size());
82  ATH_MSG_DEBUG("Number of known MNB FEBs: "<<MNBfeb.size());
83 
84 
85 
87  ATH_CHECK(noisyRO.record(m_noisyROTool->process(cellContainer.cptr(), &bf, &MNBfeb)));
88 
89 
90  bool badFEBFlag=noisyRO->BadFEBFlaggedPartitions();
91  bool badFEBFlag_W=noisyRO->BadFEB_WFlaggedPartitions();
92  bool badSaturatedTightCut=noisyRO->SatTightFlaggedPartitions();
93  bool MNBLooseCut=noisyRO->MNBLooseFlaggedPartitions();
94  bool MNBTightCut=noisyRO->MNBTightFlaggedPartitions();
95  bool MNBTight_PsVetoCut=noisyRO->MNBTight_PsVetoFlaggedPartitions();
96 
98  if ( badFEBFlag || badFEBFlag_W || badSaturatedTightCut || MNBLooseCut || MNBTightCut || MNBTight_PsVetoCut)
99  {
100  // retrieve EventInfo
101  bool failSetWARN=false;
102  bool failSetWARNREASON=false;
103  // set warning flag except if the error flag has been already set
105  if ( badFEBFlag ) {
106  failSetWARN |= (!eventInfo->updateErrorState(xAOD::EventInfo::LAr,xAOD::EventInfo::Warning));
107  failSetWARNREASON |= (!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::BADFEBS));
108  }//endif badFEBFlag
109 
110  if ( badFEBFlag_W ) {
111  //Set WARNING Flag
113  // Set reason why event was flagged
114  failSetWARNREASON |=(!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::BADFEBS_W));
115  }// end if badFEBFlag_W
116 
117  if ( badSaturatedTightCut ){
119  }
120  }
121 
122  if ( MNBTightCut ) {
124  // Set reason why event was flagged
126  }
127 
128  if ( MNBTight_PsVetoCut ) {
130  // Set reason why event was flagged
132  }
133 
134  if ( MNBLooseCut ) { //FIXME Tight cut actually implies loose cut too
136  }
137 
138  if (failSetWARN) ATH_MSG_WARNING( "Failure during EventInfo::setEventErrorState(EventInfo::LAR,EventInfo::WARNING)" );
139  if (failSetWARNREASON) ATH_MSG_WARNING( "Failure during setEventFlagBit(EventInfo::LAr,...)" );
140 
141  }
142  return StatusCode::SUCCESS;
143 }
144 
146 {
147  return StatusCode::SUCCESS;
148 }
149 
LArNoisyROSummary::MNBTight_PsVetoFlaggedPartitions
uint8_t MNBTight_PsVetoFlaggedPartitions() const
Definition: LArNoisyROSummary.h:130
LArNoisyROAlg::m_CaloCellContainerName
SG::ReadHandleKey< CaloCellContainer > m_CaloCellContainerName
Definition: LArNoisyROAlg.h:49
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArNoisyROAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: LArNoisyROAlg.cxx:39
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArEventBitInfo::MININOISEBURSTTIGHT
@ MININOISEBURSTTIGHT
Definition: LArEventBitInfo.h:18
LArBadXCont
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
Definition: LArBadChannelCont.h:28
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
LArNoisyROSummary::SatTightFlaggedPartitions
uint8_t SatTightFlaggedPartitions() const
Definition: LArNoisyROSummary.h:121
CaloCell.h
LArEventBitInfo::BADFEBS
@ BADFEBS
Definition: LArEventBitInfo.h:10
LArNoisyROAlg::initialize
virtual StatusCode initialize() override
Definition: LArNoisyROAlg.cxx:27
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
LArEventBitInfo.h
CaloCell_ID.h
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
LArNoisyROAlg::m_outputKey
SG::WriteHandleKey< LArNoisyROSummary > m_outputKey
Definition: LArNoisyROAlg.h:50
LArNoisyROAlg.h
LArEventBitInfo::TIGHTSATURATEDQ
@ TIGHTSATURATEDQ
Definition: LArEventBitInfo.h:12
LArNoisyROSummary::MNBTightFlaggedPartitions
uint8_t MNBTightFlaggedPartitions() const
Definition: LArNoisyROSummary.h:127
LArEventBitInfo::MININOISEBURSTTIGHT_PSVETO
@ MININOISEBURSTTIGHT_PSVETO
Definition: LArEventBitInfo.h:19
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
WriteDecorHandle.h
Handle class for adding a decoration to an object.
LArEventBitInfo::BADFEBS_W
@ BADFEBS_W
Definition: LArEventBitInfo.h:16
LArNoisyROSummary::MNBLooseFlaggedPartitions
uint8_t MNBLooseFlaggedPartitions() const
Definition: LArNoisyROSummary.h:124
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArBadXCont::const_iterator
BadChanVec::const_iterator const_iterator
Definition: LArBadChannelCont.h:33
LArNoisyROAlg::m_knownMNBFEBsVecKey
SG::ReadCondHandleKey< LArBadFebCont > m_knownMNBFEBsVecKey
Definition: LArNoisyROAlg.h:52
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
LArNoisyROAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: LArNoisyROAlg.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LArNoisyROAlg::m_noisyROTool
ToolHandle< ILArNoisyROTool > m_noisyROTool
Definition: LArNoisyROAlg.h:44
LArEventBitInfo::MININOISEBURSTLOOSE
@ MININOISEBURSTLOOSE
Definition: LArEventBitInfo.h:17
LArNoisyROAlg::m_isMC
Gaudi::Property< bool > m_isMC
Definition: LArNoisyROAlg.h:46
LArNoisyROAlg::LArNoisyROAlg
LArNoisyROAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArNoisyROAlg.cxx:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloCellContainer.h
EventInfo.h
LArNoisyROAlg::m_knownBadFEBsVecKey
SG::ReadCondHandleKey< LArBadFebCont > m_knownBadFEBsVecKey
Definition: LArNoisyROAlg.h:51
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
xAOD::EventInfo_v1::Warning
@ Warning
The sub-detector issued a warning.
Definition: EventInfo_v1.h:348
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.
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArNoisyROSummary::BadFEB_WFlaggedPartitions
uint8_t BadFEB_WFlaggedPartitions() const
Definition: LArNoisyROSummary.h:115
LArNoisyROAlg::m_eventInfoDecorKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition: LArNoisyROAlg.h:48
xAOD::EventInfo_v1::errorState
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
Definition: EventInfo_v1.cxx:817
LArNoisyROAlg::finalize
virtual StatusCode finalize() override
Definition: LArNoisyROAlg.cxx:145
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
LArBadXCont::begin
const_iterator begin() const
Access to the begin iterator of the underlying vector.
Definition: LArBadChannelCont.h:73
LArNoisyROSummary::BadFEBFlaggedPartitions
uint8_t BadFEBFlaggedPartitions() const
Definition: LArNoisyROSummary.h:112
LArBadXCont::end
const_iterator end() const
Access to the end iterator of the underlying vector.
Definition: LArBadChannelCont.h:76
LArOnlineID.h