ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::MuonSegmentInOverlapResolvingTool Class Reference

tool to match segments More...

#include <MuonSegmentInOverlapResolvingTool.h>

Inheritance diagram for Muon::MuonSegmentInOverlapResolvingTool:
Collaboration diagram for Muon::MuonSegmentInOverlapResolvingTool:

Public Types

typedef std::vector< const Trk::MeasurementBase * > MeasVec
typedef MeasVec::iterator MeasIt
typedef MeasVec::const_iterator MeasCit

Public Member Functions

 MuonSegmentInOverlapResolvingTool (const std::string &, const std::string &, const IInterface *)
 constructor
virtual ~MuonSegmentInOverlapResolvingTool ()
 destructor
StatusCode initialize ()
 AlgTool initilize.
SegmentMatchResult matchResult (const EventContext &ctx, const MuonSegment &seg1, const MuonSegment &seg2) const
 performance match and return result
SegmentPositionMatchResult bestPositionAlongTubeMatch (const MuonSegment &seg1, const MuonSegment &seg2, const Amg::Vector3D &segDir1Min) const
 calculate the position along a tube direction of the first segment that results in the smallest position residual in the precision plane of the second segment given the segment direction for segment 1 in global coordinates
SegmentPhiMatchResult bestPhiMatch (const MuonSegment &seg1, const MuonSegment &seg2) const
 calculate the angle phi for which the angular residual in the precision plane of the second segment is zero
SegmentPhiMatchResult bestPhiMatchAnalytic (const MuonSegment &seg1, const MuonSegment &seg2) const
 calculate the angle phi for which the angular residual in the precision plane of the second segment is zero
Amg::Vector3D updateSegmentDirection (const MuonSegment &seg, double phi) const
 recalculate the segment direction give a new angle phi, keeps the angle in the precision plane fixed
SegmentGeometrySummary segmentGeometrySummary (const MuonSegment &seg) const
 calculate geometrical information for a segment
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 access to tool interface

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

double checkPhiHitConsistency (const EventContext &ctx, const Muon::MuonSegment &segment, SegmentPhiMatchResult &phiMatchResult, SegmentPositionMatchResult &matchResult) const
 compare phi hits with segment parameters, return average pull of the phi hits
Amg::Vector3D estimateSegmentDirection (const MuonSegment &seg1, const MuonSegment &seg2, double &phi, double &stereoangle) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc
ServiceHandle< IMuonEDMHelperSvcm_edmHelperSvc
 EDM Helper tool.
PublicToolHandle< MuonEDMPrinterToolm_printer
 EDM printer tool.
ToolHandle< Trk::IPropagatorm_propagator
ToolHandle< Trk::IResidualPullCalculatorm_pullCalculator
Trk::MagneticFieldProperties m_magFieldProperties
 magnetic field properties
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

tool to match segments

Definition at line 41 of file MuonSegmentInOverlapResolvingTool.h.

Member Typedef Documentation

◆ MeasCit

typedef MeasVec::const_iterator Muon::IMuonSegmentInOverlapResolvingTool::MeasCit
inherited

Definition at line 34 of file IMuonSegmentInOverlapResolvingTool.h.

◆ MeasIt

typedef MeasVec::iterator Muon::IMuonSegmentInOverlapResolvingTool::MeasIt
inherited

Definition at line 33 of file IMuonSegmentInOverlapResolvingTool.h.

◆ MeasVec

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MuonSegmentInOverlapResolvingTool()

Muon::MuonSegmentInOverlapResolvingTool::MuonSegmentInOverlapResolvingTool ( const std::string & ty,
const std::string & na,
const IInterface * pa )

constructor

Definition at line 20 of file MuonSegmentInOverlapResolvingTool.cxx.

23{
24 declareInterface<IMuonSegmentInOverlapResolvingTool>(this);
25}
AthAlgTool()
Default constructor:
Trk::MagneticFieldProperties m_magFieldProperties
magnetic field properties
@ NoField
Field is set to 0., 0., 0.,.

◆ ~MuonSegmentInOverlapResolvingTool()

virtual Muon::MuonSegmentInOverlapResolvingTool::~MuonSegmentInOverlapResolvingTool ( )
inlinevirtual

destructor

Definition at line 47 of file MuonSegmentInOverlapResolvingTool.h.

47{};

Member Function Documentation

◆ bestPhiMatch()

MuonSegmentInOverlapResolvingTool::SegmentPhiMatchResult Muon::MuonSegmentInOverlapResolvingTool::bestPhiMatch ( const MuonSegment & seg1,
const MuonSegment & seg2 ) const
virtual

calculate the angle phi for which the angular residual in the precision plane of the second segment is zero

Implements Muon::IMuonSegmentInOverlapResolvingTool.

Definition at line 275 of file MuonSegmentInOverlapResolvingTool.cxx.

