ATLAS Offline Software
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 
7 #include "TrackSystematicsAlg.h"
8 
9 namespace InDet {
10  TrackSystematicsAlg::TrackSystematicsAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
11  AthReentrantAlgorithm( name, pSvcLocator ){}
12 
14 
18 
19  // Retrieve the tools:
20  ATH_CHECK(m_trackFilterToolLRT.retrieve());
21  ATH_CHECK(m_trackFilterToolSTD.retrieve());
22 
23  CP::SystematicSet systSetLRT = {
24  CP::SystematicVariation("TRK_EFF_LARGED0_GLOBAL")
25  };
26  CP::SystematicSet systSetSTD = {
27  CP::SystematicVariation("TRK_EFF_LOOSE_GLOBAL"),
28  CP::SystematicVariation("TRK_EFF_LOOSE_IBL"),
29  CP::SystematicVariation("TRK_EFF_LOOSE_PP0"),
30  CP::SystematicVariation("TRK_EFF_LOOSE_PHYSMODEL"),
31  };
32 
33  ATH_CHECK(m_trackFilterToolLRT->applySystematicVariation(systSetLRT));
34  ATH_CHECK(m_trackFilterToolSTD->applySystematicVariation(systSetSTD));
35 
36  return StatusCode::SUCCESS;
37  }
38 
39  StatusCode TrackSystematicsAlg::execute(const EventContext& ctx) const {
40 
41  //Retrieve the tracks:
43 
44  auto selectedTracks = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer> >( SG::VIEW_ELEMENTS );
45 
46  for(const xAOD::TrackParticle* track : *inTracks) {
47 
48  const std::bitset<xAOD::NumberOfTrackRecoInfo> patternReco = track->patternRecoInfo();
49  bool passFilter = false;
50 
51  // LRT track
52  if(patternReco.test(49)) {
54  }
55  // standard track
56  else {
58  }
59  if (passFilter) {
60  ATH_MSG_DEBUG("Track accepted!");
61  selectedTracks->push_back( track );
62  }
63  else {
64  ATH_MSG_DEBUG("Track rejected!");
65  }
66  }
67 
68  std::unique_ptr<const xAOD::TrackParticleContainer> outTracks(selectedTracks.release()->asDataVector());
70 
71  ATH_MSG_DEBUG( "Initial number of tracks: " << inTracks->size() );
72  ATH_MSG_DEBUG( "Selected number of tracks: " << outTracks->size() );
73 
74  if(not outTrackHandle.put(std::move(outTracks))){
75  ATH_MSG_ERROR("Failed to record " << m_outTrackKey.key() << " as const xAOD::TrackParticleContainer!");
76  return StatusCode::FAILURE;
77  }
78  ATH_CHECK(m_decorDeps.linkDecors (m_inTrackKey, ctx));
79 
80 
81  return StatusCode::SUCCESS;
82  }
83 }
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::TrackSystematicsAlg::m_trackFilterToolLRT
ToolHandle< InDet::InclusiveTrackFilterTool > m_trackFilterToolLRT
Definition: TrackSystematicsAlg.h:34
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
InDet::TrackSystematicsAlg::m_decorDeps
SG::ShallowCopyDecorDeps< xAOD::TrackParticleContainer > m_decorDeps
Definition: TrackSystematicsAlg.h:40
covarianceTool.passFilter
bool passFilter
Definition: covarianceTool.py:604
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CP::SystematicVariation
Definition: SystematicVariation.h:47
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
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
InDet::TrackSystematicsAlg::m_trackFilterToolSTD
ToolHandle< InDet::InDetTrackTruthFilterTool > m_trackFilterToolSTD
Definition: TrackSystematicsAlg.h:36
InDet::TrackSystematicsAlg::m_inTrackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inTrackKey
Definition: TrackSystematicsAlg.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrackSystematicsAlg.h
InDet::TrackSystematicsAlg::initialize
StatusCode initialize() override
Definition: TrackSystematicsAlg.cxx:13
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
InDet::TrackSystematicsAlg::TrackSystematicsAlg
TrackSystematicsAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrackSystematicsAlg.cxx:10
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDet::TrackSystematicsAlg::m_outTrackKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outTrackKey
Definition: TrackSystematicsAlg.h:39
InDet::TrackSystematicsAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: TrackSystematicsAlg.cxx:39