ATLAS Offline Software
McAodFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // McAodFilter.cxx
7 // Implementation file for class McAodFilter
8 // Author: S.Binet<binet@cern.ch>
10 
11 
12 // STL includes
13 #include <algorithm>
14 
15 // FrameWork includes
16 #include "Gaudi/Property.h"
17 
18 // McParticleUtils includes
20 
21 // McParticleKernel includes
24 
25 // McParticleAlgs includes
26 #include "McAodFilter.h"
27 
31 
34 McAodFilter::McAodFilter( const std::string& name,
35  ISvcLocator* pSvcLocator ) :
36  AthAlgorithm( name, pSvcLocator )
37 {
38  //
39  // Property declaration
40  //
41 
42  declareProperty( "DoGenAod",
43  m_doGenAod = false,
44  "Switch to build or not the filtered GenEvent" );
45 
46  std::string descr = "";
47  descr += "Switch to build or not the TruthParticleContainer ";
48  descr += "from the filtered GenEvent";
49  declareProperty( "DoTruthParticles",
50  m_doTruthParticles = false,
51  descr );
52 
53  descr = "Tool to filter an McEventCollection according to some DecayPattern";
54  declareProperty( "McVtxFilterTool",
55  m_mcVtxFilterTool = IMcVtxFilterTool_t( "McVtxFilterTool",
56  this ),
57  descr );
58 
59  descr = "Tool to convert a GenEvent into a TruthParticleContainer";
60  declareProperty( "TruthParticleCnvTool",
61  m_truthParticleCnvTool = CnvTool_t( "TruthParticleCnvTool",
62  this ),
63  descr );
64 }
65 
69 {}
70 
74 {
75  ATH_MSG_INFO ("Initializing " << name() << "...");
76 
78  if ( !m_mcVtxFilterTool.retrieve().isSuccess() ) {
79  ATH_MSG_ERROR ("Creation of algTool McVtxFilterTool FAILED !");
80  return StatusCode::FAILURE;
81  }
82 
84  if ( !m_truthParticleCnvTool.retrieve().isSuccess() ) {
85  ATH_MSG_ERROR ("Creation of algTool TruthParticleCnvTool FAILED !");
86  return StatusCode::FAILURE;
87  }
88 
89  return StatusCode::SUCCESS;
90 }
91 
93 {
94  ATH_MSG_INFO ("Finalizing " << name() << "...");
95  m_mcVtxFilterTool->stats();
96  return StatusCode::SUCCESS;
97 }
98 
100 {
101  StatusCode sc = StatusCode::SUCCESS;
102 
103  ATH_MSG_DEBUG ("Executing " << name() << "...");
104 
105  if ( m_doGenAod ) {
106  sc = m_mcVtxFilterTool->execute();
107  if ( !sc.isSuccess() ) {
108  ATH_MSG_WARNING ("Problem filtering the McEventCollection !!");
109  }
110  }
111 
113  if ( m_doTruthParticles ) {
114  if ( sc.isSuccess() ) {
115  sc = m_truthParticleCnvTool->execute();
116  if ( !sc.isSuccess() ) {
118  ("Could not convert McEventCollection ==> TruthParticles !!");
119  }
120  } else {
122  ("Could not convert McEventCollection ==> TruthParticles because"\
123  " McEventCollection filtering failed");
124  }
125  }
126 
127  return StatusCode::SUCCESS;
128 }
McAodFilter::CnvTool_t
ToolHandle< ITruthParticleCnvTool > CnvTool_t
Definition: McAodFilter.h:93
ITruthParticleCnvTool.h
McAodFilter::McAodFilter
McAodFilter()
Default constructor:
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
McAodFilter::m_mcVtxFilterTool
IMcVtxFilterTool_t m_mcVtxFilterTool
Tool to filter an McEventCollection according to some DecayPattern.
Definition: McAodFilter.h:86
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
McAodFilter::initialize
virtual StatusCode initialize()
Athena Algorithm's Hooks.
Definition: McAodFilter.cxx:73
McAodFilter::m_doTruthParticles
BooleanProperty m_doTruthParticles
Switch to build or not the TruthParticleContainer from the filtered GenEvent.
Definition: McAodFilter.h:91
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
McAodFilter::finalize
virtual StatusCode finalize()
Definition: McAodFilter.cxx:92
McAodFilter::m_truthParticleCnvTool
CnvTool_t m_truthParticleCnvTool
Tool to convert a GenEvent into a TruthParticleContainer.
Definition: McAodFilter.h:96
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
McAodFilter::~McAodFilter
virtual ~McAodFilter()
Destructor.
Definition: McAodFilter.cxx:68
python.TransformConfig.descr
descr
print "%s.properties()" % self.__name__
Definition: TransformConfig.py:360
AthAlgorithm
Definition: AthAlgorithm.h:47
McVtxFilter.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
McAodFilter::IMcVtxFilterTool_t
ToolHandle< IMcVtxFilterTool > IMcVtxFilterTool_t
Definition: McAodFilter.h:83
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
McAodFilter.h
McAodFilter::m_doGenAod
BooleanProperty m_doGenAod
Switch to build or not the filtered GenEvent.
Definition: McAodFilter.h:81
IMcVtxFilterTool.h
McAodFilter::execute
virtual StatusCode execute()
Definition: McAodFilter.cxx:99