ATLAS Offline Software
MuonHoughHit.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 #include "GaudiKernel/MsgStream.h"
12 #include "TrkSurfaces/Surface.h"
13 
15  const Trk::TrkDetElementBase* element = prd->detectorElement();
16  const Identifier identifier = prd->identify();
17 
18  m_pos = element->surface(identifier).Trk::Surface::localToGlobal(prd->localPosition());
19 
20  m_radius = m_pos.perp();
21  m_abs = m_pos.mag();
22  m_theta = std::atan2(m_radius, getHitz());
23  m_phi = m_pos.phi();
24  m_barrel = (std::abs(m_radius / getHitz()) < MuonHough::tan_barrel) ? 0 : 1;
25 
28  m_prd = prd;
29 }
30 
31 MuonHoughHit::MuonHoughHit(const Amg::Vector3D& pos_vec, bool measures_phi, MuonHough::DetectorTechnology detector_id, double prob,
32  double weight, const Trk::PrepRawData* prd, int id) :
33  m_prd(prd),
34  m_pos(pos_vec),
35  m_id(id),
36  m_radius(m_pos.perp()),
37  m_abs(m_pos.mag()),
38  m_phi(m_pos.phi()),
39  m_theta(std::atan2(m_radius, getHitz())),
40  m_barrel ((std::abs(m_radius / getHitz()) < MuonHough::tan_barrel) ? 0 : 1),
41  m_phi_sector(calcPhiSector()),
42  m_magnetic_trackratio(calcMagneticTrackRatio()),
43  m_weight(weight),
44  m_orig_weight(weight),
45  m_probability(prob),
46  m_detector_id(detector_id),
47  m_measures_phi(measures_phi)
48 {
49 }
50 
51 std::string MuonHoughHit::getWhichDetector() const {
52  std::string detector_name;
53  switch (m_detector_id) {
54  case MuonHough::MDT: detector_name = "MDT"; break;
55  case MuonHough::CSC: detector_name = "CSC"; break;
56  case MuonHough::RPC: detector_name = "RPC"; break;
57  case MuonHough::TGC: detector_name = "TGC"; break;
58  default:
59  MsgStream log(Athena::getMessageSvc(), "MuonHoughHit::getWhichDetector");
60  if (log.level() <= MSG::WARNING) log << MSG::WARNING << "MuonHoughHit:: no valid detector_id" << endmsg;
61  }
62  return detector_name;
63 }
64 
66  double phi = m_phi; // [-Pi , Pi]
68 
69  if (phi < 0) phi += MuonHough::two_Pi; // [ 0 , 2*Pi ]
70  int sectorhit = static_cast<int>(phi / (2 * MuonHough::half_phisector)); // 0..15
71  if (sectorhit == MuonHough::phisectors) sectorhit += -1; // could happen in rare cases
72  return sectorhit;
73 }
74 
76  // for formulas see muonhoughmathutils, only here for cpu improvements
77  double magnetic_trk_ratio = 0.;
78 
79  if (m_barrel) {
80  // Barrel hypothesis
81 
83  double diff_b = m_radius - MuonHough::radius_cylinder;
84  magnetic_trk_ratio = diff_b * diff_b / m_abs;
85  }
86  } else {
87  int sign = 1;
88  if (getHitz() < 0) sign = -1;
89  // Endcap hypothesis
90  if (std::abs(getHitz()) < MuonHough::z_cylinder) {
91  magnetic_trk_ratio = 0.;
92  } else if (std::abs(getHitz()) < MuonHough::z_end) {
93  // Inside Toroid
94  double diff_e = getHitz() - sign * MuonHough::z_cylinder;
95  magnetic_trk_ratio = diff_e * diff_e / m_abs;
96 
97  } else {
98  // Outside Toroid
100  }
101  }
102 
103  return magnetic_trk_ratio;
104 }
TrkDetElementBase.h
MuonHoughHit::m_pos
Amg::Vector3D m_pos
Definition: MuonHoughHit.h:104
MuonHoughHit::m_prd
const Trk::PrepRawData * m_prd
Pointer to preprawdata.
Definition: MuonHoughHit.h:102
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
Surface.h
MuonHoughHit::getHitz
double getHitz() const
returns z position
Definition: MuonHoughHit.h:161
perp
Scalar perp() const
perp method - perpenticular length
Definition: AmgMatrixBasePlugin.h:44
MuonHough::CSC
@ CSC
Definition: MuonHoughHit.h:17
MuonHoughHit::calcPhiSector
int calcPhiSector() const
method that calculates phi sector of hit
Definition: MuonHoughHit.cxx:65
MuonHough::z_cylinder
constexpr double z_cylinder
length of cylinder
Definition: MuonHoughMathUtils.h:26
MuonHoughHit::m_theta
double m_theta
theta of hit
Definition: MuonHoughHit.h:115
Trk::TrkDetElementBase
Definition: TrkDetElementBase.h:52
xAOD::identifier
identifier
Definition: UncalibratedMeasurement_v1.cxx:15
covarianceTool.prob
prob
Definition: covarianceTool.py:678
PrepRawData.h
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonHoughHit::m_phi
double m_phi
phi of hit
Definition: MuonHoughHit.h:113
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
MuonHough::phisectors
constexpr int phisectors
number of phi sectors
Definition: MuonHoughHit.h:19
MuonHoughHit.h
MuonHoughHit::getWhichDetector
std::string getWhichDetector() const
return DetectorTechnology in string
Definition: MuonHoughHit.cxx:51
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonHough
Definition: MuonLayerHoughTool.h:41
MuonHoughHit::m_detector_id
MuonHough::DetectorTechnology m_detector_id
detector technology of hit
Definition: MuonHoughHit.h:131
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
Trk::TrkDetElementBase::surface
virtual const Surface & surface() const =0
Return surface associated with this detector element.
MuonHough::z_end
constexpr double z_end
z value whereafter no magnetic field / curvature
Definition: MuonHoughMathUtils.h:28
MuonHoughHit::calcMagneticTrackRatio
double calcMagneticTrackRatio() const
method that calculates 'magnetic track ratio' (for curved track model)
Definition: MuonHoughHit.cxx:75
MuonHoughHit::m_radius
double m_radius
radius of hit
Definition: MuonHoughHit.h:109
Trk::PrepRawData
Definition: PrepRawData.h:62
MuonHough::RPC
@ RPC
Definition: MuonHoughHit.h:17
MuonHough::two_Pi
constexpr double two_Pi
Definition: MuonHoughMathUtils.h:16
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
MuonHough::TGC
@ TGC
Definition: MuonHoughHit.h:17
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
Trk::PrepRawData::localPosition
const Amg::Vector2D & localPosition() const
return the local position reference
MuonHough::half_phisector
constexpr double half_phisector
angle of half a sector in rad
Definition: MuonHoughHit.h:21
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonHoughHit::MuonHoughHit
MuonHoughHit(const Trk::PrepRawData *prd)
default constructor (should not be used)
Definition: MuonHoughHit.cxx:14
MuonHoughHit::m_barrel
bool m_barrel
hit is barrel / endcap
Definition: MuonHoughHit.h:117
MuonHoughHit::m_phi_sector
int m_phi_sector
phi sector (0,15), Atlas Convention
Definition: MuonHoughHit.h:119
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonHoughHit::m_magnetic_trackratio
double m_magnetic_trackratio
ratio of the tracklength of the particle to which hit might belong would have traversed in magnetic f...
Definition: MuonHoughHit.h:122
MuonHough::radius_cylinder
constexpr double radius_cylinder
radius of cylinder
Definition: MuonHoughMathUtils.h:24
MuonHoughHit::m_abs
double m_abs
absolute value of hit
Definition: MuonHoughHit.h:111
MuonHough::DetectorTechnology
DetectorTechnology
enum to identify the muondetectortechnology
Definition: MuonHoughHit.h:17
MuonHoughMathUtils.h
MuonHough::tan_barrel
constexpr double tan_barrel
relation for transition between endcap and barrel 11.43 m (r) / 14m (z)
Definition: MuonHoughMathUtils.h:22
MuonHough::z_magnetic_range
constexpr double z_magnetic_range
range where hit is curved in endcap region
Definition: MuonHoughMathUtils.h:30
MuonHough::MDT
@ MDT
Definition: MuonHoughHit.h:17
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
MuonHough::z_magnetic_range_squared
constexpr double z_magnetic_range_squared
range where hit is curved in endcap region ('squared')
Definition: MuonHoughMathUtils.h:32
Trk::PrepRawData::detectorElement
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
Identifier
Definition: IdentifierFieldParser.cxx:14