ATLAS Offline Software
Loading...
Searching...
No Matches
TrackSystematicsAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "GaudiKernel/ServiceHandle.h"
6
8
9namespace InDet {
10 TrackSystematicsAlg::TrackSystematicsAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
11 AthReentrantAlgorithm( name, pSvcLocator ){}
12
14
15 ATH_CHECK(m_inTrackKey.initialize());
16 ATH_CHECK(m_outTrackKey.initialize());
18
19 // Retrieve the tools:
22
23 CP::SystematicSet systSetLRT = {
24 CP::SystematicVariation("TRK_EFF_LARGED0_GLOBAL")
25 };
26 CP::SystematicSet systSetSTD = {
27 CP::SystematicVariation("TRK_EFF_LOOSE_COMBINED"),
28 };
29
30 ATH_CHECK(m_trackFilterToolLRT->applySystematicVariation(systSetLRT));
31 ATH_CHECK(m_trackFilterToolSTD->applySystematicVariation(systSetSTD));
32
33 return StatusCode::SUCCESS;
34 }
35
36 StatusCode TrackSystematicsAlg::execute(const EventContext& ctx) const {
37
38 //Retrieve the tracks:
40
41 auto selectedTracks = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer> >( SG::VIEW_ELEMENTS );
42
43 for(const xAOD::TrackParticle* track : *inTracks) {
44
45 const std::bitset<xAOD::NumberOfTrackRecoInfo> patternReco = track->patternRecoInfo();
46 bool passFilter = false;
47
48 // LRT track
49 if(patternReco.test(49)) {
50 passFilter = m_trackFilterToolLRT->accept(track);
51 }
52 // standard track
53 else {
54 passFilter = m_trackFilterToolSTD->accept(track);
55 }
56 if (passFilter) {
57 ATH_MSG_DEBUG("Track accepted!");
58 selectedTracks->push_back( track );
59 }
60 else {
61 ATH_MSG_DEBUG("Track rejected!");
62 }
63 }
64
65 std::unique_ptr<const xAOD::TrackParticleContainer> outTracks(selectedTracks.release()->asDataVector());
67
68 ATH_MSG_DEBUG( "Initial number of tracks: " << inTracks->size() );
69 ATH_MSG_DEBUG( "Selected number of tracks: " << outTracks->size() );
70
71 if(not outTrackHandle.put(std::move(outTracks))){
72 ATH_MSG_ERROR("Failed to record " << m_outTrackKey.key() << " as const xAOD::TrackParticleContainer!");
73 return StatusCode::FAILURE;
74 }
75 ATH_CHECK(m_decorDeps.linkDecors (m_inTrackKey, ctx));
76
77
78 return StatusCode::SUCCESS;
79 }
80}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
Class to wrap a set of SystematicVariations.
StatusCode initialize() override
TrackSystematicsAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outTrackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inTrackKey
StatusCode execute(const EventContext &ctx) const override
ToolHandle< InDet::InclusiveTrackFilterTool > m_trackFilterToolLRT
SG::ShallowCopyDecorDeps< xAOD::TrackParticleContainer > m_decorDeps
ToolHandle< InDet::InDetTrackTruthFilterTool > m_trackFilterToolSTD
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
Primary Vertex Finder.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
TrackParticle_v1 TrackParticle
Reference the current persistent version: