ATLAS Offline Software
Loading...
Searching...
No Matches
InDetV0Finder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5/***************************************************************************
6 InDetV0Finder.cxx - Description
7 -------------------
8 begin : 20-07-2005
9 authors : Evelina Bouhova-Thacker (Lancaster University), Rob Henderson (Lancater University)
10 email : e.bouhova@cern.ch, r.henderson@lancaster.ac.uk
11 changes : December 2014
12 author : Evelina Bouhova-Thacker <e.bouhova@cern.ch>
13 Changed to use xAOD
14
15 ***************************************************************************/
16
17#include "InDetV0Finder.h"
18
23#include <vector>
24#include <string>
25
26
27namespace InDet
28{
29
30InDetV0Finder::InDetV0Finder(const std::string &n, ISvcLocator *pSvcLoc)
31 :
32 AthAlgorithm(n, pSvcLoc) {}
33
35
37{
39
40 ATH_CHECK( m_vertexKey.initialize() );
41 ATH_CHECK( m_v0Key.initialize() );
42 ATH_CHECK( m_ksKey.initialize() );
43 ATH_CHECK( m_laKey.initialize() );
44 ATH_CHECK( m_lbKey.initialize() );
45
46// uploading the V0Finding tools
47 ATH_CHECK( m_v0FinderTool.retrieve() );
48 ATH_MSG_DEBUG("Retrieved tool " << m_v0FinderTool);
49 ATH_CHECK(m_v0DecoTool.retrieve(DisableTool{!m_decorate}));
50
51 ATH_MSG_DEBUG("Initialization successful");
52
53 return StatusCode::SUCCESS;
54}
55
56
58{
59
61 const EventContext& ctx = Gaudi::Hive::currentContext();
62// Get primary vertex from StoreGate
63 const xAOD::Vertex* primaryVertex = nullptr;
64 SG::ReadHandle<xAOD::VertexContainer> importedVxContainer( m_vertexKey, ctx );
65 if ( !importedVxContainer.isValid() )
66 {
67 ATH_MSG_WARNING("No xAOD::VertexContainer named " << m_vertexKey.key() << " found in StoreGate");
68 return StatusCode::RECOVERABLE;
69 } else {
70 ATH_MSG_DEBUG("Found xAOD::VertexContainer named " << m_vertexKey.key() );
71 }
72 if ( importedVxContainer->empty() ){
73 ATH_MSG_WARNING("Primary vertex container is empty.");
74 } else {
75 primaryVertex = importedVxContainer->front();
76 }
77
78 //---- Recording section: write the results to StoreGate ---//
80 if ( h_V0.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
81 ATH_MSG_ERROR("Storegate record of v0Container failed.");
82 return StatusCode::FAILURE;
83 }
84
86 if ( h_Ks.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
87 ATH_MSG_ERROR("Storegate record of ksContainer failed.");
88 return StatusCode::FAILURE;
89 }
90
92 if( h_La.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
93 ATH_MSG_ERROR("Storegate record of laContainer failed.");
94 return StatusCode::FAILURE;
95
96 }
98 if(h_Lb.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
99 ATH_MSG_ERROR("Storegate record of lbContainer failed.");
100 return StatusCode::FAILURE;
101 }
102
103
104 const auto statusOfSearch = m_v0FinderTool->performSearch(h_V0.ptr(),
105 h_Ks.ptr(),
106 h_La.ptr(),
107 h_Lb.ptr(),
108 primaryVertex, importedVxContainer.cptr(), ctx);
109
110 if (statusOfSearch != StatusCode::SUCCESS){
111 ATH_MSG_ERROR("Vertex search of v0Container failed.");
112 return StatusCode::FAILURE;
113 }
114
115 if (m_decorate) {
116 ATH_CHECK(m_v0DecoTool->decorateV0(h_V0.ptr(), ctx));
117 ATH_CHECK(m_v0DecoTool->decorateks(h_Ks.ptr() ,ctx));
118 ATH_CHECK(m_v0DecoTool->decoratela(h_La.ptr(), ctx));
119 ATH_CHECK(m_v0DecoTool->decoratelb(h_Lb.ptr(), ctx));
120 }
121
122 m_V0s_stored += h_V0->size();
123 m_Kshort_stored += h_Ks->size();
124 m_Lambda_stored += h_La->size();
125 m_Lambdabar_stored += h_Lb->size();
126
127 return StatusCode::SUCCESS;
128}// end execute block
129
131{
132 msg(MSG::INFO)
133 << "----------------------------------------------------------------------------------------------------------------------------------------------" << endmsg
134 << "\tSummary" << endmsg
135 << "\tProcessed : " << m_events_processed << " events" << endmsg
136 << "\tStored : " << m_V0s_stored << " V0s" << endmsg
137 << "\tof which : " << m_Kshort_stored << " Kshorts" << endmsg
138 << "\t : " << m_Lambda_stored << " Lambdas" << endmsg
139 << "\t : " << m_Lambdabar_stored << " Lambdabars" << endmsg;
140 msg(MSG::INFO) << "----------------------------------------------------------------------------------------------------------------------------------------------" << endmsg;
141
142 return StatusCode::SUCCESS;
143}
144
147 m_V0s_stored = 0;
148 m_Kshort_stored = 0;
150 m_Lambda_stored = 0;
151
152 return StatusCode :: SUCCESS;
153}
154
155
156}//end of namespace InDet
157
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for adding a decoration to an object.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
MsgStream & msg() const
SG::WriteHandleKey< xAOD::VertexContainer > m_lbKey
ToolHandle< InDet::InDetV0FinderTool > m_v0FinderTool
BooleanProperty m_decorate
decorate V0 containers
SG::WriteHandleKey< xAOD::VertexContainer > m_laKey
InDetV0Finder(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< xAOD::VertexContainer > m_v0Key
SG::WriteHandleKey< xAOD::VertexContainer > m_ksKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
ToolHandle< InDet::V0MainDecorator > m_v0DecoTool
virtual ~InDetV0Finder()
StatusCode resetStatistics()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
Primary Vertex Finder.
Vertex_v1 Vertex
Define the latest version of the vertex class.