ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
RecoTools
TrackToCalo
src
CaloCellSelectorUtils.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrackToCalo/CaloCellSelectorUtils.h
"
6
7
#include <algorithm>
8
#include <cmath>
9
10
namespace
Utils
{
11
double
deltaPhi
(
double
phi1,
double
phi2) {
12
double
dPhi = std::fabs(phi1 - phi2);
13
if
(dPhi >
M_PI
) dPhi = 2 *
M_PI
- dPhi;
14
return
dPhi;
15
}
16
17
double
deltaR2
(
double
eta1,
double
eta2,
double
phi1,
double
phi2) {
18
double
dPhi =
deltaPhi
(phi1, phi2);
19
double
dEta = std::fabs(eta1 - eta2);
20
return
dEta * dEta + dPhi * dPhi;
21
}
22
23
double
deltaR
(
double
eta1,
double
eta2,
double
phi1,
double
phi2) {
return
std::sqrt(
deltaR2
(eta1, eta2, phi1, phi2)); }
24
25
void
findNearestPoint
(
const
Amg::Vector3D
& inputPos,
const
Trk::CaloExtension
* caloExtension,
int
& nearestIdx,
26
Amg::Vector3D
& nearestPos,
Amg::Vector3D
& nearestMom) {
27
const
std::vector<Trk::CurvilinearParameters>& intersections = caloExtension->
caloLayerIntersections
();
28
int
nPts = intersections.size();
29
30
int
idxL, idxR, idxMid;
31
Amg::Vector3D
pos(0, 0, 0), mom(0, 0, 0);
// initialization should be(?) unnecessary, just to suppress scary warning msg...
32
Amg::Vector3D
posL(0, 0, 0), momL(0, 0, 0);
33
Amg::Vector3D
posR(0, 0, 0), momR(0, 0, 0);
34
35
// find nearest crossing point
36
idxL = 0;
37
idxR = nPts - 1;
38
while
((idxR - idxL) > 1) {
39
idxMid = (idxL + idxR) / 2;
40
pos = intersections[idxMid].position();
41
mom = intersections[idxMid].momentum();
42
43
if
((inputPos - pos).
dot
(mom) > 0) {
44
idxL = idxMid;
45
std::swap
(posL, pos);
46
std::swap
(momL, mom);
47
}
else
{
48
idxR = idxMid;
49
std::swap
(posR, pos);
50
std::swap
(momR, mom);
51
}
52
}
53
54
if
(idxL == 0) {
55
posL = intersections[0].position();
56
momL = intersections[0].momentum();
57
}
58
if
(idxR == (nPts - 1)) {
59
posR = intersections[nPts - 1].position();
60
momR = intersections[nPts - 1].momentum();
61
}
62
63
float
mag2L = (inputPos - posL).
mag2
();
64
float
mag2R = (inputPos - posR).
mag2
();
65
nearestIdx = (mag2L < mag2R) ? idxL : idxR;
66
nearestPos = (mag2L < mag2R) ? posL : posR;
67
nearestMom = (mag2L < mag2R) ? momL : momR;
68
}
69
}
// namespace Utils
M_PI
#define M_PI
Definition
ActiveFraction.h:14
mag2
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition
AmgMatrixBasePlugin.h:31
CaloCellSelectorUtils.h
Trk::CaloExtension
Tracking class to hold the extrapolation through calorimeter Layers Both the caloEntryLayerIntersecti...
Definition
TrkEvent/TrkCaloExtension/TrkCaloExtension/CaloExtension.h:19
Trk::CaloExtension::caloLayerIntersections
const std::vector< CurvilinearParameters > & caloLayerIntersections() const
access to the intersections with the calorimeter layers.
Definition
TrkEvent/TrkCaloExtension/TrkCaloExtension/CaloExtension.h:59
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
Utils
Definition
ProxyContainer.h:28
Utils::deltaR2
double deltaR2(double eta1, double eta2, double phi1, double phi2)
Definition
CaloCellSelectorUtils.cxx:17
Utils::deltaR
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition
CaloCellSelectorUtils.cxx:23
Utils::findNearestPoint
void findNearestPoint(const Amg::Vector3D &inputPos, const Trk::CaloExtension *caloExtension, int &nearestIdx, Amg::Vector3D &nearestPos, Amg::Vector3D &nearestMom)
Definition
CaloCellSelectorUtils.cxx:25
Utils::deltaPhi
double deltaPhi(double phi1, double phi2)
Definition
CaloCellSelectorUtils.cxx:11
dot
Definition
dot.py:1
std::swap
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
Definition
AthLinks/ElementLinkVector.h:484
Generated on
for ATLAS Offline Software by
1.17.0