18#include "GaudiKernel/IPartPropSvc.h"
19#include "GaudiKernel/SystemOfUnits.h"
24#include "HepPDT/ParticleDataTable.hh"
35 declareInterface<Trk::ITruthTrackBuilder>(
this);
45 return StatusCode::FAILURE;
50 return StatusCode::FAILURE;
56 return StatusCode::FAILURE;
62 return StatusCode::FAILURE;
69 return StatusCode::FAILURE;
76 ATH_MSG_ERROR(
"Could not get ParticleDataTable! Cannot associate pdg code with charge. Aborting. " );
77 return StatusCode::FAILURE;
83 return StatusCode::FAILURE;
85 return StatusCode::SUCCESS;
92 return StatusCode::SUCCESS;
98 const EventContext& ctx = Gaudi::Hive::currentContext();
99 if( segs !=
nullptr ){
100 ATH_MSG_WARNING(
"Requested to fill segment collection but mode not implemented");
107 ATH_MSG_WARNING(
"No GenParticle associated to this PRD_TruthTrajectory. Ignoring track creation.");
110 ATH_MSG_VERBOSE(
"Got PRD Truth trajectory with " << prdTraj.
nDoF <<
" degrees of freedom.");
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());
123 int pdgCode = genPart->pdg_id();
127 if (ap)
charge = ap->charge();
129 charge *= (pdgCode > 0.) ? 1. : -1.;
132 const std::vector<const Trk::PrepRawData*> & clusters = prdTraj.
prds;
137 auto per = std::unique_ptr<Trk::TrackParameters>(
145 ATH_MSG_DEBUG(
"Perigee creation for genParticle start position failed. "
146 "Skipping track creation.");
150 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
154 auto traj = std::make_unique<Trk::TrackStates>();
155 traj->push_back(pertsos);
159 std::unique_ptr<const Trk::TrackParameters> prevpar(startParams.
uniqueClone());
162 for ( ;i<(int)clusters.size();i++){
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;
167 if (
m_DetID->is_pixel(clusters[i]->identify())) ispixel=
true;
169 auto thispar = std::unique_ptr<const Trk::TrackParameters>(
178 if (!surf.
insideBounds(thispar->localPosition(),20*Gaudi::Units::mm,50*Gaudi::Units::mm)) {
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;
186 std::unique_ptr<Trk::RIO_OnTrack> rot{
m_rotcreator->correct(*clusters[i],*thispar,ctx)};
192 traj->push_back(tsos);
193 prevpar=std::move(thispar);
197 Trk::Track track(info, std::move(traj),
nullptr);
198 if ( (track.measurementsOnTrack()->size() <
m_minSiHits &&
204 "Track does not fulfill requirements for refitting. Skipping it.");
216 Trk::Track *refittedtrack=(
m_trackFitter->fit(Gaudi::Hive::currentContext(),track,
false,materialInteractions)).release();
220 if (refittedtrack && (
int)clusters.size()-i>=9){
223 std::vector<std::unique_ptr<MeasurementBase>> meassetOwn;
227 std::unique_ptr<const Trk::TrackParameters> prevpar(refittedtrack->
trackParameters()->back()->uniqueClone());
228 for (;i<(int)clusters.size();i++) {
229 const Trk::Surface *surf=&clusters[i]->detectorElement()->surface(clusters[i]->identify());
235 meassetOwn.emplace_back(rot);
236 measset.push_back(meassetOwn.back().get());
238 prevpar=std::move(thispar);
241 refittedtrack2=(
m_trackFitter->fit(Gaudi::Hive::currentContext(),*refittedtrack,measset,
false,materialInteractions)).release();
243 if (!refittedtrack2){
244 auto traj2 = std::make_unique<Trk::TrackStates>();
246 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern2;
249 for (
auto & j : meassetOwn) {
260 }
else if(!refittedtrack){
261 ATH_MSG_VERBOSE(
"Track fit of truth trajectory NOT successful, NO track created. ");
265 if (refittedtrack2)
delete refittedtrack;
266 if (!refittedtrack2 && refittedtrack) refittedtrack2=refittedtrack;
269 ATH_MSG_DEBUG(
"Track fit of truth trajectory successful, track created. ");
275 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)
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
ServiceHandle< IPartPropSvc > m_particlePropSvc
Pointer to the particle properties svc */.
Gaudi::Property< size_t > m_minNdof
checks min degrees of freedom if bigger -1
Gaudi::Property< bool > m_onlyPrimaries
restrict track creation to primaries
const HepPDT::ParticleDataTable * m_particleDataTable
ParticleDataTable needed to get connection pdg_code <-> charge */.
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
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