ATLAS Offline Software
CaloMonToolBase.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 "CaloMonToolBase.h"
6 #include "TH1F.h"
7 
8 CaloMonToolBase::CaloMonToolBase(const std::string& type, const std::string& name,const IInterface* parent)
10  m_lb(0),
11  m_passBeamBackgroundRemoval(false),
12  m_h_EvtRejSumm(nullptr),
13  m_BadLBTool(this, "BadLBTool", "DQBadLBFilterTool"),
14  m_ReadyFilterTool(this, "ReadyFilterTool", "DQAtlasReadyFilterTool")
15  {
16  declareProperty("useBadLBTool", m_useBadLBTool=false);
17 
18  declareProperty("useReadyFilterTool",m_useReadyFilterTool=true);
19 
20  declareProperty("useLArCollisionFilterTool",m_useCollisionFilterTool=true);
21 
22  declareProperty("useLArNoisyAlg",m_useLArNoisyAlg=false);
23 
24  declareProperty("useBeamBackgroundRemoval",m_useBeamBackgroundRemoval=false);
25 }
27 
29 
30  // initialize keys
34 
35  // retrieve AtlasReadyFilter tool
37  StatusCode sc = m_ReadyFilterTool.retrieve();
38  if(sc.isFailure()) {
39  ATH_MSG_ERROR("Could Not Retrieve AtlasReadyFilterTool " << m_ReadyFilterTool);
40  m_useReadyFilterTool = false;
41  return sc;
42  }
43  }
44  else {
45  m_ReadyFilterTool.disable();
46  }
47 
48  // retrieve BadLBFilter tool
49  if(m_useBadLBTool){
50  StatusCode sc = m_BadLBTool.retrieve();
51  if(sc.isFailure()){
52  ATH_MSG_ERROR("Unable to retrieve the DQBadLBFilterTool");
53  m_useBadLBTool = false;
54  return sc;
55  }
56  ATH_MSG_INFO("DQBadLBFilterTool retrieved");
57  }
58  else {
59  m_BadLBTool.disable();
60  }
61  return StatusCode::SUCCESS;
62 }
63 
64 
65 
67  m_h_EvtRejSumm = new TH1I("nEvtsRejectByDifferentTool","Total Events: bin 1, ATLAS Ready: 2, && Good LAr LB: 3, && No LAr collision: 4, && No Beam Background: 5, && No Trigger Filer: 6, && No LArError: 7 ",7,1.,8.);
68  m_h_EvtRejSumm->GetYaxis()->SetTitle("RejectedEvents");
69 
70  const std::array<const char*,7> binLabels={{"TotalEvents","ATLAS Ready","with Good LAr LB","with No LAr Collision","with No Beam Background", "with No Trigger Filter","with No LArError"}};
71 
72  for (unsigned i=0;i<binLabels.size();++i) {
73  m_h_EvtRejSumm->GetXaxis()->SetBinLabel(i+1,binLabels[i]);
74  }
76  m_h_EvtRejSumm->GetXaxis()->SetBinLabel(2,"ATLAS Ready-OFF");
77  }
78  if (!m_useBadLBTool){
79  m_h_EvtRejSumm->GetXaxis()->SetBinLabel(3,"Good LAr LB-OFF");
80  }
82  m_h_EvtRejSumm->GetXaxis()->SetBinLabel(4,"LAr collision-OFF");
83  }
85  m_h_EvtRejSumm->GetXaxis()->SetBinLabel(5,"Beam backgr.-OFF");
86  }
87  if (!m_useLArNoisyAlg){
88  m_h_EvtRejSumm->GetXaxis()->SetBinLabel(7,"LAr Error Veto-OFF");
89  }
90 
91  return group->regHist( m_h_EvtRejSumm );
92 }
93 
94 
96 
97  // ATH_MSG_INFO("CaloCellVecMon::checkFilters() starts");
98 
99  m_h_EvtRejSumm->Fill(1); //Counter of all events seen
100 
101  ifPass = 0;
102  if (m_useReadyFilterTool) {
103  if (m_ReadyFilterTool->accept()) {
104  ifPass = 1;
105  m_h_EvtRejSumm->Fill(2); //All events with ATLAS Ready
106  }
107  }
108  else{
109  m_h_EvtRejSumm->Fill(2); //ATLAS ready not activated
110  ifPass = 1;
111  }
112 
114  if (!eventInfo.isValid()) {
115  ATH_MSG_ERROR("Event info not found !" );
116  return StatusCode::SUCCESS;
117  }
118 
119  m_lb = eventInfo->lumiBlock();
120  if (m_useBadLBTool) {
121  if (m_BadLBTool->accept()) {
122  ifPass = ifPass && 1;
123  if(ifPass) m_h_EvtRejSumm->Fill(3); //All events with ATLAS Ready and Good LB
124  }
125  else {
126  ifPass = 0;
127  }
128  }
129  else{
130  if(ifPass) m_h_EvtRejSumm->Fill(3);
131  }
132 
133  // Filter the events identfied as collision by the LAr system
134  // Useful in CosmicCalo to reject collision candidates
137  if(!larTime.isValid()){
138  ATH_MSG_WARNING("Unable to retrieve LArCollisionTime event store");
139  if(ifPass) m_h_EvtRejSumm->Fill(4);
140  }
141  else {
142  if (larTime->timeC()!=0 && larTime->timeA()!=0 && std::fabs(larTime->timeC() - larTime->timeA())<10) {
143  ifPass = 0;
144  }
145  else {
146  ifPass = ifPass && 1;
147  if(ifPass) m_h_EvtRejSumm->Fill(4); //All events with ATLAS Ready and Good LB and Good LAr collision time
148  }
149  }
150  }
151  else{
152  if(ifPass) m_h_EvtRejSumm->Fill(4);
153  }
154 
155 
159  if(!beamBackgroundData.isValid()){
160  ATH_MSG_WARNING("Unable to retrieve BeamBackgroundData");
161  }
162  else {
163  if( beamBackgroundData->GetNumSegment() > 0 ) {
165  ifPass = 0;
166  ATH_MSG_DEBUG("Identified background event");
167  }
168  else {
170  ifPass = ifPass && 1;
171  if(ifPass) m_h_EvtRejSumm->Fill(5); //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background
172  }
173  }
174  }
175  else { // Do not use BeamBackgroundRemoval
176  ifPass = ifPass && 1;
177  if(ifPass) m_h_EvtRejSumm->Fill(5); //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background
178 
179  }
180 
181  std::string TheTrigger;
182  if (m_triggerChainProp.empty()) {
183  TheTrigger="NoTrigSel";
184  ifPass = ifPass && 1; // No Trigger Filter check
185  if(ifPass) m_h_EvtRejSumm->Fill(6); //All events with ATLAS Ready and Good LB and Good LAr collision time and not Beam Background and Trigger Filter pass
186  }
187  else {
188  TheTrigger = m_triggerChainProp; // Trigger Filter not implemented ++ FIXME ==
189  if(ifPass) m_h_EvtRejSumm->Fill(6);
190  }
191 
192  if(m_useLArNoisyAlg && (eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error)) {
193  ifPass = 0;
194  }
195  else {
196  ifPass = ifPass && 1;
197  if(ifPass) m_h_EvtRejSumm->Fill(7); //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
198  }
199 
200  ATH_MSG_VERBOSE("CaloMonBase::checkFilters() is done");
201  return StatusCode::SUCCESS;
202 }
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TH1I
Definition: rootspy.cxx:332
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:74
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloMonToolBase::m_lb
int m_lb
Definition: CaloMonToolBase.h:31
CaloMonToolBase::m_useLArNoisyAlg
bool m_useLArNoisyAlg
Definition: CaloMonToolBase.h:42
CaloMonToolBase::m_useReadyFilterTool
bool m_useReadyFilterTool
Definition: CaloMonToolBase.h:39
CaloMonToolBase::CaloMonToolBase
CaloMonToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CaloMonToolBase.cxx:8
CaloMonToolBase::m_useCollisionFilterTool
bool m_useCollisionFilterTool
Definition: CaloMonToolBase.h:44
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
CaloMonToolBase.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
CaloMonToolBase::checkFilters
StatusCode checkFilters(bool &ifPass)
Definition: CaloMonToolBase.cxx:95
ManagedMonitorToolBase::MonGroup
A container of information describing a monitoring object.
Definition: ManagedMonitorToolBase.h:138
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ManagedMonitorToolBase::m_triggerChainProp
std::string m_triggerChainProp
Definition: ManagedMonitorToolBase.h:917
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
CaloMonToolBase::m_passBeamBackgroundRemoval
bool m_passBeamBackgroundRemoval
Definition: CaloMonToolBase.h:32
CaloMonToolBase::m_ReadyFilterTool
ToolHandle< IDQFilterTool > m_ReadyFilterTool
Definition: CaloMonToolBase.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
CaloMonToolBase::initialize
StatusCode initialize()
Definition: CaloMonToolBase.cxx:28
CaloMonToolBase::m_EventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_EventInfoKey
Definition: CaloMonToolBase.h:47
CaloMonToolBase::m_beamBackgroundKey
SG::ReadHandleKey< BeamBackgroundData > m_beamBackgroundKey
Definition: CaloMonToolBase.h:49
CaloMonToolBase::m_BadLBTool
ToolHandle< IDQFilterTool > m_BadLBTool
Definition: CaloMonToolBase.h:38
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloMonToolBase::m_useBeamBackgroundRemoval
bool m_useBeamBackgroundRemoval
Definition: CaloMonToolBase.h:45
CaloMonToolBase::bookBaseHists
virtual StatusCode bookBaseHists(MonGroup *group)
Definition: CaloMonToolBase.cxx:66
CaloMonToolBase::m_LArCollisionTimeKey
SG::ReadHandleKey< LArCollisionTime > m_LArCollisionTimeKey
Definition: CaloMonToolBase.h:48
CaloMonToolBase::m_useBadLBTool
bool m_useBadLBTool
Definition: CaloMonToolBase.h:37
CaloMonToolBase::~CaloMonToolBase
~CaloMonToolBase()
CaloMonToolBase::m_h_EvtRejSumm
TH1I * m_h_EvtRejSumm
Definition: CaloMonToolBase.h:33