ATLAS Offline Software
Loading...
Searching...
No Matches
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/********************************************************************
6NAME: CaloExtensionBuilderAlg
7PACKAGE: offline/Reconstruction/RecoTools/TrackToCalo/CaloExtensionBuilderAlg
8
9AUTHORS: Anastopoulos/Capriles
10PURPOSE: Performs Calo Extension for all selected tracks
11 **********************************************************************/
13//
14#include "GaudiKernel/ThreadLocalContext.h"
17#include "VxVertex/RecVertex.h"
22#include "xAODTracking/Vertex.h"
24
25// std includes
26#include <algorithm>
27#include <cmath>
28#include <memory>
29
30StatusCode
32{
34 ATH_CHECK(m_ParticleCacheKey.initialize());
35 ATH_CHECK(m_TrkPartContainerKey.initialize());
36 return StatusCode::SUCCESS;
37}
38
39StatusCode
40Trk::CaloExtensionBuilderAlg::execute(const EventContext& ctx) const
41{
42 /*
43 * We want to extrapolate everything bar the the TRT-alone
44 */
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
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkPartContainerKey
input Track collection and vertex
virtual StatusCode initialize() override final
virtual StatusCode execute(const EventContext &ctx) const override final
ToolHandle< Trk::IParticleCaloExtensionTool > m_particleCaloExtensionTool
the Calo Extension tool
SG::WriteHandleKey< CaloExtensionCollection > m_ParticleCacheKey
output particle calo extension collection
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
@ TRTStandalone
TRT Standalone.