Skip to content

Commit

Permalink
Code reintegration
Browse files Browse the repository at this point in the history
  • Loading branch information
DraTeots committed Nov 20, 2024
1 parent aee1808 commit e1f0a39
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 45 deletions.
30 changes: 8 additions & 22 deletions source/tdis/tracking/CKFTracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,35 @@
#include <Acts/Definitions/TrackParametrization.hpp>
#include <Acts/Definitions/Units.hpp>
#include <Acts/EventData/GenericBoundTrackParameters.hpp>
#if Acts_VERSION_MAJOR < 36
#include <Acts/EventData/Measurement.hpp>
#endif
#include <Acts/EventData/MultiTrajectory.hpp>
#include <Acts/EventData/ParticleHypothesis.hpp>
#if Acts_VERSION_MAJOR >= 32
#include "Acts/EventData/ProxyAccessor.hpp"
#endif
#include <Acts/EventData/SourceLink.hpp>
#include <Acts/EventData/TrackContainer.hpp>
#include <Acts/EventData/TrackProxy.hpp>
#include <Acts/EventData/VectorMultiTrajectory.hpp>
#include <Acts/EventData/VectorTrackContainer.hpp>
#include <Acts/Geometry/GeometryIdentifier.hpp>
#if Acts_VERSION_MAJOR >= 34
#include "Acts/Propagator/AbortList.hpp"
#include "Acts/Propagator/EigenStepper.hpp"
#include "Acts/Propagator/MaterialInteractor.hpp"
#include "Acts/Propagator/Navigator.hpp"
#endif
#include <Acts/Propagator/Propagator.hpp>
#if Acts_VERSION_MAJOR >= 34
#include "Acts/Propagator/StandardAborters.hpp"
#endif

#include <Acts/Surfaces/PerigeeSurface.hpp>
#include <Acts/Surfaces/Surface.hpp>
#include <Acts/TrackFitting/GainMatrixSmoother.hpp>
#include <Acts/TrackFitting/GainMatrixUpdater.hpp>
#include <Acts/Utilities/Logger.hpp>
#if Acts_VERSION_MAJOR >= 34

#include "Acts/Utilities/TrackHelpers.hpp"
#endif

#include <ActsExamples/EventData/IndexSourceLink.hpp>
#include <ActsExamples/EventData/Measurement.hpp>
#include <ActsExamples/EventData/MeasurementCalibration.hpp>
#include <ActsExamples/EventData/Track.hpp>
#include <edm4eic/Cov3f.h>
#include <edm4eic/Cov6f.h>
#include <edm4eic/Measurement2DCollection.h>
#include <edm4eic/TrackParametersCollection.h>
#include <edm4hep/Vector2f.h>
#include <podio_model/Cov3f.h>
#include <podio_model/Cov6f.h>
#include <podio_model/Measurement2DCollection.h>
#include <podio_model/TrackParametersCollection.h>
#include <podio_model/Vector2f.h>
#include <fmt/core.h>
#include <Eigen/Core>
#include <array>
Expand All @@ -58,8 +46,6 @@
#include <optional>
#include <utility>

#include "ActsGeometryProvider.h"
#include "DD4hepBField.h"
#include "extensions/spdlog/SpdlogFormatters.h" // IWYU pragma: keep
#include "extensions/spdlog/SpdlogToActs.h"

Expand Down
25 changes: 5 additions & 20 deletions source/tdis/tracking/CKFTracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
#include <ActsExamples/EventData/IndexSourceLink.hpp>
#include <ActsExamples/EventData/Track.hpp>
#include <ActsExamples/EventData/Trajectories.hpp>
#include <edm4eic/Measurement2DCollection.h>
#include <edm4eic/TrackParametersCollection.h>
#include <podio_model/Measurement2DCollection.h>
#include <podio_model/TrackParametersCollection.h>
#include <spdlog/logger.h>
#include <memory>
#include <tuple>
#include <vector>

#include "CKFTrackingConfig.h"

#include "DD4hepBField.h"
#include "algorithms/interfaces/WithPodConfig.h"


class ActsGeometryProvider;