276{
277
278 unsigned int nbins = 11;
279 // unsigned int bestBin = 0;
280 double scanRange = 1.;
281 double scanStep = scanRange / (nbins - 1);
282 double phiStart = seg1.globalDirection().phi() - 0.5 * scanRange;
283
284 double dthetaMin = 1e9;
285 Amg::Vector3D segDir1Min = seg1.globalDirection();
286 Trk::LocalDirection segLocDir2;
288 for (unsigned int i = 0; i < nbins; ++i) {
289 double phi = phiStart + scanStep * i;
291 Trk::LocalDirection segLocDir12;
292 seg2.associatedSurface().globalToLocalDirection(segDir1, segLocDir12);
293 double dyz = std::abs(segLocDir12.angleYZ() - segLocDir2.angleYZ());
294 if (dyz < dthetaMin) {
295 dthetaMin = dyz;
296 segDir1Min = segDir1;
297 // bestBin = i;
298 }
299 }
300 return {segDir1Min, updateSegmentDirection(seg2, segDir1Min.phi()), dthetaMin};
301}
Scalar phi() const
phi method
virtual const Trk::PlaneSurface & associatedSurface() const override final
returns the surface for the local to global transformation
Amg::Vector3D updateSegmentDirection(const MuonSegment &seg, double phi) const
recalculate the segment direction give a new angle phi, keeps the angle in the precision plane fixed
double angleYZ() const
access method for angle of local YZ projection
void globalToLocalDirection(const Amg::Vector3D &glodir, Trk::LocalDirection &locdir) const
This method transforms the global direction to a local direction wrt the plane.
Eigen::Matrix< double, 3, 1 > Vector3D

◆ bestPhiMatchAnalytic()

MuonSegmentInOverlapResolvingTool::SegmentPhiMatchResult Muon::MuonSegmentInOverlapResolvingTool::bestPhiMatchAnalytic ( const MuonSegment & seg1,
const MuonSegment & seg2 ) const

calculate the angle phi for which the angular residual in the precision plane of the second segment is zero

Definition at line 194 of file MuonSegmentInOverlapResolvingTool.cxx.

195{
196
197 //
198 // From two segments the direction and position of the segments are determined
199 // assuming a straight line
200 //
201 // if a stereoangle is present one can determine: phi and x local for both segments
202 //
203
204 // bool check = false;
205
206 // Confusing use of objects:
207 // Trk::GlobalDirection can and will hold a 3D LOCAL direction
208 // Trk::GlobalPositionn can and will hold a 3D LOCAL position
209 // This is needed because otherwise the Amg::Transform3D DOES NOT know
210 // whether it transforms a position or a direction
211 //
212 const Amg::Transform3D& gToGlobal1 = seg1.associatedSurface().transform();
213 const Amg::Transform3D& gToGlobal2 = seg2.associatedSurface().transform();
214 Amg::Transform3D gToLocal1 = seg1.associatedSurface().transform().inverse();
215 // Amg::Transform3D gToLocal2 = seg2.associatedSurface().transform().inverse();
216 //
217 const Amg::Vector3D& gDir1 = seg1.globalDirection();
218 const Amg::Vector3D& gDir2 = seg2.globalDirection();
219 // Confusing but Amg::Vector3D can hold a 3D local direction
220 Amg::Vector3D lDir1 = gToLocal1.linear() * gDir1;
221 // Amg::Vector3D lDir2 = gToLocal2.linear()*gDir2;
222 // segment 2 local direction in frame of segment 1
223 Amg::Vector3D lDir12 = gToLocal1.linear() * gDir2;
224 // Amg::Vector3D lDir21 = gToLocal2.linear()*gDir1;
225
226 Amg::Vector3D segLocDiro(1., 0., 0.);
227 // orthogonal vector to segment 2 in local frame of segment 1
228 Amg::Vector3D lDiro12 = gToLocal1.linear() * (gToGlobal2.linear() * segLocDiro);
229 // orthogonal vector to segment 1in local frame of segment 2
230 // Amg::Vector3D lDiro21 = gToLocal2.linear()*(gToGlobal1.linear()*segLocDiro);
231
232 // stereoangle = acos(lDiro12.x());
233
234 // We have the following equations for segment 2 in local frame of segment 1
235 // dx1 = free
236 // dy1 = lDir1.y() = a * lDir12.y() + b * lDiro12.y()
237 // dz1 = lDir1.z() = a * lDir12.z() + b * lDiro12.z()
238
239 double b = lDir1.y() * lDir12.z() - lDir1.z() * lDir12.y();
240 double a = lDir1.y() * lDiro12.z() - lDir1.z() * lDiro12.y();
241 double dxn = lDir12.x();
242 double dyn = lDir12.y();
243 double dzn = lDir12.z();
244 if (std::abs(a) > 1e-2) {
245 dxn = lDir12.x() - b * lDiro12.x() / a;
246 dyn = lDir12.y() - b * lDiro12.y() / a;
247 dzn = lDir12.z() - b * lDiro12.z() / a;
248 }
249 double norm = std::hypot(dxn, dyn, dzn);
250 if (norm < 1e-6) {
251 ATH_MSG_DEBUG(" Unexpected normalisation " << norm);
252 norm = 1e-6;
253 }
254 if (dxn * lDir1.x() + dyn * lDir1.y() + dzn * lDir1.z() < 0) norm = -norm;
255 dxn = dxn / norm;
256 dyn = dyn / norm;
257 dzn = dzn / norm;
258
259 // The final result for the direction of the two segments
260
261 // New Local direction of segment 1
262 Amg::Vector3D lDirn1(dxn, dyn, dzn);
263 // Global direction of both segments
264 Amg::Vector3D segDir1Min = gToGlobal1.linear() * lDirn1;
265 const Amg::Vector3D& segDir2Min = segDir1Min; // updateSegmentDirection(seg2,segDir1Min.phi());
266 Trk::LocalDirection segLocDir1;
267 seg2.associatedSurface().globalToLocalDirection(segDir1Min, segLocDir1);
268 Trk::LocalDirection segLocDir2;
269 seg2.associatedSurface().globalToLocalDirection(segDir2Min, segLocDir2);
270 double dyz = std::abs(segLocDir1.angleYZ() - segLocDir2.angleYZ());
271 return {segDir1Min, segDir2Min, dyz};
272}
#define ATH_MSG_DEBUG(x)
static Double_t a
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Eigen::Affine3d Transform3D

