diff --git a/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt b/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt index a0966bbbca735e11fe8d9e46ef5f24ce33914c59..a9b281c3cc9e12bf9911aeeb3d163a1e102929f6 100755 --- a/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt +++ b/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt @@ -29,6 +29,8 @@ atlas_add_component(FaserActsKalmanFilter FaserActsKalmanFilter/IdentifierLink.h FaserActsKalmanFilter/IndexSourceLink.h FaserActsKalmanFilter/ITrackFinderTool.h + FaserActsKalmanFilter/ITrackSeedTool.h + FaserActsKalmanFilter/ClusterTrackSeedTool.h # FaserActsKalmanFilter/TruthTrackFinderTool.h FaserActsKalmanFilter/Measurement.h FaserActsKalmanFilter/MultiTrackFinderTool.h @@ -42,7 +44,8 @@ atlas_add_component(FaserActsKalmanFilter # FaserActsKalmanFilter/ProtoTrackWriterTool.h FaserActsKalmanFilter/TruthBasedInitialParameterTool.h # FaserActsKalmanFilter/TruthSeededTrackFinderTool.h - src/CombinatorialKalmbanFilterAlg.cxx + src/ClusterTrackSeedTool.cxx + src/CombinatorialKalmanFilterAlg.cxx src/FaserActsKalmanFilterAlg.cxx src/MultiTrackFinderTool.cxx src/RootTrajectoryStatesWriterTool.cxx diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ClusterTrackSeedTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ClusterTrackSeedTool.h new file mode 100644 index 0000000000000000000000000000000000000000..ffd2cc73ab06bb1377085b550533b08bc284e8f6 --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ClusterTrackSeedTool.h @@ -0,0 +1,96 @@ +#ifndef FASERACTSKALMANFILTER_CLUSTERTRACKFINDERTOOL_H +#define FASERACTSKALMANFILTER_CLUSTERTRACKFINDERTOOL_H + +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "AthenaBaseComps/AthAlgTool.h" +#include "Gaudi/Property.h" +#include "GaudiKernel/IInterface.h" +#include "GaudiKernel/StatusCode.h" + +#include "FaserActsGeometryInterfaces/IFaserActsTrackingGeometryTool.h" +#include "FaserActsKalmanFilter/ITrackSeedTool.h" +#include "TrkTrack/TrackCollection.h" +#include <memory> +#include <string> +#include <vector> + +class FaserSCT_ID; +namespace TrackerDD { class SCT_DetectorManager; } + +class ClusterTrackSeedTool : public extends<AthAlgTool, ITrackSeedTool> { +public: + ClusterTrackSeedTool(const std::string& type, const std::string& name, const IInterface* parent); + virtual ~ClusterTrackSeedTool() = default; + virtual StatusCode initialize() override; + virtual StatusCode finalize() override; + virtual StatusCode run() override; + + const std::shared_ptr<std::vector<Acts::CurvilinearTrackParameters>> initialTrackParameters() const override; + const std::shared_ptr<const Acts::Surface> initialSurface() const override; + const std::shared_ptr<std::vector<IndexSourceLink>> sourceLinks() const override; + const std::shared_ptr<IdentifierLink> idLinks() const override; + const std::shared_ptr<std::vector<Measurement>> measurements() const override; + const std::shared_ptr<std::vector<const Tracker::FaserSCT_Cluster*>> clusters() const override; + +private: + std::shared_ptr<std::vector<Acts::CurvilinearTrackParameters>> m_initialTrackParameters; + std::shared_ptr<const Acts::Surface> m_initialSurface; + std::shared_ptr<std::vector<IndexSourceLink>> m_sourceLinks {}; + std::shared_ptr<IdentifierLink> m_idLinks {}; + std::shared_ptr<std::vector<Measurement>> m_measurements {}; + std::shared_ptr<std::vector<const Tracker::FaserSCT_Cluster*>> m_clusters {}; + + const FaserSCT_ID* m_idHelper {nullptr}; + const TrackerDD::SCT_DetectorManager* m_detManager {nullptr}; + + ToolHandle<IFaserActsTrackingGeometryTool> m_trackingGeometryTool { + this, "TrackingGeometryTool", "FaserActsTrackingGeometryTool"}; + SG::ReadHandleKey<TrackCollection> m_trackCollection { + this, "TrackCollection", "SegmentFit", "Input track collection name" }; + SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_clusterContainerKey { + this, "ClusterContainer", "SCT_ClusterContainer"}; + + // position resolution of a cluster + Gaudi::Property<double> m_std_cluster {this, "std_cluster", 0.04}; + + // covariance of the initial parameters + Gaudi::Property<double> m_covLoc0 {this, "covLoc0", 1}; + Gaudi::Property<double> m_covLoc1 {this, "covLoc1", 1}; + Gaudi::Property<double> m_covPhi {this, "covPhi", 1}; + Gaudi::Property<double> m_covTheta {this, "covTheta", 1}; + Gaudi::Property<double> m_covQOverP {this, "covQOverP", 1}; + Gaudi::Property<double> m_covTime {this, "covTime", 1}; +}; + +inline const std::shared_ptr<std::vector<Acts::CurvilinearTrackParameters>> +ClusterTrackSeedTool::initialTrackParameters() const { + return m_initialTrackParameters; +} + +inline const std::shared_ptr<const Acts::Surface> +ClusterTrackSeedTool::initialSurface() const { + return m_initialSurface; +} + +inline const std::shared_ptr<std::vector<IndexSourceLink>> +ClusterTrackSeedTool::sourceLinks() const { + return m_sourceLinks; +} + +inline const std::shared_ptr<IdentifierLink> +ClusterTrackSeedTool::idLinks() const { + return m_idLinks; +} + +inline const std::shared_ptr<std::vector<Measurement>> +ClusterTrackSeedTool::measurements() const { + return m_measurements; +} + +inline const std::shared_ptr<std::vector<const Tracker::FaserSCT_Cluster*>> +ClusterTrackSeedTool::clusters() const { + return m_clusters; +} + + +#endif // FASERACTSKALMANFILTER_CLUSTERTRACKFINDERTOOL_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h index 4b750614a3f496a9cabef0352c223d9b9e5a9658..6997b964d80c7e66c499a0149f31757cc245cc5e 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h @@ -2,6 +2,7 @@ #define COMBINATORIALKALMANFILTERALG_H #include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "AthenaBaseComps/AthAlgorithm.h" #include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" #include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" #include "FaserActsGeometryInterfaces/IFaserActsTrackingGeometryTool.h" @@ -14,70 +15,74 @@ #include "MagFieldConditions/FaserFieldCacheCondObj.h" #include "FaserActsKalmanFilter/TrajectoryWriterTool.h" #include "TrkTrack/TrackCollection.h" +#include "FaserActsKalmanFilter/ITrackSeedTool.h" +#include "FaserActsKalmanFilter/RootTrajectoryStatesWriterTool.h" class FaserSCT_ID; -namespace Trk -{ +namespace Trk { class TrackStateOnSurface; } namespace TrackerDD { - class SCT_DetectorManager; +class SCT_DetectorManager; } -class CombinatorialKalmanFilterAlg : public AthReentrantAlgorithm { - public: +class CombinatorialKalmanFilterAlg : public AthAlgorithm { +public: CombinatorialKalmanFilterAlg(const std::string& name, ISvcLocator* pSvcLocator); virtual ~CombinatorialKalmanFilterAlg() = default; StatusCode initialize() override; - StatusCode execute(const EventContext& ctx) const override; + StatusCode execute() override; StatusCode finalize() override; using TrackFinderOptions = - Acts::CombinatorialKalmanFilterOptions<IndexSourceLinkAccessor, MeasurementCalibrator, Acts::MeasurementSelector>; - using FitterResult = Acts::Result<Acts::CombinatorialKalmanFilterResult<IndexSourceLink>>; - using TrackFinderResult = std::vector<FitterResult>; -// using TrackFinderResult = std::vector< -// Acts::Result<Acts::CombinatorialKalmanFilterResult<IndexSourceLink>>>; - using TrackFinderFunction = std::function<TrackFinderResult( - const IndexSourceLinkContainer&, const std::vector<Acts::CurvilinearTrackParameters>&, - const TrackFinderOptions&)>; + Acts::CombinatorialKalmanFilterOptions<IndexSourceLinkAccessor, + MeasurementCalibrator, + Acts::MeasurementSelector>; + using TrackFitterResult = + Acts::Result<Acts::CombinatorialKalmanFilterResult<IndexSourceLink>>; + using TrackFinderResult = std::vector<TrackFitterResult>; + using TrackParameters = Acts::CurvilinearTrackParameters; + using TrackParametersContainer = std::vector<TrackParameters>; - static TrackFinderFunction makeTrackFinderFunction( - std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry); - - Acts::MagneticFieldContext getMagneticFieldContext(const EventContext& ctx) const; + class TrackFinderFunction { + public: + virtual ~TrackFinderFunction() = default; + virtual TrackFinderResult operator()(const IndexSourceLinkContainer&, + const TrackParametersContainer&, + const TrackFinderOptions&) const = 0; + }; + static std::shared_ptr<TrackFinderFunction> makeTrackFinderFunction( + std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry); + virtual Acts::MagneticFieldContext getMagneticFieldContext(const EventContext& ctx) const; private: - const FaserSCT_ID* m_idHelper{nullptr}; - const TrackerDD::SCT_DetectorManager* m_detManager{nullptr}; + std::shared_ptr<TrackFinderFunction> m_fit; + std::unique_ptr<const Acts::Logger> m_logger; + const FaserSCT_ID* m_idHelper {nullptr}; + const TrackerDD::SCT_DetectorManager* m_detManager {nullptr}; -// std::unique_ptr<Trk::Track> makeTrack(Acts::GeometryContext& tgContext, FitterResult& fitResult, std::vector<Tracker::FaserSCT_Cluster> seed_spcollection) const; - std::unique_ptr<Trk::Track> makeTrack(Acts::GeometryContext& tgContext, FitterResult& fitResult, std::vector<Tracker::FaserSCT_SpacePoint> seed_spcollection) const; - const Trk::TrackParameters* ConvertActsTrackParameterToATLAS(const Acts::BoundTrackParameters &actsParameter, const Acts::GeometryContext& gctx) const; - - SG::WriteHandleKey<TrackCollection> m_trackCollection { this, "FaserActsCKFTrackCollection", "FaserActsCKFTrackCollection", "Output trackcollectionname" }; - - ToolHandle<IFaserActsTrackingGeometryTool> m_trackingGeometryTool{this, "TrackingGeometryTool", "FaserActsTrackingGeometryTool"}; -// ToolHandle<SPSeedBasedInitialParameterTool> m_initialParameterTool{this, "InitialParameterTool", "SPSeedBasedInitialParameterTool"}; -// ToolHandle<SPSimpleInitialParameterTool> m_initialParameterTool{this, "InitialParameterTool", "SPSimpleInitialParameterTool"}; - ToolHandle<TruthBasedInitialParameterTool> m_initialParameterTool{this, "InitialParameterTool", "TruthBasedInitialParameterTool"}; - ToolHandle<TrajectoryWriterTool> m_trajectoryWriterTool{this, "OutputTool", "TrajectoryWriterTool"}; + // FIXME add tool to get initial parameters + Gaudi::Property<std::string> m_actsLogging {this, "ActsLogging", "VERBOSE"}; + Gaudi::Property<bool> m_resolvePassive {this, "resolvePassive", false}; + Gaudi::Property<bool> m_resolveMaterial {this, "resolveMaterial", true}; + Gaudi::Property<bool> m_resolveSensitive {this, "resolveSensitive", true}; + Gaudi::Property<double> m_maxSteps {this, "maxSteps", 10000}; + Gaudi::Property<double> m_chi2Max {this, "chi2Max", 15}; + Gaudi::Property<unsigned long> m_nMax {this, "nMax", 10}; SG::ReadCondHandleKey<FaserFieldCacheCondObj> m_fieldCondObjInputKey {this, "FaserFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; - SG::ReadHandleKey<FaserSCT_SpacePointContainer> m_SpacePointContainerKey{this, "SpacePointsSCTName", "SCT_SpacePointContainer", "SCT space point container"}; - SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_Sct_clcontainerKey{this, "SCT_ClusterContainer", "SCT_ClusterContainer"}; - mutable int m_nevents; - mutable int m_ntracks; - mutable int m_nseeds; - mutable int m_nsp1; - mutable int m_nsp2; - mutable int m_nsp3; - mutable int m_nsp10; - mutable int m_nsp11; - mutable int m_ncom; + ToolHandle<ITrackSeedTool> m_trackSeedTool {this, "TrackSeed", "ClusterTrackSeedTool"}; + ToolHandle<IFaserActsTrackingGeometryTool> m_trackingGeometryTool {this, "TrackingGeometryTool", "FaserActsTrackingGeometryTool"}; + ToolHandle<RootTrajectoryStatesWriterTool> m_trajectoryStatesWriterTool {this, "RootTrajectoryStatesWriterTool", "RootTrajectoryStatesWriterTool"}; + + // FIXME persistify tracks + // std::unique_ptr<Trk::Track> makeTrack(Acts::GeometryContext& tgContext, FitterResult& fitResult, std::vector<Tracker::FaserSCT_Cluster> seed_spcollection) const; + // std::unique_ptr<Trk::Track> makeTrack(Acts::GeometryContext& tgContext, TrackFitterResult& fitResult, std::vector<Tracker::FaserSCT_SpacePoint> seed_spcollection) const; + // const Trk::TrackParameters* ConvertActsTrackParameterToATLAS(const Acts::BoundTrackParameters &actsParameter, const Acts::GeometryContext& gctx) const; + // SG::WriteHandleKey<TrackCollection> m_trackCollection { this, "FaserActsCKFTrackCollection", "FaserActsCKFTrackCollection", "Output trackcollectionname" }; }; #endif // COMBINATORIALKALMANFILTERALG_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ITrackSeedTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ITrackSeedTool.h new file mode 100644 index 0000000000000000000000000000000000000000..34b5c23c2516ec620a73ab74d192e7f76ae278fc --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/ITrackSeedTool.h @@ -0,0 +1,25 @@ +#ifndef FASERACTSKALMANFILTER_ITRACKSEEDTOOL_H +#define FASERACTSKALMANFILTER_ITRACKSEEDTOOL_H + +#include "GaudiKernel/IInterface.h" +#include "GaudiKernel/IAlgTool.h" +#include "FaserActsKalmanFilter/IndexSourceLink.h" +#include "FaserActsKalmanFilter/IdentifierLink.h" +#include "FaserActsKalmanFilter/Measurement.h" +#include "Acts/EventData/TrackParameters.hpp" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" + +class ITrackSeedTool : virtual public IAlgTool { +public: + DeclareInterfaceID(ITrackSeedTool, 1, 0); + + virtual StatusCode run() = 0; + virtual const std::shared_ptr<std::vector<Acts::CurvilinearTrackParameters>> initialTrackParameters() const = 0; + virtual const std::shared_ptr<const Acts::Surface> initialSurface() const = 0; + virtual const std::shared_ptr<std::vector<IndexSourceLink>> sourceLinks() const = 0; + virtual const std::shared_ptr<IdentifierLink> idLinks() const = 0; + virtual const std::shared_ptr<std::vector<Measurement>> measurements() const = 0; + virtual const std::shared_ptr<std::vector<const Tracker::FaserSCT_Cluster*>> clusters() const = 0; +}; + +#endif // FASERACTSKALMANFILTER_ITRACKSEEDTOOL_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/MultiTrackFinderTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/MultiTrackFinderTool.h index d963d1189a7fc2a1e2c0a9e410907100fc88f32e..56e5db2666157c330e91258776b3a6b34af44278 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/MultiTrackFinderTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/MultiTrackFinderTool.h @@ -84,9 +84,9 @@ public: cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = covQOverP; cov(Acts::eBoundTime, Acts::eBoundTime) = covTime; - Acts::CurvilinearTrackParameters m_params = + Acts::CurvilinearTrackParameters params = Acts::CurvilinearTrackParameters(pos4, dir, abs_momentum, charge, cov); - return m_params; + return params; } std::tuple<std::vector<Measurement>, std::vector<IndexSourceLink>, std::map<Index, Identifier>, std::vector<const Tracker::FaserSCT_Cluster*>> run() const { diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SegmentFitClusterTrackFinderTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SegmentFitClusterTrackFinderTool.h index 0e3bd17560e42ed8c36533810bb61cb64b5dcb29..0b123162f69ef96c408d507d2f7d33459151fb44 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SegmentFitClusterTrackFinderTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SegmentFitClusterTrackFinderTool.h @@ -58,6 +58,7 @@ private: this, "TrackCollection", "SegmentFit", "Input track collection name" }; // covariance of the initial parameters + Gaudi::Property<double> m_sigmaCluster {this, "sigmaCluster", 0.04}; Gaudi::Property<double> m_covLoc0 {this, "covLoc0", 1}; Gaudi::Property<double> m_covLoc1 {this, "covLoc1", 1}; Gaudi::Property<double> m_covPhi {this, "covPhi", 1}; diff --git a/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py b/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py index 46c01fd06268dddf34867f76d358e4ab10f961e3..0f291b931fd092348535518a878bb7a8ad34a487 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py +++ b/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py @@ -6,38 +6,40 @@ from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg def CombinatorialKalmanFilter_OutputCfg(flags): - acc = ComponentAccumulator() - acc.merge(OutputStreamCfg(flags, "ESD")) - ostream = acc.getEventAlgo("OutputStreamESD") - ostream.TakeItemsFromInput = True - return acc - -def CombinatorialKalmanFilter_OutputAODCfg(flags): acc = ComponentAccumulator() itemList = ["xAOD::EventInfo#*", "xAOD::EventAuxInfo#*", - "FaserSCT_RDO_Container#*", - "xAOD::FaserTriggerData#*", - "xAOD::FaserTriggerDataAux#*", - "ScintWaveformContainer#*", "TrackCollection#*", - "xAOD::WaveformHitContainer#*", - "xAOD::WaveformHitAuxContainer#*", - "xAOD::WaveformClock#*", - "xAOD::WaveformClockAuxInfo#*" ] - acc.merge(OutputStreamCfg(flags, "AOD",itemList)) - ostream = acc.getEventAlgo("OutputStreamAOD") + acc.merge(OutputStreamCfg(flags, "ESD", itemList)) + ostream = acc.getEventAlgo("OutputStreamESD") ostream.TakeItemsFromInput = True return acc - def CombinatorialKalmanFilterCfg(flags, **kwargs): acc = ComponentAccumulator() - kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer") - combinatorialKalmanFilterAlg = CompFactory.CombinatorialKalmanFilterAlg(**kwargs) - acc.addEventAlgo(combinatorialKalmanFilterAlg) + + track_seed_tool = CompFactory.ClusterTrackSeedTool() + sigma_loc0 = 1.9e-2 + sigma_loc1 = 9e-1 + sigma_phi = 3.3e-2 + sigma_theta = 2.9e-4 + sigma_p = 1.3e2 + p = 1000 + 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.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 + + # trajectory_states_writer_tool = CompFactory.RootTrajectoryStatesWriterTool() + + ckf = CompFactory.CombinatorialKalmanFilterAlg(**kwargs) + ckf.TrackSeed = track_seed_tool + ckf.ActsLogging = "DEBUG" + acc.addEventAlgo(ckf) acc.merge(CombinatorialKalmanFilter_OutputCfg(flags)) - acc.merge(CombinatorialKalmanFilter_OutputAODCfg(flags)) return acc diff --git a/Tracking/Acts/FaserActsKalmanFilter/python/FaserActsKalmanFilterConfig.py b/Tracking/Acts/FaserActsKalmanFilter/python/FaserActsKalmanFilterConfig.py index 0301c724bb7dbde37d901d4f7c2c0695c078c1a7..7826671a93ecc0196ae4ee26d3ab7e8de3eff6d8 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/python/FaserActsKalmanFilterConfig.py +++ b/Tracking/Acts/FaserActsKalmanFilter/python/FaserActsKalmanFilterConfig.py @@ -52,7 +52,11 @@ from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg def FaserActsKalmanFilter_OutputCfg(flags): acc = ComponentAccumulator() - acc.merge(OutputStreamCfg(flags, "ESD")) + itemList = ["xAOD::EventInfo#*", + "xAOD::EventAuxInfo#*", + "TrackCollection#*", + ] + acc.merge(OutputStreamCfg(flags, "ESD", itemList)) ostream = acc.getEventAlgo("OutputStreamESD") ostream.TakeItemsFromInput = True return acc @@ -79,9 +83,10 @@ def FaserActsKalmanFilter_OutputAODCfg(flags): def FaserActsKalmanFilterCfg(flags, **kwargs): acc = ComponentAccumulator() - track_finder_tool = CompFactory.MultiTrackFinderTool() - # track_finder_tool = CompFactory.SegmentFitClusterTrackFinderTool() + # track_finder_tool = CompFactory.MultiTrackFinderTool() + track_finder_tool = CompFactory.SegmentFitClusterTrackFinderTool() # track_finder_tool = CompFactory.SegmentFitTrackFinderTool() + sigmaCluster = 0.023 sigma_loc0 = 1.9e-2 sigma_loc1 = 9e-1 sigma_phi = 3.3e-2 @@ -149,8 +154,8 @@ def FaserActsKalmanFilterCfg(flags, **kwargs): # kalman_filter.RootTrajectoryStatesWriterTool = trajectory_states_writer_tool kalman_filter.OutputTool = trajectory_writer_tool kalman_filter.TrackFinderTool = track_finder_tool - kalman_filter.ActsLogging = "VERBOSE" + kalman_filter.ActsLogging = "INFO" acc.addEventAlgo(kalman_filter) acc.merge(FaserActsKalmanFilter_OutputCfg(flags)) - acc.merge(FaserActsKalmanFilter_OutputAODCfg(flags)) + # acc.merge(FaserActsKalmanFilter_OutputAODCfg(flags)) return acc diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/ClusterTrackSeedTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/ClusterTrackSeedTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9dad95bfaaf5f25050d0fc4aaced6c90886ccf7d --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/src/ClusterTrackSeedTool.cxx @@ -0,0 +1,127 @@ +#include "FaserActsKalmanFilter/ClusterTrackSeedTool.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrackerReadoutGeometry/SCT_DetectorManager.h" +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "Identifier/Identifier.h" +#include "Acts/Geometry/GeometryIdentifier.hpp" + + +// FIXME make this a method of ClusterTrackSeedTool +std::pair<double, double> momentum(const std::map<int, Amg::Vector3D>& pos, double B=0.57) { + Acts::Vector3 vec_l = pos.at(3) - pos.at(1); + double abs_l = std::sqrt(vec_l.y() * vec_l.y() + vec_l.z() * vec_l.z()); + double t = (pos.at(2).z() - pos.at(1).z()) / (pos.at(3).z() - pos.at(1).z()); + Acts::Vector3 vec_m = pos.at(1) + t * vec_l; + Acts::Vector3 vec_s = pos.at(2) - vec_m; + double abs_s = std::sqrt(vec_s.y() * vec_s.y() + vec_s.z() * vec_s.z()); + double p_yz = 0.3 * abs_l * abs_l * B / (8 * abs_s * 1000); + double charge = vec_s.y() < 0 ? 1 : -1; + return std::make_pair(p_yz, charge); +} + + +ClusterTrackSeedTool::ClusterTrackSeedTool( + const std::string& type, const std::string& name, const IInterface* parent) + : base_class(type, name, parent) {} + + +StatusCode ClusterTrackSeedTool::initialize() { + ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID")); + ATH_CHECK(detStore()->retrieve(m_detManager, "SCT")); + ATH_CHECK(m_trackingGeometryTool.retrieve()); + ATH_CHECK(m_trackCollection.initialize()); + ATH_CHECK(m_clusterContainerKey.initialize()); + return StatusCode::SUCCESS; +} + + +StatusCode ClusterTrackSeedTool::run() { + // FIXME currently this is only valid for events with a single track + // create track seeds for multiple tracks + SG::ReadHandle<TrackCollection> trackCollection {m_trackCollection}; + ATH_CHECK(trackCollection.isValid()); + + SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> clusterContainer {m_clusterContainerKey}; + ATH_CHECK(clusterContainer.isValid()); + + using IdentifierMap = std::map<Identifier, Acts::GeometryIdentifier>; + std::shared_ptr<IdentifierMap> identifierMap = m_trackingGeometryTool->getIdentifierMap(); + + const int kSize = 1; + using ThisMeasurement = Acts::Measurement<IndexSourceLink, Acts::BoundIndices, kSize>; + std::array<Acts::BoundIndices, kSize> Indices = {Acts::eBoundLoc0}; + std::vector<IndexSourceLink> sourceLinks; + std::vector<Measurement> measurements; + std::map<Index, Identifier> identifierLinkMap; + for (const Tracker::FaserSCT_ClusterCollection* clusterCollection : *clusterContainer) { + for (const Tracker::FaserSCT_Cluster* cluster : *clusterCollection) { + Identifier id = cluster->detectorElement()->identify(); + identifierLinkMap[measurements.size()] = id; + Acts::GeometryIdentifier geoId = identifierMap->at(id); + IndexSourceLink sourceLink(geoId, measurements.size()); + // create measurement + const auto& par = cluster->localPosition(); + Eigen::Matrix<double, 1, 1> pos {par.x(),}; + Eigen::Matrix<double, 1, 1> cov {m_std_cluster * m_std_cluster,}; + ThisMeasurement meas(sourceLink, Indices, pos, cov); + sourceLinks.push_back(sourceLink); + measurements.emplace_back(std::move(meas)); + } + } + + std::vector<Acts::CurvilinearTrackParameters> initParams {}; + + std::map<int, Amg::Vector3D> positions; + std::map<int, Amg::Vector3D> directions; + for (const Trk::Track* track : *trackCollection) { + auto fitParameters = track->trackParameters()->front(); + const Amg::Vector3D fitPosition = fitParameters->position(); + const Amg::Vector3D fitMomentum = fitParameters->momentum(); + // FIXME fix station identification + int station = 1; + if (fitPosition.z() > 500) station = 2; + if (fitPosition.z() > 1500) station = 3; + positions[station] = fitPosition; + directions[station] = fitMomentum; + } + + if (positions.size() != 3) { + return StatusCode::RECOVERABLE; + } + + Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = m_covLoc0; + cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = m_covLoc1; + cov(Acts::eBoundPhi, Acts::eBoundPhi) = m_covPhi; + cov(Acts::eBoundTheta, Acts::eBoundTheta) = m_covTheta; + cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = m_covQOverP; + cov(Acts::eBoundTime, Acts::eBoundTime) = m_covTime; + + Acts::Vector3 dir = positions[2] - positions[1]; + Acts::Vector3 pos = positions[1] - positions[1].z()/dir.z() * dir; + Acts::Vector4 pos4 {pos.x(), pos.y(), pos.z(), 0}; + auto [abs_momentum, charge] = momentum(positions); + + // auto initialParameters = Acts::CurvilinearTrackParameters(pos4, dir, abs_momentum, charge, cov); + auto initialParameters = Acts::CurvilinearTrackParameters(pos4, dir, 1000000, 1, cov); + initParams.push_back(initialParameters); + + m_initialTrackParameters = std::make_shared<std::vector<Acts::CurvilinearTrackParameters>>(initParams); + + m_sourceLinks = std::make_shared<std::vector<IndexSourceLink>>(sourceLinks); + m_idLinks = std::make_shared<IdentifierLink>(identifierLinkMap); + m_measurements = std::make_shared<std::vector<Measurement>>(measurements); + m_initialSurface = Acts::Surface::makeShared<Acts::PlaneSurface>( + Acts::Vector3 {0, 0, 0}, Acts::Vector3{0, 0, 1}); + + return StatusCode::SUCCESS; +} + + +StatusCode ClusterTrackSeedTool::finalize() { + return StatusCode::SUCCESS; +} + + + diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmanFilterAlg.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmanFilterAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f9814ad1bee02db036546119b16935a65571f23e --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmanFilterAlg.cxx @@ -0,0 +1,149 @@ +#include "FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h" + +#include "StoreGate/ReadHandle.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "TrkPrepRawData/PrepRawData.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerRIO_OnTrack/FaserSCT_ClusterOnTrack.h" +#include "TrkRIO_OnTrack/RIO_OnTrack.h" +#include "TrkSurfaces/Surface.h" +#include "Identifier/Identifier.h" +#include "Acts/Geometry/GeometryIdentifier.hpp" +#include "Acts/EventData/TrackParameters.hpp" +#include "FaserActsKalmanFilter/IndexSourceLink.h" +#include "FaserActsKalmanFilter/Measurement.h" +#include "FaserActsKalmanFilter/FaserActsRecMultiTrajectory.h" +#include "Acts/Surfaces/PerigeeSurface.hpp" +#include "Acts/MagneticField/MagneticFieldContext.hpp" + +using TrajectoriesContainer = std::vector<FaserActsRecMultiTrajectory>; +std::array<Acts::BoundIndices, 2> indices = {Acts::eBoundLoc0, Acts::eBoundLoc1}; + + +CombinatorialKalmanFilterAlg::CombinatorialKalmanFilterAlg( + const std::string& name, ISvcLocator* pSvcLocator) + : AthAlgorithm(name, pSvcLocator) {} + + +StatusCode CombinatorialKalmanFilterAlg::initialize() { + ATH_CHECK(m_fieldCondObjInputKey.initialize()); + ATH_CHECK(m_trackingGeometryTool.retrieve()); + ATH_CHECK(m_trackSeedTool.retrieve()); + ATH_CHECK(m_trajectoryStatesWriterTool.retrieve()); + ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); + m_fit = makeTrackFinderFunction(m_trackingGeometryTool->trackingGeometry()); + // FIXME fix Acts logging level + if (m_actsLogging == "VERBOSE") { + m_logger = Acts::getDefaultLogger("KalmanFitter", Acts::Logging::VERBOSE); + } else if (m_actsLogging == "DEBUG") { + m_logger = Acts::getDefaultLogger("KalmanFitter", Acts::Logging::DEBUG); + } else { + m_logger = Acts::getDefaultLogger("KalmanFitter", Acts::Logging::INFO); + } + return StatusCode::SUCCESS; +} + + +StatusCode CombinatorialKalmanFilterAlg::execute() { + const EventContext& ctx = Gaudi::Hive::currentContext(); + + std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry + = m_trackingGeometryTool->trackingGeometry(); + + const FaserActsGeometryContext& gctx = m_trackingGeometryTool->getNominalGeometryContext(); + auto geoctx = gctx.context(); + Acts::MagneticFieldContext magctx = getMagneticFieldContext(ctx); + Acts::CalibrationContext calctx; + + CHECK(m_trackSeedTool->run()); + std::shared_ptr<const Acts::Surface> initialSurface = + m_trackSeedTool->initialSurface(); + std::shared_ptr<std::vector<Acts::CurvilinearTrackParameters>> initialParameters = + m_trackSeedTool->initialTrackParameters(); + std::shared_ptr<std::vector<IndexSourceLink>> sourceLinks = + m_trackSeedTool->sourceLinks(); + std::shared_ptr<IdentifierLink> idLinks = m_trackSeedTool->idLinks(); + std::shared_ptr<std::vector<Measurement>> measurements = m_trackSeedTool->measurements(); + std::shared_ptr<std::vector<const Tracker::FaserSCT_Cluster*>> clusters = m_trackSeedTool->clusters(); + + TrajectoriesContainer trajectories; + trajectories.reserve(initialParameters->size()); + + Acts::PropagatorPlainOptions pOptions; + pOptions.maxSteps = m_maxSteps; + + Acts::GeometryContext geoContext = m_trackingGeometryTool->getNominalGeometryContext().context(); + Acts::MagneticFieldContext magFieldContext = getMagneticFieldContext(ctx); + Acts::CalibrationContext calibContext; + Acts::MeasurementSelector::Config measurementSelectorCfg = { + {Acts::GeometryIdentifier(), {m_chi2Max, m_nMax}}, + }; + + // Set the CombinatorialKalmanFilter options + CombinatorialKalmanFilterAlg::TrackFinderOptions options( + geoContext, magFieldContext, calibContext, + IndexSourceLinkAccessor(), MeasurementCalibrator(*measurements), + Acts::MeasurementSelector(measurementSelectorCfg), + Acts::LoggerWrapper{*m_logger}, pOptions, &(*initialSurface)); + + // Perform the track finding for all initial parameters + ATH_MSG_DEBUG("Invoke track finding with " << initialParameters->size() << " seeds."); + IndexSourceLinkContainer tmp; + for (const auto& sl : *sourceLinks) { + tmp.emplace_hint(tmp.end(), sl); + } + auto results = (*m_fit)(tmp, *initialParameters, options); + + // Loop over the track finding results for all initial parameters + for (std::size_t iseed = 0; iseed < initialParameters->size(); ++iseed) { + // The result for this seed + auto& result = results[iseed]; + if (result.ok()) { + // Get the track finding output object + const auto& trackFindingOutput = result.value(); + if (trackFindingOutput.fittedParameters.size()) { + const std::unordered_map<size_t, Acts::BoundTrackParameters>& params = trackFindingOutput.fittedParameters; + for (const auto& surface_params : params) { + ATH_MSG_VERBOSE("Fitted parameters for track " << iseed << ", surface " << surface_params.first); + ATH_MSG_VERBOSE(" position: " << surface_params.second.position(geoctx).transpose()); + ATH_MSG_VERBOSE(" momentum: " << surface_params.second.momentum().transpose()); + } + } else { + ATH_MSG_DEBUG("No fitted parameters for track " << iseed); + } + // Create a Trajectories result struct + trajectories.emplace_back(std::move(trackFindingOutput.fittedStates), + std::move(trackFindingOutput.lastMeasurementIndices), + std::move(trackFindingOutput.fittedParameters)); + } else { + ATH_MSG_WARNING("Track finding failed for seed " << iseed << " with error" << result.error()); + // Track finding failed. Add an empty result so the output container has + // the same number of entries as the input. + trajectories.push_back(FaserActsRecMultiTrajectory()); + } + } + + ATH_CHECK(m_trajectoryStatesWriterTool->write(trajectories, geoctx, std::vector<IdentifierLink>{*idLinks})); + + return StatusCode::SUCCESS; +} + + +StatusCode CombinatorialKalmanFilterAlg::finalize() { + return StatusCode::SUCCESS; +} + + +Acts::MagneticFieldContext CombinatorialKalmanFilterAlg::getMagneticFieldContext(const EventContext& ctx) const { + SG::ReadCondHandle<FaserFieldCacheCondObj> readHandle{m_fieldCondObjInputKey, ctx}; + if (!readHandle.isValid()) { + std::stringstream msg; + msg << "Failed to retrieve magnetic field condition data " << m_fieldCondObjInputKey.key() << "."; + throw std::runtime_error(msg.str()); + } + const FaserFieldCacheCondObj* fieldCondObj{*readHandle}; + return Acts::MagneticFieldContext(fieldCondObj); +} diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx deleted file mode 100644 index f5c547e61418ca7d5d0e4eb8b1cbdb9651e9316b..0000000000000000000000000000000000000000 --- a/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx +++ /dev/null @@ -1,449 +0,0 @@ -#include "FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h" - -#include "StoreGate/ReadHandle.h" -#include "StoreGate/ReadCondHandleKey.h" -#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" -#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" -#include "TrackerIdentifier/FaserSCT_ID.h" -#include "TrkPrepRawData/PrepRawData.h" -#include "TrackerPrepRawData/FaserSCT_Cluster.h" -#include "TrackerRIO_OnTrack/FaserSCT_ClusterOnTrack.h" -#include "TrkRIO_OnTrack/RIO_OnTrack.h" -#include "TrkSurfaces/Surface.h" -#include "Identifier/Identifier.h" -#include "Acts/Geometry/GeometryIdentifier.hpp" -#include "Acts/EventData/TrackParameters.hpp" -#include "FaserActsKalmanFilter/IndexSourceLink.h" -#include "FaserActsKalmanFilter/Measurement.h" -#include "FaserActsKalmanFilter/FaserActsRecMultiTrajectory.h" -#include "Acts/Surfaces/PerigeeSurface.hpp" -#include "Acts/MagneticField/MagneticFieldContext.hpp" - -using IdentifierMap = std::map<Identifier, Acts::GeometryIdentifier>; -using ThisMeasurement = Acts::Measurement<IndexSourceLink, Acts::BoundIndices, 2>; -using TrajectoriesContainer = std::vector<FaserActsRecMultiTrajectory>; -std::array<Acts::BoundIndices, 2> indices = {Acts::eBoundLoc0, Acts::eBoundLoc1}; - - -CombinatorialKalmanFilterAlg::CombinatorialKalmanFilterAlg( - const std::string& name, ISvcLocator* pSvcLocator) - : AthReentrantAlgorithm(name, pSvcLocator) {} - - -StatusCode CombinatorialKalmanFilterAlg::initialize() { - ATH_MSG_INFO("CombinatorialKalmanFilterAlg::initialize"); - m_nevents=0; - m_ntracks=0; - m_nseeds=0; - m_nsp10=0; - m_nsp11=0; - m_ncom=0; - m_nsp1=0; - m_nsp2=0; - m_nsp3=0; - - ATH_CHECK(m_trackingGeometryTool.retrieve()); - ATH_CHECK(m_initialParameterTool.retrieve()); - ATH_CHECK(m_trajectoryWriterTool.retrieve()); - ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); - - ATH_CHECK( m_fieldCondObjInputKey.initialize() ); - - ATH_CHECK(m_trackCollection.initialize()); - - if (m_SpacePointContainerKey.key().empty()) { - ATH_MSG_FATAL("empty space point container key"); - return StatusCode::FAILURE; - } - ATH_CHECK(m_SpacePointContainerKey.initialize()); - ATH_CHECK(m_Sct_clcontainerKey.initialize() ); - - return StatusCode::SUCCESS; -} - - -StatusCode CombinatorialKalmanFilterAlg::execute(const EventContext& ctx) const { - ATH_MSG_DEBUG("CombinatorialKalmanFilterAlg::execute"); - m_nevents++; - - SG::ReadHandle<FaserSCT_SpacePointContainer> spcontainer(m_SpacePointContainerKey, ctx); - if (!spcontainer.isValid()) { - ATH_MSG_FATAL( "Could not find the data object "<< spcontainer.name()); - return StatusCode::FAILURE; - } - SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> sct_clcontainer( m_Sct_clcontainerKey, ctx ); -if (!sct_clcontainer.isValid()){ -msg(MSG:: FATAL) << "Could not find the data object "<< sct_clcontainer.name() << " !" << endmsg; -return StatusCode::RECOVERABLE; -} - - - //make TrackCollection - SG::WriteHandle<TrackCollection> trackContainer{m_trackCollection,ctx}; - std::unique_ptr<TrackCollection> outputTracks = std::make_unique<TrackCollection>(); - - const std::shared_ptr<IdentifierMap> identifierMap - = m_trackingGeometryTool->getIdentifierMap(); - - /* - // Create measurement and source link containers - IndexSourceLinkContainer sourceLinks; - MeasurementContainer measurements; - std::vector<Identifier> sp_ids; - std::vector<Tracker::FaserSCT_Cluster> sps; - - std::vector<Acts::Vector3> pos1; - std::vector<Acts::Vector3> pos2; - std::vector<Acts::Vector3> pos3; - pos1.clear();pos2.clear();pos3.clear(); - Tracker::FaserSCT_ClusterContainer::const_iterator coll_it = sct_clcontainer->begin(); - Tracker::FaserSCT_ClusterContainer::const_iterator coll_itend = sct_clcontainer->end(); - for (; coll_it != coll_itend; ++coll_it) { - const Tracker::FaserSCT_ClusterCollection* spcollection = *coll_it; - Tracker::FaserSCT_ClusterCollection::const_iterator sp_it = spcollection->begin(); - Tracker::FaserSCT_ClusterCollection::const_iterator sp_end = spcollection->end(); - for (; sp_it != sp_end; ++sp_it) { - const Tracker::FaserSCT_Cluster* sp = *sp_it; - Identifier id = sp->detectorElement()->identify(); - //Identifier id = sp->associatedSurface().associatedDetectorElementIdentifier(); - Acts::GeometryIdentifier geoId = identifierMap->at(id); - IndexSourceLink sourceLink(geoId, measurements.size()); - sourceLinks.emplace_hint(sourceLinks.end(), std::move(sourceLink)); - ThisMeasurement meas(sourceLink, indices, sp->localPosition(), sp->localCovariance()); - //ThisMeasurement meas(sourceLink, indices, sp->localParameters(), sp->localCovariance()); - measurements.emplace_back(std::move(meas)); - - if(m_idHelper->station(sp->identify())==1)pos1.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); - if(m_idHelper->station(sp->identify())==2)pos2.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); - if(m_idHelper->station(sp->identify())==3)pos3.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); - sp_ids.push_back(sp->identify()); - sps.push_back(*sp); - } - } -*/ - // Create measurement and source link containers - IndexSourceLinkContainer sourceLinks; - MeasurementContainer measurements; - std::vector<Identifier> sp_ids; - std::vector<Tracker::FaserSCT_SpacePoint> sps; - -// std::vector<Acts::Vector3> pos1; -// std::vector<Acts::Vector3> pos2; -// std::vector<Acts::Vector3> pos3; -// pos1.clear();pos2.clear();pos3.clear(); - std::vector<int> layer1; - layer1.clear(); - FaserSCT_SpacePointContainer::const_iterator coll_it = spcontainer->begin(); - FaserSCT_SpacePointContainer::const_iterator coll_itend = spcontainer->end(); - for (; coll_it != coll_itend; ++coll_it) { - const FaserSCT_SpacePointCollection* spcollection = *coll_it; - FaserSCT_SpacePointCollection::const_iterator sp_it = spcollection->begin(); - FaserSCT_SpacePointCollection::const_iterator sp_end = spcollection->end(); - for (; sp_it != sp_end; ++sp_it) { - const Tracker::FaserSCT_SpacePoint* sp = *sp_it; - Identifier id = sp->associatedSurface().associatedDetectorElementIdentifier(); - Acts::GeometryIdentifier geoId = identifierMap->at(id); - IndexSourceLink sourceLink(geoId, measurements.size()); - sourceLinks.emplace_hint(sourceLinks.end(), std::move(sourceLink)); - ThisMeasurement meas(sourceLink, indices, sp->localParameters(), sp->localCovariance()); - measurements.emplace_back(std::move(meas)); - -// if(m_idHelper->station(sp->clusterList().first->identify())==1) { -// pos1.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); -// layer1.push_back(m_idHelper->layer(sp->clusterList().first->identify())); -// } -// if(m_idHelper->station(sp->clusterList().first->identify())==2)pos2.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); -// if(m_idHelper->station(sp->clusterList().first->identify())==3)pos3.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); - sp_ids.push_back(sp->clusterList().first->identify()); - sps.push_back(*sp); - } - } - - // Get initial parameters - // FIXME: Get initial parameters from clusterFitter or SeedFinder not MC! - std::vector<Acts::CurvilinearTrackParameters> initialParameters; - auto initialParameter = m_initialParameterTool->getInitialParameters(sp_ids); - initialParameters.push_back(initialParameter); -// if(pos1.size()<1||pos2.size()<1||pos3.size()<1) return StatusCode::SUCCESS; -// std::vector<Acts::CurvilinearTrackParameters> initialParameters; -// initialParameters.clear(); -// Acts::Vector3 pos1a(0,0,0); -// Acts::Vector3 pos2a(0,0,0); -// Acts::Vector3 pos3a(0,0,0); -// for(long unsigned int i1=0;i1<pos1.size();i1++)pos1a+=pos1[i1]; -// for(long unsigned int i1=0;i1<pos2.size();i1++)pos2a+=pos2[i1]; -// for(long unsigned int i1=0;i1<pos3.size();i1++)pos3a+=pos3[i1]; -// pos1a/=pos1.size(); -// pos2a/=pos2.size(); -// pos3a/=pos3.size(); -// m_nsp1+=pos1.size(); -// m_nsp2+=pos2.size(); -// m_nsp3+=pos3.size(); -// for(int i1=0;i1<pos1.size();i1++){ -// for(int i2=0;i2<pos2.size();i2++){ -// for(int i3=0;i3<pos3.size();i3++){ -// auto initialParameter=m_initialParameterTool->getInitialParameters(pos1[i1],pos2[i2],pos3[i3]); -// initialParameters.push_back(initialParameter); -// } -// } -// } - /* - if(pos1.size()>0&&pos2.size()>0&&pos3.size()>0) { - auto initialParameter=m_initialParameterTool->getInitialParameters(pos1a,pos2a,pos3a); - if(initialParameter.momentum().z()>0){ - m_nseeds++; - initialParameters.push_back(initialParameter); - */ - // for one stations -// if(pos1.size()>2) { -// std::vector<Acts::Vector3> pos10; -// std::vector<Acts::Vector3> pos11; -// std::vector<Acts::Vector3> pos12; -// pos10.clear();pos11.clear();pos12.clear(); -// for(std::size_t ipos=0;ipos<pos1.size();ipos++){ -// if(layer1[ipos]==0)pos10.push_back(pos1[ipos]); -// if(layer1[ipos]==1)pos11.push_back(pos1[ipos]); -// if(layer1[ipos]==2)pos12.push_back(pos1[ipos]); -// } -// if(pos10.size()>0&&pos11.size()>0&&pos12.size()>0){ -// auto initialParameter=m_initialParameterTool->getInitialParameters_1station(pos10,pos11,pos12); -// initialParameters.insert(initialParameters.end(),initialParameter.begin(),initialParameter.end()); - /* - //for two stations - if(pos1.size()>1&&pos2.size()>0) { - Acts::Vector3 pos10a(0,0,0); - Acts::Vector3 pos11a(0,0,0); - int n10a=0,n11a=0; - for(int ipos=0;ipos<pos1.size();ipos++){ - if(layer1[ipos]==0){pos10a+=pos1[ipos];n10a++;} - if(layer1[ipos]>0){pos11a+=pos1[ipos];n11a++;} - } - m_nsp10+=n10a; - m_nsp11+=n11a; - if(n10a>0&&n11a>0){ - m_ncom++; - pos10a/=n10a; - pos11a/=n11a; - Acts::Vector3 dir1=(pos11a-pos10a).normalized(); - auto initialParameter=m_initialParameterTool->getInitialParameters_2stations(pos1a,pos2a,dir1); - if(initialParameter.momentum().z()>0){ - m_nseeds++; - initialParameters.push_back(initialParameter); - } - */ - - // Prepare the output data with MultiTrajectory - TrajectoriesContainer trajectories; - trajectories.reserve(initialParameters.size()); - - // Construct a perigee surface as the target surface - auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>( - Acts::Vector3{0., 0., 0.}); - - Acts::PropagatorPlainOptions pOptions; - pOptions.maxSteps = 10000; - /* - Acts::DirectNavigator navigator; - std::unique_ptr<ActsExtrapolationDetail::VariantPropagator> varProp; - Acts::Vector3 constantFieldVector = Acts::Vector3(0,0,0.55); - auto bField = std::make_shared<Acts::ConstantBField>(constantFieldVector); - auto stepper = Acts::EigenStepper<>(std::move(bField)); - auto propagator = Acts::Propagator<decltype(stepper), Acts::DirectNavigator>(std::move(stepper), - std::move(navigator)); - varProp = std::make_unique<VariantPropagator>(propagator); - */ - - Acts::GeometryContext geoContext = m_trackingGeometryTool->getNominalGeometryContext().context(); - Acts::MagneticFieldContext magFieldContext = getMagneticFieldContext(ctx); - Acts::CalibrationContext calibContext; - double chi2Max = 15; - size_t nMax = 10; - Acts::MeasurementSelector::Config measurementSelectorCfg = { - {Acts::GeometryIdentifier(), {chi2Max, nMax}}, - }; - std::unique_ptr<const Acts::Logger> logger - = Acts::getDefaultLogger("CombinatorialKalmanFilter", Acts::Logging::INFO); - - // Set the CombinatorialKalmanFilter options - CombinatorialKalmanFilterAlg::TrackFinderOptions options( - geoContext, magFieldContext, calibContext, - IndexSourceLinkAccessor(), MeasurementCalibrator(measurements), - Acts::MeasurementSelector(measurementSelectorCfg), - //Acts::LoggerWrapper{*logger}, varProp, &(*pSurface)); - Acts::LoggerWrapper{*logger}, pOptions, &(*pSurface)); - - std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry - = m_trackingGeometryTool->trackingGeometry(); - - // Get track finder function - auto trackFinderFunction = makeTrackFinderFunction(trackingGeometry); - - // Perform the track finding for all initial parameters - ATH_MSG_DEBUG("Invoke track finding with " << initialParameters.size() - << " seeds."); - auto results = trackFinderFunction(sourceLinks, initialParameters, options); - // Loop over the track finding results for all initial parameters - for (std::size_t iseed = 0; iseed < initialParameters.size(); ++iseed) { - // The result for this seed - auto& result = results[iseed]; - if (result.ok()) { - // Get the track finding output object - const auto& trackFindingOutput = result.value(); - std::unique_ptr<Trk::Track> track = makeTrack(geoContext, result,sps); - m_ntracks++; - if(track!=nullptr) { - outputTracks->push_back(std::move(track)); - } else { - ATH_MSG_DEBUG("No Trk::Track is created" ); - } - // Create a Trajectories result struct - trajectories.emplace_back(std::move(trackFindingOutput.fittedStates), - std::move(trackFindingOutput.lastMeasurementIndices), - std::move(trackFindingOutput.fittedParameters)); - } else { - ATH_MSG_WARNING("Track finding failed for seed " << iseed << " with error" - << result.error()); - // Track finding failed. Add an empty result so the output container has - // the same number of entries as the input. - trajectories.push_back(FaserActsRecMultiTrajectory()); - } - } - - m_trajectoryWriterTool->writeout(trajectories, geoContext,initialParameters); -// } -// } - - if(outputTracks->size()>0) { - ATH_MSG_DEBUG("Found " << outputTracks->size() << " tracks"); - } else { - ATH_MSG_WARNING("No track is found"); - } - - ATH_CHECK(trackContainer.record(std::move(outputTracks))); - return StatusCode::SUCCESS; -} - - -StatusCode CombinatorialKalmanFilterAlg::finalize() { - ATH_MSG_INFO("CombinatorialKalmanFilterAlg::finalize"); - ATH_MSG_INFO("Summary info"); - ATH_MSG_INFO("In total, "<<m_nevents<<" events, and "<<m_nseeds<<" seeds, and "<<m_ntracks<<" tracks"); - ATH_MSG_INFO("In total, "<<m_nsp1<<" , "<<m_nsp2<<" , "<<m_nsp3<<" ,"<<m_nsp10<<" , "<<m_nsp11<<" , "<<m_ncom); - - return StatusCode::SUCCESS; -} - - -Acts::MagneticFieldContext CombinatorialKalmanFilterAlg::getMagneticFieldContext(const EventContext& ctx) const { - SG::ReadCondHandle<FaserFieldCacheCondObj> readHandle{m_fieldCondObjInputKey, ctx}; - if (!readHandle.isValid()) { - std::stringstream msg; - msg << "Failed to retrieve magnetic field condition data " << m_fieldCondObjInputKey.key() << "."; - throw std::runtime_error(msg.str()); - } - const FaserFieldCacheCondObj* fieldCondObj{*readHandle}; - - return Acts::MagneticFieldContext(fieldCondObj); -} - -std::unique_ptr<Trk::Track> -CombinatorialKalmanFilterAlg::makeTrack(Acts::GeometryContext& tgContext, FitterResult& fitResult, std::vector<Tracker::FaserSCT_SpacePoint> sps) const { - std::unique_ptr<Trk::Track> newtrack = nullptr; - //Get the fit output object - const auto& fitOutput = fitResult.value(); - if (fitOutput.fittedParameters.size()>0) { - DataVector<const Trk::TrackStateOnSurface>* finalTrajectory = new DataVector<const Trk::TrackStateOnSurface>{}; - std::vector<std::unique_ptr<const Acts::BoundTrackParameters>> actsSmoothedParam; - ATH_MSG_DEBUG("makeTrack : trackTip "<<fitOutput.lastMeasurementIndices.size()); - // Loop over all the output state to create track state - fitOutput.fittedStates.visitBackwards(fitOutput.lastMeasurementIndices.front(), [&](const auto &state) { - auto flag = state.typeFlags(); - if (state.referenceSurface().associatedDetectorElement() != nullptr) { - // const auto* actsElement = dynamic_cast<const FaserActsDetectorElement*>(state.referenceSurface().associatedDetectorElement()); - // if (actsElement != nullptr ){ - // We need to determine the type of state - std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern; - const Trk::TrackParameters *parm; - - // State is a hole (no associated measurement), use predicted para meters - if (flag[Acts::TrackStateFlag::HoleFlag] == true) { - const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(), - state.predicted(), - state.predictedCovariance()); - parm = ConvertActsTrackParameterToATLAS(actsParam, tgContext); - // auto boundaryCheck = m_boundaryCheckTool->boundaryCheck(*p arm); - typePattern.set(Trk::TrackStateOnSurface::Hole); - } - // The state was tagged as an outlier, use filtered parameters - else if (flag[Acts::TrackStateFlag::OutlierFlag] == true) { - const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(), - state.filtered(), state.filteredCovariance()); - parm = ConvertActsTrackParameterToATLAS(actsParam, tgContext); - typePattern.set(Trk::TrackStateOnSurface::Outlier); - } - // The state is a measurement state, use smoothed parameters - else { - const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(), - state.smoothed(), state.smoothedCovariance()); - actsSmoothedParam.push_back(std::make_unique<const Acts::BoundTrackParameters>(Acts::BoundTrackParameters(actsParam))); - // const auto& psurface=actsParam.referenceSurface(); - Acts::Vector2 local(actsParam.parameters()[Acts::eBoundLoc0], actsParam.parameters()[Acts::eBoundLoc1]); - // const Acts::Vector3 dir = Acts::makeDirectionUnitFromPhiTheta(actsParam.parameters()[Acts::eBoundPhi], actsParam.parameters()[Acts::eBoundTheta]); - // auto pos=actsParam.position(tgContext); - parm = ConvertActsTrackParameterToATLAS(actsParam, tgContext); - typePattern.set(Trk::TrackStateOnSurface::Measurement); - } - Tracker::FaserSCT_ClusterOnTrack* measState = nullptr; - if (state.hasUncalibrated()) { - auto sp= sps.at(state.uncalibrated().index()); - //const Tracker::FaserSCT_Cluster* fitCluster=&sp; - const Tracker::FaserSCT_Cluster* fitCluster=sp.clusterList().first; - if(fitCluster !=nullptr) { - measState = new Tracker::FaserSCT_ClusterOnTrack{ fitCluster, Trk::LocalParameters { Trk::DefinedParameter { fitCluster->localPosition()[0], Trk::loc1 }, Trk::DefinedParameter { fitCluster->localPosition()[1], Trk::loc2 } }, fitCluster->localCovariance(), m_idHelper->wafer_hash(fitCluster->detectorElement()->identify())}; - } - } - double nDoF = state.calibratedSize(); - const Trk::FitQualityOnSurface *quality = new Trk::FitQualityOnSurface(state.chi2(), nDoF); - const Trk::TrackStateOnSurface *perState = new Trk::TrackStateOnSurface(measState, parm, quality, nullptr, typePattern); - // If a state was succesfully created add it to the trajectory - if (perState) { - finalTrajectory->insert(finalTrajectory->begin(), perState); - } - } - return; - }); - - // Create the track using the states - const Trk::TrackInfo newInfo(Trk::TrackInfo::TrackFitter::KalmanFitter, Trk::ParticleHypothesis::muon); - // Trk::FitQuality* q = nullptr; - // newInfo.setTrackFitter(Trk::TrackInfo::TrackFitter::KalmanFitter ); //Mark the fitter as KalmanFitter - newtrack = std::make_unique<Trk::Track>(newInfo, std::move(*finalTrajectory), nullptr); - } - return newtrack; -} - -const Trk::TrackParameters* -CombinatorialKalmanFilterAlg ::ConvertActsTrackParameterToATLAS(const Acts::BoundTrackParameters &actsParameter, const Acts::GeometryContext& gctx) const { - using namespace Acts::UnitLiterals; - std::optional<AmgSymMatrix(5)> cov = std::nullopt; - if (actsParameter.covariance()){ - AmgSymMatrix(5) newcov(actsParameter.covariance()->topLeftCorner(5, 5)); - // Convert the covariance matrix to GeV - for(int i=0; i < newcov.rows(); i++){ - newcov(i, 4) = newcov(i, 4)*1_MeV; - } - for(int i=0; i < newcov.cols(); i++){ - newcov(4, i) = newcov(4, i)*1_MeV; - } - cov = std::optional<AmgSymMatrix(5)>(newcov); - } - const Amg::Vector3D& pos=actsParameter.position(gctx); - double tphi=actsParameter.get<Acts::eBoundPhi>(); - double ttheta=actsParameter.get<Acts::eBoundTheta>(); - double tqOverP=actsParameter.get<Acts::eBoundQOverP>()*1_MeV; - double p = std::abs(1. / tqOverP); - Amg::Vector3D tmom(p * std::cos(tphi) * std::sin(ttheta), p * std::sin(tphi) * std::sin(ttheta), p * std::cos(ttheta)); - const Trk::CurvilinearParameters * curv = new Trk::CurvilinearParameters(pos,tmom,tqOverP>0, cov); - return curv; -} - diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/MultiTrackFinderTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/MultiTrackFinderTool.cxx index 719088b3ba459d1bb2fd43e22e1bb54e5d7e6cfb..6601eced4b1a221ca0be969fda813e1bf723ea28 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/MultiTrackFinderTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/MultiTrackFinderTool.cxx @@ -39,11 +39,6 @@ StatusCode MultiTrackFinderTool::run() { using IdentifierMap = std::map<Identifier, Acts::GeometryIdentifier>; std::shared_ptr<IdentifierMap> identifierMap = m_trackingGeometryTool->getIdentifierMap(); - // create source links and measurements - const int kSize = 1; - using ThisMeasurement = Acts::Measurement<IndexSourceLink, Acts::BoundIndices, kSize>; - std::array<Acts::BoundIndices, kSize> Indices = {Acts::eBoundLoc0}; - std::map<int, std::vector<Tracklet>> tracklets; for (const Trk::Track* track : *trackCollection) { std::vector<Identifier> ids; diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectoryStatesWriterTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectoryStatesWriterTool.cxx index 8fcf006b8418c677cff8b00508bb1fb7cf666b2a..0fb97b44e9173c1071a461ee3f63b66721fd0aa6 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectoryStatesWriterTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/RootTrajectoryStatesWriterTool.cxx @@ -220,7 +220,12 @@ StatusCode RootTrajectoryStatesWriterTool::write( // Loop over the trajectories for (size_t itraj = 0; itraj < trajectories.size(); ++itraj) { const auto& traj = trajectories[itraj]; - const auto& idLink = idLinks[itraj]; + IdentifierLink idLink; + if (idLinks.size() == 1) { + idLink = idLinks[0]; + } else { + idLink = idLinks[itraj]; + } if (traj.empty()) { ATH_MSG_WARNING("Empty trajectories object " << itraj); diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/SegmentFitClusterTrackFinderTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/SegmentFitClusterTrackFinderTool.cxx index c93808020ea2b180547416401edeb708d240ca43..fe0afbd67bdcc51966c34fc93d02b3104cf1fb65 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/SegmentFitClusterTrackFinderTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/SegmentFitClusterTrackFinderTool.cxx @@ -74,7 +74,7 @@ StatusCode SegmentFitClusterTrackFinderTool::run() { // create measurement const auto& par = cluster->localPosition(); const auto& cov = cluster->localCovariance(); - Eigen::Matrix<double, 1, 1> myCov {0.04 * 0.04,}; + Eigen::Matrix<double, 1, 1> myCov {m_sigmaCluster * m_sigmaCluster,}; ThisMeasurement meas(sourceLink, Indices, par.head(1), myCov); // ThisMeasurement meas(sourceLink, Indices, par.head(1), cov.block<1,1>(0,0)); sourceLinks.push_back(sourceLink); diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/TrackFindingAlgorithmFunction.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/TrackFindingAlgorithmFunction.cxx index 954906a0f4263c6e17f17143b23d4639c5d1107a..2738c3e605e2a932be64929a902b67b99d446a5a 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/TrackFindingAlgorithmFunction.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/TrackFindingAlgorithmFunction.cxx @@ -6,94 +6,50 @@ #include "Acts/Propagator/Propagator.hpp" #include "Acts/TrackFitting/GainMatrixSmoother.hpp" #include "Acts/TrackFitting/GainMatrixUpdater.hpp" -#include "Acts/MagneticField/ConstantBField.hpp" -#include "Acts/MagneticField/InterpolatedBFieldMap.hpp" -#include "Acts/MagneticField/SharedBField.hpp" -#include <boost/variant/variant.hpp> -#include <boost/variant/apply_visitor.hpp> -#include <boost/variant/static_visitor.hpp> +namespace { using Updater = Acts::GainMatrixUpdater; using Smoother = Acts::GainMatrixSmoother; -using Stepper = Acts::EigenStepper<>; -using Propagator = Acts::Propagator<Stepper, Acts::Navigator>; - -namespace ActsExtrapolationDetail { - using VariantPropagatorBase = boost::variant< - Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>, - Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator> - >; - - class VariantPropagator : public VariantPropagatorBase - { - public: - using VariantPropagatorBase::VariantPropagatorBase; - }; -} - -using ActsExtrapolationDetail::VariantPropagator; +using Stepper = Acts::EigenStepper<>; +using Navigator = Acts::Navigator; +using Propagator = Acts::Propagator<Stepper, Navigator>; +using CKF = Acts::CombinatorialKalmanFilter<Propagator, Updater, Smoother>; +using TrackParametersContainer = std::vector<CombinatorialKalmanFilterAlg::TrackParameters>; -template <typename TrackFinder> -struct TrackFinderFunctionImpl { - TrackFinder trackFinder; +struct TrackFinderFunctionImpl + : public CombinatorialKalmanFilterAlg::TrackFinderFunction { + CKF trackFinder; - TrackFinderFunctionImpl(TrackFinder&& f) : trackFinder(std::move(f)) {} + TrackFinderFunctionImpl(CKF&& f) : trackFinder(std::move(f)) {} CombinatorialKalmanFilterAlg::TrackFinderResult operator()( - const IndexSourceLinkContainer& sourceLinks, - const std::vector<Acts::CurvilinearTrackParameters>& initialParameters, - const CombinatorialKalmanFilterAlg::TrackFinderOptions& options) const - { - return trackFinder.findTracks(sourceLinks, initialParameters, options); - } + const IndexSourceLinkContainer& sourcelinks, + const TrackParametersContainer& initialParameters, + const CombinatorialKalmanFilterAlg::TrackFinderOptions& options) + const override { + return trackFinder.findTracks(sourcelinks, initialParameters, options); + }; }; +} // namespace -CombinatorialKalmanFilterAlg::TrackFinderFunction +std::shared_ptr<CombinatorialKalmanFilterAlg::TrackFinderFunction> CombinatorialKalmanFilterAlg::makeTrackFinderFunction( - std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry) -{ - const std::string fieldMode = "FASER"; - const std::vector<double> constantFieldVector = {0., 0., 0.55}; - - Acts::Navigator::Config cfg{trackingGeometry}; - cfg.resolvePassive = false; - cfg.resolveMaterial = true; + std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry) { + auto magneticField = std::make_shared<FASERMagneticFieldWrapper>(); + Stepper stepper(std::move(magneticField)); + Navigator::Config cfg{trackingGeometry}; + cfg.resolvePassive = false; + cfg.resolveMaterial = true; cfg.resolveSensitive = true; - Acts::Navigator navigator( cfg ); - - std::unique_ptr<ActsExtrapolationDetail::VariantPropagator> varProp; - - if (fieldMode == "FASER") { - auto bField = std::make_shared<FASERMagneticFieldWrapper>(); - auto stepper = Acts::EigenStepper<>(std::move(bField)); - auto propagator = Acts::Propagator<decltype(stepper), Acts::Navigator>(std::move(stepper), - std::move(navigator)); - varProp = std::make_unique<VariantPropagator>(propagator); - } - else if (fieldMode == "Constant") { - Acts::Vector3 constantFieldVector = Acts::Vector3(constantFieldVector[0], - constantFieldVector[1], - constantFieldVector[2]); - - auto bField = std::make_shared<Acts::ConstantBField>(constantFieldVector); - auto stepper = Acts::EigenStepper<>(std::move(bField)); - auto propagator = Acts::Propagator<decltype(stepper), Acts::Navigator>(std::move(stepper), - std::move(navigator)); - varProp = std::make_unique<VariantPropagator>(propagator); - } + Navigator navigator(cfg); + Propagator propagator(std::move(stepper), std::move(navigator)); + CKF trackFinder(std::move(propagator)); - return boost::apply_visitor([&](const auto& propagator) -> TrackFinderFunction { - using Updater = Acts::GainMatrixUpdater; - using Smoother = Acts::GainMatrixSmoother; - using CKF = Acts::CombinatorialKalmanFilter<typename std::decay_t<decltype(propagator)>, Updater, Smoother>; - - CKF trackFinder(std::move(propagator)); - - return TrackFinderFunctionImpl<CKF>(std::move(trackFinder)); - }, *varProp); -} \ No newline at end of file + // build the track finder functions. owns the track finder object. + return std::make_shared<TrackFinderFunctionImpl>(std::move(trackFinder)); +} diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx index 451ceddd274ea1307814135c85804d6aeeaf01c2..15c0fbc413476f9da38938f4c15b2f098777eff1 100755 --- a/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx @@ -16,6 +16,7 @@ #include "FaserActsKalmanFilter/RootTrajectoryStatesWriterTool.h" #include "FaserActsKalmanFilter/SegmentFitClusterTrackFinderTool.h" //#include "FaserActsKalmanFilter/SegmentFitTrackFinderTool.h" +#include "FaserActsKalmanFilter/ClusterTrackSeedTool.h" DECLARE_COMPONENT(FaserActsKalmanFilterAlg) @@ -32,3 +33,4 @@ DECLARE_COMPONENT(SegmentFitClusterTrackFinderTool) //DECLARE_COMPONENT(SegmentFitTrackFinderTool) DECLARE_COMPONENT(RootTrajectoryStatesWriterTool) DECLARE_COMPONENT(MultiTrackFinderTool) +DECLARE_COMPONENT(ClusterTrackSeedTool) diff --git a/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py b/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py index eef29095e39bc064e2dde11149be503b0d0d79ea..ff2749341fba499f92d86e5afedf5ec1ab96e354 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py +++ b/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py @@ -9,18 +9,16 @@ 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 TrackerSeedFinder.TrackerSeedFinderConfig import TrackerSeedFinderCfg +from TrackerSegmentFit.TrackerSegmentFitConfig import SegmentFitAlgCfg from FaserActsKalmanFilter.CombinatorialKalmanFilterConfig import CombinatorialKalmanFilterCfg log.setLevel(DEBUG) Configurable.configurableRun3Behavior = True ConfigFlags.Input.Files = ['my.RDO.pool.root'] -ConfigFlags.Output.ESDFileName = "myCKF.ESD.pool.root" -ConfigFlags.Output.AODFileName = "myCKF.AOD.pool.root" +ConfigFlags.Output.ESDFileName = "CKF.ESD.pool.root" ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" -# ConfigFlags.GeoModel.FaserVersion = "FASER-01" +ConfigFlags.GeoModel.FaserVersion = "FASER-01" ConfigFlags.GeoModel.Align.Dynamic = False ConfigFlags.Beam.NumberOfCollisions = 0. ConfigFlags.lock() @@ -30,9 +28,9 @@ acc.merge(PoolReadCfg(ConfigFlags)) # acc.merge(PoolWriteCfg(ConfigFlags)) acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) -acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) -acc.merge(TrackerSeedFinderCfg(ConfigFlags)) +acc.merge(SegmentFitAlgCfg(ConfigFlags)) acc.merge(CombinatorialKalmanFilterCfg(ConfigFlags)) +acc.getEventAlgo("CombinatorialKalmanFilterAlg").OutputLevel = VERBOSE # logging.getLogger('forcomps').setLevel(INFO) # acc.foreach_component("*").OutputLevel = INFO @@ -42,6 +40,5 @@ acc.merge(CombinatorialKalmanFilterCfg(ConfigFlags)) # acc.printConfig(withDetails=True) # ConfigFlags.dump() -sc = acc.run(maxEvents=1000) - +sc = acc.run(maxEvents=100) sys.exit(not sc.isSuccess()) diff --git a/Tracking/Acts/FaserActsKalmanFilter/test/FaserActsKalmanFilterAlg.py b/Tracking/Acts/FaserActsKalmanFilter/test/FaserActsKalmanFilterAlg.py index ad51ab5394d041f583030eac6dd0c3fa5d972eea..e1b08a986408ad409f67cb99e21afaafe2205965 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/test/FaserActsKalmanFilterAlg.py +++ b/Tracking/Acts/FaserActsKalmanFilter/test/FaserActsKalmanFilterAlg.py @@ -21,7 +21,7 @@ log.setLevel(DEBUG) Configurable.configurableRun3Behavior = True # Configure -ConfigFlags.Input.Files = ['my.RDO.pool.root'] +ConfigFlags.Input.Files = ['../my.RDO.pool.root'] ConfigFlags.Output.ESDFileName = "FaserActsKalmanFilter.ESD.root" ConfigFlags.Output.AODFileName = "FaserActsKalmanFilter.AOD.pool.root" ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" @@ -40,7 +40,7 @@ acc.merge(SegmentFitAlgCfg(ConfigFlags)) # acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) # acc.merge(TruthSeededTrackFinderCfg(ConfigFlags)) acc.merge(FaserActsKalmanFilterCfg(ConfigFlags)) -acc.getEventAlgo("FaserActsKalmanFilterAlg").OutputLevel = DEBUG +acc.getEventAlgo("FaserActsKalmanFilterAlg").OutputLevel = INFO # logging.getLogger('forcomps').setLevel(VERBOSE) # acc.foreach_component("*").OutputLevel = VERBOSE @@ -51,5 +51,5 @@ acc.getEventAlgo("FaserActsKalmanFilterAlg").OutputLevel = DEBUG # ConfigFlags.dump() # Execute and finish -sc = acc.run(maxEvents=-1) +sc = acc.run(maxEvents=1000) sys.exit(not sc.isSuccess()) diff --git a/Tracking/Acts/FaserActsKalmanFilter/test/TI12KalmanFilter.py b/Tracking/Acts/FaserActsKalmanFilter/test/TI12KalmanFilter.py index 0a8dc9ae131fb78410da19250f36155e12912367..411aafd8dad72c410dc5b26774ce79fa2914ca02 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/test/TI12KalmanFilter.py +++ b/Tracking/Acts/FaserActsKalmanFilter/test/TI12KalmanFilter.py @@ -40,7 +40,7 @@ acc = MainServicesCfg(ConfigFlags) acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags)) acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) acc.merge(SegmentFitAlgCfg(ConfigFlags)) -acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +# acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) acc.merge(FaserActsKalmanFilterCfg(ConfigFlags)) acc.getEventAlgo("FaserActsKalmanFilterAlg").OutputLevel = DEBUG