ATLAS Offline Software
Functions
JiveXML::TrackRetrieverHelpers Namespace Reference

Namespace for all helper functions. More...

Functions

const Trk::PerigeegetPerigeeParameters (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 vectors. More...
 
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 comparison functions. More...
 
void getPolylineFromHits (const std::vector< const Trk::TrackStateOnSurface * > &TSoSVec, DataVect &polylineX, DataVect &polylineY, DataVect &polylineZ, DataVect &numPolyline)
 Get polyline hits if available. More...
 
const Trk::RIO_OnTrackgetBaseInfoFromHit (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. More...
 
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. More...
 
void getTruthFromTrack (const Trk::Track *track, const TrackCollection *trackCollection, const TrackTruthCollection *truthCollection, DataVect &barcode)
 Get the barcode of the associated truth track. More...
 

Detailed Description

Namespace for all helper functions.

Function Documentation

◆ getBaseInfoFromHit()

const Trk::RIO_OnTrack* JiveXML::TrackRetrieverHelpers::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.

Returns
the reconstruction input object (RIO) for further use

Definition at line 184 of file TrackRetriever.cxx.

185  {
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  }

◆ getPerigeeParameters()

const Trk::Perigee* JiveXML::TrackRetrieverHelpers::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 vectors.

Perigee parameters are written out in the old format using \( \cot\theta \) and \( q/p_T \)

Returns
the perigee parameter object for further use

Get perigee parameters in old format ( \( d_0 \), \( z_0 \), \( \phi \), \( \cot\theta \), \( q/p_T \)), whereas tracking uses ( \( d_0 \), \( z_0 \), \( \phi \), \( \theta \), q/p), therefore a transformation of the covariance matrix is needed

get transformed covariance matrix

Definition at line 50 of file TrackRetriever.cxx.

52  {
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  }

◆ getPolylineFromHits()

void JiveXML::TrackRetrieverHelpers::getPolylineFromHits ( const std::vector< const Trk::TrackStateOnSurface * > &  TSoSVec,
DataVect polylineX,
DataVect polylineY,
DataVect polylineZ,
DataVect numPolyline 
)

Get polyline hits if available.

Polyline tracks that have less than 2 points are not useful - skip

Definition at line 158 of file TrackRetriever.cxx.

159  {
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  }

◆ getResidualPullFromHit()

void JiveXML::TrackRetrieverHelpers::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.

Using track residual tool: ResidualPullCalculator -excerpt from Tracking/TrkValidation/TrkValTools/src/BasicValidationNtupleTool.cxx

Definition at line 253 of file TrackRetriever.cxx.

255  {
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  }

◆ getTrackStateOnSurfaces()

std::vector<const Trk::TrackStateOnSurface*> JiveXML::TrackRetrieverHelpers::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 comparison functions.

Returns
a std::vector of Trk::TrackStateOnSurface*

Definition at line 120 of file TrackRetriever.cxx.

120  {
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  }

◆ getTruthFromTrack()

void JiveXML::TrackRetrieverHelpers::getTruthFromTrack ( const Trk::Track track,
const TrackCollection trackCollection,
const TrackTruthCollection truthCollection,
DataVect barcode 
)

Get the barcode of the associated truth track.

Definition at line 302 of file TrackRetriever.cxx.

303  {
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  }
AtlasDetectorID::is_pixel
bool is_pixel(Identifier id) const
Definition: AtlasDetectorID.h:760
Trk::TrackStateOnSurface::trackParameters
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
AtlasDetectorID::is_rpc
bool is_rpc(Identifier id) const
Definition: AtlasDetectorID.h:875
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
AtlasDetectorID::is_csc
bool is_csc(Identifier id) const
Definition: AtlasDetectorID.h:891
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:770
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
compFunc
bool(*)(const xAOD::Jet *, const xAOD::Jet *) compFunc
Definition: JetSorter.cxx:12
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
test_pyathena.pt
pt
Definition: test_pyathena.py:11
Trk::z0
@ z0
Definition: ParamDefs.h:64
Trk::TrackStateOnSurface::measurementOnTrack
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
Trk::loc2
@ loc2
generic first and second local coordinate
Definition: ParamDefs.h:35
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
AtlasDetectorID::is_trt
bool is_trt(Identifier id) const
Definition: AtlasDetectorID.h:782
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
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
MuonR4::SegmentFitHelpers::driftSign
int driftSign(const Amg::Vector3D &posInChamber, const Amg::Vector3D &dirInChamber, const SpacePoint &uncalibHit, MsgStream &msg)
Calculates whether a segement line travereses the tube measurement on the left (-1) or right (1) side...
Definition: SegmentFitHelperFunctions.cxx:232
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
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.
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
lumiFormat.i
int i
Definition: lumiFormat.py:85
AtlasDetectorID::is_tgc
bool is_tgc(Identifier id) const
Definition: AtlasDetectorID.h:902
Trk::theta
@ theta
Definition: ParamDefs.h:66
xAOD::covMatrix
covMatrix
Definition: TrackMeasurement_v1.cxx:19
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:53
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Trk::ParametersBase
Definition: ParametersBase.h:55
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::d0
@ d0
Definition: ParamDefs.h:63
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
Trk::ResidualPull::Biased
@ Biased
RP with track state including the hit.
Definition: ResidualPull.h:55
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:152
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
TRT::Track::cotTheta
@ cotTheta
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:65
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
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:34
Trk::JacobianThetaPToCotThetaPt
Definition: JacobianThetaPToCotThetaPt.h:41
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
AtlasDetectorID::is_mdt
bool is_mdt(Identifier id) const
Definition: AtlasDetectorID.h:859
Identifier
Definition: IdentifierFieldParser.cxx:14