34 : base_class(t, n, p) {}
37 StatusCode
sc = AthAlgTool::initialize();
70 <<
", y: " << last_param->
position().y()
71 <<
", z: " << last_param->
position().z());
73 <<
", py: " << last_param->
momentum().y()
74 <<
", pz: " << last_param->
momentum().z());
86 bool is_pos_endcap = last_param->
eta() > 0;
90 is_pos_endcap ?
"HGTD::PositiveEndcap" :
"HGTD::NegativeEndcap");
92 if (not hgtd_trk_volume) {
100 if (not confined_layers) {
107 std::span<Trk::Layer const * const> layers = confined_layers->
arrayObjects();
108 size_t layer_size = layers.size();
110 short position = is_pos_endcap ? 0 : layer_size - 1;
111 short step = is_pos_endcap ? 1 : -1;
112 short hgtd_layer_i = -1;
113 for (
size_t i = 0; i < layer_size - 1; i++, position = position + step) {
117 if (layer->layerType() != 1) {
122 const Trk::Surface& surf_obj = layer->surfaceRepresentation();
128 std::unique_ptr<const Trk::TrackParameters> extrap_result =
nullptr;
139 if (not extrap_result) {
141 result.m_hits.at(hgtd_layer_i) =
nullptr;
142 result.m_truth_primary_hits.at(hgtd_layer_i) =
nullptr;
148 if (hgtd_layer_i == 0) {
149 result.m_extrap_x = extrap_result->position().x();
150 result.m_extrap_y = extrap_result->position().y();
154 << extrap_result->position().x()
155 <<
", y: " << extrap_result->position().y()
156 <<
", z: " << extrap_result->position().z());
158 << extrap_result->momentum().x()
159 <<
", py: " << extrap_result->momentum().y()
160 <<
", pz: " << extrap_result->momentum().z());
165 if (compatible_surfaces.empty()) {
167 result.m_hits.at(hgtd_layer_i) =
nullptr;
168 result.m_truth_primary_hits.at(hgtd_layer_i) =
nullptr;
173 auto extrapolated_params =
176 bool on_surface =
false;
177 std::unique_ptr<const Trk::TrackStateOnSurface> updated_state =
179 container, on_surface);
181 if (not updated_state) {
182 result.m_hits.at(hgtd_layer_i) =
nullptr;
183 result.m_truth_primary_hits.at(hgtd_layer_i) =
nullptr;
185 result.m_holes_hgtd.at(hgtd_layer_i) = on_surface;
190 last_param = updated_state->trackParameters();
193 std::pair<const HGTD_Cluster*, HGTD::ClusterTruthInfo> truth_info =
197 result.m_hits.at(hgtd_layer_i) = std::move(updated_state);
198 result.m_truth_primary_hits.at(hgtd_layer_i) = truth_info.first;
199 result.m_truth_primary_info.at(hgtd_layer_i) = truth_info.second;
210 track.trackStateOnSurfaces();
217 for (
auto i = tsos->
rbegin(); i != tsos->
rend(); ++i) {
218 const auto* curr_last_tsos = *i;
219 if (not curr_last_tsos) {
223 curr_last_tsos->trackParameters() and
224 curr_last_tsos->measurementOnTrack()) {
225 return curr_last_tsos;
231std::vector<const Trk::Surface*>
235 std::vector<const Trk::Surface*> surfaces;
240 const auto* surface_arr = layer->surfaceArray();
244 const Trk::Surface* module_surface = surface_arr->object(
246 if (!module_surface) {
249 surfaces.push_back(module_surface);
254 float delta_angle = 6.2831853 / (float)steps;
257 for (
short i = 0; i < steps; i++,
angle =
angle + delta_angle) {
260 const Trk::Surface* additional_surface = surface_arr->object(result);
261 if (!additional_surface) {
265 if (std::find(surfaces.begin(), surfaces.end(), additional_surface) ==
267 surfaces.push_back(additional_surface);
274std::vector<std::unique_ptr<const Trk::TrackParameters>>
277 const std::vector<const Trk::Surface*>& surfaces)
const {
279 std::vector<std::unique_ptr<const Trk::TrackParameters>> params;
280 params.reserve(surfaces.size());
282 for (
const auto* surface : surfaces) {
283 std::unique_ptr<const Trk::TrackParameters> extrapolated_params =
nullptr;
288 if (not extrapolated_params) {
291 params.push_back(std::move(extrapolated_params));
297std::unique_ptr<const Trk::TrackStateOnSurface>
300 const std::vector<std::unique_ptr<const Trk::TrackParameters>>& params,
302 ATH_MSG_DEBUG(
"[updateStateWithBestFittingCluster] start updating");
304 std::unique_ptr<const Trk::TrackStateOnSurface> updated_state =
nullptr;
306 double lowest_chi2 = -1.;
308 for (
const auto& param : params) {
315 std::unique_ptr<const Trk::TrackStateOnSurface> best_tsos =
318 ATH_MSG_DEBUG(
"[updateStateWithBestFittingCluster] tsos is null");
321 ATH_MSG_DEBUG(
"[updateStateWithBestFittingCluster] tsos found");
323 double chi2 = best_tsos->fitQualityOnSurface().chiSquared() /
324 best_tsos->fitQualityOnSurface().doubleNumberDoF();
326 "[updateStateWithBestFittingCluster] found state with chi2 of "
329 if (!updated_state or
chi2 < lowest_chi2) {
330 updated_state.swap(best_tsos);
335 return updated_state;
339std::unique_ptr<const Trk::TrackStateOnSurface>
346 std::unique_ptr<const Trk::TrackStateOnSurface> tsos =
nullptr;
348 double lowest_chi2 = -1;
349 for (
const auto* collection : *container) {
351 if (collection->identify() !=
356 "[findBestCompatibleCluster] found collection of given surface");
358 for (
const auto* cluster : *collection) {
360 std::unique_ptr<const Trk::TrackStateOnSurface> candidate =
366 if (not candidate->measurementOnTrack() and
367 not candidate->fitQualityOnSurface()) {
370 double chi2 = candidate->fitQualityOnSurface().chiSquared() /
371 candidate->fitQualityOnSurface().doubleNumberDoF();
378 if (not tsos or
chi2 < lowest_chi2) {
379 tsos.swap(candidate);
391std::unique_ptr<const Trk::TrackStateOnSurface>
402 std::pair<float, float> corr_time_and_res =
406 std::unique_ptr<HGTD_ClusterOnTrack> cot =
407 std::make_unique<HGTD_ClusterOnTrack>(
410 corr_time_and_res.second, det_el->identifyHash());
414 std::unique_ptr<Trk::TrackParameters> pars =
m_updator->addToState(
415 *param, cot->localParameters(), cot->localCovariance(), quality);
423 auto uniqueQuality= std::unique_ptr<Trk::FitQualityOnSurface>(quality);
425 return std::make_unique<const Trk::TrackStateOnSurface>(QoS, std::move(cot),
429std::pair<const HGTD_Cluster*, HGTD::ClusterTruthInfo>
431 const std::vector<const Trk::Surface*>& surfaces,
436 if (not truth_ptkl or not sim_data) {
445 std::vector<Identifier> ids;
446 std::for_each(surfaces.begin(), surfaces.end(),
448 ids.push_back(surf->associatedDetectorElementIdentifier());
451 for (
const auto *
const collection : *container) {
454 if (std::find(ids.begin(), ids.end(), collection->identify()) ==
458 for (
const auto* cluster : *collection) {
461 cluster, truth_ptkl, sim_data, hs_event);
465 return {cluster, truth_info};
488 bool is_pos_endcap = startParameters->
eta() > 0;
492 is_pos_endcap ?
"HGTD::PositiveEndcap" :
"HGTD::NegativeEndcap");
494 if (not hgtd_trk_volume) {
502 if (not confined_layer) {
509 std::span<Trk::Layer const * const> layers =
512 surf = &(layer->surfaceRepresentation());
517std::vector<std::unique_ptr<Trk::TrackParameters> >
524 std::vector<std::unique_ptr<Trk::TrackParameters> > paramList =
m_extrapolator->extrapolateStepwise(
528 int nOfExtrapolations = paramList.size();
529 if (paramList.empty()) {
533 std::vector<std::unique_ptr<Trk::TrackParameters> > listOfHoles;
534 listOfHoles.reserve(nOfExtrapolations);
536 for (std::unique_ptr<Trk::TrackParameters>& thisParameters : paramList) {
537 ATH_MSG_DEBUG(
"extrapolated pos: " << thisParameters->position() <<
" r: " <<
538 sqrt(pow(thisParameters->position().x(),2)+pow(thisParameters->position().y(),2)));
542 if ((thisParameters->associatedSurface()).associatedDetectorElement() !=
nullptr and
543 (thisParameters->associatedSurface()).associatedDetectorElement()->identify() != 0) {
544 id = (thisParameters->associatedSurface()).associatedDetectorElement()->identify();
553 thisParameters->associatedSurface().associatedDetectorElement());
554 if (siElement ==
nullptr) {
555 ATH_MSG_DEBUG(
"TrackParameters do not belong to a Si Element");
561 if (thisParameters->covariance()) {
565 if (siElement->
nearBondGap(thisParameters->localPosition(), etatol)) {
569 siElement->
inDetector(thisParameters->localPosition(), phitol, etatol);
576 if(thisParameters->position().z() > 3200){
577 ATH_MSG_DEBUG(
"Extrapolated pos. z is probably at HGTD: " << thisParameters->position().z());
582 auto searchRepeatition = std::find_if(
583 listOfHoles.begin(), listOfHoles.end(), [
id](std::unique_ptr<Trk::TrackParameters> &tp_test)
584 {return tp_test->associatedSurface().associatedDetectorElement()->identify() == id ; });
585 if (searchRepeatition == listOfHoles.end()) {
586 listOfHoles.push_back(std::move(thisParameters));
593 ATH_MSG_DEBUG(
"[HGTD_IterativeExtensionTool::getHolesITk] difference in 2 lists: "<< nOfExtrapolations-listOfHoles.size());
598 const std::unique_ptr<const Trk::TrackParameters>& last_param)
const {
603 if (last_param->covariance()) {
610 ATH_MSG_DEBUG(
"Distance from the surface: " << last_param->associatedSurface().bounds().minDistance(
611 last_param->localPosition()));
612 ATH_MSG_DEBUG(
"Phitol: " << phitol <<
" , etatol: "<<etatol);
613 ATH_MSG_DEBUG(
"Is on surface: "<< bounds_HGTD.
inside(last_param->localPosition(), phitol, etatol));
615 return bounds_HGTD.
inside(last_param->localPosition(), phitol, etatol);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#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.
float timeResolution() const
Class to hold geometrical description of a silicon detector element.
bool nearBondGap(const Amg::Vector2D &localPosition, double etaTol) const
Test if near bond gap within tolerances.
class to run intersection tests
SiIntersect inDetector(const Amg::Vector2D &localPosition, double phiTol, double etaTol) const
Test that it is in the active region.
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 surface bounds to be specified.
virtual bool inside(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const =0
Each Bounds has a method inside, which checks if a LocalPosition is inside the bounds.
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
HepMC3::GenEvent GenEvent
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