ATLAS Offline Software
CaloMonAlgBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "CaloMonAlgBase.h"
6 
7 CaloMonAlgBase::CaloMonAlgBase(const std::string& name, ISvcLocator* pSvcLocator)
8  :AthMonitorAlgorithm(name, pSvcLocator)
9  {
10  declareProperty("useBadLBTool", m_useBadLBTool=false);
11  declareProperty("BadLBTool", m_BadLBTool);
12 
13  declareProperty("useReadyFilterTool",m_useReadyFilterTool=true);
14  declareProperty("ReadyFilterTool",m_ReadyFilterTool);
15 
16  declareProperty("useLArCollisionFilterTool",m_useCollisionFilterTool=true);
17 
18  declareProperty("useLArNoisyAlg",m_useLArNoisyAlg=false);
19 
20  declareProperty("useBeamBackgroundRemoval",m_useBeamBackgroundRemoval=false);
21 }
22 
24 
25  // retrieve AtlasReadyFilter tool
27  StatusCode sc = m_ReadyFilterTool.retrieve();
28  if(sc.isFailure()) {
29  ATH_MSG_ERROR("Could Not Retrieve AtlasReadyFilterTool " << m_ReadyFilterTool);
30  m_useReadyFilterTool = false;
31  return sc;
32  }
33  }
34  else {
35  m_ReadyFilterTool.disable();
36  }
37 
38  // retrieve BadLBFilter tool
39  if(m_useBadLBTool){
40  StatusCode sc = m_BadLBTool.retrieve();
41  if(sc.isFailure()){
42  ATH_MSG_ERROR("Unable to retrieve the DQBadLBFilterTool");
43  m_useBadLBTool = false;
44  return sc;
45  }
46  ATH_MSG_INFO("DQBadLBFilterTool retrieved");
47  }
48  else {
49  m_BadLBTool.disable();
50  }
51 
54  ATH_CHECK( detStore()->retrieve (m_calo_id, "CaloCell_ID") );
55 
57 }
58 
59 StatusCode CaloMonAlgBase::checkFilters(bool &ifPass, bool &passBeamBackgroundRemoval, const std::string &MonGroupName, const EventContext &ctx) const{
60 
61  ATH_MSG_DEBUG("CaloMonAlgBase:checkFilters() starts "<<MonGroupName);
62 
63  auto evtbin = Monitored::Scalar<int>("EvtBin",1);
64  fill(MonGroupName,evtbin);
65 
66  ifPass = 0;
68  if (m_ReadyFilterTool->accept()) {
69  ifPass = 1;
70  evtbin = 2;
71  fill(MonGroupName,evtbin); //All events with ATLAS Ready
72  }
73  }
74  else{
75  evtbin = 2;
76  fill(MonGroupName,evtbin); //ATLAS ready not activated
77  ifPass = 1;
78  }
79 
80  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() ATLAS Ready done");
81 
83 
84  if (m_useBadLBTool) {
85  if (m_BadLBTool->accept()) {
86  ifPass = ifPass && 1;
87  if(ifPass) {evtbin=3; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB
88  }
89  else {
90  ifPass = 0;
91  }
92  }
93  else{
94  if(ifPass) {evtbin=3; fill(MonGroupName,evtbin);}
95  }
96 
97  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() BadLBTool done");
98 
99  // Filter the events identfied as collision by the LAr system
100  // Useful in CosmicCalo to reject collision candidates
103  if(!larTime.isValid()){
104  ATH_MSG_WARNING("Unable to retrieve LArCollisionTime event store");
105  if(ifPass) {evtbin=4; fill(MonGroupName,evtbin);}
106  }
107  else {
108  if (larTime->timeC()!=0 && larTime->timeA()!=0 && std::fabs(larTime->timeC() - larTime->timeA())<10) {
109  ifPass = 0;
110  }
111  else {
112  ifPass = ifPass && 1;
113  if(ifPass) {evtbin=4; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time
114  }
115  }
116  }
117  else{
118  if(ifPass) {evtbin=4; fill(MonGroupName,evtbin);}
119  }
120  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() CollisionFilterTool done");
121 
122 
123  passBeamBackgroundRemoval=true;
126  if(!beamBackgroundData.isValid()){
127  ATH_MSG_WARNING("Unable to retrieve BeamBackgroundData");
128  }
129  else {
130  if( beamBackgroundData->GetNumSegment() > 0 ) {
131  passBeamBackgroundRemoval = false;
132  ifPass = 0;
133  ATH_MSG_DEBUG("Identified background event");
134  }
135  else {
136  passBeamBackgroundRemoval = true;
137  ifPass = ifPass && 1;
138  if(ifPass){evtbin=5; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background
139  }
140  }
141  }
142  else { // Do not use BeamBackgroundRemoval
143  ifPass = ifPass && 1;
144  if(ifPass) {evtbin=5; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background
145 
146  }
147  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() m_useBeamBackgroundRemoval done");
148 
149  std::string TheTrigger;
150  if ( m_vTrigChainNames.empty()) {
151  TheTrigger="NoTrigSel";
152  ifPass = ifPass && 1; // No Trigger Filter check
153  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
154  }
155  else {
156  TheTrigger = m_triggerChainString; // Trigger Filter not implemented ++ FIXME ==
157  if(ifPass) {evtbin=6; fill(MonGroupName,evtbin);}
158  }
159 
160  if(m_useLArNoisyAlg && (eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error)) {
161  ifPass = 0;
162  }
163  else {
164  ifPass = ifPass && 1;
165  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
166  }
167 
168  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() is done");
169  return StatusCode::SUCCESS;
170 }
171 
172 
173 
174 void CaloMonAlgBase::getHistoCoordinates(const CaloDetDescrElement* dde, float& celleta, float& cellphi, unsigned& iLyr, unsigned& iLyrNS) const {
175 
176  celleta=dde->eta_raw();
177  cellphi=dde->phi_raw();
178 
179  int calosample=dde->getSampling();
180  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
181  iLyrNS=m_caloSamplingToLyrNS.at(calosample); //will throw if out of bounds
182  if ((iLyrNS==EMB1NS || iLyrNS==EMB2NS) && m_calo_id->region(dde->identify())==1) {
183  //We are in the awkward region 1 of the EM Barrel
184  //Looking at the image at http://atlas.web.cern.ch/Atlas/GROUPS/LIQARGEXT/TDR/figures6/figure6-17.eps
185  //may be useful to understand what's going on here.
186 
187  //In brief: Region 1, layer 1 is closer related ot the middle compartment (aka layer 2)
188  // and region 1, layer 2 closer related to the back compartment (aka layer 3)
189  iLyrNS+=1;
190 
191  //Layer 2: 0<eta<1.4 + 1.4<eta<1.475, deta = 0.025. 3 rows of cells from region 1
192  //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
193  }
194 
195  const unsigned side=(celleta>0) ? 0 : 1; //Value >0 means A-side
196  iLyr=iLyrNS*2+side;
197  }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CaloMonAlgBase::checkFilters
StatusCode checkFilters(bool &ifPass, bool &passBeamBackgroundRemoval, const std::string &MonGroupName, const EventContext &ctx) const
Definition: CaloMonAlgBase.cxx:59
CaloDetDescrElement::is_lar_em_endcap_inner
bool is_lar_em_endcap_inner() const
cell belongs to the inner wheel of EM end cap
Definition: CaloDetDescrElement.cxx:113
CaloCell_Base_ID::region
int region(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloMonAlgBase::m_LArCollisionTimeKey
SG::ReadHandleKey< LArCollisionTime > m_LArCollisionTimeKey
Definition: CaloMonAlgBase.h:26
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
AthMonitorAlgorithm::m_triggerChainString
Gaudi::Property< std::string > m_triggerChainString
Trigger chain string pulled from the job option and parsed into a vector.
Definition: AthMonitorAlgorithm.h:360
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
AthMonitorAlgorithm::m_vTrigChainNames
std::vector< std::string > m_vTrigChainNames
Vector of trigger chain names parsed from trigger chain string.
Definition: AthMonitorAlgorithm.h:361
CaloMonAlgBase::m_useCollisionFilterTool
bool m_useCollisionFilterTool
Definition: CaloMonAlgBase.h:37
CaloMonAlgBase::EMB1NS
@ EMB1NS
Definition: CaloMonAlgBase.h:54
CaloMonAlgBase::m_useBeamBackgroundRemoval
bool m_useBeamBackgroundRemoval
Definition: CaloMonAlgBase.h:38
CaloMonAlgBase::initialize
virtual StatusCode initialize()
initialize
Definition: CaloMonAlgBase.cxx:23
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
CaloMonAlgBase::m_caloSamplingToLyrNS
const std::map< unsigned, LayerEnumNoSides > m_caloSamplingToLyrNS
Definition: CaloMonAlgBase.h:60
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
TRT::Hit::side
@ side
Definition: HitInfo.h:83
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:39
CaloDetDescrElement::identify
Identifier identify() const override final
cell identifier
Definition: CaloDetDescrElement.cxx:63
CaloMonAlgBase.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloMonAlgBase::CaloMonAlgBase
CaloMonAlgBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CaloMonAlgBase.cxx:7
CaloMonAlgBase::m_useBadLBTool
bool m_useBadLBTool
Definition: CaloMonAlgBase.h:30
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
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloMonAlgBase::m_calo_id
const CaloCell_ID * m_calo_id
Definition: CaloMonAlgBase.h:43
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
CaloMonAlgBase::m_BadLBTool
ToolHandle< IDQFilterTool > m_BadLBTool
Definition: CaloMonAlgBase.h:31
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
CaloMonAlgBase::getHistoCoordinates
void getHistoCoordinates(const CaloDetDescrElement *dde, float &celleta, float &cellphi, unsigned &iLyr, unsigned &iLyrNS) const
Definition: CaloMonAlgBase.cxx:174
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:111
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
CaloMonAlgBase::m_useLArNoisyAlg
bool m_useLArNoisyAlg
Definition: CaloMonAlgBase.h:35
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:22
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloMonAlgBase::m_useReadyFilterTool
bool m_useReadyFilterTool
Definition: CaloMonAlgBase.h:32
CaloMonAlgBase::m_beamBackgroundKey
SG::ReadHandleKey< BeamBackgroundData > m_beamBackgroundKey
Definition: CaloMonAlgBase.h:27
CaloMonAlgBase::m_ReadyFilterTool
ToolHandle< IDQFilterTool > m_ReadyFilterTool
Definition: CaloMonAlgBase.h:33
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
CaloMonAlgBase::EMB2NS
@ EMB2NS
Definition: CaloMonAlgBase.h:54
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352