◆ bestPositionAlongTubeMatch()

MuonSegmentInOverlapResolvingTool::SegmentPositionMatchResult Muon::MuonSegmentInOverlapResolvingTool::bestPositionAlongTubeMatch ( const MuonSegment & seg1,
const MuonSegment & seg2,
const Amg::Vector3D & segDir1Min ) const
virtual

calculate the position along a tube direction of the first segment that results in the smallest position residual in the precision plane of the second segment given the segment direction for segment 1 in global coordinates

Implements Muon::IMuonSegmentInOverlapResolvingTool.

Definition at line 305 of file MuonSegmentInOverlapResolvingTool.cxx.

307{
308 bool goodMatch = true;
309
310 // get geomtry summary for segment
311 SegmentGeometrySummary segmentGeometry = segmentGeometrySummary(seg1);
312 SegmentGeometrySummary segmentGeometry2 = segmentGeometrySummary(seg2);
313
314 int nbins = 2;
315 double tubeStep = segmentGeometry.hvPosInSegFrame - segmentGeometry.roPosInSegFrame;
316
317 double posStep = tubeStep / (nbins - 1);
318
319 double resfirst{1e9}, reslast{1e9}, posfirst{1e9}, poslast{1e9};
320 double locy = seg1.localParameters().contains(Trk::locY) ? seg1.localParameters()[Trk::locY] : 0.;
321
322 for (int j = 0; j < nbins; ++j) {
323 double distToRO = segmentGeometry.roPosInSegFrame + posStep * j;
324
325 // create local position
326 Amg::Vector2D lpos(distToRO, locy);
327
328 // segment reference surface
329 const Trk::PlaneSurface& segmentSurface = seg2.associatedSurface();
330
331 // get global position
332 Amg::Vector3D gpos;
333 seg1.associatedSurface().localToGlobal(lpos, segDir1Min, gpos);
334
335 // calculate intersection
336 Trk::Intersection intersect = segmentSurface.straightLineIntersection(gpos, segDir1Min, false, false);
337 if (!intersect.valid || !segmentSurface.globalToLocal(intersect.position, segDir1Min, lpos)) {
338 // if( !intersect.valid || !segmentSurface.globalToLocal(intersect.intersection,segDir1Min,lpos) ){
339 ATH_MSG_WARNING(" Intersect with surface position " << Amg::toString(gpos) << " direction: phi "
340 << segDir1Min.phi() << " theta "
341 << segDir1Min.theta());
342 } else {
343
344 // now we have the prediction of the track in the segment frame, lets look at residuals
345 double resy = lpos[Trk::locY] - seg2.localParameters()[Trk::locY];
346
347 if (j == 0) {
348 resfirst = resy;
349 posfirst = distToRO;
350 }
351 if (j == nbins - 1) {
352 reslast = resy;
353 poslast = distToRO;
354 }
355 }
356 }
357
358 double distPosMin2{1e9}, distPosInTube2{1e9}, distPosMin{1e9}, distPosInTube{1e9}, resyMin{1e9};
359 Amg::Vector3D segPos(0., 0., 0.);
360 double rangeCut = 1e5;
361 if (resfirst < rangeCut && reslast < rangeCut && posfirst < rangeCut && poslast < rangeCut) {
362 double resDif = reslast - resfirst;
363 double posDif = poslast - posfirst;
364 if (std::abs(resDif) < 1e-6) {
365 ATH_MSG_DEBUG(" Unexpected residual difference " << resDif);
366 resDif = resDif < 0. ? -1e-6 : 1e-6;
367 }
368 if (std::abs(posDif) < 1e-6) {
369 ATH_MSG_DEBUG(" Unexpected position difference " << posDif);
370 posDif = posDif < 0. ? -1e-6 : 1e-6;
371 }
372 distPosMin = posfirst - resfirst / (resDif) * (posDif);
373 distPosInTube = segmentGeometry.positionInsideTube(distPosMin);
374 resyMin = resfirst + (resDif) * (distPosInTube - posfirst) / (posDif);
375
376 double locx = distPosInTube;
377 double locy = seg1.localParameters().contains(Trk::locY) ? seg1.localParameters()[Trk::locY] : 0.;
378
379 // create local position
380 Amg::Vector2D lpos(locx, locy);
381
382 // segment reference surface
383 const Trk::PlaneSurface& segmentSurface = seg2.associatedSurface();
384
385 // get global position
386 Amg::Vector3D gpos;
387 seg1.associatedSurface().localToGlobal(lpos, segDir1Min, gpos);
388 segPos = gpos;
389
390 // calculate intersection
391 Trk::Intersection intersect = segmentSurface.straightLineIntersection(gpos, segDir1Min, false, false);
392 if (!intersect.valid) {
393 ATH_MSG_WARNING(" Intersect with surface position " << Amg::toString(gpos) << " direction: phi "
394 << segDir1Min.phi() << " theta "
395 << segDir1Min.theta());
396 goodMatch = false;
397 } else {
398 Amg::Vector3D locExSeg2 = segmentGeometry2.globalToSeg * intersect.position;
399 distPosMin2 = locExSeg2.x();
400 distPosInTube2 = segmentGeometry2.positionInsideTube(distPosMin2);
401 }
402
403 } else {
404 goodMatch = false;
405 }
406
407 return {distPosMin, distPosInTube, segmentGeometry.shortestChannelLength, distPosMin2,
408 distPosInTube2, segmentGeometry2.shortestChannelLength, resyMin, goodMatch,
409 segPos};
410}
#define ATH_MSG_WARNING(x)
SegmentGeometrySummary segmentGeometrySummary(const MuonSegment &seg) const
calculate geometrical information for a segment
bool contains(ParamDefs par) const
The simple check for the clients whether the parameter is contained.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for PlaneSurface: LocalToGlobal method without dynamic memory allocation.
virtual Intersection straightLineIntersection(const Amg::Vector3D &pos, const Amg::Vector3D &dir, bool forceDir, Trk::BoundaryCheck bchk) const override final
fast straight line intersection schema - standard: provides closest intersection and (signed) path le...
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specified for PlaneSurface: GlobalToLocal method without dynamic memory allocation - boolean checks i...
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 2, 1 > Vector2D
@ locY
local cartesian
Definition ParamDefs.h:38

