ATLAS Offline Software
Loading...
Searching...
No Matches
TrackSystematicsAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "GaudiKernel/ServiceHandle.h"
6
9
10namespace InDet {
11 TrackSystematicsAlg::TrackSystematicsAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
12 AthReentrantAlgorithm( name, pSvcLocator ){}
13
15
16 ATH_CHECK(m_inTrackKey.initialize());
17 ATH_CHECK(m_outTrackKey.initialize());
19
20 // Retrieve the tools:
23
24 if (m_systematicVariationSTD.value().empty() && m_systematicVariationLRT.value().empty()) {
25 ATH_MSG_ERROR("No track filter systematic configured (SystematicVariationSTD, SystematicVariationLRT)");
26 return StatusCode::FAILURE;
27 }
28
29 // The tools silently ignore unknown systematics, so reject them here
30 auto makeSet = [this](const std::string& name, const CP::ISystematicsTool& tool,
31 const char* type, CP::SystematicSet& systSet) -> StatusCode {
32 if (name.empty()) return StatusCode::SUCCESS;
33 const CP::SystematicVariation var(name);
34 if (!tool.isAffectedBySystematic(var)) {
35 ATH_MSG_ERROR("Systematic '" << name << "' is not known to the " << type << " track filter tool");
36 return StatusCode::FAILURE;
37 }
38 systSet.insert(var);
39 return StatusCode::SUCCESS;
40 };
41 CP::SystematicSet systSetSTD, systSetLRT;
42 ATH_CHECK(makeSet(m_systematicVariationSTD, *m_trackFilterToolSTD, "STD", systSetSTD));
43 ATH_CHECK(makeSet(m_systematicVariationLRT, *m_trackFilterToolLRT, "LRT", systSetLRT));
44
45 ATH_CHECK(m_trackFilterToolLRT->applySystematicVariation(systSetLRT));
46 ATH_CHECK(m_trackFilterToolSTD->applySystematicVariation(systSetSTD));
47
48 return StatusCode::SUCCESS;
49 }
50
51 StatusCode TrackSystematicsAlg::execute(const EventContext& ctx) const {
52
53 //Retrieve the tracks:
55
56 auto selectedTracks = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer> >( SG::VIEW_ELEMENTS );
57
58 for(const xAOD::TrackParticle* track : *inTracks) {
59
60 const std::bitset<xAOD::NumberOfTrackRecoInfo> patternReco = track->patternRecoInfo();
61 bool passFilter = false;
62
63 // LRT track
64 if(patternReco.test(xAOD::SiSpacePointsSeedMaker_LargeD0)) {
65 passFilter = m_trackFilterToolLRT->accept(track);
66 }
67 // standard track
68 else {
69 passFilter = m_trackFilterToolSTD->accept(track);
70 }
71 if (passFilter) {
72 ATH_MSG_DEBUG("Track accepted!");
73 selectedTracks->push_back( track );
74 }
75 else {
76 ATH_MSG_DEBUG("Track rejected!");
77 }
78 }
79
80 std::unique_ptr<const xAOD::TrackParticleContainer> outTracks(selectedTracks.release()->asDataVector());
82
83 ATH_MSG_DEBUG( "Initial number of tracks: " << inTracks->size() );
84 ATH_MSG_DEBUG( "Selected number of tracks: " << outTracks->size() );
85
86 if(not outTrackHandle.put(std::move(outTracks))){
87 ATH_MSG_ERROR("Failed to record " << m_outTrackKey.key() << " as const xAOD::TrackParticleContainer!");
88 return StatusCode::FAILURE;
89 }
90 ATH_CHECK(m_decorDeps.linkDecors (m_inTrackKey, ctx));
91
92
93 return StatusCode::SUCCESS;
94 }
95}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
An algorithm that can be simultaneously executed in multiple threads.
Interface for all CP tools supporting systematic variations.
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
Gaudi::Property< std::string > m_systematicVariationSTD
ToolHandle< InDet::InclusiveTrackFilterTool > m_trackFilterToolLRT
SG::ShallowCopyDecorDeps< xAOD::TrackParticleContainer > m_decorDeps
ToolHandle< InDet::InDetTrackTruthFilterTool > m_trackFilterToolSTD
Gaudi::Property< std::string > m_systematicVariationLRT
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:
@ SiSpacePointsSeedMaker_LargeD0