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  m_BadLBTool(this, "DQBadLBFilterTool"),
10  m_ReadyFilterTool(this, "DQAtlasReadyFilterTool")
11  {
12  declareProperty("useBadLBTool", m_useBadLBTool=false);
13  declareProperty("BadLBTool", m_BadLBTool);
14 
15  declareProperty("useReadyFilterTool",m_useReadyFilterTool=true);
16  declareProperty("ReadyFilterTool",m_ReadyFilterTool);
17 
18  declareProperty("useLArCollisionFilterTool",m_useCollisionFilterTool=true);
19 
20  declareProperty("useLArNoisyAlg",m_useLArNoisyAlg=false);
21 
22  declareProperty("useBeamBackgroundRemoval",m_useBeamBackgroundRemoval=false);
23 }
24 
26 
27  // retrieve AtlasReadyFilter tool
29  StatusCode sc = m_ReadyFilterTool.retrieve();
30  if(sc.isFailure()) {
31  ATH_MSG_ERROR("Could Not Retrieve AtlasReadyFilterTool " << m_ReadyFilterTool);
32  m_useReadyFilterTool = false;
33  return sc;
34  }
35  }
36  else {
37  m_ReadyFilterTool.disable();
38  }
39 
40  // retrieve BadLBFilter tool
41  if(m_useBadLBTool){
42  StatusCode sc = m_BadLBTool.retrieve();
43  if(sc.isFailure()){
44  ATH_MSG_ERROR("Unable to retrieve the DQBadLBFilterTool");
45  m_useBadLBTool = false;
46  return sc;
47  }
48  ATH_MSG_INFO("DQBadLBFilterTool retrieved");
49  }
50  else {
51  m_BadLBTool.disable();
52  }
53 
56  ATH_CHECK( detStore()->retrieve (m_calo_id, "CaloCell_ID") );
57 
59 }
60 
61 StatusCode CaloMonAlgBase::checkFilters(bool &ifPass, bool &passBeamBackgroundRemoval, const std::string &MonGroupName, const EventContext &ctx) const{
62 
63  ATH_MSG_DEBUG("CaloMonAlgBase:checkFilters() starts "<<MonGroupName);
64 
65  auto evtbin = Monitored::Scalar<int>("EvtBin",1);
66  fill(MonGroupName,evtbin);
67 
68  ifPass = 0;
70  if (m_ReadyFilterTool->accept()) {
71  ifPass = 1;
72  evtbin = 2;
73  fill(MonGroupName,evtbin); //All events with ATLAS Ready
74  }
75  }
76  else{
77  evtbin = 2;
78  fill(MonGroupName,evtbin); //ATLAS ready not activated
79  ifPass = 1;
80  }
81 
82  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() ATLAS Ready done");
83 
85 
86  if (m_useBadLBTool) {
87  if (m_BadLBTool->accept()) {
88  ifPass = ifPass && 1;
89  if(ifPass) {evtbin=3; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB
90  }
91  else {
92  ifPass = 0;
93  }
94  }
95  else{
96  if(ifPass) {evtbin=3; fill(MonGroupName,evtbin);}
97  }
98 
99  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() BadLBTool done");
100 
101  // Filter the events identfied as collision by the LAr system
102  // Useful in CosmicCalo to reject collision candidates
105  if(!larTime.isValid()){
106  ATH_MSG_WARNING("Unable to retrieve LArCollisionTime event store");
107  if(ifPass) {evtbin=4; fill(MonGroupName,evtbin);}
108  }
109  else {
110  if (larTime->timeC()!=0 && larTime->timeA()!=0 && std::fabs(larTime->timeC() - larTime->timeA())<10) {
111  ifPass = 0;
112  }
113  else {
114  ifPass = ifPass && 1;
115  if(ifPass) {evtbin=4; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time
116  }
117  }
118  }
119  else{
120  if(ifPass) {evtbin=4; fill(MonGroupName,evtbin);}
121  }
122  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() CollisionFilterTool done");
123 
124 
125  passBeamBackgroundRemoval=true;
128  if(!beamBackgroundData.isValid()){
129  ATH_MSG_WARNING("Unable to retrieve BeamBackgroundData");
130  }
131  else {
132  if( beamBackgroundData->GetNumSegment() > 0 ) {
133  passBeamBackgroundRemoval = false;
134  ifPass = 0;
135  ATH_MSG_DEBUG("Identified background event");
136  }
137  else {
138  passBeamBackgroundRemoval = true;
139  ifPass = ifPass && 1;
140  if(ifPass){evtbin=5; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background
141  }
142  }
143  }
144  else { // Do not use BeamBackgroundRemoval
145  ifPass = ifPass && 1;
146  if(ifPass) {evtbin=5; fill(MonGroupName,evtbin);} //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background
147 
148  }
149  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() m_useBeamBackgroundRemoval done");
150 
151  std::string TheTrigger;
152  if ( m_vTrigChainNames.empty()) {
153  TheTrigger="NoTrigSel";
154  ifPass = ifPass && 1; // No Trigger Filter check
155  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
156  }
157  else {
158  TheTrigger = m_triggerChainString; // Trigger Filter not implemented ++ FIXME ==
159  if(ifPass) {evtbin=6; fill(MonGroupName,evtbin);}
160  }
161 
162  if(m_useLArNoisyAlg && (eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error)) {
163  ifPass = 0;
164  }
165  else {
166  ifPass = ifPass && 1;
167  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
168  }
169 
170  ATH_MSG_DEBUG("CaloMonAlgBase::checkFilters() is done");
171  return StatusCode::SUCCESS;
172 }
173 
174 
175 
176 void CaloMonAlgBase::getHistoCoordinates(const CaloDetDescrElement* dde, float& celleta, float& cellphi, unsigned& iLyr, unsigned& iLyrNS) const {
177 
178  celleta=dde->eta_raw();
179  cellphi=dde->phi_raw();
180 
181  int calosample=dde->getSampling();
182  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
183  iLyrNS=m_caloSamplingToLyrNS.at(calosample); //will throw if out of bounds
184  if ((iLyrNS==EMB1NS || iLyrNS==EMB2NS) && m_calo_id->region(dde->identify())==1) {
185  //We are in the awkward region 1 of the EM Barrel
186  //Looking at the image at http://atlas.web.cern.ch/Atlas/GROUPS/LIQARGEXT/TDR/figures6/figure6-17.eps
187  //may be useful to understand what's going on here.
188 
189  //In brief: Region 1, layer 1 is closer related ot the middle compartment (aka layer 2)
190  // and region 1, layer 2 closer related to the back compartment (aka layer 3)
191  iLyrNS+=1;
192 
193  //Layer 2: 0<eta<1.4 + 1.4<eta<1.475, deta = 0.025. 3 rows of cells from region 1
194  //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
195  }
196 
197  const unsigned side=(celleta>0) ? 0 : 1; //Value >0 means A-side
198  iLyr=iLyrNS*2+side;
199  }
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:61
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:114
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:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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:355
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:356
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:25
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:36
CaloDetDescrElement::identify
Identifier identify() const override final
cell identifier
Definition: CaloDetDescrElement.cxx:64
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
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:176
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:107
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
CaloMonAlgBase::m_useLArNoisyAlg
bool m_useLArNoisyAlg
Definition: CaloMonAlgBase.h:35
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
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