From a60de1a9c962df122d831adab37916b931a3d1e1 Mon Sep 17 00:00:00 2001 From: Tobias Boeckh <tobias.boeckh@cern.ch> Date: Fri, 13 May 2022 17:53:34 +0200 Subject: [PATCH] WIP cleanup code for merge request --- .../FaserActsKalmanFilter/CKF2.h | 1 + .../CombinatorialKalmanFilterAlg.h | 1 + .../FaserActsKalmanFilter/KalmanFitterTool.h | 13 +++- .../RootTrajectoryStatesWriterTool.h | 1 + .../ThreeStationTrackSeedTool.h | 1 + .../python/CKF2Config.py | 55 +++++++-------- .../python/CombinatorialKalmanFilterConfig.py | 12 ++-- .../Acts/FaserActsKalmanFilter/src/CKF2.cxx | 32 ++++++++- .../src/KalmanFitterTool.cxx | 69 +++++++++++-------- .../src/RootTrajectorySummaryWriterTool.cxx | 2 + .../Acts/FaserActsKalmanFilter/test/CKF2.py | 2 +- .../test/CombinatorialKalmanFilterAlg.py | 4 +- 12 files changed, 122 insertions(+), 71 deletions(-) diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CKF2.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CKF2.h index 721fda62..98d6139d 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CKF2.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CKF2.h @@ -152,3 +152,4 @@ private: }; #endif // FASERACTSKALMANFILTER_CKF2_H + diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h index 3044a2fc..b6f33a19 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h @@ -130,3 +130,4 @@ public: }; #endif // COMBINATORIALKALMANFILTERALG_H + diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/KalmanFitterTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/KalmanFitterTool.h index a88d8b95..1ded1200 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/KalmanFitterTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/KalmanFitterTool.h @@ -40,19 +40,25 @@ public: std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry); virtual Acts::MagneticFieldContext getMagneticFieldContext(const EventContext& ctx) const; - std::unique_ptr<Trk::Track> fit(const EventContext& ctx, const Trk::Track& inputTrack, const Acts::BoundVector& params, - std::vector<FaserActsRecMultiTrajectory> &trajectories, double charge) const; + std::unique_ptr<Trk::Track> fit(const EventContext& ctx, const Trk::Track& inputTrack, + std::vector<FaserActsRecMultiTrajectory> &trajectories, double charge, + const Acts::BoundVector& inputVector) const; private: const FaserSCT_ID* m_idHelper {nullptr}; std::tuple<std::vector<IndexSourceLink>, std::vector<Measurement>> getMeasurementsFromTrack(const Trk::Track &track) const; - Acts::BoundTrackParameters getParametersFromTrack(const Acts::BoundVector& params, const Trk::TrackParameters *inputParameters) const; + // Acts::BoundTrackParameters getParametersFromTrack(const Acts::BoundVector& params, const Trk::TrackParameters *inputParameters) const; + Acts::BoundTrackParameters getParametersFromTrack(const Trk::TrackParameters *inputParameters, double charge, + const Acts::BoundVector& inputVector) const; std::shared_ptr<TrackFitterFunction> m_fit; std::unique_ptr<const Acts::Logger> m_logger; Gaudi::Property<std::string> m_actsLogging {this, "ActsLogging", "VERBOSE"}; Gaudi::Property<std::size_t> m_minMeasurements {this, "MinMeasurements", 12, "minimum number of measurements of the input track"}; Gaudi::Property<double> m_seedCovarianceScale {this, "SeedCovarianceScale", 100, "scale covariance from initial track"}; + Gaudi::Property<bool> m_isMC {this, "isMC", false}; + Gaudi::Property<bool> m_summaryWriter {this, "SummaryWriter", false}; + Gaudi::Property<bool> m_statesWriter {this, "StatesWriter", false}; SG::ReadCondHandleKey<FaserFieldCacheCondObj> m_fieldCondObjInputKey {this, "FaserFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; ToolHandle<IFaserActsTrackingGeometryTool> m_trackingGeometryTool {this, "TrackingGeometryTool", "FaserActsTrackingGeometryTool"}; @@ -63,3 +69,4 @@ private: }; #endif //FASERACTSKALMANFILTER_KALMANFITTERTOOL_H + diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/RootTrajectoryStatesWriterTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/RootTrajectoryStatesWriterTool.h index 280762a8..60ed86e7 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/RootTrajectoryStatesWriterTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/RootTrajectoryStatesWriterTool.h @@ -127,3 +127,4 @@ private: }; #endif // FASERACTSKALMANFILTER_ROOTTRAJECTORYSTATESWRITERTOOL_H + diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ThreeStationTrackSeedTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ThreeStationTrackSeedTool.h index 46dce197..15d20cdf 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ThreeStationTrackSeedTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ThreeStationTrackSeedTool.h @@ -126,3 +126,4 @@ ThreeStationTrackSeedTool::spacePoints() const { } #endif // FASERACTSKALMANFILTER_THREESTATIONTRACKSEEDTOOL_H + diff --git a/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Config.py b/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Config.py index 3a15dc2f..a912f035 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Config.py +++ b/Tracking/Acts/FaserActsKalmanFilter/python/CKF2Config.py @@ -35,9 +35,9 @@ def CKF2Cfg(flags, **kwargs): acc.merge(acts_tracking_geometry_svc ) # track_seed_tool = CompFactory.ClusterTrackSeedTool() -# track_seed_tool = CompFactory.ThreeStationTrackSeedTool() + track_seed_tool = CompFactory.ThreeStationTrackSeedTool() # track_seed_tool = CompFactory.ActsTrackSeedTool() - track_seed_tool = CompFactory.MyTrackSeedTool() + # track_seed_tool = CompFactory.MyTrackSeedTool() sigma_loc0 = 1.9e-2 sigma_loc1 = 9e-1 sigma_phi = 3.3e-2 @@ -58,24 +58,12 @@ def CKF2Cfg(flags, **kwargs): track_seed_writer_tool = CompFactory.TrackSeedWriterTool() track_seed_writer_tool.FilePath = "TrackSeeds.root" - trajectory_states_writer_tool = CompFactory.RootTrajectoryStatesWriterTool() - trajectory_states_writer_tool.MC = True + # trajectory_states_writer_tool = CompFactory.RootTrajectoryStatesWriterTool() + # trajectory_states_writer_tool1 = CompFactory.RootTrajectoryStatesWriterTool() + # trajectory_states_writer_tool1.FilePath = "track_states_ckf1.root" + # trajectory_states_writer_tool2 = CompFactory.RootTrajectoryStatesWriterTool() + # trajectory_states_writer_tool2.FilePath = "track_states_ckf2.root" - trajectory_states_writer_tool1 = CompFactory.RootTrajectoryStatesWriterTool() - trajectory_states_writer_tool1.FilePath = "track_states_ckf1.root" - trajectory_states_writer_tool1.MC = True - - trajectory_states_writer_tool2 = CompFactory.RootTrajectoryStatesWriterTool() - trajectory_states_writer_tool2.FilePath = "track_states_ckf2.root" - trajectory_states_writer_tool2.MC = True - - trajectory_summary_writer_tool = CompFactory.RootTrajectorySummaryWriterTool() - - trajectory_summary_writer_tool1 = CompFactory.RootTrajectorySummaryWriterTool() - trajectory_summary_writer_tool1.FilePath = "track_summary_ckf1.root" - - trajectory_summary_writer_tool2 = CompFactory.RootTrajectorySummaryWriterTool() - trajectory_summary_writer_tool2.FilePath = "track_summary_ckf2.root" actsExtrapolationTool = CompFactory.FaserActsExtrapolationTool("FaserActsExtrapolationTool") actsExtrapolationTool.MaxSteps = 1000 @@ -83,24 +71,33 @@ def CKF2Cfg(flags, **kwargs): performance_writer_tool = CompFactory.PerformanceWriterTool("PerformanceWriterTool") performance_writer_tool.ExtrapolationTool = actsExtrapolationTool - kalman_fitter1 = CompFactory.KalmanFitterTool() + ckf = CompFactory.CKF2(**kwargs) + kalman_fitter1 = CompFactory.KalmanFitterTool(name="fitterTool1", **kwargs) kalman_fitter1.ActsLogging = "INFO" - kalman_fitter1.SeedCovarianceScale = 100 - kalman_fitter1.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool1 + kalman_fitter1.SummaryWriter = True + # kalman_fitter1.StatesWriter = True + kalman_fitter1.SeedCovarianceScale = 10 + # kalman_fitter1.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool1 + trajectory_summary_writer_tool1 = CompFactory.RootTrajectorySummaryWriterTool() + trajectory_summary_writer_tool1.FilePath = "track_summary_ckf1.root" kalman_fitter1.RootTrajectorySummaryWriterTool = trajectory_summary_writer_tool1 + ckf.KalmanFitterTool1 = kalman_fitter1 - kalman_fitter2 = CompFactory.KalmanFitterTool() + kalman_fitter2 = CompFactory.KalmanFitterTool(name="fitterTool2", **kwargs) kalman_fitter2.ActsLogging = "INFO" - kalman_fitter2.SeedCovarianceScale = 10 - kalman_fitter2.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool2 + kalman_fitter2.SummaryWriter = True + # kalman_fitter2.StatesWriter = True + kalman_fitter2.SeedCovarianceScale = 1 + # kalman_fitter2.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool2 + trajectory_summary_writer_tool2 = CompFactory.RootTrajectorySummaryWriterTool(**kwargs) + trajectory_summary_writer_tool2.FilePath = "track_summary_ckf2.root" kalman_fitter2.RootTrajectorySummaryWriterTool = trajectory_summary_writer_tool2 - - ckf = CompFactory.CKF2(**kwargs) - ckf.KalmanFitterTool1 = kalman_fitter1 ckf.KalmanFitterTool2 = kalman_fitter2 + ckf.TrackSeed = track_seed_tool ckf.ActsLogging = "INFO" - ckf.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool + # ckf.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool + trajectory_summary_writer_tool = CompFactory.RootTrajectorySummaryWriterTool(**kwargs) ckf.RootTrajectorySummaryWriterTool = trajectory_summary_writer_tool ckf.PerformanceWriterTool = performance_writer_tool ckf.nTrajectories = 1 diff --git a/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py b/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py index edf1e5b8..6c76a8a5 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py +++ b/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py @@ -35,9 +35,9 @@ def CombinatorialKalmanFilterCfg(flags, **kwargs): acc.merge(acts_tracking_geometry_svc ) # track_seed_tool = CompFactory.ClusterTrackSeedTool() - # track_seed_tool = CompFactory.ThreeStationTrackSeedTool() + track_seed_tool = CompFactory.ThreeStationTrackSeedTool() # track_seed_tool = CompFactory.ActsTrackSeedTool() - track_seed_tool = CompFactory.MyTrackSeedTool() + # track_seed_tool = CompFactory.MyTrackSeedTool() sigma_loc0 = 1.9e-2 sigma_loc1 = 9e-1 sigma_phi = 3.3e-2 @@ -46,8 +46,8 @@ def CombinatorialKalmanFilterCfg(flags, **kwargs): sigma_p = 0.1 * p sigma_qop = sigma_p / (p * p) initial_variance_inflation = [100, 100, 100, 100, 1000] - track_seed_tool.covLoc0 = initial_variance_inflation[0] * sigma_loc1 * sigma_loc1 - track_seed_tool.covLoc1 = initial_variance_inflation[1] * sigma_loc0 * sigma_loc0 + track_seed_tool.covLoc0 = initial_variance_inflation[0] * sigma_loc0 * sigma_loc0 + track_seed_tool.covLoc1 = initial_variance_inflation[1] * sigma_loc1 * sigma_loc1 track_seed_tool.covPhi = initial_variance_inflation[2] * sigma_phi * sigma_phi track_seed_tool.covTheta = initial_variance_inflation[3] * sigma_theta * sigma_theta track_seed_tool.covQOverP = initial_variance_inflation[4] * sigma_qop * sigma_qop @@ -70,13 +70,13 @@ def CombinatorialKalmanFilterCfg(flags, **kwargs): ckf = CompFactory.CombinatorialKalmanFilterAlg(**kwargs) ckf.TrackSeed = track_seed_tool - ckf.ActsLogging = "VERBOSE" + ckf.ActsLogging = "INFO" ckf.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool ckf.RootTrajectorySummaryWriterTool = trajectory_summary_writer_tool ckf.PerformanceWriterTool = performance_writer_tool ckf.nMax = 10 - ckf.chi2Max = 75 + ckf.chi2Max = 25 acc.addEventAlgo(ckf) acc.merge(CombinatorialKalmanFilter_OutputCfg(flags)) return acc diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx index 50c6843a..7c75857d 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/CKF2.cxx @@ -49,8 +49,12 @@ StatusCode CKF2::initialize() { ATH_CHECK(m_trackingGeometryTool.retrieve()); ATH_CHECK(m_trackSeedTool.retrieve()); ATH_CHECK(m_trackSeedWriterTool.retrieve()); + std::cout << "?? retrieve m_kalmanFitterTool1.\n"; ATH_CHECK(m_kalmanFitterTool1.retrieve()); + std::cout << "done.\n"; + std::cout << "?? retrieve m_kalmanFitterTool2.\n"; ATH_CHECK(m_kalmanFitterTool2.retrieve()); + std::cout << "done.\n"; // ATH_CHECK(m_trackCollection.initialize()); if (m_performanceWriter) { ATH_CHECK(m_performanceWriterTool.retrieve()); @@ -277,6 +281,27 @@ StatusCode CKF2::execute() { }); } + for (const FaserActsRecMultiTrajectory &traj : selectedTrajectories) { + const auto params = traj.trackParameters(traj.tips().front()); + ATH_MSG_DEBUG("Fitted parameters"); + ATH_MSG_DEBUG(" params: " << params.parameters().transpose()); + ATH_MSG_DEBUG(" position: " << params.position(geoctx).transpose()); + ATH_MSG_DEBUG(" momentum: " << params.momentum().transpose()); + ATH_MSG_DEBUG(" charge: " << params.charge()); + double charge = params.charge(); + std::unique_ptr<Trk::Track> track = makeTrack(geoctx, traj); + if (track) { + // outputTracks->push_back(std::move(track)); + std::unique_ptr<Trk::Track> track2 = m_kalmanFitterTool1->fit(ctx, *track, trajectories, charge, Acts::BoundVector::Zero()); + if (track2) { + std::unique_ptr<Trk::Track> track3 = m_kalmanFitterTool2->fit(ctx, *track2, trajectories, charge, Acts::BoundVector::Zero()); + outputTracks->push_back(std::move(track3)); + } + } + } + + + /* // create Trk::Tracks from the trajectories for (const FaserActsRecMultiTrajectory &traj : selectedTrajectories) { @@ -355,6 +380,7 @@ StatusCode CKF2::execute() { } } } + */ /* @@ -410,14 +436,14 @@ StatusCode CKF2::execute() { */ if (m_statesWriter) { - ATH_CHECK(m_trajectoryStatesWriterTool->write(geoctx, trajectories)); + ATH_CHECK(m_trajectoryStatesWriterTool->write(geoctx, selectedTrajectories)); } if (m_summaryWriter) { ATH_MSG_DEBUG("?? write trajectories"); - ATH_CHECK(m_trajectorySummaryWriterTool->write(geoctx, trajectories)); + ATH_CHECK(m_trajectorySummaryWriterTool->write(geoctx, selectedTrajectories)); } if (m_performanceWriter) { - ATH_CHECK(m_performanceWriterTool->write(geoctx, trajectories)); + ATH_CHECK(m_performanceWriterTool->write(geoctx, selectedTrajectories)); } ATH_CHECK(trackContainer.record(std::move(outputTracks))); diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/KalmanFitterTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/KalmanFitterTool.cxx index 77392f87..2855c03c 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/KalmanFitterTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/KalmanFitterTool.cxx @@ -13,15 +13,15 @@ KalmanFitterTool::KalmanFitterTool(const std::string& type, const std::string& name, const IInterface* parent) : -AthAlgTool(type, name, parent) {} + AthAlgTool(type, name, parent) {} StatusCode KalmanFitterTool::initialize() { - ATH_CHECK(m_fieldCondObjInputKey.initialize()); - ATH_CHECK(m_trackingGeometryTool.retrieve()); - ATH_CHECK(m_trajectoryStatesWriterTool.retrieve()); - ATH_CHECK(m_trajectorySummaryWriterTool.retrieve()); - ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); + ATH_CHECK(m_fieldCondObjInputKey.initialize()); + ATH_CHECK(m_trackingGeometryTool.retrieve()); + ATH_CHECK(m_trajectoryStatesWriterTool.retrieve()); + ATH_CHECK(m_trajectorySummaryWriterTool.retrieve()); + ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); m_fit = makeTrackFitterFunction(m_trackingGeometryTool->trackingGeometry()); if (m_actsLogging == "VERBOSE") { m_logger = Acts::getDefaultLogger("KalmanFitter", Acts::Logging::VERBOSE); @@ -39,8 +39,10 @@ StatusCode KalmanFitterTool::finalize() { } std::unique_ptr<Trk::Track> -KalmanFitterTool::fit(const EventContext &ctx, const Trk::Track &inputTrack, const Acts::BoundVector& params, - std::vector<FaserActsRecMultiTrajectory> &trajectories, double charge) const { +KalmanFitterTool::fit(const EventContext &ctx, const Trk::Track &inputTrack, + std::vector<FaserActsRecMultiTrajectory> &trajectories, double charge, + const Acts::BoundVector& inputVector = Acts::BoundVector::Zero()) const { + std::cout << "?? scale: " << m_seedCovarianceScale << std::endl; std::unique_ptr<Trk::Track> newTrack = nullptr; std::vector<FaserActsRecMultiTrajectory> myTrajectories; @@ -54,7 +56,8 @@ KalmanFitterTool::fit(const EventContext &ctx, const Trk::Track &inputTrack, con return nullptr; } - auto pSurface = Acts::Surface::makeShared<Acts::PlaneSurface>( + + auto pSurface = Acts::Surface::makeShared<Acts::PlaneSurface>( Acts::Vector3 {0, 0, 0}, Acts::Vector3{0, 0, -1}); Acts::GeometryContext gctx = m_trackingGeometryTool->getNominalGeometryContext().context(); @@ -62,15 +65,15 @@ KalmanFitterTool::fit(const EventContext &ctx, const Trk::Track &inputTrack, con Acts::CalibrationContext calibContext = Acts::CalibrationContext(); auto [sourceLinks, measurements] = getMeasurementsFromTrack(inputTrack); - auto trackParameters = getParametersFromTrack(params, inputTrack.trackParameters()->front()); + auto trackParameters = getParametersFromTrack(inputTrack.trackParameters()->front(), charge, inputVector); ATH_MSG_DEBUG("trackParameters: " << trackParameters.parameters().transpose()); ATH_MSG_DEBUG("position: " << trackParameters.parameters().transpose()); ATH_MSG_DEBUG("momentum: " << trackParameters.momentum().transpose()); Acts::KalmanFitterOptions<MeasurementCalibrator, Acts::VoidOutlierFinder, Acts::VoidReverseFilteringLogic> kfOptions(gctx, mfContext, calibContext, MeasurementCalibrator(measurements), - Acts::VoidOutlierFinder(), Acts::VoidReverseFilteringLogic(), Acts::LoggerWrapper{*m_logger}, - Acts::PropagatorPlainOptions(), &(*pSurface)); + Acts::VoidOutlierFinder(), Acts::VoidReverseFilteringLogic(), Acts::LoggerWrapper{*m_logger}, + Acts::PropagatorPlainOptions(), &(*pSurface)); kfOptions.multipleScattering = false; kfOptions.energyLoss = false; @@ -92,12 +95,12 @@ KalmanFitterTool::fit(const EventContext &ctx, const Trk::Track &inputTrack, con std::vector<size_t> trackTips; trackTips.reserve(1); trackTips.emplace_back(fitOutput.lastMeasurementIndex); - trajectories.emplace_back(std::move(fitOutput.fittedStates), - std::move(trackTips), - std::move(indexedParams)); + // trajectories.emplace_back(std::move(fitOutput.fittedStates), + // std::move(trackTips), + // std::move(indexedParams)); myTrajectories.emplace_back(std::move(fitOutput.fittedStates), - std::move(trackTips), - std::move(indexedParams)); + std::move(trackTips), + std::move(indexedParams)); } else { ATH_MSG_DEBUG("No fitted parameters for track"); } @@ -105,8 +108,13 @@ KalmanFitterTool::fit(const EventContext &ctx, const Trk::Track &inputTrack, con } ATH_MSG_DEBUG("?? running states writer " << m_trajectoryStatesWriterTool.name() << " " << m_trajectoryStatesWriterTool.propertyName()); - StatusCode statusStatesWriterTool = m_trajectoryStatesWriterTool->write(gctx, myTrajectories); - StatusCode statusSummaryWriterToll = m_trajectorySummaryWriterTool->write(gctx, myTrajectories); + if (m_statesWriter) { + StatusCode statusStatesWriterTool = m_trajectoryStatesWriterTool->write(gctx, myTrajectories); + } + if (m_summaryWriter) { + std::cout << "?? summary Writer KalmanFitterTool\n"; + StatusCode statusSummaryWriterTool = m_trajectorySummaryWriterTool->write(gctx, myTrajectories); + } return newTrack; } @@ -198,7 +206,8 @@ KalmanFitterTool::getMeasurementsFromTrack(const Trk::Track &track) const { Acts::BoundTrackParameters -KalmanFitterTool::getParametersFromTrack(const Acts::BoundVector& params, const Trk::TrackParameters *inputParameters) const { +KalmanFitterTool::getParametersFromTrack(const Trk::TrackParameters *inputParameters, double charge, + const Acts::BoundVector& inputVector) const { using namespace Acts::UnitLiterals; std::shared_ptr<const Acts::Surface> pSurface = Acts::Surface::makeShared<Acts::PlaneSurface>( Acts::Vector3 {0, 0, 0}, Acts::Vector3{0, 0, -1}); @@ -209,13 +218,17 @@ KalmanFitterTool::getParametersFromTrack(const Acts::BoundVector& params, const // atlasParam[Trk::phi0], atlasParam[Trk::theta], // charge / (inputParameters->momentum().norm() * 1_MeV), // 0.}; - // Acts::BoundVector params; - // params(0.0) = center[Trk::locY]; - // params(1.0) = center[Trk::locX]; - // params(2.0) = atlasParam[Trk::phi0]; - // params(3.0) = atlasParam[Trk::theta]; - // params(4.0) = charge / (inputParameters->momentum().norm() * 1_MeV); - // params(5.0) = 0.; + Acts::BoundVector params; + if (inputVector == Acts::BoundVector::Zero()) { + params(0.0) = center[Trk::locY]; + params(1.0) = center[Trk::locX]; + params(2.0) = atlasParam[Trk::phi0]; + params(3.0) = atlasParam[Trk::theta]; + params(4.0) = charge / (inputParameters->momentum().norm() * 1_MeV); + params(5.0) = 0.; + } else { + params = inputVector; + } Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Identity(); cov.topLeftCorner(5, 5) = *inputParameters->covariance(); @@ -236,7 +249,7 @@ KalmanFitterTool::getParametersFromTrack(const Acts::BoundVector& params, const std::unique_ptr<Trk::Track> KalmanFitterTool::makeTrack(Acts::GeometryContext& geoCtx, TrackFitterResult& fitResult) const { using ConstTrackStateProxy = - Acts::detail_lt::TrackStateProxy<IndexSourceLink, 6, true>; + Acts::detail_lt::TrackStateProxy<IndexSourceLink, 6, true>; std::unique_ptr<Trk::Track> newtrack = nullptr; //Get the fit output object const auto& fitOutput = fitResult.value(); diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectorySummaryWriterTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectorySummaryWriterTool.cxx index e3251a80..15a955ff 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectorySummaryWriterTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectorySummaryWriterTool.cxx @@ -42,6 +42,8 @@ StatusCode RootTrajectorySummaryWriterTool::initialize() { if (m_outputFile == nullptr) { ATH_MSG_WARNING("Unable to open output file at " << m_filePath); return StatusCode::RECOVERABLE; + } else { + std::cout << "(SummaryWriter) create file " << filePath << std::endl; } m_outputFile->cd(); m_outputTree = new TTree(treeName.c_str(), treeName.c_str()); diff --git a/Tracking/Acts/FaserActsKalmanFilter/test/CKF2.py b/Tracking/Acts/FaserActsKalmanFilter/test/CKF2.py index 19aa1d7f..e040b01b 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/test/CKF2.py +++ b/Tracking/Acts/FaserActsKalmanFilter/test/CKF2.py @@ -43,5 +43,5 @@ acc.getEventAlgo("CKF2").OutputLevel = VERBOSE # acc.printConfig(withDetails=True) # ConfigFlags.dump() -sc = acc.run(maxEvents=-1) +sc = acc.run(maxEvents=500) sys.exit(not sc.isSuccess()) diff --git a/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py b/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py index 8ab0ceff..56bd49e6 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py +++ b/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py @@ -9,6 +9,7 @@ from CalypsoConfiguration.MainServicesConfig import MainServicesCfg from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg # from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg from TrackerSegmentFit.TrackerSegmentFitConfig import SegmentFitAlgCfg from FaserActsKalmanFilter.CombinatorialKalmanFilterConfig import CombinatorialKalmanFilterCfg @@ -29,6 +30,7 @@ acc.merge(PoolReadCfg(ConfigFlags)) # acc.merge(PoolWriteCfg(ConfigFlags)) acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) acc.merge(SegmentFitAlgCfg(ConfigFlags, SharedHitFraction=0.51, MinClustersPerFit=5, TanThetaCut=0.25)) acc.merge(CombinatorialKalmanFilterCfg(ConfigFlags)) acc.getEventAlgo("CombinatorialKalmanFilterAlg").OutputLevel = VERBOSE @@ -41,5 +43,5 @@ acc.getEventAlgo("CombinatorialKalmanFilterAlg").OutputLevel = VERBOSE # acc.printConfig(withDetails=True) # ConfigFlags.dump() -sc = acc.run(maxEvents=-1) +sc = acc.run(maxEvents=100) sys.exit(not sc.isSuccess()) -- GitLab