ATLAS Offline Software
Loading...
Searching...
No Matches
InDetAlignHitQualSelTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
10// geometry
11#include "Identifier/Identifier.h"
16
18
19using namespace std ;
20
22 , const std::string& n
23 , const IInterface* p
24 )
25 : AthAlgTool(t,n,p)
26 , m_rejectOutliers( true )
27 , m_maxClusterSize( 5 )
28 , m_rejectEdgeChannels( true )
29 , m_rejectGangedPixels( false )
30 , m_maxIncidAngle( 0.8 )
31 , m_acceptIBLHits( true )
32 , m_acceptPixelHits( true )
33 , m_acceptSCTHits( true )
34 , m_PIXManager{}
35 , m_pixelid{}
36 , m_sctID{}
37{
38 declareInterface<IInDetAlignHitQualSelTool>(this) ;
39 declareProperty( "RejectOutliers", m_rejectOutliers ) ;
40 declareProperty( "MaxClusterSize", m_maxClusterSize ) ;
41 declareProperty( "RejectEdgeChannels", m_rejectEdgeChannels ) ;
42 declareProperty( "RejectGangedPixels", m_rejectGangedPixels ) ;
43 declareProperty( "MaxIncidAngle", m_maxIncidAngle ) ;
44 declareProperty( "AcceptIBLHits", m_acceptIBLHits ) ;
45 declareProperty( "AcceptPixelHits", m_acceptPixelHits ) ;
46 declareProperty( "AcceptSCTHits", m_acceptSCTHits ) ;
47}
48
49
51
52
54 StatusCode sc = AlgTool::initialize() ;
55 if( sc.isFailure() ) return sc ;
56 // get DetectorStore service
57 ATH_CHECK( detStore().retrieve()) ;
58 ATH_CHECK(detStore()->retrieve(m_sctID, "SCT_ID"));
59 ATH_CHECK(detStore()->retrieve(m_pixelid, "PixelID"));
60 // get pixel manager
61 ATH_CHECK(detStore()->retrieve( m_PIXManager, "Pixel" )) ;
62 return StatusCode::SUCCESS ;
63}
64
65
67 ATH_MSG_DEBUG( "finalize() successful in " << name() ) ;
68 return AlgTool::finalize() ;
69}
70
72 ATH_MSG_DEBUG( "** getGoodHit ** Dealing with a new tsos ** START ** " ) ;
73
74 if( tsos == nullptr ) {
75 ATH_MSG_ERROR( "0 pointer passed for TSOS!" ) ;
76 return nullptr ;
77 }
79 ATH_MSG_DEBUG( "not a hit, cast to MeasurementBase will fail, so reject" ) ;
80 return nullptr ;
81 }
83 ATH_MSG_DEBUG( "outlier, reject" ) ;
84 return nullptr ;
85 }
86 const Trk::MeasurementBase* measBase = tsos->measurementOnTrack() ;
87 if( measBase == nullptr) {
88 ATH_MSG_DEBUG( "tsos->measurementOnTrack() returned 0 pointer" ) ;
89 return nullptr ;
90 }
91
92 const Trk::RIO_OnTrack* hit = dynamic_cast <const Trk::RIO_OnTrack*>( measBase ) ;
93 if( hit == nullptr ) {
94 ATH_MSG_DEBUG( "dynamic_cast <const Trk::RIO_OnTrack*>( measBase ) returned 0 pointer" ) ;
95 return nullptr ;
96 }
97
98 const Trk::PrepRawData* prd = hit->prepRawData() ;
99 if( prd == nullptr ) {
100 ATH_MSG_WARNING( "hit->prepRawData() method failed" ) ;
101 return nullptr ;
102 }
103
104
105 if( m_rejectGangedPixels && isGangedPixel( prd ) ) return nullptr ;
106 const vector<Identifier> &idVec = prd->rdoList() ;
107
108 // cut on the cluster size
109 if( m_maxClusterSize > 0 && !isGoodClusterSize( idVec ) ) return nullptr ;
110
111 // cut on edge channels
112 if( m_rejectEdgeChannels && isEdgeChannel( idVec ) ) return nullptr ;
113 // cut on the track incidence angle alpha
114 const Trk::TrackParameters* trkPar = tsos->trackParameters() ;
115 if( trkPar == nullptr ) {
116 ATH_MSG_WARNING( "tsos->trackParameters() returned 0 pointer" ) ;
117 return nullptr ;
118 }
119 const InDetDD::SiDetectorElement *detEle
120 = dynamic_cast<const InDetDD::SiDetectorElement*>( hit->detectorElement() ) ;
121 if( detEle == nullptr ) {
122 ATH_MSG_WARNING( "hit cast to SiDetectorElement returned 0 pointer" ) ;
123 return nullptr ;
124 }
125 if( !isGoodAngle( trkPar, detEle ) ) return nullptr ;
126 return hit ;
127}
128
130 bool isSiliconHit = false;
131 bool isPixelHit = false;
132 bool isIBLHit = false;
133
134 if( tsos == nullptr ) {
135 ATH_MSG_ERROR( "0 pointer passed for TSOS!" ) ;
136 return false ;
137 }
139 ATH_MSG_DEBUG( "not a hit, cast to MeasurementBase will fail --> keep it anyway" ) ;
140 return false ;
141 }
142
144 ATH_MSG_DEBUG( "outlier --> keep it" ) ;
145 return false ;
146 }
147 const Trk::MeasurementBase* measBase = tsos->measurementOnTrack() ;
148 if( measBase == nullptr) {
149 ATH_MSG_DEBUG( "tsos->measurementOnTrack() returned 0 pointer" ) ;
150 return false ;
151 }
152
153 const Trk::RIO_OnTrack* hit = dynamic_cast <const Trk::RIO_OnTrack*>( measBase ) ;
154 if( hit == nullptr ) {
155 ATH_MSG_DEBUG( "dynamic_cast <const Trk::RIO_OnTrack*>( measBase ) returned 0 pointer" ) ;
156 return false ;
157 }
158
159 const Trk::PrepRawData* prd = hit->prepRawData() ;
160 if( prd == nullptr ) {
161 ATH_MSG_WARNING( "hit->prepRawData() method failed" ) ;
162 return false ;
163 }
164
165
166 const Identifier & hitId = hit->identify();
167 if (m_sctID->is_sct(hitId)) {
168 ATH_MSG_DEBUG( " this is a SCT hit - SCT - SCT - ");
169 isSiliconHit = true;
170 }
171 if (m_pixelid->is_pixel(hitId)) {
172 ATH_MSG_DEBUG( " this is a PIX hit - PIX - PIX - ");
173 isSiliconHit = true;
174 isPixelHit = true; // assume that is pixel hit
175 // but check if it is IBL
176 if (m_pixelid->layer_disk(hitId) == 0 && m_pixelid->barrel_ec(hitId) == 0 ) {isIBLHit = true; isPixelHit = false;}
177 }
178
179 if (!isSiliconHit) {
180 ATH_MSG_DEBUG( "This is not a silicon hit. Keep it as good" ) ;
181 return true;
182 }
183
184 // accept IBL hits ?
185 if (!m_acceptIBLHits && isIBLHit) {
186 ATH_MSG_INFO( "this is an IBL hit --> user wants to drop it" ) ;
187 return false;
188 }
189
190 // accept pixel hits ?
191 if (!m_acceptPixelHits && isPixelHit) {
192 ATH_MSG_INFO( "this is a pixel hit --> user wants to drop it" ) ;
193 return false;
194 }
195
196 // accept SCT hits ?
197 if (!m_acceptSCTHits) {
198 if (isSiliconHit && m_sctID->is_sct(hitId)) {
199 ATH_MSG_INFO( "this is a SCT hit --> user wants to drop it" ) ;
200 return false;
201 }
202 }
203
204 if( m_rejectGangedPixels && isGangedPixel( prd ) ) return false ;
205 const vector<Identifier> &idVec = prd->rdoList() ;
206
207 // cut on the cluster size
208 if( m_maxClusterSize > 0 && !isGoodClusterSize( idVec ) ) return false ;
209
210 // cut on edge channels
211 if( m_rejectEdgeChannels && isEdgeChannel( idVec ) ) return false ;
212
213 // cut on the track incidence angle alpha
214 const Trk::TrackParameters* trkPar = tsos->trackParameters() ;
215 if( trkPar == nullptr ) {
216 ATH_MSG_WARNING( "tsos->trackParameters() returned 0 pointer" ) ;
217 return false ;
218 }
219 // incidence angle
220 const InDetDD::SiDetectorElement *detEle
221 = dynamic_cast<const InDetDD::SiDetectorElement*>( hit->detectorElement() ) ;
222 if( detEle == nullptr ) {
223 ATH_MSG_WARNING( "hit cast to SiDetectorElement returned 0 pointer" ) ;
224 return false ;
225 }
226 if( !isGoodAngle( trkPar, detEle ) ) return false ;
227
228 return true ;
229}
230
231
232
234 if( tsos == nullptr ) {
235 ATH_MSG_ERROR( "0 pointer passed for TSOS!" ) ;
236 return false ;
237 }
239 ATH_MSG_DEBUG( "This is not a hole, reject" ) ;
240 return false ;
241 }
242 // for holes only cut on the track incidence angle alpha
243 const Trk::TrackParameters* trkPar = tsos->trackParameters() ;
244 if( trkPar == nullptr ) {
245 ATH_MSG_WARNING( "tsos->trackParameters() returned 0 pointer" ) ;
246 return false ;
247 }
248 const InDetDD::SiDetectorElement *detEle = dynamic_cast<const InDetDD::SiDetectorElement*>(
249 tsos->trackParameters()->associatedSurface().associatedDetectorElement() ) ;
250 if( detEle == nullptr ) {
251 ATH_MSG_WARNING( "hole cast to SiDetectorElement returned 0 pointer" ) ;
252 return false ;
253 }
254 if( !isGoodAngle( trkPar, detEle ) ) return false ;
255 return true;
256}
257
258
260 const InDet::SiCluster* cluster = dynamic_cast<const InDet::SiCluster*>( prd ) ;
261 if( cluster == nullptr ) {
262 ATH_MSG_WARNING( "dynamic_cast<const InDet::SiCluster*>( prd ) failed!" ) ;
263 return false ;
264 }
265 if( cluster->gangedPixel() ) {
266 ATH_MSG_DEBUG( "cluster contains a ganged pixel, reject" ) ;
267 return true ;
268 }
269 return false ;
270}
271
272
273bool InDetAlignHitQualSelTool::isGoodClusterSize( const std::vector<Identifier>& idVec ) const {
274 int clusterSize = idVec.size() ;
275 ATH_MSG_DEBUG( "clusterSize = " << clusterSize ) ;
276 if( clusterSize > m_maxClusterSize ) {
277 ATH_MSG_DEBUG( "clusterSize = " << clusterSize << " > " << m_maxClusterSize << ", reject" ) ;
278 return false ;
279 }
280 return true ;
281}
282
283
284bool InDetAlignHitQualSelTool::isEdgeChannel( const vector<Identifier>& idVec ) const {
285 for( unsigned int i=0, i_max=idVec.size() ; i!=i_max ; ++i ) {
286 if( m_sctID->is_sct(idVec[i]) ) {
287 int stripId = m_sctID->strip(idVec[i]) ;
288 if( stripId == 0 || stripId == 767 ) {
289 ATH_MSG_DEBUG( " SCT strip " << i << " with id " << stripId << " is an edge channel " ) ;
290 return true ;
291 }
292 if( stripId < 0 || stripId > 767 ) {
293 ATH_MSG_FATAL( " WRONG DETECTOR INFORMATION " ) ;
294 }
295 }
296 if( m_PIXManager->identifierBelongs(idVec[i]) ) {
297 int pixelIdPhi = m_pixelid->phi_index(idVec[i]) ;
298 int pixelIdEta = m_pixelid->eta_index(idVec[i]) ;
299 if( pixelIdPhi == 0 || pixelIdPhi == 327 || pixelIdEta == 0 || pixelIdEta == 143 ) {
300 ATH_MSG_DEBUG( " pixel hit " << i << " with idPhi " << pixelIdPhi << " and idEta " << pixelIdEta << " is an edge channel " ) ;
301 return true ;
302 }
303 if( pixelIdPhi < 0 || pixelIdPhi > 327 || pixelIdEta < 0 || pixelIdEta > 143 ) {
304 ATH_MSG_FATAL( " WRONG DETECTOR INFORMATION " ) ;
305 }
306 }
307 }
308 return false ;
309}
310
312 , const InDetDD::SiDetectorElement* detEle
313 ) const {
314 const double trkIncidAngle = incidAngle( trkPar, detEle ) ;
315 if( std::abs(trkIncidAngle) > m_maxIncidAngle ) {
316 ATH_MSG_DEBUG( "trkIncidAngle = |" << trkIncidAngle << "| > " << m_maxIncidAngle << ", reject" ) ;
317 return false ;
318 }
319 return true;
320}
321
322
324 , const InDetDD::SiDetectorElement* detEle
325 ) const {
326 Amg::Vector3D trkDir = trkPar->momentum() ;
327 const Amg::Vector3D& detElePhi = detEle->phiAxis() ;
328 const Amg::Vector3D& detEleNormal = detEle->normal() ;
329 double trkDotPhi = trkDir.dot( detElePhi ) ;
330 double trkDotNormal = trkDir.dot( detEleNormal ) ;
331 double trkIncidAngle = atan( trkDotPhi/trkDotNormal ) ;
332 ATH_MSG_DEBUG( "trkIncidAngle = " << trkIncidAngle ) ;
333 return trkIncidAngle ;
334}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
static Double_t sc
This is an Identifier helper class for the SCT subdetector.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
bool m_rejectEdgeChannels
reject clusters containing edge channels
bool m_rejectGangedPixels
reject clusters containing ganged pixels
bool isGoodSiHit(const Trk::TrackStateOnSurface *tsos) const
const PixelID * m_pixelid
Pixel id helper.
bool isGangedPixel(const Trk::PrepRawData *prd) const
check, whether cluster contains a ganged pixel
float m_maxIncidAngle
maximum incidence angle of a track (to which the hit belongs) on the Si-module.
double incidAngle(const Trk::TrackParameters *trkPar, const InDetDD::SiDetectorElement *detEle) const
calculate track incidence angle in local x-z frame
const Trk::RIO_OnTrack * getGoodHit(const Trk::TrackStateOnSurface *tsos) const
main method: from a TrackStateOnSurface select a good hit cutting on outlier hits,...
const InDetDD::PixelDetectorManager * m_PIXManager
to get pixel phi and eta identifiers
const SCT_ID * m_sctID
Pixel id helper.
InDetAlignHitQualSelTool(const std::string &, const std::string &, const IInterface *)
bool isGoodAngle(const Trk::TrackParameters *trkPar, const InDetDD::SiDetectorElement *detEle) const
check whether track incidence angle within limits of m_maxIncidAngle
bool isGoodClusterSize(const std::vector< Identifier > &idVec) const
check, whether cluster size within limits of m_maxClusterSize
bool getGoodHole(const Trk::TrackStateOnSurface *tsos) const
from a TrackStateOnSurface select a good hole in track cutting on large incidence angles only
bool m_rejectOutliers
reject hits labeled as outliers by the track fitter
bool isEdgeChannel(const std::vector< Identifier > &idVec) const
check, whether the strip/pixel is an edge channel
Class to hold geometrical description of a silicon detector element.
virtual const Amg::Vector3D & normal() const override final
Get reconstruction local normal axes in global frame.
bool gangedPixel() const
return the flag of this cluster containing a gangedPixel
This class is the pure abstract base class for all fittable tracking measurements.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
virtual const TrkDetElementBase * detectorElement() const =0
returns the detector element, assoicated with the PRD of this class
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
Identifier identify() const
return the identifier -extends MeasurementBase
represents the track state (measurement, material, fit parameters and quality) at a surface.
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
bool type(const TrackStateOnSurfaceType type) const
Use this method to find out if the TSoS is of a certain type: i.e.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ Hole
A hole on the track - this is defined in the following way.
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersBase< TrackParametersDim, Charged > TrackParameters
STL namespace.