Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
6 #include "GaudiKernel/IToolSvc.h"
7 #include "GaudiKernel/TypeNameString.h"
21 #include "AthLinks/ElementLink.h"
36 #include "GaudiKernel/SystemOfUnits.h"
40 namespace TrackRetrieverHelpers {
57 const Trk::Perigee *perigee = track->perigeeParameters();
60 if (!perigee)
return nullptr;
63 if ((perigee->parameters())[
Trk::qOverP]==0)
pt.emplace_back(9999.);
80 const AmgSymMatrix(5)* covariance = perigee->covariance();
81 if (perigee && covariance) {
83 double measuredTheta = perigee->parameters()[
Trk::theta];
84 double measuredQoverp = perigee->parameters()[
Trk::qOverP];
86 covVert = covariance->similarity(theJac);
88 for (
int ii=0; ii<20; ii++){
95 const long scale = 10000;
96 const double thisScale(
scale/100.);
98 covMatrix.emplace_back(covVert(0)*thisScale);
99 covMatrix.emplace_back(covVert(1)*thisScale);
100 covMatrix.emplace_back(covVert(2)*thisScale);
101 covMatrix.emplace_back(covVert(3)*thisScale);
102 covMatrix.emplace_back(covVert(4)*thisScale);
105 for (
int i=0;
i<10;
i++){
120 std::vector<const Trk::TrackStateOnSurface*> TSoSVec;
124 for (; tsos!=track->trackStateOnSurfaces()->
end(); ++tsos) {
128 TSoSVec.push_back(*tsos);
141 if (TSoSVec.size() > 2 && !is_sorted(TSoSVec.begin(), TSoSVec.end(), *
compFunc))
142 std::sort(TSoSVec.begin(), TSoSVec.end(), *
compFunc);
158 if (TSoSVec.size() > 1) {
160 std::vector<const Trk::TrackStateOnSurface*>::const_iterator tsosIter;
161 const double onetenth(0.1);
162 for (tsosIter=TSoSVec.begin(); tsosIter!=TSoSVec.end(); ++tsosIter) {
164 if (!(*tsosIter)->trackParameters()) continue ;
166 polylineX.emplace_back(
pos.x()*onetenth);
167 polylineY.emplace_back(
pos.y()*onetenth);
168 polylineZ.emplace_back(
pos.z()*onetenth);
173 numPolyline.emplace_back(numPoly);
188 if (!measurement)
return nullptr;
202 if (!rot)
return nullptr;
214 int theDriftSign = 0;
215 if (idHelper->
is_trt(hitId)) {
223 tsosDetType.emplace_back(
"unident");
224 }
else if (idHelper->
is_pixel(hitId) ) {
225 tsosDetType.emplace_back(
"PIX");
226 }
else if (idHelper->
is_sct(hitId)) {
227 tsosDetType.emplace_back(
"SIL");
228 }
else if (idHelper->
is_trt(hitId)) {
229 tsosDetType.emplace_back(
"TRT");
230 }
else if (idHelper->
is_mdt(hitId)) {
231 tsosDetType.emplace_back(
"MDT");
232 }
else if (idHelper->
is_csc(hitId)) {
233 tsosDetType.emplace_back(
"CSC");
234 }
else if (idHelper->
is_rpc(hitId)) {
235 tsosDetType.emplace_back(
"RPC");
236 }
else if (idHelper->
is_tgc(hitId)) {
237 tsosDetType.emplace_back(
"TGC");
239 tsosDetType.emplace_back(
"unident");
251 const ToolHandle<Trk::IResidualPullCalculator> & residualPullCalculator,
255 double ResLoc1 = -99.;
256 double ResLoc2 = -99.;
257 double PullLoc1 = -99.;
258 double PullLoc2 = -99.;
272 std::optional<Trk::ResidualPull> residualPull = residualPullCalculator->residualPull(rot, tsosParameters,
Trk::ResidualPull::Biased);
276 ResLoc1 = residualPull->residual()[
Trk::loc1];
278 if (residualPull->dimension() >= 2) ResLoc2 = residualPull->residual()[
Trk::loc2];
280 if ((residualPull->isPullValid()) ) {
282 PullLoc1 = residualPull->pull()[
Trk::loc1];
284 if (residualPull->dimension() >= 2) PullLoc2 = residualPull->pull()[
Trk::loc2];
290 tsosResLoc1.emplace_back(ResLoc1 );
291 tsosResLoc2.emplace_back(ResLoc2 );
292 tsosPullLoc1.emplace_back(PullLoc1 );
293 tsosPullLoc2.emplace_back(PullLoc2 );
302 if (!truthCollection.
isValid()) {
314 std::map<Trk::TrackTruthKey,TrackTruth>::const_iterator tempTrackTruthItr = truthCollection->find(tracklink);
317 if (tempTrackTruthItr == truthCollection->end()){
324 barcode.emplace_back((*tempTrackTruthItr).second.particleLink().barcode());
354 return StatusCode::SUCCESS;
373 return StatusCode::SUCCESS;
377 for (
const std::string&
key :
keys) {
390 return StatusCode::SUCCESS;
398 if ( trackCollection->
empty()){
399 ATH_MSG_DEBUG(
"Empty track collection " << collectionName );
401 ATH_MSG_DEBUG(
"Retrieving data for track collection " << collectionName);
415 if (truthCollection.
isValid()) {
420 if (truthCollection.
isValid()) {
421 ATH_MSG_DEBUG(
"Found TrackTruthCollection with key " << collectionName <<
"TruthCollection");
424 if (truthCollection.
isValid()) {
425 ATH_MSG_DEBUG(
"Found TrackTruthCollection with key " << collectionName <<
"Truth");
427 ATH_MSG_DEBUG(
"Could not find matching TrackTruthCollection for " << collectionName);
435 DataVect numDoF; numDoF.reserve(trackCollection->
size());
436 DataVect trackAuthor; trackAuthor.reserve(trackCollection->
size());
438 DataVect numHits; numHits.reserve(trackCollection->
size());
439 DataVect numPolyline; numPolyline.reserve(trackCollection->
size());
440 DataVect nBLayerHits; nBLayerHits.reserve(trackCollection->
size());
441 DataVect nPixHits; nPixHits.reserve(trackCollection->
size());
470 for (track=trackCollection->
begin(); track!=trackCollection->
end(); ++track) {
474 id.emplace_back(
id.
size());
475 chi2.emplace_back((*track)->fitQuality()->chiSquared());
476 numDoF.emplace_back((*track)->fitQuality()->numberDoF());
477 trackAuthor.emplace_back((*track)->info().trackFitter());
492 std::unique_ptr<Trk::TrackSummary>
summary =
nullptr;
497 nBLayerHits.emplace_back(0);
498 nPixHits.emplace_back(0);
518 polylineX.reserve(polylineX.size()+TSoSVec.size());
519 polylineY.reserve(polylineY.size()+TSoSVec.size());
520 polylineZ.reserve(polylineZ.size()+TSoSVec.size());
529 isOutlier.reserve(isOutlier.size()+TSoSVec.size());
530 hits.reserve(
hits.size()+TSoSVec.size());
532 tsosResLoc1.reserve(tsosResLoc1.size()+TSoSVec.size());
533 tsosResLoc2.reserve(tsosResLoc2.size()+TSoSVec.size());
534 tsosPullLoc1.reserve(tsosPullLoc1.size()+TSoSVec.size());
535 tsosPullLoc2.reserve(tsosPullLoc2.size()+TSoSVec.size());
536 tsosDetType.reserve(tsosDetType.size()+TSoSVec.size());
539 std::vector< const Trk::TrackStateOnSurface* >::const_iterator TSoSItr = TSoSVec.begin();
543 for (; TSoSItr != TSoSVec.end(); ++TSoSItr){
550 ATH_MSG_VERBOSE(
"Could not obtain RIO for TSoS of type " << (*TSoSItr)->dumpType() );
564 numHits.emplace_back(nHits);
574 DataMap[
"trackAuthor"] = trackAuthor;
577 DataMap[
"nBLayerHits"] = nBLayerHits;
578 DataMap[
"nPixHits"] = nPixHits;
581 DataMap[
"numPolyline"] = numPolyline;
595 if ( !polylineX.empty()){
596 std::string numPolyPerTrack =
DataType(polylineX.size()/((
double)
id.size())).toString();
597 DataMap[
"polylineX multiple=\"" + numPolyPerTrack +
"\""] = polylineX;
598 DataMap[
"polylineY multiple=\"" + numPolyPerTrack +
"\""] = polylineY;
599 DataMap[
"polylineZ multiple=\"" + numPolyPerTrack +
"\""] = polylineZ;
603 std::string numHitsPerTrack =
DataType(
hits.size()/((
double)
id.size())).toString();
604 DataMap[
"hits multiple=\"" + numHitsPerTrack +
"\""] =
hits;
605 DataMap[
"isOutlier multiple=\""+numHitsPerTrack+
"\""] = isOutlier;
611 DataMap[
"tsosResLoc1 multiple=\""+numHitsPerTrack+
"\""] = tsosResLoc1;
612 DataMap[
"tsosResLoc2 multiple=\""+numHitsPerTrack+
"\""] = tsosResLoc2;
613 DataMap[
"tsosPullLoc1 multiple=\""+numHitsPerTrack+
"\""] = tsosPullLoc1;
614 DataMap[
"tsosPullLoc2 multiple=\""+numHitsPerTrack+
"\""] = tsosPullLoc2;
615 DataMap[
"tsosDetType multiple=\""+numHitsPerTrack+
"\""] = tsosDetType;
638 std::vector<std::string> allKeys;
644 for (
const std::string&
key : allKeys) {
const std::vector< std::string > getKeys()
Gets the StoreGate keys for the desired containers.
bool is_pixel(Identifier id) const
@ numberOfPixelHits
number of pixel layers on track with absence of hits
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
char data[hepevt_bytes_allocation_ATLAS]
bool is_rpc(Identifier id) const
Const iterator class for DataVector/DataList.
Gaudi::Property< std::string > m_priorityKey
StatusCode initialize()
Default AthAlgTool methods.
Gaudi::Property< std::string > m_TrackTruthCollection
@ numberOfInnermostPixelLayerHits
these are the hits in the 1st pixel layer
bool is_csc(Identifier id) const
Gaudi::Property< bool > m_doWriteResiduals
Gaudi::Property< bool > m_doHitsDetails
bool is_sct(Identifier id) const
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
const Trk::Perigee * getPerigeeParameters(const Trk::Track *track, DataVect &pt, DataVect &d0, DataVect &z0, DataVect &phi0, DataVect &cotTheta, DataVect &covMatrix)
Obtain the perigee parameters for a given track, if available, and fill them in the corresponding dat...
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
bool(*)(const xAOD::Jet *, const xAOD::Jet *) compFunc
value_type get_compact() const
Get the compact id.
Gaudi::Property< std::vector< std::string > > m_otherKeys
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
@ loc2
generic first and second local coordinate
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.
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...
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
For each track collection retrieve all data.
bool is_trt(Identifier id) const
#define ATH_MSG_VERBOSE(x)
std::map< std::string, DataVect > DataMap
ToolHandle< Trk::IResidualPullCalculator > m_residualPullCalculator
bool is_valid() const
Check if id is in a valid state.
#define AmgSymMatrix(dim)
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
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.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
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...
bool type(const TrackStateOnSurfaceType type) const
Use this method to find out if the TSoS is of a certain type: i.e.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
Class providing comparison function, or relational definition, for sorting MeasurementBase objects.
Gaudi::Property< bool > m_doWriteAllCollections
Templated class to convert any object that is streamable in a ostringstream in a string.
float nSCTHits(const U &p)
const DataMap getData(const TrackCollection *trackCollection, const std::string &collectionName)
Puts the variables into a DataMap.
bool is_tgc(Identifier id) const
float nTRTHits(const U &p)
::StatusCode StatusCode
StatusCode definition for legacy code.
@ numberOfSCTHits
number of SCT holes
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
double chi2(TH1 *h0, TH1 *h1)
const AtlasDetectorID * m_idHelper
Used to find out the corresponding sub-det from ROT->identify().
Gaudi::Property< bool > m_doWriteHLT
virtual bool isValid() override final
Can the handle be successfully dereferenced?
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
bool setElement(ElementType element)
Set to point to an element.
@ numberOfTRTHits
number of TRT outliers
represents the track state (measurement, material, fit parameters and quality) at a surface.
bool setStorableObject(BaseConstReference data, bool replace=false, IProxyDict *sg=0)
Set link to point to a new container (storable).
TrackRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Eigen::Matrix< double, 3, 1 > Vector3D
Gaudi::Property< bool > m_doHitsSorting
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
An STL vector of pointers that by default owns its pointed-to elements.
ToolHandle< Trk::ITrackSummaryTool > m_trackSumTool
@ Biased
RP with track state including the hit.
#define ATH_MSG_WARNING(x)
Identifier identify() const
return the identifier -extends MeasurementBase
void getTruthFromTrack(const Trk::Track *track, const TrackCollection *trackCollection, SG::ReadHandle< TrackTruthCollection > &truthCollection, DataVect &barcode)
Get the barcode of the associated truth track.
unsigned int indexOfMaxAssignProb() const
Index of the ROT with the highest assignment probability.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
virtual std::string dataTypeName() const
Return the name of the data type that is generated by this retriever.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
bool is_mdt(Identifier id) const
void getPolylineFromHits(const std::vector< const Trk::TrackStateOnSurface * > &TSoSVec, DataVect &polylineX, DataVect &polylineY, DataVect &polylineZ, DataVect &numPolyline)
Get polyline hits if available.