|
ATLAS Offline Software
|
Go to the documentation of this file.
10 #include "Acts/Definitions/Units.hpp"
11 #include "Acts/Propagator/detail/JacobianEngine.hpp"
19 #include "GaudiKernel/PhysicalConstants.h"
36 template <
typename T,
class T_SquareMatrix>
37 inline void lowerTriangleToVector(
const T_SquareMatrix&
covMatrix,
38 std::vector<T>&
vec,
unsigned int n_rows_max) {
41 unsigned int n_rows =
std::min(n_rows_max,
static_cast<unsigned int>(
covMatrix.rows()));
42 vec.reserve((n_rows+1)*n_rows/2);
43 for (
unsigned int i = 0;
i < n_rows; ++
i) {
44 for (
unsigned int j = 0; j <=
i; ++j) {
59 template <
typename T,
class T_SquareMatrix>
60 inline void lowerTriangleToVectorScaleLastRow(
const T_SquareMatrix&
covMatrix,
61 std::vector<T>&
vec,
unsigned int n_rows_max,
62 typename T_SquareMatrix::Scalar last_element_scale) {
65 unsigned int n_rows =
std::min(n_rows_max,
static_cast<unsigned int>(
covMatrix.rows()));
66 vec.reserve((n_rows+1)*n_rows/2);
67 for (
unsigned int i = 0;
i < n_rows; ++
i) {
68 for (
unsigned int j = 0; j <=
i; ++j) {
74 *cov_iter *= last_element_scale;
75 for (
unsigned int i=0;
i<n_rows_max; ++
i) {
76 *cov_iter *= last_element_scale;
96 for (
unsigned short &elm : ret) {
107 std::vector<std::pair<Acts::PdgParticle, xAOD::ParticleHypothesis> > TrackToTrackParticleCnvAlg::s_actsHypothesisToxAOD;
110 if (s_actsHypothesisToxAOD.empty()) {
111 s_actsHypothesisToxAOD.reserve(7);
112 s_actsHypothesisToxAOD.push_back( std::make_pair( Acts::eElectron ,
xAOD::electron) );
113 s_actsHypothesisToxAOD.push_back( std::make_pair( Acts::eMuon ,
xAOD::muon) );
114 s_actsHypothesisToxAOD.push_back( std::make_pair( Acts::ePionPlus ,
xAOD::pion) );
115 s_actsHypothesisToxAOD.push_back( std::make_pair( Acts::eProton ,
xAOD::proton) );
116 s_actsHypothesisToxAOD.push_back( std::make_pair( Acts::ePionZero ,
xAOD::pi0) );
117 s_actsHypothesisToxAOD.push_back( std::make_pair( Acts::eNeutron ,
xAOD::neutron) );
118 s_actsHypothesisToxAOD.push_back( std::make_pair( Acts::eGamma ,
xAOD::photon) );
124 ISvcLocator *pSvcLocator)
143 cfg.resolvePassive =
false;
144 cfg.resolveMaterial =
true;
145 cfg.resolveSensitive =
true;
146 auto navigtor_logger =
logger->cloneWithSuffix(
"Navigator");
147 m_propagator = std::make_unique<Propagator>(
Stepper(std::make_shared<ATLASMagneticFieldWrapper>()),
155 unsigned int collection_idx=0;
157 if (type <1 || type >2) {
158 ATH_MSG_ERROR(
"Invalid measurement type (" <<
type <<
") given for collection " << collection_idx <<
" : "
160 <<
". Expected 1 for pixel, 2 for strips.");
161 return StatusCode::FAILURE;
167 ATH_MSG_ERROR(
"Expected exactly one value in SiDetEleCollToMeasurementType per SiDetectorElementCollection. But got "
169 return StatusCode::FAILURE;
174 return StatusCode::SUCCESS;
180 if (wh_track_particles.
record(std::make_unique<xAOD::TrackParticleContainer>(),
181 std::make_unique<xAOD::TrackParticleAuxContainer>()).isFailure()) {
183 return StatusCode::FAILURE;
192 std::size_t nTracks = 0
ul;
193 std::vector<const ActsTrk::TrackContainer *> trackContainers;
197 trackContainers.push_back( handle.
cptr() );
198 nTracks += trackContainers.back()->size();
208 std::shared_ptr<Acts::PerigeeSurface> perigee_surface =
makePerigeeSurface(beamspot_data);
209 track_particles->
reserve( nTracks );
224 std::vector<float> tmp_cov_vector;
225 std::vector<ActsTrk::TrackStateBackend::ConstTrackStateProxy::IndexType > tmp_param_state_idx;
226 tmp_param_state_idx.reserve(30);
228 std::vector<std::vector<float>> parametersVec;
231 unsigned int converted_track_states=0;
235 using namespace Acts::UnitLiterals;
237 for (
const typename ActsTrk::TrackContainer::ConstTrackProxy
track : *tracksContainer) {
245 perigeeParam.parameters()[Acts::eBoundLoc1],
246 perigeeParam.parameters()[Acts::eBoundPhi],
247 perigeeParam.parameters()[Acts::eBoundTheta],
248 perigeeParam.parameters()[Acts::eBoundQOverP] * 1_MeV);
249 if (perigeeParam.covariance().has_value()) {
251 lowerTriangleToVectorScaleLastRow(perigeeParam.covariance().value(),tmp_cov_vector,5, 1_MeV);
267 constexpr
float inv_1_MeV = 1/1_MeV;
279 measurementToSummaryType,
293 std::array< std::tuple< uint8_t, uint8_t, uint8_t, bool >, 4> copy_summary {
314 for (
auto [src_region, dest_xaod_summary_layer, dest_xaod_summary_hits, add_outlier] : copy_summary ) {
315 setSummaryValue(*track_particle,
318 setSummaryValue(*track_particle,
325 setSummaryValue(*track_particle,
329 setSummaryValue(*track_particle,
332 setSummaryValue(*track_particle,
338 setSummaryValue(*track_particle,
342 setSummaryValue(*track_particle,
345 setSummaryValue(*track_particle,
355 : std::array<unsigned int,4> {0
u,0
u, 0
u,0
u} );
358 setSummaryValue(*track_particle,
359 static_cast<uint8_t>((expect_layer_pattern[0] & (1<<0)) != 0 ),
361 setSummaryValue(*track_particle,
362 static_cast<uint8_t>((expect_layer_pattern[0] & (1<<1)) != 0 ),
364 setSummaryValue(*track_particle,
367 setSummaryValue(*track_particle,
370 setSummaryValue(*track_particle,
373 setSummaryValue(*track_particle,
378 setSummaryValue(*track_particle,
381 setSummaryValue(*track_particle,
384 setSummaryValue(*track_particle,
389 setSummaryValue(*track_particle,
390 static_cast<uint8_t> (biased_chi2_variance>0.
391 ?
std::min(
static_cast<unsigned int>(std::sqrt(biased_chi2_variance) * 100),255
u)
395 setSummaryValue(*track_particle,
403 tmp_param_state_idx[1]=tmp_param_state_idx.back();
404 tmp_param_state_idx.erase(tmp_param_state_idx.begin()+2,tmp_param_state_idx.end());
408 parametersVec.clear();
409 parametersVec.reserve(tmp_param_state_idx.size());
411 for(std::vector<ActsTrk::TrackStateBackend::ConstTrackStateProxy::IndexType>::const_reverse_iterator
412 idx_iter = tmp_param_state_idx.rbegin();
413 idx_iter != tmp_param_state_idx.rend();
416 ActsTrk::TrackStateBackend::ConstTrackStateProxy
417 state = tracksContainer->trackStateContainer().getTrackState(*idx_iter);
418 const Acts::BoundTrackParameters actsParam =
track.createParametersFromState(state);
420 Acts::Vector3 position = actsParam.position(gctx.
context());
421 Acts::Vector3
momentum = actsParam.momentum();
429 if (actsParam.covariance()) {
431 Acts::GeometryContext tgContext = gctx.
context();
433 magnFieldVect.setZero();
434 fieldCache.
getField(position.data(), magnFieldVect.data());
437 using namespace Acts::UnitLiterals;
438 magnFieldVect *= 1000_T;
442 if (curvilinear_cov_result.has_value()) {
443 Acts::BoundSquareMatrix &curvilinear_cov = curvilinear_cov_result.value();
446 for (
unsigned int col_i=0; col_i<4; ++col_i) {
447 curvilinear_cov(col_i,4) *= 1_MeV;
448 curvilinear_cov(4,col_i) *= 1_MeV;
450 curvilinear_cov(4,4) *= (1_MeV * 1_MeV);
452 std::size_t param_idx = parametersVec.size();
454 lowerTriangleToVector(curvilinear_cov,tmp_cov_vector,5);
455 if (tmp_cov_vector.size() != 15) {
456 ATH_MSG_ERROR(
"Invalid size of lower triangle cov " << tmp_cov_vector.size() <<
" != 15"
457 <<
" input matrix : " << curvilinear_cov.rows() <<
" x " << curvilinear_cov.cols() );
462 parametersVec.emplace_back(std::vector<float>{
463 static_cast<float>(position[0]),
static_cast<float>(position[1]),
static_cast<float>(position[2]),
465 ++converted_track_states;
469 for (
const std::vector<float> ¶m : parametersVec) {
470 if (param.size() != 6) {
471 ATH_MSG_ERROR(
"Invalid size of param element " << param.size() <<
" != 6" );
478 trackLink(*track_particle)
484 ATH_MSG_DEBUG(
"Converted " << nTracks <<
" acts tracks into " << track_particles->
size()
485 <<
" track particles with parameters for " << converted_track_states <<
" track states.");
487 return StatusCode::SUCCESS;
492 Acts::Vector3 beamspot(0., 0., 0.);
500 Acts::Translation3 translation(beamspot);
501 Acts::Transform3
transform( translation * Acts::RotationMatrix3::Identity() );
502 transform *= Acts::AngleAxis3(tilty, Acts::Vector3(0.,1.,0.));
503 transform *= Acts::AngleAxis3(tiltx, Acts::Vector3(1.,0.,0.));
504 return Acts::Surface::makeShared<Acts::PerigeeSurface>(
transform);
508 const typename ActsTrk::TrackContainer::ConstTrackProxy &
track,
509 const Acts::PerigeeSurface &perigee_surface)
const {
510 const Acts::BoundTrackParameters trackParam =
track.createParametersAtReference();
512 std::optional<const Acts::BoundTrackParameters>
516 Acts::Direction::Backward,
518 if (!perigeeParam.has_value()) {
519 ATH_MSG_WARNING(
"Failed to extrapolate to perigee, started from \n" << trackParam <<
" " << trackParam.referenceSurface().name() );
525 return perigeeParam.value();
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
JetConstituentVector::iterator iterator
@ neutron
for Fatras usage
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
void setTrackFitter(const TrackFitter fitter)
Method for setting the fitter, using the TrackFitter enum.
static std::shared_ptr< Acts::PerigeeSurface > makePerigeeSurface(const InDet::BeamSpotData *beamspotptr)
std::optional< Acts::BoundMatrix > convertActsBoundCovToCurvilinearParam(const Acts::GeometryContext &tgContext, const Acts::BoundTrackParameters ¶m, const Acts::Vector3 &magnFieldVect, const Acts::ParticleHypothesis &particle_hypothesis)
Convert the covariance of the given Acts track parameters into curvilinear parameterisation.
Gaudi::Property< bool > m_expectIfPixelContributes
Helper class to gather statistics and compute the biased variance.
void gatherTrackSummaryData(const ActsTrk::TrackContainer &tracksContainer, const typename ActsTrk::TrackContainer::ConstTrackProxy &track, const std::array< const InDetDD::SiDetectorElementCollection *, to_underlying(xAOD::UncalibMeasType::nTypes)> &siDetEleColl, const std::array< unsigned short, to_underlying(xAOD::UncalibMeasType::nTypes)> &measurement_to_summary_type, SumOfValues &chi2_stat_out, HitSummaryData &hit_info_out, std::vector< ActsTrk::TrackStateBackend::ConstTrackStateProxy::IndexType > ¶m_state_idx_out, std::array< std::array< uint8_t, to_underlying(HitCategory::N)>, to_underlying(xAOD::UncalibMeasType::nTypes)> &special_hit_counts_out)
Helper to gather track summary information from the track states of the specified track.
virtual StatusCode initialize() override
uint8_t contributingHits(DetectorRegion region) const
return the number of hits in a certain detector region.
const_pointer_type cptr()
Dereference the pointer.
void setTrackParameters(std::vector< std::vector< float > > ¶meters)
Set the parameters via the passed vector of vectors.
virtual StatusCode execute(const EventContext &ctx) const override
constexpr std::underlying_type< T_EnumClass >::type to_underlying(T_EnumClass an_enum)
Helper to convert class enum into an integer.
@ numberOfContribPixelBarrelInclinedLayers
number of contributing barrel inclined layers of the pixel detector [unit8_t].
Gaudi::Property< bool > m_firstAndLastParamOnly
@ numberOfContribPixelBarrelFlatLayers
number of contributing barrel flat layers of the pixel detector [unit8_t].
std::array< unsigned int, 4 > expectedLayerPattern(const EventContext &ctx, const IActsExtrapolationTool &extrapolator, Acts::BoundTrackParameters perigee_parameters, double pathLimit)
Extrapolate from the perigee outwards and gather information which detector layers should have hits.
void setDefiningParameters(float d0, float z0, float phi0, float theta, float qOverP)
Set the defining parameters.
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
std::vector< size_t > vec
const Trk::RecVertex & beamVtx() const noexcept
void setTrackParameterCovarianceMatrix(unsigned int index, std::vector< float > &cov)
Set the cov matrix of the parameter at 'index', using a vector of floats.
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
const std::string & key() const
Return the StoreGate ID for the referenced object.
@ u
Enums for curvilinear frames.
@ numberOfInnermostPixelLayerEndcapOutliers
number of 0th layer endcap outliers
void setBeamlineTiltY(float tiltY)
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Acts::GeometryContext context() const
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
@ numberOfContribPixelEndcap
number of contributing endcap layers of the pixel detector [unit8_t].
@ numberOfInnermostPixelLayerOutliers
number of 0th layer barrel outliers
@ numberOfInnermostPixelLayerEndcapHits
these are the hits in the 0th pixel layer endcap [unit8_t].
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
Helper class to gather hit summary information for e.g.
uint8_t contributingOutlierHits(DetectorRegion region) const
return the number of outliers in a certain detector region.
Acts::Navigator Navigator
SummaryType
Enumerates the different types of information stored in Summary.
@ expectNextToInnermostPixelLayerHit
Do we expect a 1st-layer barrel hit for this track?
@ numberOfPixelBarrelFlatHits
these are the pixel hits, in the barrel flat layers [unit8_t].
static void initParticleHypothesisMap()
Helper class to provide type-safe access to aux data.
::StatusCode StatusCode
StatusCode definition for legacy code.
pointer_type ptr()
Dereference the pointer.
uint8_t contributingLayers(DetectorRegion region) const
return the number of layers contributing to the hit collection in the given detector region.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
@ numberOfPixelOutliers
these are the pixel outliers, including the b-layer [unit8_t].
@ standardDeviationOfChi2OS
100 times the standard deviation of the chi2 from the surfaces [unit8_t].
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
const Amg::Vector3D & position() const
return position of vertex
@ numberOfSCTHoles
number of SCT holes [unit8_t].
const T * back() const
Access the last element in the collection as an rvalue.
void setParticleHypothesis(const ParticleHypothesis hypo)
Method for setting the particle type, using the ParticleHypothesis enum.
@ numberOfTrackSummaryTypes
Include the GeoPrimitives which need to be put first.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ numberOfNextToInnermostPixelLayerEndcapHits
these are the hits in the 0.5th and 1st pixel layer endcap rings [unit8_t].
ElementLink implementation for ROOT usage.
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_trackParticlesOutKey
uint8_t sum(DetectorRegion region, uint8_t layer) const
return the total number of hits, outliers or hits+outliers in the givrn detector region and layer.
@ KalmanFitter
tracks produced by the Kalman Fitter
@ numberOfNextToInnermostPixelLayerOutliers
number of 1st pixel layer barrel outliers
@ numberOfNextToInnermostPixelLayerHits
these are the hits in the 1st pixel barrel layer
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCacheCondObjInputKey
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StatusCode initialize(bool used=true)
Eigen::Matrix< double, 3, 1 > Vector3D
@ numberOfPixelBarrelInclinedHits
these are the pixel hits, in the barrel inclined layers [unit8_t].
void setDefiningParametersCovMatrixVec(const std::vector< float > &cov)
void setSummaryValue(uint8_t &value, const SummaryType &information)
Set method for TrackSummary values.
@ numberOfOutliersOnTrack
number of measurements flaged as outliers in TSOS [unit8_t].
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Acts::EigenStepper<> Stepper
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
@ numberOfSCTOutliers
number of SCT outliers [unit8_t].
#define ATH_MSG_WARNING(x)
double biasedVariance() const
@ numberOfNextToInnermostPixelLayerEndcapOutliers
number of 1st layer endcap disk outliers
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
Gaudi::Property< double > m_pixelExpectLayerPathLimitInMM
@ SiSPSeededFinder
Tracks from SiSPSeedFinder.
void getField(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
get B field value at given position xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given,...
std::unique_ptr< Propagator > m_propagator
@ numberOfContribPixelLayers
number of contributing layers of the pixel detector [unit8_t].
@ numberOfSCTHits
number of hits in SCT [unit8_t].
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
@ numberOfPixelEndcapHits
these are the pixel hits, in the endcap layers [unit8_t].
SG::ReadHandleKeyArray< ActsTrk::TrackContainer > m_tracksContainerKey
Gaudi::Property< double > m_paramExtrapolationParLimit
Class describing a TrackParticle.
Acts::BoundTrackParameters parametersAtBeamLine(const EventContext &ctx, const typename ActsTrk::TrackContainer::ConstTrackProxy &track, const Acts::PerigeeSurface &perigee_surface) const
ToolHandle< IActsExtrapolationTool > m_extrapolationTool
Gaudi::Property< std::vector< unsigned int > > m_siDetEleCollToMeasurementType
static std::vector< std::pair< Acts::PdgParticle, xAOD::ParticleHypothesis > > s_actsHypothesisToxAOD ATLAS_THREAD_SAFE
DetectorRegion
Regions for which hit counts are computed.
SG::ReadCondHandleKeyArray< InDetDD::SiDetectorElementCollection > m_siDetEleCollKey
size_type size() const noexcept
Returns the number of elements in the collection.
Helper class to provide type-safe access to aux data.
void setBeamlineTiltX(float tiltX)
static xAOD::ParticleHypothesis convertParticleHypothesis(Acts::PdgParticle abs_pdg_id)
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
float beamTilt(int i) const noexcept
Returns the beam sigma for the i+3-th error matrix element (the 'tilt')
void setPatternRecognitionInfo(const std::bitset< xAOD::NumberOfTrackRecoInfo > &patternReco)
Method setting the pattern recognition algorithm, using a bitset.
const_pointer_type cptr()
TrackToTrackParticleCnvAlg(const std::string &name, ISvcLocator *pSvcLocator)