ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecAlgs
InDetV0Finder
src
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
19
#include "
xAODTracking/VertexContainer.h
"
20
#include "
xAODTracking/VertexAuxContainer.h
"
21
#include "
InDetV0Finder/InDetV0FinderTool.h
"
22
#include "
StoreGate/WriteDecorHandle.h
"
23
#include <vector>
24
#include <string>
25
26
27
namespace
InDet
28
{
29
30
InDetV0Finder::InDetV0Finder
(
const
std::string &n, ISvcLocator *pSvcLoc)
31
:
32
AthAlgorithm
(n, pSvcLoc) {}
33
34
InDetV0Finder::~InDetV0Finder
() =
default
;
35
36
StatusCode
InDetV0Finder::initialize
()
37
{
38
ATH_CHECK
(
resetStatistics
() );
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
57
StatusCode
InDetV0Finder::execute
(
const
EventContext& ctx)
58
{
59
60
m_events_processed
++;
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 ---//
78
SG::WriteHandle<xAOD::VertexContainer>
h_V0(
m_v0Key
, ctx );
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
84
SG::WriteHandle<xAOD::VertexContainer>
h_Ks(
m_ksKey
, ctx );
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
90
SG::WriteHandle<xAOD::VertexContainer>
h_La(
m_laKey
, ctx );
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
}
96
SG::WriteHandle<xAOD::VertexContainer>
h_Lb(
m_lbKey
, ctx );
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
129
StatusCode
InDetV0Finder::finalize
()
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
144
StatusCode
InDetV0Finder::resetStatistics
() {
145
m_events_processed
= 0;
146
m_V0s_stored
= 0;
147
m_Kshort_stored
= 0;
148
m_Lambdabar_stored
= 0;
149
m_Lambda_stored
= 0;
150
151
return
StatusCode :: SUCCESS;
152
}
153
154
155
}
//end of namespace InDet
156
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
InDetV0FinderTool.h
InDetV0Finder.h
WriteDecorHandle.h
Handle class for adding a decoration to an object.
VertexAuxContainer.h
VertexContainer.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
InDet::InDetV0Finder::m_lbKey
SG::WriteHandleKey< xAOD::VertexContainer > m_lbKey
Definition
InDetV0Finder.h:58
InDet::InDetV0Finder::m_v0FinderTool
ToolHandle< InDet::InDetV0FinderTool > m_v0FinderTool
Definition
InDetV0Finder.h:63
InDet::InDetV0Finder::m_decorate
BooleanProperty m_decorate
decorate V0 containers
Definition
InDetV0Finder.h:68
InDet::InDetV0Finder::m_laKey
SG::WriteHandleKey< xAOD::VertexContainer > m_laKey
Definition
InDetV0Finder.h:56
InDet::InDetV0Finder::m_Lambdabar_stored
long m_Lambdabar_stored
Definition
InDetV0Finder.h:74
InDet::InDetV0Finder::InDetV0Finder
InDetV0Finder(const std::string &name, ISvcLocator *pSvcLocator)
Definition
InDetV0Finder.cxx:30
InDet::InDetV0Finder::finalize
StatusCode finalize()
Definition
InDetV0Finder.cxx:129
InDet::InDetV0Finder::m_v0Key
SG::WriteHandleKey< xAOD::VertexContainer > m_v0Key
Definition
InDetV0Finder.h:54
InDet::InDetV0Finder::initialize
StatusCode initialize()
Definition
InDetV0Finder.cxx:36
InDet::InDetV0Finder::m_Lambda_stored
long m_Lambda_stored
Definition
InDetV0Finder.h:73
InDet::InDetV0Finder::m_V0s_stored
long m_V0s_stored
Definition
InDetV0Finder.h:71
InDet::InDetV0Finder::m_Kshort_stored
long m_Kshort_stored
Definition
InDetV0Finder.h:72
InDet::InDetV0Finder::m_ksKey
SG::WriteHandleKey< xAOD::VertexContainer > m_ksKey
Definition
InDetV0Finder.h:55
InDet::InDetV0Finder::m_vertexKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
Definition
InDetV0Finder.h:51
InDet::InDetV0Finder::m_events_processed
long m_events_processed
Definition
InDetV0Finder.h:70
InDet::InDetV0Finder::m_v0DecoTool
ToolHandle< InDet::V0MainDecorator > m_v0DecoTool
Definition
InDetV0Finder.h:64
InDet::InDetV0Finder::~InDetV0Finder
virtual ~InDetV0Finder()
InDet::InDetV0Finder::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
InDetV0Finder.cxx:57
InDet::InDetV0Finder::resetStatistics
StatusCode resetStatistics()
Definition
InDetV0Finder.cxx:144
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Generated on
for ATLAS Offline Software by
1.17.0