ATLAS Offline Software
FtfRoadDefiner.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 "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  TrigL2MuonSA::MuonRoad& muonRoad) const
30 {
31  ATH_MSG_DEBUG("FtfRoadDefiner::defineRoad");
32 
33  const int N_SECTOR = 2; // 0: normal, 1:overlap
34 
35  double extFtfInnerEta=0., extFtfInnerZ=0., extFtfInnerR=0., extFtfInnerPhi=0.;
36  double extFtfMiddleEta=0., extFtfMiddleZ=0., extFtfMiddleR=0., extFtfMiddlePhi=0.;
37  double extFtfOuterEta=0., extFtfOuterZ=0., extFtfOuterR=0., extFtfOuterPhi=0.;
38 
39  double aw_ftf[3]={0.,0.,0.}; // slope of FTF Road for Inner/Middle/Outer
40  double bw_ftf[3]={0.,0.,0.}; // intercept of FTF Road for Inner/Middle/Outer
41  // Inner
42 
43  bool CylinderFirst = (std::abs(idtrack->eta()) < 1.05);
44 
45  double innerCylinderZ = 7500.;
46  double middleCylinderZ = 14000.;
47  double outerCylinderZ = 21500.;
48  if(idtrack->eta() < 0) {
49  innerCylinderZ = -innerCylinderZ;
50  middleCylinderZ = -middleCylinderZ;
51  outerCylinderZ = -outerCylinderZ;
52  }
53 
54  auto extFtfInner = extTrack( CylinderFirst, idtrack, 4700., innerCylinderZ, muonRoad.ext_ftf_flag[0][0]);
55  if( !extFtfInner ) {
56  ATH_MSG_DEBUG("extrapolated track parameters on BarrelInner is null");
57  } else {
58  extFtfInnerEta = extFtfInner->eta();
59  extFtfInnerPhi = extFtfInner->position().phi();
60  extFtfInnerZ = extFtfInner->position().z();
61  extFtfInnerR = std::hypot(extFtfInner->position().x(), extFtfInner->position().y());
62  ATH_MSG_DEBUG("extFtfInnerEta: " << extFtfInnerEta << ", extFtfInnerPhi: " << extFtfInnerPhi << ", extFtfInnerZ: " << extFtfInnerZ << ", extFtfInnerR: " << extFtfInnerR);
63  aw_ftf[0] = std::tan(2*std::atan(std::exp(-extFtfInnerEta)));
64  bw_ftf[0] = extFtfInnerR - (aw_ftf[0])*extFtfInnerZ;
65  muonRoad.r_ftf[0][0] = extFtfInnerR;
66  muonRoad.z_ftf[0][0] = extFtfInnerZ;
67 
68  // Middle
69  if(muonRoad.ext_ftf_flag[0][0]==0||
70  muonRoad.ext_ftf_flag[0][0]==3)
71  CylinderFirst = true;
72  else
73  CylinderFirst = false;
74 
75  auto extFtfMiddle = extTrack( CylinderFirst, *extFtfInner, 7300., middleCylinderZ, muonRoad.ext_ftf_flag[1][0]);
76  if( !extFtfMiddle ) {
77  ATH_MSG_DEBUG("extrapolated track parameters on BarrelMiddle is null");
78  } else {
79  extFtfMiddleEta = extFtfMiddle->eta();
80  extFtfMiddlePhi = extFtfMiddle->position().phi();
81  extFtfMiddleZ = extFtfMiddle->position().z();
82  extFtfMiddleR = std::hypot(extFtfMiddle->position().x(), extFtfMiddle->position().y());
83  ATH_MSG_DEBUG("extFtfMiddleEta: " << extFtfMiddleEta << ", extFtfMiddlePhi: " << extFtfMiddlePhi << ", extFtfMiddleZ: " << extFtfMiddleZ << ", extFtfMiddleR: " << extFtfMiddleR);
84  aw_ftf[1] = std::tan(2*std::atan(std::exp(-extFtfMiddleEta)));
85  bw_ftf[1] = extFtfMiddleR - (aw_ftf[1])*extFtfMiddleZ;
86  muonRoad.r_ftf[1][0] = extFtfMiddleR;
87  muonRoad.z_ftf[1][0] = extFtfMiddleZ;
88 
89  // Outer
90  if(muonRoad.ext_ftf_flag[1][0]==0||
91  muonRoad.ext_ftf_flag[1][0]==3)
92  CylinderFirst = true;
93  else
94  CylinderFirst = false;
95 
96  auto extFtfOuter = extTrack( CylinderFirst, *extFtfMiddle, 9800., outerCylinderZ, muonRoad.ext_ftf_flag[2][0]);
97  if( !extFtfOuter ) {
98  ATH_MSG_DEBUG("extrapolated track parameters on BarrelOuter is null");
99  } else {
100  extFtfOuterEta = extFtfOuter->eta();
101  extFtfOuterPhi = extFtfOuter->position().phi();
102  extFtfOuterZ = extFtfOuter->position().z();
103  extFtfOuterR = std::hypot(extFtfOuter->position().x(), extFtfOuter->position().y());
104  ATH_MSG_DEBUG("extFtfOuterEta: " << extFtfOuterEta << ", extFtfOuterPhi: " << extFtfOuterPhi << ", extFtfOuterZ: " << extFtfOuterZ << ", extFtfOuterR: " << extFtfOuterR);
105  aw_ftf[2] = std::tan(2*std::atan(std::exp(-extFtfOuterEta)));
106  bw_ftf[2] = extFtfOuterR - (aw_ftf[2])*extFtfOuterZ;
107  muonRoad.r_ftf[2][0] = extFtfOuterR;
108  muonRoad.z_ftf[2][0] = extFtfOuterZ;
109  }
110  }
111  }
112 
113  muonRoad.extFtfMiddleEta = extFtfMiddleEta;
114  muonRoad.extFtfMiddlePhi = extFtfMiddlePhi;
115 
116  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
117  muonRoad.aw_ftf[0][i_sector] = aw_ftf[0];
118  muonRoad.bw_ftf[0][i_sector] = bw_ftf[0];
119  muonRoad.aw_ftf[1][i_sector] = aw_ftf[1];
120  muonRoad.bw_ftf[1][i_sector] = bw_ftf[1];
121  muonRoad.aw_ftf[2][i_sector] = aw_ftf[2];
122  muonRoad.bw_ftf[2][i_sector] = bw_ftf[2];
123  muonRoad.aw_ftf[3][i_sector] = aw_ftf[0];
124  muonRoad.bw_ftf[3][i_sector] = bw_ftf[0];
125  muonRoad.aw_ftf[4][i_sector] = aw_ftf[1];
126  muonRoad.bw_ftf[4][i_sector] = bw_ftf[1];
127  muonRoad.aw_ftf[5][i_sector] = aw_ftf[2];
128  muonRoad.bw_ftf[5][i_sector] = bw_ftf[2];
129  muonRoad.aw_ftf[6][i_sector] = aw_ftf[0];
130  muonRoad.bw_ftf[6][i_sector] = bw_ftf[0];
131  muonRoad.aw_ftf[7][i_sector] = aw_ftf[0];
132  muonRoad.bw_ftf[7][i_sector] = bw_ftf[0];
133  muonRoad.aw_ftf[8][i_sector] = aw_ftf[0];
134  muonRoad.bw_ftf[8][i_sector] = bw_ftf[0];
135  muonRoad.aw_ftf[9][i_sector] = aw_ftf[1];//BME
136  muonRoad.bw_ftf[9][i_sector] = bw_ftf[1];
137  muonRoad.aw_ftf[10][i_sector] = aw_ftf[1];//BMG
138  muonRoad.bw_ftf[10][i_sector] = bw_ftf[1];
139 
140  muonRoad.eta_ftf[0][i_sector] = extFtfInnerEta;
141  muonRoad.phi_ftf[0][i_sector] = extFtfInnerPhi;
142  muonRoad.eta_ftf[1][i_sector] = extFtfMiddleEta;
143  muonRoad.phi_ftf[1][i_sector] = extFtfMiddlePhi;
144  muonRoad.eta_ftf[2][i_sector] = extFtfOuterEta;
145  muonRoad.phi_ftf[2][i_sector] = extFtfOuterPhi;
146  muonRoad.eta_ftf[3][i_sector] = extFtfInnerEta;
147  muonRoad.phi_ftf[3][i_sector] = extFtfInnerPhi;
148  muonRoad.eta_ftf[4][i_sector] = extFtfMiddleEta;
149  muonRoad.phi_ftf[4][i_sector] = extFtfMiddlePhi;
150  muonRoad.eta_ftf[5][i_sector] = extFtfOuterEta;
151  muonRoad.phi_ftf[5][i_sector] = extFtfOuterPhi;
152  muonRoad.eta_ftf[6][i_sector] = extFtfInnerEta;
153  muonRoad.phi_ftf[6][i_sector] = extFtfInnerPhi;
154  muonRoad.eta_ftf[7][i_sector] = extFtfInnerEta;
155  muonRoad.phi_ftf[7][i_sector] = extFtfInnerPhi;
156  muonRoad.eta_ftf[8][i_sector] = extFtfInnerEta;
157  muonRoad.phi_ftf[8][i_sector] = extFtfInnerPhi;
158  muonRoad.eta_ftf[9][i_sector] = extFtfMiddleEta;//BME
159  muonRoad.phi_ftf[9][i_sector] = extFtfMiddlePhi;
160  muonRoad.eta_ftf[10][i_sector] = extFtfMiddleEta;//BMG
161  muonRoad.phi_ftf[10][i_sector] = extFtfMiddlePhi;
162  }
163 
164  return StatusCode::SUCCESS;
165 }
166 
167 // --------------------------------------------------------------------------------
168 // --------------------------------------------------------------------------------
169 
170 // extrapolate a FTF track to MS in order to define FTF Road
171 std::unique_ptr<const Trk::TrackParameters> TrigL2MuonSA::FtfRoadDefiner::extTrack( const bool CylinderFirst, const xAOD::TrackParticle* trk, const double R, const double Z, int& extFlag ) const
172 {
173 
174  const EventContext& ctx = Gaudi::Hive::currentContext();
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 bool CylinderFirst, const Trk::TrackParameters& param, const double R, const double Z, int& extFlag ) const
236 {
237 
238  const EventContext& ctx = Gaudi::Hive::currentContext();
239  const bool boundaryCheck = true;
240 
241  // Cylinder
242  std::unique_ptr<const Trk::CylinderSurface> barrel = std::make_unique<const Trk::CylinderSurface>( R, Z );
243 
244  // Disk
246  std::unique_ptr<const Trk::DiscSurface> disc = std::make_unique<const Trk::DiscSurface>( matrix, 0, R );
247 
248  ATH_MSG_DEBUG("R: " << R << ", Z: " << Z);
249 
250  if(CylinderFirst) {
251  std::unique_ptr<const Trk::TrackParameters> param1( m_extrapolator->extrapolate(ctx,
252  param,
253  *barrel,
254  Trk::anyDirection, boundaryCheck, Trk::muon) );
255  if(param1){
256  ATH_MSG_DEBUG("Cylinder -> eta: " << param1->eta() << ", phi: " << param1->position().phi() << ", Z: " << param1->position().z() << ", Rms: " << std::hypot(param1->position().x(), param1->position().y()));
257  extFlag = 0;
258  return param1;
259  }
260  // Cylinder failed, try Disk
261  std::unique_ptr<const Trk::TrackParameters> param2( m_extrapolator->extrapolate(ctx,
262  param,
263  *disc,
264  Trk::anyDirection, boundaryCheck, Trk::muon) );
265  if(param2){
266  ATH_MSG_DEBUG("Disk -> eta: " << param2->eta() << ", phi: " << param2->position().phi() << ", Z: " << param2->position().z() << ", Rms: " << std::hypot(param2->position().x(), param2->position().y()));
267  extFlag = 1;
268  return param2;
269  }
270  }
271  else { // Endcap First
272  std::unique_ptr<const Trk::TrackParameters> param2( m_extrapolator->extrapolate(ctx,
273  param,
274  *disc,
275  Trk::anyDirection, boundaryCheck, Trk::muon) );
276  if(param2){
277  ATH_MSG_DEBUG("Disk -> eta: " << param2->eta() << ", phi: " << param2->position().phi() << ", Z: " << param2->position().z() << ", Rms: " << std::hypot(param2->position().x(), param2->position().y()));
278  extFlag = 2;
279  return param2;
280  }
281  // Disk failed, try Cylinder
282  std::unique_ptr<const Trk::TrackParameters> param1( m_extrapolator->extrapolate(ctx,
283  param,
284  *barrel,
285  Trk::anyDirection, boundaryCheck, Trk::muon) );
286  if(param1){
287  ATH_MSG_DEBUG("Cylinder -> eta: " << param1->eta() << ", phi: " << param1->position().phi() << ", Z: " << param1->position().z() << ", Rms: " << std::hypot(param1->position().x(), param1->position().y()));
288  extFlag = 3;
289  return param1;
290  }
291  }
292 
293  extFlag = 4;
294 
295  return nullptr;
296 }
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:97
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:77
TrigL2MuonSA::MuonRoad::phi_ftf
double phi_ftf[N_STATION][N_SECTOR]
Definition: MuonRoad.h:94
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
TrigL2MuonSA::FtfRoadDefiner::defineRoad
StatusCode defineRoad(const xAOD::TrackParticle *idtrack, TrigL2MuonSA::MuonRoad &muonRoad) const
Definition: FtfRoadDefiner.cxx:28
xAOD::TrackParticle_v1::perigeeParameters
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
Definition: TrackParticle_v1.cxx:485
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:96
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
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::muon
@ muon
Definition: ParticleHypothesis.h:28
TrigL2MuonSA::MuonRoad::ext_ftf_flag
int ext_ftf_flag[N_STATION][N_SECTOR]
Definition: MuonRoad.h:98
TrigL2MuonSA::FtfRoadDefiner::extTrack
std::unique_ptr< const Trk::TrackParameters > extTrack(const bool CylinderFirst, const xAOD::TrackParticle *trk, const double R, const double Z, int &extFlag) const
Definition: FtfRoadDefiner.cxx:171
TrigL2MuonSA::MuonRoad::bw_ftf
double bw_ftf[N_STATION][N_SECTOR]
Definition: MuonRoad.h:93
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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:95
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:66
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigL2MuonSA::MuonRoad::extFtfMiddlePhi
double extFtfMiddlePhi
Definition: MuonRoad.h:91
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:92
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
TrigL2MuonSA::MuonRoad::extFtfMiddleEta
double extFtfMiddleEta
Definition: MuonRoad.h:90
AthAlgTool
Definition: AthAlgTool.h:26
FtfRoadDefiner.h