ATLAS Offline Software
TrackRetriever.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 #include "GaudiKernel/IToolSvc.h"
7 #include "GaudiKernel/ListItem.h"
8 
9 #include "TrkTrack/Track.h"
10 #include "TrkTrack/TrackInfo.h"
14 
15 
23 #include "AthLinks/ElementLink.h"
25 
28 
30 
31 // for residuals
34 
35 // for detector id
37 
38 #include "GaudiKernel/SystemOfUnits.h"
39 
40 namespace JiveXML {
42  namespace TrackRetrieverHelpers {
43 
53 
59  const Trk::Perigee *perigee = track->perigeeParameters();
60 
61  //return immediately if there is no perigee information
62  if (! perigee) return nullptr ;
63 
64  //write out p_T
65  if ((perigee->parameters())[Trk::qOverP]==0) pt.emplace_back(9999.);
66  else pt.push_back( (perigee->charge() > 0) ? DataType(perigee->pT()/Gaudi::Units::GeV) : DataType((-perigee->pT())/Gaudi::Units::GeV));
67 
68  d0.emplace_back((perigee->parameters())[Trk::d0]/Gaudi::Units::cm);
69  z0.emplace_back(perigee->parameters()[Trk::z0]/Gaudi::Units::cm);
70  phi0.emplace_back(perigee->parameters()[Trk::phi0]);
71 
72  if (perigee->parameters()[Trk::theta] == 0.) cotTheta.emplace_back(9999.);
73  else cotTheta.emplace_back(1./tan(perigee->parameters()[Trk::theta]));
74 
75  // CLHEP->Eigen migration. jpt Dec'13
76  // https://twiki.cern.ch/twiki/bin/viewauth/Atlas/MigrationCLHEPtoEigen
77  // https://twiki.cern.ch/twiki/bin/viewauth/Atlas/MigrationToUpdatedEDM#Changes_to_TrkParameters
78 
80  AmgSymMatrix(5) covVert;
81 
82  const AmgSymMatrix(5)* covariance = perigee->covariance(); //perigee cannot be null here
83  if (perigee && covariance) {
84  // do trafo to old format
85  double measuredTheta = perigee->parameters()[Trk::theta];
86  double measuredQoverp = perigee->parameters()[Trk::qOverP];
87  const Trk::JacobianThetaPToCotThetaPt theJac( measuredTheta, measuredQoverp );
88  covVert = covariance->similarity(theJac);
89  }else{
90  for ( int ii=0; ii<20; ii++){ // placeholder. Do this nicer.
91  covVert(ii) = 0.;
92  }
93  }
94  //Scale covariance matrix values to get good resolution with fixed
95  //precision in JiveXML data
96 
97  const long scale = 10000;
98  const double thisScale(scale/100.);
99  // Migration: Now only has diagonal elements from covariance matrix ?
100  covMatrix.emplace_back(covVert(0)*thisScale); // 5 elements
101  covMatrix.emplace_back(covVert(1)*thisScale);
102  covMatrix.emplace_back(covVert(2)*thisScale);
103  covMatrix.emplace_back(covVert(3)*thisScale);
104  covMatrix.emplace_back(covVert(4)*thisScale);
105 
106  // Used to be 15 elements before migration, so need to put 10 placeholders
107  for ( int i=0; i<10; i++){
108  covMatrix.emplace_back( 0. );
109  }
110 
111  //All for perigee, return object for use by other functions
112  return perigee ;
113  }
114 
120  std::vector<const Trk::TrackStateOnSurface*> getTrackStateOnSurfaces( const Trk::Track* track, const Trk::Perigee* perigee, bool doHitsSorting){
121  // vector for the return object
122  std::vector<const Trk::TrackStateOnSurface*> TSoSVec;
123 
124  // loop over TrackStateOnSurfaces to extract interesting ones
125  Trk::TrackStates::const_iterator tsos = track->trackStateOnSurfaces()->begin();
126  for (; tsos!=track->trackStateOnSurfaces()->end(); ++tsos) {
127  // include measurements AND outliers:
128  if ((*tsos)->type(Trk::TrackStateOnSurface::Measurement) || (*tsos)->type(Trk::TrackStateOnSurface::Outlier) ) {
129  // add to temp vector
130  TSoSVec.push_back(*tsos);
131  } // end if TSoS is measurement or outlier
132  } // end loop over TSoS
133 
134  // sort the selected TSoS, if not already sorted using a comparison functor
135 
136  if (perigee) {
137  //Get hold of the comparison functor
139  = new Trk::TrackStateOnSurfaceComparisonFunction(perigee->position(), perigee->momentum(\
140  ));
141  if (compFunc){
142  if (doHitsSorting) {
143  //Sort track state on surface if needed
144  if (TSoSVec.size() > 2 && !is_sorted(TSoSVec.begin(), TSoSVec.end(), *compFunc))
145  std::sort(TSoSVec.begin(), TSoSVec.end(), *compFunc);
146  }
147  }
148  delete compFunc;
149  } // end if compFunc
150 
151  //Now return that vector
152  return TSoSVec;
153  }
154 
158  void getPolylineFromHits( const std::vector<const Trk::TrackStateOnSurface*>& TSoSVec,
159  DataVect& polylineX, DataVect& polylineY, DataVect& polylineZ, DataVect& numPolyline){
160  int numPoly = 0 ;
161  if (TSoSVec.size() > 1) {
162  //Loop over track state on surfaces
163  std::vector<const Trk::TrackStateOnSurface*>::const_iterator tsosIter;
164  const double onetenth(0.1);
165  for (tsosIter=TSoSVec.begin(); tsosIter!=TSoSVec.end(); ++tsosIter) {
166  // get global track position
167  if (!(*tsosIter)->trackParameters()) continue ;
168  const Amg::Vector3D& pos = (*tsosIter)->trackParameters()->position();
169  polylineX.emplace_back(pos.x()*onetenth);
170  polylineY.emplace_back(pos.y()*onetenth);
171  polylineZ.emplace_back(pos.z()*onetenth);
172  ++numPoly;
173  }
174  }
175  //Store counter as well
176  numPolyline.emplace_back(numPoly);
177  }
178 
179 
185  DataVect& isOutlier, DataVect& hits, DataVect& driftSign, DataVect& tsosDetType){
186 
187  //Get corresponding measurement
188  const Trk::MeasurementBase *measurement = tsos->measurementOnTrack();
189 
190  //If measurement is invalid, return imediately
191  if ( ! measurement ) return nullptr ;
192 
193  // get RIO_OnTrack
194  const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(measurement);
195 
196  // check for competing RIO_OnTracks
197  if (!rot) {
198  // try to get identifier by CompetingROT:
199  const Trk::CompetingRIOsOnTrack* comprot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(measurement);
200  //Get the input object with highest probability
201  if (comprot) rot = &(comprot->rioOnTrack(comprot->indexOfMaxAssignProb()));
202  }
203 
204  //If there is still no RIO_onTrack, return Null
205  if (!rot) return nullptr ;
206 
207  // Now start writing out values:
208  // Check if this is an outlier hit
209  isOutlier.emplace_back(tsos->type(Trk::TrackStateOnSurface::Outlier));
210 
211  //Now try to get the identifier, create an empty invalid one if no rot
212  Identifier hitId (rot->identify());
213  //Check if it is valid, othwerise store 0
214  hits.push_back( hitId.is_valid()?DataType( hitId.get_compact() ):DataType(0) );
215 
216  // get sign of drift radius for TRT measurements
217  int theDriftSign = 0;
218  if (idHelper->is_trt(hitId)) {
219  // get local parameters
220  theDriftSign = measurement->localParameters()[Trk::driftRadius] > 0. ? 1 : -1;
221  }
222  driftSign.emplace_back(theDriftSign);
223 
224  //Now get the detector type of the hit
225  if ( !hitId.is_valid() ){
226  tsosDetType.emplace_back("unident");
227  } else if (idHelper->is_pixel(hitId) ) {
228  tsosDetType.emplace_back("PIX"); // is PIX in Atlantis
229  } else if (idHelper->is_sct(hitId)) {
230  tsosDetType.emplace_back("SIL"); // is SIL in Atlantis
231  } else if (idHelper->is_trt(hitId)) {
232  tsosDetType.emplace_back("TRT");
233  } else if (idHelper->is_mdt(hitId)) {
234  tsosDetType.emplace_back("MDT");
235  } else if (idHelper->is_csc(hitId)) {
236  tsosDetType.emplace_back("CSC");
237  } else if (idHelper->is_rpc(hitId)) {
238  tsosDetType.emplace_back("RPC");
239  } else if (idHelper->is_tgc(hitId)) {
240  tsosDetType.emplace_back("TGC");
241  } else {
242  tsosDetType.emplace_back("unident");
243  }
244 
245  //Return the reco input object
246  return rot;
247  }
248 
249 
254  const ToolHandle<Trk::IResidualPullCalculator> & residualPullCalculator,
255  DataVect& tsosResLoc1, DataVect& tsosResLoc2, DataVect& tsosPullLoc1, DataVect& tsosPullLoc2 ){
256 
257  //Define default return values for invalid states
258  double ResLoc1 = -99.;
259  double ResLoc2 = -99.;
260  double PullLoc1 = -99.;
261  double PullLoc2 = -99.;
262 
263  // get TrackParameters on the surface to calculate residual
264  const Trk::TrackParameters* tsosParameters = tsos->trackParameters();
265 
266  //Check we got the parameters
267  if (tsosParameters){
268 
274  //Get the residualPull object
275  std::optional<Trk::ResidualPull> residualPull = residualPullCalculator->residualPull(rot, tsosParameters,Trk::ResidualPull::Biased);
276 
277  if (residualPull) {
278  //Get the first residual
279  ResLoc1 = residualPull->residual()[Trk::loc1];
280  //Get the second residual for more than 1 dimension
281  if (residualPull->dimension() >= 2) ResLoc2 = residualPull->residual()[Trk::loc2];
282 
283  if ((residualPull->isPullValid()) ) {
284  //Get the first residual
285  PullLoc1 = residualPull->pull()[Trk::loc1];
286  //Get the second residual for more than 1 dimension
287  if (residualPull->dimension() >= 2) PullLoc2 = residualPull->pull()[Trk::loc2];
288  }
289  } // end if residualPull
290  } // end if tsosParameters
291 
292  //Finally store the values
293  tsosResLoc1.emplace_back(ResLoc1 );
294  tsosResLoc2.emplace_back(ResLoc2 );
295  tsosPullLoc1.emplace_back(PullLoc1 );
296  tsosPullLoc2.emplace_back(PullLoc2 );
297  }
298 
302  void getTruthFromTrack( const Trk::Track* track, const TrackCollection* trackCollection,
303  const TrackTruthCollection* truthCollection, DataVect& barcode){
304 
305  if (!truthCollection) {
306  //Fill with zero if none found
307  barcode.emplace_back(0);
308  return ;
309  }
310 
311  //Get the element link to this track collection
313  tracklink.setElement(track);
314  tracklink.setStorableObject(*trackCollection);
315 
316  //try to find it in the truth collection
317  std::map<Trk::TrackTruthKey,TrackTruth>::const_iterator tempTrackTruthItr = truthCollection->find(tracklink);
318 
319  //Fill with zero if none found
320  if (tempTrackTruthItr == truthCollection->end()){
321  //Fill with zero if none found
322  barcode.emplace_back(0);
323  return ;
324  }
325 
326  //if found, Store the barcode
327  barcode.emplace_back((*tempTrackTruthItr).second.particleLink().barcode());
328  }
329 
330  } //namespace TrackRetrieverHelpers
331 
338  TrackRetriever::TrackRetriever(const std::string& type,const std::string& name,const IInterface* parent):
340  m_typeName("Track"),
341  m_residualPullCalculator("Trk::ResidualPullCalculator/ResidualPullCalculator"),
342  m_idHelper(nullptr),
343  m_trackSumTool ("Trk::TrackSummaryTool/InDetTrackSummaryTool")
344  {
345  //Declare the interface
346  declareInterface<IDataRetriever>(this);
347  //Properties
348  declareProperty("ResidualPullCalculator" , m_residualPullCalculator, "ToolHandle to ResidualPullCaclulator" );
349  declareProperty("PriorityTrackCollection", m_PriorityTrackCollection = "CombinedInDetTracks", "Track collections to retrieve first, shown as default in Atlantis");
350  declareProperty("OtherTrackCollections" , m_OtherTrackCollections , "Track collections to retrieve, all if empty");
351  declareProperty("TrackTruthColName" , m_TrackTruthCollection = "TrackTruthCollection",
352  "Track collection from which to retrieve the truth associations for the priority track collection");
353  declareProperty("DoWriteHLT" , m_doWriteHLT = false, "Whether to write HLTAutoKey objects");
354  declareProperty("DoWriteResiduals" , m_doWriteResiduals = true, "Whether to write TrackResiduals");
355  declareProperty("DoHitsSorting" , m_doHitsSorting = false, "Whether to sort hits (TrackStateOnSurfaces)");
356  declareProperty("DoHitsDetails" , m_doHitsDetails = true, "Whether to write hits details (TrackStateOnSurfaces)");
357  }
358 
365  //Set up ATLAS ID helper to be able to identify the RIO's det-subsystem.
366  if (detStore()->retrieve(m_idHelper, "AtlasID").isFailure()) {
367  msg(MSG::FATAL) << "Could not get AtlasDetectorID helper" << endmsg;
368  return StatusCode::FAILURE;
369  }
370  // try to retrieve residual-pull calculation only if requested
371  if (m_doWriteResiduals){
372  if ( m_residualPullCalculator.retrieve().isFailure()) {
373  //Give a warning
374  ATH_MSG_WARNING( "Cannot retrieve ResidualPullCalculator tool " << m_residualPullCalculator);
375  ATH_MSG_WARNING( " -> will not write out residuals and pulls! " );
376  //switch of residual writing
377  m_doWriteResiduals = false ;
378  }
379  }
380  //All fine
381 
382  // get TrackSummaryTool
383  if ( m_trackSumTool.retrieve().isFailure() ) {
384  ATH_MSG_WARNING( "Failed to retrieve tool " << m_trackSumTool );
385  } else {
386  if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Retrieved tool " << m_trackSumTool << endmsg;
387  }
388  return StatusCode::SUCCESS;
389  }
390 
391 
392 
399  StatusCode TrackRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
400  //be verbose
401  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Retrieving " << dataTypeName() << endmsg;
402  //Generate a list of requested track collections
403  using tracksNamePair = std::pair<TrackCollection, std::string>;
404  std::vector< tracksNamePair > requestedTrackColls;
405  //First try to get hold of the priorty track collection
406  const TrackCollection* tracks = nullptr ;
407  if (evtStore()->retrieve(tracks, m_PriorityTrackCollection).isFailure()){
408  ATH_MSG_WARNING( "Unable to retrieve requested priority track collection "<< m_PriorityTrackCollection);
409  } else {
410  //Add this to the list of requested collections
411  requestedTrackColls.emplace_back(*tracks,m_PriorityTrackCollection);
412  }
413 
414  //If we have been given an explicit list, try to retrieve these in the order
415  //they were given
417  for ( ; CollNameItr != m_OtherTrackCollections.end(); ++CollNameItr){
418  const TrackCollection* tracks = nullptr ;
419  if (evtStore()->retrieve(tracks, (*CollNameItr)).isFailure()){
420  ATH_MSG_WARNING( "Unable to retrieve requested track collection " << (*CollNameItr) );
421  continue ;
422  }
423  //skip if it's priority collection again
424  if ((*CollNameItr) == m_PriorityTrackCollection){ continue; }
425  //Add them to the list of requested collections
426  requestedTrackColls.emplace_back(*tracks,(*CollNameItr));
427  } // end OtherCollections loop
428  //If no collections had been requested explicitly, loop over all of them
429  if (m_OtherTrackCollections.empty()) {
430  //Get an iterator over all other track collections
431  SG::ConstIterator<TrackCollection> trackCollIter, trackCollEnd;
432  if ((evtStore()->retrieve(trackCollIter, trackCollEnd)).isFailure()){
433  ATH_MSG_ERROR( "Unable to retrieve track collection iterator" );
434  return StatusCode::RECOVERABLE;
435  }
436 
437  //Next loop over all collections
438  for (; trackCollIter!=trackCollEnd; ++trackCollIter) {
439  //Check if this is an HLT-AutoKey collection
440  if ((trackCollIter.key().find("HLT",0) != std::string::npos) && (!m_doWriteHLT)){
441  ATH_MSG_DEBUG( "Ignoring HLT-AutoKey collection " << trackCollIter.key());
442  continue ;
443  }
444  //Ignore TRTSeed and MuonSlimmedTrackCollections
445  if ( (trackCollIter.key()=="TRTSeeds") || (trackCollIter.key() =="MuonSlimmedTrackCollection")) {
446  ATH_MSG_DEBUG( "Always ignoring collection " << trackCollIter.key() );
447  continue ;
448  }
449  //Next try to retrieve the actual collection
450  if (evtStore()->retrieve(tracks,trackCollIter.key()).isFailure()){
451  ATH_MSG_DEBUG( "Unable to retrieve collection " << trackCollIter.key());
452  continue ;
453  }
454  //Check if this collection is not already in the list
455  if (std::find(requestedTrackColls.begin(), requestedTrackColls.end(),tracksNamePair(*tracks,trackCollIter.key())) != requestedTrackColls.end())
456  continue ;
457 
458  //Add this to the list of requested collections
459  requestedTrackColls.emplace_back(*tracks,trackCollIter.key());
460  } //loop over all track collections
461  }
462 
468  //Loop over the collection list we have assembled above
469  std::vector<tracksNamePair>::iterator tracksNamePairItr = requestedTrackColls.begin();
470  for ( ; tracksNamePairItr != requestedTrackColls.end(); ++tracksNamePairItr){
471  //save some typing by getting a handle on the collection pointer
472  const TrackCollection* trackCollection =&((*tracksNamePairItr).first);
473  std::string collectionName = (*tracksNamePairItr).second;
474  //Some sanity checks
475  if ( trackCollection->empty()){
476  ATH_MSG_DEBUG( "Ignoring empty track collection " << collectionName );
477  } else {
478  ATH_MSG_DEBUG( "Retrieving data for track collection " << collectionName);
479  }
480 
486  const TrackTruthCollection *truthCollection = nullptr ;
487  //Check for given truth collection
488  if ( collectionName == m_PriorityTrackCollection ){
489  if ( evtStore()->contains<TrackTruthCollection>(m_TrackTruthCollection) ){
490  evtStore()->retrieve(truthCollection, m_TrackTruthCollection).ignore();
491  ATH_MSG_DEBUG( "Found TrackTruthCollection with key " << m_TrackTruthCollection );
492  }
493  //Check for name+TruthCollection
494  } else if ( evtStore()->contains<TrackTruthCollection>(collectionName+"TruthCollection") ){
495  evtStore()->retrieve(truthCollection, collectionName+"TruthCollection").ignore();
496  ATH_MSG_DEBUG( "Found TrackTruthCollection with key " << collectionName << "TruthCollection" );
497  //Check for name+Truth
498  } else if ( evtStore()->contains<TrackTruthCollection>(collectionName+"Truth") ){
499  evtStore()->retrieve(truthCollection, collectionName+"Truth").ignore();
500  ATH_MSG_DEBUG( "Found TrackTruthCollection with key " << collectionName << "Truth" );
501  // No matching track truth collection found at all
502  } else {
503  ATH_MSG_DEBUG( "Could not find matching TrackTruthCollection for " << collectionName );
504  truthCollection = nullptr ;
505  }
506 
507  // Make a list of track-wise entries and reserve enough space
508  DataVect id; id.reserve(trackCollection->size());
509  DataVect chi2; chi2.reserve(trackCollection->size());
510  DataVect numDoF; numDoF.reserve(trackCollection->size());
511  DataVect trackAuthor; trackAuthor.reserve(trackCollection->size());
512  DataVect barcode; barcode.reserve(trackCollection->size());
513  DataVect numHits; numHits.reserve(trackCollection->size());
514  DataVect numPolyline; numPolyline.reserve(trackCollection->size());
515  DataVect nBLayerHits; nBLayerHits.reserve(trackCollection->size());
516  DataVect nPixHits; nPixHits.reserve(trackCollection->size());
517  DataVect nSCTHits; nSCTHits.reserve(trackCollection->size());
518  DataVect nTRTHits; nTRTHits.reserve(trackCollection->size());
519 
520  // vectors with measurement- or TrackStateOnSurface-wise entries
521  // reserve space later on
522  DataVect polylineX;
523  DataVect polylineY;
524  DataVect polylineZ;
525  DataVect tsosResLoc1;
526  DataVect tsosResLoc2;
527  DataVect tsosPullLoc1;
528  DataVect tsosPullLoc2;
529  DataVect tsosDetType;
530  DataVect isOutlier;
531  DataVect driftSign;
532  DataVect hits;
533 
534  //Store wether this collection has perigee parameters
535  DataVect pt; pt.reserve(trackCollection->size());
536  DataVect d0; d0.reserve(trackCollection->size());
537  DataVect z0; z0.reserve(trackCollection->size());
538  DataVect phi0; phi0.reserve(trackCollection->size());
539  DataVect cotTheta; cotTheta.reserve(trackCollection->size());
540  //Covariance matrix has 15 entries per track
541  DataVect covMatrix; covMatrix.reserve(trackCollection->size() * 15 );
542 
543  // Now loop over all tracks in the collection
545  for (track=trackCollection->begin(); track!=trackCollection->end(); ++track) {
549  id.emplace_back(id.size()); //<! simple counter starting from 0
550  chi2.emplace_back((*track)->fitQuality()->chiSquared());
551  numDoF.emplace_back((*track)->fitQuality()->numberDoF());
552  trackAuthor.emplace_back((*track)->info().trackFitter());
553 
557  TrackRetrieverHelpers::getTruthFromTrack(*track,trackCollection,truthCollection,barcode);
558 
563 
567  std::unique_ptr<Trk::TrackSummary> summary = nullptr;
568  summary = m_trackSumTool->summary(**track);
569 
570  if(not summary){
571  ATH_MSG_DEBUG( "Track summary is NULL " );
572  nBLayerHits.emplace_back(0);
573  nPixHits.emplace_back(0);
574  nSCTHits.emplace_back(0);
575  nTRTHits.emplace_back(0);
576  }else{
577  nBLayerHits.emplace_back(summary->get(Trk::numberOfInnermostPixelLayerHits));
578  nPixHits.emplace_back(summary->get(Trk::numberOfPixelHits));
579  nSCTHits.emplace_back(summary->get(Trk::numberOfSCTHits));
580  nTRTHits.emplace_back(summary->get(Trk::numberOfTRTHits));
581  }
582 
586  // Vector of interesting TrackStateOnSurfaces
587  std::vector<const Trk::TrackStateOnSurface*> TSoSVec = TrackRetrieverHelpers::getTrackStateOnSurfaces(*track,perigee,m_doHitsSorting);
588 
592  // Reserving some space for polyline hits
593  polylineX.reserve(polylineX.size()+TSoSVec.size());
594  polylineY.reserve(polylineY.size()+TSoSVec.size());
595  polylineZ.reserve(polylineZ.size()+TSoSVec.size());
596 
597  //And fill them
598  TrackRetrieverHelpers::getPolylineFromHits(TSoSVec,polylineX,polylineY,polylineZ,numPolyline);
599 
603  //Reserve some space for resPull and other hit info
604  isOutlier.reserve(isOutlier.size()+TSoSVec.size());
605  hits.reserve(hits.size()+TSoSVec.size());
606  driftSign.reserve(driftSign.size()+TSoSVec.size());
607  tsosResLoc1.reserve(tsosResLoc1.size()+TSoSVec.size());
608  tsosResLoc2.reserve(tsosResLoc2.size()+TSoSVec.size());
609  tsosPullLoc1.reserve(tsosPullLoc1.size()+TSoSVec.size());
610  tsosPullLoc2.reserve(tsosPullLoc2.size()+TSoSVec.size());
611  tsosDetType.reserve(tsosDetType.size()+TSoSVec.size());
612 
613  //Now loop over tracks and fill them
614  std::vector< const Trk::TrackStateOnSurface* >::const_iterator TSoSItr = TSoSVec.begin();
615  //Count number of hits stored in this loop
616  long nHits = 0;
617  if (m_doHitsDetails){ // disable only for HeavyIons !
618  for (; TSoSItr != TSoSVec.end(); ++TSoSItr){
619  // This produces the full long debug dump for TSoS:
620  ATH_MSG_VERBOSE( (**TSoSItr) );
621  //Get the basic hit information
622  const Trk::RIO_OnTrack* rot = TrackRetrieverHelpers::getBaseInfoFromHit(*TSoSItr, m_idHelper, isOutlier, hits, driftSign, tsosDetType );
623  //tell if this didn't work out
624  if (!rot){
625  ATH_MSG_VERBOSE( "Could not obtain RIO for TSoS of type " << (*TSoSItr)->dumpType() );
626  continue ;
627  }
628  //count this as a hit
629  ++nHits;
630 
631  //if we shell retrieve residuals, also get those
632  if (m_doWriteResiduals){
633  TrackRetrieverHelpers::getResidualPullFromHit( *TSoSItr, rot, m_residualPullCalculator, tsosResLoc1, tsosResLoc2, tsosPullLoc1, tsosPullLoc2);
634  }
635  }
636  } // end hits details
637 
638  //Store number of retrieved hits for which we have retrieved information
639  numHits.emplace_back(nHits);
640 
641  } // end loop over tracks in collection
642 
643  //Now fill everything in a datamap
645  // Start with mandatory entries
646  DataMap["id"] = id;
647  DataMap["chi2"] = chi2;
648  DataMap["numDoF"] = numDoF;
649  DataMap["trackAuthor"] = trackAuthor;
650  DataMap["barcode"] = barcode;
651  DataMap["numHits"] = numHits;
652  DataMap["nBLayerHits"] = nBLayerHits;
653  DataMap["nPixHits"] = nPixHits;
654  DataMap["nSCTHits"] = nSCTHits;
655  DataMap["nTRTHits"] = nTRTHits;
656  DataMap["numPolyline"] = numPolyline;
657 
658  // if perigee parameters are not available, leave the corresponding subtags empty.
659  // This way atlantis knows that such tracks can only be displayed as polylines.
660  if (!pt.empty()){
661  DataMap["pt"] = pt;
662  DataMap["d0"] = d0;
663  DataMap["z0"] = z0;
664  DataMap["phi0"] = phi0;
665  DataMap["cotTheta"] = cotTheta;
666  DataMap["covMatrix multiple=\"15\""] = covMatrix;
667  }
668 
669  // vectors with measurement- or TrackStateOnSurface-wise entries
670  if ( !polylineX.empty()){
671  std::string numPolyPerTrack = DataType(polylineX.size()/((double)id.size())).toString();
672  DataMap["polylineX multiple=\"" + numPolyPerTrack + "\""] = polylineX;
673  DataMap["polylineY multiple=\"" + numPolyPerTrack + "\""] = polylineY;
674  DataMap["polylineZ multiple=\"" + numPolyPerTrack + "\""] = polylineZ;
675  }
676 
677  if ( !hits.empty()){
678  std::string numHitsPerTrack = DataType(hits.size()/((double)id.size())).toString();
679  DataMap["hits multiple=\"" + numHitsPerTrack + "\""] = hits;
680  DataMap["isOutlier multiple=\""+numHitsPerTrack+"\""] = isOutlier;
681  DataMap["driftSign multiple=\""+numHitsPerTrack+"\""] = driftSign;
682 
683  if (m_doWriteResiduals){
684  // hits counter in principle not needed anymore:
685  DataMap["numTsos"] = numHits;
686  DataMap["tsosResLoc1 multiple=\""+numHitsPerTrack+"\""] = tsosResLoc1;
687  DataMap["tsosResLoc2 multiple=\""+numHitsPerTrack+"\""] = tsosResLoc2;
688  DataMap["tsosPullLoc1 multiple=\""+numHitsPerTrack+"\""] = tsosPullLoc1;
689  DataMap["tsosPullLoc2 multiple=\""+numHitsPerTrack+"\""] = tsosPullLoc2;
690  DataMap["tsosDetType multiple=\""+numHitsPerTrack+"\""] = tsosDetType;
691  }
692  }
693 
694  //forward data to formating tool
695  if ( FormatTool->AddToEvent(dataTypeName(), collectionName, &DataMap).isFailure())
696  return StatusCode::RECOVERABLE;
697 
698  //Be verbose
699  if (msgLvl(MSG::DEBUG)) {
700  msg(MSG::DEBUG) << dataTypeName() << " collection " << collectionName;
701  msg(MSG::DEBUG) << " retrieved with " << id.size() << " entries"<< endmsg;
702  }
703 
704  } //loop over track collections
705 
706  //All collections retrieved okay
707  return StatusCode::SUCCESS;
708 
709  } //retrieve
710 } //namespace JiveXML
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AtlasDetectorID::is_pixel
bool is_pixel(Identifier id) const
Definition: AtlasDetectorID.h:760
Trk::numberOfPixelHits
@ numberOfPixelHits
number of pixel layers on track with absence of hits
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:57
Trk::TrackStateOnSurface::trackParameters
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
ITrackSummaryTool.h
AtlasDetectorID::is_rpc
bool is_rpc(Identifier id) const
Definition: AtlasDetectorID.h:875
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
JiveXML::TrackRetriever::initialize
StatusCode initialize()
Default AthAlgTool methods.
Definition: TrackRetriever.cxx:364
Trk::numberOfInnermostPixelLayerHits
@ numberOfInnermostPixelLayerHits
these are the hits in the 1st pixel layer
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:53
TrackParameters.h
MeasurementBase.h
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
AtlasDetectorID::is_csc
bool is_csc(Identifier id) const
Definition: AtlasDetectorID.h:891
CompetingRIOsOnTrack.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:770
TrackStateDefs.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
SG::detail::IteratorBase::key
const std::string & key() const
Get the key string with which the current object was stored.
Definition: SGIterator.cxx:155
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
JiveXML::TrackRetrieverHelpers::getPerigeeParameters
const Trk::Perigee * getPerigeeParameters(const Trk::Track *track, DataVect &pt, DataVect &d0, DataVect &z0, DataVect &phi0, DataVect &cotTheta, DataVect &covMatrix)
Obtain the perigee paramets for a given track, if available, and fill them in the corresponding data ...
Definition: TrackRetriever.cxx:50
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
compFunc
bool(*)(const xAOD::Jet *, const xAOD::Jet *) compFunc
Definition: JetSorter.cxx:12
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
JiveXML::TrackRetriever::m_PriorityTrackCollection
std::string m_PriorityTrackCollection
First track collections to retrieve, shown as default in Atlantis.
Definition: TrackRetriever.h:83
test_pyathena.pt
pt
Definition: test_pyathena.py:11
TrackRetriever.h
TrackStateOnSurfaceComparisonFunction.h
Trk::z0
@ z0
Definition: ParamDefs.h:70
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
Trk::TrackStateOnSurface::measurementOnTrack
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
Trk::loc2
@ loc2
generic first and second local coordinate
Definition: ParamDefs.h:41
JiveXML::TrackRetrieverHelpers::getBaseInfoFromHit
const Trk::RIO_OnTrack * getBaseInfoFromHit(const Trk::TrackStateOnSurface *tsos, const AtlasDetectorID *idHelper, DataVect &isOutlier, DataVect &hits, DataVect &driftSign, DataVect &tsosDetType)
Retrieve all the basic hit information from the Trk::TrackStateOnSurface.
Definition: TrackRetriever.cxx:184
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
JiveXML::TrackRetrieverHelpers::getTrackStateOnSurfaces
std::vector< const Trk::TrackStateOnSurface * > getTrackStateOnSurfaces(const Trk::Track *track, const Trk::Perigee *perigee, bool doHitsSorting)
Get a list of track-State on Surfaces for measurement and outlier hits, sorted using the perigee comp...
Definition: TrackRetriever.cxx:120
JiveXML::TrackRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: TrackRetriever.cxx:399
AtlasDetectorID::is_trt
bool is_trt(Identifier id) const
Definition: AtlasDetectorID.h:782
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
JiveXML::TrackRetriever::m_residualPullCalculator
ToolHandle< Trk::IResidualPullCalculator > m_residualPullCalculator
ToolHandle to ResidualPullCaclulator tool.
Definition: TrackRetriever.h:98
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
TrackTruthKey.h
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:52
JiveXML::TrackRetriever::m_doWriteHLT
bool m_doWriteHLT
Whether to write HLTAutoKey objects.
Definition: TrackRetriever.h:90
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
JiveXML::TrackRetrieverHelpers::getResidualPullFromHit
void getResidualPullFromHit(const Trk::TrackStateOnSurface *tsos, const Trk::RIO_OnTrack *rot, const ToolHandle< Trk::IResidualPullCalculator > &residualPullCalculator, DataVect &tsosResLoc1, DataVect &tsosResLoc2, DataVect &tsosPullLoc1, DataVect &tsosPullLoc2)
Get the residual pull information from the Trk::TrackStateOnSurface hit.
Definition: TrackRetriever.cxx:253
Trk::TrackStateOnSurface::Outlier
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
Definition: TrackStateOnSurface.h:122
Track.h
JiveXML::TrackRetriever::m_doHitsDetails
bool m_doHitsDetails
Whether to write hits (TSoS) details.
Definition: TrackRetriever.h:96
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Trk::TrackStateOnSurface::type
bool type(const TrackStateOnSurfaceType type) const
Use this method to find out if the TSoS is of a certain type: i.e.
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Trk::CompetingRIOsOnTrack::rioOnTrack
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
Trk::TrackStateOnSurfaceComparisonFunction
Class providing comparison function, or relational definition, for sorting MeasurementBase objects.
Definition: TrackStateOnSurfaceComparisonFunction.h:37
TrackTruthCollection
Definition: TrackTruthCollection.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
JiveXML::TrackRetriever::m_doWriteResiduals
bool m_doWriteResiduals
Whether to write TrackResiduals.
Definition: TrackRetriever.h:92
ResidualPull.h
JiveXML::TrackRetrieverHelpers::getTruthFromTrack
void getTruthFromTrack(const Trk::Track *track, const TrackCollection *trackCollection, const TrackTruthCollection *truthCollection, DataVect &barcode)
Get the barcode of the associated truth track.
Definition: TrackRetriever.cxx:302
TrackTruthCollection.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
JiveXML::DataType
Templated class to convert any object that is streamable in a ostringstream in a string.
Definition: DataType.h:21
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
AtlasDetectorID::is_tgc
bool is_tgc(Identifier id) const
Definition: AtlasDetectorID.h:902
Trk::theta
@ theta
Definition: ParamDefs.h:72
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::numberOfSCTHits
@ numberOfSCTHits
number of SCT holes
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:71
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::covMatrix
covMatrix
Definition: TrackMeasurement_v1.cxx:19
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:59
TrackCollection.h
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
test_pyathena.parent
parent
Definition: test_pyathena.py:15
JiveXML::TrackRetriever::m_idHelper
const AtlasDetectorID * m_idHelper
Used to find out the corresponding sub-det from ROT->identify().
Definition: TrackRetriever.h:100
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
TrackSummary.h
Trk::ParametersBase
Definition: ParametersBase.h:55
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
JiveXML::TrackRetriever::m_doHitsSorting
bool m_doHitsSorting
Whether to perform hits (TSoS) sorting.
Definition: TrackRetriever.h:94
DataVector< Trk::Track >
JacobianThetaPToCotThetaPt.h
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:21
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::numberOfTRTHits
@ numberOfTRTHits
number of TRT outliers
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:79
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:191
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trk::d0
@ d0
Definition: ParamDefs.h:69
TrackInfo.h
RIO_OnTrack.h
TauGNNUtils::Variables::Track::nSCTHits
bool nSCTHits(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:549
JiveXML::TrackRetriever::TrackRetriever
TrackRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: TrackRetriever.cxx:338
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition: MeasurementBase.h:132
IResidualPullCalculator.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
JiveXML::TrackRetriever::m_trackSumTool
ToolHandle< Trk::ITrackSummaryTool > m_trackSumTool
TrackSummaryTool for number of Pix/SCT/TRT hits.
Definition: TrackRetriever.h:102
Trk::ResidualPull::Biased
@ Biased
RP with track state including the hit.
Definition: ResidualPull.h:55
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:73
Trk::RIO_OnTrack::identify
virtual Identifier identify() const final
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:155
TRT::Track::cotTheta
@ cotTheta
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:65
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
AthAlgTool
Definition: AthAlgTool.h:26
FitQuality.h
Trk::CompetingRIOsOnTrack::indexOfMaxAssignProb
unsigned int indexOfMaxAssignProb() const
Index of the ROT with the highest assignment probability.
Definition: CompetingRIOsOnTrack.cxx:101
Trk::loc1
@ loc1
Definition: ParamDefs.h:40
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
Trk::JacobianThetaPToCotThetaPt
Definition: JacobianThetaPToCotThetaPt.h:41
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ConstIterator
Definition: SGIterator.h:163
JiveXML::TrackRetriever::m_OtherTrackCollections
std::vector< std::string > m_OtherTrackCollections
Track collections to retrieve in the sequence they are given, all if empty.
Definition: TrackRetriever.h:85
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
Trk::phi0
@ phi0
Definition: ParamDefs.h:71
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
JiveXML::TrackRetriever::m_TrackTruthCollection
std::string m_TrackTruthCollection
Track collection from which to retrieve the truth associations for the priority track collection.
Definition: TrackRetriever.h:88
JiveXML::TrackRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: TrackRetriever.h:71
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
AtlasDetectorID::is_mdt
bool is_mdt(Identifier id) const
Definition: AtlasDetectorID.h:859
JiveXML::TrackRetrieverHelpers::getPolylineFromHits
void getPolylineFromHits(const std::vector< const Trk::TrackStateOnSurface * > &TSoSVec, DataVect &polylineX, DataVect &polylineY, DataVect &polylineZ, DataVect &numPolyline)
Get polyline hits if available.
Definition: TrackRetriever.cxx:158
SCT_Monitoring::summary
@ summary
Definition: SCT_MonitoringNumbers.h:65