◆ checkPhiHitConsistency()

double Muon::MuonSegmentInOverlapResolvingTool::checkPhiHitConsistency ( const EventContext & ctx,
const Muon::MuonSegment & segment,
SegmentPhiMatchResult & phiMatchResult,
SegmentPositionMatchResult & matchResult ) const
private

compare phi hits with segment parameters, return average pull of the phi hits

Definition at line 492 of file MuonSegmentInOverlapResolvingTool.cxx.

495{
496
497 // calculate average pull of phi measurements
498 unsigned int nphiMeas = 0;
499 double averagePull = 0.;
500
501 // calculate segment AtaPlane
502 // SegmentGeometrySummary geometry = segmentGeometrySummary( segment );
503 double locx = posMatchResult.positionInTube1;
504 double locy = segment.localParameters().contains(Trk::locY) ? segment.localParameters()[Trk::locY] : 0.;
505 Trk::AtaPlane segPars(locx, locy, phiMatchResult.segmentDirection1.phi(), phiMatchResult.segmentDirection1.theta(),
506 0., segment.associatedSurface());
507
508 // loop over hits and calculate residuals for phi hits
509 for (const Trk::MeasurementBase* meas : segment.containedMeasurements()) {
510
511 Identifier id = m_edmHelperSvc->getIdentifier(*meas);
512 if (!id.is_valid() || !m_idHelperSvc->measuresPhi(id)) continue;
513
514 // predict onto segment surface
515 const Trk::Surface& measSurf = meas->associatedSurface();
516
517 // propagate station parameters to segment
518 std::unique_ptr<const Trk::TrackParameters> exPars {
519 m_propagator->propagate(
520 ctx,
521 segPars,
522 measSurf,
524 false,
526 if (!exPars) {
527 ATH_MSG_WARNING(" Failed to propagate parameter to segment surface" << std::endl
528 << " pars "
529 << m_printer->print(segPars));
530 continue;
531 }
532
533 std::optional<Trk::ResidualPull> resPull { m_pullCalculator->residualPull(meas, exPars.get(), Trk::ResidualPull::Unbiased)};
534 if (!resPull) {
535 ATH_MSG_DEBUG(" calculation of residual/pull failed !!!!! ");
536 continue;
537 }
538
539 // sanity check
540 if (resPull->pull().size() != 1) {
541 ATH_MSG_WARNING(" ResidualPull with empty pull vector for channel " << m_idHelperSvc->toString(id));
542 continue;
543 }
544 const double pull = resPull->pull().front();
545 averagePull += pull;
546 ++nphiMeas;
547
548 }
549 if (nphiMeas != 0) averagePull /= nphiMeas;
550 return averagePull;
551}
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
PublicToolHandle< MuonEDMPrinterTool > m_printer
EDM printer tool.
ToolHandle< Trk::IResidualPullCalculator > m_pullCalculator
ServiceHandle< IMuonEDMHelperSvc > m_edmHelperSvc
EDM Helper tool.
virtual const Trk::PlaneSurface & associatedSurface() const override final
returns the surface for the local to global transformation
@ Unbiased
RP with track state that has measurement not included.
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
@ anyDirection
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ estimateSegmentDirection()

Amg::Vector3D Muon::MuonSegmentInOverlapResolvingTool::estimateSegmentDirection ( const MuonSegment & seg1,
const MuonSegment & seg2,
double & phi,
double & stereoangle ) const
private

Definition at line 69 of file MuonSegmentInOverlapResolvingTool.cxx.

71{
72 //
73 // From two segments the direction and position of the segments are determined
74 // assuming a straight line
75 //
76 // if a stereoangle is present one can determine: phi and x local for both segments
77 //
78
79 // bool check = false;
80
81 // Confusing use of objects:
82 // This is needed because otherwise the Transform3D DOES NOT know
83 // whether it transforms a position or a direction
84 //
85 const Amg::Transform3D& gToGlobal1 = seg1.associatedSurface().transform();
86 const Amg::Transform3D& gToGlobal2 = seg2.associatedSurface().transform();
87 Amg::Transform3D gToLocal1 = seg1.associatedSurface().transform().inverse();
88 Amg::Transform3D gToLocal2 = seg2.associatedSurface().transform().inverse();
89 //
90 const Amg::Vector3D& gDir1 = seg1.globalDirection();
91 const Amg::Vector3D& gDir2 = seg2.globalDirection();
92 // Confusing but Amg::Vector3D can hold a 3D local direction
93 Amg::Vector3D lDir1 = gToLocal1.linear() * gDir1;
94 // Amg::Vector3D lDir2 = gToLocal2.linear()*gDir2;
95 // segment 2 local direction in frame of segment 1
96 Amg::Vector3D lDir12 = gToLocal1.linear() * gDir2;
97 // Amg::Vector3D lDir21 = gToLocal2.linear()*gDir1;
98
99 Amg::Vector3D segLocDiro(1., 0., 0.);
100 // orthogonal vector to segment 2 in local frame of segment 1
101 Amg::Vector3D lDiro12 = gToLocal1.linear() * (gToGlobal2.linear() * segLocDiro);
102 // orthogonal vector to segment 1in local frame of segment 2
103 Amg::Vector3D lDiro21 = gToLocal2.linear() * (gToGlobal1.linear() * segLocDiro);
104
105 stereoangle = std::acos(lDiro12.x());
106
107 // We have the following equations for segment 2 in local frame of segment 1
108 // dx1 = free
109 // dy1 = lDir1.y() = a * lDir12.y() + b * lDiro12.y()
110 // dz1 = lDir1.z() = a * lDir12.z() + b * lDiro12.z()
111
112 double b = lDir1.y() * lDir12.z() - lDir1.z() * lDir12.y();
113 double a = lDir1.y() * lDiro12.z() - lDir1.z() * lDiro12.y();
114 double dxn = lDir12.x();
115 double dyn = lDir12.y();
116 double dzn = lDir12.z();
117 if (std::abs(a) > 1e-2) {
118 dxn = lDir12.x() - b * lDiro12.x() / a;
119 dyn = lDir12.y() - b * lDiro12.y() / a;
120 dzn = lDir12.z() - b * lDiro12.z() / a;
121 }
122 double norm = std::hypot(dxn, dyn, dzn);
123 if (norm < 1e-6) {
124 ATH_MSG_DEBUG(" Unexpected normalisation " << norm);
125 norm = 1e-6;
126 }
127 if (dxn * lDir1.x() + dyn * lDir1.y() + dzn * lDir1.z() < 0) norm = -norm;
128 dxn = dxn / norm;
129 dyn = dyn / norm;
130 dzn = dzn / norm;
131
132 // The final result for the direction of the two segments
133
134 // New Local direction of segment 1
135 Amg::Vector3D lDirn1(dxn, dyn, dzn);
136 // Global direction of both segments
137 Amg::Vector3D gDirn = gToGlobal1.linear() * lDirn1;
138 // New Local direction of segment 2
139 Amg::Vector3D lDirn2 = gToLocal2.linear() * gDirn;
140 phi = gDirn.phi();
141 double theta = gDirn.theta();
142
143 const Amg::Vector3D& gPos1 = seg1.globalPosition();
144 // Confusing but Amg::Vector3D can hold a 3D local position
145 Amg::Vector3D lPos1 = gToLocal1 * gPos1;
146 Amg::Vector3D lPos21 = gToLocal2 * gPos1;
147 const Amg::Vector3D& gPos2 = seg2.globalPosition();
148 Amg::Vector3D lPos12 = gToLocal1 * gPos2;
149 Amg::Vector3D lPos2 = gToLocal2 * gPos2;
150 // In local frame of segment 2 shift segment 1 to obtain zero residual
151 double res21 = (lPos2.y() - lPos21.y()) * lDirn2.z() - (lPos2.z() - lPos21.z()) * lDirn2.y();
152 double localx1 = 0.;
153 double step = (lDiro21.y() * lDirn2.z() - lDiro21.z() * lDirn2.y());
154 if (std::abs(step) > 1e-5) {
155 localx1 = res21 / step;
156 }
157 ATH_MSG_DEBUG(" localx1 " << localx1 << " res21 " << res21 << " step " << step);
158
159 // Result: New local and global position of segment 1
160 Amg::Vector3D lPosn1(lPos1.x() + localx1, lPos1.y(), lPos1.z());
161 Amg::Vector3D gPosn1 = gToGlobal1 * lPosn1;
162 // In local frame of segment 1 shift segment 2 to obtain zero residual
163 double res12 = (lPos1.y() - lPos12.y()) * lDirn1.z() - (lPos1.z() - lPos12.z()) * lDirn1.y();
164 step = (lDiro12.y() * lDirn1.z() - lDiro12.z() * lDirn1.y());
165 double localx2 = 0.;
166 if (std::abs(step) > 1e-5) {
167 localx2 = res12 / step;
168 }
169 ATH_MSG_DEBUG(" localx2 " << localx2 << " res12 " << res12 << " step " << step);
170
171 // Result: New local and global position of segment 2
172 Amg::Vector3D lPosn2(lPos2.x() + localx2, lPos2.y(), lPos2.z());
173 Amg::Vector3D gPosn2 = gToGlobal2 * lPosn2;
174 ATH_MSG_DEBUG(" segment 1 local position "
175 << lPos1 << " new " << lPosn1 << std::endl
176 << " segment 1 global position " << gPos1 << " new " << gPosn1 << std::endl
177 << " segment 2 local position " << lPos2 << " new " << lPosn2 << std::endl
178 << " segment 2 global position " << gPos2 << " new " << gPosn2);
179
180 // This gives the direction from the position of the segments
181 Amg::Vector3D gDirPos = gPosn2 - gPosn1;
182 if (gDir1.x() * gDirPos.x() + gDir1.y() * gDirPos.y() + gDir1.z() * gDirPos.z() < 0) {
183 gDirPos = -gPosn2 + gPosn1;
184 }
185 double dtheta = theta - gDirPos.theta();
186 double dphi = phi - gDirPos.phi();
187 ATH_MSG_DEBUG(" theta " << theta << " gDirPos theta " << gDirPos.theta() << " dtheta " << dtheta << " phi " << phi
188 << " gDirPos phi " << gDirPos.phi() << " dphi " << dphi);
189 return gDirn;
190}
Scalar theta() const
theta method
virtual const Amg::Vector3D & globalPosition() const override final
global position

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode Muon::MuonSegmentInOverlapResolvingTool::initialize ( )

AlgTool initilize.

Definition at line 28 of file MuonSegmentInOverlapResolvingTool.cxx.

29{
30 ATH_CHECK(AthAlgTool::initialize());
31
32 ATH_CHECK(m_edmHelperSvc.retrieve());
33 ATH_CHECK(m_printer.retrieve());
34 ATH_CHECK(m_idHelperSvc.retrieve());
35 ATH_CHECK(m_propagator.retrieve());
36 ATH_CHECK(m_pullCalculator.retrieve());
37
38 return StatusCode::SUCCESS;
39}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Muon::IMuonSegmentInOverlapResolvingTool::interfaceID ( )
inlinestaticinherited

access to tool interface

Definition at line 150 of file IMuonSegmentInOverlapResolvingTool.h.

150 {
151 static const InterfaceID IID_IMuonSegmentInOverlapResolvingTool("Muon::IMuonSegmentInOverlapResolvingTool", 1, 0);
152 return IID_IMuonSegmentInOverlapResolvingTool;
153 }

◆ matchResult()

MuonSegmentInOverlapResolvingTool::SegmentMatchResult Muon::MuonSegmentInOverlapResolvingTool::matchResult ( const EventContext & ctx,
const MuonSegment & seg1,
const MuonSegment & seg2 ) const
virtual

performance match and return result

Implements Muon::IMuonSegmentInOverlapResolvingTool.

Definition at line 456 of file MuonSegmentInOverlapResolvingTool.cxx.

457{
458
459 ATH_MSG_DEBUG(" First segment " << m_printer->print(seg1) << std::endl
460 << " Second segment " << m_printer->print(seg2));
462
463 // calculate the phi angle that matches the two local segment angles
464 result.phiResult = bestPhiMatchAnalytic(seg1, seg2);
465
466 // calculate the position along the tube that minimizes the position residual for both segments
467 result.segmentResult1 = bestPositionAlongTubeMatch(seg1, seg2, result.phiResult.segmentDirection1);
468 result.segmentResult2 = bestPositionAlongTubeMatch(seg2, seg1, result.phiResult.segmentDirection2);
469
470 // calculate the average pull of the phi hits on the segments with the new parameters
471 result.averagePhiHitPullSegment1 = checkPhiHitConsistency(ctx, seg1, result.phiResult, result.segmentResult1);
472 result.averagePhiHitPullSegment2 = checkPhiHitConsistency(ctx, seg2, result.phiResult, result.segmentResult2);
473
474 if (result.segmentResult1.goodMatch && result.segmentResult2.goodMatch) {
475
476 // calculate vector connecting the two new segment positions
477 Amg::Vector3D difPos = result.segmentResult2.segmentPosition - result.segmentResult1.segmentPosition;
478
479 // check if vectors are pointing in the same direction, else flip
480 if (result.phiResult.segmentDirection1.y() * difPos.y() < 0.) {
481 difPos *= -1.;
482 }
483
484 // calculate difference in angle between phi from phi match and the two new segment positions
485 result.angularDifferencePhi = difPos.deltaPhi(result.phiResult.segmentDirection1);
486 }
487 return result;
488}
double checkPhiHitConsistency(const EventContext &ctx, const Muon::MuonSegment &segment, SegmentPhiMatchResult &phiMatchResult, SegmentPositionMatchResult &matchResult) const
compare phi hits with segment parameters, return average pull of the phi hits
SegmentPhiMatchResult bestPhiMatchAnalytic(const MuonSegment &seg1, const MuonSegment &seg2) const
calculate the angle phi for which the angular residual in the precision plane of the second segment i...
SegmentPositionMatchResult bestPositionAlongTubeMatch(const MuonSegment &seg1, const MuonSegment &seg2, const Amg::Vector3D &segDir1Min) const
calculate the position along a tube direction of the first segment that results in the smallest posit...

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ segmentGeometrySummary()

MuonSegmentInOverlapResolvingTool::SegmentGeometrySummary Muon::MuonSegmentInOverlapResolvingTool::segmentGeometrySummary ( const MuonSegment & seg) const
virtual

calculate geometrical information for a segment

Implements Muon::IMuonSegmentInOverlapResolvingTool.

Definition at line 414 of file MuonSegmentInOverlapResolvingTool.cxx.

415{
416
418 // loop over hits
419 Identifier tubeId1;
420 const MuonGM::MdtReadoutElement* detEl = nullptr;
421 double shortestTubeLen = 1e9;
422 Amg::Vector3D roPos;
423 Amg::Vector3D tubeCenter;
424 bool hasMdt = false;
425 for (const Trk::MeasurementBase* meas :seg.containedMeasurements()) {
426
427 const MdtDriftCircleOnTrack* mdt = dynamic_cast<const MdtDriftCircleOnTrack*>(meas);
428 if (mdt) {
429 hasMdt = true;
430 const Identifier& id = mdt->identify();
431 int layer = m_idHelperSvc->mdtIdHelper().tubeLayer(id);
432 int tube = m_idHelperSvc->mdtIdHelper().tube(id);
433 double tubelen = mdt->prepRawData()->detectorElement()->getActiveTubeLength(layer, tube);
434 if (tubelen < shortestTubeLen) {
435 shortestTubeLen = tubelen;
436 roPos = mdt->prepRawData()->detectorElement()->ROPos(id);
437 tubeCenter = mdt->prepRawData()->detectorElement()->surface(id).center();
438 detEl = mdt->prepRawData()->detectorElement();
439 tubeId1 = id;
440 }
441 }
442 }
443 summary.detEl = detEl;
444 summary.hasMdt = hasMdt;
445 summary.segToGlobal = seg.associatedSurface().transform();
446 summary.globalToSeg = summary.segToGlobal.inverse();
447 summary.roPosInSegFrame = (summary.globalToSeg * roPos).x();
448 double distTubeCenterFromRO = (summary.globalToSeg * tubeCenter).x() - summary.roPosInSegFrame;
449 summary.hvPosInSegFrame = summary.roPosInSegFrame + 2 * distTubeCenterFromRO;
450 summary.shortestChannelLength = std::abs(2 * distTubeCenterFromRO);
451
452 return summary;
453}
#define x
virtual const MdtPrepData * prepRawData() const override final
Returns the PrepRawData used to create this corrected measurement.
Identifier identify() const
return the identifier -extends MeasurementBase
@ layer
Definition HitInfo.h:79

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateSegmentDirection()

Amg::Vector3D Muon::MuonSegmentInOverlapResolvingTool::updateSegmentDirection ( const MuonSegment & seg,
double phi ) const
virtual

recalculate the segment direction give a new angle phi, keeps the angle in the precision plane fixed

Implements Muon::IMuonSegmentInOverlapResolvingTool.

Definition at line 42 of file MuonSegmentInOverlapResolvingTool.cxx.

43{
44
45 Amg::Transform3D gToStation = seg.associatedSurface().transform().inverse();
46 Amg::Vector3D phiDir(1., 0., 0.);
47 Amg::setThetaPhi(phiDir, seg.globalDirection().theta(), phi);
48 Amg::Vector3D lphiDir = gToStation.linear() * phiDir;
49 Amg::Vector3D lsegDir = gToStation.linear() * seg.globalDirection();
50 double road_dz = lphiDir.z();
51 double seg_dy = lsegDir.y();
52 double seg_dz = lsegDir.z();
53 if (road_dz * seg_dz < 0) {
54 seg_dy *= -1.;
55 seg_dz *= -1.;
56 }
57 if (std::abs(seg_dz) < 1e-6) {
58 seg_dz = 1e-6;
59 ATH_MSG_DEBUG(" Unexpected local direction of segment " << lsegDir);
60 }
61 double scale = road_dz / seg_dz;
62 seg_dy *= scale;
63 Amg::Vector3D locDir(lphiDir.x(), seg_dy, road_dz);
64 Amg::Vector3D gDir = seg.associatedSurface().transform().linear() * locDir;
65 return gDir;
66}
void setThetaPhi(Amg::Vector3D &v, double theta, double phi)
sets the theta and phi angle of a vector without changing the magnitude

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_edmHelperSvc

ServiceHandle<IMuonEDMHelperSvc> Muon::MuonSegmentInOverlapResolvingTool::m_edmHelperSvc
private
Initial value:
{
this,
"edmHelper",
"Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
"Handle to the service providing the IMuonEDMHelperSvc interface",
}

EDM Helper tool.

Definition at line 88 of file MuonSegmentInOverlapResolvingTool.h.

88 {
89 this,
90 "edmHelper",
91 "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
92 "Handle to the service providing the IMuonEDMHelperSvc interface",
93 };

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::MuonSegmentInOverlapResolvingTool::m_idHelperSvc
private
Initial value:
{
this,
"MuonIdHelperSvc",
"Muon::MuonIdHelperSvc/MuonIdHelperSvc",
}

Definition at line 83 of file MuonSegmentInOverlapResolvingTool.h.

83 {
84 this,
85 "MuonIdHelperSvc",
86 "Muon::MuonIdHelperSvc/MuonIdHelperSvc",
87 };

◆ m_magFieldProperties

Trk::MagneticFieldProperties Muon::MuonSegmentInOverlapResolvingTool::m_magFieldProperties
private

magnetic field properties

Definition at line 111 of file MuonSegmentInOverlapResolvingTool.h.

◆ m_printer

PublicToolHandle<MuonEDMPrinterTool> Muon::MuonSegmentInOverlapResolvingTool::m_printer
private
Initial value:
{
this,
"Printer",
"Muon::MuonEDMPrinterTool/MuonEDMPrinterTool",
}

EDM printer tool.

Definition at line 95 of file MuonSegmentInOverlapResolvingTool.h.

95 {
96 this,
97 "Printer",
98 "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool",
99 };

◆ m_propagator

ToolHandle<Trk::IPropagator> Muon::MuonSegmentInOverlapResolvingTool::m_propagator
private
Initial value:
{
this,
"AtlasRungeKuttaPropagator",
"Trk::RungeKuttaPropagator/AtlasRungeKuttaPropagator",
}

Definition at line 100 of file MuonSegmentInOverlapResolvingTool.h.

100 {
101 this,
102 "AtlasRungeKuttaPropagator",
103 "Trk::RungeKuttaPropagator/AtlasRungeKuttaPropagator",
104 };

◆ m_pullCalculator

ToolHandle<Trk::IResidualPullCalculator> Muon::MuonSegmentInOverlapResolvingTool::m_pullCalculator
private
Initial value:
{
this,
"ResidualPullCalculator",
"Trk::ResidualPullCalculator/ResidualPullCalculator",
}

Definition at line 105 of file MuonSegmentInOverlapResolvingTool.h.

105 {
106 this,
107 "ResidualPullCalculator",
108 "Trk::ResidualPullCalculator/ResidualPullCalculator",
109 };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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