File indexing completed on 2026-05-07 08:04:19
0001
0002 #include <Acts/Definitions/Algebra.hpp>
0003 #include <Acts/EventData/TrackContainer.hpp>
0004 #include <Acts/EventData/TrackProxy.hpp>
0005 #include <Acts/EventData/VectorMultiTrajectory.hpp>
0006 #include <Acts/EventData/VectorTrackContainer.hpp>
0007 #include <Acts/Surfaces/DiscSurface.hpp>
0008 #include <Acts/Surfaces/RadialBounds.hpp>
0009 #include <Acts/Surfaces/Surface.hpp>
0010 #include <ActsExamples/EventData/Track.hpp>
0011 #include <JANA/JApplication.h>
0012 #include <JANA/JApplicationFwd.h>
0013 #include <JANA/JEvent.h>
0014 #include <JANA/JException.h>
0015 #include <JANA/Services/JGlobalRootLock.h>
0016 #include <edm4eic/TrackCollection.h>
0017 #include <edm4eic/TrackPoint.h>
0018 #include <edm4hep/Vector3f.h>
0019 #include <fmt/format.h>
0020 #include <spdlog/logger.h>
0021 #include <Eigen/Geometry>
0022 #include <exception>
0023 #include <map>
0024 #include <string>
0025 #include <vector>
0026
0027 #include "TrackPropagation.h"
0028 #include "TrackPropagationTest_processor.h"
0029 #include "services/rootfile/RootFile_service.h"
0030
0031
0032
0033
0034 void TrackPropagationTest_processor::Init() {
0035 std::string plugin_name = ("track_propagation_test");
0036
0037
0038 auto* app = GetApplication();
0039
0040
0041 auto root_file_service = app->GetService<RootFile_service>();
0042
0043
0044 auto globalRootLock = app->GetService<JGlobalRootLock>();
0045 globalRootLock->acquire_write_lock();
0046 auto* file = root_file_service->GetHistFile();
0047 globalRootLock->release_lock();
0048
0049
0050 m_dir_main = file->mkdir(plugin_name.c_str());
0051
0052
0053 InitLogger(app, plugin_name);
0054
0055
0056 m_propagation_algo = std::make_unique<eicrecon::TrackPropagation>("TrackPropagationTest");
0057 m_propagation_algo->init();
0058
0059
0060 auto transform = Acts::Transform3::Identity();
0061
0062
0063 const auto hcalEndcapNZ = -3322.;
0064 const auto hcalEndcapNMinR = 83.01;
0065 const auto hcalEndcapNMaxR = 950;
0066 auto hcalEndcapNBounds = std::make_shared<Acts::RadialBounds>(hcalEndcapNMinR, hcalEndcapNMaxR);
0067 auto hcalEndcapNTrf = transform * Acts::Translation3(Acts::Vector3(0, 0, hcalEndcapNZ));
0068 m_hcal_surface = Acts::Surface::makeShared<Acts::DiscSurface>(hcalEndcapNTrf, hcalEndcapNBounds);
0069 }
0070
0071
0072
0073
0074
0075 void TrackPropagationTest_processor::Process(const std::shared_ptr<const JEvent>& event) {
0076 m_log->trace("TrackPropagationTest_processor event");
0077
0078
0079 auto track_states = event->Get<Acts::ConstVectorMultiTrajectory>("CentralCKFActsTrackStates");
0080 auto tracks = event->Get<Acts::ConstVectorTrackContainer>("CentralCKFActsTracks");
0081
0082 if (track_states.empty() || tracks.empty()) {
0083 m_log->debug("No track containers found");
0084 return;
0085 }
0086
0087
0088 auto trackStateContainer =
0089 std::make_shared<Acts::ConstVectorMultiTrajectory>(*track_states.front());
0090 auto trackContainer = std::make_shared<Acts::ConstVectorTrackContainer>(*tracks.front());
0091 ActsExamples::ConstTrackContainer track_container(trackContainer, trackStateContainer);
0092
0093
0094 m_log->debug("Propagating through {} tracks", track_container.size());
0095 for (const auto& track : track_container) {
0096 m_log->trace(" -- track {} --", track.index());
0097
0098 std::unique_ptr<edm4eic::TrackPoint> projection_point;
0099 try {
0100
0101 projection_point =
0102 m_propagation_algo->propagate(edm4eic::Track{}, track, track_container, m_hcal_surface);
0103 } catch (std::exception& e) {
0104 throw JException(e.what());
0105 }
0106
0107 if (!projection_point) {
0108 m_log->trace(" could not propagate track {}!", track.index());
0109 continue;
0110 }
0111
0112
0113
0114 auto pos = projection_point->position;
0115 auto length = projection_point->pathlength;
0116 m_log->trace(" {:>10} {:>10.2f} {:>10.2f} {:>10.2f} {:>10.2f}", track.index(), pos.x, pos.y,
0117 pos.z, length);
0118 }
0119 }
0120
0121
0122
0123
0124 void TrackPropagationTest_processor::Finish() {
0125
0126 }