ATLAS Offline Software
Loading...
Searching...
No Matches
TrigTauTrackRoiUpdater.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
6
8
9#include "GaudiKernel/IToolSvc.h"
10#include "GaudiKernel/StatusCode.h"
11
13#include "CxxUtils/phihelper.h"
14
16#include <cmath>
17
18TrigTauTrackRoiUpdater::TrigTauTrackRoiUpdater(const std::string& name, ISvcLocator* pSvcLocator)
19 : AthReentrantAlgorithm(name, pSvcLocator)
20{
21
22}
23
24
29
30
32{
33 ATH_MSG_DEBUG("Initializing " << name() );
34 ATH_MSG_DEBUG("z0HalfWidth: " << m_z0HalfWidth );
35 ATH_MSG_DEBUG("etaHalfWidth: " << m_etaHalfWidth );
36 ATH_MSG_DEBUG("phiHalfWidth: " << m_phiHalfWidth );
37 ATH_MSG_DEBUG("nHitPix: " << m_nHitPix );
38 ATH_MSG_DEBUG("nSiHoles: " << m_nSiHoles );
39
40 if(m_z0HalfWidth < 0 || m_etaHalfWidth < 0 || m_phiHalfWidth < 0) {
41 ATH_MSG_ERROR("Incorrect parameters");
42 return StatusCode::FAILURE;
43 }
44
45 ATH_MSG_DEBUG("Initialising HandleKeys");
46 ATH_CHECK(m_roIInputKey.initialize());
47 ATH_CHECK(m_tracksKey.initialize());
48 ATH_CHECK(m_roIOutputKey.initialize());
49
50 return StatusCode::SUCCESS;
51}
52
53
54StatusCode TrigTauTrackRoiUpdater::execute(const EventContext& ctx) const
55{
56 ATH_MSG_DEBUG("Running " << name());
57
58 //---------------------------------------------------------------
59 // Prepare I/O
60 //---------------------------------------------------------------
61
62 // Prepare output RoI container
63 std::unique_ptr<TrigRoiDescriptorCollection> roiCollection = std::make_unique<TrigRoiDescriptorCollection>();
65 ATH_CHECK(outputRoIHandle.record(std::move(roiCollection)));
66
67
68 // Retrieve Input TrackCollection
70 ATH_CHECK(TrackCollectionHandle.isValid());
71 const xAOD::TrackParticleContainer* foundTracks = TrackCollectionHandle.get();
72
73 if(!foundTracks) {
74 ATH_MSG_ERROR("No track container found, the Track RoI updater should not be scheduled");
75 return StatusCode::FAILURE;
76 }
77 ATH_MSG_DEBUG("Found " << foundTracks->size() << " FTF tracks, updating the RoI");
78
79
80 // Retrieve input RoI descriptor
82 ATH_MSG_DEBUG("Size of roisHandle: " << roisHandle->size());
83 const TrigRoiDescriptor* roiDescriptor = roisHandle->at(0); // We only have one RoI in the handle
84
85
86 // Fill local variables for RoI reference position
87 float eta = roiDescriptor->eta();
88 float phi = roiDescriptor->phi();
89
90 float zed = roiDescriptor->zed();
91 float zedMinus = roiDescriptor->zedMinus();
92 float zedPlus = roiDescriptor->zedPlus();
93
94
95
96 //---------------------------------------------------------------
97 // Find leading track
98 //---------------------------------------------------------------
99
100 const xAOD::TrackParticle* leadTrack = nullptr;
101 float trkPtMax = 0;
102
103 // Use the highest-pt track satisfying quality cuts
104 // If no track is found, the input ROI is used
105 for(const xAOD::TrackParticle* track : *foundTracks) {
106
107 float trackPt = track->pt();
108 if(trackPt > trkPtMax) {
109 uint8_t nPix{}, nPixHoles{}, nSCTHoles{}, summaryVal{};
110 nPix = track->summaryValue(summaryVal, xAOD::numberOfPixelHits) ? summaryVal : 0;
111 if(nPix < m_nHitPix) {
112 ATH_MSG_DEBUG("Track rejected because nHitPix " << static_cast<int>(nPix) << " < " << m_nHitPix);
113 continue;
114 }
115
116 nPixHoles = track->summaryValue(summaryVal, xAOD::numberOfPixelHoles) ? summaryVal : 0;
117 nSCTHoles = track->summaryValue(summaryVal, xAOD::numberOfSCTHoles) ? summaryVal : 0;
118 if((nPixHoles + nSCTHoles) > m_nSiHoles) {
119 ATH_MSG_DEBUG("Track rejected because nSiHoles " << static_cast<int>(nPixHoles + nSCTHoles) << " > " << m_nSiHoles);
120 continue;
121 }
122
123 leadTrack = track;
124 trkPtMax = trackPt;
125 ATH_MSG_VERBOSE("pTmax = " << trkPtMax);
126 }
127 }
128
129
130
131 //---------------------------------------------------------------
132 // Update the RoI
133 //---------------------------------------------------------------
134
135 // If a leading track is found, update all the ROI position and size parameters;
136 // else, only update the eta/phi width (etaMinus, etaPlus, phiMinus, phiPlus)
137 if(leadTrack) {
138 zed = leadTrack->z0() + leadTrack->vz();
139 ATH_MSG_DEBUG("Track z0 " << leadTrack->z0() <<" vz: " << leadTrack->vz() << " zed:" << zed);
140 zedMinus = zed - m_z0HalfWidth;
141 zedPlus = zed + m_z0HalfWidth;
142 eta = leadTrack->eta();
143 phi = leadTrack->phi0();
144 }
145
146 float etaMinus = eta - m_etaHalfWidth;
147 float etaPlus = eta + m_etaHalfWidth;
148 float phiMinus = CxxUtils::wrapToPi(phi - m_phiHalfWidth);
149 float phiPlus = CxxUtils::wrapToPi(phi + m_phiHalfWidth);
150
151
152 // Create the new RoI
153 outputRoIHandle->push_back(std::make_unique<TrigRoiDescriptor>(
154 roiDescriptor->roiWord(), roiDescriptor->l1Id(), roiDescriptor->roiId(),
155 eta, etaMinus, etaPlus,
156 phi, phiMinus, phiPlus,
157 zed, zedMinus, zedPlus
158 ));
159
160
161 ATH_MSG_DEBUG("Input RoI: " << *roiDescriptor);
162 ATH_MSG_DEBUG("Output RoI: " << *outputRoIHandle->back());
163
164 return StatusCode::SUCCESS;
165}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual double zed() const override final
virtual double phi() const override final
Methods to retrieve data members.
virtual double zedPlus() const override final
z at the most forward end of the RoI
virtual double zedMinus() const override final
z at the most backward end of the RoI
virtual double eta() const override final
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
virtual unsigned int roiWord() const override final
virtual unsigned int roiId() const override final
these quantities probably don't need to be used any more
virtual unsigned int l1Id() const override final
virtual StatusCode execute(const EventContext &) const override
Gaudi::Property< int > m_nSiHoles
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roIInputKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_tracksKey
Gaudi::Property< float > m_phiHalfWidth
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roIOutputKey
Gaudi::Property< int > m_nHitPix
Gaudi::Property< float > m_z0HalfWidth
TrigTauTrackRoiUpdater(const std::string &, ISvcLocator *)
Gaudi::Property< float > m_etaHalfWidth
virtual StatusCode initialize() override
float z0() const
Returns the parameter.
float vz() const
The z origin for the parameters.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
float phi0() const
Returns the parameter, which has range to .
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition phihelper.h:24
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ numberOfSCTHoles
number of SCT holes [unit8_t].
Helper for azimuthal angle calculations.