File indexing completed on 2024-09-28 07:02:22
0001
0002
0003
0004 #include <cmath>
0005
0006 #include "Gaudi/Property.h"
0007 #include "GaudiAlg/GaudiAlgorithm.h"
0008 #include "GaudiAlg/GaudiTool.h"
0009 #include "GaudiAlg/Transformer.h"
0010 #include "GaudiKernel/RndmGenerators.h"
0011 #include "GaudiKernel/ToolHandle.h"
0012
0013 #include "Acts/Definitions/Common.hpp"
0014 #include "Acts/Definitions/Units.hpp"
0015 #include "JugBase/DataHandle.h"
0016 #include "JugBase/IGeoSvc.h"
0017 #include "JugTrack/Track.hpp"
0018
0019 #include "edm4eic/ClusterCollection.h"
0020 #include "edm4eic/TrackerHitCollection.h"
0021 #include "edm4hep/utils/vector_utils.h"
0022
0023 #include "Acts/Surfaces/PerigeeSurface.hpp"
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 namespace Jug::Reco {
0038
0039
0040
0041
0042
0043
0044
0045 class TrackParamClusterInit : public GaudiAlgorithm {
0046 private:
0047 using Clusters = edm4eic::ClusterCollection;
0048
0049 DataHandle<Clusters> m_inputClusters{"inputClusters", Gaudi::DataHandle::Reader, this};
0050 DataHandle<TrackParametersContainer> m_outputInitialTrackParameters{"outputInitialTrackParameters",
0051 Gaudi::DataHandle::Writer, this};
0052
0053 public:
0054 TrackParamClusterInit(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
0055 declareProperty("inputClusters", m_inputClusters, "Input clusters");
0056 declareProperty("outputInitialTrackParameters", m_outputInitialTrackParameters, "");
0057 }
0058
0059 StatusCode initialize() override {
0060 if (GaudiAlgorithm::initialize().isFailure()) {
0061 return StatusCode::FAILURE;
0062 }
0063 IRndmGenSvc* randSvc = svc<IRndmGenSvc>("RndmGenSvc", true);
0064 if (randSvc == nullptr) {
0065 return StatusCode::FAILURE;
0066 }
0067 return StatusCode::SUCCESS;
0068 }
0069
0070 StatusCode execute() override {
0071
0072 const auto* const clusters = m_inputClusters.get();
0073
0074 auto* init_trk_params = m_outputInitialTrackParameters.createAndPut();
0075
0076 for (const auto& c : *clusters) {
0077
0078 using Acts::UnitConstants::GeV;
0079 using Acts::UnitConstants::MeV;
0080 using Acts::UnitConstants::mm;
0081 using Acts::UnitConstants::ns;
0082
0083 double p = c.getEnergy() * GeV;
0084 if (p < 0.1 * GeV) {
0085 continue;
0086 }
0087 double len = edm4hep::utils::magnitude(c.getPosition());
0088 auto momentum = c.getPosition() * p / len;
0089
0090 Acts::BoundVector params;
0091 params(Acts::eBoundLoc0) = 0.0 * mm;
0092 params(Acts::eBoundLoc1) = 0.0 * mm;
0093 params(Acts::eBoundPhi) = edm4hep::utils::angleAzimuthal(momentum);
0094 params(Acts::eBoundTheta) = edm4hep::utils::anglePolar(momentum);
0095 params(Acts::eBoundQOverP) = 1 / p;
0096 params(Acts::eBoundTime) = 0 * ns;
0097
0098 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3{0, 0, 0});
0099
0100 if (msgLevel(MSG::DEBUG)) {
0101 debug() << "Invoke track finding seeded by truth particle with p = " << p / GeV << " GeV" << endmsg;
0102 }
0103
0104
0105 init_trk_params->push_back({pSurface, params, 1});
0106
0107 Acts::BoundVector params2;
0108 params2(Acts::eBoundLoc0) = 0.0 * mm;
0109 params2(Acts::eBoundLoc1) = 0.0 * mm;
0110 params2(Acts::eBoundPhi) = edm4hep::utils::angleAzimuthal(momentum);
0111 params2(Acts::eBoundTheta) = edm4hep::utils::anglePolar(momentum);
0112 params2(Acts::eBoundQOverP) = -1 / p;
0113 params2(Acts::eBoundTime) = 0 * ns;
0114 init_trk_params->push_back({pSurface, params2, -1});
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 }
0129 return StatusCode::SUCCESS;
0130 }
0131 };
0132
0133 DECLARE_COMPONENT(TrackParamClusterInit)
0134
0135 }