ATLAS Offline Software
LeadTracksRoISeedTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Implementation file for class LeadTracksRoISeedTool
8 // (c) ATLAS Detector software
10 
12 
13 #include "GaudiKernel/EventContext.h"
15 
16 #include "TVector2.h"
17 
18 #include <map>
19 #include <cmath>
20 
21 
23 // Constructor
25 
27 (const std::string& t,const std::string& n,const IInterface* p)
28  : base_class(t,n,p)
29 {
30 }
31 
33 // Initialization
35 
37 {
39 
40  ATH_CHECK( m_inputTracksCollectionKey.initialize() );
42 
43  ATH_CHECK( m_trackToVertex.retrieve() );
44 
45  return sc;
46 }
47 
49 // Compute RoI
51 
52 std::vector<InDet::IZWindowRoISeedTool::ZWindow> InDet::LeadTracksRoISeedTool::getRoIs(const EventContext& ctx) const
53 {
54 
55  static const float nonZeroInvP = 1e-9;
56 
57  // prepare output
58  std::vector<InDet::IZWindowRoISeedTool::ZWindow> listRoIs;
60  listRoIs.clear();
61 
62  //select tracks, then order by pT
64  if ( not tracks.isValid() ) {
65  ATH_MSG_ERROR("Could not find TrackCollection " << m_inputTracksCollectionKey.key() << " in StoreGate.");
66  return listRoIs;
67  }
68  ATH_MSG_DEBUG("Input track collection size "<<tracks->size());
70 
71  std::vector<Trk::Track*> selectedTracks;
72  for ( Trk::Track* trk : tracks->stdcont() ) {
73  float theta = trk->perigeeParameters()->parameters()[Trk::theta];
74  float ptinv = std::abs(trk->perigeeParameters()->parameters()[Trk::qOverP]) / std::sin(theta);
75  if (ptinv < 0.001) //1 GeV tracks
76  ATH_MSG_VERBOSE("Examining track");
77  if ( std::abs(ptinv) > nonZeroInvP ) {
78  float pt = 1. / ptinv;
79  if (pt > 1000.) //1 GeV tracks for printout
80  ATH_MSG_VERBOSE("- pT = " << pt << " MeV");
81  if ( pt < m_trkSubLeadingPt ) continue;
82  }
83  float eta = -std::log( std::tan( 0.5*theta ) );
84  ATH_MSG_VERBOSE("- eta = " << eta);
85  if ( std::abs(eta) > m_trkEtaMax ) continue;
86  float d0 = trk->perigeeParameters()->parameters()[Trk::d0];
87  ATH_MSG_VERBOSE("- d0 = " << d0 << "mm");
88  if ( std::abs(d0) > m_trkD0Max ) continue;
89  ATH_MSG_VERBOSE("- Passed all selections");
90  selectedTracks.push_back(trk);
91  }
92 
93  std::sort(selectedTracks.begin(), selectedTracks.end(), tracksPtGreaterThan);
94  ATH_MSG_DEBUG("Selected track collection size "<<selectedTracks.size());
95 
96  //create all pairs that satisfy leading pT and delta z0 requirements
97  for ( Trk::Track *trkLeading : selectedTracks ) {
98  //kinematic requirements
99  float thetaLeading = trkLeading->perigeeParameters()->parameters()[Trk::theta];
100  float ptInvLeading = std::abs(trkLeading->perigeeParameters()->parameters()[Trk::qOverP]) / std::sin(thetaLeading);
101  ATH_MSG_VERBOSE("Examining selected track pairs");
102  if (std::abs(ptInvLeading) > nonZeroInvP) {
103  float pt = 1. / ptInvLeading;
104  ATH_MSG_VERBOSE("- pT_leading = " << pt << " MeV");
105  if ( pt < m_trkLeadingPt ) break; //tracks ordered by pT
106  }
107  //loop over sub-leading track
108  for ( Trk::Track* trk : selectedTracks ) {
109  //kinematic requirements
110  float z0Leading = trkLeading->perigeeParameters()->parameters()[Trk::z0];
111  float z0 = trk->perigeeParameters()->parameters()[Trk::z0];
112  ATH_MSG_VERBOSE("- z0Leading = " << z0Leading << " mm");
113  ATH_MSG_VERBOSE("- z0_sublead = " << z0 << " mm");
114 
115  auto leadAtBeam = m_trackToVertex->perigeeAtBeamline(ctx, *trkLeading, *beamSpotHandle);
116  auto subleadAtBeam = m_trackToVertex->perigeeAtBeamline(ctx, *trk, *beamSpotHandle);
117  float z0LeadingBeam = leadAtBeam->parameters()[Trk::z0];
118  float z0Beam = subleadAtBeam->parameters()[Trk::z0];
119 
120  if ( std::abs(z0LeadingBeam - z0Beam) > m_maxDeltaZ ) continue;
121  //create the pair in global coordinates
122  float z0TrkReference = subleadAtBeam->associatedSurface().center().z();
123  float z0TrkLeadingReference = leadAtBeam->associatedSurface().center().z();
124  RoI.zReference = (z0Beam + z0TrkReference + z0LeadingBeam + z0TrkLeadingReference) / 2;
125  RoI.zWindow[0] = RoI.zReference - m_z0Window;
126  RoI.zWindow[1] = RoI.zReference + m_z0Window;
127  RoI.zPerigeePos[0] = z0LeadingBeam;
128  RoI.zPerigeePos[1] = z0Beam;
129  ATH_MSG_DEBUG("New RoI created [mm]: " << RoI.zWindow[0] << " - " << RoI.zWindow[1] << " (z-ref: " << RoI.zReference << ")");
130  listRoIs.push_back(RoI);
131  }
132  }
133 
134 
135  if( listRoIs.empty() ){
136  for( Trk::Track* trkLeading : selectedTracks ){
137  //kinematic requirements
138  float thetaLeading = trkLeading->perigeeParameters()->parameters()[Trk::theta];
139  float ptInvLeading = std::abs(trkLeading->perigeeParameters()->parameters()[Trk::qOverP]) / std::sin(thetaLeading);
140  ATH_MSG_VERBOSE("Examining selected track pairs");
141  if (std::abs(ptInvLeading) > nonZeroInvP) {
142  float pt = 1. / ptInvLeading;
143  ATH_MSG_VERBOSE("- pT_leading = " << pt << " MeV");
144  if ( pt < m_trkLeadingPt ) break; //tracks ordered by pT
145 
146  auto leadAtBeam = m_trackToVertex->perigeeAtBeamline(ctx, *trkLeading, *beamSpotHandle);
147  float z0LeadingBeam = leadAtBeam->parameters()[Trk::z0];
148 
149  //create the pair in global coordinates
150  float z0TrkLeadingReference = leadAtBeam->associatedSurface().center().z();
151  RoI.zReference = z0LeadingBeam + z0TrkLeadingReference;
152  RoI.zWindow[0] = RoI.zReference - m_z0Window;
153  RoI.zWindow[1] = RoI.zReference + m_z0Window;
154  RoI.zPerigeePos[0] = z0LeadingBeam;
155  ATH_MSG_DEBUG("New RoI created [mm]: " << RoI.zWindow[0] << " - " << RoI.zWindow[1] << " (z-ref: " << RoI.zReference << ")");
156  listRoIs.push_back(RoI);
157  }
158 
159 
160  }
161  }
162 
163  return listRoIs;
164 
165 }
166 
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
InDet::LeadTracksRoISeedTool::m_z0Window
FloatProperty m_z0Window
Definition: LeadTracksRoISeedTool.h:69
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
InDet::LeadTracksRoISeedTool::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition: LeadTracksRoISeedTool.h:70
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
initialize
void initialize()
Definition: run_EoverP.cxx:894
test_pyathena.pt
pt
Definition: test_pyathena.py:11
Trk::z0
@ z0
Definition: ParamDefs.h:64
LeadTracksRoISeedTool.h
InDet::LeadTracksRoISeedTool::m_maxDeltaZ
FloatProperty m_maxDeltaZ
Definition: LeadTracksRoISeedTool.h:68
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
InDet::LeadTracksRoISeedTool::m_trkSubLeadingPt
FloatProperty m_trkSubLeadingPt
Definition: LeadTracksRoISeedTool.h:65
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
InDet::LeadTracksRoISeedTool::initialize
virtual StatusCode initialize() override
Definition: LeadTracksRoISeedTool.cxx:36
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
InDet::LeadTracksRoISeedTool::m_inputTracksCollectionKey
SG::ReadHandleKey< TrackCollection > m_inputTracksCollectionKey
Definition: LeadTracksRoISeedTool.h:63
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::IZWindowRoISeedTool::ZWindow
Definition: IZWindowRoISeedTool.h:46
InDet::LeadTracksRoISeedTool::getRoIs
virtual std::vector< ZWindow > getRoIs(const EventContext &ctx) const override
Compute RoI.
Definition: LeadTracksRoISeedTool.cxx:52
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:66
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
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::IZWindowRoISeedTool::ZWindow::zPerigeePos
float zPerigeePos[2]
Definition: IZWindowRoISeedTool.h:53
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
TrackSummary.h
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
InDet::LeadTracksRoISeedTool::m_trkD0Max
FloatProperty m_trkD0Max
Definition: LeadTracksRoISeedTool.h:67
Trk::d0
@ d0
Definition: ParamDefs.h:63
InDet::LeadTracksRoISeedTool::tracksPtGreaterThan
static bool tracksPtGreaterThan(const Trk::Track *const &track1, const Trk::Track *const &track2)
Definition: LeadTracksRoISeedTool.h:75
InDet::IZWindowRoISeedTool::ZWindow::zWindow
float zWindow[2]
Definition: IZWindowRoISeedTool.h:49
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
InDet::LeadTracksRoISeedTool::m_trackToVertex
ToolHandle< Reco::ITrackToVertex > m_trackToVertex
Definition: LeadTracksRoISeedTool.h:71
InDet::LeadTracksRoISeedTool::m_trkLeadingPt
FloatProperty m_trkLeadingPt
Definition: LeadTracksRoISeedTool.h:64
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
InDet::IZWindowRoISeedTool::ZWindow::zReference
float zReference
Definition: IZWindowRoISeedTool.h:51
InDet::LeadTracksRoISeedTool::m_trkEtaMax
FloatProperty m_trkEtaMax
Definition: LeadTracksRoISeedTool.h:66
InDet::LeadTracksRoISeedTool::LeadTracksRoISeedTool
LeadTracksRoISeedTool()=delete