ATLAS Offline Software
CaloExtensionBuilderAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 NAME: CaloExtensionBuilderAlg
7 PACKAGE: offline/Reconstruction/RecoTools/TrackToCalo/CaloExtensionBuilderAlg
8 
9 AUTHORS: Anastopoulos/Capriles
10 PURPOSE: Performs Calo Extension for all selected tracks
11  **********************************************************************/
13 //
14 #include "GaudiKernel/ThreadLocalContext.h"
15 #include "StoreGate/ReadHandle.h"
16 #include "StoreGate/WriteHandle.h"
17 #include "VxVertex/RecVertex.h"
18 #include "VxVertex/VxCandidate.h"
22 #include "xAODTracking/Vertex.h"
24 
25 // std includes
26 #include <algorithm>
27 #include <cmath>
28 #include <memory>
29 
32 {
34  ATH_CHECK(m_ParticleCacheKey.initialize());
36  return StatusCode::SUCCESS;
37 }
38 
40 Trk::CaloExtensionBuilderAlg::execute(const EventContext& ctx) const
41 {
42  /*
43  * We want to extrapolate everything bar the the TRT-alone
44  */
45  SG::ReadHandle<xAOD::TrackParticleContainer> tracks(m_TrkPartContainerKey,
46  ctx);
47  if (!tracks.isValid()) {
48  ATH_MSG_FATAL("Failed to retrieve TrackParticle container: "
49  << m_TrkPartContainerKey.key());
50  return StatusCode::FAILURE;
51  }
52  // creating and saving the calo extension collection
53  SG::WriteHandle<CaloExtensionCollection> lastCache(m_ParticleCacheKey, ctx);
54  ATH_CHECK(lastCache.record(std::make_unique<CaloExtensionCollection>()));
55 
56  // set everything to false
57  const xAOD::TrackParticleContainer* ptrTracks = tracks.cptr();
58  std::vector<bool> mask(ptrTracks->size(), false);
59  // set to true if 500 MeV and above
60  // or not TRT-alone
61  for (const auto* track : *tracks) {
62  if (track->pt() < 500) {
63  continue;
64  }
65  // Cut out TRT alone, but do it for all else
66  if (track->patternRecoInfo().test(xAOD::TRTStandalone)) {
67  continue;
68  }
69  mask[track->index()] = true;
70  }
71 
72  ATH_CHECK(m_particleCaloExtensionTool->caloExtensionCollection(
73  ctx, *ptrTracks, mask, *lastCache));
74 
75  return StatusCode::SUCCESS;
76 }
RecVertex.h
Trk::CaloExtensionBuilderAlg::m_particleCaloExtensionTool
ToolHandle< Trk::IParticleCaloExtensionTool > m_particleCaloExtensionTool
the Calo Extension tool
Definition: CaloExtensionBuilderAlg.h:61
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Trk::CaloExtensionBuilderAlg::initialize
virtual StatusCode initialize() override final
Definition: CaloExtensionBuilderAlg.cxx:31
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
CaloExtensionBuilderAlg.h
Trk::CaloExtensionBuilderAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: CaloExtensionBuilderAlg.cxx:40
WriteHandle.h
Handle class for recording to StoreGate.
TrackParticleAuxContainer.h
Trk::CaloExtensionBuilderAlg::m_TrkPartContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkPartContainerKey
input Track collection and vertex
Definition: CaloExtensionBuilderAlg.h:76
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector< xAOD::TrackParticle_v1 >
Vertex.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
VxCandidate.h
Trk::CaloExtensionBuilderAlg::m_ParticleCacheKey
SG::WriteHandleKey< CaloExtensionCollection > m_ParticleCacheKey
output particle calo extension collection
Definition: CaloExtensionBuilderAlg.h:68
TrackParticle.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
VertexContainer.h
xAOD::TRTStandalone
@ TRTStandalone
TRT Standalone.
Definition: TrackingPrimitives.h:125
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
ReadHandle.h
Handle class for reading from StoreGate.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TrackParticleContainer.h