File indexing completed on 2025-01-18 09:13:15
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/ToolHandle.h"
0011
0012 #include "JugBase/DataHandle.h"
0013 #include "JugBase/IGeoSvc.h"
0014 #include "JugTrack/ProtoTrack.hpp"
0015 #include "JugTrack/Track.hpp"
0016
0017 #include "Math/Vector3D.h"
0018
0019 #include "edm4eic/TrackerHitCollection.h"
0020
0021 namespace Jug::Reco {
0022
0023
0024
0025
0026
0027 class ProtoTrackMatching : public GaudiAlgorithm {
0028 private:
0029 DataHandle<edm4eic::TrackerHitCollection> m_inputTrackerHits{"inputTrackerHits", Gaudi::DataHandle::Reader, this};
0030 DataHandle<TrackParametersContainer> m_initialTrackParameters{"initialTrackParameters", Gaudi::DataHandle::Reader, this};
0031 DataHandle<ProtoTrackContainer> m_inputProtoTracks{"inputProtoTracks", Gaudi::DataHandle::Reader, this};
0032 DataHandle<ProtoTrackContainer> m_outputProtoTracks{"matchedProtoTracks", Gaudi::DataHandle::Writer, this};
0033
0034 public:
0035 ProtoTrackMatching(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
0036 declareProperty("inputTrackerHits", m_inputTrackerHits, "");
0037 declareProperty("initialTrackParameters", m_initialTrackParameters, "");
0038 declareProperty("inputProtoTracks", m_inputProtoTracks, "");
0039 declareProperty("matchedProtoTracks", m_outputProtoTracks, "proto tracks matched to initial track parameters");
0040 }
0041
0042 StatusCode initialize() override {
0043 if (GaudiAlgorithm::initialize().isFailure()) {
0044 return StatusCode::FAILURE;
0045 }
0046 return StatusCode::SUCCESS;
0047 }
0048
0049 StatusCode execute() override {
0050
0051
0052
0053
0054
0055 const auto* const proto_tracks = m_inputProtoTracks.get();
0056 const auto* const initialParameters = m_initialTrackParameters.get();
0057
0058
0059 auto* matched_proto_tracks = m_outputProtoTracks.createAndPut();
0060
0061 int n_tracks = initialParameters->size();
0062 int n_proto_tracks = proto_tracks->size();
0063
0064
0065 if(n_proto_tracks < n_tracks) {
0066 warning() << " Number of proto tracks does not match the initial track parameters." << endmsg;
0067 if(n_proto_tracks == 0 ) {
0068 warning() << " Zero proto tracks to match! " << endmsg;
0069 return StatusCode::SUCCESS;
0070 }
0071 }
0072
0073
0074 if (msgLevel(MSG::DEBUG)) {
0075 debug() << " ntracks " << n_tracks << endmsg;
0076 debug() << " n_proto_tracks " << n_proto_tracks << endmsg;
0077 }
0078
0079 for (int itrack = 0; itrack < n_tracks; itrack++) {
0080
0081
0082
0083
0084
0085
0086
0087
0088 if( n_proto_tracks <= itrack) {
0089 matched_proto_tracks->push_back( proto_tracks->back() );
0090 } else {
0091 matched_proto_tracks->push_back( (*proto_tracks)[itrack] );
0092 }
0093
0094
0095
0096
0097
0098 }
0099 return StatusCode::SUCCESS;
0100 }
0101 };
0102
0103 DECLARE_COMPONENT(ProtoTrackMatching)
0104
0105 }