ATLAS Offline Software
SegmentFitterEventData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
6 #include <GaudiKernel/SystemOfUnits.h>
7 #include <CxxUtils/sincos.h>
8 #include <vector>
9 #include <array>
10 #include <sstream>
11 #include <format>
12 
13 namespace MuonR4{
14  double houghTanTheta(const Amg::Vector3D& v){
15  constexpr double eps = std::numeric_limits<float>::epsilon();
16  return v.y() / ( std::abs(v.z()) > eps ? v.z() : eps);
17  }
18  double houghTanPhi(const Amg::Vector3D& v){
19  constexpr double eps = std::numeric_limits<float>::epsilon();
20  return v.x() / ( std::abs(v.z()) > eps ? v.z() : eps);
21  }
22  namespace SegmentFit {
23  Amg::Vector3D dirFromTangents(const double tanPhi, const double tanTheta) {
24  return Amg::Vector3D(tanPhi, tanTheta, 1.).unit();
25  }
26  Amg::Vector3D dirFromAngles(const double phi, const double theta) {
27  const CxxUtils::sincos csPhi{phi}, csTheta{theta};
28  return Amg::Vector3D{csPhi.cs*csTheta.sn,csPhi.sn*csTheta.sn, csTheta.cs};
29  }
30  std::pair<Amg::Vector3D, Amg::Vector3D> makeLine(const Parameters& pars) {
31  return std::make_pair(Amg::Vector3D(pars[toInt(ParamDefs::x0)],
32  pars[toInt(ParamDefs::y0)],0.),
35  }
37  static const SG::Accessor<xAOD::MeasVector<toInt(ParamDefs::nPars)>> acc{"localSegPars"};
38  return xAOD::toEigen(xAOD::ConstVectorMap<toInt(ParamDefs::nPars)>{acc(seg).data()});
39  }
41  const Segment& segment) {
43  const Amg::Transform3D globToLoc = segment.msSector()->globalToLocalTrans(gctx);
44  const Amg::Vector3D locPos = globToLoc * segment.position();
45  const Amg::Vector3D locDir = globToLoc.linear() * segment.direction();
46  pars[toInt(ParamDefs::x0)] = locPos.x();
47  pars[toInt(ParamDefs::y0)] = locPos.y();
48  pars[toInt(ParamDefs::theta)] = locDir.theta();
49  pars[toInt(ParamDefs::phi)] = locDir.phi();
50  pars[toInt(ParamDefs::time)] = segment.segementT0();
51  return pars;
52  }
53 
54  std::string makeLabel(const Parameters&pars) {
55  std::stringstream sstr{};
56  sstr<<"x_{0}="<<std::format("{:.2f}", pars[toInt(ParamDefs::x0)])<<", ";
57  sstr<<"y_{0}="<<std::format("{:.2f}", pars[toInt(ParamDefs::y0)])<<", ";
58  sstr<<std::format("#theta={:.3f}", pars[toInt(ParamDefs::theta)] / Gaudi::Units::deg )<<", ";
59  sstr<<std::format("#phi={:.3f}", pars[toInt(ParamDefs::phi)] / Gaudi::Units::deg)<<", ";
60  sstr<<"t_{0}="<<std::format("{:.1f}", pars[toInt(ParamDefs::time)]);
61  return sstr.str();
62  }
63  std::string toString(const Parameters& pars) {
64  std::stringstream sstr{};
65  sstr<< std::format("{}={:.2f}, ",toString(ParamDefs::x0), pars[toInt(ParamDefs::x0)]);
66  sstr<< std::format("{}={:.2f}, ",toString(ParamDefs::y0), pars[toInt(ParamDefs::y0)]);
70  return sstr.str();
71  }
72  std::string toString(const ParamDefs a) {
73  switch (a){
74  case ParamDefs::x0:{
75  return "x0";
76  break;
77  } case ParamDefs::y0: {
78  return "y0";
79  break;
80  } case ParamDefs::theta: {
81  return "theta";
82  break;
83  } case ParamDefs::phi: {
84  return "phi";
85  break;
86  } case ParamDefs::time: {
87  return "time";
88  break;
89  } case ParamDefs::nPars:
90  break;
91  }
92  return "";
93  }
94 
95  }
96 }
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
MuonR4::SegmentFit::ParamDefs
ParamDefs
This file defines the parameter enums in the Trk namespace.
Definition: MuonHoughDefs.h:29
MuonR4::SegmentFit::Parameters
AmgVector(toInt(ParamDefs::nPars)) Parameters
Definition: MuonHoughDefs.h:48
vtune_athena.format
format
Definition: vtune_athena.py:14
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
MuonR4::Segment
Placeholder for what will later be the muon segment EDM representation.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:19
sincos.h
Helper to simultaneously calculate sin and cos of the same angle.
deg
#define deg
Definition: SbPolyhedron.cxx:17
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
MuonR4::SegmentFit::makeLine
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
Definition: SegmentFitterEventData.cxx:30
MuonR4::SegmentFit::ParamDefs::phi
@ phi
MuonR4::houghTanPhi
double houghTanPhi(const Amg::Vector3D &v)
: Returns the hough tanPhi [x] / [z]
Definition: SegmentFitterEventData.cxx:18
MuonR4::SegmentFit::dirFromTangents
Amg::Vector3D dirFromTangents(const double tanPhi, const double tanTheta)
Constructs a direction vector from tanPhi & tanTheta.
Definition: SegmentFitterEventData.cxx:23
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
MuonR4::SegmentFit::toString
std::string toString(const Parameters &pars)
Definition: SegmentFitterEventData.cxx:63
MuonR4::SegmentFit::ParamDefs::x0
@ x0
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MuonR4::SegmentFit::ParamDefs::time
@ time
xAOD::MeasVector
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Definition: MeasurementDefs.h:52
MuonR4::SegmentFit::ParamDefs::y0
@ y0
MuonR4::SegmentFit::toInt
constexpr int toInt(const ParamDefs p)
Definition: MuonHoughDefs.h:42
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.copyTCTOutput.locDir
locDir
Definition: copyTCTOutput.py:113
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
python.PyAthena.v
v
Definition: PyAthena.py:154
a
TList * a
Definition: liststreamerinfos.cxx:10
SegmentFitterEventData.h
CxxUtils::sincos
Helper to simultaneously calculate sin and cos of the same angle.
Definition: sincos.h:76
MuonR4::SegmentFit::makeLabel
std::string makeLabel(const Parameters &pars)
Definition: SegmentFitterEventData.cxx:54
MuonR4::SegmentFit::localSegmentPars
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
Definition: SegmentFitterEventData.cxx:36
MuonR4::SegmentFit::dirFromAngles
Amg::Vector3D dirFromAngles(const double phi, const double theta)
Constructs a direction vector from the polar theta & phi angles.
Definition: SegmentFitterEventData.cxx:26
Segment.h
MuonR4::SegmentFit::ParamDefs::nPars
@ nPars
MuonR4::houghTanTheta
double houghTanTheta(const Amg::Vector3D &v)
Returns the hough tanTheta [y] / [z].
Definition: SegmentFitterEventData.cxx:14
xAOD::ConstVectorMap
Eigen::Map< const MeasVector< N > > ConstVectorMap
Definition: MeasurementDefs.h:59
MuonR4::SegmentFit::ParamDefs::theta
@ theta
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5