ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
44 m_compareAll(false),
45 m_writeNtuple(true),
50 m_fakes{},
51
52 m_missed{},
55 m_fakeType{},
56 m_refType{},
61 m_nDiffs{},
63 m_isFake{},
74 m_surfX{},
75 m_surfY{},
76 m_surfZ{},
77 m_trackEta{},
78 m_trackPhi{},
81 m_fakesSum{},
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
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
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" );
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] );
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)" );
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
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] );
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] );
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;
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
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";
498 } else if (m_idHelper->is_sct(id)) {
499 detTypeName = "SCT";
501 } else if (m_idHelper->is_trt(id)) {
502 detTypeName = "TRT";
504 } else if (m_idHelper->is_mdt(id)) {
505 detTypeName = "MDT";
507 } else if (m_idHelper->is_csc(id)) {
508 detTypeName = "CSC";
510 } else if (m_idHelper->is_rpc(id)) {
511 detTypeName = "RPC";
513 } else if (m_idHelper->is_tgc(id)) {
514 detTypeName = "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 }
560 else if (compareTrackState) {
561 // we have a compared state without ref state
562 isFake = true;
563 foundDiff = true;
564 m_fakes[ compareTrackState->detType() ]++;
565 detType = compareTrackState->detType();
566 detTypeName = compareTrackState->detTypeName();
567 } // end if (refTrackState)
568 if (compareTrackState){
569 compIsMeasurement = compareTrackState->trackStateOnSurface()->type(Trk::TrackStateOnSurface::Measurement);
570 compIsOutlier = compareTrackState->trackStateOnSurface()->type(Trk::TrackStateOnSurface::Outlier);
571 // count the compared states by detector type
572 m_nCompStates[ compareTrackState->detType() ]++;
573 }//end if (compareTrackState)
574
575 // find differences if both states exist
576 if (refTrackState && compareTrackState) {
577
578 // find differences in the TrackStateOnSurface types:
579 if (m_compareAll) {
580
581 } else {
582 if (m_compareOutliers && (refIsOutlier != compIsOutlier)) {
583 foundDiff = true;
584 wrongType = true;
585 if (refIsOutlier) {
587 } else {
589 }
590 } // end if differ in outlier type
591 if (refIsMeasurement != compIsMeasurement ) {
592 foundDiff = true;
593 wrongType = true;
594 if (refIsMeasurement) {
596 } else {
598 }
599 } // end if differ in measurement type
600 } // end else (compare all types)
601
602 // find differences in the ROTs:
603 const Trk::RIO_OnTrack* refROT = refTrackState->rot();
604 const Trk::RIO_OnTrack* compareROT = compareTrackState->rot();
605 if (refROT && compareROT) {
606 if (refROT->prepRawData() != compareROT->prepRawData()) {
607 isPRD_Mismatch = true;
608 (m_PRD_Mismatches[detType])++;
609 }
610 if (detType == Trk::TrackState::TRT) {
611 isFlippedSign = ((refROT->localParameters()[Trk::locR]) * (compareROT->localParameters()[Trk::locR]) < 0. );
612 if (isFlippedSign) m_driftCircleSignFlips++;
613 isNoDriftTime = ((refROT->localParameters()[Trk::locR] != 0. ) && (compareROT->localParameters()[Trk::locR] == 0. ) );
614 if (isNoDriftTime) m_noDriftTime++;
615 }
616 foundDiff = (foundDiff || isPRD_Mismatch || isFlippedSign || isNoDriftTime );
617 } // end if (both states have ROTs)
618 } // end if (both states exist)
619 if (foundDiff) {
620 double surfX = 0;
621 double surfY = 0;
622 double surfZ = 0;
623 // give some info about the diff:
624 msg(MSG::DEBUG) << "Diff:";
625 if (isFake){ msg(MSG::DEBUG) << " -- ";}
626 else {msg(MSG::DEBUG) << (refIsOutlier ? " O" : " ") << (refIsMeasurement ? "M " : " ");}
627 if (isMissing){ msg(MSG::DEBUG) << " -- ";}
628 else {msg(MSG::DEBUG) << (compIsOutlier ? " O" : " ") << (compIsMeasurement ? "M " : " ");}
629 msg(MSG::DEBUG) << (isFake ? " FakeState " : "")
630 << (isMissing ? " MissingState " : "")
631 << (wrongType ? " Wrong TSoS type" : "")
632 << (isPRD_Mismatch ? " PRD mismatch " : "")
633 << (isFlippedSign ? " Flipped Sign " : "")
634 << (isNoDriftTime ? " NoDriftTime " : "")
635 << " in " << detTypeName
636 << " detector at surface with center " << endmsg; //<< surfaceCenter
637 if (refTrackState) {
638 surfX = refTrackState->surface()->center().x();
639 surfY = refTrackState->surface()->center().y();
640 surfZ = refTrackState->surface()->center().z();
641 } else {
642 surfX = compareTrackState->surface()->center().x();
643 surfY = compareTrackState->surface()->center().y();
644 surfZ = compareTrackState->surface()->center().z();
645 }
646 ATH_MSG_DEBUG ( "(" << surfX << ", " << surfY << "," << surfZ << ")");
647 if (m_writeNtuple) {
649 // write some data specific to TrkCompetingRIOsOnTrack
650 float maxAssgnProb = -1.;
651 float sumAssgnProb = -1.;
652 if (compareTrackState) {
653 const Trk::CompetingRIOsOnTrack* competingROT = dynamic_cast< const Trk::CompetingRIOsOnTrack* > (compareTrackState->trackStateOnSurface()->measurementOnTrack());
654 if (competingROT) {
655 maxAssgnProb = competingROT->assignmentProbability(competingROT->indexOfMaxAssignProb());
656 // sum up all assignment probs:
657 sumAssgnProb = 0.;
658 for (unsigned int index = 0; index < competingROT->numberOfContainedROTs(); index++) {
659 sumAssgnProb += competingROT->assignmentProbability(index);
660 }
661 } // end if competingROT
662 } // end if compareTrackState
663 m_maxAssignProb->push_back(maxAssgnProb);
664 m_sumAssignProb->push_back(sumAssgnProb);
665 } // end if writeComepetingROT
666
667 // push data into the vectors
668 m_isFake->push_back(isFake?1:0);
669 m_isMissing->push_back(isMissing?1:0);
670 m_detectorType->push_back(detType);
671 m_isPRD_Mismatch->push_back(isPRD_Mismatch?1:0);
672 m_isFlippedSign->push_back(isFlippedSign?1:0);
673 m_isNoDriftTime->push_back(isNoDriftTime?1:0);
674 m_refIsOutlier->push_back(refIsOutlier?1:0);
675 m_refIsMeasurement->push_back(refIsMeasurement?1:0);
676 m_compIsOutlier->push_back(compIsOutlier?1:0);
677 m_compIsMeasurement->push_back(compIsMeasurement?1:0);
678 m_surfX->push_back(surfX);
679 m_surfY->push_back(surfY);
680 m_surfZ->push_back(surfZ);
681 } // end if (writeNtuple)
682 m_nDiffs++;
683 } // end if (foundDiff)
684 return (foundDiff);
685
686}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
static Double_t sc
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
iterator erase(iterator position)
Remove element at a given position.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
AssignmentProb assignmentProbability(unsigned int indx) const
returns the AssignmentProbability depending on the integer.
virtual unsigned int numberOfContainedROTs() const =0
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
unsigned int indexOfMaxAssignProb() const
Index of the ROT with the highest assignment probability.
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
This class is the pure abstract base class for all fittable tracking measurements.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
double eta() const
Access method for pseudorapidity - from momentum.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
Identifier identify() const
return the identifier -extends MeasurementBase
Abstract Base Class for tracking surfaces.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
int m_PRD_Mismatches[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:124
std::vector< int > * m_isNoDriftTime
Definition TrackDiff.h:134
int m_driftCircleSignFlips
Definition TrackDiff.h:125
TrackDiff(const std::string &, const std::string &, const IInterface *)
Definition TrackDiff.cxx:34
SG::ReadHandleKey< xAOD::EventInfo > m_evt
Definition TrackDiff.h:157
StatusCode finalize()
finalize
std::vector< int > * m_compIsOutlier
Definition TrackDiff.h:138
int m_nRefStates[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:114
int m_missed[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:118
std::vector< int > * m_isFake
vector<bool> would be more efficient, but vector<bool> is not a normal vector<> and seems to make tro...
Definition TrackDiff.h:130
int m_wrongTypeSum[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:153
std::vector< float > * m_sumAssignProb
Definition TrackDiff.h:140
int m_refType[Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes]
Definition TrackDiff.h:122
std::string m_ntupleTreeName
jobOption: Ntuple tree name
Definition TrackDiff.h:105
int m_fakeType[Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes]
Definition TrackDiff.h:121
Trk::TrackState::MeasurementType detectorType(const Trk::RIO_OnTrack &ROT, std::string &detTypeName) const
get detector type and name by identifier of Trk::RIO_OnTrack
bool m_compareOutliers
jobOption: compare track states of type "outlier"
Definition TrackDiff.h:107
int m_missedSum[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:152
std::vector< int > * m_isPRD_Mismatch
Definition TrackDiff.h:132
int m_PRD_MismatchesSum[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:154
std::vector< int > * m_detectorType
Definition TrackDiff.h:129
StatusCode initialize()
int m_wrongType[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:119
int m_fakesSum[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:151
bool m_compareAll
jobOption: compare track states of all types
Definition TrackDiff.h:108
std::string m_ntupleDirName
jobOption: Ntuple directory name
Definition TrackDiff.h:104
int m_nCompStatesSum[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:150
int m_compareType[Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes]
Definition TrackDiff.h:123
std::string m_ntupleFileName
jobOption: Ntuple file name
Definition TrackDiff.h:103
std::vector< float > * m_surfZ
Definition TrackDiff.h:143
int m_missingType[Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes]
Definition TrackDiff.h:120
TTree * m_nt
Pointer to the NTuple tree.
Definition TrackDiff.h:98
std::vector< float > * m_maxAssignProb
Definition TrackDiff.h:139
std::vector< int > * m_compIsMeasurement
Definition TrackDiff.h:137
bool m_writeCompetingROT
jobOption: write data about TrkCompetingRIOsOnTrack?
Definition TrackDiff.h:110
DataVector< const Trk::TrackStateData > * extractDataFromTrack(const Trk::Track &) const
extract data from a Trk::Track into a list of Trk::TrackStateData
std::vector< int > * m_isMissing
Definition TrackDiff.h:131
int m_fakes[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:116
AtlasDetectorID * m_idHelper
Used to find out the sub-det from PRD->identify().
Definition TrackDiff.h:100
std::vector< int > * m_isFlippedSign
Definition TrackDiff.h:133
std::vector< float > * m_surfX
Definition TrackDiff.h:141
virtual StatusCode diff(const Trk::Track &referenceTrack, const Trk::Track &comparedTrack)
diff of two given tracks
std::vector< float > * m_surfY
Definition TrackDiff.h:142
std::vector< int > * m_refIsMeasurement
Definition TrackDiff.h:135
bool diffStateInfo(const Trk::TrackStateData *refTrackStateData, const Trk::TrackStateData *compareTrackStateData)
diff of two given track state data
int m_nRefStatesSum[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:149
std::vector< int > * m_refIsOutlier
Definition TrackDiff.h:136
bool m_writeNtuple
jobOption: write data to ntuple?
Definition TrackDiff.h:109
int m_nCompStates[Trk::TrackState::NumberOfMeasurementTypes]
Definition TrackDiff.h:115
void resetVariables()
reset the ntuple variables
Helper class for Trk::TrackDiff.
const std::string & detTypeName() const
return detector type name
const Trk::TrackStateOnSurface * trackStateOnSurface() const
assignment operator
const TrackState::MeasurementType & detType() const
return dectector type
const Trk::RIO_OnTrack * rot() const
return Trk::RIO_OnTrack pointer
const Trk::Surface * surface() const
return Trk::Surface pointer
bool type(const TrackStateOnSurfaceType type) const
Use this method to find out if the TSoS is of a certain type: i.e.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
const Perigee * perigeeParameters() const
return Perigee.
MeasurementType
enum describing the flavour of MeasurementBase
DataVector< const Trk::TrackStateOnSurface > TrackStates
@ locR
Definition ParamDefs.h:44
@ phi0
Definition ParamDefs.h:65
Definition index.py:1
MsgStream & msg
Definition testRead.cxx:32