ATLAS Offline Software
Loading...
Searching...
No Matches
SCTExtensionAlg.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#include "TrkTrack/Track.h"
11
12
13
14
16SCTExtensionAlg::SCTExtensionAlg(const std::string& name, ISvcLocator* pSvcLocator) :
17 AthReentrantAlgorithm(name, pSvcLocator)
18{
19 // Properties go here
20}
21// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
23
24 ATH_MSG_INFO ("initialize()");
25
26 ATH_CHECK(m_pixelTracklets.initialize());
27 ATH_CHECK(m_tracks.initialize());
28
29 return StatusCode::SUCCESS;
30}
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
32StatusCode SCTExtensionAlg::execute(const EventContext& ctx) const {
33
35 if (not tracklets.isValid())
36 {
37 ATH_MSG_FATAL("Could not retrieve " << m_pixelTracklets.key());
38 return StatusCode::FAILURE;
39 }
40
42 if (not trks.isValid())
43 {
44 ATH_MSG_FATAL("Could not retrieve " << m_tracks.key());
45 return StatusCode::FAILURE;
46 }
47
49
50 int n_tracks=0;
51 int n_tracklets=0;
52
53 static const SG::Decorator< ElementLink< xAOD:: TrackParticleContainer > > MatchedTrackLinkDec("MatchedTrackLink");
54 static const SG::Decorator< int > MatchedTrackSharedHitsDec("MatchedTrackSharedHits");
55
56 for (mytracklet = tracklets->begin(); mytracklet != tracklets->end(); ++mytracklet) // Loop over tracklets
57 {
58 n_tracklets++;
59 int nSharedHits=0;
60 const xAOD::TrackParticle* trackletParticle = *mytracklet;
61 const Trk::Track* tracklet = trackletParticle->track();
62 if(!tracklet)
63 return StatusCode::FAILURE;
64
65 std::vector<const InDet::PixelCluster*> tracklet_pixelClusters;
66
67 const DataVector<const Trk::MeasurementBase>* tracklet_measurements = tracklet->measurementsOnTrack();
68 for ( auto tracklet_measurement : *tracklet_measurements )
69 {
70 // find out if it is a pixel hit
71 const InDet::PixelClusterOnTrack* pixelClusterOnTracklet = dynamic_cast<const InDet::PixelClusterOnTrack*>(tracklet_measurement);
72 if( pixelClusterOnTracklet )
73 {
74 //Go back to the original pixel cluster
75 const InDet::PixelCluster* tracklet_pixelCluster = dynamic_cast<const InDet::PixelCluster*>( pixelClusterOnTracklet->prepRawData() );
76
77 if( tracklet_pixelCluster )
78 {
79 // This is the pixel cluster that you would like to check if it contained in the other tracklet.
80 // to avoid doing this loop multiple time then would store these is a vector
81 tracklet_pixelClusters.push_back(tracklet_pixelCluster);
82 }
83 } // End: tracklet_PixelCluster
84 } // End: tracklet_Measurements
85
87 for (mytrack = trks->begin(); mytrack != trks->end(); ++mytrack) // Loop over tracks for each tracklet
88 {
89 n_tracks++;
90 const xAOD::TrackParticle* trackParticle = *mytrack;
91 const Trk::Track* track = trackParticle->track();
92 if(!track)
93 return StatusCode::FAILURE;
94
95 std::vector<const InDet::PixelCluster*> pixelClusters;
96
97 const DataVector<const Trk::MeasurementBase>* measurements = track->measurementsOnTrack();
98 for ( auto measurement : *measurements )
99 {
100 // find out if it is a pixel hit
101 const InDet::PixelClusterOnTrack* pixelClusterOnTrack = dynamic_cast<const InDet::PixelClusterOnTrack*>(measurement);
102 if( pixelClusterOnTrack )
103 {
104 //Go back to the original pixel cluster
105 const InDet::PixelCluster* pixelCluster = dynamic_cast<const InDet::PixelCluster*>( pixelClusterOnTrack->prepRawData() );
106
107 if( pixelCluster )
108 {
109 // This is the pixel cluster that you would like to check if it contained in the other track.
110 // to avoid doing this loop multiple time then would store these is a vector
111 pixelClusters.push_back(pixelCluster);
112 }
113 } // End: PixelCluster
114 } // End: Measurements
115
116 int n_corr=0;
117 for (unsigned int i = 0; i < pixelClusters.size(); i++)
118 {
119 if ( std::find(tracklet_pixelClusters.begin(),tracklet_pixelClusters.end(),pixelClusters[i]) != tracklet_pixelClusters.end() )
120 n_corr++;
121 }
122 if (n_corr>0)
123 {
124 nSharedHits=n_corr;
125 ElementLink< xAOD:: TrackParticleContainer > eLink( *trks, trackParticle->index());
126 eLink.toPersistent();
127 MatchedTrackLinkDec(*trackletParticle) = eLink;
128
129 break; //??? how many n_corr?
130
131 }
132 } // End: Loop over tracks for each tracklet
133
134 MatchedTrackSharedHitsDec(*trackletParticle) = nSharedHits;
135
136
137
138 } // End: Loop over tracklets
139
140 if (n_tracks==0 || n_tracklets==0) ATH_MSG_INFO("=========>>>>>>>>n_tracklets=" << n_tracklets << " =========>>>>>>>>n_tracks="<< n_tracks);
141
142
143 ATH_MSG_DEBUG ("Your new package and algorithm are successfully executing");
144
145 return StatusCode::SUCCESS;
146}
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
149
150 ATH_MSG_INFO ("finalize()");
151
152 return StatusCode::SUCCESS;
153}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Helper class to provide type-safe access to aux data.
An algorithm that can be simultaneously executed in multiple threads.
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
Specific class to represent the pixel measurements.
virtual const PixelCluster * prepRawData() const override final
returns the PrepRawData - is a SiCluster in this scope
virtual StatusCode execute(const EventContext &ctx) const override
SCTExtensionAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_tracks
virtual StatusCode finalize() override
virtual StatusCode initialize() override
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_pixelTracklets
size_t index() const
Return the index of this element within its container.
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const DataVector< const MeasurementBase > * measurementsOnTrack() const
return a pointer to a vector of MeasurementBase (NOT including any that come from outliers).
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
TrackParticle_v1 TrackParticle
Reference the current persistent version: