ATLAS Offline Software
SkimmingToolExample.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // SkimmingToolExample.cxx, (c) ATLAS Detector software
8 // Author: James Catmore (James.Catmore@cern.ch)
9 // Based on the Integrated Simulation Framework
10 // This is a trivial example of an implementation of a skimming tool
11 // which only passes events with N combined muons passing a pt cut of M
12 
14 #include <vector>
15 #include <string>
16 
17 // Constructor
19  const std::string& n,
20  const IInterface* p ) :
21  AthAlgTool(t,n,p),
22  m_ntot(0),
23  m_npass(0),
24  m_muonSGKey("Muons"),
25  m_nMuons(2),
26  m_muonPtCut(10000.0)
27  {
28  declareInterface<DerivationFramework::ISkimmingTool>(this);
29  declareProperty("MuonContainerKey", m_muonSGKey);
30  declareProperty("NumberOfMuons", m_nMuons);
31  declareProperty("MuonPtCut", m_muonPtCut);
32  }
33 
34 // Destructor
36 }
37 
38 // Athena initialize and finalize
40 {
41  ATH_MSG_VERBOSE("initialize() ...");
42  return StatusCode::SUCCESS;
43 }
45 {
46  ATH_MSG_VERBOSE("finalize() ...");
47  ATH_MSG_INFO("Processed "<< m_ntot <<" events, "<< m_npass<<" events passed filter ");
48  return StatusCode::SUCCESS;
49 }
50 
51 // The filter itself
53 {
54  ++m_ntot;
55 
56  // Retrieve muon container
57  const xAOD::MuonContainer* muons(0);
58  StatusCode sc = evtStore()->retrieve(muons,m_muonSGKey);
59  if (sc.isFailure()) {
60  ATH_MSG_FATAL("No muon collection with name " << m_muonSGKey << " found in StoreGate!");
61  return false;
62  }
63 
64  // Loop over muons, count up and set decision
66  unsigned int nGoodMu(0);
67  for (muItr=muons->begin(); muItr!=muons->end(); ++muItr) {
68  if ( (*muItr)->muonType() == xAOD::Muon::Combined && (*muItr)->pt() > m_muonPtCut ) ++nGoodMu;
69  }
70  bool acceptEvent(false);
71  if (nGoodMu >= m_nMuons) {
72  acceptEvent = true;
73  ++m_npass;
74  }
75  return acceptEvent;
76 
77 }
78 
DerivationFramework::SkimmingToolExample::initialize
virtual StatusCode initialize() override
Definition: SkimmingToolExample.cxx:39
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::SkimmingToolExample::finalize
virtual StatusCode finalize() override
Definition: SkimmingToolExample.cxx:44
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
SkimmingToolExample.h
DerivationFramework::SkimmingToolExample::m_muonPtCut
double m_muonPtCut
Definition: SkimmingToolExample.h:51
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::SkimmingToolExample::SkimmingToolExample
SkimmingToolExample(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: SkimmingToolExample.cxx:18
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
DerivationFramework::SkimmingToolExample::~SkimmingToolExample
~SkimmingToolExample()
Destructor.
Definition: SkimmingToolExample.cxx:35
DerivationFramework::SkimmingToolExample::eventPassesFilter
virtual bool eventPassesFilter() const override
Check that the current event passes this filter.
Definition: SkimmingToolExample.cxx:52
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Trk::Combined
@ Combined
Definition: TrackSummaryTool.h:32
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DerivationFramework::SkimmingToolExample::m_nMuons
unsigned int m_nMuons
Definition: SkimmingToolExample.h:50
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::SkimmingToolExample::m_muonSGKey
std::string m_muonSGKey
Definition: SkimmingToolExample.h:49
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.