ATLAS Offline Software
Reco_V0Finder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
5 // Reco_V0Finder.cxx, (c) ATLAS Detector software
7 // Author: Adam Barton
11 
12 namespace DerivationFramework {
13 
14  Reco_V0Finder::Reco_V0Finder(const std::string& t,
15  const std::string& n,
16  const IInterface* p) :
17  AthAlgTool(t,n,p),
18  m_v0FinderTool("InDet::V0FinderTool", this)
19  {
20  declareInterface<DerivationFramework::IAugmentationTool>(this);
21 
22  // Declare user-defined properties
23  declareProperty("CheckVertexContainers", m_CollectionsToCheck);
24  declareProperty("V0FinderTool", m_v0FinderTool);
25  }
26 
27  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
28 
30  {
31 
32  ATH_MSG_DEBUG("in initialize()");
33  // get the V0Finder tool
34  ATH_CHECK( m_v0FinderTool.retrieve());
35  ATH_CHECK( m_v0DecoTool.retrieve());
36 
37  ATH_CHECK(m_vertexKey.initialize());
38  ATH_CHECK(m_v0Key.initialize());
39  ATH_CHECK(m_ksKey.initialize());
40  ATH_CHECK(m_laKey.initialize());
41  ATH_CHECK(m_lbKey.initialize());
42 
43  return StatusCode::SUCCESS;
44 
45  }
46 
47 
48  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
49 
51  {
52 
53  bool callV0Finder = false;
54  // Jpsi container and its auxilliary store
55  for(const auto &str : m_CollectionsToCheck){
56  const xAOD::VertexContainer* vertContainer = nullptr;
57  ATH_CHECK( evtStore()->retrieve(vertContainer, str) );
58  if(vertContainer->size() == 0) {
59  ATH_MSG_DEBUG("Container VertexContainer (" << str << ") is empty");
60  }else{
61  callV0Finder = true;
62  ATH_MSG_DEBUG("Container VertexContainer (" << str << ") has events N= " << vertContainer->size());
63  break;//No point checking other containers
64  }
65  }
66 
67  const EventContext& ctx = Gaudi::Hive::currentContext();
68  // InDetV0 container and its auxilliary store
69  //---- Recording section: write the results to StoreGate ---//
71  if ( h_V0.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
72  ATH_MSG_ERROR("Storegate record of v0Container failed.");
73  return StatusCode::FAILURE;
74  }
75 
77  if ( h_Ks.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
78  ATH_MSG_ERROR("Storegate record of ksContainer failed.");
79  return StatusCode::FAILURE;
80  }
81 
83  if( h_La.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
84  ATH_MSG_ERROR("Storegate record of laContainer failed.");
85  return StatusCode::FAILURE;
86 
87  }
89  if(h_Lb.record(std::make_unique<xAOD::VertexContainer>() ,std::make_unique<xAOD::VertexAuxContainer>()).isFailure()){
90  ATH_MSG_ERROR("Storegate record of lbContainer failed.");
91  return StatusCode::FAILURE;
92  }
93 
94  xAOD::VertexContainer* v0Container(h_V0.ptr());
95  xAOD::VertexContainer* ksContainer(h_Ks.ptr());
96  xAOD::VertexContainer* laContainer(h_La.ptr());
97  xAOD::VertexContainer* lbContainer(h_Lb.ptr());
98  // Call V0Finder
99  if (callV0Finder) {
100  const xAOD::Vertex * primaryVertex(0);
101  SG::ReadHandle<xAOD::VertexContainer> importedVxContainer( m_vertexKey, ctx );
102  ATH_CHECK(importedVxContainer.isValid());
103 
104  if (importedVxContainer->size()==0){
105  ATH_MSG_WARNING("You have no primary vertices: " << importedVxContainer->size());
106  } else {
107  primaryVertex = (*importedVxContainer)[0];
108  }
109  ATH_CHECK( m_v0FinderTool->performSearch(h_V0.ptr(),
110  h_Ks.ptr(),
111  h_La.ptr(),
112  h_Lb.ptr(),
113  primaryVertex, importedVxContainer.cptr(), ctx));
114 
115  ATH_MSG_DEBUG("Reco_V0Finder v0Container->size() " << v0Container->size());
116  ATH_MSG_DEBUG("Reco_V0Finder ksContainer->size() " << ksContainer->size());
117  ATH_MSG_DEBUG("Reco_V0Finder laContainer->size() " << laContainer->size());
118  ATH_MSG_DEBUG("Reco_V0Finder lbContainer->size() " << lbContainer->size());
119 
120 
121  ATH_CHECK(m_v0DecoTool->decorateV0(h_V0.ptr(), ctx));
122  ATH_CHECK(m_v0DecoTool->decorateks(h_Ks.ptr() ,ctx));
123  ATH_CHECK(m_v0DecoTool->decoratela(h_La.ptr(), ctx));
124  ATH_CHECK(m_v0DecoTool->decoratelb(h_Lb.ptr(), ctx));
125  }
126 
127  return StatusCode::SUCCESS;
128  }
129 }
130 
131 
132 
133 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::Reco_V0Finder::m_v0FinderTool
ToolHandle< InDet::InDetV0FinderTool > m_v0FinderTool
Definition: Reco_V0Finder.h:33
DerivationFramework::Reco_V0Finder::m_lbKey
SG::WriteHandleKey< xAOD::VertexContainer > m_lbKey
Definition: Reco_V0Finder.h:42
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Reco_V0Finder.h
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
DerivationFramework::Reco_V0Finder::m_CollectionsToCheck
std::vector< std::string > m_CollectionsToCheck
Definition: Reco_V0Finder.h:32
DerivationFramework::Reco_V0Finder::Reco_V0Finder
Reco_V0Finder(const std::string &t, const std::string &n, const IInterface *p)
Definition: Reco_V0Finder.cxx:14
DerivationFramework::Reco_V0Finder::addBranches
virtual StatusCode addBranches() const override
Pass the thinning service
Definition: Reco_V0Finder.cxx:50
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
VertexContainer.h
DerivationFramework::Reco_V0Finder::m_v0DecoTool
ToolHandle< InDet::V0MainDecorator > m_v0DecoTool
Definition: Reco_V0Finder.h:45
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::Reco_V0Finder::m_ksKey
SG::WriteHandleKey< xAOD::VertexContainer > m_ksKey
Definition: Reco_V0Finder.h:39
str
Definition: BTagTrackIpAccessor.cxx:11
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::Reco_V0Finder::m_vertexKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
Definition: Reco_V0Finder.h:35
DerivationFramework::Reco_V0Finder::m_v0Key
SG::WriteHandleKey< xAOD::VertexContainer > m_v0Key
Definition: Reco_V0Finder.h:38
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
VertexAuxContainer.h
DerivationFramework::Reco_V0Finder::initialize
StatusCode initialize() override
Definition: Reco_V0Finder.cxx:29
DerivationFramework::Reco_V0Finder::m_laKey
SG::WriteHandleKey< xAOD::VertexContainer > m_laKey
Definition: Reco_V0Finder.h:40