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
57StatusCode InDetV0Finder::execute(const EventContext& ctx)
58{
59
61// Get primary vertex from StoreGate
62 const xAOD::Vertex* primaryVertex = nullptr;
63 SG::ReadHandle<xAOD::VertexContainer> importedVxContainer( m_vertexKey, ctx );
64 if ( !importedVxContainer.isValid() )
65 {
66 ATH_MSG_WARNING("No xAOD::VertexContainer named " << m_vertexKey.key() << " found in StoreGate");
67 return StatusCode::RECOVERABLE;
68 } else {
69 ATH_MSG_DEBUG("Found xAOD::VertexContainer named " << m_vertexKey.key() );
70 }
71 if ( importedVxContainer->empty() ){
72 ATH_MSG_WARNING("Primary vertex container is empty.");
73 } else {
74 primaryVertex = importedVxContainer->front();
75 }
76
77 //---- Recording section: write the results to StoreGate ---//
79 if ( h_V0.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
80 ATH_MSG_ERROR("Storegate record of v0Container failed.");
81 return StatusCode::FAILURE;
82 }
83
85 if ( h_Ks.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
86 ATH_MSG_ERROR("Storegate record of ksContainer failed.");
87 return StatusCode::FAILURE;
88 }
89
91 if( h_La.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
92 ATH_MSG_ERROR("Storegate record of laContainer failed.");
93 return StatusCode::FAILURE;
94
95 }
97 if(h_Lb.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
98 ATH_MSG_ERROR("Storegate record of lbContainer failed.");
99 return StatusCode::FAILURE;
100 }
101
102
103 const auto statusOfSearch = m_v0FinderTool->performSearch(h_V0.ptr(),
104 h_Ks.ptr(),
105 h_La.ptr(),
106 h_Lb.ptr(),
107 primaryVertex, importedVxContainer.cptr(), ctx);
108
109 if (statusOfSearch != StatusCode::SUCCESS){
110 ATH_MSG_ERROR("Vertex search of v0Container failed.");
111 return StatusCode::FAILURE;
112 }
113
114 if (m_decorate) {
115 ATH_CHECK(m_v0DecoTool->decorateV0(h_V0.ptr(), ctx));
116 ATH_CHECK(m_v0DecoTool->decorateks(h_Ks.ptr() ,ctx));
117 ATH_CHECK(m_v0DecoTool->decoratela(h_La.ptr(), ctx));
118 ATH_CHECK(m_v0DecoTool->decoratelb(h_Lb.ptr(), ctx));
119 }
120
121 m_V0s_stored += h_V0->size();
122 m_Kshort_stored += h_Ks->size();
123 m_Lambda_stored += h_La->size();
124 m_Lambdabar_stored += h_Lb->size();
125
126 return StatusCode::SUCCESS;
127}// end execute block
128
130{
131 msg(MSG::INFO)
132 << "----------------------------------------------------------------------------------------------------------------------------------------------" << endmsg
133 << "\tSummary" << endmsg
134 << "\tProcessed : " << m_events_processed << " events" << endmsg
135 << "\tStored : " << m_V0s_stored << " V0s" << endmsg
136 << "\tof which : " << m_Kshort_stored << " Kshorts" << endmsg
137 << "\t : " << m_Lambda_stored << " Lambdas" << endmsg
138 << "\t : " << m_Lambdabar_stored << " Lambdabars" << endmsg;
139 msg(MSG::INFO) << "----------------------------------------------------------------------------------------------------------------------------------------------" << endmsg;
140
141 return StatusCode::SUCCESS;
142}
143
146 m_V0s_stored = 0;
147 m_Kshort_stored = 0;
149 m_Lambda_stored = 0;
150
151 return StatusCode :: SUCCESS;
152}
153
154
155}//end of namespace InDet
156
#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:
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 execute(const EventContext &ctx)
Execute method.
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.