ATLAS Offline Software
Loading...
Searching...
No Matches
CaloMonAlgBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CaloMonAlgBase.h"
6
7CaloMonAlgBase::CaloMonAlgBase(const std::string& name, ISvcLocator* pSvcLocator)
8 :AthMonitorAlgorithm(name, pSvcLocator)
9{
10}
11
13
14 // retrieve AtlasReadyFilter tool
16 StatusCode sc = m_ReadyFilterTool.retrieve();
17 if(sc.isFailure()) {
18 ATH_MSG_ERROR("Could Not Retrieve AtlasReadyFilterTool " << m_ReadyFilterTool);
20 return sc;
21 }
22 }
23 else {
24 m_ReadyFilterTool.disable();
25 }
26
27 // retrieve BadLBFilter tool
28 if(m_useBadLBTool){
29 StatusCode sc = m_BadLBTool.retrieve();
30 if(sc.isFailure()){
31 ATH_MSG_ERROR("Unable to retrieve the DQBadLBFilterTool");
32 m_useBadLBTool = false;
33 return sc;
34 }
35 ATH_MSG_INFO("DQBadLBFilterTool retrieved");
36 }
37 else {
38 m_BadLBTool.disable();
39 }
40
41 ATH_CHECK( m_LArCollisionTimeKey.initialize(m_useCollisionFilterTool) );
42 ATH_CHECK( m_beamBackgroundKey.initialize(m_useBeamBackgroundRemoval) );
43 ATH_CHECK( detStore()->retrieve (m_calo_id, "CaloCell_ID") );
44
46}
47
48StatusCode CaloMonAlgBase::checkFilters(bool &ifPass, bool &passBeamBackgroundRemoval, const std::string &MonGroupName, const EventContext &ctx) const{
49
50 ATH_MSG_DEBUG("CaloMonAlgBase:checkFilters() starts "<<MonGroupName);
51
52 auto evtbin = Monitored::Scalar<int>("EvtBin",1);
53 fill(MonGroupName,evtbin);
54
55 ifPass = 0;
57 if (m_ReadyFilterTool->accept(ctx)) {
58 ifPass = 1;
59 evtbin = 2;
60 fill(MonGroupName,evtbin); //All events with ATLAS Ready
61 }
62 }
63 else{
64 evtbin = 2;
65 fill(MonGroupName,evtbin); //ATLAS ready not activated
66 ifPass = 1;
67 }
68
69 ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() ATLAS Ready done");
70
72
73 if (m_useBadLBTool) {
74 if (m_BadLBTool->accept(ctx)) {
75 ifPass = ifPass && 1;
76 if(ifPass) {evtbin=3; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB
77 }
78 else {
79 ifPass = 0;
80 }
81 }
82 else{
83 if(ifPass) {evtbin=3; fill(MonGroupName,evtbin);}
84 }
85
86 ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() BadLBTool done");
87
88 // Filter the events identfied as collision by the LAr system
89 // Useful in CosmicCalo to reject collision candidates
92 if(!larTime.isValid()){
93 ATH_MSG_WARNING("Unable to retrieve LArCollisionTime event store");
94 if(ifPass) {evtbin=4; fill(MonGroupName,evtbin);}
95 }
96 else {
97 if (larTime->timeC()!=0 && larTime->timeA()!=0 && std::fabs(larTime->timeC() - larTime->timeA())<10) {
98 ifPass = 0;
99 }
100 else {
101 ifPass = ifPass && 1;
102 if(ifPass) {evtbin=4; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time
103 }
104 }
105 }
106 else{
107 if(ifPass) {evtbin=4; fill(MonGroupName,evtbin);}
108 }
109 ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() CollisionFilterTool done");
110
111
112 passBeamBackgroundRemoval=true;
115 if(!beamBackgroundData.isValid()){
116 ATH_MSG_WARNING("Unable to retrieve BeamBackgroundData");
117 }
118 else {
119 if( beamBackgroundData->GetNumSegment() > 0 ) {
120 passBeamBackgroundRemoval = false;
121 ifPass = 0;
122 ATH_MSG_DEBUG("Identified background event");
123 }
124 else {
125 passBeamBackgroundRemoval = true;
126 ifPass = ifPass && 1;
127 if(ifPass){evtbin=5; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background
128 }
129 }
130 }
131 else { // Do not use BeamBackgroundRemoval
132 ifPass = ifPass && 1;
133 if(ifPass) {evtbin=5; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background
134
135 }
136 ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() m_useBeamBackgroundRemoval done");
137
138 std::string TheTrigger;
139 if ( m_vTrigChainNames.empty()) {
140 TheTrigger="NoTrigSel";
141 ifPass = ifPass && 1; // No Trigger Filter check
142 if(ifPass) {evtbin=6; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background and Trigger Filter pass
143 }
144 else {
145 TheTrigger = m_triggerChainString; // Trigger Filter not implemented ++ FIXME ==
146 if(ifPass) {evtbin=6; fill(MonGroupName,evtbin);}
147 }
148
149 if(m_useLArNoisyAlg && (eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error)) {
150 ifPass = 0;
151 }
152 else {
153 ifPass = ifPass && 1;
154 if(ifPass) {evtbin=7; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background and Trigger Filter pass and no Lar Error
155 }
156
157 ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() is done with pass=" << ifPass);
158 return StatusCode::SUCCESS;
159}
160
161
162
163void CaloMonAlgBase::getHistoCoordinates(const CaloDetDescrElement* dde, float& celleta, float& cellphi, unsigned& iLyr, unsigned& iLyrNS) const {
164
165 celleta=dde->eta_raw();
166 cellphi=dde->phi_raw();
167
168 int calosample=dde->getSampling();
169 if (dde->is_lar_em_endcap_inner()) calosample-=1; //Here, we consider the two layers of the EMEC IW as EME1 and EME2 instad of layer 2 and 3
170 iLyrNS=m_caloSamplingToLyrNS.at(calosample); //will throw if out of bounds
171 if ((iLyrNS==EMB1NS || iLyrNS==EMB2NS) && m_calo_id->region(dde->identify())==1) {
172 //We are in the awkward region 1 of the EM Barrel
173 //Looking at the image at http://atlas.web.cern.ch/Atlas/GROUPS/LIQARGEXT/TDR/figures6/figure6-17.eps
174 //may be useful to understand what's going on here.
175
176 //In brief: Region 1, layer 1 is closer related ot the middle compartment (aka layer 2)
177 // and region 1, layer 2 closer related to the back compartment (aka layer 3)
178 iLyrNS+=1;
179
180 //Layer 2: 0<eta<1.4 + 1.4<eta<1.475, deta = 0.025. 3 rows of cells from region 1
181 //Layer 3: 0<eta<1.35 (deta=0.050) + 1.4<eta<1.475 (deta = 0.075). 1 row of cell from region 1 with different dEta
182 }
183
184 const unsigned side=(celleta>0) ? 0 : 1; //Value >0 means A-side
185 iLyr=iLyrNS*2+side;
186 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
const ServiceHandle< StoreGateSvc > & detStore() const
Gaudi::Property< std::string > m_triggerChainString
Trigger chain string pulled from the job option and parsed into a vector.
virtual StatusCode initialize() override
initialize
std::vector< std::string > m_vTrigChainNames
Vector of trigger chain names parsed from trigger chain string.
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.).
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
This class groups all DetDescr information related to a CaloCell.
CaloCell_ID::CaloSample getSampling() const
cell sampling
Identifier identify() const override final
cell identifier
bool is_lar_em_endcap_inner() const
cell belongs to the inner wheel of EM end cap
CaloMonAlgBase(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< IDQFilterTool > m_ReadyFilterTool
Gaudi::Property< bool > m_useBeamBackgroundRemoval
Gaudi::Property< bool > m_useCollisionFilterTool
Gaudi::Property< bool > m_useLArNoisyAlg
StatusCode checkFilters(bool &ifPass, bool &passBeamBackgroundRemoval, const std::string &MonGroupName, const EventContext &ctx) const
Gaudi::Property< bool > m_useBadLBTool
SG::ReadHandleKey< LArCollisionTime > m_LArCollisionTimeKey
ToolHandle< IDQFilterTool > m_BadLBTool
const std::map< unsigned, LayerEnumNoSides > m_caloSamplingToLyrNS
Gaudi::Property< bool > m_useReadyFilterTool
void getHistoCoordinates(const CaloDetDescrElement *dde, float &celleta, float &cellphi, unsigned &iLyr, unsigned &iLyrNS) const
virtual StatusCode initialize() override
initialize
const CaloCell_ID * m_calo_id
SG::ReadHandleKey< BeamBackgroundData > m_beamBackgroundKey
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
@ LAr
The LAr calorimeter.
@ Error
The sub-detector issued an error.
::StatusCode StatusCode
StatusCode definition for legacy code.
void fill(H5::Group &out_file, size_t iterations)