ATLAS Offline Software
Loading...
Searching...
No Matches
LArNoisyROAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include "LArNoisyROAlg.h"
7
10#include "Identifier/Identifier.h"
17
18#include <cmath>
19
20LArNoisyROAlg::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());
30 ATH_CHECK(m_outputKey.initialize());
31 ATH_CHECK(m_eventInfoKey.initialize());
32 ATH_CHECK(m_eventInfoDecorKey.initialize());
35 ATH_CHECK(m_hvMapKey.initialize(!(m_isMC || m_hvMapKey.empty())));
37 ATH_CHECK(m_hvCablingKey.initialize(!( m_isMC || m_hvMapKey.empty())));
38
39 return StatusCode::SUCCESS;
40}
41
42StatusCode LArNoisyROAlg::execute (const EventContext& ctx) const
43{
45 if (!cellContainer.isValid()) {
46 ATH_MSG_WARNING( " Can not retrieve CaloCellContainer: " << m_CaloCellContainerName.key());
47 ATH_MSG_WARNING( " Empty object recorded !");
48
49 const std::set<unsigned int> knownBadFEBs;
50 const std::vector<HWIdentifier> knownMNBFEBs;
52 ATH_CHECK(noisyRO.record(m_noisyROTool->process(ctx,nullptr, &knownBadFEBs, &knownMNBFEBs, nullptr, nullptr, nullptr)));
53
54 return StatusCode::SUCCESS;
55 }
56
57 const EventIDBase& EIHandle = ctx.eventID();
58 long int thisTimeStamp = (EIHandle).time_stamp();
59 long int thisTimeStampns = (EIHandle).time_stamp_ns_offset();
60 uint32_t thisLB = (EIHandle).lumi_block();
61 unsigned long long thisEv = (EIHandle).event_number();
62 ATH_MSG_DEBUG ( name() << " processing EN : " << thisEv << " in LB : " << thisLB << " TS : " << thisTimeStamp << " TSNS : " << thisTimeStampns );
63
64 std::set<unsigned int> bf;
65 std::vector<HWIdentifier> MNBfeb;
66 const LArHVNMap* hvmap=nullptr;
67 const CaloDetDescrManager* cddm=nullptr;
68 const LArHVIdMapping* hvid=nullptr;
69 if (! m_isMC) {
71 const LArBadFebCont* badCont=*badHdl;
72 if(badCont) {
73 for(LArBadFebCont::BadChanVec::const_iterator i = badCont->begin(); i!=badCont->end(); ++i) {
74 bf.insert(i->first);
75 }
76 }
77
79 const LArBadFebCont* MNBCont=*MNBHdl;
80 if(MNBCont) {
81 for(LArBadFebCont::BadChanVec::const_iterator i = MNBCont->begin(); i!=MNBCont->end(); ++i) {
82 MNBfeb.emplace_back(i->first);
83 }
84 }
85
86 if(!m_hvMapKey.empty()) {
88 if(!hvMapHdl.isValid()) {
89 ATH_MSG_WARNING( " Can not retrieve HVline nCells: " << m_hvMapKey.key());
90 ATH_MSG_WARNING( " Will not flag HV lines noise !");
91 } else {
92 hvmap = *hvMapHdl;
93 }
94 }
95
97 if(!cddmHdl.isValid()) {
98 ATH_MSG_WARNING( " Can not retrieve CaloDetDesrManager: " << m_caloDetDescrMgrKey.key());
99 ATH_MSG_WARNING( " Will not flag HV lines noise !");
100 } else {
101 cddm = *cddmHdl;
102 }
103
104 if(!m_hvCablingKey.empty()){
106 if(!hvidHdl.isValid()) {
107 ATH_MSG_WARNING( " Can not retrieve LArHVIdMapping: " << m_hvCablingKey.key());
108 ATH_MSG_WARNING( " Will not flag HV lines noise !");
109 } else {
110 hvid = *hvidHdl;
111 }
112 }
113 }
114
115 ATH_MSG_DEBUG("Number of known Bad FEBs: "<<bf.size());
116 ATH_MSG_DEBUG("Number of known MNB FEBs: "<<MNBfeb.size());
117
118
119
121 ATH_CHECK(noisyRO.record(m_noisyROTool->process(ctx,cellContainer.cptr(), &bf, &MNBfeb, hvmap, cddm, hvid)));
122 ATH_MSG_DEBUG("Recorded LArNoisyROSummary with key: "<<m_outputKey.key());
123
124
125 bool badFEBFlag=noisyRO->BadFEBFlaggedPartitions();
126 bool badFEBFlag_W=noisyRO->BadFEB_WFlaggedPartitions();
127 bool badSaturatedTightCut=noisyRO->SatTightFlaggedPartitions();
128 bool MNBLooseCut=noisyRO->MNBLooseFlaggedPartitions();
129 bool MNBTightCut=noisyRO->MNBTightFlaggedPartitions();
130 bool MNBTight_PsVetoCut=noisyRO->MNBTight_PsVetoFlaggedPartitions();
131 bool badHVlinesFlag=noisyRO->HVlineFlaggedPartitions();
132
134 if ( badFEBFlag || badFEBFlag_W || badSaturatedTightCut || MNBLooseCut || MNBTightCut || MNBTight_PsVetoCut || badHVlinesFlag )
135 {
136 // retrieve EventInfo
137 bool failSetWARN=false;
138 bool failSetWARNREASON=false;
139 // set warning flag except if the error flag has been already set
140 if ( eventInfo->errorState(xAOD::EventInfo::LAr) != xAOD::EventInfo::Error) {
141 if ( badFEBFlag ) {
142 failSetWARN |= (!eventInfo->updateErrorState(xAOD::EventInfo::LAr,xAOD::EventInfo::Warning));
143 failSetWARNREASON |= (!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::BADFEBS));
144 }//endif badFEBFlag
145
146 if ( badFEBFlag_W ) {
147 //Set WARNING Flag
148 failSetWARN |=(!eventInfo->updateErrorState(xAOD::EventInfo::LAr,xAOD::EventInfo::Warning));
149 // Set reason why event was flagged
150 failSetWARNREASON |=(!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::BADFEBS_W));
151 }// end if badFEBFlag_W
152
153 if ( badSaturatedTightCut ){
154 failSetWARNREASON |= (!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::TIGHTSATURATEDQ));
155 }
156 }
157
158 if ( MNBTightCut ) {
159 failSetWARN |=(!eventInfo->updateErrorState(xAOD::EventInfo::LAr,xAOD::EventInfo::Warning));
160 // Set reason why event was flagged
161 failSetWARNREASON |=(!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::MININOISEBURSTTIGHT));
162 }
163
164 if ( MNBTight_PsVetoCut ) {
165 failSetWARN |=(!eventInfo->updateErrorState(xAOD::EventInfo::LAr,xAOD::EventInfo::Warning));
166 // Set reason why event was flagged
167 failSetWARNREASON |=(!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::MININOISEBURSTTIGHT_PSVETO));
168 }
169
170 if ( MNBLooseCut ) { //FIXME Tight cut actually implies loose cut too
171 failSetWARNREASON |=(!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::MININOISEBURSTLOOSE));
172 }
173
174 if ( badHVlinesFlag ) {
175 failSetWARN |= (!eventInfo->updateErrorState(xAOD::EventInfo::LAr,xAOD::EventInfo::Warning));
176 failSetWARNREASON |= (!eventInfo->updateEventFlagBit(xAOD::EventInfo::LAr,LArEventBitInfo::BADHVLINES));
177 }//endif badFEBFlag
178
179 if (failSetWARN) ATH_MSG_WARNING( "Failure during EventInfo::setEventErrorState(EventInfo::LAR,EventInfo::WARNING)" );
180 if (failSetWARNREASON) ATH_MSG_WARNING( "Failure during setEventFlagBit(EventInfo::LAr,...)" );
181
182 }
183 return StatusCode::SUCCESS;
184}
185
187{
188 return StatusCode::SUCCESS;
189}
190
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
LArBadXCont< LArBadFeb > LArBadFebCont
Handle class for adding a decoration to an object.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
This class provides the client interface for accessing the detector description information common to...
const_iterator end() const
Access to the end iterator of the underlying vector.
const_iterator begin() const
Access to the begin iterator of the underlying vector.
BadChanVec::const_iterator const_iterator
SG::ReadCondHandleKey< LArHVNMap > m_hvMapKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG::ReadCondHandleKey< LArBadFebCont > m_knownMNBFEBsVecKey
SG::WriteHandleKey< LArNoisyROSummary > m_outputKey
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode finalize() override
SG::ReadCondHandleKey< LArBadFebCont > m_knownBadFEBsVecKey
virtual StatusCode initialize() override
ToolHandle< ILArNoisyROTool > m_noisyROTool
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
SG::ReadCondHandleKey< LArHVIdMapping > m_hvCablingKey
SG::ReadHandleKey< CaloCellContainer > m_CaloCellContainerName
Gaudi::Property< bool > m_isMC
LArNoisyROAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
@ LAr
The LAr calorimeter.
@ Warning
The sub-detector issued a warning.
@ Error
The sub-detector issued an error.