< get the charge via the particle table ...
79{
80 const EventContext& ctx = Gaudi::Hive::currentContext();
81 if( segs != nullptr ){
82 ATH_MSG_WARNING(
"Requested to fill segment collection but mode not implemented");
83 }
84 ATH_MSG_VERBOSE(
"The PRD Truth trajectory contains " << prdTraj.prds.size() <<
" PRDs.");
85
86
87 auto genPart = prdTraj.genParticle;
88 if (!genPart) {
89 ATH_MSG_WARNING(
"No GenParticle associated to this PRD_TruthTrajectory. Ignoring track creation.");
90 return nullptr;
91 }
92 ATH_MSG_VERBOSE(
"Got PRD Truth trajectory with " << prdTraj.nDoF <<
" degrees of freedom.");
93
95
98 genPart->production_vertex()->position().y(),
99 genPart->production_vertex()->position().z()) : Amg::
Vector3D(0.,0.,0.);
101 genPart->momentum().y(),
102 genPart->momentum().z());
104
105 const int pdgCode = genPart->pdg_id();
107
108
109 const std::vector<const Trk::PrepRawData*> &
clusters = prdTraj.prds;
110
111 Trk::PerigeeSurface persurf;
113
114 auto per = std::unique_ptr<Trk::TrackParameters>(
116 startParams,
117 persurf,
119 false,
121 if (!per) {
122 ATH_MSG_DEBUG(
"Perigee creation for genParticle start position failed. "
123 "Skipping track creation.");
124 return nullptr;
125 }
126
127 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
129
130 const Trk::TrackStateOnSurface *pertsos=new Trk::TrackStateOnSurface(nullptr,std::move(per),nullptr,typePattern);
131 auto traj = std::make_unique<Trk::TrackStates>();
132 traj->push_back(pertsos);
133
134
135
136 std::unique_ptr<const Trk::TrackParameters> prevpar(startParams.uniqueClone());
137
140 if (
m_DetID->is_trt(clusters[i]->identify()))
break;
141 const Trk::Surface &surf=
clusters[
i]->detectorElement()->surface(clusters[i]->
identify());
142 if (surf==prevpar->associatedSurface()) continue;
143 bool ispixel=false;
144 if (
m_DetID->is_pixel(clusters[i]->identify())) ispixel=
true;
145
146 auto thispar = std::unique_ptr<const Trk::TrackParameters>(
148 *prevpar,
149 surf,
151 false,
153 if (!thispar)
154 break;
155 if (!surf.
insideBounds(thispar->localPosition(),20*Gaudi::Units::mm,50*Gaudi::Units::mm)) {
156 continue;
157 }
158 AmgVector(5) params=thispar->parameters();
159 params[Trk::
loc1]=clusters[i]->localPosition().
x();
160 if (ispixel) params[Trk::
loc2]=clusters[i]->localPosition().
y();
161 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
162 typePattern.set(Trk::TrackStateOnSurface::
Measurement);
163 std::unique_ptr<Trk::RIO_OnTrack> rot{
m_rotcreator->correct(*clusters[i],*thispar,ctx)};
164 if (!rot) {
165 continue;
166 }
167
168 const Trk::TrackStateOnSurface *tsos=new Trk::TrackStateOnSurface(std::move(rot),thispar->uniqueClone(),nullptr,typePattern);
169 traj->push_back(tsos);
170 prevpar=std::move(thispar);
171 }
172
174 Trk::Track
track(info, std::move(traj),
nullptr);
181 "Track does not fulfill requirements for refitting. Skipping it.");
182 return nullptr;
183 }
184
186
187
188
189
190
192
193 Trk::Track *refittedtrack=(
m_trackFitter->fit(Gaudi::Hive::currentContext(),track,
false,materialInteractions)).release();
194
196 Trk::Track *refittedtrack2=nullptr;
197 if (refittedtrack && (
int)
clusters.size()-i>=9){
198
199
200 std::vector<std::unique_ptr<MeasurementBase>> meassetOwn;
201
203
204 std::unique_ptr<const Trk::TrackParameters> prevpar(refittedtrack->
trackParameters()->back()->uniqueClone());
206 const Trk::Surface *surf=&
clusters[
i]->detectorElement()->surface(clusters[i]->
identify());
208 if (!thispar) break;
210
211 if (rot) {
212 meassetOwn.emplace_back(rot);
213 measset.push_back(meassetOwn.back().get());
214 }
215 prevpar=std::move(thispar);
216 }
217
218 refittedtrack2=(
m_trackFitter->fit(Gaudi::Hive::currentContext(),*refittedtrack,measset,
false,materialInteractions)).release();
219
220 if (!refittedtrack2){
221 auto traj2 = std::make_unique<Trk::TrackStates>();
222 for (
const Trk::TrackStateOnSurface *j : *refittedtrack->
trackStateOnSurfaces()) traj2->push_back(
new Trk::TrackStateOnSurface(*j));
223 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern2;
225
226 for (auto & j : meassetOwn) {
227 traj2->push_back(new Trk::TrackStateOnSurface(
228 std::move(j),
229 nullptr,
230 nullptr,
231 typePattern2));
232 }
233 refittedtrack2 =
new Trk::Track(refittedtrack->
info(),
234 std::move(traj2),
236 }
237 } else if(!refittedtrack){
238 ATH_MSG_VERBOSE(
"Track fit of truth trajectory NOT successful, NO track created. ");
239 return nullptr;
240 }
241
242 if (refittedtrack2) delete refittedtrack;
243 if (!refittedtrack2 && refittedtrack) refittedtrack2=refittedtrack;
244
245
246 ATH_MSG_DEBUG(
"Track fit of truth trajectory successful, track created. ");
247
248
249 if (refittedtrack2){
251 }
252 return refittedtrack2;
253}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double charge(const T &p)
std::unique_ptr< FitQuality > uniqueClone() const
NVI uniqueClone.
virtual bool insideBounds(const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const =0
virtual methods to be overwritten by the inherited surfaces
void setPatternRecognitionInfo(const TrackPatternRecoInfo &patternReco)
Method setting the pattern recognition algorithm.
@ Pseudotracking
Pseudo-tracking flag.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
const DataVector< const TrackParameters > * trackParameters() const
Return a pointer to a vector of TrackParameters.
const TrackInfo & info() const
Returns a const ref to info of a const tracks.
const FitQuality * fitQuality() const
return a pointer to the fit quality const-overload
ToolHandle< IRIO_OnTrackCreator > m_rotcreator
Gaudi::Property< unsigned int > m_minSiHits
min number of Si hits for refit
Gaudi::Property< float > m_forwardBoundary
Boundary eta value defining the forward region.
Gaudi::Property< unsigned int > m_minSiHitsForward
min number of Si hits for refit in forward region (ITk specific)
Gaudi::Property< size_t > m_minNdof
checks min degrees of freedom if bigger -1
Gaudi::Property< bool > m_onlyPrimaries
restrict track creation to primaries
ToolHandle< ITrackFitter > m_trackFitter
fits the PRDs
Gaudi::Property< int > m_matEffects
ToolHandle< IRIO_OnTrackCreator > m_rotcreatorbroad
ToolHandle< IExtrapolator > m_extrapolator
extrapolator
Eigen::Matrix< double, 3, 1 > Vector3D
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
double charge(const T &p)
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
std::vector< const MeasurementBase * > MeasurementSet
vector of fittable measurements
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
@ loc2
generic first and second local coordinate
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.