ATLAS Offline Software
Loading...
Searching...
No Matches
MuonPRDSelectionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9namespace Muon {
10
11 MuonPRDSelectionTool::MuonPRDSelectionTool(const std::string& type, const std::string& name, const IInterface* parent):
12 AthAlgTool(type,name,parent),
15 {
16 declareInterface<IMuonPRDSelectionTool>(this);
17 }
18
20
21 ATH_CHECK(m_idHelperSvc.retrieve());
22 ATH_CHECK(m_mdtCreator.retrieve());
23 ATH_CHECK(m_clusterCreator.retrieve());
24 return StatusCode::SUCCESS;
25 }
26
28
29 if( msgLvl(MSG::DEBUG) ){
30 msg(MSG::DEBUG) << " intersection: in sector " << intersection.layerSurface.sector
31 << " region " << MuonStationIndex::regionName(intersection.layerSurface.regionIndex)
32 << " layer " << MuonStationIndex::layerName(intersection.layerSurface.layerIndex)
33 << " r " << intersection.trackParameters->position().perp() << " z " << intersection.trackParameters->position().z()
34 << " phi " << intersection.trackParameters->position().phi()
35 << " local (" << intersection.trackParameters->parameters()[Trk::loc1] << "," << intersection.trackParameters->parameters()[Trk::loc2] << ")";
36 if( intersection.trackParameters->covariance() ) {
37 msg(MSG::DEBUG) << " err (" << Amg::error(*intersection.trackParameters->covariance(),Trk::loc1) << "," << Amg::error(*intersection.trackParameters->covariance(),Trk::loc2) << ")";
38 }
39
40 if( !layerPrepRawData.mdts.empty() ) msg(MSG::DEBUG) << " MDTs " << layerPrepRawData.mdts.size();
41 if( !layerPrepRawData.rpcs.empty() ) msg(MSG::DEBUG) << " RPCs " << layerPrepRawData.rpcs.size();
42 if( !layerPrepRawData.tgcs.empty() ) msg(MSG::DEBUG) << " TGCs " << layerPrepRawData.tgcs.size();
43 if( !layerPrepRawData.cscs.empty() ) msg(MSG::DEBUG) << " CSCs " << layerPrepRawData.cscs.size();
44 if( !layerPrepRawData.stgcs.empty() ) msg(MSG::DEBUG) << " STGCs " << layerPrepRawData.stgcs.size();
45 if( !layerPrepRawData.mms.empty() ) msg(MSG::DEBUG) << " MMs " << layerPrepRawData.mms.size();
46 msg(MSG::DEBUG) << endmsg;
47 }
48
49 // loop over MDT collections
50 for( const auto *col : layerPrepRawData.mdts ){
51 calibrateAndSelectMdt(intersection,*col,layerROTs);
52 }
53
54 // loop over RPC collections
55 for( const auto *col : layerPrepRawData.rpcs ){
57 }
58
59 // loop over TGC collections
60 for( const auto *col : layerPrepRawData.tgcs ){
62 }
63
64 // loop over STGC collections
65 for( const auto *col : layerPrepRawData.stgcs ){
67 }
68
69 // loop over MM collections
70 for( const auto *col : layerPrepRawData.mms ){
72 }
73
74 return true;
75 }
76
77
79
80 // calculate intersection with tube
81 const Amg::Vector3D& direction = intersection.trackParameters->momentum();
82 Amg::Vector3D intersect = intersectMDT(mdt,intersection.trackParameters->position(),direction,true);
83
84
85 // calculate local position of the intersection in tube frame
86 const Identifier& id = mdt.identify();
87 const MuonGM::MdtReadoutElement* detEl = mdt.detectorElement();
88 const Trk::Surface& surface = mdt.detectorElement()->surface(id);
89 Amg::Vector2D localPosition{Amg::Vector2D::Zero()};
90 if( !surface.globalToLocal(intersect,direction,localPosition) ){
91 ATH_MSG_VERBOSE(" globalToLocal failed for " << m_idHelperSvc->toString(id) );
92 return nullptr;
93 }
94
95 // bound checks
96 double tubeHalfLen = 0.5*detEl->getActiveTubeLength( m_idHelperSvc->mdtIdHelper().tubeLayer(id),m_idHelperSvc->mdtIdHelper().tube(id) );
97 double distanceAlongTube = localPosition[Trk::locZ];
98
99 if( msgLvl(MSG::VERBOSE) ) {
100 msg(MSG::VERBOSE) << " Intersected " << m_idHelperSvc->toString(id) << " distance to wire " << localPosition[Trk::locR]
101 << " error " << Amg::error(*intersection.trackParameters->covariance(),Trk::locX) << " along tube (%) " << distanceAlongTube/tubeHalfLen;
102
103 }
104 if( std::abs(distanceAlongTube) > tubeHalfLen + m_secondCoordinateCut ) {
105 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " outside tube second coordinate range, dropping " << endmsg;
106 return nullptr;
107 }
108
109 if( std::abs(localPosition[Trk::locR]) > m_distanceToTubeCut ) {
110 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " too far from wire, dropping " << endmsg;
111 return nullptr;
112 }
113
114 // shift intersection within tube
115 if( distanceAlongTube > tubeHalfLen ){
116 localPosition[Trk::locZ] = distanceAlongTube < 0 ? -tubeHalfLen : tubeHalfLen;
117 surface.localToGlobal(localPosition,direction,intersect);
118 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " outside tube, shifting";
119 }
120 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << endmsg;
121
122 // calibrate hit
123 const MdtDriftCircleOnTrack* mdtROT = m_mdtCreator->createRIO_OnTrack( mdt, intersect, &direction, 0., nullptr, beta, 0.);
124 if( !mdtROT ) ATH_MSG_VERBOSE(" Failed to calibrate " << m_idHelperSvc->toString(id));
125 return mdtROT;
126 }
127
129
130 // basic info
131 const Identifier& id = clus.identify();
132 const Trk::Surface& surf = clus.detectorElement()->surface(id);
133
134 // calculate intersection
135 const Amg::Vector3D& position = pars.position();
136 const Amg::Vector3D& direction = pars.momentum();
137 Trk::Intersection slIntersection = clus.detectorElement()->surface(id).straightLineIntersection(position,direction,false,false);
138 Amg::Vector3D intersect = slIntersection.position;
139
140
141 // get local position
142 Amg::Vector2D localPosition;
143 if( !surf.globalToLocal(intersect,direction,localPosition) ){
144 ATH_MSG_VERBOSE(" globalToLocal failed for " << m_idHelperSvc->toString(id) );
145 return nullptr;
146 }
147
148 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " Intersected " << m_idHelperSvc->toString(id) << " local position " << localPosition[Trk::loc1] << " " << localPosition[Trk::loc2];
149
150 if( !surf.insideBounds(localPosition, m_distanceToTubeCut, m_secondCoordinateCut) ) {
151 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " outside bounds, dropping " << endmsg;
152 return nullptr;
153 }
154 if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << endmsg;
155
156 const MuonClusterOnTrack *cluster = m_clusterCreator->createRIO_OnTrack(clus, intersect);
157
158 if( !cluster ){
159 ATH_MSG_VERBOSE(" --- cluster creation failed ");
160 return nullptr;
161 }
162
163 return cluster;
164 }
165
169
170 Amg::Vector3D MuonPRDSelectionTool::intersectMDT( const MdtPrepData& mdt, const Amg::Vector3D& position, const Amg::Vector3D& direction, bool usePlane ) const {
171
172 if( usePlane ){
173 const Identifier& id = mdt.identify();
174 const MuonGM::MdtReadoutElement* detEl = mdt.detectorElement();
175 const Amg::Vector3D& tubePos = mdt.globalPosition();
176 // if there is a phi measurement in the pattern use the global direction to calculate the intersect with the tube
177 // use the intersect to calculate the second coordinate
178 const Amg::Transform3D amdbToGlobal = detEl->AmdbLRSToGlobalTransform();
179
180 // calculate intersect pattern measurement plane
181 const Amg::Vector3D& planeposition = tubePos;
182
183 // always project on plane with normal in radial direction
184 Amg::Vector3D planenormal = !m_idHelperSvc->isEndcap(id) ? amdbToGlobal.linear()*Amg::Vector3D(0.,0.,1.) : amdbToGlobal.linear()*Amg::Vector3D(0.,1.,0.);
185
186 double denom = direction.dot(planenormal);
187 double u = (planenormal.dot(planeposition - position))/denom;
188 Amg::Vector3D piOnPlane = ( position + u * direction);
189 return piOnPlane;
190 }
191 Trk::Intersection intersection = mdt.detectorElement()->surface(mdt.identify()).straightLineIntersection(position,direction,false,false);
192 return intersection.position;
193 }
194
195
196
197}
198
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
double getActiveTubeLength(const int tubeLayer, const int tube) const
virtual const Trk::Surface & surface() const override final
Return surface associated with this detector element.
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
Class to represent measurements from the Monitored Drift Tubes.
Definition MdtPrepData.h:33
virtual const MuonGM::MdtReadoutElement * detectorElement() const override
Returns the detector element corresponding to this PRD.
virtual const Amg::Vector3D & globalPosition() const
Returns the global position of the CENTER of the drift tube (i.e.
Base class for Muon cluster RIO_OnTracks.
struct holding RIO_OnTracks for a given layer
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
bool calibrateAndSelectCluster(const MuonSystemExtension::Intersection &intersection, const COL &prds, std::vector< const MuonClusterOnTrack * > &rots) const
calibrate and select clusters in a collection
MuonPRDSelectionTool(const std::string &type, const std::string &name, const IInterface *parent)
Default AlgTool functions.
bool calibrateAndSelectMdt(const MuonSystemExtension::Intersection &intersection, const MdtPrepDataCollection &prds, std::vector< const MdtDriftCircleOnTrack * > &rots) const
calibrate and select MDTs in a collection
ToolHandle< IMdtDriftCircleOnTrackCreator > m_mdtCreator
bool calibrateAndSelect(const MuonSystemExtension::Intersection &intersection, const MuonLayerPrepRawData &layerPrepRawData, MuonLayerROTs &layerROTs) const
IMuonPRDSelectionTool interface: calibrateAndSelect.
Amg::Vector3D intersectMDT(const MdtPrepData &mdt, const Amg::Vector3D &position, const Amg::Vector3D &direction, bool usePlane) const
intersect MDT surface or tube plane
ToolHandle< IMuonClusterOnTrackCreator > m_clusterCreator
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
Identifier identify() const
return the identifier
Abstract Base Class for tracking surfaces.
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const =0
Specified by each surface type: GlobalToLocal method without dynamic memory allocation - boolean chec...
virtual bool insideBounds(const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const =0
virtual methods to be overwritten by the inherited surfaces
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
Intersection straightLineIntersection(const T &pars, bool forceDir=false, const Trk::BoundaryCheck &bchk=false) const
fst straight line intersection schema - templated for charged and neutral parameters
virtual const Surface & surface() const =0
Return surface associated with this detector element.
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
const std::string & layerName(LayerIndex index)
convert LayerIndex into a string
const std::string & regionName(DetectorRegionIndex index)
convert DetectorRegionIndex into a string
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
@ locX
Definition ParamDefs.h:37
@ locR
Definition ParamDefs.h:44
@ loc2
generic first and second local coordinate
Definition ParamDefs.h:35
@ loc1
Definition ParamDefs.h:34
@ locZ
local cylindrical
Definition ParamDefs.h:42
ParametersBase< TrackParametersDim, Charged > TrackParameters
Struct to hold all PrepRawData collections in a given layer.
std::vector< const CscPrepDataCollection * > cscs
std::vector< const MMPrepDataCollection * > mms
std::vector< const TgcPrepDataCollection * > tgcs
std::vector< const MdtPrepDataCollection * > mdts
std::vector< const RpcPrepDataCollection * > rpcs
std::vector< const sTgcPrepDataCollection * > stgcs
Amg::Vector3D position