ATLAS Offline Software
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 
15 namespace Trk {
16  class MeasurementBase;
17 }
18 
19 namespace MuonGM {
20  class MdtReadoutElement;
21 }
22 
23 namespace Muon {
24  class MuonSegment;
25 
30  class IMuonSegmentInOverlapResolvingTool : virtual public IAlgTool {
31  public:
32  typedef std::vector<const Trk::MeasurementBase*> MeasVec;
34  typedef MeasVec::const_iterator MeasCit;
35 
37  SegmentPhiMatchResult() = default;
38  SegmentPhiMatchResult(Amg::Vector3D segDir1, Amg::Vector3D segDir2, double dYZ) :
39  segmentDirection1(segDir1), segmentDirection2(segDir2), deltaYZ(dYZ) {}
40 
42  Amg::Vector3D segmentDirection1{-999, -999, -999};
43 
45  Amg::Vector3D segmentDirection2{-999, -999, -999};
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 
134  SegmentMatchResult() = default;
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
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult::angularDifferencePhi
double angularDifferencePhi
Definition: IMuonSegmentInOverlapResolvingTool.h:136
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPhiMatchResult::segmentDirection1
Amg::Vector3D segmentDirection1
new segment direction for first segment with the update phi angle
Definition: IMuonSegmentInOverlapResolvingTool.h:42
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
Muon::IMuonSegmentInOverlapResolvingTool::MeasVec
std::vector< const Trk::MeasurementBase * > MeasVec
Definition: IMuonSegmentInOverlapResolvingTool.h:32
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::segmentPosition
Amg::Vector3D segmentPosition
Definition: IMuonSegmentInOverlapResolvingTool.h:121
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::channelLength1
double channelLength1
Definition: IMuonSegmentInOverlapResolvingTool.h:113
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::SegmentPositionMatchResult
SegmentPositionMatchResult()=default
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPhiMatchResult
Definition: IMuonSegmentInOverlapResolvingTool.h:36
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::hvPosInSegFrame
double hvPosInSegFrame
Definition: IMuonSegmentInOverlapResolvingTool.h:62
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::shortestChannelLength
double shortestChannelLength
Definition: IMuonSegmentInOverlapResolvingTool.h:56
Muon::IMuonSegmentInOverlapResolvingTool::~IMuonSegmentInOverlapResolvingTool
virtual ~IMuonSegmentInOverlapResolvingTool()=default
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPhiMatchResult::toString
std::string toString() const
Definition: IMuonSegmentInOverlapResolvingTool.h:183
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::distanceFromReadout
double distanceFromReadout(double locPosX)
distance to readout, positive axis towards hv side
Definition: IMuonSegmentInOverlapResolvingTool.h:81
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult::goodMatch
bool goodMatch() const
Definition: IMuonSegmentInOverlapResolvingTool.h:222
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult::SegmentMatchResult
SegmentMatchResult()=default
Muon::IMuonSegmentInOverlapResolvingTool::matchResult
virtual SegmentMatchResult matchResult(const EventContext &ctx, const MuonSegment &seg1, const MuonSegment &seg2) const =0
performance match and return result
Muon::IMuonSegmentInOverlapResolvingTool
tool to match segments
Definition: IMuonSegmentInOverlapResolvingTool.h:30
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::positionInsideTube
double positionInsideTube(double locPosX)
checks wether the position is inside the range, if not returns the position inside the range closest ...
Definition: IMuonSegmentInOverlapResolvingTool.h:73
xAOD::MuonSegment
MuonSegment_v1 MuonSegment
Reference the current persistent version:
Definition: Event/xAOD/xAODMuon/xAODMuon/MuonSegment.h:13
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult::phiResult
SegmentPhiMatchResult phiResult
Definition: IMuonSegmentInOverlapResolvingTool.h:135
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult::segmentResult2
SegmentPositionMatchResult segmentResult2
Definition: IMuonSegmentInOverlapResolvingTool.h:141
GeoPrimitives.h
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::hasMdt
bool hasMdt
Definition: IMuonSegmentInOverlapResolvingTool.h:55
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::segToGlobal
Amg::Transform3D segToGlobal
Definition: IMuonSegmentInOverlapResolvingTool.h:60
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPhiMatchResult::deltaYZ
double deltaYZ
angular difference in the precision plane of the second segment after the phi angle correction
Definition: IMuonSegmentInOverlapResolvingTool.h:48
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:50
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult::averagePhiHitPullSegment2
double averagePhiHitPullSegment2
Definition: IMuonSegmentInOverlapResolvingTool.h:139
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary
Definition: IMuonSegmentInOverlapResolvingTool.h:53
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::SegmentPositionMatchResult
SegmentPositionMatchResult(double distMin1, double distMinInTube1, double chLen1, double distMin2, double distMinInTube2, double chLen2, double res, bool good, Amg::Vector3D pos)
Definition: IMuonSegmentInOverlapResolvingTool.h:99
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::distanceFromCenter
double distanceFromCenter(double locPosX)
distance to tube center, positive axis towards hv side
Definition: IMuonSegmentInOverlapResolvingTool.h:89
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult::toString
std::string toString() const
Definition: IMuonSegmentInOverlapResolvingTool.h:203
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::roPosInSegFrame
double roPosInSegFrame
Definition: IMuonSegmentInOverlapResolvingTool.h:61
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::positionInTube1
double positionInTube1
Definition: IMuonSegmentInOverlapResolvingTool.h:112
Muon::IMuonSegmentInOverlapResolvingTool::MeasCit
MeasVec::const_iterator MeasCit
Definition: IMuonSegmentInOverlapResolvingTool.h:34
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPhiMatchResult::SegmentPhiMatchResult
SegmentPhiMatchResult(Amg::Vector3D segDir1, Amg::Vector3D segDir2, double dYZ)
Definition: IMuonSegmentInOverlapResolvingTool.h:38
Muon::IMuonSegmentInOverlapResolvingTool::segmentGeometrySummary
virtual SegmentGeometrySummary segmentGeometrySummary(const MuonSegment &seg) const =0
calculate geometrical information for a segment
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::detEl
const MuonGM::MdtReadoutElement * detEl
Definition: IMuonSegmentInOverlapResolvingTool.h:54
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult
Definition: IMuonSegmentInOverlapResolvingTool.h:97
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult::segmentResult1
SegmentPositionMatchResult segmentResult1
Definition: IMuonSegmentInOverlapResolvingTool.h:140
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::toString
std::string toString() const
Definition: IMuonSegmentInOverlapResolvingTool.h:189
Muon::IMuonSegmentInOverlapResolvingTool::bestPositionAlongTubeMatch
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...
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::IMuonSegmentInOverlapResolvingTool::updateSegmentDirection
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
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::toString
std::string toString() const
Definition: IMuonSegmentInOverlapResolvingTool.h:177
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPhiMatchResult::SegmentPhiMatchResult
SegmentPhiMatchResult()=default
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Muon::IMuonSegmentInOverlapResolvingTool::interfaceID
static const InterfaceID & interfaceID()
access to tool interface
Definition: IMuonSegmentInOverlapResolvingTool.h:150
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult::averagePhiHitPullSegment1
double averagePhiHitPullSegment1
Definition: IMuonSegmentInOverlapResolvingTool.h:138
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::inBounds
bool inBounds(double locPosX, double cut=0.)
check whether the position is inside the range
Definition: IMuonSegmentInOverlapResolvingTool.h:65
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::positionAlongTube1
double positionAlongTube1
Definition: IMuonSegmentInOverlapResolvingTool.h:111
ReadBchFromCool.good
good
Definition: ReadBchFromCool.py:433
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::positionInTube2
double positionInTube2
Definition: IMuonSegmentInOverlapResolvingTool.h:116
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::positionAlongTube2
double positionAlongTube2
Definition: IMuonSegmentInOverlapResolvingTool.h:115
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::channelLength2
double channelLength2
Definition: IMuonSegmentInOverlapResolvingTool.h:117
Muon::IMuonSegmentInOverlapResolvingTool::SegmentMatchResult
Definition: IMuonSegmentInOverlapResolvingTool.h:133
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPhiMatchResult::segmentDirection2
Amg::Vector3D segmentDirection2
new segment direction for second segment with the update phi angle
Definition: IMuonSegmentInOverlapResolvingTool.h:45
Muon::IMuonSegmentInOverlapResolvingTool::MeasIt
MeasVec::iterator MeasIt
Definition: IMuonSegmentInOverlapResolvingTool.h:33
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::goodMatch
bool goodMatch
Definition: IMuonSegmentInOverlapResolvingTool.h:120
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::inBounds
bool inBounds(double cut)
check whether the calculated segment position is consistent with the two chambers
Definition: IMuonSegmentInOverlapResolvingTool.h:124
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
Muon::IMuonSegmentInOverlapResolvingTool::SegmentGeometrySummary::globalToSeg
Amg::Transform3D globalToSeg
Definition: IMuonSegmentInOverlapResolvingTool.h:59
Muon::IMuonSegmentInOverlapResolvingTool::bestPhiMatch
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...
Muon::IMuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult::positionResidual
double positionResidual
Definition: IMuonSegmentInOverlapResolvingTool.h:119