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  std::pair<Amg::Vector3D, Amg::Vector3D> makeLine(const Parameters& pars) {
27  return std::make_pair(Amg::Vector3D(pars[toInt(ParamDefs::x0)],
28  pars[toInt(ParamDefs::y0)],0.),
31  }
33  static const SG::Accessor<xAOD::MeasVector<toInt(ParamDefs::nPars)>> acc{"localSegPars"};
34  return xAOD::toEigen(xAOD::ConstVectorMap<toInt(ParamDefs::nPars)>{acc(seg).data()});
35  }
37  const Segment& segment) {
39  const Amg::Transform3D globToLoc = segment.msSector()->globalToLocalTrans(gctx);
40  const Amg::Vector3D locPos = globToLoc * segment.position();
41  const Amg::Vector3D locDir = globToLoc.linear() * segment.direction();
42  pars[toInt(ParamDefs::x0)] = locPos.x();
43  pars[toInt(ParamDefs::y0)] = locPos.y();
44  pars[toInt(ParamDefs::theta)] = locDir.theta();
45  pars[toInt(ParamDefs::phi)] = locDir.phi();
46  pars[toInt(ParamDefs::time)] = segment.segementT0();
47  return pars;
48  }
49 
50  std::string makeLabel(const Parameters&pars) {
51  std::stringstream sstr{};
52  sstr<<std::format("x_{{0}}={:.2f}", pars[toInt(ParamDefs::x0)])<<", ";
53  sstr<<std::format("y_{{0}}={:.2f}", pars[toInt(ParamDefs::y0)])<<", ";
54  sstr<<std::format("#theta={:.2f}^{{#circ}}", pars[toInt(ParamDefs::theta)] / Gaudi::Units::deg )<<", ";
55  sstr<<std::format("#phi={:.2f}^{{#circ}}", pars[toInt(ParamDefs::phi)] / Gaudi::Units::deg)<<", ";
56  sstr<<std::format("t_{{0}}={:.1f}", pars[toInt(ParamDefs::time)]);
57  return sstr.str();
58  }
59  std::string toString(const Parameters& pars) {
60  std::stringstream sstr{};
61  sstr<< std::format("{}={:.2f}, ",toString(ParamDefs::x0), pars[toInt(ParamDefs::x0)]);
62  sstr<< std::format("{}={:.2f}, ",toString(ParamDefs::y0), pars[toInt(ParamDefs::y0)]);
66  return sstr.str();
67  }
68  std::string toString(const ParamDefs a) {
69  switch (a){
70  case ParamDefs::x0:{
71  return "x0";
72  break;
73  } case ParamDefs::y0: {
74  return "y0";
75  break;
76  } case ParamDefs::theta: {
77  return "theta";
78  break;
79  } case ParamDefs::phi: {
80  return "phi";
81  break;
82  } case ParamDefs::time: {
83  return "time";
84  break;
85  } case ParamDefs::nPars:
86  break;
87  }
88  return "";
89  }
90 
91  }
92 }
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:26
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:59
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
Amg::dirFromAngles
Amg::Vector3D dirFromAngles(const double phi, const double theta)
Constructs a direction vector from the azimuthal & polar angles.
Definition: GeoPrimitivesHelpers.h:299
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
MuonR4::SegmentFit::makeLabel
std::string makeLabel(const Parameters &pars)
Definition: SegmentFitterEventData.cxx:50
MuonR4::SegmentFit::localSegmentPars
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
Definition: SegmentFitterEventData.cxx:32
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