ATLAS Offline Software
Loading...
Searching...
No Matches
IMuonSegmentInOverlapResolvingTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUON_IMUONSEGMENTSOVERLAPRESOLVINGTOOL_H
6#define MUON_IMUONSEGMENTSOVERLAPRESOLVINGTOOL_H
7
8#include <iostream>
9#include <string>
10#include <vector>
11
12#include "GaudiKernel/IAlgTool.h"
14
15namespace Trk {
16 class MeasurementBase;
17}
18
19namespace MuonGM {
21}
22
23namespace Muon {
24 class MuonSegment;
25
30 class IMuonSegmentInOverlapResolvingTool : virtual public IAlgTool {
31 public:
32 typedef std::vector<const Trk::MeasurementBase*> MeasVec;
33 typedef MeasVec::iterator MeasIt;
34 typedef MeasVec::const_iterator MeasCit;
35
38 SegmentPhiMatchResult(Amg::Vector3D segDir1, Amg::Vector3D segDir2, double dYZ) :
39 segmentDirection1(segDir1), segmentDirection2(segDir2), deltaYZ(dYZ) {}
40
43
46
48 double deltaYZ{-999.};
49
50 std::string toString() const;
51 };
52
55 bool hasMdt{false};
57 -999.,
58 };
61 double roPosInSegFrame{-999.};
62 double hvPosInSegFrame{-999.};
63
65 bool inBounds(double locPosX, double cut = 0.) {
66 double dist = distanceFromReadout(locPosX);
67 if (dist < -cut) return false;
68 if (dist > shortestChannelLength + cut) return false;
69 return true;
70 }
71
73 double positionInsideTube(double locPosX) {
74 if (inBounds(locPosX)) return locPosX;
75 double distFromRO = distanceFromReadout(locPosX);
76 if (distFromRO < 0.) return roPosInSegFrame;
77 return hvPosInSegFrame;
78 }
79
81 double distanceFromReadout(double locPosX) {
82 double dist = locPosX - roPosInSegFrame;
83 // if ro at large value than hv flip sign so that a positive dist is always in direction of the hv
84 if (roPosInSegFrame > hvPosInSegFrame) dist *= -1.;
85 return dist;
86 }
87
89 double distanceFromCenter(double locPosX) {
90 double dist = distanceFromReadout(locPosX) - 0.5 * shortestChannelLength;
91 return dist;
92 }
93
94 std::string toString() const;
95 };
96
99 SegmentPositionMatchResult(double distMin1, double distMinInTube1, double chLen1, double distMin2, double distMinInTube2,
100 double chLen2, double res, bool good, Amg::Vector3D pos) :
101 positionAlongTube1(distMin1),
102 positionInTube1(distMinInTube1),
103 channelLength1(chLen1),
104 positionAlongTube2(distMin2),
105 positionInTube2(distMinInTube2),
106 channelLength2(chLen2),
108 goodMatch(good),
109 segmentPosition(pos) {}
110
111 double positionAlongTube1{-999.}; // calculated new position along the tube in chamber of input segment
112 double positionInTube1{-999.}; // calculated new position in the tube in chamber of input segment
113 double channelLength1{-999.}; // the tube length of the shortest tube in chamber of input segment
114
115 double positionAlongTube2{-999.}; // calculated new position along the tube in chamber of second segment
116 double positionInTube2{-999.}; // calculated new position in the tube in chamber of second segment
117 double channelLength2{-999.}; // the tube length of the shortest tube in chamber of second segment
118
119 double positionResidual{-999.}; // residual of the segment positions in the precision plane of the second segment
120 bool goodMatch{false}; // flag to indicate problems during match
121 Amg::Vector3D segmentPosition{-999., -999., -999.}; // recalculated position of first segment
122
124 bool inBounds(double cut) {
125 if (fabs(positionAlongTube1 - positionInTube1) > cut) return false;
126 if (fabs(positionAlongTube2 - positionInTube2) > cut) return false;
127 return true;
128 }
129
130 std::string toString() const;
131 };
132
135 SegmentPhiMatchResult phiResult{}; // result of phi match
136 double angularDifferencePhi{-999}; // angular difference of the phi from phi match and the phi from the difference of the
137 // recalculate positions
138 double averagePhiHitPullSegment1{-999.}; // average pull of the phi hits on the first segment with the recalculated parameters
139 double averagePhiHitPullSegment2{-999.}; // average pull of the phi hits on the second segment with the recalculated parameters
140 SegmentPositionMatchResult segmentResult1{}; // result of recalculation of position of first segment
141 SegmentPositionMatchResult segmentResult2{}; // result of recalculation of position of second segment
142
143 bool goodMatch() const; // check whether matching was ok
144
145 std::string toString() const; // dump match result
146 };
147
148 public:
150 static const InterfaceID& interfaceID() {
151 static const InterfaceID IID_IMuonSegmentInOverlapResolvingTool("Muon::IMuonSegmentInOverlapResolvingTool", 1, 0);
152 return IID_IMuonSegmentInOverlapResolvingTool;
153 }
154
156 virtual SegmentMatchResult matchResult(const EventContext& ctx, const MuonSegment& seg1, const MuonSegment& seg2) const = 0;
157
162 const Amg::Vector3D& segDir1Min) const = 0;
163
166 virtual SegmentPhiMatchResult bestPhiMatch(const MuonSegment& seg1, const MuonSegment& seg2) const = 0;
167
169 virtual Amg::Vector3D updateSegmentDirection(const MuonSegment& seg, double phi) const = 0;
170
173
175 };
176
178 std::ostringstream sout;
179 sout << " Segment geometry: position ro " << roPosInSegFrame << " hv " << hvPosInSegFrame;
180 return sout.str();
181 }
182
184 std::ostringstream sout;
185 sout << " Matching angle phi " << segmentDirection1.phi() << " deltaYZ " << deltaYZ;
186 return sout.str();
187 }
188
190 std::ostringstream sout;
191 sout << " Segment chamber: ";
192 if (goodMatch)
193 sout << " position " << std::setw(5) << (int)positionAlongTube1 << " in tube " << std::setw(5) << (int)positionInTube1
194 << std::endl
195 << " Matching chamber: position " << std::setw(5) << (int)positionAlongTube2 << " in tube " << std::setw(5)
196 << (int)positionInTube2 << std::endl
197 << " position residual " << std::setw(5) << (int)positionResidual;
198 else
199 sout << "match failed";
200 return sout.str();
201 }
202
204 std::ostringstream sout;
205 if (goodMatch()) {
206 sout << phiResult.toString() << " dphi " << angularDifferencePhi << " phi Pull1 " << averagePhiHitPullSegment1 << " phi Pull2 "
207 << averagePhiHitPullSegment2 << " phi pos1 first " << segmentResult1.segmentPosition.phi() << " phi pos2 second "
208 << segmentResult2.segmentPosition.phi() << std::endl
209 << " segment1 " << segmentResult1.toString() << std::endl
210 << " segment " << segmentResult2.toString();
211 } else {
212 if (!segmentResult1.goodMatch)
213 sout << " Match of first segment failed";
214 else if (!segmentResult2.goodMatch)
215 sout << " Match of second segment failed";
216 else
217 sout << " unknown failure";
218 }
219 return sout.str();
220 }
221
223 return segmentResult1.goodMatch && segmentResult2.goodMatch;
224 }
225} // namespace Muon
226
227#endif
Scalar phi() const
phi method
std::pair< std::vector< unsigned int >, bool > res
static const InterfaceID & interfaceID()
access to tool interface
virtual Amg::Vector3D updateSegmentDirection(const MuonSegment &seg, double phi) const =0
recalculate the segment direction give a new angle phi, keeps the angle in the precision plane fixed
virtual SegmentGeometrySummary segmentGeometrySummary(const MuonSegment &seg) const =0
calculate geometrical information for a segment
std::vector< const Trk::MeasurementBase * > MeasVec
virtual SegmentPositionMatchResult bestPositionAlongTubeMatch(const MuonSegment &seg1, const MuonSegment &seg2, const Amg::Vector3D &segDir1Min) const =0
calculate the position along a tube direction of the first segment that results in the smallest posit...
virtual SegmentPhiMatchResult bestPhiMatch(const MuonSegment &seg1, const MuonSegment &seg2) const =0
calculate the angle phi for which the angular residual in the precision plane of the second segment i...
virtual SegmentMatchResult matchResult(const EventContext &ctx, const MuonSegment &seg1, const MuonSegment &seg2) const =0
performance match and return result
virtual ~IMuonSegmentInOverlapResolvingTool()=default
This is the common class for 3D segments used in the muon spectrometer.
This class is the pure abstract base class for all fittable tracking measurements.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the Athena extensions are properly loaded.
Definition GeoMuonHits.h:27
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Ensure that the ATLAS eigen extensions are properly loaded.
double distanceFromReadout(double locPosX)
distance to readout, positive axis towards hv side
double positionInsideTube(double locPosX)
checks wether the position is inside the range, if not returns the position inside the range closest ...
bool inBounds(double locPosX, double cut=0.)
check whether the position is inside the range
double distanceFromCenter(double locPosX)
distance to tube center, positive axis towards hv side
Amg::Vector3D segmentDirection2
new segment direction for second segment with the update phi angle
double deltaYZ
angular difference in the precision plane of the second segment after the phi angle correction
Amg::Vector3D segmentDirection1
new segment direction for first segment with the update phi angle
SegmentPhiMatchResult(Amg::Vector3D segDir1, Amg::Vector3D segDir2, double dYZ)
bool inBounds(double cut)
check whether the calculated segment position is consistent with the two chambers
SegmentPositionMatchResult(double distMin1, double distMinInTube1, double chLen1, double distMin2, double distMinInTube2, double chLen2, double res, bool good, Amg::Vector3D pos)