ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCalib::LocalSegmentResolver Class Reference

Class calculates the local position and direction of the segment using the hits on track. More...

#include <LocalSegmentResolver.h>

Collaboration diagram for MuonCalib::LocalSegmentResolver:

Public Member Functions

 LocalSegmentResolver ()
 constructor
bool resolve (MuonCalibSegment *seg) const
 resolve local position and direction of the track segment
void setPrintLevel (int level)
 set print level

Private Types

typedef MuonCalibSegment::MdtHitVec HitVec
typedef std::pair< Amg::Vector3D, Amg::Vector3DLine
typedef std::vector< LineLineVec

Private Member Functions

LineVec getLines (const MdtCalibHitBase &firstHit, const MdtCalibHitBase &lastHit) const
int bestLine (const HitVec &hits, const LineVec &localTracks) const

Private Attributes

int m_printLevel
 print level

Detailed Description

Class calculates the local position and direction of the segment using the hits on track.

Author
Niels.nosp@m..Van.nosp@m..Eldi.nosp@m.k@ce.nosp@m.rn.ch

Definition at line 32 of file LocalSegmentResolver.h.

Member Typedef Documentation

◆ HitVec

◆ Line

Definition at line 45 of file LocalSegmentResolver.h.

◆ LineVec

typedef std::vector<Line> MuonCalib::LocalSegmentResolver::LineVec
private

Definition at line 46 of file LocalSegmentResolver.h.

Constructor & Destructor Documentation

◆ LocalSegmentResolver()

MuonCalib::LocalSegmentResolver::LocalSegmentResolver ( )

constructor

Definition at line 16 of file LocalSegmentResolver.cxx.

Member Function Documentation

◆ bestLine()

int MuonCalib::LocalSegmentResolver::bestLine ( const HitVec & hits,
const LineVec & localTracks ) const
private

Definition at line 186 of file LocalSegmentResolver.cxx.

186 {
187 // loop over tangent lines
188 LineVec::const_iterator lit = localTracks.begin();
189 LineVec::const_iterator lit_end = localTracks.end();
190
191 // look for line with smallest residual sum
192 double ressummin = 1e20;
193 unsigned int resnum = 0;
194
195 for (; lit != lit_end; ++lit) {
196 double ressum = 0;
197
198 // calculate angle between line and z precision plane
199 double alpha = std::atan2(lit->second.y(), lit->second.x());
200
201 // get rotations in track frame
202 Amg::AngleAxis3D rotationAroundZ(-alpha, Amg::Vector3D::UnitZ());
203 // Amg::AngleAxis3D rotationAroundZ_inv(alpha,Amg::Vector3D::UnitZ());
204
205 // rotate position on track into track frame
206 Amg::Vector3D avePosTrk = rotationAroundZ * lit->first;
207
208 if (m_printLevel >= 1) {
209 Amg::Vector3D lTrkDir = rotationAroundZ * lit->second;
210 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
211 log << MSG::VERBOSE << " angle " << alpha * 57.32 << " trk dir in trk frame " << lTrkDir << " pos " << avePosTrk
212 << endmsg;
213 }
214 // loop over local hits
215 LocalSegmentResolver::HitVec::const_iterator it = hits.begin();
216 LocalSegmentResolver::HitVec::const_iterator it_end = hits.end();
217 for (; it != it_end; ++it) {
218 // rotate into track system
219 Amg::Vector3D spos = MuonCalib::LocalToPrecision::precision((*it)->localPosition());
220 Amg::Vector3D sposAve = rotationAroundZ * spos - avePosTrk;
221
222 // get drift radius (unsigned)
223 double r = std::abs((*it)->driftRadius());
224
225 // calculate residual and pull
226 double res = r - std::abs(sposAve.y());
227
228 if (m_printLevel >= 1) {
229 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
230 log << MSG::VERBOSE << " r " << r << " r_trk " << std::abs(sposAve.y()) << " residual " << res << endmsg;
231 }
232
233 ressum += res * res;
234 }
235
236 if (m_printLevel >= 3) {
237 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
238 log << MSG::INFO << " line " << lit - localTracks.begin() << " residual sum " << ressum << endmsg;
239 }
240 if (ressum < ressummin) {
241 ressummin = ressum;
242 resnum = lit - localTracks.begin();
243 }
244 }
245
246 if (m_printLevel >= 3) {
247 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
248 log << MSG::INFO << " Done selected line: ressum " << ressummin << " ## " << resnum << endmsg;
249 log << MSG::INFO << " Position " << localTracks[resnum].first << " direction " << localTracks[resnum].second << endmsg;
250 }
251 if (resnum >= localTracks.size()) {
252 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
253 log << MSG::WARNING << "wrong line index" << endmsg;
254 return -1;
255 }
256
257 return resnum;
258 }
#define endmsg
std::pair< std::vector< unsigned int >, bool > res
static Amg::Vector3D precision(const Amg::Vector3D &p)
int r
Definition globals.cxx:22
Eigen::AngleAxisd AngleAxis3D
Eigen::Matrix< double, 3, 1 > Vector3D
IMessageSvc * getMessageSvc(bool quiet=false)

