ATLAS Offline Software
HoleSearchValidation.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // HoleSearchValidation.cxx, (c) ATLAS Detector Software
8 
10 // Gaudi
11 #include "GaudiKernel/MsgStream.h"
12 // Trk
13 #include "TrkTrack/Track.h"
14 
16 
18 
21 #include "InDetIdentifier/SCT_ID.h"
22 #include "InDetIdentifier/TRT_ID.h"
25 
26 #include "CLHEP/Random/RandFlat.h"
27 
28 using namespace InDet;
29 
30 HoleSearchValidation::HoleSearchValidation(const std::string& name, ISvcLocator* pSvcLocator):
31  AthReentrantAlgorithm(name, pSvcLocator),
32  m_idHelper(nullptr),
33  m_pixelID(nullptr),
34  m_sctID(nullptr),
35  m_trtID(nullptr),
36  m_siliconID(nullptr),
37  m_holeSearchTool("InDet::InDetTrackHoleSearchTool"),
38  m_trackCollectionKey("Tracks"),
39  m_saveNewTracksInSG(false),
40  m_removeParts {},
41  m_removeOverlapHitsOnly(false),
42  m_ignoreTrackEnds(true),
43  m_randomRemovalMode(false),
44  m_maxNumberOfHoles(3),
45  m_rndmGenSvc("AthRNGSvc", name),
46  m_randomEngineName("HoleSearchRnd")
47 
48 {
49  declareProperty("HoleSearchTool" , m_holeSearchTool);
50  declareProperty("TrackCollection" , m_trackCollectionKey, "Name of the reference track collection");
51 
52  declareProperty("SaveNewTracksInSG" , m_saveNewTracksInSG , "Boolean: save tracks in SG");
53 
54  // for (unsigned int part_i=0; part_i<Parts::kNParts; ++part_i) {
55  // m_removeParts[part_i]=false;
56  // }
57  declareProperty("RemovePIX0" , m_removeParts[Parts::kPix0] , "Remove hit(s) in PIXEL layer 0");
58  declareProperty("RemovePIX1" , m_removeParts[Parts::kPix1] , "Remove hit(s) in PIXEL layer 1");
59  declareProperty("RemovePIX2" , m_removeParts[Parts::kPix2] , "Remove hit(s) in PIXEL layer 2");
60 
61  declareProperty("RemoveSCT0" , m_removeParts[Parts::kSct0] , "Remove hit(s) in SCT layer 0");
62  declareProperty("RemoveSCT1" , m_removeParts[Parts::kSct1] , "Remove hit(s) in SCT layer 1");
63  declareProperty("RemoveSCT2" , m_removeParts[Parts::kSct2] , "Remove hit(s) in SCT layer 2");
64  declareProperty("RemoveSCT3" , m_removeParts[Parts::kSct3] , "Remove hit(s) in SCT layer 3");
65 
66  declareProperty("RemoveSCT4" , m_removeParts[Parts::kSct4] , "Remove hit(s) in SCT endcap layer 4");
67  declareProperty("RemoveSCT5" , m_removeParts[Parts::kSct5] , "Remove hit(s) in SCT endcap layer 5");
68  declareProperty("RemoveSCT6" , m_removeParts[Parts::kSct6] , "Remove hit(s) in SCT endcap layer 6");
69  declareProperty("RemoveSCT7" , m_removeParts[Parts::kSct7] , "Remove hit(s) in SCT endcap layer 7");
70  declareProperty("RemoveSCT8" , m_removeParts[Parts::kSct8] , "Remove hit(s) in SCT endcap layer 8");
71 
72  declareProperty("RemoveSCTSide0" , m_removeParts[Parts::kSctSide0] , "Remove SCT hits on side 0");
73  declareProperty("RemoveSCTSide1" , m_removeParts[Parts::kSctSide1] , "Remove SCT hits on side 1");
74 
75  declareProperty("RemoveOverlapHitsOnly" , m_removeOverlapHitsOnly, "Only remove overlap track hits");
76  declareProperty("IgnoreTrackEnds" , m_ignoreTrackEnds , "Ignore hits at the end of the track");
77 
78  declareProperty("RandomRemovalMode" , m_randomRemovalMode , "Randomly remove track hits (overwrites the other flags!)");
79  declareProperty("MaximalHoles" , m_maxNumberOfHoles , "Number of maximal holes to be created");
80 
81  declare( m_trackCollectionOutputKey );
82 
83  // start with 10x10
84  m_trackStats = std::vector< std::vector< unsigned int> >(0, std::vector< unsigned int>(0));
85 }
86 
88 
90  ATH_MSG_INFO( "HoleSearchValidation initialize()" ) ;
91 
92  //ID Helper
93  StatusCode sc = detStore()->retrieve(m_idHelper, "AtlasID" );
94  if (sc.isFailure()) {
95  ATH_MSG_WARNING( "Could not get AtlasDetectorID !" ) ;
96  return StatusCode::SUCCESS;
97  }else{
98  ATH_MSG_DEBUG( "Found AtlasDetectorID" ) ;
99  }
100 
101  sc = detStore()->retrieve(m_pixelID, "PixelID");
102  if (sc.isFailure()) {
103  ATH_MSG_WARNING( "Could not get Pixel ID helper !" ) ;
104  return StatusCode::SUCCESS;
105  }
106  ATH_MSG_DEBUG( "Initialized PixelIDHelper" ) ;
107 
108  sc = detStore()->retrieve(m_sctID, "SCT_ID");
109  if (sc.isFailure()) {
110  ATH_MSG_WARNING( "Could not get SCT ID helper !" ) ;
111  return StatusCode::SUCCESS;
112  }
113  ATH_MSG_DEBUG( "Initialized SCTIDHelper" ) ;
114 
115  sc = detStore()->retrieve(m_trtID, "TRT_ID");
116  if (sc.isFailure()) {
117  ATH_MSG_WARNING( "Could not get TRT ID helper !" ) ;
118  return StatusCode::SUCCESS;
119  }
120  ATH_MSG_DEBUG( "Initialized TRTIDHelper" ) ;
121 
122  sc = detStore()->retrieve(m_siliconID, "SiliconID");
123  if (sc.isFailure()) {
124  ATH_MSG_WARNING( "Could not get Silicon ID helper !" ) ;
125  return StatusCode::SUCCESS;
126  }
127  ATH_MSG_DEBUG( "Initialized SiliconIDHelper" ) ;
128 
129 
130  // Get HoleSearchTool
131  sc = m_holeSearchTool.retrieve();
132  if (sc.isFailure()) {
133  ATH_MSG_FATAL( "Could not retrieve "<< m_holeSearchTool ) ;
134  return sc;
135  }
136 
137  if ( m_rndmGenSvc.retrieve().isFailure() ){
138  ATH_MSG_FATAL( "Could not retrieve " << m_rndmGenSvc );
139  return StatusCode::FAILURE;
140  }
141 
142  ATH_CHECK(m_trackCollectionKey.initialize());
143  if (m_saveNewTracksInSG) {
144  m_trackCollectionOutputKey = m_trackCollectionKey.key() + "_removedHits";
146  }
147 
148  return StatusCode::SUCCESS;
149 }
150 
151 StatusCode HoleSearchValidation::execute(const EventContext& ctx) const {
152 
153  ATHRNG::RNGWrapper* wrapper = m_rndmGenSvc->getEngine(this, m_randomEngineName);
154  wrapper->setSeed (this->name(), ctx);
155  CLHEP::HepRandomEngine* engine = wrapper->getEngine (ctx);
156 
157  std::array<bool,Parts::kNParts> remove_parts{};
158  for (unsigned int part_i=0; part_i<Parts::kNParts; ++part_i) {
159  remove_parts[part_i]=( !m_randomRemovalMode ? m_removeParts[part_i] : false );
160  }
161  ATH_MSG_VERBOSE( "HoleSearchValidation execute() start" ) ;
162 
163  std::unique_ptr<TrackCollection> newTrackCollection( m_saveNewTracksInSG ? std::make_unique<TrackCollection>() : nullptr );
164 
165  // get track collection
167  if (!tracks.isValid()) {
168  ATH_MSG_ERROR("Missing input track collection " << m_trackCollectionKey.key());
169  return StatusCode::FAILURE;
170  }
171 
172  // loop over tracks
173  TrackCollection::const_iterator trackIterator = tracks->begin();
174  for ( ; trackIterator < tracks->end(); ++trackIterator) {
175  if (!((*trackIterator))) {
176  ATH_MSG_WARNING( "TrackCollection " << m_trackCollectionKey.key() << "contains empty entries" ) ;
177  continue;
178  }
179 
180  // get all TSOS
181  const Trk::Track& track = *(*trackIterator);
182  const Trk::TrackStates* tsos = track.trackStateOnSurfaces();
183  ATH_MSG_DEBUG( "Perform hole search on unmodified track (" << *trackIterator << ")"
184  << " which contains " << tsos->size() <<" track states" ) ;
185  // perform hole search
186  unsigned int oldHoles = doHoleSearch( *trackIterator );
187 
188  auto vecTsos = std::make_unique<Trk::TrackStates>();
189 
190  // loop over TSOS, copy TSOS and push into vector
191  Trk::TrackStates::const_iterator iTsos = tsos->begin();
192  Trk::TrackStates::const_iterator iTsosEnd = tsos->end();
193 
194  unsigned int nRemoved = 0;
195 
196  std::vector< unsigned int > pixelHitsPerLayer = std::vector< unsigned int>(3);
197  std::vector< unsigned int > sctHitsPerLayer = std::vector< unsigned int>(9);
198 
199  // in case of removing the end hits we need to parse the track first once,
200  // variables will be call pl (for preloop)
201  int maxPixelLayerBarrel = -1;
202  int maxPixelLayerEndcap = -1;
203  int maxSctLayerBarrel = -1;
204  int maxSctLayerEndcap = -1;
205 
207  ATH_MSG_VERBOSE( "Parsing track first to find end layers and maximal numbers" ) ;
208  for ( ; iTsos != iTsosEnd ; ++iTsos) {
209  //
210  Identifier plSurfaceID;
211  const Trk::MeasurementBase* plMesb = (*iTsos)->measurementOnTrack();
212  if (plMesb && plMesb->associatedSurface().associatedDetectorElement()){
213  plSurfaceID = plMesb->associatedSurface().associatedDetectorElement()->identify();
214  // to find out whether it is barrel / endcap
215  // check pixel / sct
216  if ( m_idHelper->is_pixel( plSurfaceID ) ) {
217  int plLayer = abs(m_pixelID->layer_disk( plSurfaceID ));
218  bool isBarrel = m_pixelID->is_barrel( plSurfaceID );
219  // set the maximal pixel layer: barrel / ec
220  if ( isBarrel )
221  maxPixelLayerBarrel = plLayer > maxPixelLayerBarrel ? plLayer : maxPixelLayerBarrel;
222  else
223  maxPixelLayerEndcap = plLayer > maxPixelLayerEndcap ? plLayer : maxPixelLayerEndcap;
224  } else if (m_idHelper->is_sct( plSurfaceID ) ) {
225  int plLayer = abs(m_sctID->layer_disk( plSurfaceID ));
226  bool isBarrel = m_sctID->is_barrel( plSurfaceID );
227  // set the maximal pixel layer: barrel / ec
228  if ( isBarrel )
229  maxSctLayerBarrel = plLayer > maxSctLayerBarrel ? plLayer : maxSctLayerBarrel;
230  else
231  maxSctLayerEndcap = plLayer > maxSctLayerEndcap ? plLayer : maxSctLayerEndcap;
232  }
233  }
234  }
235  // sct overrules pixels
236  maxPixelLayerBarrel = maxSctLayerBarrel > 0 ? -1 : maxPixelLayerBarrel;
237  maxPixelLayerEndcap = maxSctLayerEndcap > 0 ? -1 : maxPixelLayerEndcap;
238  // reset to start the main loop correctly
239  iTsos = tsos->begin();
240  }
241 
242 
243  for ( ; iTsos != iTsosEnd ; ++iTsos) {
244  if ((*iTsos)->type(Trk::TrackStateOnSurface::Measurement)) {
245 
246  Identifier surfaceID;
247  const Trk::MeasurementBase* mesb = (*iTsos)->measurementOnTrack();
248 
249  // also reset the identifiers
250  unsigned int randomHoles = 0;
251  if (m_randomRemovalMode){
252  // ---------------------------------------------------------------------------------------
253  randomHoles = (unsigned int)(m_maxNumberOfHoles*CLHEP::RandFlat::shoot(engine));
254  ATH_MSG_VERBOSE("Random mode chosen: will create " << randomHoles << " holes on the track.");
255 
256  // max int pixel
257  unsigned int maxPixel = maxPixelLayerBarrel > maxPixelLayerEndcap
258  ? maxPixelLayerBarrel : maxPixelLayerEndcap;
259  // max int sct
260  unsigned int maxSct = maxSctLayerBarrel > maxSctLayerEndcap
261  ? maxSctLayerBarrel : maxSctLayerEndcap;
262  // -------------------------------------------------------------------
263  int maxHit = maxPixel + maxSct;
264  int holesTriggered = 0;
265  maxHit -= m_ignoreTrackEnds ? 1 : 0;
266  // make the switch
267  for (unsigned int ihole = 0; ihole < randomHoles && holesTriggered < int(randomHoles); ++ihole){
268  // throw the dices
269  unsigned int holeId = (unsigned int)(maxHit*CLHEP::RandFlat::shoot(engine));
270  ATH_MSG_VERBOSE( "Random mode : layer identifier " << holeId << " chosen." );
271  {
272  // now switch between --------
273  switch (holeId) {
274  case 0 : { remove_parts[Parts::kPix0] = true; ++holesTriggered; }; break;
275  case 1 : { remove_parts[Parts::kPix1] = true; ++holesTriggered; }; break;
276  case 2 : { remove_parts[Parts::kPix2] = true; ++holesTriggered; }; break;
277  case 3 : { remove_parts[Parts::kSct0] = true; ++holesTriggered; }; break;
278  case 4 : { remove_parts[Parts::kSct1] = true; ++holesTriggered; }; break;
279  case 5 : { remove_parts[Parts::kSct2] = true; ++holesTriggered; }; break;
280  case 6 : { remove_parts[Parts::kSct3] = true; ++holesTriggered; }; break;
281  case 7 : { remove_parts[Parts::kSct4] = true; ++holesTriggered; }; break;
282  case 8 : { remove_parts[Parts::kSct5] = true; ++holesTriggered; }; break;
283  case 9 : { remove_parts[Parts::kSct6] = true; ++holesTriggered; }; break;
284  case 10 : { remove_parts[Parts::kSct7] = true; ++holesTriggered; }; break;
285  case 11 : { remove_parts[Parts::kSct8] = true; ++holesTriggered; }; break;
286  default : break;
287  }
288  // make the side decision on the side
289  if (holeId > 2) {
290  double sideDecision = CLHEP::RandFlat::shoot(engine);
291  if ( sideDecision < 1./3. )
292  remove_parts[Parts::kSctSide0] = true;
293  else if ( sideDecision < 2./3. )
294  remove_parts[Parts::kSctSide1] = true;
295  else {
296  remove_parts[Parts::kSctSide0] = true;
297  remove_parts[Parts::kSctSide1] = true;
298  ++holesTriggered;
299  }
300  }
301  }
302  }
303  }
304 
305  // hits, outliers
306  if (mesb != nullptr && mesb->associatedSurface().associatedDetectorElement() != nullptr) {
307  surfaceID = mesb->associatedSurface().associatedDetectorElement()->identify();
308  // the pixel case
309  if ( m_idHelper->is_pixel( surfaceID ) ) {
310  int layer = abs(m_pixelID->layer_disk( surfaceID ));
311  // check barrel / ec
312  bool isBarrel = m_pixelID->is_barrel( surfaceID );
313  // indicate how many pixel hits are per layer
314  pixelHitsPerLayer[layer]++;
315  ATH_MSG_VERBOSE( "Pixel hits on layer " << layer << " : " << pixelHitsPerLayer[layer] ) ;
316  // check for last layer
317  bool isLastLayer = (isBarrel && layer == maxPixelLayerBarrel) || (!isBarrel && layer == maxPixelLayerEndcap);
318  // only in the ignore track case
319  if (m_ignoreTrackEnds && isLastLayer){
320  ATH_MSG_VERBOSE( "This pixel hit is not removed, it is at the track end." ) ;
321  } else if ( !m_removeOverlapHitsOnly || pixelHitsPerLayer[layer] > 1) {
322  if ( !m_ignoreTrackEnds && layer == 0 && remove_parts[Parts::kPix0] ) {
323  ATH_MSG_DEBUG( "Removing PIXEL layer 0 hit" ) ;
324  printInfoTSoS( *iTsos );
325  nRemoved++;
326  continue;
327  } else if( layer == 1 && remove_parts[Parts::kPix1] ) {
328  ATH_MSG_DEBUG( "Removing PIXEL layer 1 hit" ) ;
329  printInfoTSoS( *iTsos );
330  nRemoved++;
331  continue;
332  } else if( layer == 2 && remove_parts[Parts::kPix2] ) {
333  ATH_MSG_DEBUG( "Removing PIXEL layer 2 hit" ) ;
334  printInfoTSoS( *iTsos );
335  nRemoved++;
336  continue;
337  }
338  }
339  } else if ( m_idHelper->is_sct( surfaceID ) ) {
340  int layer = abs(m_sctID->layer_disk( surfaceID ));
341  // check barrel / ec
342  bool isBarrel = m_sctID->is_barrel( surfaceID );
343  // counter for number of layers
344  sctHitsPerLayer[layer]++;
345  ATH_MSG_VERBOSE( "SCT hits on layer " << layer << " : " << sctHitsPerLayer[layer] ) ;
346  // steer the side to be removed
347  int side = m_sctID->side( surfaceID );
348  bool canRemoveSide = (side == 0) ? remove_parts[Parts::kSctSide0] : remove_parts[Parts::kSctSide1];
349  // check for last layer
350  bool isLastLayer = (isBarrel && layer == maxSctLayerBarrel) || (!isBarrel && layer == maxSctLayerEndcap);
351  // only in the ignore track case
352  if (m_ignoreTrackEnds && isLastLayer){
353  ATH_MSG_VERBOSE( "This SCT hit is not removed, it is at the track end." ) ;
354  } else if ( layer == 0 && remove_parts[Parts::kSct0] && canRemoveSide ) {
355  ATH_MSG_DEBUG( "Removing SCT layer 0 hit" ) ;
356  printInfoTSoS( *iTsos );
357  nRemoved++;
358  continue;
359  } else if ( layer == 1 && remove_parts[Parts::kSct1] && canRemoveSide ) {
360  ATH_MSG_DEBUG( "Removing SCT layer 1 hit" ) ;
361  printInfoTSoS( *iTsos );
362  nRemoved++;
363  continue;
364  } else if ( layer == 2 && remove_parts[Parts::kSct2] && canRemoveSide ) {
365  ATH_MSG_DEBUG( "Removing SCT layer 2 hit" ) ;
366  printInfoTSoS( *iTsos );
367  nRemoved++;
368  continue;
369  } else if ( layer == 3 && remove_parts[Parts::kSct3] && canRemoveSide ) {
370  ATH_MSG_DEBUG( "Removing SCT layer 3 hit" ) ;
371  printInfoTSoS( *iTsos );
372  nRemoved++;
373  continue;
374  } else if ( layer == 4 && remove_parts[Parts::kSct4] && canRemoveSide ) {
375  ATH_MSG_DEBUG( "Removing SCT endcap layer 4 hit" ) ;
376  printInfoTSoS( *iTsos );
377  nRemoved++;
378  continue;
379  } else if ( layer == 5 && remove_parts[Parts::kSct5] && canRemoveSide ) {
380  ATH_MSG_DEBUG( "Removing SCT endcap layer 5 hit" ) ;
381  printInfoTSoS( *iTsos );
382  nRemoved++;
383  continue;
384  } else if ( layer == 6 && remove_parts[Parts::kSct6] && canRemoveSide ) {
385  ATH_MSG_DEBUG( "Removing SCT endcap layer 6 hit" ) ;
386  printInfoTSoS( *iTsos );
387  nRemoved++;
388  continue;
389  } else if ( layer == 7 && remove_parts[Parts::kSct7] && canRemoveSide ) {
390  ATH_MSG_DEBUG( "Removing SCT endcap layer 7 hit" ) ;
391  printInfoTSoS( *iTsos );
392  nRemoved++;
393  continue;
394  } else if ( layer == 8 && remove_parts[Parts::kSct8] && canRemoveSide ) {
395  ATH_MSG_DEBUG( "Removing SCT endcap layer 8 hit" ) ;
396  printInfoTSoS( *iTsos );
397  nRemoved++;
398  continue;
399  }
400 
401  } // end SCT hit
402  } // end have identifier
403  } // end TSoS is of type measurement
404 
405  const Trk::TrackStateOnSurface* newTsos = new Trk::TrackStateOnSurface(**iTsos);
406  vecTsos->push_back(newTsos);
407  } // end loop over all TSoS
408 
409  ATH_MSG_DEBUG( "Removed total of " << nRemoved << " TSoS on track." ) ;
410 
411  Trk::Track* newTrack = new Trk::Track(track.info(), std::move(vecTsos), nullptr );
412  ATH_MSG_VERBOSE( "Perform hole search on new track:" ) ;
413  // perform hole search
414  unsigned int newHoles = doHoleSearch( newTrack );
415  unsigned int foundHoles = abs(static_cast<int>(newHoles) - static_cast<int>(oldHoles));
416 
417  if ( foundHoles == nRemoved )
418  ATH_MSG_DEBUG( "== OK : "<< nRemoved <<" generated holes out of which all were found" ) ;
419  else
420  ATH_MSG_DEBUG( "== PROBLEM : "<< nRemoved <<" generated holes out of which "<< newHoles - oldHoles << " were found" ) ;
421 
422  // fill track statistics
423  // first, check size of vectors
424  {
425  std::lock_guard<std::mutex> lock(m_trackStatsMutex);
426  while (m_trackStats.size() < nRemoved+1) {
427  m_trackStats.emplace_back(0 );
428  }
429  while (m_trackStats[nRemoved].size() < foundHoles+1) {
430  m_trackStats[nRemoved].push_back( 0 );
431  }
432  ATH_MSG_DEBUG( "m_trackStats.size()= " << m_trackStats.size() );
433  // // increase counter
434  m_trackStats[nRemoved][foundHoles]++;
435  }
436 
437  // posibly save new track into container and SG
438  if (m_saveNewTracksInSG) {
439  newTrackCollection->push_back( newTrack );
440  } else {
441  delete newTrack; // TSOS are owned by track (so no need to delete them manually)
442  }
443 
444  } // end loop over all input tracks
445  ATH_MSG_DEBUG( "Finished looping over all input tracks" ) ;
446 
447  if (m_saveNewTracksInSG) {
448  SG::WriteHandle<TrackCollection> newTrackCollection_handle(m_trackCollectionOutputKey,ctx);
449  if (newTrackCollection_handle.record( std::move(newTrackCollection) ).isFailure()){
450  ATH_MSG_ERROR("Failed to record output collection " << m_trackCollectionOutputKey.key());
451  return StatusCode::FAILURE;
452  }
453  }
454  return StatusCode::SUCCESS;
455 }
456 
458  ATH_MSG_INFO( "HoleSearchValidation finalize()" ) ;
459 
460  ATH_MSG_INFO( "Printing statistics for hole search validation:" ) ;
461  ATH_MSG_INFO( " # removed hits | # tracks / found holes | ... " ) ;
462  for ( unsigned int nRemoved = 0; nRemoved < m_trackStats.size(); ++nRemoved) {
463  unsigned int nTracks = 0;
464  for ( unsigned int holes = 0; holes < m_trackStats[nRemoved].size(); ++holes) nTracks += m_trackStats[nRemoved][holes];
465  if ( nTracks == 0) continue;
466  ATH_MSG_INFO( "Removed " << nRemoved << " hits from track -- found: " ) ;
467  for ( unsigned int holes = 0; holes < m_trackStats[nRemoved].size(); ++holes) {
468  ATH_MSG_INFO( " -- " << 100.0 * m_trackStats[nRemoved][holes]/float(nTracks)
469  << "% of tracks with " << holes << " holes (" << m_trackStats[nRemoved][holes] << " / " << float(nTracks) << ")") ;
470  }
471  }
472 
473  return StatusCode::SUCCESS;
474 }
475 
477 {
478  ATH_MSG_VERBOSE( "start hole search for track ( " << track << ")" ) ;
479  unsigned int nHoles(0);
480 
481  std::unique_ptr<const Trk::TrackStates> holesOnTrack
482  (m_holeSearchTool->getHolesOnTrack(*track, track->info().particleHypothesis()));
483  // loop over holes
484  if (!holesOnTrack) {
485  ATH_MSG_WARNING( "HoleSearchTool returned NULL !" ) ;
486  return nHoles;
487  } else {
488  nHoles = holesOnTrack->size();
489  ATH_MSG_DEBUG( "found " << nHoles << " holes on track." ) ;
490  for (Trk::TrackStates::const_iterator it=holesOnTrack->begin();
491  it!=holesOnTrack->end(); ++it) {
492  if (!(*it)) {
493  ATH_MSG_WARNING( "TrackStateOnSurface from hole search tool == Null" ) ;
494  continue;
495  }
496  ATH_MSG_DEBUG( "Found hole:" ) ;
497  printInfoTSoS( *it );
498  } // end loop on holes
499  }
500  return nHoles;
501 }
502 
503 
505 {
506 
507  ATH_MSG_VERBOSE( "Position : " << tsos->trackParameters()->position()
508  << " with R = " << sqrt(pow(tsos->trackParameters()->position().x(),2)
509  +pow(tsos->trackParameters()->position().y(),2)) );
510  Identifier surfaceID;
511  const Trk::MeasurementBase* mesb = tsos->measurementOnTrack();
512  // hits, outliers
513  if (mesb != nullptr && mesb->associatedSurface().associatedDetectorElement() != nullptr) {
514  surfaceID = mesb->associatedSurface().associatedDetectorElement()->identify();
515  if ( m_siliconID->is_barrel( surfaceID ) ) {
516  ATH_MSG_VERBOSE( " -- Barrel:");
517  } else {
518  ATH_MSG_VERBOSE( " -- Endcap:");
519  }
520  if ( m_idHelper->is_sct( surfaceID ) ) {
521  ATH_MSG_VERBOSE( " -> SCT layer = " << m_sctID->layer_disk( surfaceID )
522  << " side = " << m_sctID->side( surfaceID ) );
523  //ATH_MSG_VERBOSE( m_sctID->show_to_string(surfaceID) ) ;
524 
525  }
526  if ( m_idHelper->is_pixel( surfaceID ) ) {
527  ATH_MSG_VERBOSE( " -> PIXEL layer = " << m_pixelID->layer_disk( surfaceID ) );
528  //ATH_MSG_VERBOSE( m_pixelID->show_to_string(surfaceID) ) ;
529  }
530  }
531 
532 }
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
AtlasDetectorID::is_pixel
bool is_pixel(Identifier id) const
Definition: AtlasDetectorID.h:760
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition: RNGWrapper.h:169
Trk::TrackStateOnSurface::trackParameters
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
InDet::HoleSearchValidation::m_randomEngineName
std::string m_randomEngineName
Name of the random number stream.
Definition: HoleSearchValidation.h:114
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
InDet::HoleSearchValidation::Parts::kSct5
@ kSct5
Definition: HoleSearchValidation.h:96
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
Trk::Surface::associatedDetectorElement
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
MeasurementBase.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HoleSearchValidation.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:770
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
InDetDD::holes
@ holes
Definition: InDetDD_Defs.h:17
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::HoleSearchValidation::printInfoTSoS
void printInfoTSoS(const Trk::TrackStateOnSurface *tsos) const
Definition: HoleSearchValidation.cxx:504
InDet::HoleSearchValidation::Parts::kPix2
@ kPix2
Definition: HoleSearchValidation.h:89
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
xAOD::JetInput::Track
@ Track
Definition: JetContainerInfo.h:61
SiliconID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - generic, i.e. works for EITHER pixel or sct id.
Definition: SiliconID.h:156
InDet::HoleSearchValidation::Parts::kSct3
@ kSct3
Definition: HoleSearchValidation.h:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
InDet::HoleSearchValidation::Parts::kSct8
@ kSct8
Definition: HoleSearchValidation.h:99
InDet::HoleSearchValidation::Parts::kSct6
@ kSct6
Definition: HoleSearchValidation.h:97
InDet::HoleSearchValidation::m_removeParts
bool m_removeParts[Parts::kNParts]
Definition: HoleSearchValidation.h:106
InDet::HoleSearchValidation::m_maxNumberOfHoles
unsigned int m_maxNumberOfHoles
Definition: HoleSearchValidation.h:111
Trk::TrackStateOnSurface::measurementOnTrack
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
InDet::HoleSearchValidation::m_rndmGenSvc
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
Random number generator.
Definition: HoleSearchValidation.h:113
Trk::TrkDetElementBase::identify
virtual Identifier identify() const =0
Identifier.
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
InDet::HoleSearchValidation::m_ignoreTrackEnds
bool m_ignoreTrackEnds
Definition: HoleSearchValidation.h:108
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
TRT::Hit::side
@ side
Definition: HitInfo.h:83
Track.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
InDet::HoleSearchValidation::m_sctID
const SCT_ID * m_sctID
Definition: HoleSearchValidation.h:73
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
PixelID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - WARNING: id MUST be pixel id, otherwise answer is not accurate. Use SiliconID for g...
Definition: PixelID.h:605
InDet::HoleSearchValidation::m_trackStatsMutex
std::mutex m_trackStatsMutex
Definition: HoleSearchValidation.h:117
InDet::HoleSearchValidation::Parts::kSct4
@ kSct4
Definition: HoleSearchValidation.h:95
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::HoleSearchValidation::m_holeSearchTool
ToolHandle< Trk::ITrackHoleSearchTool > m_holeSearchTool
Definition: HoleSearchValidation.h:77
InDet::HoleSearchValidation::m_trackCollectionKey
SG::ReadHandleKey< TrackCollection > m_trackCollectionKey
jobOption: name of the TrackCollection
Definition: HoleSearchValidation.h:78
InDet::HoleSearchValidation::Parts::kPix1
@ kPix1
Definition: HoleSearchValidation.h:88
InDet::HoleSearchValidation::Parts::kSct1
@ kSct1
Definition: HoleSearchValidation.h:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
InDet::HoleSearchValidation::Parts::kPix0
@ kPix0
Definition: HoleSearchValidation.h:87
SiliconID.h
This is an Identifier helper class for both the Pixel and SCT subdetectors. This class defines identi...
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::HoleSearchValidation::doHoleSearch
unsigned int doHoleSearch(const Trk::Track *track) const
Definition: HoleSearchValidation.cxx:476
InDet::HoleSearchValidation::HoleSearchValidation
HoleSearchValidation(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: HoleSearchValidation.cxx:30
InDet::HoleSearchValidation::~HoleSearchValidation
~HoleSearchValidation()
Default Destructor.
InDet::HoleSearchValidation::Parts::kSct7
@ kSct7
Definition: HoleSearchValidation.h:98
DataVector< const Trk::TrackStateOnSurface >
InDet::HoleSearchValidation::m_saveNewTracksInSG
bool m_saveNewTracksInSG
jobOption: save new tracks to SG ?
Definition: HoleSearchValidation.h:82
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
InDet::HoleSearchValidation::m_idHelper
const AtlasDetectorID * m_idHelper
Definition: HoleSearchValidation.h:71
InDet::HoleSearchValidation::m_trtID
const TRT_ID * m_trtID
Definition: HoleSearchValidation.h:74
Trk::MeasurementBase
Definition: MeasurementBase.h:58
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
ITrackHoleSearchTool.h
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Trk::MeasurementBase::associatedSurface
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
InDet::HoleSearchValidation::m_pixelID
const PixelID * m_pixelID
Definition: HoleSearchValidation.h:72
InDet::HoleSearchValidation::Parts::kSct2
@ kSct2
Definition: HoleSearchValidation.h:93
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition: RNGWrapper.h:134
RNGWrapper.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
InDet::HoleSearchValidation::Parts::kSctSide1
@ kSctSide1
Definition: HoleSearchValidation.h:101
InDet::HoleSearchValidation::m_siliconID
const SiliconID * m_siliconID
Definition: HoleSearchValidation.h:75
InDet::HoleSearchValidation::m_trackCollectionOutputKey
SG::WriteHandleKey< TrackCollection > m_trackCollectionOutputKey
jobOption: name of the TrackCollection
Definition: HoleSearchValidation.h:79
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
InDet::HoleSearchValidation::m_removeOverlapHitsOnly
bool m_removeOverlapHitsOnly
Definition: HoleSearchValidation.h:107
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.LArCondContChannels.isBarrel
isBarrel
Definition: LArCondContChannels.py:659
InDet::HoleSearchValidation::Parts::kSctSide0
@ kSctSide0
Definition: HoleSearchValidation.h:100
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
InDet::HoleSearchValidation::m_randomRemovalMode
bool m_randomRemovalMode
Definition: HoleSearchValidation.h:110
InDet::HoleSearchValidation::Parts::kNParts
@ kNParts
Definition: HoleSearchValidation.h:102
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDet::HoleSearchValidation::Parts::kSct0
@ kSct0
Definition: HoleSearchValidation.h:91
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
InDet::HoleSearchValidation::finalize
StatusCode finalize()
standard Athena-Algorithm method
Definition: HoleSearchValidation.cxx:457
SCT_ID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - WARNING: id MUST be sct id, otherwise answer is not accurate. Use SiliconID for gen...
Definition: SCT_ID.h:721
InDet::HoleSearchValidation::execute
StatusCode execute(const EventContext &ctx) const
standard Athena-Algorithm method
Definition: HoleSearchValidation.cxx:151
InDet::HoleSearchValidation::initialize
StatusCode initialize()
standard Athena-Algorithm method
Definition: HoleSearchValidation.cxx:89
Identifier
Definition: IdentifierFieldParser.cxx:14