ATLAS Offline Software
InDetV0Finder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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 
27 namespace InDet
28 {
29 
30 InDetV0Finder::InDetV0Finder(const std::string &n, ISvcLocator *pSvcLoc)
31  :
32  AthAlgorithm(n, pSvcLoc),
33  m_v0FinderTool("InDet::InDetV0FinderTool",this),
34  m_decorate(true),
35  m_events_processed(0),
36  m_V0s_stored(0),
37  m_Kshort_stored(0),
38  m_Lambda_stored(0),
39  m_Lambdabar_stored(0)
40 {
41  declareProperty("InDetV0FinderToolName" , m_v0FinderTool);
42  declareProperty("decorateV0", m_decorate);
43 }
44 
46 
48 {
50 
51  ATH_CHECK( m_vertexKey.initialize() );
52  ATH_CHECK( m_v0Key.initialize() );
53  ATH_CHECK( m_ksKey.initialize() );
54  ATH_CHECK( m_laKey.initialize() );
55  ATH_CHECK( m_lbKey.initialize() );
56 
57 // uploading the V0Finding tools
58  ATH_CHECK( m_v0FinderTool.retrieve() );
59  ATH_MSG_DEBUG("Retrieved tool " << m_v0FinderTool);
60  ATH_CHECK(m_v0DecoTool.retrieve(DisableTool{!m_decorate}));
61 
62  ATH_MSG_DEBUG("Initialization successful");
63 
64  return StatusCode::SUCCESS;
65 }
66 
67 
69 {
70 
72  const EventContext& ctx = Gaudi::Hive::currentContext();
73 // Get primary vertex from StoreGate
74  const xAOD::Vertex* primaryVertex = nullptr;
75  SG::ReadHandle<xAOD::VertexContainer> importedVxContainer( m_vertexKey, ctx );
76  if ( !importedVxContainer.isValid() )
77  {
78  ATH_MSG_WARNING("No xAOD::VertexContainer named " << m_vertexKey.key() << " found in StoreGate");
79  return StatusCode::RECOVERABLE;
80  } else {
81  ATH_MSG_DEBUG("Found xAOD::VertexContainer named " << m_vertexKey.key() );
82  }
83  if ( importedVxContainer->empty() ){
84  ATH_MSG_WARNING("Primary vertex container is empty.");
85  } else {
86  primaryVertex = importedVxContainer->front();
87  }
88 
89  //---- Recording section: write the results to StoreGate ---//
91  if ( h_V0.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
92  ATH_MSG_ERROR("Storegate record of v0Container failed.");
93  return StatusCode::FAILURE;
94  }
95 
97  if ( h_Ks.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
98  ATH_MSG_ERROR("Storegate record of ksContainer failed.");
99  return StatusCode::FAILURE;
100  }
101 
103  if( h_La.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
104  ATH_MSG_ERROR("Storegate record of laContainer failed.");
105  return StatusCode::FAILURE;
106 
107  }
109  if(h_Lb.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
110  ATH_MSG_ERROR("Storegate record of lbContainer failed.");
111  return StatusCode::FAILURE;
112  }
113 
114 
115  const auto statusOfSearch = m_v0FinderTool->performSearch(h_V0.ptr(),
116  h_Ks.ptr(),
117  h_La.ptr(),
118  h_Lb.ptr(),
119  primaryVertex, importedVxContainer.cptr(), ctx);
120 
121  if (statusOfSearch != StatusCode::SUCCESS){
122  ATH_MSG_ERROR("Vertex search of v0Container failed.");
123  return StatusCode::FAILURE;
124  }
125 
126  if (m_decorate) {
127  ATH_CHECK(m_v0DecoTool->decorateV0(h_V0.ptr(), ctx));
128  ATH_CHECK(m_v0DecoTool->decorateks(h_Ks.ptr() ,ctx));
129  ATH_CHECK(m_v0DecoTool->decoratela(h_La.ptr(), ctx));
130  ATH_CHECK(m_v0DecoTool->decoratelb(h_Lb.ptr(), ctx));
131  }
132 
133  m_V0s_stored += h_V0->size();
134  m_Kshort_stored += h_Ks->size();
135  m_Lambda_stored += h_La->size();
136  m_Lambdabar_stored += h_Lb->size();
137 
138  return StatusCode::SUCCESS;
139 }// end execute block
140 
142 {
143  msg(MSG::INFO)
144  << "----------------------------------------------------------------------------------------------------------------------------------------------" << endmsg
145  << "\tSummary" << endmsg
146  << "\tProcessed : " << m_events_processed << " events" << endmsg
147  << "\tStored : " << m_V0s_stored << " V0s" << endmsg
148  << "\tof which : " << m_Kshort_stored << " Kshorts" << endmsg
149  << "\t : " << m_Lambda_stored << " Lambdas" << endmsg
150  << "\t : " << m_Lambdabar_stored << " Lambdabars" << endmsg;
151  msg(MSG::INFO) << "----------------------------------------------------------------------------------------------------------------------------------------------" << endmsg;
152 
153  return StatusCode::SUCCESS;
154 }
155 
157  m_events_processed = 0;
158  m_V0s_stored = 0;
159  m_Kshort_stored = 0;
160  m_Lambdabar_stored = 0;
161  m_Lambda_stored = 0;
162 
163  return StatusCode :: SUCCESS;
164 }
165 
166 
167 }//end of namespace InDet
168 
InDet::InDetV0Finder::resetStatistics
StatusCode resetStatistics()
Definition: InDetV0Finder.cxx:166
InDet::InDetV0Finder::m_lbKey
SG::WriteHandleKey< xAOD::VertexContainer > m_lbKey
Definition: InDetV0Finder.h:58
InDet::InDetV0Finder::m_Kshort_stored
long m_Kshort_stored
Definition: InDetV0Finder.h:73
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
InDet::InDetV0Finder::m_v0Key
SG::WriteHandleKey< xAOD::VertexContainer > m_v0Key
Definition: InDetV0Finder.h:54
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::InDetV0Finder::m_ksKey
SG::WriteHandleKey< xAOD::VertexContainer > m_ksKey
Definition: InDetV0Finder.h:55
InDet::InDetV0Finder::m_v0FinderTool
ToolHandle< InDet::InDetV0FinderTool > m_v0FinderTool
Definition: InDetV0Finder.h:63
InDet::InDetV0Finder::m_decorate
bool m_decorate
decorate V0 containers
Definition: InDetV0Finder.h:68
InDet::InDetV0Finder::InDetV0Finder
InDetV0Finder(const std::string &name, ISvcLocator *pSvcLocator)
Definition: InDetV0Finder.cxx:40
InDet::InDetV0Finder::m_laKey
SG::WriteHandleKey< xAOD::VertexContainer > m_laKey
Definition: InDetV0Finder.h:56
InDetV0Finder.h
InDet::InDetV0Finder::m_Lambda_stored
long m_Lambda_stored
Definition: InDetV0Finder.h:74
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::InDetV0Finder::m_vertexKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
Definition: InDetV0Finder.h:51
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
InDet::InDetV0Finder::execute
StatusCode execute()
Definition: InDetV0Finder.cxx:78
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDetV0FinderTool.h
AthAlgorithm
Definition: AthAlgorithm.h:47
InDet::InDetV0Finder::initialize
StatusCode initialize()
Definition: InDetV0Finder.cxx:57
InDet::InDetV0Finder::m_v0DecoTool
ToolHandle< InDet::V0MainDecorator > m_v0DecoTool
Definition: InDetV0Finder.h:64
InDet::InDetV0Finder::m_Lambdabar_stored
long m_Lambdabar_stored
Definition: InDetV0Finder.h:75
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
VertexContainer.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
InDet::InDetV0Finder::m_events_processed
long m_events_processed
Definition: InDetV0Finder.h:71
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
InDet::InDetV0Finder::finalize
StatusCode finalize()
Definition: InDetV0Finder.cxx:151
InDet::InDetV0Finder::m_V0s_stored
long m_V0s_stored
Definition: InDetV0Finder.h:72
InDet::InDetV0Finder::~InDetV0Finder
virtual ~InDetV0Finder()
VertexAuxContainer.h