ATLAS Offline Software
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 
27 namespace InDet
28 {
29 
30 InDetV0Finder::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 
146  m_events_processed = 0;
147  m_V0s_stored = 0;
148  m_Kshort_stored = 0;
149  m_Lambdabar_stored = 0;
150  m_Lambda_stored = 0;
151 
152  return StatusCode :: SUCCESS;
153 }
154 
155 
156 }//end of namespace InDet
157 
InDet::InDetV0Finder::resetStatistics
StatusCode resetStatistics()
Definition: InDetV0Finder.cxx:155
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:72
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
InDet::InDetV0Finder::m_v0Key
SG::WriteHandleKey< xAOD::VertexContainer > m_v0Key
Definition: InDetV0Finder.h:54
InDet
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::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:73
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:67
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:46
InDet::InDetV0Finder::m_decorate
BooleanProperty m_decorate
decorate V0 containers
Definition: InDetV0Finder.h:68
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:74
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:70
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
InDet::InDetV0Finder::finalize
StatusCode finalize()
Definition: InDetV0Finder.cxx:140
InDet::InDetV0Finder::m_V0s_stored
long m_V0s_stored
Definition: InDetV0Finder.h:71
InDet::InDetV0Finder::~InDetV0Finder
virtual ~InDetV0Finder()
VertexAuxContainer.h