ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetTruth
InDetTruthTools
src
PRD_TruthTrajectorySelectorID.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// PRD_TruthTrajectorySelectorID.cxx, (c) ATLAS Detector software
8
9
#include "
InDetTruthTools/PRD_TruthTrajectorySelectorID.h
"
10
#include "
InDetPrepRawData/SCT_Cluster.h
"
11
#include "
InDetPrepRawData/TRT_DriftCircle.h
"
12
#include "
InDetPrepRawData/PixelCluster.h
"
13
// DetectorDescription
14
#include "
AtlasDetDescr/AtlasDetectorID.h
"
15
// HepMC
16
#include "
AtlasHepMC/GenParticle.h
"
17
#include "
TruthUtils/MagicNumbers.h
"
18
19
20
InDet::PRD_TruthTrajectorySelectorID::PRD_TruthTrajectorySelectorID
(
const
std::string& t,
const
std::string& n,
const
IInterface* p) :
21
AthAlgTool
(t,n,p)
22
{
23
declareInterface<Trk::IPRD_TruthTrajectorySelector>(
this
);
24
}
25
26
StatusCode
InDet::PRD_TruthTrajectorySelectorID::initialize
() {
27
ATH_MSG_VERBOSE
(
"Initializing ..."
);
28
StatusCode
sc
=
detStore
()->retrieve(
m_atlasId
,
"AtlasID"
);
29
if
(
sc
.isFailure()) {
30
msg
(MSG::ERROR) <<
"Could not get AtlasID helper !"
<<
endmsg
;
31
return
StatusCode::FAILURE;
32
}
33
return
StatusCode::SUCCESS;
34
35
}
36
37
StatusCode
InDet::PRD_TruthTrajectorySelectorID::finalize
() {
38
ATH_MSG_VERBOSE
(
"Finalizing ..."
);
39
return
StatusCode::SUCCESS;
40
}
41
42
ThreePointCircle::ThreePointCircle
(
const
std::vector<Amg::Vector3D>& posVec) :
43
m_translation
(nullptr),
m_d0
(0.),
m_z0
(0.),
m_phi0
(0.),
m_eta
(0.),
m_pt
(0.)
44
{
45
if
(posVec.size() <3)
46
std::cout <<
"[WARNING] not enough points"
<< std::endl;
47
else
48
constructCircle
(posVec[0],posVec[1],posVec[2]);
49
}
50
51
ThreePointCircle::~ThreePointCircle
()
52
{
53
delete
m_translation
;
54
}
55
56
void
ThreePointCircle::constructCircle
(
const
Amg::Vector3D
& p1,
57
const
Amg::Vector3D
& p2,
58
const
Amg::Vector3D
& p3) {
59
60
// get the (x/y) coordinates of all points
61
double
translationX =
m_translation
? -(
m_translation
->translation()).x() : 0.;
62
double
translationY =
m_translation
? -(
m_translation
->translation()).y() : 0.;
63
64
double
bx = p1.x()+translationX;
65
double
by = p1.y()+translationY;
66
double
cx = p2.x()+translationX;
67
double
cy = p2.y()+translationY;
68
double
dx = p3.x()+translationX;
69
double
dy = p3.y()+translationY;
70
71
double
temp = cx*cx+cy*cy;
72
73
// prepare the matrix for the linear equation
74
double
bc = (bx*bx + by*by - temp)/2.0;
75
double
cd = (temp - dx*dx - dy*dy)/2.0;
76
double
det = (bx-cx)*(cy-dy)-(cx-dx)*(by-cy);
77
//if (std::abs(det) < 1.0e-6) {
78
//std::cout << "[WARNING] Determinant is close to 0 " << std::endl;
79
//}
80
81
// invert the determinant
82
det = 1./det;
83
84
// x / y coordinate of the center
85
double
cRx= (bc*(cy-dy)-cd*(by-cy))*det;
86
double
cRy = ((bx-cx)*cd-(cx-dx)*bc)*det;
87
88
// get the center, radius and momentum
89
m_center
=
Amg::Vector2D
(cRx,cRy);
90
m_radius
= sqrt((cRx-bx)*(cRx-bx)+(cRy-by)*(cRy-by));
91
m_pt
=
m_radius
*(0.3*2.);
92
93
// transverse parameters
94
m_d0
= std::sqrt(cRx*cRx+cRy*cRy)-
m_radius
;
95
96
// longitudinal parameters
97
double
theta
= 1./3*(p1.theta() + p2.theta() + p3.theta());
98
double
r1 = p1.perp();
99
double
z1 = p1.z();
100
double
deltaz = r1/tan(
theta
);
101
m_z0
= z1 - deltaz;
102
// eta
103
m_eta
= 1./3*(p1.eta() + p2.eta() + p3.eta());
104
105
// get the point of closest approach
106
Amg::Vector2D
poca = -
m_d0
*
m_center
.unit();
107
108
// find the closest measurement
109
Amg::Vector2D
closestMeasurement = p1.perp() < p2.perp() ?
110
Amg::Vector2D
(p1.x(),p1.y()) :
Amg::Vector2D
(p2.x(),p2.y());
111
if
(p3.perp() < p1.perp()) closestMeasurement =
Amg::Vector2D
(p3.x(),p3.y());
112
113
// phi0 is the most difficult one, two solution possible
114
Amg::Vector2D
directionOne(-cRy,cRx);
115
Amg::Vector2D
directionTwo(cRy,-cRx);
116
117
// build difference vector closest measurement, poca
118
Amg::Vector2D
toFirstMeas(closestMeasurement-poca);
119
120
// check with scalar product
121
m_phi0
= directionOne.dot(toFirstMeas) > 0. ? directionOne.phi() : directionTwo.phi();
122
123
// now sign d0
124
Amg::Vector3D
pocaDir(poca.x(),poca.y(),0.);
125
Amg::Vector3D
momDir(std::cos(
m_phi0
),std::sin(
m_phi0
),0.);
126
double
signD0 = pocaDir.cross(momDir).z() > 0. ? 1. : -1.;
127
m_d0
= signD0 * std::abs(
m_d0
);
128
129
// update the center for the translation
130
m_center
+=
Amg::Vector2D
(translationX,translationY);
131
132
}
133
134
bool
InDet::PRD_TruthTrajectorySelectorID::pass
(
const
Trk::PRD_TruthTrajectory
& prdvec)
const
{
135
136
std::vector<Amg::Vector3D> pos;
137
std::vector<const Trk::PrepRawData* >::const_iterator prdIter = prdvec.
prds
.begin();
138
std::vector<const Trk::PrepRawData* >::const_iterator prdIterE = prdvec.
prds
.end();
139
140
// look for 3 globalPositions for ThreePointCircle approximation
141
for
(
int
i = 0; i < 3 && prdIter != prdIterE; ++ prdIter ){
142
if
(
m_atlasId
->is_pixel((*prdIter)->identify()) ){
143
const
InDet::PixelCluster
* pixclus=
dynamic_cast<
const
InDet::PixelCluster
*
>
(*prdIter);
144
if
(pixclus) {
145
if
(!pos.empty() && (pos.back()-pixclus->
globalPosition
()).squaredNorm() < 9)
146
continue
;
147
pos.push_back (pixclus->
globalPosition
());
148
}
149
}
150
else
if
(
m_atlasId
->is_sct((*prdIter)->identify()) ){
151
const
InDet::SCT_Cluster
* sctclus=
dynamic_cast<
const
InDet::SCT_Cluster
*
>
(*prdIter);
152
if
(sctclus) {
153
if
(!pos.empty() && (pos.back()-sctclus->
globalPosition
()).squaredNorm() < 9)
154
continue
;
155
pos.push_back (sctclus->
globalPosition
());
156
}
157
}
158
else
if
(
m_atlasId
->is_trt((*prdIter)->identify()) ){
159
continue
;
160
}
161
i++;
162
}
163
164
// only take trajectory if enough hits
165
if
( pos.size() != 3 )
return
false
;
166
167
ThreePointCircle
circle(pos);
168
// trajectory only selected when within cuts
169
if
( ( std::abs(circle.
d0
()) <= 15 && !
HepMC::is_simulation_particle
(prdvec.
genParticle
) ))
return
true
;
170
171
return
false
;
172
}
theta
Scalar theta() const
theta method
Definition
AmgMatrixBasePlugin.h:75
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
GenParticle.h
PixelCluster.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
MagicNumbers.h
PRD_TruthTrajectorySelectorID.h
SCT_Cluster.h
TRT_DriftCircle.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
InDet::PRD_TruthTrajectorySelectorID::pass
virtual bool pass(const Trk::PRD_TruthTrajectory &) const
Interface method from IPRD_TruthTrajectorySelector.
Definition
PRD_TruthTrajectorySelectorID.cxx:134
InDet::PRD_TruthTrajectorySelectorID::PRD_TruthTrajectorySelectorID
PRD_TruthTrajectorySelectorID(const std::string &t, const std::string &n, const IInterface *p)
Definition
PRD_TruthTrajectorySelectorID.cxx:20
InDet::PRD_TruthTrajectorySelectorID::m_atlasId
const AtlasDetectorID * m_atlasId
ID pixel helper.
Definition
PRD_TruthTrajectorySelectorID.h:96
InDet::PRD_TruthTrajectorySelectorID::initialize
StatusCode initialize()
Definition
PRD_TruthTrajectorySelectorID.cxx:26
InDet::PRD_TruthTrajectorySelectorID::finalize
StatusCode finalize()
Definition
PRD_TruthTrajectorySelectorID.cxx:37
InDet::PixelCluster
Definition
InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
InDet::SCT_Cluster
Definition
SCT_Cluster.h:34
InDet::SiCluster::globalPosition
const Amg::Vector3D & globalPosition() const
return global position reference
ThreePointCircle
Definition
PRD_TruthTrajectorySelectorID.h:16
ThreePointCircle::d0
double d0() const
Definition
PRD_TruthTrajectorySelectorID.h:55
ThreePointCircle::m_translation
Amg::Translation3D * m_translation
Definition
PRD_TruthTrajectorySelectorID.h:47
ThreePointCircle::m_radius
double m_radius
Definition
PRD_TruthTrajectorySelectorID.h:50
ThreePointCircle::m_eta
double m_eta
Definition
PRD_TruthTrajectorySelectorID.h:49
ThreePointCircle::~ThreePointCircle
~ThreePointCircle()
Destructor.
Definition
PRD_TruthTrajectorySelectorID.cxx:51
ThreePointCircle::m_center
Amg::Vector2D m_center
Definition
PRD_TruthTrajectorySelectorID.h:51
ThreePointCircle::ThreePointCircle
ThreePointCircle(const std::vector< Amg::Vector3D > &vecPoints)
The constructor from three points.
Definition
PRD_TruthTrajectorySelectorID.cxx:42
ThreePointCircle::m_pt
double m_pt
Definition
PRD_TruthTrajectorySelectorID.h:49
ThreePointCircle::constructCircle
void constructCircle(const Amg::Vector3D &, const Amg::Vector3D &, const Amg::Vector3D &)
Definition
PRD_TruthTrajectorySelectorID.cxx:56
ThreePointCircle::m_z0
double m_z0
Definition
PRD_TruthTrajectorySelectorID.h:49
ThreePointCircle::m_phi0
double m_phi0
Definition
PRD_TruthTrajectorySelectorID.h:49
ThreePointCircle::m_d0
double m_d0
Definition
PRD_TruthTrajectorySelectorID.h:49
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition
GeoPrimitives.h:48
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
HepMC::is_simulation_particle
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
Definition
MagicNumbers.h:322
Trk::PRD_TruthTrajectory
simple definitiion of a PRD_TruhtTrajectory
Definition
PRD_TruthTrajectory.h:27
Trk::PRD_TruthTrajectory::prds
std::vector< const Trk::PrepRawData * > prds
public members
Definition
PRD_TruthTrajectory.h:30
Trk::PRD_TruthTrajectory::genParticle
HepMC::ConstGenParticlePtr genParticle
Definition
PRD_TruthTrajectory.h:31
Generated on
for ATLAS Offline Software by
1.17.0