< get the charge via the particle table ...
97{
98 const EventContext& ctx = Gaudi::Hive::currentContext();
99 if( segs != nullptr ){
100 ATH_MSG_WARNING(
"Requested to fill segment collection but mode not implemented");
101 }
102 ATH_MSG_VERBOSE(
"The PRD Truth trajectory contains " << prdTraj.prds.size() <<
" PRDs.");
103
104
105 auto genPart = prdTraj.genParticle;
106 if (!genPart) {
107 ATH_MSG_WARNING(
"No GenParticle associated to this PRD_TruthTrajectory. Ignoring track creation.");
108 return nullptr;
109 }
110 ATH_MSG_VERBOSE(
"Got PRD Truth trajectory with " << prdTraj.nDoF <<
" degrees of freedom.");
111
113
116 genPart->production_vertex()->position().y(),
117 genPart->production_vertex()->position().z()) : Amg::
Vector3D(0.,0.,0.);
119 genPart->momentum().y(),
120 genPart->momentum().z());
122
123 int pdgCode = genPart->pdg_id();
124
128
129 charge *= (pdgCode > 0.) ? 1. : -1.;
130
131
132 const std::vector<const Trk::PrepRawData*> &
clusters = prdTraj.prds;
133
134 Trk::PerigeeSurface persurf;
136
137 auto per = std::unique_ptr<Trk::TrackParameters>(
139 startParams,
140 persurf,
142 false,
144 if (!per) {
145 ATH_MSG_DEBUG(
"Perigee creation for genParticle start position failed. "
146 "Skipping track creation.");
147 return nullptr;
148 }
149
150 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
152
153 const Trk::TrackStateOnSurface *pertsos=new Trk::TrackStateOnSurface(nullptr,std::move(per),nullptr,typePattern);
154 auto traj = std::make_unique<Trk::TrackStates>();
155 traj->push_back(pertsos);
156
157
158
159 std::unique_ptr<const Trk::TrackParameters> prevpar(startParams.uniqueClone());
160
163 if (
m_DetID->is_trt(clusters[i]->identify()))
break;
164 const Trk::Surface &surf=
clusters[
i]->detectorElement()->surface(clusters[i]->
identify());
165 if (surf==prevpar->associatedSurface()) continue;
166 bool ispixel=false;
167 if (
m_DetID->is_pixel(clusters[i]->identify())) ispixel=
true;
168
169 auto thispar = std::unique_ptr<const Trk::TrackParameters>(
171 *prevpar,
172 surf,
174 false,
176 if (!thispar)
177 break;
178 if (!surf.
insideBounds(thispar->localPosition(),20*Gaudi::Units::mm,50*Gaudi::Units::mm)) {
179 continue;
180 }
181 AmgVector(5) params=thispar->parameters();
182 params[Trk::
loc1]=clusters[i]->localPosition().
x();
183 if (ispixel) params[Trk::
loc2]=clusters[i]->localPosition().
y();
184 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
185 typePattern.set(Trk::TrackStateOnSurface::
Measurement);
186 std::unique_ptr<Trk::RIO_OnTrack> rot{
m_rotcreator->correct(*clusters[i],*thispar,ctx)};
187 if (!rot) {
188 continue;
189 }
190
191 const Trk::TrackStateOnSurface *tsos=new Trk::TrackStateOnSurface(std::move(rot),thispar->uniqueClone(),nullptr,typePattern);
192 traj->push_back(tsos);
193 prevpar=std::move(thispar);
194 }
195
197 Trk::Track
track(info, std::move(traj),
nullptr);
204 "Track does not fulfill requirements for refitting. Skipping it.");
205 return nullptr;
206 }
207
209
210
211
212
213
215
216 Trk::Track *refittedtrack=(
m_trackFitter->fit(Gaudi::Hive::currentContext(),track,
false,materialInteractions)).release();
217
219 Trk::Track *refittedtrack2=nullptr;
220 if (refittedtrack && (
int)
clusters.size()-i>=9){
221
222
223 std::vector<std::unique_ptr<MeasurementBase>> meassetOwn;
224
226
227 std::unique_ptr<const Trk::TrackParameters> prevpar(refittedtrack->
trackParameters()->back()->uniqueClone());
229 const Trk::Surface *surf=&
clusters[
i]->detectorElement()->surface(clusters[i]->
identify());
231 if (!thispar) break;
233
234 if (rot) {
235 meassetOwn.emplace_back(rot);
236 measset.push_back(meassetOwn.back().get());
237 }
238 prevpar=std::move(thispar);
239 }
240
241 refittedtrack2=(
m_trackFitter->fit(Gaudi::Hive::currentContext(),*refittedtrack,measset,
false,materialInteractions)).release();
242
243 if (!refittedtrack2){
244 auto traj2 = std::make_unique<Trk::TrackStates>();
245 for (
const Trk::TrackStateOnSurface *j : *refittedtrack->
trackStateOnSurfaces()) traj2->push_back(
new Trk::TrackStateOnSurface(*j));
246 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern2;
248
249 for (auto & j : meassetOwn) {
250 traj2->push_back(new Trk::TrackStateOnSurface(
251 std::move(j),
252 nullptr,
253 nullptr,
254 typePattern2));
255 }
256 refittedtrack2 =
new Trk::Track(refittedtrack->
info(),
257 std::move(traj2),
259 }
260 } else if(!refittedtrack){
261 ATH_MSG_VERBOSE(
"Track fit of truth trajectory NOT successful, NO track created. ");
262 return nullptr;
263 }
264
265 if (refittedtrack2) delete refittedtrack;
266 if (!refittedtrack2 && refittedtrack) refittedtrack2=refittedtrack;
267
268
269 ATH_MSG_DEBUG(
"Track fit of truth trajectory successful, track created. ");
270
271
272 if (refittedtrack2){
274 }
275 return refittedtrack2;
276}
#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...
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.