ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalChi2Fitter.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef GLOBALCHI2FITTER_H
6#define GLOBALCHI2FITTER_H
7
11#include "GaudiKernel/ToolHandle.h"
12#include "GaudiKernel/EventContext.h"
13
14
20
27
29
36
39
42
43#include <memory>
44#include <mutex>
45
138
139class AtlasDetectorID;
140
141
142namespace Trk {
143 class Track;
144 class IMagneticFieldTool;
145 class MeasuredPerigee;
149 class Layer;
150 class CylinderLayer;
151 class DiscLayer;
153 class TrackingVolume;
154 class Volume;
155
156 class GlobalChi2Fitter: public extends<AthCheckedComponent<AthAlgTool>, IGlobalTrackFitter> {
158 std::unique_ptr<const TrackParameters> m_parameters;
159 std::optional<TransportJacobian> m_jacobian;
160 std::optional<std::vector<std::unique_ptr<TrackParameters>>> m_preholes;
161 };
162
163 /*
164 * This struct serves as a very simple container for the five different
165 * hole and dead module states that we want to count, which are the dead
166 * Pixels, dead SCTs, Pixel holes, SCT holes, and SCT double holes.
167 */
169 unsigned int m_pixel_hole = 0;
170 unsigned int m_sct_hole = 0;
171 unsigned int m_sct_double_hole = 0;
172 unsigned int m_pixel_dead = 0;
173 unsigned int m_sct_dead = 0;
174 };
175
188
189 struct Cache {
190 /*
191 * Currently the information about what type of fit is being passed by the
192 * presence of a TrackingVolume.
193 */
194 template <class T>
195 static
196 void objVectorDeleter(const std::vector<const T *> *ptr) {
197 if (ptr) {
198 for (const T *elm : *ptr) { delete elm; }
199 delete ptr;
200 }
201 }
202
205 const TrackingVolume *m_msEntrance = nullptr;
206
208 bool m_idmat = true;
209 bool m_sirecal{};
212 bool m_matfilled = false;
216
217 std::vector<double> m_phiweight;
218 std::vector<int> m_firstmeasurement;
219 std::vector<int> m_lastmeasurement;
220
221 std::vector < const Trk::Layer * >m_negdiscs;
222 std::vector < const Trk::Layer * >m_posdiscs;
223 std::vector < const Trk::Layer * >m_barrelcylinders;
224
225 bool m_fastmat = true;
226
229
232
233 std::vector< std::unique_ptr< const std::vector < const TrackStateOnSurface *>,
234 void (*)(const std::vector<const TrackStateOnSurface *> *) > >
236
238
240
241 std::array<unsigned int, S_MAX_VALUE> m_fit_status {};
242 std::array<std::atomic<unsigned int>, S_MAX_VALUE> *m_fit_status_out = nullptr;
243
244 Cache(const GlobalChi2Fitter *fitter):
245 m_calomat(fitter->m_calomat),
246 m_extmat(fitter->m_extmat),
247 m_sirecal(fitter->m_sirecal),
249 m_reintoutl(fitter->m_reintoutl),
251 m_fiteloss(fitter->m_fiteloss),
252 m_asymeloss(fitter->m_asymeloss),
253 m_miniter(fitter->m_miniter),
255 {}
257 unsigned int idx=0;
258 for (unsigned int a_fit_status : m_fit_status) {
259 if (a_fit_status) {
260 (*m_fit_status_out)[idx] += a_fit_status;
261 }
262 ++idx;
263 }
264 }
265
266 Cache & operator=(const Cache &) = delete;
267
269 m_fit_status[status]++;
270 }
271 };
272
273 public:
275 const std::string &,
276 const std::string &,
277 const IInterface *
278 );
279
280 virtual ~ GlobalChi2Fitter();
281
282 virtual StatusCode initialize() override;
283 virtual StatusCode finalize() override;
284
285 virtual std::unique_ptr<Track> fit(
286 const EventContext& ctx,
287 const PrepRawDataSet&,
288 const TrackParameters&,
289 const RunOutlierRemoval runOutlier = false,
290 const ParticleHypothesis matEffects = nonInteracting
291 ) const override final;
292
293 virtual std::unique_ptr<Track> fit(
294 const EventContext& ctx,
295 const Track &,
296 const RunOutlierRemoval runOutlier = false,
297 const ParticleHypothesis matEffects = nonInteracting
298 ) const override final;
299
300 virtual std::unique_ptr<Track> fit(
301 const EventContext& ctx,
302 const MeasurementSet &,
303 const TrackParameters &,
304 const RunOutlierRemoval runOutlier = false,
305 const ParticleHypothesis matEffects = nonInteracting
306 ) const override final;
307
308 virtual std::unique_ptr<Track> fit(
309 const EventContext& ctx,
310 const Track &,
311 const PrepRawDataSet &,
312 const RunOutlierRemoval runOutlier = false,
313 const ParticleHypothesis matEffects = nonInteracting
314 ) const override final;
315
316 virtual std::unique_ptr<Track> fit(
317 const EventContext& ctx,
318 const Track &,
319 const Track &,
320 const RunOutlierRemoval runOutlier = false,
321 const ParticleHypothesis matEffects = nonInteracting
322 ) const override final;
323
324 virtual std::unique_ptr<Track> fit(
325 const EventContext& ctx,
326 const Track &,
327 const MeasurementSet &,
328 const RunOutlierRemoval runOutlier = false,
329 const ParticleHypothesis matEffects = nonInteracting
330 ) const override final;
331
332 virtual Track* alignmentFit(
333 AlignmentCache&,
334 const Track&,
335 const RunOutlierRemoval runOutlier=false,
337 ) const override;
338
339 private:
340
341 Track * fitIm(
342 const EventContext& ctx,
343 Cache & cache,
344 const Track & inputTrack,
345 const RunOutlierRemoval runOutlier,
346 const ParticleHypothesis matEffects
347 ) const;
348
349 Track *myfit(
350 const EventContext& ctx,
351 Cache &,
353 const TrackParameters &,
354 const RunOutlierRemoval runOutlier = false,
355 const ParticleHypothesis matEffects = nonInteracting
356 ) const;
357
359 Cache &,
361 const TrackParameters &,
362 const RunOutlierRemoval runOutlier = false,
363 const ParticleHypothesis matEffects = nonInteracting
364 ) const;
365
367 const EventContext& ctx,
368 Cache &,
369 const Track &,
370 const Track &,
372 std::vector<MaterialEffectsOnTrack> &
373 ) const;
374
376 const EventContext& ctx,
377 Cache &,
378 const Track &,
379 const Track &,
381 std::vector<MaterialEffectsOnTrack> &
382 ) const;
383
384 void makeProtoState(
385 Cache &,
387 const TrackStateOnSurface *,
388 int index = -1
389 ) const;
390
392 Cache &,
394 const MeasurementBase *,
395 const TrackParameters * trackpar = nullptr,
396 bool isoutlier = false,
397 int index = -1
398 ) const;
399
400 bool processTrkVolume(
401 Cache &,
402 const Trk::TrackingVolume * tvol
403 ) const;
404
430 static std::optional<std::pair<Amg::Vector3D, double>> addMaterialFindIntersectionDisc(
431 Cache & cache,
432 const DiscSurface & surface,
433 const TrackParameters & param1,
434 const TrackParameters & param2,
435 const ParticleHypothesis mat
436 ) ;
437
447 static std::optional<std::pair<Amg::Vector3D, double>> addMaterialFindIntersectionCyl(
448 Cache & cache,
449 const CylinderSurface & surface,
450 const TrackParameters & param1,
451 const TrackParameters & param2,
452 const ParticleHypothesis mat
453 ) ;
454
476 Cache & cache,
477 GXFTrajectory & track,
478 int offset,
479 std::vector<std::pair<const Layer *, const Layer *>> & layers,
480 const TrackParameters * ref1,
481 const TrackParameters * ref2,
483 ) const;
484
506 static void addMaterialGetLayers(
507 Cache & cache,
508 std::vector<std::pair<const Layer *, const Layer *>> & layers,
509 std::vector<std::pair<const Layer *, const Layer *>> & uplayers,
510 const std::vector<std::unique_ptr<GXFTrackState>> & states,
511 GXFTrackState & first,
512 GXFTrackState & last,
513 const TrackParameters * refpar,
514 bool hasmat
515 ) ;
516
540 const EventContext& ctx,
541 Cache & cache,
542 GXFTrajectory & track,
543 const TrackParameters * parameters,
545 ) const;
546
547 void addMaterial(
548 const EventContext& ctx,
549 Cache &,
551 const TrackParameters *,
553 ) const;
554
569 std::vector<std::unique_ptr<TrackParameters>> holesearchExtrapolation(
570 const EventContext & ctx,
571 const TrackParameters & src,
572 const GXFTrackState & dst,
573 PropDirection propdir
574 ) const;
575
576 std::unique_ptr<const TrackParameters> makePerigee(
577 Cache &,
578 const TrackParameters &,
580 ) const;
581
583 Cache &,
585 ) ;
586
587 std::unique_ptr<const TrackParameters> makeTrackFindPerigeeParameters(
588 const EventContext &,
589 Cache &,
592 ) const;
593
594 std::unique_ptr<GXFTrackState> makeTrackFindPerigee(
595 const EventContext &,
596 Cache &,
599 ) const;
600
601 std::unique_ptr<Track> makeTrack(
602 const EventContext& ctx,
603 Cache &,
606 ) const;
607
608 /*
609 * @brief Fill the residual and error vector
610 *
611 * Loop over all track states and extract residual and error data. Then
612 * fill the data sorted into vectors. Since we have all data here, we
613 * already sum over all chi2 contributions. The b-vector is in this step
614 * only filled with the scattering contributions.
615 *
616 * @param[in] ctx An event context for extrapolation.
617 * @param[in] cache General cache object for asym energy loss.
618 * @param[in, out] trajectory The trajectory, we want to analyse.
619 * @param[in] it The current iteration, we are in.
620 * @param[in, out] b The b-vector to be filled with scattering elements.
621 * @param[in, out] bremno_maxbrempull The position of the maxbrempull in all brempull elements.
622 * @param[in, out] state_maxbrempull The actual state holding the maxbrempull.
623 */
625 const EventContext& ctx,
626 const Cache & cache,
627 GXFTrajectory & trajectory,
628 const int it,
629 Amg::VectorX & b,
630 int & bremno_maxbrempull,
631 GXFTrackState* & state_maxbrempull
632 ) const;
633
634 /*
635 * @brief Check if we already converged and set the flag.
636 *
637 * We run a few checks on convergence. Depending on the iteration we are in,
638 * different criteria are applied.
639 *
640 * @param[in] cache General cache object for the external iteration goal.
641 * @param[in, out] trajectory The trajectory, we want to analyse.
642 * @param[in] it The current iteration, we are in.
643 */
644 void tryToConverge(
645 const Cache & cache,
646 GXFTrajectory & trajectory,
647 const int it
648 ) const;
649
650 /*
651 * @brief Update errors with the information from the maxbremspull.
652 *
653 * Marks the state of the maxbremspull as a kink and updates the
654 * sigmaDeltaE. Then the error for the corresponding residual is updated.
655 * The [a]-matrix is modified with the new error information.
656 *
657 * @param[in, out] trajectory The trajectory, we want to analyse.
658 * @param[in] bremno_maxbrempull The position of the maxbrempull in the brempull list.
659 * @param[in, out] state_maxbrempull Pointer to the state, so we can modify it.
660 * @param[in, out] a The [a]-matrix of the system.
661 *
662 * @note You might want to redo your derivatives after this step.
663 */
665 GXFTrajectory & trajectory,
666 const int bremno_maxbrempull,
667 GXFTrackState* state_maxbrempull,
669 ) const;
670
671 void fillDerivatives(
672 GXFTrajectory & traj
673 ) const;
674
675 /*
676 * @brief Find and set first and last measurement for each fit parameter.
677 *
678 * Find the first and last measurement relevant for each parameter. The
679 * perigee parameter use all real measurements. For the scattering and
680 * brems parameters, all measurements after/before encountering that
681 * surface are skipped, depending if we are still looking at upstream
682 * states or not.
683 *
684 * @param[in, out] cache General cache object to fill with first/last.
685 * @param[in, out] trajectory The trajectory, we want to analyse.
686 */
687 static void fillFirstLastMeasurement(
688 Cache & cache,
689 GXFTrajectory & trajectory
690 ) ;
691
692 /*
693 * @brief Fill the b-vector with the residual information from the measurements.
694 *
695 * Loop over all fit parameters. For each, loop over all relevant,
696 * measurements and add the information to the b-vector. For each fit
697 * parameter k we get:
698 * b[k] = sum( res / error * derivative )
699 * For qOverP and brems we get also a contribution the brems elements in
700 * the b-vector.
701 *
702 * @param[out] cache General cache object for first/last measurements.
703 * @param[in, out] trajectory The trajectory, we want to analyse.
704 * @param[in, out] b The b-vector of the system.
705 */
706 static void fillBfromMeasurements(
707 const Cache & cache,
708 GXFTrajectory & trajectory,
709 Amg::VectorX & b
710 ) ;
711
712 /*
713 * @brief Fill the [a]-matrix with the derivative information from the measurements.
714 *
715 * Loop over all fit parameters in two dimensions k and l. For each, loop
716 * over all relevant, measurements and add the information to the
717 * [a]-matrix. We get:
718 * [a]_kl = sum( derivative_k * derivative_l )
719 *
720 * @param[out] cache General cache object for first/last measurements.
721 * @param[in, out] trajectory The trajectory, we want to analyse.
722 * @param[in, out] a The [a]-matrix of the system.
723 */
724 static void fillAfromMeasurements(
725 const Cache & cache,
726 GXFTrajectory & trajectory,
728 ) ;
729
730 /*
731 * @brief Fill the [a]-matrix with the derivative information from the scatterers.
732 *
733 * Loop over non-perigee (except qOverP) parameters in two dimensions k and
734 * l. For each, loop over all relevant, derivative entries and add the
735 * information to the [a]-matrix. We get an update of the diagonal:
736 * [a]_kk += 1 / scatSigma^2
737 * and an update of the general elements:
738 * [a]_kl += sum( derivative_k * derivative_l )
739 *
740 * @param[in, out] trajectory The trajectory, we want to analyse.
741 * @param[in, out] a The [a]-matrix of the system.
742 */
743 static void fillAfromScatterers(
744 GXFTrajectory & trajectory,
746 ) ;
747
748 /*
749 * @brief Update [a]-matrix with material effects by weighting some elements.
750 *
751 * Applies weights to the diagonal material elements in the [a]-matrix.
752 * The weights depend on the progress of the iteration and can vary on the
753 * absolute iteration number as well as on the convergence of the chi2.
754 *
755 * @param[in, out] cache General cache object for the phi weights.
756 * @param[in, out] trajectory The trajectory, we want to analyse.
757 * @param[in, out] a The [a]-matrix of the system.
758 * @param[in] doDeriv If we redid derivatives in this iteration
759 * @param[in] it The current iteration, we are in.
760 * @param[in] oldRedChi2 Old reduced chi2 for convergence analysis.
761 * @param[in] newdRedChi2 New reduced chi2 for convergence analysis.
762 *
763 * @return a bool if any weights have been applied.
764 *
765 * @note prefit == 1 does not do a lot, maybe changes weightChanged. Could be wrong behaviour?
766 */
767 static bool tryToWeightAfromMaterial(
768 Cache & cache,
769 GXFTrajectory & trajectory,
771 const bool doDeriv,
772 const int it,
773 const double oldRedChi2,
774 const double newRedChi2
775 ) ;
776
777 /*
778 * @brief Effectively removes the phi weights from the [a]-matrix.
779 *
780 * Removes the phi weights added by tryToWeightAfromMaterial() from the
781 * diagonal material elements in the [a]-matrix. Then sets the stored
782 * weights to 1.
783 *
784 * @param[in, out] cache General cache object for the phi weights.
785 * @param[in, out] trajectory The trajectory, we want to analyse.
786 * @param[in, out] a The [a]-matrix of the system.
787 */
788 static void compensatePhiWeights(
789 Cache & cache,
790 GXFTrajectory & trajectory,
792 ) ;
793
794 /*
795 * @brief Performs the main work of the GX2F iteration.
796 *
797 * The main parts are:
798 * - calculate parameters
799 * - calculate residuals
800 * - (opt) redo derivatives
801 * - fill b-vector
802 * - (opt) update [a]-matrix
803 * - (opt) update [lu]-matrix
804 * - check for convergence
805 *
806 * @param[in] ctx An event context for extrapolation.
807 * @param[in, out] cache General cache object for.
808 * @param[in, out] trajectory The trajectory, we want to analyse.
809 * @param[in] it The current iteration, we are in.
810 * @param[in, out] a The [a]-matrix of the system.
811 * @param[in, out] b The b-vector of the system.
812 * @param[in, out] lu The [lu]-matrix of the system.
813 * @param[in, out] doDeriv Toggle if we need to do now and return if we need to do again.
814 *
815 * @return a status code with success or a detailed error.
816 */
817
819 const EventContext& ctx,
820 Cache & cache,
821 GXFTrajectory & trajectory,
822 const int it,
824 Amg::VectorX & b,
825 Amg::SymMatrixX & lu,
826 bool & doDeriv
827 ) const;
828
837 const Amg::VectorX &,
838 const Amg::SymMatrixX &
839 ) const;
840
841
845 void updatePixelROTs(
848 Amg::VectorX &,
849 const EventContext& evtctx
850 ) const;
851
852
859 const EventContext& ctx,
860 Cache &,
864 Amg::VectorX &,
865 bool
866 ) const;
867
869 Cache &,
872 Amg::VectorX &,
874 bool, bool, int,
875 const EventContext& ctx
876 ) const;
877
891 const EventContext &,
892 const TrackParameters &,
893 const GXFTrackState &,
896 bool,
897 bool
898 ) const;
899
941 const EventContext &,
942 const TrackParameters &,
943 const GXFTrackState &,
946 bool,
947 bool
948 ) const;
949
977 std::vector<std::reference_wrapper<GXFTrackState>> holeSearchStates(
978 GXFTrajectory & trajectory
979 ) const;
980
1002 std::optional<GlobalChi2Fitter::TrackHoleCount> holeSearchProcess(
1003 const EventContext & ctx,
1004 const std::vector<std::reference_wrapper<GXFTrackState>> & states
1005 ) const;
1006
1029 void holeSearchHelper(
1030 const std::vector<std::unique_ptr<TrackParameters>> & hc,
1031 std::set<Identifier> & id_set,
1032 std::set<Identifier> & sct_set,
1033 TrackHoleCount & rv,
1034 bool count_holes,
1035 bool count_dead
1036 ) const;
1037
1039 const EventContext& ctx,
1041 bool) const;
1042
1043 std::variant<std::unique_ptr<const TrackParameters>, FitterStatusCode> updateEnergyLoss(
1044 const Surface &,
1045 const GXFMaterialEffects &,
1046 const TrackParameters &,
1047 double,
1048 int
1049 ) const;
1050
1051 static void calculateDerivatives(GXFTrajectory &) ;
1052
1053 void calculateTrackErrors(GXFTrajectory &, Amg::SymMatrixX &, bool) const;
1054
1055 std::optional<TransportJacobian> numericalDerivatives(
1056 const EventContext& ctx,
1057 const TrackParameters *,
1058 const Surface &,
1061 ) const;
1062
1063 virtual int iterationsOfLastFit() const;
1064
1065 virtual void setMinIterations(int);
1066
1067 static bool correctAngles(double &, double &) ;
1068
1069 bool isMuonTrack(const Track &) const;
1070
1082 void initFieldCache(
1083 const EventContext& ctx,
1084 Cache & cache
1085 ) const;
1086
1087 ToolHandle<IRIO_OnTrackCreator> m_ROTcreator {this, "RotCreatorTool", "", ""};
1088 ToolHandle<IRIO_OnTrackCreator> m_broadROTcreator {this, "BroadRotCreatorTool", "", ""};
1089 ToolHandle<IUpdator> m_updator {this, "MeasurementUpdateTool", "", ""};
1090 ToolHandle<IExtrapolator> m_extrapolator {this, "ExtrapolationTool", "Trk::Extrapolator/CosmicsExtrapolator", ""};
1091 ToolHandle<IMultipleScatteringUpdator> m_scattool {this, "MultipleScatteringTool", "Trk::MultipleScatteringUpdator/AtlasMultipleScatteringUpdator", ""};
1092 ToolHandle<IEnergyLossUpdator> m_elosstool {this, "EnergyLossTool", "Trk::EnergyLossUpdator/AtlasEnergyLossUpdator", ""};
1093 ToolHandle<IMaterialEffectsUpdator> m_matupdator {this, "MaterialUpdateTool", "", ""};
1094 ToolHandle<IPropagator> m_propagator {this, "PropagatorTool", "", ""};
1095 ToolHandle<INavigator> m_navigator {this, "NavigatorTool", "Trk::Navigator/CosmicsNavigator", ""};
1096 ToolHandle<IResidualPullCalculator> m_residualPullCalculator {this, "ResidualPullCalculatorTool", "Trk::ResidualPullCalculator/ResidualPullCalculator", ""};
1097 ToolHandle<Trk::ITrkMaterialProviderTool> m_caloMaterialProvider {this, "CaloMaterialProvider", "Trk::TrkMaterialProviderTool/TrkMaterialProviderTool", ""};
1098 ToolHandle<IMaterialEffectsOnTrackProvider> m_calotool {this, "MuidTool", "Rec::MuidMaterialEffectsOnTrackProvider/MuidMaterialEffectsOnTrackProvider", ""};
1099 ToolHandle<IMaterialEffectsOnTrackProvider> m_calotoolparam {this, "MuidToolParam", "", ""};
1100 ToolHandle<IBoundaryCheckTool> m_boundaryCheckTool {this, "BoundaryCheckTool", "", "Boundary checking tool for detector sensitivities" };
1101
1103
1104 /*
1105 * @brief Check if the entrance to the calo is valid. If not, attempt to fix it.
1106 *
1107 * Ensure that the cache contains a valid tracking geometry that we can
1108 * use. If it is not set yet, set it as InDet::Containers::InnerDetector.
1109 *
1110 * @param[in] ctx A context for creating the geometry.
1111 * @param[in, out] cache The GX2F cache objects.
1112 */
1114 const EventContext& ctx,
1115 Cache& cache
1116 ) const;
1117
1118 /*
1119 * @brief Check if the entrance to the Muon Spectrometer is valid. If not, attempt to fix it.
1120 *
1121 * Ensure that the cache contains a valid tracking geometry that we can
1122 * use. If it is not set yet, set it as MuonSpectrometerEntrance.
1123 *
1124 * @param[in] ctx A context for creating the geometry.
1125 * @param[in, out] cache The GX2F cache objects.
1126 */
1128 const EventContext& ctx,
1129 Cache& cache
1130 ) const;
1131
1133 const EventContext& ctx) const
1134 {
1135 if (!cache.m_trackingGeometry)
1137 return cache.m_trackingGeometry;
1138 }
1140 const EventContext& ctx) const
1141 {
1143 ctx);
1144 if (!handle.isValid()) {
1146 }
1147 return handle.cptr();
1148 }
1149
1151 this,
1152 "TrackingGeometryReadKey",
1153 "AtlasTrackingGeometry",
1154 "Key of the TrackingGeometry conditions data."
1155 };
1156
1158 this,
1159 "AtlasFieldCacheCondObj",
1160 "fieldCondObj",
1161 "Trk::GlobalChi2Fitter field conditions object key"
1162 };
1163
1164 const AtlasDetectorID *m_DetID = nullptr;
1165
1166 Gaudi::Property<bool> m_signedradius {this, "SignedDriftRadius", true};
1167 Gaudi::Property<bool> m_calomat {this, "MuidMat", false};
1168 Gaudi::Property<bool> m_extmat {this, "ExtrapolatorMaterial", true};
1169 Gaudi::Property<bool> m_fillderivmatrix {this, "FillDerivativeMatrix", false};
1170 Gaudi::Property<bool> m_straightlineprop {this, "StraightLine", true};
1171 Gaudi::Property<bool> m_extensioncuts {this, "TRTExtensionCuts", true};
1172 Gaudi::Property<bool> m_sirecal {this, "RecalibrateSilicon", false};
1173 Gaudi::Property<bool> m_trtrecal {this, "RecalibrateTRT", false};
1174 Gaudi::Property<bool> m_kinkfinding {this, "KinkFinding", false};
1175 Gaudi::Property<bool> m_decomposesegments {this, "DecomposeSegments", true};
1176 Gaudi::Property<bool> m_getmaterialfromtrack {this, "GetMaterialFromTrack", true};
1177 Gaudi::Property<bool> m_domeastrackpar {this, "MeasuredTrackParameters", true};
1178 Gaudi::Property<bool> m_storemat {this, "StoreMaterialOnTrack", true};
1179 Gaudi::Property<bool> m_redoderivs {this, "RecalculateDerivatives", false};
1180 Gaudi::Property<bool> m_reintoutl {this, "ReintegrateOutliers", false};
1181 Gaudi::Property<bool> m_acceleration {this, "Acceleration", false};
1182 Gaudi::Property<bool> m_numderiv {this, "NumericalDerivs", false};
1183 Gaudi::Property<bool> m_fiteloss {this, "FitEnergyLoss", false};
1184 Gaudi::Property<bool> m_asymeloss {this, "AsymmetricEnergyLoss", true};
1185 Gaudi::Property<bool> m_useCaloTG {this, "UseCaloTG", false};
1186 Gaudi::Property<bool> m_rejectLargeNScat {this, "RejectLargeNScat", false};
1187 Gaudi::Property<bool> m_createSummary {this, "CreateTrackSummary", true};
1188 Gaudi::Property<bool> m_holeSearch {this, "DoHoleSearch", false};
1189
1190 Gaudi::Property<double> m_outlcut {this, "OutlierCut", 5.0};
1191 Gaudi::Property<double> m_p {this, "Momentum", 0.0};
1192 Gaudi::Property<double> m_chi2cut {this, "TrackChi2PerNDFCut", 1.e15};
1193 Gaudi::Property<double> m_scalefactor {this, "TRTTubeHitCut", 2.5};
1194 Gaudi::Property<double> m_minphfcut {this, "MinPHFCut", 0.};
1195
1196 Gaudi::Property<int> m_maxoutliers {this, "MaxOutliers", 10};
1197 Gaudi::Property<int> m_maxit {this, "MaxIterations", 30};
1198 Gaudi::Property<int> m_miniter {this, "MinimumIterations", 1};
1199 Gaudi::Property<int> m_fixbrem {this, "FixBrem", -1};
1200 Gaudi::Property<int> m_maxitPixelROT {this, "IterationsToRebuildPixelRots", 0};
1201
1203
1204
1205 /*
1206 * This little volume defines the inner detector. Its exact size is set at
1207 * the time that the fitter object is created. We just make one and keep
1208 * it around to save us a few allocations.
1209 */
1211
1212 /*
1213 * The following members are mutable. They keep track of the number of
1214 * fits that have returned with a certain status. Since this must be
1215 * shared across threads, we protect the array with a mutex, and we mark
1216 * these members as thread_safe for the ATLAS G++ plugin.
1217 */
1218 //mutable std::mutex m_fit_status_lock ATLAS_THREAD_SAFE;
1219 mutable std::array<std::atomic<unsigned int>, S_MAX_VALUE> m_fit_status ATLAS_THREAD_SAFE = {};
1220 };
1221}
1222#endif
static Double_t a
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
const_pointer_type cptr()
Property holding a SG store/key/clid from which a ReadHandle is made.
Class to describe a cylindrical detector layer for tracking, it inhertis from both,...
Class for a CylinderSurface in the ATLAS detector.
Class to describe a disc-like detector layer for tracking, it inhertis from both, Layer base class an...
Definition DiscLayer.h:45
Class for a DiscSurface in the ATLAS detector.
Definition DiscSurface.h:54
Status codes for track fitters.
class that is similar to MaterialEffectsOnTrack, but has 'set' methods for more flexibility during tr...
Internal representation of the track, used in the track fit.
Gaudi::Property< int > m_maxoutliers
ToolHandle< IBoundaryCheckTool > m_boundaryCheckTool
Gaudi::Property< bool > m_reintoutl
std::unique_ptr< Track > makeTrack(const EventContext &ctx, Cache &, GXFTrajectory &, const ParticleHypothesis) const
void tryToConverge(const Cache &cache, GXFTrajectory &trajectory, const int it) const
void makeProtoState(Cache &, GXFTrajectory &, const TrackStateOnSurface *, int index=-1) const
Gaudi::Property< double > m_p
FitterStatusCode calculateTrackParameters(const EventContext &ctx, GXFTrajectory &, bool) const
Track * myfit(const EventContext &ctx, Cache &, GXFTrajectory &, const TrackParameters &, const RunOutlierRemoval runOutlier=false, const ParticleHypothesis matEffects=nonInteracting) const
Gaudi::Property< bool > m_signedradius
void fillResidualsAndErrors(const EventContext &ctx, const Cache &cache, GXFTrajectory &trajectory, const int it, Amg::VectorX &b, int &bremno_maxbrempull, GXFTrackState *&state_maxbrempull) const
Gaudi::Property< double > m_scalefactor
Gaudi::Property< bool > m_rejectLargeNScat
std::variant< std::unique_ptr< const TrackParameters >, FitterStatusCode > updateEnergyLoss(const Surface &, const GXFMaterialEffects &, const TrackParameters &, double, int) const
ToolHandle< Trk::ITrkMaterialProviderTool > m_caloMaterialProvider
Gaudi::Property< bool > m_trtrecal
bool processTrkVolume(Cache &, const Trk::TrackingVolume *tvol) const
ToolHandle< IPropagator > m_propagator
Gaudi::Property< bool > m_straightlineprop
Gaudi::Property< bool > m_fiteloss
std::optional< GlobalChi2Fitter::TrackHoleCount > holeSearchProcess(const EventContext &ctx, const std::vector< std::reference_wrapper< GXFTrackState > > &states) const
Conduct a hole search between a list of states, possibly reusing existing information.
static std::optional< std::pair< Amg::Vector3D, double > > addMaterialFindIntersectionDisc(Cache &cache, const DiscSurface &surface, const TrackParameters &param1, const TrackParameters &param2, const ParticleHypothesis mat)
Find the intersection of a set of track parameters onto a disc surface.
ToolHandle< INavigator > m_navigator
Gaudi::Property< bool > m_sirecal
void updateSystemWithMaxBremPull(GXFTrajectory &trajectory, const int bremno_maxbrempull, GXFTrackState *state_maxbrempull, Amg::SymMatrixX &a) const
SG::ReadHandleKey< Trk::ClusterSplitProbabilityContainer > m_clusterSplitProbContainer
virtual Track * alignmentFit(AlignmentCache &, const Track &, const RunOutlierRemoval runOutlier=false, const ParticleHypothesis matEffects=Trk::nonInteracting) const override
Gaudi::Property< bool > m_extmat
ToolHandle< IRIO_OnTrackCreator > m_broadROTcreator
std::unique_ptr< GXFTrackState > makeTrackFindPerigee(const EventContext &, Cache &, GXFTrajectory &, const ParticleHypothesis) const
Gaudi::Property< bool > m_asymeloss
FitterStatusCode updateFitParameters(GXFTrajectory &, const Amg::VectorX &, const Amg::SymMatrixX &) const
Method to update peregee parameters, scattering angles, and brems.
void addMaterial(const EventContext &ctx, Cache &, GXFTrajectory &, const TrackParameters *, ParticleHypothesis) const
static void fillFirstLastMeasurement(Cache &cache, GXFTrajectory &trajectory)
Gaudi::Property< bool > m_storemat
PropagationResult calculateTrackParametersPropagateHelper(const EventContext &, const TrackParameters &, const GXFTrackState &, PropDirection, const MagneticFieldProperties &, bool, bool) const
Helper method that encapsulates calls to the propagator tool in the calculateTrackParameters() method...
ToolHandle< IUpdator > m_updator
std::array< std::atomic< unsigned int >, S_MAX_VALUE > m_fit_status ATLAS_THREAD_SAFE
const TrackingGeometry * retrieveTrackingGeometry(const EventContext &ctx) const
static void fillBfromMeasurements(const Cache &cache, GXFTrajectory &trajectory, Amg::VectorX &b)
std::unique_ptr< const TrackParameters > makeTrackFindPerigeeParameters(const EventContext &, Cache &, GXFTrajectory &, const ParticleHypothesis) const
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_field_cache_key
Gaudi::Property< bool > m_domeastrackpar
virtual int iterationsOfLastFit() const
Gaudi::Property< int > m_fixbrem
Track * backupCombinationStrategy(const EventContext &ctx, Cache &, const Track &, const Track &, GXFTrajectory &, std::vector< MaterialEffectsOnTrack > &) const
GlobalChi2Fitter(const std::string &, const std::string &, const IInterface *)
Track * mainCombinationStrategy(const EventContext &ctx, Cache &, const Track &, const Track &, GXFTrajectory &, std::vector< MaterialEffectsOnTrack > &) const
static void compensatePhiWeights(Cache &cache, GXFTrajectory &trajectory, Amg::SymMatrixX &a)
const TrackingGeometry * trackingGeometry(Cache &cache, const EventContext &ctx) const
Gaudi::Property< int > m_maxit
PropagationResult calculateTrackParametersPropagate(const EventContext &, const TrackParameters &, const GXFTrackState &, PropDirection, const MagneticFieldProperties &, bool, bool) const
Propagate onto a track state, collecting new track parameters, and optionally the Jacobian and possib...
ToolHandle< IExtrapolator > m_extrapolator
void makeProtoStateFromMeasurement(Cache &, GXFTrajectory &, const MeasurementBase *, const TrackParameters *trackpar=nullptr, bool isoutlier=false, int index=-1) const
std::optional< TransportJacobian > numericalDerivatives(const EventContext &ctx, const TrackParameters *, const Surface &, PropDirection, const MagneticFieldProperties &) const
void addIDMaterialFast(const EventContext &ctx, Cache &cache, GXFTrajectory &track, const TrackParameters *parameters, ParticleHypothesis part) const
A faster strategy for adding scatter material to tracks, works only for inner detector tracks.
static void fillAfromScatterers(GXFTrajectory &trajectory, Amg::SymMatrixX &a)
void updatePixelROTs(GXFTrajectory &, Amg::SymMatrixX &, Amg::VectorX &, const EventContext &evtctx) const
Update the Pixel ROT using the current trajectory/local track parameters.
Gaudi::Property< double > m_outlcut
Gaudi::Property< bool > m_calomat
Gaudi::Property< bool > m_fillderivmatrix
ToolHandle< IMaterialEffectsOnTrackProvider > m_calotoolparam
ToolHandle< IRIO_OnTrackCreator > m_ROTcreator
GXFTrajectory * runTrackCleanerSilicon(const EventContext &ctx, Cache &, GXFTrajectory &, Amg::SymMatrixX &, Amg::SymMatrixX &, Amg::VectorX &, bool) const
std::unique_ptr< const TrackParameters > makePerigee(Cache &, const TrackParameters &, const ParticleHypothesis) const
virtual std::unique_ptr< Track > fit(const EventContext &ctx, const PrepRawDataSet &, const TrackParameters &, const RunOutlierRemoval runOutlier=false, const ParticleHypothesis matEffects=nonInteracting) const override final
Gaudi::Property< double > m_chi2cut
void throwFailedToGetTrackingGeomtry() const
Gaudi::Property< bool > m_extensioncuts
virtual void setMinIterations(int)
bool ensureValidEntranceCalo(const EventContext &ctx, Cache &cache) const
static void addMaterialGetLayers(Cache &cache, std::vector< std::pair< const Layer *, const Layer * > > &layers, std::vector< std::pair< const Layer *, const Layer * > > &uplayers, const std::vector< std::unique_ptr< GXFTrackState > > &states, GXFTrackState &first, GXFTrackState &last, const TrackParameters *refpar, bool hasmat)
Collect all possible layers that a given track could have passed through.
static std::optional< std::pair< Amg::Vector3D, double > > addMaterialFindIntersectionCyl(Cache &cache, const CylinderSurface &surface, const TrackParameters &param1, const TrackParameters &param2, const ParticleHypothesis mat)
Find the intersection of a set of track parameters onto a cylindrical surface.
void runTrackCleanerTRT(Cache &, GXFTrajectory &, Amg::SymMatrixX &, Amg::VectorX &, Amg::SymMatrixX &, bool, bool, int, const EventContext &ctx) const
static void calculateDerivatives(GXFTrajectory &)
Gaudi::Property< bool > m_decomposesegments
void calculateTrackErrors(GXFTrajectory &, Amg::SymMatrixX &, bool) const
static bool correctAngles(double &, double &)
bool ensureValidEntranceMuonSpectrometer(const EventContext &ctx, Cache &cache) const
bool isMuonTrack(const Track &) const
std::vector< std::unique_ptr< TrackParameters > > holesearchExtrapolation(const EventContext &ctx, const TrackParameters &src, const GXFTrackState &dst, PropDirection propdir) const
Helper method which performs an extrapolation with additional logic for hole search.
virtual StatusCode finalize() override
Gaudi::Property< bool > m_useCaloTG
std::vector< std::reference_wrapper< GXFTrackState > > holeSearchStates(GXFTrajectory &trajectory) const
Extracts a collection of track states which are important for hole search.
Track * fitIm(const EventContext &ctx, Cache &cache, const Track &inputTrack, const RunOutlierRemoval runOutlier, const ParticleHypothesis matEffects) const
Gaudi::Property< bool > m_redoderivs
void initFieldCache(const EventContext &ctx, Cache &cache) const
Initialize a field cache inside a fit cache object.
Gaudi::Property< int > m_maxitPixelROT
ToolHandle< IMaterialEffectsOnTrackProvider > m_calotool
ToolHandle< IMaterialEffectsUpdator > m_matupdator
void holeSearchHelper(const std::vector< std::unique_ptr< TrackParameters > > &hc, std::set< Identifier > &id_set, std::set< Identifier > &sct_set, TrackHoleCount &rv, bool count_holes, bool count_dead) const
Helper method for the hole search that does the actual counting of holes and dead modules.
ToolHandle< IResidualPullCalculator > m_residualPullCalculator
void addMaterialUpdateTrajectory(Cache &cache, GXFTrajectory &track, int offset, std::vector< std::pair< const Layer *, const Layer * > > &layers, const TrackParameters *ref1, const TrackParameters *ref2, ParticleHypothesis mat) const
Given layer information, probe those layers for scatterers and add them to a track.
ToolHandle< IEnergyLossUpdator > m_elosstool
void fillDerivatives(GXFTrajectory &traj) const
Gaudi::Property< bool > m_numderiv
SG::ReadCondHandleKey< TrackingGeometry > m_trackingGeometryReadKey
Gaudi::Property< bool > m_kinkfinding
Gaudi::Property< bool > m_acceleration
static bool tryToWeightAfromMaterial(Cache &cache, GXFTrajectory &trajectory, Amg::SymMatrixX &a, const bool doDeriv, const int it, const double oldRedChi2, const double newRedChi2)
const AtlasDetectorID * m_DetID
static void fillAfromMeasurements(const Cache &cache, GXFTrajectory &trajectory, Amg::SymMatrixX &a)
virtual StatusCode initialize() override
static void makeTrackFillDerivativeMatrix(Cache &, GXFTrajectory &)
Gaudi::Property< bool > m_holeSearch
FitterStatusCode runIteration(const EventContext &ctx, Cache &cache, GXFTrajectory &trajectory, const int it, Amg::SymMatrixX &a, Amg::VectorX &b, Amg::SymMatrixX &lu, bool &doDeriv) const
Gaudi::Property< bool > m_createSummary
Track * myfit_helper(Cache &, GXFTrajectory &, const TrackParameters &, const RunOutlierRemoval runOutlier=false, const ParticleHypothesis matEffects=nonInteracting) const
Gaudi::Property< int > m_miniter
ToolHandle< IMultipleScatteringUpdator > m_scattool
Gaudi::Property< double > m_minphfcut
Gaudi::Property< bool > m_getmaterialfromtrack
Base Class for a Detector Layer in the Tracking realm.
Definition Layer.h:72
magnetic field properties to steer the behavior of the extrapolation
represents the full description of deflection and e-loss of a track in material.
Class implementing a comparison function for sorting MeasurementBase objects.
This class is the pure abstract base class for all fittable tracking measurements.
Class providing comparison function, or relational definition, for PrepRawData.
Abstract Base Class for tracking surfaces.
represents the track state (measurement, material, fit parameters and quality) at a surface.
The TrackingGeometry class is the owner of the constructed TrackingVolumes.
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
Base class for all volumes inside the tracking realm, it defines the interface for inherited Volume c...
Definition Volume.h:36
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > SymMatrixX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Ensure that the ATLAS eigen extensions are properly loaded.
PropDirection
PropDirection, enum for direction of the propagation.
std::vector< const MeasurementBase * > MeasurementSet
vector of fittable measurements
Definition FitterTypes.h:30
bool RunOutlierRemoval
switch to toggle quality processing after fit
Definition FitterTypes.h:22
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters
std::vector< const PrepRawData * > PrepRawDataSet
vector of clusters and drift circles
Definition FitterTypes.h:26
Perigee MeasuredPerigee
Definition index.py:1
std::vector< std::unique_ptr< const std::vector< const TrackStateOnSurface * >, void(*)(const std::vector< const TrackStateOnSurface * > *) > > m_matTempStore
void incrementFitStatus(enum FitterStatusType status)
std::vector< const Trk::Layer * > m_posdiscs
std::vector< int > m_lastmeasurement
std::vector< const Trk::Layer * > m_negdiscs
std::vector< const Trk::Layer * > m_barrelcylinders
MagField::AtlasFieldCache m_field_cache
static void objVectorDeleter(const std::vector< const T * > *ptr)
std::vector< int > m_firstmeasurement
std::array< std::atomic< unsigned int >, S_MAX_VALUE > * m_fit_status_out
std::array< unsigned int, S_MAX_VALUE > m_fit_status
std::vector< double > m_phiweight
const TrackingVolume * m_msEntrance
const TrackingGeometry * m_trackingGeometry
Cache(const GlobalChi2Fitter *fitter)
const TrackingVolume * m_caloEntrance
Cache & operator=(const Cache &)=delete
std::optional< TransportJacobian > m_jacobian
std::optional< std::vector< std::unique_ptr< TrackParameters > > > m_preholes
std::unique_ptr< const TrackParameters > m_parameters