◆ getLines()

LocalSegmentResolver::LineVec MuonCalib::LocalSegmentResolver::getLines ( const MdtCalibHitBase & firstHit,
const MdtCalibHitBase & lastHit ) const
private

Definition at line 50 of file LocalSegmentResolver.cxx.

50 {
51 Amg::Vector3D hpos1 = MuonCalib::LocalToPrecision::precision(firstHit.localPosition());
52 double x1 = hpos1.x();
53 double y1 = hpos1.y();
54 double r1 = std::abs(firstHit.driftRadius());
55 Amg::Vector3D hpos2 = MuonCalib::LocalToPrecision::precision(lastHit.localPosition());
56 double x2 = hpos2.x();
57 double y2 = hpos2.y();
58 double r2 = std::abs(lastHit.driftRadius());
59
60 double DeltaX = x2 - x1;
61 double DeltaY = y2 - y1;
62 double DistanceOfCenters = std::hypot(DeltaX, DeltaY);
63 double Alpha0 = std::atan2(DeltaY, DeltaX);
64
65 LineVec list_of_lines;
66
67 if (m_printLevel >= 1) {
68 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
69 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: calculating Lines (" << x1 << "," << y1 << ") " << r1 << " ("
70 << x2 << "," << y2 << ") " << r2 << endmsg;
71 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: general dir " << (hpos2 - hpos1).unit()
72 << " calculated : " << Amg::Vector3D(std::cos(Alpha0), std::sin(Alpha0), 0.) << endmsg;
73 }
74
75 // Case of 0 drift distances, only 1 line
76 if (r1 == 0. && r2 == 0.) {
77 Amg::Vector3D pos = hpos1;
78 Amg::Vector3D dir(std::cos(Alpha0), std::sin(Alpha0), 0);
79 if (m_printLevel >= 1) {
80 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
81 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: line pos " << pos << " dir " << dir << endmsg;
82 }
83 list_of_lines.push_back(std::make_pair(pos, dir));
84 return list_of_lines;
85 }
86
87 // Here are the first 2 "inner" lines ....
88 double RSum = r1 + r2;
89 double Alpha1 = std::asin(RSum / DistanceOfCenters);
90
91 double line_phi = Alpha0 + Alpha1;
92
93 Amg::Vector3D pos1(x1 + r1 * std::sin(line_phi), y1 - r1 * std::cos(line_phi), 0.);
94 Amg::Vector3D dir1(std::cos(line_phi), std::sin(line_phi), 0.);
95
96 if (m_printLevel >= 1) {
97 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
98 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: line pos " << pos1 << " dir " << dir1 << endmsg;
99 }
100
101 list_of_lines.push_back(std::make_pair(pos1, dir1));
102
103 line_phi = Alpha0 - Alpha1;
104
105 Amg::Vector3D pos2(x1 - r1 * std::sin(line_phi), y1 + r1 * std::cos(line_phi), 0.);
106 Amg::Vector3D dir2(std::cos(line_phi), std::sin(line_phi), 0.);
107
108 if (m_printLevel >= 1) {
109 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
110 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: line pos " << pos2 << " dir " << dir2 << endmsg;
111 }
112
113 list_of_lines.push_back(std::make_pair(pos2, dir2));
114
115 // Case where one of the drifts is 0 ==> Only two lines
116 if (r1 == 0. || r2 == 0.) return list_of_lines;
117
118 // ... and here are the other 2 "outer" lines
119 double DeltaR = std::abs(r2 - r1);
120 double Alpha2 = std::asin(DeltaR / DistanceOfCenters);
121
122 if (r1 < r2) {
123 if (m_printLevel >= 1) {
124 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
125 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: r1 < r2" << endmsg;
126 }
127
128 line_phi = Alpha0 + Alpha2;
129
130 Amg::Vector3D pos3(x1 - r1 * std::sin(line_phi), y1 + r1 * std::cos(line_phi), 0.);
131 Amg::Vector3D dir3(std::cos(line_phi), std::sin(line_phi), 0.);
132
133 if (m_printLevel >= 1) {
134 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
135 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: line pos " << pos3 << " dir " << dir3 << endmsg;
136 }
137
138 list_of_lines.push_back(std::make_pair(pos3, dir3));
139
140 line_phi = Alpha0 - Alpha2;
141
142 Amg::Vector3D pos4(x1 + r1 * std::sin(line_phi), y1 - r1 * std::cos(line_phi), 0.);
143 Amg::Vector3D dir4(std::cos(line_phi), std::sin(line_phi), 0.);
144
145 if (m_printLevel >= 1) {
146 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
147 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: line pos " << pos4 << " dir " << dir4 << endmsg;
148 }
149
150 list_of_lines.push_back(std::make_pair(pos4, dir4));
151
152 } else {
153 if (m_printLevel >= 1) {
154 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
155 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: r1 > r2" << endmsg;
156 }
157
158 line_phi = Alpha0 + Alpha2;
159
160 Amg::Vector3D pos3(x1 + r1 * std::sin(line_phi), y1 - r1 * std::cos(line_phi), 0.);
161 Amg::Vector3D dir3(std::cos(line_phi), std::sin(line_phi), 0.);
162
163 if (m_printLevel >= 1) {
164 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
165 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: line pos " << pos3 << " dir " << dir3 << endmsg;
166 }
167
168 list_of_lines.push_back(std::make_pair(pos3, dir3));
169
170 line_phi = Alpha0 - Alpha2;
171
172 Amg::Vector3D pos4(x1 - r1 * std::sin(line_phi), y1 + r1 * std::cos(line_phi), 0.);
173 Amg::Vector3D dir4(std::cos(line_phi), std::sin(line_phi), 0.);
174
175 if (m_printLevel >= 1) {
176 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
177 log << MSG::VERBOSE << "LocalSegmentResolver::getLines: line pos " << pos4 << " dir " << dir4 << endmsg;
178 }
179
180 list_of_lines.push_back(std::make_pair(pos4, dir4));
181 }
182
183 return list_of_lines;
184 }
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.

◆ resolve()

bool MuonCalib::LocalSegmentResolver::resolve ( MuonCalibSegment * seg) const

resolve local position and direction of the track segment

Definition at line 18 of file LocalSegmentResolver.cxx.

18 {
19 if (!seg) {
20 if (m_printLevel >= 1) {
21 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
22 log << MSG::VERBOSE << "LocalSegmentResolver::resolve: <got nullptr>" << endmsg;
23 }
24 return false;
25 }
26 if (seg->mdtHitsOnTrack() < 2) {
27 if (m_printLevel >= 1) {
28 MsgStream log(Athena::getMessageSvc(), "LocalSegmentResolver");
29 log << MSG::VERBOSE << "LocalSegmentResolver::resolve: <to few hits, cannot resolve direction>" << endmsg;
30 }
31 return false;
32 }
33
34 // get tangent lines
35 LineVec lines = getLines(*seg->mdtHOT().front(), *seg->mdtHOT().back());
36
37 // find line which yields smallest residuals
38 int lineIndex = bestLine(seg->mdtHOT(), lines);
39
40 // check if everything went right
41 if (lineIndex < 0) return false;
42
43 // reset local position and direction of segment
44 seg->set(seg->chi2(), MuonCalib::LocalToPrecision::local(lines[lineIndex].first),
45 MuonCalib::LocalToPrecision::local(lines[lineIndex].second));
46
47 return true;
48 }
int bestLine(const HitVec &hits, const LineVec &localTracks) const
LineVec getLines(const MdtCalibHitBase &firstHit, const MdtCalibHitBase &lastHit) const
static Amg::Vector3D local(const Amg::Vector3D &p)

◆ setPrintLevel()

void MuonCalib::LocalSegmentResolver::setPrintLevel ( int level)
inline

set print level

Definition at line 41 of file LocalSegmentResolver.h.

Member Data Documentation

◆ m_printLevel

int MuonCalib::LocalSegmentResolver::m_printLevel
private

print level

Definition at line 54 of file LocalSegmentResolver.h.


The documentation for this class was generated from the following files: