32 : base_class(t, n, p) {}
35 StatusCode
sc = AthAlgTool::initialize();
68 <<
", y: " << last_param->
position().y()
69 <<
", z: " << last_param->
position().z());
71 <<
", py: " << last_param->
momentum().y()
72 <<
", pz: " << last_param->
momentum().z());
84 bool is_pos_endcap = last_param->
eta() > 0;
88 is_pos_endcap ?
"HGTD::PositiveEndcap" :
"HGTD::NegativeEndcap");
90 if (not hgtd_trk_volume) {
98 if (not confined_layers) {
105 std::span<Trk::Layer const * const> layers = confined_layers->
arrayObjects();
106 size_t layer_size = layers.size();
108 short position = is_pos_endcap ? 0 : layer_size - 1;
109 short step = is_pos_endcap ? 1 : -1;
110 short hgtd_layer_i = -1;
111 for (
size_t i = 0; i < layer_size - 1; i++, position = position + step) {
115 if (layer->layerType() != 1) {
120 const Trk::Surface& surf_obj = layer->surfaceRepresentation();
126 std::unique_ptr<const Trk::TrackParameters> extrap_result =
nullptr;
137 if (not extrap_result) {
139 result.m_hits.at(hgtd_layer_i) =
nullptr;
140 result.m_truth_primary_hits.at(hgtd_layer_i) =
nullptr;
146 if (hgtd_layer_i == 0) {
147 result.m_extrap_x = extrap_result->position().x();
148 result.m_extrap_y = extrap_result->position().y();
152 << extrap_result->position().x()
153 <<
", y: " << extrap_result->position().y()
154 <<
", z: " << extrap_result->position().z());
156 << extrap_result->momentum().x()
157 <<
", py: " << extrap_result->momentum().y()
158 <<
", pz: " << extrap_result->momentum().z());
163 if (compatible_surfaces.empty()) {
165 result.m_hits.at(hgtd_layer_i) =
nullptr;
166 result.m_truth_primary_hits.at(hgtd_layer_i) =
nullptr;
171 auto extrapolated_params =
174 std::unique_ptr<const Trk::TrackStateOnSurface> updated_state =
178 if (not updated_state) {
179 result.m_hits.at(hgtd_layer_i) =
nullptr;
180 result.m_truth_primary_hits.at(hgtd_layer_i) =
nullptr;
186 last_param = updated_state->trackParameters();
189 std::pair<const HGTD_Cluster*, HGTD::ClusterTruthInfo> truth_info =
193 result.m_hits.at(hgtd_layer_i) = std::move(updated_state);
194 result.m_truth_primary_hits.at(hgtd_layer_i) = truth_info.first;
195 result.m_truth_primary_info.at(hgtd_layer_i) = truth_info.second;
205 track.trackStateOnSurfaces();
212 for (
auto i = tsos->
rbegin(); i != tsos->
rend(); ++i) {
213 const auto* curr_last_tsos = *i;
214 if (not curr_last_tsos) {
218 curr_last_tsos->trackParameters() and
219 curr_last_tsos->measurementOnTrack()) {
220 return curr_last_tsos;
226std::vector<const Trk::Surface*>
230 std::vector<const Trk::Surface*> surfaces;
235 const auto* surface_arr = layer->surfaceArray();
239 const Trk::Surface* module_surface = surface_arr->object(
241 if (!module_surface) {
244 surfaces.push_back(module_surface);
249 float delta_angle = 6.2831853 / (float)steps;
252 for (
short i = 0; i < steps; i++,
angle =
angle + delta_angle) {
256 if (!additional_surface) {
260 if (std::find(surfaces.begin(), surfaces.end(), additional_surface) ==
262 surfaces.push_back(additional_surface);
269std::vector<std::unique_ptr<const Trk::TrackParameters>>
272 const std::vector<const Trk::Surface*>& surfaces)
const {
274 std::vector<std::unique_ptr<const Trk::TrackParameters>> params;
275 params.reserve(surfaces.size());
277 for (
const auto* surface : surfaces) {
278 std::unique_ptr<const Trk::TrackParameters> extrapolated_params =
nullptr;
283 if (not extrapolated_params) {
286 params.push_back(std::move(extrapolated_params));
292std::unique_ptr<const Trk::TrackStateOnSurface>
295 const std::vector<std::unique_ptr<const Trk::TrackParameters>>& params,
297 ATH_MSG_DEBUG(
"[updateStateWithBestFittingCluster] start updating");
299 std::unique_ptr<const Trk::TrackStateOnSurface> updated_state =
nullptr;
301 double lowest_chi2 = -1.;
303 for (
const auto& param : params) {
304 std::unique_ptr<const Trk::TrackStateOnSurface> best_tsos =
307 ATH_MSG_DEBUG(
"[updateStateWithBestFittingCluster] tsos is null");
310 ATH_MSG_DEBUG(
"[updateStateWithBestFittingCluster] tsos found");
312 double chi2 = best_tsos->fitQualityOnSurface().chiSquared() /
313 best_tsos->fitQualityOnSurface().doubleNumberDoF();
315 "[updateStateWithBestFittingCluster] found state with chi2 of "
318 if (!updated_state or
chi2 < lowest_chi2) {
319 updated_state.swap(best_tsos);
324 return updated_state;
328std::unique_ptr<const Trk::TrackStateOnSurface>
335 std::unique_ptr<const Trk::TrackStateOnSurface> tsos =
nullptr;
337 double lowest_chi2 = -1;
338 for (
const auto* collection : *
container) {
340 if (collection->identify() !=
345 "[findBestCompatibleCluster] found collection of given surface");
347 for (
const auto* cluster : *collection) {
349 std::unique_ptr<const Trk::TrackStateOnSurface> candidate =
355 if (not candidate->measurementOnTrack() and
356 not candidate->fitQualityOnSurface()) {
359 double chi2 = candidate->fitQualityOnSurface().chiSquared() /
360 candidate->fitQualityOnSurface().doubleNumberDoF();
367 if (not tsos or
chi2 < lowest_chi2) {
368 tsos.swap(candidate);
380std::unique_ptr<const Trk::TrackStateOnSurface>
391 std::pair<float, float> corr_time_and_res =
395 std::unique_ptr<HGTD_ClusterOnTrack> cot =
396 std::make_unique<HGTD_ClusterOnTrack>(
399 corr_time_and_res.second, det_el->identifyHash());
403 std::unique_ptr<Trk::TrackParameters> pars =
m_updator->addToState(
404 *param, cot->localParameters(), cot->localCovariance(), quality);
407 auto uniqueQuality= std::unique_ptr<Trk::FitQualityOnSurface>(quality);
409 return std::make_unique<const Trk::TrackStateOnSurface>(QoS, std::move(cot),
413std::pair<const HGTD_Cluster*, HGTD::ClusterTruthInfo>
415 const std::vector<const Trk::Surface*>& surfaces,
420 if (not truth_ptkl or not sim_data) {
429 std::vector<Identifier> ids;
430 std::for_each(surfaces.begin(), surfaces.end(),
432 ids.push_back(surf->associatedDetectorElementIdentifier());
435 for (
const auto *
const collection : *
container) {
438 if (std::find(ids.begin(), ids.end(), collection->identify()) ==
442 for (
const auto* cluster : *collection) {
445 cluster, truth_ptkl, sim_data, hs_event);
449 return {cluster, truth_info};
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Trk::PrepRawDataContainer< HGTD_ClusterCollection > HGTD_ClusterContainer
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration.
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
virtual float time() const
virtual float timeResolution() const
Binned Array for avoiding map searches/.
virtual std::span< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
Base Class for a Detector Layer in the Tracking realm.
double eta() const
Access method for pseudorapidity - from momentum.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
Abstract Base Class for tracking surfaces.
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
const Amg::Vector3D & center() const
Returns the center position of the Surface.
represents the track state (measurement, material, fit parameters and quality) at a surface.
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
The TrackingGeometry class is the owner of the constructed TrackingVolumes.
const TrackingVolume * trackingVolume(const std::string &name) const
return the tracking Volume by name, 0 if it doesn't exist
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
const LayerArray * confinedLayers() const
Return the subLayer array.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
double chi2(TH1 *h0, TH1 *h1)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
ClusterTruthOrigin origin