ATLAS Offline Software
BCIDFilterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // BCIDFilterTool.cxx, (c) ATLAS Detector software
8 
10 
12 
13 #include <string>
14 
15 // Constructor
16 BCIDFilterTool::BCIDFilterTool( const std::string& t,
17  const std::string& n,
18  const IInterface* p ) :
19  AthAlgTool(t,n,p)
20  {
21  declareInterface<DerivationFramework::ISkimmingTool>(this);
22  declareProperty("AcceptBCIDs", m_acceptBCIDs);
23  declareProperty("RejectBCIDs", m_rejectBCIDs);
24  }
25 
26 // Destructor
28 
29 // Athena initialize and finalize
31 {
32  if (m_acceptBCIDs.size() && m_rejectBCIDs.size()) {
33  ATH_MSG_ERROR("Failed to initialize - both accept and reject BCIDs specified, please only use one");
34  return StatusCode::FAILURE;
35  }
36  if (!(m_acceptBCIDs.size() || m_rejectBCIDs.size())) {
37  ATH_MSG_ERROR("Neither AcceptBCIDs nor RejectBCIDs specified, can't use filter!");
38  }
39  if (m_acceptBCIDs.size()) {
40  ATH_MSG_INFO("Events with the following " << m_acceptBCIDs.size() << " BCIDs will be accepted into the stream");
41  for (int bcid : m_acceptBCIDs) ATH_MSG_INFO(" " << bcid);
42  }
43  if (m_rejectBCIDs.size()) {
44  ATH_MSG_INFO("Events with the following " << m_rejectBCIDs.size() << " BCIDs will be rejected from the stream");
45  for (int bcid : m_rejectBCIDs) ATH_MSG_INFO(" " << bcid);
46  }
47 
48  return StatusCode::SUCCESS;
49 }
51 {
52  ATH_MSG_INFO("Processed "<< m_ntot <<" events, "<< m_npass<<" events passed filter ");
53  return StatusCode::SUCCESS;
54 }
55 
56 // The filter itself
58 {
59  ++m_ntot;
60 
61  const xAOD::EventInfo* ei(0);
62  ATH_CHECK( evtStore()->retrieve(ei, "EventInfo"), false );
63 
64  int bcid = ei->bcid();
65 
66  if (m_acceptBCIDs.size()) {
67  for (auto acceptBCID : m_acceptBCIDs) {
68  if (bcid == acceptBCID) {
69  ++m_npass;
70  return true;
71  }
72  }
73  return false;
74  }
75 
76  else {
77  for (auto rejectBCID : m_rejectBCIDs) {
78  if (bcid == rejectBCID) return false;
79  }
80  ++m_npass;
81  return true;
82  }
83 }
84 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
BCIDFilterTool.h
BCIDFilterTool::finalize
virtual StatusCode finalize() override
Definition: BCIDFilterTool.cxx:50
BCIDFilterTool::initialize
virtual StatusCode initialize() override
Definition: BCIDFilterTool.cxx:30
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
BCIDFilterTool::m_ntot
std::atomic< unsigned int > m_ntot
Definition: BCIDFilterTool.h:42
BCIDFilterTool::BCIDFilterTool
BCIDFilterTool(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: BCIDFilterTool.cxx:16
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
BCIDFilterTool::m_npass
std::atomic< unsigned int > m_npass
Definition: BCIDFilterTool.h:43
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
BCIDFilterTool::~BCIDFilterTool
~BCIDFilterTool()
Destructor.
Definition: BCIDFilterTool.cxx:27
BCIDFilterTool::eventPassesFilter
virtual bool eventPassesFilter() const override
Check that the current event passes this filter.
Definition: BCIDFilterTool.cxx:57
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
BCIDFilterTool::m_acceptBCIDs
std::vector< int > m_acceptBCIDs
Definition: BCIDFilterTool.h:45
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
AthAlgTool
Definition: AthAlgTool.h:26
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
BCIDFilterTool::m_rejectBCIDs
std::vector< int > m_rejectBCIDs
Definition: BCIDFilterTool.h:46