ATLAS Offline Software
CosmicEventFilterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // CosmicEventFilterTool.cxx, (c) ATLAS Detector software
8 
9 // class include
10 #include "CosmicEventFilterTool.h"
11 
12 //Athena includes
14 #include "StoreGate/ReadHandle.h"
15 
16 // stl includes
17 #include <vector>
18 #include <string>
19 
22  const std::string& n,
23  const IInterface* p )
24  : base_class(t,n,p)
25  , m_ntot(0)
26  , m_npass(0)
27  , m_VolumeNames{""}
28  , m_useANDFilter(true)
29  , m_magicID(0)
30  , m_ptMin(-1)
31  , m_ptMax(-1)
32 {
33  declareProperty("UseAndFilter", m_useANDFilter, "Use an AND Filter over all the Volumes, if false use an OR filter");
34  declareProperty("VolumeNames", m_VolumeNames, "List of Volumes to use for filtering");
35  declareProperty("PDG_ID", m_magicID, "If this is non-zero then more detailed checks will be made, requiring this particle to be present.");
36  declareProperty("ptMin", m_ptMin, "Minimum pT for detailed cuts.");
37  declareProperty("ptMax", m_ptMax, "Minimum pT for detailed cuts.");
38 }
39 
42 }
43 
44 
47 {
48  ATH_MSG_VERBOSE("initialize() ...");
49  ATH_CHECK(m_VolumeNames.initialize());
50  ATH_MSG_VERBOSE("initialize() successful");
51  return StatusCode::SUCCESS;
52 }
53 
54 
57 {
58  ATH_MSG_VERBOSE("finalize() ...");
59  ATH_MSG_INFO("Processed "<< m_ntot <<" events, "<< m_npass<<" events passed filter ");
60  ATH_MSG_VERBOSE("finalize() successful");
61  return StatusCode::SUCCESS;
62 }
63 
64 
67 {
68 
69  ++m_ntot;
70  if (m_VolumeNames.empty()) { ++m_npass; return true;}
71  bool evtPassesFilter(m_useANDFilter);
72  auto trackRecordCollectionHandles = m_VolumeNames.makeHandles();
73  for(auto& coll : trackRecordCollectionHandles) {
74  if (!coll.isValid())
75  {
76  ATH_MSG_DEBUG("Cannot retrieve TrackRecordCollection " << coll.key());
77  return false;
78  }
79  unsigned int counter(0);
80  if (m_magicID!=0 || m_ptMin>0 || m_ptMax>0)
81  {
82  const unsigned int ntracks(coll->size());
83  for (unsigned int track=0;track<ntracks;++track)
84  {
85  if (m_magicID!=0 && m_magicID != std::fabs(coll->operator[](track).GetPDGCode())) { continue; }
86  if (m_ptMin>0 && m_ptMin > coll->operator[](track).GetMomentum().perp() ) { continue; }
87  if (m_ptMax>0 && m_ptMax < coll->operator[](track).GetMomentum().perp() ) { continue; }
88  ++counter;
89  }// end of loop over tracks
90  }
91  else
92  {
93  counter = coll->size();
94  }
95 
96  if(m_useANDFilter)
97  { //AND Filter
98  if(0==counter)
99  { //One Failure is too many
100  return false;
101  }
102  }
103  else
104  { //OR Filter
105  if(0!=counter)
106  { //One Success is enough
107  ++m_npass;
108  return true;
109  }
110  }
111  }// end of loop over volumes
112 
113  if (evtPassesFilter)
114  {
115  ++m_npass;
116  }
117  return evtPassesFilter;
118 }
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
perp
Scalar perp() const
perp method - perpenticular length
Definition: AmgMatrixBasePlugin.h:35
ISF::CosmicEventFilterTool::eventPassesFilter
virtual bool eventPassesFilter() const override final
Check that the current event passes this filter.
Definition: CosmicEventFilterTool.cxx:66
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ISF::CosmicEventFilterTool::finalize
virtual StatusCode finalize() override final
Athena algtool Hook.
Definition: CosmicEventFilterTool.cxx:56
CosmicEventFilterTool.h
beamspotman.n
n
Definition: beamspotman.py:731
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
ISF::CosmicEventFilterTool::CosmicEventFilterTool
CosmicEventFilterTool(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: CosmicEventFilterTool.cxx:21
TrackRecordCollection.h
ISF::CosmicEventFilterTool::initialize
virtual StatusCode initialize() override final
Athena algtool Hooks.
Definition: CosmicEventFilterTool.cxx:46
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
ReadHandle.h
Handle class for reading from StoreGate.
test_pyathena.counter
counter
Definition: test_pyathena.py:15
ISF::CosmicEventFilterTool::~CosmicEventFilterTool
~CosmicEventFilterTool()
Destructor.
Definition: CosmicEventFilterTool.cxx:41