32 : base_class(
t,
n,
p) {}
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) {
96 hgtd_trk_volume->confinedLayers();
98 if (not confined_layers) {
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) {
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 std::unique_ptr<const Trk::TrackStateOnSurface> updated_state =
180 if (not updated_state) {
181 result.m_hits.at(hgtd_layer_i) =
nullptr;
182 result.m_truth_primary_hits.at(hgtd_layer_i) =
nullptr;
188 last_param = updated_state->trackParameters();
191 std::pair<const HGTD_Cluster*, HGTD::ClusterTruthInfo> truth_info =
195 result.m_hits.at(hgtd_layer_i) = std::move(updated_state);
196 result.m_truth_primary_hits.at(hgtd_layer_i) = truth_info.first;
197 result.m_truth_primary_info.at(hgtd_layer_i) = truth_info.second;
207 track.trackStateOnSurfaces();
214 for (
auto i = tsos->rbegin();
i != tsos->rend(); ++
i) {
215 const auto* curr_last_tsos = *
i;
216 if (not curr_last_tsos) {
220 curr_last_tsos->trackParameters() and
221 curr_last_tsos->measurementOnTrack()) {
222 return curr_last_tsos;
228 std::vector<const Trk::Surface*>
232 std::vector<const Trk::Surface*> surfaces;
237 const auto* surface_arr =
layer->surfaceArray();
241 const Trk::Surface* module_surface = surface_arr->object(
243 if (!module_surface) {
246 surfaces.push_back(module_surface);
258 if (!additional_surface) {
262 if (
std::find(surfaces.begin(), surfaces.end(), additional_surface) ==
264 surfaces.push_back(additional_surface);
271 std::vector<std::unique_ptr<const Trk::TrackParameters>>
274 const std::vector<const Trk::Surface*>& surfaces)
const {
276 std::vector<std::unique_ptr<const Trk::TrackParameters>>
params;
277 params.reserve(surfaces.size());
279 for (
const auto* surface : surfaces) {
280 std::unique_ptr<const Trk::TrackParameters> extrapolated_params =
nullptr;
285 if (not extrapolated_params) {
288 params.push_back(std::move(extrapolated_params));
294 std::unique_ptr<const Trk::TrackStateOnSurface>
297 const std::vector<std::unique_ptr<const Trk::TrackParameters>>&
params,
299 ATH_MSG_DEBUG(
"[updateStateWithBestFittingCluster] start updating");
301 std::unique_ptr<const Trk::TrackStateOnSurface> updated_state =
nullptr;
303 double lowest_chi2 = -1.;
305 for (
const auto& param :
params) {
306 std::unique_ptr<const Trk::TrackStateOnSurface> best_tsos =
309 ATH_MSG_DEBUG(
"[updateStateWithBestFittingCluster] tsos is null");
312 ATH_MSG_DEBUG(
"[updateStateWithBestFittingCluster] tsos found");
314 double chi2 = best_tsos->fitQualityOnSurface().chiSquared() /
315 best_tsos->fitQualityOnSurface().doubleNumberDoF();
317 "[updateStateWithBestFittingCluster] found state with chi2 of "
320 if (!updated_state or
chi2 < lowest_chi2) {
321 updated_state.swap(best_tsos);
326 return updated_state;
330 std::unique_ptr<const Trk::TrackStateOnSurface>
337 std::unique_ptr<const Trk::TrackStateOnSurface> tsos =
nullptr;
339 double lowest_chi2 = -1;
340 for (
const auto* collection : *container) {
342 if (collection->identify() !=
347 "[findBestCompatibleCluster] found collection of given surface");
349 for (
const auto* cluster : *collection) {
351 std::unique_ptr<const Trk::TrackStateOnSurface> candidate =
357 if (not candidate->measurementOnTrack() and
358 not candidate->fitQualityOnSurface()) {
361 double chi2 = candidate->fitQualityOnSurface().chiSquared() /
362 candidate->fitQualityOnSurface().doubleNumberDoF();
369 if (not tsos or
chi2 < lowest_chi2) {
370 tsos.swap(candidate);
382 std::unique_ptr<const Trk::TrackStateOnSurface>
393 std::pair<float, float> corr_time_and_res =
397 std::unique_ptr<HGTD_ClusterOnTrack> cot =
398 std::make_unique<HGTD_ClusterOnTrack>(
401 corr_time_and_res.second, det_el->identifyHash());
405 std::unique_ptr<Trk::TrackParameters>
pars =
m_updator->addToState(
409 auto uniqueQuality= std::unique_ptr<Trk::FitQualityOnSurface>(quality);
411 return std::make_unique<const Trk::TrackStateOnSurface>(QoS, std::move(cot),
415 std::pair<const HGTD_Cluster*, HGTD::ClusterTruthInfo>
417 const std::vector<const Trk::Surface*>& surfaces,
422 if (not truth_ptkl or not sim_data) {
431 std::vector<Identifier>
ids;
432 std::for_each(surfaces.begin(), surfaces.end(),
434 ids.push_back(surf->associatedDetectorElementIdentifier());
437 for (
const auto *
const collection : *container) {
444 for (
const auto* cluster : *collection) {
447 cluster, truth_ptkl, sim_data, hs_event);
451 return {cluster, truth_info};