18#include "GaudiKernel/SystemOfUnits.h"
32 declareInterface<Trk::ITruthTrackBuilder>(
this);
42 return StatusCode::FAILURE;
47 return StatusCode::FAILURE;
53 return StatusCode::FAILURE;
59 return StatusCode::FAILURE;
65 return StatusCode::FAILURE;
67 return StatusCode::SUCCESS;
74 return StatusCode::SUCCESS;
80 const EventContext& ctx = Gaudi::Hive::currentContext();
81 if( segs !=
nullptr ){
82 ATH_MSG_WARNING(
"Requested to fill segment collection but mode not implemented");
89 ATH_MSG_WARNING(
"No GenParticle associated to this PRD_TruthTrajectory. Ignoring track creation.");
92 ATH_MSG_VERBOSE(
"Got PRD Truth trajectory with " << prdTraj.
nDoF <<
" degrees of freedom.");
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());
105 const int pdgCode = genPart->pdg_id();
109 const std::vector<const Trk::PrepRawData*> & clusters = prdTraj.
prds;
114 auto per = std::unique_ptr<Trk::TrackParameters>(
122 ATH_MSG_DEBUG(
"Perigee creation for genParticle start position failed. "
123 "Skipping track creation.");
127 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
131 auto traj = std::make_unique<Trk::TrackStates>();
132 traj->push_back(pertsos);
136 std::unique_ptr<const Trk::TrackParameters> prevpar(startParams.
uniqueClone());
139 for ( ;i<(int)clusters.size();i++){
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;
144 if (
m_DetID->is_pixel(clusters[i]->identify())) ispixel=
true;
146 auto thispar = std::unique_ptr<const Trk::TrackParameters>(
155 if (!surf.
insideBounds(thispar->localPosition(),20*Gaudi::Units::mm,50*Gaudi::Units::mm)) {
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;
163 std::unique_ptr<Trk::RIO_OnTrack> rot{
m_rotcreator->correct(*clusters[i],*thispar,ctx)};
169 traj->push_back(tsos);
170 prevpar=std::move(thispar);
174 Trk::Track track(info, std::move(traj),
nullptr);
175 if ( (track.measurementsOnTrack()->size() <
m_minSiHits &&
181 "Track does not fulfill requirements for refitting. Skipping it.");
193 Trk::Track *refittedtrack=(
m_trackFitter->fit(Gaudi::Hive::currentContext(),track,
false,materialInteractions)).release();
197 if (refittedtrack && (
int)clusters.size()-i>=9){
200 std::vector<std::unique_ptr<MeasurementBase>> meassetOwn;
204 std::unique_ptr<const Trk::TrackParameters> prevpar(refittedtrack->
trackParameters()->back()->uniqueClone());
205 for (;i<(int)clusters.size();i++) {
206 const Trk::Surface *surf=&clusters[i]->detectorElement()->surface(clusters[i]->identify());
212 meassetOwn.emplace_back(rot);
213 measset.push_back(meassetOwn.back().get());
215 prevpar=std::move(thispar);
218 refittedtrack2=(
m_trackFitter->fit(Gaudi::Hive::currentContext(),*refittedtrack,measset,
false,materialInteractions)).release();
220 if (!refittedtrack2){
221 auto traj2 = std::make_unique<Trk::TrackStates>();
223 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern2;
226 for (
auto & j : meassetOwn) {
237 }
else if(!refittedtrack){
238 ATH_MSG_VERBOSE(
"Track fit of truth trajectory NOT successful, NO track created. ");
242 if (refittedtrack2)
delete refittedtrack;
243 if (!refittedtrack2 && refittedtrack) refittedtrack2=refittedtrack;
246 ATH_MSG_DEBUG(
"Track fit of truth trajectory successful, track created. ");
252 return refittedtrack2;
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
double charge(const T &p)
ATLAS-specific HepMC functions.
const ServiceHandle< StoreGateSvc > & detStore() const
std::unique_ptr< FitQuality > uniqueClone() const
NVI uniqueClone.
std::unique_ptr< ParametersBase< DIM, T > > uniqueClone() const
clone method for polymorphic deep copy returning unique_ptr; it is not overriden, but uses the existi...
Class describing the Line to which the Perigee refers to.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Abstract Base Class for tracking surfaces.
virtual bool insideBounds(const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const =0
virtual methods to be overwritten by the inherited surfaces
Contains information about the 'fitter' of this track.
void setPatternRecognitionInfo(const TrackPatternRecoInfo &patternReco)
Method setting the pattern recognition algorithm.
@ Pseudotracking
Pseudo-tracking flag.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ 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)
const AtlasDetectorID * m_DetID
TruthTrackBuilder(const std::string &t, const std::string &n, const IInterface *p)
Constructor.
Track * createTrack(const PRD_TruthTrajectory &prdTraj, SegmentCollection *segs=0) const
return a map of GenParticles to PRDs for further processing
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
DataVector< Trk::Segment > SegmentCollection
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
@ loc2
generic first and second local coordinate
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
simple definitiion of a PRD_TruhtTrajectory
std::vector< const Trk::PrepRawData * > prds
public members
HepMC::ConstGenParticlePtr genParticle