ATLAS Offline Software
FtfRoadDefiner.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "FtfRoadDefiner.h"
6 
8  const std::string& name,
9  const IInterface* parent):
11 {
12 }
13 
14 // --------------------------------------------------------------------------------
15 // --------------------------------------------------------------------------------
16 
18 {
19 
20  ATH_CHECK( m_extrapolator.retrieve() );
21 
22  return StatusCode::SUCCESS;
23 }
24 
25 // --------------------------------------------------------------------------------
26 // --------------------------------------------------------------------------------
27 
29  const xAOD::TrackParticle* idtrack,
30  TrigL2MuonSA::MuonRoad& muonRoad) const
31 {
32  ATH_MSG_DEBUG("FtfRoadDefiner::defineRoad");
33 
34  const int N_SECTOR = 2; // 0: normal, 1:overlap
35 
36  double extFtfInnerEta=0., extFtfInnerZ=0., extFtfInnerR=0., extFtfInnerPhi=0.;
37  double extFtfMiddleEta=0., extFtfMiddleZ=0., extFtfMiddleR=0., extFtfMiddlePhi=0.;
38  double extFtfOuterEta=0., extFtfOuterZ=0., extFtfOuterR=0., extFtfOuterPhi=0.;
39 
40  double aw_ftf[3]={0.,0.,0.}; // slope of FTF Road for Inner/Middle/Outer
41  double bw_ftf[3]={0.,0.,0.}; // intercept of FTF Road for Inner/Middle/Outer
42  // Inner
43 
44  bool CylinderFirst = (std::abs(idtrack->eta()) < 1.05);
45 
46  double innerCylinderZ = 7500.;
47  double middleCylinderZ = 14000.;
48  double outerCylinderZ = 21500.;
49  if(idtrack->eta() < 0) {
50  innerCylinderZ = -innerCylinderZ;
51  middleCylinderZ = -middleCylinderZ;
52  outerCylinderZ = -outerCylinderZ;
53  }
54 
55  auto extFtfInner = extTrack( ctx, CylinderFirst, idtrack, 4700., innerCylinderZ, muonRoad.ext_ftf_flag[0][0]);
56  if( !extFtfInner ) {
57  ATH_MSG_DEBUG("extrapolated track parameters on BarrelInner is null");
58  } else {
59  extFtfInnerEta = extFtfInner->eta();
60  extFtfInnerPhi = extFtfInner->position().phi();
61  extFtfInnerZ = extFtfInner->position().z();
62  extFtfInnerR = std::hypot(extFtfInner->position().x(), extFtfInner->position().y());
63  ATH_MSG_DEBUG("extFtfInnerEta: " << extFtfInnerEta << ", extFtfInnerPhi: " << extFtfInnerPhi << ", extFtfInnerZ: " << extFtfInnerZ << ", extFtfInnerR: " << extFtfInnerR);
64  aw_ftf[0] = std::tan(2*std::atan(std::exp(-extFtfInnerEta)));
65  bw_ftf[0] = extFtfInnerR - (aw_ftf[0])*extFtfInnerZ;
66  muonRoad.r_ftf[0][0] = extFtfInnerR;
67  muonRoad.z_ftf[0][0] = extFtfInnerZ;
68 
69  // Middle
70  if(muonRoad.ext_ftf_flag[0][0]==0||
71  muonRoad.ext_ftf_flag[0][0]==3)
72  CylinderFirst = true;
73  else
74  CylinderFirst = false;
75 
76  auto extFtfMiddle = extTrack( ctx, CylinderFirst, *extFtfInner, 7300., middleCylinderZ, muonRoad.ext_ftf_flag[1][0]);
77  if( !extFtfMiddle ) {
78  ATH_MSG_DEBUG("extrapolated track parameters on BarrelMiddle is null");
79  } else {
80  extFtfMiddleEta = extFtfMiddle->eta();
81  extFtfMiddlePhi = extFtfMiddle->position().phi();
82  extFtfMiddleZ = extFtfMiddle->position().z();
83  extFtfMiddleR = std::hypot(extFtfMiddle->position().x(), extFtfMiddle->position().y());
84  ATH_MSG_DEBUG("extFtfMiddleEta: " << extFtfMiddleEta << ", extFtfMiddlePhi: " << extFtfMiddlePhi << ", extFtfMiddleZ: " << extFtfMiddleZ << ", extFtfMiddleR: " << extFtfMiddleR);
85  aw_ftf[1] = std::tan(2*std::atan(std::exp(-extFtfMiddleEta)));
86  bw_ftf[1] = extFtfMiddleR - (aw_ftf[1])*extFtfMiddleZ;
87  muonRoad.r_ftf[1][0] = extFtfMiddleR;
88  muonRoad.z_ftf[1][0] = extFtfMiddleZ;
89 
90  // Outer
91  if(muonRoad.ext_ftf_flag[1][0]==0||
92  muonRoad.ext_ftf_flag[1][0]==3)
93  CylinderFirst = true;
94  else
95  CylinderFirst = false;
96 
97  auto extFtfOuter = extTrack( ctx, CylinderFirst, *extFtfMiddle, 9800., outerCylinderZ, muonRoad.ext_ftf_flag[2][0]);
98  if( !extFtfOuter ) {
99  ATH_MSG_DEBUG("extrapolated track parameters on BarrelOuter is null");
100  } else {
101  extFtfOuterEta = extFtfOuter->eta();
102  extFtfOuterPhi = extFtfOuter->position().phi();
103  extFtfOuterZ = extFtfOuter->position().z();
104  extFtfOuterR = std::hypot(extFtfOuter->position().x(), extFtfOuter->position().y());
105  ATH_MSG_DEBUG("extFtfOuterEta: " << extFtfOuterEta << ", extFtfOuterPhi: " << extFtfOuterPhi << ", extFtfOuterZ: " << extFtfOuterZ << ", extFtfOuterR: " << extFtfOuterR);
106  aw_ftf[2] = std::tan(2*std::atan(std::exp(-extFtfOuterEta)));
107  bw_ftf[2] = extFtfOuterR - (aw_ftf[2])*extFtfOuterZ;
108  muonRoad.r_ftf[2][0] = extFtfOuterR;
109  muonRoad.z_ftf[2][0] = extFtfOuterZ;
110  }
111  }
112  }
113 
114  muonRoad.extFtfMiddleEta = extFtfMiddleEta;
115  muonRoad.extFtfMiddlePhi = extFtfMiddlePhi;
116 
117  for (int i_sector=0; i_sector<N_SECTOR; i_sector++) { // 0: normal sector, 1: overlap sector, which is used when a muon pass through boundary of MS sectors
118  muonRoad.aw_ftf[0][i_sector] = aw_ftf[0];
119  muonRoad.bw_ftf[0][i_sector] = bw_ftf[0];
120  muonRoad.aw_ftf[1][i_sector] = aw_ftf[1];
121  muonRoad.bw_ftf[1][i_sector] = bw_ftf[1];
122  muonRoad.aw_ftf[2][i_sector] = aw_ftf[2];
123  muonRoad.bw_ftf[2][i_sector] = bw_ftf[2];
124  muonRoad.aw_ftf[3][i_sector] = aw_ftf[0];
125  muonRoad.bw_ftf[3][i_sector] = bw_ftf[0];
126  muonRoad.aw_ftf[4][i_sector] = aw_ftf[1];
127  muonRoad.bw_ftf[4][i_sector] = bw_ftf[1];
128  muonRoad.aw_ftf[5][i_sector] = aw_ftf[2];
129  muonRoad.bw_ftf[5][i_sector] = bw_ftf[2];
130  muonRoad.aw_ftf[6][i_sector] = aw_ftf[0];
131  muonRoad.bw_ftf[6][i_sector] = bw_ftf[0];
132  muonRoad.aw_ftf[7][i_sector] = aw_ftf[0];
133  muonRoad.bw_ftf[7][i_sector] = bw_ftf[0];
134  muonRoad.aw_ftf[8][i_sector] = aw_ftf[0];
135  muonRoad.bw_ftf[8][i_sector] = bw_ftf[0];
136  muonRoad.aw_ftf[9][i_sector] = aw_ftf[1];//BME
137  muonRoad.bw_ftf[9][i_sector] = bw_ftf[1];
138  muonRoad.aw_ftf[10][i_sector] = aw_ftf[1];//BMG
139  muonRoad.bw_ftf[10][i_sector] = bw_ftf[1];
140 
141  muonRoad.eta_ftf[0][i_sector] = extFtfInnerEta;
142  muonRoad.phi_ftf[0][i_sector] = extFtfInnerPhi;
143  muonRoad.eta_ftf[1][i_sector] = extFtfMiddleEta;
144  muonRoad.phi_ftf[1][i_sector] = extFtfMiddlePhi;
145  muonRoad.eta_ftf[2][i_sector] = extFtfOuterEta;
146  muonRoad.phi_ftf[2][i_sector] = extFtfOuterPhi;
147  muonRoad.eta_ftf[3][i_sector] = extFtfInnerEta;
148  muonRoad.phi_ftf[3][i_sector] = extFtfInnerPhi;
149  muonRoad.eta_ftf[4][i_sector] = extFtfMiddleEta;
150  muonRoad.phi_ftf[4][i_sector] = extFtfMiddlePhi;
151  muonRoad.eta_ftf[5][i_sector] = extFtfOuterEta;
152  muonRoad.phi_ftf[5][i_sector] = extFtfOuterPhi;
153  muonRoad.eta_ftf[6][i_sector] = extFtfInnerEta;
154  muonRoad.phi_ftf[6][i_sector] = extFtfInnerPhi;
155  muonRoad.eta_ftf[7][i_sector] = extFtfInnerEta;
156  muonRoad.phi_ftf[7][i_sector] = extFtfInnerPhi;
157  muonRoad.eta_ftf[8][i_sector] = extFtfInnerEta;
158  muonRoad.phi_ftf[8][i_sector] = extFtfInnerPhi;
159  muonRoad.eta_ftf[9][i_sector] = extFtfMiddleEta;//BME
160  muonRoad.phi_ftf[9][i_sector] = extFtfMiddlePhi;
161  muonRoad.eta_ftf[10][i_sector] = extFtfMiddleEta;//BMG
162  muonRoad.phi_ftf[10][i_sector] = extFtfMiddlePhi;
163  }
164 
165  return StatusCode::SUCCESS;
166 }
167 
168 // --------------------------------------------------------------------------------
169 // --------------------------------------------------------------------------------
170 
171 // extrapolate a FTF track to MS in order to define FTF Road
172 std::unique_ptr<const Trk::TrackParameters> TrigL2MuonSA::FtfRoadDefiner::extTrack( const EventContext& ctx, const bool CylinderFirst, const xAOD::TrackParticle* trk, const double R, const double Z, int& extFlag ) const
173 {
174 
175  const bool boundaryCheck = true;
176 
177  // Cylinder
178  std::unique_ptr<const Trk::CylinderSurface> barrel = std::make_unique<const Trk::CylinderSurface>( R, Z );
179 
180  // Disk
182  std::unique_ptr<const Trk::DiscSurface> disc = std::make_unique<const Trk::DiscSurface>( matrix, 0, R );
183 
184  ATH_MSG_DEBUG("R: " << R << ", Z: " << Z);
185 
186  if(CylinderFirst) {
187  std::unique_ptr<const Trk::TrackParameters> param1( m_extrapolator->extrapolate(ctx,
188  trk->perigeeParameters(),
189  *barrel,
190  Trk::anyDirection, boundaryCheck, Trk::muon) );
191  if(param1){
192  ATH_MSG_DEBUG("Cylinder -> eta: " << param1->eta() << ", phi: " << param1->position().phi() << ", Z: " << param1->position().z() << ", Rms: " << std::hypot(param1->position().x(), param1->position().y()));
193  extFlag = 0;
194  return param1;
195  }
196  // Cylinder failed, try Disk
197  std::unique_ptr<const Trk::TrackParameters> param2( m_extrapolator->extrapolate(ctx,
198  trk->perigeeParameters(),
199  *disc,
200  Trk::anyDirection, boundaryCheck, Trk::muon) );
201  if(param2){
202  ATH_MSG_DEBUG("Disk -> eta: " << param2->eta() << ", phi: " << param2->position().phi() << ", Z: " << param2->position().z() << ", Rms: " << std::hypot(param2->position().x(), param2->position().y()));
203  extFlag = 1;
204  return param2;
205  }
206  }
207  else { // Endcap First
208  std::unique_ptr<const Trk::TrackParameters> param2( m_extrapolator->extrapolate(ctx,
209  trk->perigeeParameters(),
210  *disc,
211  Trk::anyDirection, boundaryCheck, Trk::muon) );
212  if(param2){
213  ATH_MSG_DEBUG("Disk -> eta: " << param2->eta() << ", phi: " << param2->position().phi() << ", Z: " << param2->position().z() << ", Rms: " << std::hypot(param2->position().x(), param2->position().y()));
214  extFlag = 2;
215  return param2;
216  }
217  // Disk failed, try Cylinder
218  std::unique_ptr<const Trk::TrackParameters> param1( m_extrapolator->extrapolate(ctx,
219  trk->perigeeParameters(),
220  *barrel,
221  Trk::anyDirection, boundaryCheck, Trk::muon) );
222  if(param1){
223  ATH_MSG_DEBUG("Cylinder -> eta: " << param1->eta() << ", phi: " << param1->position().phi() << ", Z: " << param1->position().z() << ", Rms: " << std::hypot(param1->position().x(), param1->position().y()));
224  extFlag = 3;
225  return param1;
226  }
227  }
228 
229  extFlag = 4;
230 
231  return nullptr;
232 }
233 
234 // extrapolate a FTF track to MS in order to define FTF Road
235 std::unique_ptr<const Trk::TrackParameters> TrigL2MuonSA::FtfRoadDefiner::extTrack( const EventContext& ctx, const bool CylinderFirst, const Trk::TrackParameters& param, const double R, const double Z, int& extFlag ) const
236 {
237 
238  const bool boundaryCheck = true;
239 
240  // Cylinder
241  std::unique_ptr<const Trk::CylinderSurface> barrel = std::make_unique<const Trk::CylinderSurface>( R, Z );
242 
243  // Disk
245  std::unique_ptr<const Trk::DiscSurface> disc = std::make_unique<const Trk::DiscSurface>( matrix, 0, R );
246 
247  ATH_MSG_DEBUG("R: " << R << ", Z: " << Z);
248 
249  if(CylinderFirst) {
250  std::unique_ptr<const Trk::TrackParameters> param1( m_extrapolator->extrapolate(ctx,
251  param,
252  *barrel,
253  Trk::anyDirection, boundaryCheck, Trk::muon) );
254  if(param1){
255  ATH_MSG_DEBUG("Cylinder -> eta: " << param1->eta() << ", phi: " << param1->position().phi() << ", Z: " << param1->position().z() << ", Rms: " << std::hypot(param1->position().x(), param1->position().y()));
256  extFlag = 0;
257  return param1;
258  }
259  // Cylinder failed, try Disk
260  std::unique_ptr<const Trk::TrackParameters> param2( m_extrapolator->extrapolate(ctx,
261  param,
262  *disc,
263  Trk::anyDirection, boundaryCheck, Trk::muon) );
264  if(param2){
265  ATH_MSG_DEBUG("Disk -> eta: " << param2->eta() << ", phi: " << param2->position().phi() << ", Z: " << param2->position().z() << ", Rms: " << std::hypot(param2->position().x(), param2->position().y()));
266  extFlag = 1;
267  return param2;
268  }
269  }
270  else { // Endcap First
271  std::unique_ptr<const Trk::TrackParameters> param2( m_extrapolator->extrapolate(ctx,
272  param,
273  *disc,
274  Trk::anyDirection, boundaryCheck, Trk::muon) );
275  if(param2){
276  ATH_MSG_DEBUG("Disk -> eta: " << param2->eta() << ", phi: " << param2->position().phi() << ", Z: " << param2->position().z() << ", Rms: " << std::hypot(param2->position().x(), param2->position().y()));
277  extFlag = 2;
278  return param2;
279  }
280  // Disk failed, try Cylinder
281  std::unique_ptr<const Trk::TrackParameters> param1( m_extrapolator->extrapolate(ctx,
282  param,
283  *barrel,
284  Trk::anyDirection, boundaryCheck, Trk::muon) );
285  if(param1){
286  ATH_MSG_DEBUG("Cylinder -> eta: " << param1->eta() << ", phi: " << param1->position().phi() << ", Z: " << param1->position().z() << ", Rms: " << std::hypot(param1->position().x(), param1->position().y()));
287  extFlag = 3;
288  return param1;
289  }
290  }
291 
292  extFlag = 4;
293 
294  return nullptr;
295 }
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
TrigL2MuonSA::N_SECTOR
constexpr int N_SECTOR
Definition: MuonRoad.h:16
TrigL2MuonSA::MuonRoad::z_ftf
double z_ftf[N_STATION][N_SECTOR]
Definition: MuonRoad.h:99
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:78
TrigL2MuonSA::MuonRoad::phi_ftf
double phi_ftf[N_STATION][N_SECTOR]
Definition: MuonRoad.h:96
TrigL2MuonSA::FtfRoadDefiner::defineRoad
StatusCode defineRoad(const EventContext &ctx, const xAOD::TrackParticle *idtrack, TrigL2MuonSA::MuonRoad &muonRoad) const
Definition: FtfRoadDefiner.cxx:28
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
xAOD::TrackParticle_v1::perigeeParameters
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
Definition: TrackParticle_v1.cxx:486
TrigL2MuonSA::FtfRoadDefiner::initialize
virtual StatusCode initialize() override
Definition: FtfRoadDefiner.cxx:17
TrigL2MuonSA::MuonRoad
Definition: MuonRoad.h:20
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
TrigL2MuonSA::MuonRoad::r_ftf
double r_ftf[N_STATION][N_SECTOR]
Definition: MuonRoad.h:98
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigL2MuonSA::FtfRoadDefiner::extTrack
std::unique_ptr< const Trk::TrackParameters > extTrack(const EventContext &ctx, const bool CylinderFirst, const xAOD::TrackParticle *trk, const double R, const double Z, int &extFlag) const
Definition: FtfRoadDefiner.cxx:172
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::muon
@ muon
Definition: ParticleHypothesis.h:31
TrigL2MuonSA::MuonRoad::ext_ftf_flag
int ext_ftf_flag[N_STATION][N_SECTOR]
Definition: MuonRoad.h:100
TrigL2MuonSA::MuonRoad::bw_ftf
double bw_ftf[N_STATION][N_SECTOR]
Definition: MuonRoad.h:95
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
TrigL2MuonSA::FtfRoadDefiner::FtfRoadDefiner
FtfRoadDefiner(const std::string &type, const std::string &name, const IInterface *parent)
Definition: FtfRoadDefiner.cxx:7
TrigL2MuonSA::MuonRoad::eta_ftf
double eta_ftf[N_STATION][N_SECTOR]
Definition: MuonRoad.h:97
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:63
TrigL2MuonSA::MuonRoad::extFtfMiddlePhi
double extFtfMiddlePhi
Definition: MuonRoad.h:93
Trk::ParametersBase::eta
double eta() const
Access method for pseudorapidity - from momentum.
TrigL2MuonSA::MuonRoad::aw_ftf
double aw_ftf[N_STATION][N_SECTOR]
Definition: MuonRoad.h:94
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
TrigL2MuonSA::MuonRoad::extFtfMiddleEta
double extFtfMiddleEta
Definition: MuonRoad.h:92
AthAlgTool
Definition: AthAlgTool.h:26
FtfRoadDefiner.h