Expand All @@ -36,7 +36,7 @@ namespace eicrecon {
* \ingroup tracking
*/

class CKFTracking: public WithPodConfig<eicrecon::CKFTrackingConfig> {
class CKFTracking {
public:


Expand Down Expand Up @@ -71,21 +71,6 @@ namespace eicrecon {
process(const edm4eic::Measurement2DCollection& meas2Ds,
const edm4eic::TrackParametersCollection &init_trk_params);

private:
std::shared_ptr<spdlog::logger> m_log;
std::shared_ptr<const Acts::Logger> m_acts_logger{nullptr};
std::shared_ptr<CKFTrackingFunction> m_trackFinderFunc;
std::shared_ptr<const ActsGeometryProvider> m_geoSvc;

std::shared_ptr<const eicrecon::BField::DD4hepBField> m_BField = nullptr;
Acts::GeometryContext m_geoctx;
Acts::CalibrationContext m_calibctx;
Acts::MagneticFieldContext m_fieldctx;

Acts::MeasurementSelector::Config m_sourcelinkSelectorCfg;

/// Private access to the logging instance
const Acts::Logger& logger() const { return *m_acts_logger; }
};

} // namespace eicrecon::Reco
62 changes: 61 additions & 1 deletion source/tdis/tracking/KalmanFittingFactory.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,59 @@
#pragma once

#include <JANA/JFactory.h>
#include <JANA/Components/JOmniFactory.h>
#include <JANA/JFactory.h>

#include <ActsExamples/EventData/Track.hpp>

namespace tdis::tracking {



struct KalmanFittingFactory : public JOmniFactory<KalmanFittingFactory> {

PodioInput<tdis::DigitizedMtpcMcHit> m_mc_hits_in{this, {"DigitizedMtpcMcHit"}};
PodioOutput<edm4eic::TrackerHit> m_tracker_hits_out{this, "TrackerHit"};
PodioOutput<edm4eic::Measurement2D> m_measurements_out{this, "Measurement2D"};
Service<ActsGeometryService> m_service_geometry{this};
Service<services::LogService> m_service_log{this};
Parameter<bool> m_cfg_use_true_pos{this, "acts:use_true_position", true, "Use true hits xyz instead of digitized one"};


// Construct a propagator using a constant magnetic field along z.
template <typename stepper_t>
auto makeConstantFieldPropagator(
std::shared_ptr<const Acts::TrackingGeometry> geo, double bz) {
Acts::Navigator::Config cfg{std::move(geo)};
cfg.resolvePassive = false;
cfg.resolveMaterial = true;
cfg.resolveSensitive = true;
Acts::Navigator navigator(
cfg, Acts::getDefaultLogger("Navigator", Acts::Logging::INFO));
auto field =
std::make_shared<Acts::ConstantBField>(Acts::Vector3(0.0, 0.0, bz));
stepper_t stepper(std::move(field));
return Acts::Propagator<decltype(stepper), Acts::Navigator>(
std::move(stepper), std::move(navigator));
}

void Configure() {
m_log = log;
m_acts_logger = eicrecon::getSpdlogLogger("CKF", m_log);

m_geoSvc = geo_svc;

m_BField = std::dynamic_pointer_cast<const eicrecon::BField::DD4hepBField>(m_geoSvc->getFieldProvider());
m_fieldctx = eicrecon::BField::BFieldVariant(m_BField);

// eta bins, chi2 and #sourclinks per surface cutoffs
m_sourcelinkSelectorCfg = {
{Acts::GeometryIdentifier(),
{m_cfg.etaBins, m_cfg.chi2CutOff,
{m_cfg.numMeasurementsCutOff.begin(), m_cfg.numMeasurementsCutOff.end()}
}
},
};
m_trackFinderFunc = CKFTracking::makeCKFTrackingFunction(m_geoSvc->trackingGeometry(), m_BField, logger());
}

void ChangeRun(int32_t /*run_nr*/) {
Expand All @@ -19,6 +63,22 @@ namespace tdis::tracking {


}
private:
std::shared_ptr<spdlog::logger> m_log;
std::shared_ptr<const Acts::Logger> m_acts_logger{nullptr};
std::shared_ptr<CKFTrackingFunction> m_trackFinderFunc;
std::shared_ptr<const ActsGeometryProvider> m_geoSvc;

std::shared_ptr<const eicrecon::BField::DD4hepBField> m_BField = nullptr;
Acts::GeometryContext m_geoctx;
Acts::CalibrationContext m_calibctx;
Acts::MagneticFieldContext m_fieldctx;

Acts::MeasurementSelector::Config m_sourcelinkSelectorCfg;

/// Private access to the logging instance
const Acts::Logger& logger() const { return *m_acts_logger; }

};

}
3 changes: 1 addition & 2 deletions source/tdis/tracking/ReconstructedHitFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ namespace tdis::tracking {
PodioOutput<edm4eic::Measurement2D> m_measurements_out{this, "Measurement2D"};
Service<ActsGeometryService> m_service_geometry{this};
Service<services::LogService> m_service_log{this};
Parameter<bool> m_cfg_use_true_pos{this, "acts:use_true_position", true,
"Use true hits xyz instead of digitized one"};
Parameter<bool> m_cfg_use_true_pos{this, "acts:use_true_position", true, "Use true hits xyz instead of digitized one"};

std::shared_ptr<spdlog::logger> m_log;

Expand Down

0 comments on commit e1f0a39

Please sign in to comment.