ATLAS Offline Software
TrackDiff.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // TrackDiff.cxx
7 // Source file for class TrackDiff
9 // (c) ATLAS Detector software
11 // Sebastian.Fleischmann@cern.ch
13 
14 
15 //Gaudi
16 #include "GaudiKernel/TypeNameString.h"
17 #include "GaudiKernel/ITHistSvc.h"
18 #include "TString.h"
19 #include "TTree.h"
20 
21 // Trk
22 #include "TrkValTools/TrackDiff.h"
25 #include "TrkSurfaces/Surface.h"
26 
29 #include "TrkTrack/Track.h"
30 
32 
33 // constructor
35  const std::string& t,
36  const std::string& n,
37  const IInterface* p )
38  :
39  AthAlgTool(t,n,p),
40  m_nt(nullptr),
41  m_idHelper(nullptr),
42  //strings initialised in job options
43  m_compareOutliers(true),
44  m_compareAll(false),
45  m_writeNtuple(true),
46  m_writeCompetingROT(false),
47  m_eventNumber{},
48  m_nRefStates{},
49  m_nCompStates{},
50  m_fakes{},
51 
52  m_missed{},
53  m_wrongType{},
54  m_missingType{},
55  m_fakeType{},
56  m_refType{},
57  m_compareType{},
58  m_PRD_Mismatches{},
59  m_driftCircleSignFlips{},
60  m_noDriftTime{},
61  m_nDiffs{},
62  m_detectorType{},
63  m_isFake{},
64  m_isMissing{},
65  m_isPRD_Mismatch{},
66  m_isFlippedSign{},
67  m_isNoDriftTime{},
68  m_refIsMeasurement{},
69  m_refIsOutlier{},
70  m_compIsMeasurement{},
71  m_compIsOutlier{},
72  m_maxAssignProb{},
73  m_sumAssignProb{},
74  m_surfX{},
75  m_surfY{},
76  m_surfZ{},
77  m_trackEta{},
78  m_trackPhi{},
79  m_nRefStatesSum{},
80  m_nCompStatesSum{},
81  m_fakesSum{},
82  m_missedSum{},
83  m_wrongTypeSum{},
84  m_PRD_MismatchesSum{},
85  m_trackSum(0) {
86  declareInterface<ITrackDiff>(this);
87  // Declare the properties
88  //declareProperty("BookNewNtuple", m_bookNewNtuple = true);
89  declareProperty("NtupleFileName", m_ntupleFileName = "/NTUPLES");
90  declareProperty("NtupleDirectoryName", m_ntupleDirName = "TrackValidation");
91  declareProperty("NtupleTreeName", m_ntupleTreeName = "TrackDiff");
92  //declareProperty("CompareMeasurements", m_compareMeasurements = true);
93  declareProperty("CompareOutliers", m_compareOutliers = true);
94  declareProperty("CompareAllTSoS", m_compareAll = false);
95  declareProperty("WriteNtuple", m_writeNtuple = true);
96  declareProperty("WriteCompetingROTdata",m_writeCompetingROT = false);
97 }
98 
99 // destructor
100 Trk::TrackDiff::~TrackDiff() = default;
101 
102 
103 
104 // initialize
106 
107  ATH_CHECK( m_evt.initialize() );
108 
109  StatusCode sc;
110  if (m_writeNtuple) {
111  // ---------------------------
112  // retrieve pointer to THistSvc
113  SmartIF<ITHistSvc> tHistSvc{service("THistSvc")};
114  ATH_CHECK( tHistSvc.isValid() );
115 
116  // ---------------------------
117  // create tree and register it to THistSvc
118  m_nt = new TTree(TString(m_ntupleTreeName), "Track diff output");
119  // NB: we must not delete the tree, this is done by THistSvc
120  std::string fullNtupleName = "/"+m_ntupleFileName+"/"+m_ntupleDirName+"/"+m_ntupleTreeName;
121  ATH_CHECK( tHistSvc->regTree(fullNtupleName, m_nt) );
122 
123  //-----------------
124  // add items
125  // event info:
126  m_nt->Branch("EventNumber", &m_eventNumber );
127  m_nt->Branch("RefTrackPhi0", &m_trackPhi );
128  m_nt->Branch("RefTrackEta0", &m_trackEta );
129 
130  m_nt->Branch("nRefStates", &m_nRefStates, "nRefStates[8]/I");
131  m_nt->Branch("nCompareStates", &m_nCompStates, "nRefStates[8]/I");
132  m_nt->Branch("nFakeStates", &m_fakes, "nFakeStates[8]/I");
133  m_nt->Branch("nMissedStates", &m_missed, "nMissedStates[8]/I");
134  m_nt->Branch("nWrongType", &m_wrongType, "nWrongType[8]/I");
135  m_nt->Branch("nPRD_Mismatches", &m_PRD_Mismatches, "nPRD_Mismatches[8]/I");
136  m_nt->Branch("nDriftCircleSignFlips", &m_driftCircleSignFlips );
137  m_nt->Branch("nNoDriftTime", &m_noDriftTime );
138  m_nt->Branch("nRefTypes", &m_refType, "nRefTypes[8]/I");
139  m_nt->Branch("nCompareTypes", &m_compareType, "nCompareTypes[8]/I");
140  m_nt->Branch("nMissedTypes", &m_missingType, "nMissedTypes[8]/I");
141  m_nt->Branch("nFakeTypes", &m_fakeType, "nFakeTypes[8]/I");
142  // entries for each difference
143  m_nt->Branch("nDiffs", &m_nDiffs );
144  m_detectorType = new std::vector<int>();
145  m_isFake = new std::vector<int>();
146  m_isMissing = new std::vector<int>();
147  m_isPRD_Mismatch = new std::vector<int>();
148  m_isFlippedSign = new std::vector<int>();
149  m_isNoDriftTime = new std::vector<int>();
150  m_refIsMeasurement = new std::vector<int>();
151  m_refIsOutlier = new std::vector<int>();
152  m_compIsMeasurement = new std::vector<int>();
153  m_compIsOutlier = new std::vector<int>();
154  m_surfX = new std::vector<float>();
155  m_surfY = new std::vector<float>();
156  m_surfZ = new std::vector<float>();
157 
158  m_nt->Branch("DetectorType", &m_detectorType);
159  m_nt->Branch("IsFake", &m_isFake);
160  m_nt->Branch("IsMissing", &m_isMissing);
161  m_nt->Branch("IsPRD_Mismatch", &m_isPRD_Mismatch);
162  m_nt->Branch("IsFlippedSign", &m_isFlippedSign);
163  m_nt->Branch("IsNoDriftTime", &m_isNoDriftTime);
164  m_nt->Branch("RefIsMeasurement", &m_refIsMeasurement);
165  m_nt->Branch("RefIsOutlier", &m_refIsOutlier);
166  m_nt->Branch("ComparedIsMeasurement", &m_compIsMeasurement);
167  m_nt->Branch("ComparedIsOutlier", &m_compIsOutlier);
168  m_nt->Branch("SurfaceX" , &m_surfX);
169  m_nt->Branch("SurfaceY" , &m_surfY);
170  m_nt->Branch("SurfaceZ" , &m_surfZ);
171 
172  if (m_writeCompetingROT) {
173  m_maxAssignProb = new std::vector<float>();
174  m_sumAssignProb = new std::vector<float>();
175  m_nt->Branch("MaxAssgnProb", &m_maxAssignProb);
176  m_nt->Branch("SumAssgnProb", &m_sumAssignProb);
177  } // end if writeComepetingROT
178  } // end if (m_writeNtuple)
179  // ---------------------------------------
180  // Get the detector helper to be able to identify sub-det technologies
181  if (detStore()->retrieve(m_idHelper, "AtlasID").isFailure()) {
182  ATH_MSG_ERROR ("Could not get AtlasDetectorID helper" );
183  return StatusCode::FAILURE;
184  }
185 
186  for (int detType = 0; detType < Trk::TrackState::NumberOfMeasurementTypes; detType++) {
187  m_fakesSum[detType] = 0;
188  m_missedSum[detType] = 0;
189  m_PRD_MismatchesSum[detType] = 0;
190  m_nRefStatesSum[detType] = 0;
191  m_nCompStatesSum[detType] = 0;
192  m_wrongTypeSum[detType] = 0;
193  m_fakes[detType] = 0;
194  m_missed[detType] = 0;
195  m_PRD_Mismatches[detType] = 0;
196  m_nRefStates[detType] = 0;
197  m_nCompStates[detType] = 0;
198  m_wrongType[detType] = 0;
199  }
200 
201  return StatusCode::SUCCESS;
202 }
203 
208  ATH_MSG_INFO ( "sums for " << m_trackSum << " compared tracks" );
209  ATH_MSG_INFO ( "reference TSoS (Pixel/SCT/TRT): " << m_nRefStatesSum[Trk::TrackState::Pixel] << "/" << m_nRefStatesSum[Trk::TrackState::SCT] << "/" << m_nRefStatesSum[Trk::TrackState::TRT] );
210  ATH_MSG_INFO ( "compared TSoS (Pixel/SCT/TRT): " << m_nCompStatesSum[Trk::TrackState::Pixel] << "/" << m_nCompStatesSum[Trk::TrackState::SCT] << "/" << m_nCompStatesSum[Trk::TrackState::TRT] );
211  ATH_MSG_INFO ( "missed TSoS (Pixel/SCT/TRT): " << m_missedSum[Trk::TrackState::Pixel] << "/" << m_missedSum[Trk::TrackState::SCT] << "/" << m_missedSum[Trk::TrackState::TRT] );
212  ATH_MSG_INFO ( "faked TSoS (Pixel/SCT/TRT): " << m_fakesSum[Trk::TrackState::Pixel] << "/" << m_fakesSum[Trk::TrackState::SCT] << "/" << m_fakesSum[Trk::TrackState::TRT] );
213  ATH_MSG_INFO ( "wrong type TSoS (Pixel/SCT/TRT): " << m_wrongTypeSum[Trk::TrackState::Pixel] << "/" << m_wrongTypeSum[Trk::TrackState::SCT] << "/" << m_wrongTypeSum[Trk::TrackState::TRT] );
214  ATH_MSG_INFO ( "PRD mismatches (Pixel/SCT/TRT): " << m_PRD_MismatchesSum[Trk::TrackState::Pixel] << "/" << m_PRD_MismatchesSum[Trk::TrackState::SCT] << "/" << m_PRD_MismatchesSum[Trk::TrackState::TRT] );
215 
216  ATH_MSG_INFO ( "finalize() successful in " << name() );
217  return StatusCode::SUCCESS;
218 }
219 
224  const Trk::Track& referenceTrack,
225  const Trk::Track& comparedTrack ) {
226 
227  ATH_MSG_VERBOSE ( "in diff(trk, trk)" );
228  resetVariables();
229 
230  // ---------------------------------------
231  // fill event data
233  if (!evt.isValid()) {
234  ATH_MSG_ERROR ("Could not retrieve event info");
235  return StatusCode::FAILURE;
236  }
237 
238  m_eventNumber = evt->eventNumber();
239  if (referenceTrack.perigeeParameters()) {
240  m_trackPhi = referenceTrack.perigeeParameters()->parameters()[Trk::phi0];
241  m_trackEta = referenceTrack.perigeeParameters()->eta();
242  } else {
243  m_trackPhi = -1000.;
244  m_trackEta = -1000.;
245  }
246 
247 
248  // list of track state data of the reference track
249  DataVector< const Trk::TrackStateData > *refTrackStateData;
250  // list of track state data of the compared track
251  DataVector< const Trk::TrackStateData > *compareTrackStateData;
252  // get data from the track states to be able to compare the surfaces and PrepRawData
253  refTrackStateData = extractDataFromTrack(referenceTrack);
254  compareTrackStateData = extractDataFromTrack(comparedTrack);
255 
256  ATH_MSG_VERBOSE ( "number of track states: ref=" << refTrackStateData->size() << ", compare=" << compareTrackStateData->size() );
257  ATH_MSG_VERBOSE ( "reference track: eta_0 = " << m_trackEta << ", phi_0 = " << m_trackPhi );
258  ATH_MSG_DEBUG ( " Ref Comp other diffs detector " );
259  //----------------------------------------------
260  // loop over the track states of the reference track
261  // and try to find the related measurements on the
262  // comparison track
263  DataVector< const Trk::TrackStateData >::iterator refIter = refTrackStateData->begin();
264  DataVector< const Trk::TrackStateData >::iterator compIter = compareTrackStateData->begin();
265  for (; refIter != refTrackStateData->end(); ++refIter) {
266  // count the reference states by detector type
267  //m_nRefStates[ refIter->detType() ]++;
268  // loop over trackstates of the comparison track till we find
269  // a track state with the same surface or the same PRD
270  bool foundMatchingState = false;
271  //bool foundDiff = false;
272  // cache the pointer to reference PRD, so we do not have get it again and again
273  const Trk::PrepRawData* refPRD = nullptr;
274  if ((*refIter)->rot()) {
275  refPRD = (*refIter)->rot()->prepRawData();
276  }
277  compIter = compareTrackStateData->begin();
278  for ( ; compIter != compareTrackStateData->end(); ++compIter ) {
279  // compare the surfaces of the reference and the compared track state
280  if ( (*compIter)->surface() == (*refIter)->surface() ) {
281  // we found a track state on the same surface!
282  foundMatchingState = true;
283  //m_nCompStates[ compIter->detType() ]++;
284  //if (diffStateInfo( refIter, compIter ) {
285  // foundDiff = true;
286  //}
287  // there should be at maximum only one track state
288  // per surface, so we do not have to search further!
289  break;
290  } else if ( refPRD && (*compIter)->rot() ) {
291  // try to match the PrepRawData, if we did not succeed with the surfaces
292  // this is only needed in the case of dynamically created surfaces,
293  // which contain track specific corrections (e.g. "wire sagging")
294  if ( refPRD == ((*compIter)->rot()->prepRawData()) ) {
295  // we found a track state belonging to the same PrepRawData
296  foundMatchingState = true;
297 
298  // there should be only one track state
299  // belonging to the same PRD, so we can stop searching!
300  break;
301  } // end if PRD match
302  } // end else if( refPRD && compIter->rot() )
303  } // end loop over compared states
304  if (!foundMatchingState) {
305  // we have a state in the reference, which is not contained in the
306  // compared track!
307  diffStateInfo((*refIter), nullptr);
308  } else {
309  diffStateInfo((*refIter), (*compIter));
310  // drop the compared track state from our list:
311  compareTrackStateData->erase(compIter);
312  }
313 
314  } // end loop over reference states
315 
316  // loop over the remaining compared states: They are fakes
317  compIter = compareTrackStateData->begin();
318  for (; compIter != compareTrackStateData->end(); ++compIter) {
319  diffStateInfo(nullptr, (*compIter));
320  }
321  // -----------------------
322  // output some statistics:
323 
324  ATH_MSG_VERBOSE ( "reference TSoS (Pixel/SCT/TRT): " << m_nRefStates[Trk::TrackState::Pixel] << "/" << m_nRefStates[Trk::TrackState::SCT] << "/" << m_nRefStates[Trk::TrackState::TRT] );
325  ATH_MSG_VERBOSE ( "compared TSoS (Pixel/SCT/TRT): " << m_nCompStates[Trk::TrackState::Pixel] << "/" << m_nCompStates[Trk::TrackState::SCT] << "/" << m_nCompStates[Trk::TrackState::TRT] );
326  ATH_MSG_VERBOSE ( "missed TSoS (Pixel/SCT/TRT): " << m_missed[Trk::TrackState::Pixel] << "/" << m_missed[Trk::TrackState::SCT] << "/" << m_missed[Trk::TrackState::TRT] );
327  ATH_MSG_VERBOSE ( "faked TSoS (Pixel/SCT/TRT): " << m_fakes[Trk::TrackState::Pixel] << "/" << m_fakes[Trk::TrackState::SCT] << "/" << m_fakes[Trk::TrackState::TRT] );
328  ATH_MSG_VERBOSE ( "wrong type TSoS (Pixel/SCT/TRT): " << m_wrongType[Trk::TrackState::Pixel] << "/" << m_wrongType[Trk::TrackState::SCT] << "/" << m_wrongType[Trk::TrackState::TRT] );
329  ATH_MSG_VERBOSE ( "PRD mismatches (Pixel/SCT/TRT): " << m_PRD_Mismatches[Trk::TrackState::Pixel] << "/" << m_PRD_Mismatches[Trk::TrackState::SCT] << "/" << m_PRD_Mismatches[Trk::TrackState::TRT] );
330  ATH_MSG_VERBOSE ( "missing TSoS types: (Meas/Outl): " << m_missingType[Trk::TrackStateOnSurface::Measurement] << "/" << m_missingType[Trk::TrackStateOnSurface::Outlier] );
331  ATH_MSG_VERBOSE ( "fake TSoS types: (Meas/Outl): " << m_fakeType[Trk::TrackStateOnSurface::Measurement] << "/" << m_fakeType[Trk::TrackStateOnSurface::Outlier] );
332  if (m_writeNtuple) {
333  //----------------------------------------------
334  // write the ntuple record out (once per call)
335  m_nt->Fill();
336  }
337  m_trackSum++;
338  // clean up
339  delete refTrackStateData;
340  delete compareTrackStateData;
341  return StatusCode::SUCCESS;
342 }
343 
346 
347  // Get pointer to track state on surfaces
348  const Trk::TrackStates* trackStates = track.trackStateOnSurfaces();
349  if (!trackStates) {
350  ATH_MSG_ERROR ( "track containes no track states, diff impossible" );
351  return nullptr;
352  }
353 
354  // create the vector of extracted data
356 
357  // track state iterator
358  Trk::TrackStates::const_iterator iter = trackStates->begin();
359  // Loop over all track states on surfaces
360  // to extract the measurements
361  for (; iter != trackStates->end(); ++iter) {
362  if (!(*iter)) {
363  ATH_MSG_WARNING ( "TrackStateOnSurface == Null" );
364  continue;
365  }
366  if (!m_compareAll) {
367  // just use TSoS of type "measurement" or "outlier"
368  if (m_compareOutliers) {
369  if (!( (*iter)->type(Trk::TrackStateOnSurface::Measurement) ||
370  (*iter)->type(Trk::TrackStateOnSurface::Outlier) ) ) {
371  continue;
372  }
373  } else {
374  if (!( (*iter)->type(Trk::TrackStateOnSurface::Measurement) ) ) {
375  continue;
376  }
377  } // end if (compareOutliers)
378  } // end if (!compareAll)
379 
380  // Get pointer to measurement on track
381  const Trk::MeasurementBase *measurement = (*iter)->measurementOnTrack();
382  if (!measurement && !m_compareAll) {
383  ATH_MSG_ERROR ( "measurementOnTrack == Null for a TrackStateOnSurface "
384  << "of type Measurement or Outlier" );
385  continue;
386  } // end if (!measurement)
387  const Trk::Surface& surface = measurement ?
388  (measurement->associatedSurface()) :
389  (*iter)->trackParameters()->associatedSurface();
390  // we need the RIO_OnTrack to decide if we have the same PrepRawData
391  // on the track
392  const Trk::RIO_OnTrack* ROT = dynamic_cast< const Trk::RIO_OnTrack* > (measurement);
393  if (!ROT) {
394  // try to cast to CompetingRIOsOnTrack
395  const Trk::CompetingRIOsOnTrack* compROT = dynamic_cast< const Trk::CompetingRIOsOnTrack* > (measurement);
396  if (compROT) {
397  ROT = &compROT->rioOnTrack( compROT->indexOfMaxAssignProb() );
398 // // quick hack to identify DAF ouliers:
399 // if (!m_compareOutliers && (compROT->assignmentProbability(compROT->indexOfMaxAssignProb()) < 0.4)) {
400 // continue;
401 // }
402  // use surface of the most prob. ROT:
403  // FIXME put back in place: surface = compROT->rioOnTrack( compROT->indexOfMaxAssignProb() ).associatedSurface();
404  } // end if (compROT)
405  }
406  // if we just compare Measurements and Outliers, we demand a ROT.
407  if ( !ROT && !m_compareAll ) {
408  continue;
409  }
410  // try to identify detector type by ROT
411  std::string detTypeName = "unidentified";
413  if ( ROT ) {
414  detType = detectorType(*ROT, detTypeName);
415  }
416  // add the extracted data to the vector:
417  const Trk::TrackStateData *tsData = new const Trk::TrackStateData( (*iter),
418  ROT,
419  &surface,
420  detTypeName,
421  detType);
422  trackStateData->push_back(tsData);
423  //ATH_MSG_VERBOSE ( detTypeName << " surf: " << surface << " (" << surface->center().x() << ", " << surface->center().y() << "," << surface->center().z() << ")"
424  // << " ROT: " << ROT << " PRD: " << (ROT ? ROT->prepRawData() : 0) << " PRD detEl: " << (ROT ? ROT->prepRawData()->detectorElement() : 0) );
425  } // end for loop over trackstates
426  return trackStateData;
427 }
428 
429 
432  // reset the counters
433  //m_fakes = 0;
434  //m_missed = 0;
435  m_driftCircleSignFlips = 0;
436  m_noDriftTime = 0;
437  m_nDiffs = 0;
438  for (int detType = 0; detType < Trk::TrackState::NumberOfMeasurementTypes; detType++) {
439  m_fakesSum[detType] += m_fakes[detType];
440  m_fakes[detType] = 0;
441  m_missedSum[detType] += m_missed[detType];
442  m_missed[detType] = 0;
443  m_PRD_MismatchesSum[detType] += m_PRD_Mismatches[detType];
444  m_PRD_Mismatches[detType] = 0;
445  m_nRefStatesSum[detType] += m_nRefStates[detType];
446  m_nRefStates[detType] = 0;
447  m_nCompStatesSum[detType] += m_nCompStates[detType];
448  m_nCompStates[detType] = 0;
449  m_wrongType[detType] += m_wrongType[detType];
450  m_wrongType[detType] = 0;
451  }
452  for (int TSoSType = 0; TSoSType < Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes; TSoSType++) {
453  m_missingType[TSoSType] = 0;
454  m_fakeType[TSoSType] = 0;
455  m_refType[TSoSType] = 0;
456  m_compareType[TSoSType] = 0;
457  }
458 // m_missingType->clear();
459 // m_missingType->resize(Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes, 0);
460 // m_fakeType->clear();
461 // m_fakeType->resize(Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes, 0);
462 // m_PRD_Mismatches->clear();
463 // m_PRD_Mismatches->resize(8, 0);
464  if (m_writeNtuple) {
465  m_detectorType->clear();
466  m_isFake->clear();
467  m_isMissing->clear();
468  m_isPRD_Mismatch->clear();
469  m_isFlippedSign->clear();
470  m_isNoDriftTime->clear();
471  m_refIsMeasurement->clear();
472  m_refIsOutlier->clear();
473  m_compIsMeasurement->clear();
474  m_compIsOutlier->clear();
475  m_surfX->clear();
476  m_surfY->clear();
477  m_surfZ->clear();
478 
479  if (m_writeCompetingROT) {
480  m_maxAssignProb->clear();
481  m_sumAssignProb->clear();
482  } // end if writeComepetingROT
483  }
484 
485 }
486 
489  std::string &detTypeName ) const {
490  // identify by ROT of reference track:
491  Identifier id = ROT.identify();
492 
493  // get dector type
494  if ( id.is_valid()) {
495  if (m_idHelper->is_pixel(id) ) {
496  detTypeName = "Pixel";
497  return Trk::TrackState::Pixel;
498  } else if (m_idHelper->is_sct(id)) {
499  detTypeName = "SCT";
500  return Trk::TrackState::SCT;
501  } else if (m_idHelper->is_trt(id)) {
502  detTypeName = "TRT";
503  return Trk::TrackState::TRT;
504  } else if (m_idHelper->is_mdt(id)) {
505  detTypeName = "MDT";
506  return Trk::TrackState::MDT;
507  } else if (m_idHelper->is_csc(id)) {
508  detTypeName = "CSC";
509  return Trk::TrackState::CSC;
510  } else if (m_idHelper->is_rpc(id)) {
511  detTypeName = "RPC";
512  return Trk::TrackState::RPC;
513  } else if (m_idHelper->is_tgc(id)) {
514  detTypeName = "TGC";
515  return Trk::TrackState::TGC;
516  }
517  }
518  detTypeName = "unidentified";
520 }
521 
524  const Trk::TrackStateData* compareTrackState) {
525 
526  bool foundDiff = false;
527 
528  bool isFake = false;
529  bool isMissing = false;
530  bool isPRD_Mismatch = false;
531  bool isFlippedSign = false;
532  bool isNoDriftTime = false;
533  bool refIsMeasurement = false;
534  bool refIsOutlier = false;
535  bool compIsMeasurement = false;
536  bool compIsOutlier = false;
537  bool wrongType = false;
538  std::string detTypeName = "unidentified";
540  //std::stringstream surfaceCenter;
541 
542  //ATH_MSG_VERBOSE ( "Writing info for states: " << (refTrackState ? "REF ": "") << (refTrackState ? m_refIndex : 0) << " " << (compareTrackState ? "CMP " : "" ) << (compareTrackState ? m_compIndex : 0) );
543 
544  // info about the state types
545  if (refTrackState){
546  refIsMeasurement = refTrackState->trackStateOnSurface()->type(Trk::TrackStateOnSurface::Measurement);
547  refIsOutlier = refTrackState->trackStateOnSurface()->type(Trk::TrackStateOnSurface::Outlier);
548  if (!compareTrackState) {
549  // we have a ref state without compared state
550  isMissing = true;
551  foundDiff = true;
552  m_missed[ refTrackState->detType() ]++;
553  }
554  // count the reference states by detector type
555  m_nRefStates[ refTrackState->detType() ]++;
556  detType = refTrackState->detType();
557  detTypeName = refTrackState->detTypeName();
558  //surfaceCenter << "(" << refTrackState->surface()->center().x() << ", " << refTrackState->surface()->center().y() << "," <<refTrackState->surface()->center().z() << ")";
559  } else {
560  // we have a compared state without ref state
561  isFake = true;
562  foundDiff = true;
563  m_fakes[ compareTrackState->detType() ]++;
564  detType = compareTrackState->detType();
565  detTypeName = compareTrackState->detTypeName();
566  } // end if (refTrackState)
567  if (compareTrackState){
568  compIsMeasurement = compareTrackState->trackStateOnSurface()->type(Trk::TrackStateOnSurface::Measurement);
569  compIsOutlier = compareTrackState->trackStateOnSurface()->type(Trk::TrackStateOnSurface::Outlier);
570  // count the compared states by detector type
571  m_nCompStates[ compareTrackState->detType() ]++;
572  }//end if (compareTrackState)
573 
574  // find differences if both states exist
575  if (refTrackState && compareTrackState) {
576 
577  // find differences in the TrackStateOnSurface types:
578  if (m_compareAll) {
579 
580  } else {
581  if (m_compareOutliers && (refIsOutlier != compIsOutlier)) {
582  foundDiff = true;
583  wrongType = true;
584  if (refIsOutlier) {
585  m_missingType[Trk::TrackStateOnSurface::Outlier]++;
586  } else {
587  m_fakeType[Trk::TrackStateOnSurface::Outlier]++;
588  }
589  } // end if differ in outlier type
590  if (refIsMeasurement != compIsMeasurement ) {
591  foundDiff = true;
592  wrongType = true;
593  if (refIsMeasurement) {
594  m_missingType[Trk::TrackStateOnSurface::Measurement]++;
595  } else {
597  }
598  } // end if differ in measurement type
599  } // end else (compare all types)
600 
601  // find differences in the ROTs:
602  const Trk::RIO_OnTrack* refROT = refTrackState->rot();
603  const Trk::RIO_OnTrack* compareROT = compareTrackState->rot();
604  if (refROT && compareROT) {
605  if (refROT->prepRawData() != compareROT->prepRawData()) {
606  isPRD_Mismatch = true;
607  (m_PRD_Mismatches[detType])++;
608  }
609  if (detType == Trk::TrackState::TRT) {
610  isFlippedSign = ((refROT->localParameters()[Trk::locR]) * (compareROT->localParameters()[Trk::locR]) < 0. );
611  if (isFlippedSign) m_driftCircleSignFlips++;
612  isNoDriftTime = ((refROT->localParameters()[Trk::locR] != 0. ) && (compareROT->localParameters()[Trk::locR] == 0. ) );
613  if (isNoDriftTime) m_noDriftTime++;
614  }
615  foundDiff = (foundDiff || isPRD_Mismatch || isFlippedSign || isNoDriftTime );
616  } // end if (both states have ROTs)
617  } // end if (both states exist)
618  if (foundDiff) {
619  double surfX = 0;
620  double surfY = 0;
621  double surfZ = 0;
622  // give some info about the diff:
623  msg(MSG::DEBUG) << "Diff:";
624  if (isFake){ msg(MSG::DEBUG) << " -- ";}
625  else {msg(MSG::DEBUG) << (refIsOutlier ? " O" : " ") << (refIsMeasurement ? "M " : " ");}
626  if (isMissing){ msg(MSG::DEBUG) << " -- ";}
627  else {msg(MSG::DEBUG) << (compIsOutlier ? " O" : " ") << (compIsMeasurement ? "M " : " ");}
628  msg(MSG::DEBUG) << (isFake ? " FakeState " : "")
629  << (isMissing ? " MissingState " : "")
630  << (wrongType ? " Wrong TSoS type" : "")
631  << (isPRD_Mismatch ? " PRD mismatch " : "")
632  << (isFlippedSign ? " Flipped Sign " : "")
633  << (isNoDriftTime ? " NoDriftTime " : "")
634  << " in " << detTypeName
635  << " detector at surface with center " << endmsg; //<< surfaceCenter
636  if (refTrackState) {
637  surfX = refTrackState->surface()->center().x();
638  surfY = refTrackState->surface()->center().y();
639  surfZ = refTrackState->surface()->center().z();
640  } else {
641  surfX = compareTrackState->surface()->center().x();
642  surfY = compareTrackState->surface()->center().y();
643  surfZ = compareTrackState->surface()->center().z();
644  }
645  ATH_MSG_DEBUG ( "(" << surfX << ", " << surfY << "," << surfZ << ")");
646  if (m_writeNtuple) {
647  if (m_writeCompetingROT) {
648  // write some data specific to TrkCompetingRIOsOnTrack
649  float maxAssgnProb = -1.;
650  float sumAssgnProb = -1.;
651  if (compareTrackState) {
652  const Trk::CompetingRIOsOnTrack* competingROT = dynamic_cast< const Trk::CompetingRIOsOnTrack* > (compareTrackState->trackStateOnSurface()->measurementOnTrack());
653  if (competingROT) {
654  maxAssgnProb = competingROT->assignmentProbability(competingROT->indexOfMaxAssignProb());
655  // sum up all assignment probs:
656  sumAssgnProb = 0.;
657  for (unsigned int index = 0; index < competingROT->numberOfContainedROTs(); index++) {
658  sumAssgnProb += competingROT->assignmentProbability(index);
659  }
660  } // end if competingROT
661  } // end if compareTrackState
662  m_maxAssignProb->push_back(maxAssgnProb);
663  m_sumAssignProb->push_back(sumAssgnProb);
664  } // end if writeComepetingROT
665 
666  // push data into the vectors
667  m_isFake->push_back(isFake?1:0);
668  m_isMissing->push_back(isMissing?1:0);
669  m_detectorType->push_back(detType);
670  m_isPRD_Mismatch->push_back(isPRD_Mismatch?1:0);
671  m_isFlippedSign->push_back(isFlippedSign?1:0);
672  m_isNoDriftTime->push_back(isNoDriftTime?1:0);
673  m_refIsOutlier->push_back(refIsOutlier?1:0);
674  m_refIsMeasurement->push_back(refIsMeasurement?1:0);
675  m_compIsOutlier->push_back(compIsOutlier?1:0);
676  m_compIsMeasurement->push_back(compIsMeasurement?1:0);
677  m_surfX->push_back(surfX);
678  m_surfY->push_back(surfY);
679  m_surfZ->push_back(surfZ);
680  } // end if (writeNtuple)
681  m_nDiffs++;
682  } // end if (foundDiff)
683  return (foundDiff);
684 
685 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
Trk::TrackStateData::detTypeName
const std::string & detTypeName() const
return detector type name
Definition: TrackStateData.cxx:57
Trk::TrackState::RPC
@ RPC
Definition: TrackStateDefs.h:33
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
Trk::TrackState::Pixel
@ Pixel
Definition: TrackStateDefs.h:28
Trk::TrackStateData::detType
const TrackState::MeasurementType & detType() const
return dectector type
Definition: TrackStateData.cxx:61
TrackParameters.h
Trk::TrackState::TRT
@ TRT
Definition: TrackStateDefs.h:30
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CompetingRIOsOnTrack.h
Surface.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
InDetSecVtxTruthMatchUtils::isFake
bool isFake(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:60
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
Trk::TrackState::MDT
@ MDT
Definition: TrackStateDefs.h:31
Trk::TrackDiff::initialize
StatusCode initialize()
Definition: TrackDiff.cxx:105
Trk::TrackDiff::finalize
StatusCode finalize()
finalize
Definition: TrackDiff.cxx:207
Trk::TrackStateOnSurface::measurementOnTrack
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
Trk::TrackState::TGC
@ TGC
Definition: TrackStateDefs.h:34
Trk::TrackDiff::diffStateInfo
bool diffStateInfo(const Trk::TrackStateData *refTrackStateData, const Trk::TrackStateData *compareTrackStateData)
diff of two given track state data
Definition: TrackDiff.cxx:523
Trk::locR
@ locR
Definition: ParamDefs.h:44
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Trk::TrackState::unidentified
@ unidentified
Definition: TrackStateDefs.h:27
Trk::TrackStateData::surface
const Trk::Surface * surface() const
return Trk::Surface pointer
Definition: TrackStateData.cxx:53
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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
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.
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::TrackDiff::resetVariables
void resetVariables()
reset the ntuple variables
Definition: TrackDiff.cxx:431
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
Trk::CompetingRIOsOnTrack::numberOfContainedROTs
virtual unsigned int numberOfContainedROTs() const =0
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
Trk::TrackDiff::TrackDiff
TrackDiff(const std::string &, const std::string &, const IInterface *)
Definition: TrackDiff.cxx:34
beamspotman.n
n
Definition: beamspotman.py:731
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
Trk::TrackState::MeasurementType
MeasurementType
enum describing the flavour of MeasurementBase
Definition: TrackStateDefs.h:26
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Trk::PrepRawData
Definition: PrepRawData.h:62
Trk::MeasurementBase
Definition: MeasurementBase.h:58
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
Trk::Track::perigeeParameters
const Perigee * perigeeParameters() const
return Perigee.
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:163
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.
RIO_OnTrack.h
TrackDiff.h
Trk::TrackStateData::trackStateOnSurface
const Trk::TrackStateOnSurface * trackStateOnSurface() const
return Trk::TrackStateOnSurface pointer
Definition: TrackStateData.cxx:45
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Trk::RIO_OnTrack::prepRawData
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
LocalParameters.h
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition: MeasurementBase.h:132
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
Trk::TrackDiff::detectorType
Trk::TrackState::MeasurementType detectorType(const Trk::RIO_OnTrack &ROT, std::string &detTypeName) const
get detector type and name by identifier of Trk::RIO_OnTrack
Definition: TrackDiff.cxx:488
Trk::TrackStateData
Definition: TrackStateData.h:30
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::TrackDiff::extractDataFromTrack
DataVector< const Trk::TrackStateData > * extractDataFromTrack(const Trk::Track &) const
extract data from a Trk::Track into a list of Trk::TrackStateData
Definition: TrackDiff.cxx:345
Trk::TrackStateData::rot
const Trk::RIO_OnTrack * rot() const
return Trk::RIO_OnTrack pointer
Definition: TrackStateData.cxx:49
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:152
DEBUG
#define DEBUG
Definition: page_access.h:11
Trk::TrackState::CSC
@ CSC
Definition: TrackStateDefs.h:32
Trk::TrackDiff::~TrackDiff
~TrackDiff()
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Trk::TrackState::SCT
@ SCT
Definition: TrackStateDefs.h:29
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::erase
iterator erase(iterator position)
Remove element at a given position.
Trk::CompetingRIOsOnTrack::indexOfMaxAssignProb
unsigned int indexOfMaxAssignProb() const
Index of the ROT with the highest assignment probability.
Definition: CompetingRIOsOnTrack.cxx:101
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
Trk::phi0
@ phi0
Definition: ParamDefs.h:65
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes
@ NumberOfTrackStateOnSurfaceTypes
Definition: TrackStateOnSurface.h:152
Trk::TrackState::NumberOfMeasurementTypes
@ NumberOfMeasurementTypes
Definition: TrackStateDefs.h:43
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Trk::TrackDiff::diff
virtual StatusCode diff(const Trk::Track &referenceTrack, const Trk::Track &comparedTrack)
diff of two given tracks
Definition: TrackDiff.cxx:223
Trk::CompetingRIOsOnTrack::assignmentProbability
AssignmentProb assignmentProbability(unsigned int indx) const
returns the AssignmentProbability depending on the integer.
Definition: CompetingRIOsOnTrack.h:139
Identifier
Definition: IdentifierFieldParser.cxx:14