From b1077d68006e7f0104d5afd4d04b85c74d448c47 Mon Sep 17 00:00:00 2001 From: Rosie-Hasan Date: Tue, 26 Sep 2023 11:39:15 +0100 Subject: [PATCH] first step of implementing necessary classes from FTF and 2 funcitons, currently blank inner function --- Core/include/Acts/Seeding/SeedFinderFTF.hpp | 22 ++- Core/include/Acts/Seeding/SeedFinderFTF.ipp | 84 +++++++++++- .../Acts/Seeding/SeedFinderFTFConfig.hpp | 1 + Core/include/Acts/Seeding/TrigBase.hpp | 126 ++++++++++++++++++ .../TrackFinding/src/SeedingFTFAlgorithm.cpp | 3 +- 5 files changed, 229 insertions(+), 7 deletions(-) create mode 100644 Core/include/Acts/Seeding/TrigBase.hpp diff --git a/Core/include/Acts/Seeding/SeedFinderFTF.hpp b/Core/include/Acts/Seeding/SeedFinderFTF.hpp index b69146e7682..3635ebab429 100644 --- a/Core/include/Acts/Seeding/SeedFinderFTF.hpp +++ b/Core/include/Acts/Seeding/SeedFinderFTF.hpp @@ -8,6 +8,7 @@ #include "Acts/Seeding/SeedFinderConfig.hpp" #include "Acts/Seeding/SeedFinderFTFConfig.hpp" #include "Acts/Utilities/KDTree.hpp" +#include "Acts/Seeding/TrigBase.hpp" //definition of Trigsispacepoint base and trigtriplets #include #include @@ -21,6 +22,17 @@ namespace Acts { +template +struct GNN_TrigTracklet{ + public: + GNN_TrigTracklet(std::vector*>& vSP, std::vector>& tbuf) : m_track(vSP), m_seeds(tbuf) {}; + ~GNN_TrigTracklet() {}; + + std::vector*> m_track; + std::vector> m_seeds; + +}; + template class SeedFinderFTF { public: @@ -42,16 +54,18 @@ class SeedFinderFTF { void loadSpacePoints(const std::vector> &); + void createSeeds(); + // create seeeds function template - void createSeeds(const Acts::SeedFinderOptions &options, + void createSeeds_old(const Acts::SeedFinderOptions &options, const input_container_t &spacePoints, output_container_t &out_cont, callable_t &&extract_coordinates) const; template - std::vector createSeeds(const Acts::SeedFinderOptions &options, + std::vector createSeeds_old(const Acts::SeedFinderOptions &options, const input_container_t &spacePoints, callable_t &&extract_coordinates) const; @@ -61,8 +75,12 @@ class SeedFinderFTF { // config object SeedFinderFTFConfig m_config; + void runGNN_TrackFinder(std::vector>&); + // needs to be memeber of class so can accessed by all memeber functions TrigFTF_GNN_DataStorage *m_storage; + + std::vector> m_triplets; }; } // namespace Acts diff --git a/Core/include/Acts/Seeding/SeedFinderFTF.ipp b/Core/include/Acts/Seeding/SeedFinderFTF.ipp index 1e24c2c5c51..8e3573c7e90 100644 --- a/Core/include/Acts/Seeding/SeedFinderFTF.ipp +++ b/Core/include/Acts/Seeding/SeedFinderFTF.ipp @@ -62,11 +62,87 @@ void SeedFinderFTF::loadSpacePoints( m_storage->generatePhiIndexing(1.5 * m_config.m_phiSliceWidth); } -// still to be developed + +template +void SeedFinderFTF::runGNN_TrackFinder(std::vector>&){ + + // const int MaxEdges = 2000000; + + // const float cut_dphi_max = 0.012; + // const float cut_dcurv_max = 0.001; + // const float cut_tau_ratio_max = 0.007; + // const float min_z0 = -2800; //roiDescriptor->zedMinus(); //blank for now, get from config eventually + // const float max_z0 = 2800; //roiDescriptor->zedPlus(); + + // const float maxOuterRadius = 550.0; + // const float cut_zMinU = min_z0 // + maxOuterRadius*roiDescriptor->dzdrMinus(); + // const float cut_zMaxU = max_z0 // + maxOuterRadius*roiDescriptor->dzdrPlus(); + + // float m_minR_squ = 1 ; //set earlier + // float m_maxCurv = 1 ; + + // const float maxKappa_high_eta = 0.8/m_minR_squ; + // const float maxKappa_low_eta = 0.6/m_minR_squ; + + // //1. loop over stages + + // int currentStage = 0; + + // const FASTRACK_CONNECTOR& conn = *(m_settings.m_conn); //turn into class name and template! + + // std::vector> edgeStorage; + + // edgeStorage.reserve(MaxEdges); + + // int nEdges = 0; + +} + + +template +void SeedFinderFTF::createSeeds(){ + + std::vector> vTracks; //make empty vector + + vTracks.reserve(5000); + + runGNN_TrackFinder(vTracks); //returns filled vector + + if(vTracks.empty()) return; + + m_triplets.clear(); //member of class , saying not declared, maybe public? + + for(auto& track : vTracks) { + for(auto& seed : track.m_seeds) { //access mmeber of GNN_TrigTracklet + + float newQ = seed.Q(); //function of TrigInDetTriplet + if (m_config.m_LRTmode) { //dont have settings, just bool for now? + // In LRT mode penalize pixels in Triplets + if(seed.s1().isPixel()) newQ+=1000; //functions of TrigSiSpacePointBase + if(seed.s2().isPixel()) newQ+=1000; + if(seed.s3().isPixel()) newQ+=1000; + } else { + // In normal (non LRT) mode penalise SSS by 1000, PSS (if enabled) and PPS by 10000 + if(seed.s3().isSCT()) { //functions of TrigSiSpacePointBase + newQ += seed.s1().isSCT() ? 1000.0 : 10000.0; + } + } + seed.Q(newQ); + m_triplets.emplace_back(seed); + } + } + vTracks.clear(); + + + +} + + +// // still to be developed template template -void SeedFinderFTF::createSeeds( +void SeedFinderFTF::createSeeds_old( const Acts::SeedFinderOptions &options, const input_container_t &spacePoints, output_container_t &out_cont, callable_t &&extract_coordinates) const {} @@ -74,12 +150,12 @@ void SeedFinderFTF::createSeeds( template template std::vector> -SeedFinderFTF::createSeeds( +SeedFinderFTF::createSeeds_old( const Acts::SeedFinderOptions &options, const input_container_t &spacePoints, callable_t &&extract_coordinates) const { std::vector r; - createSeeds(options, spacePoints, r, + createSeeds_old(options, spacePoints, r, std::forward(extract_coordinates)); return r; } diff --git a/Core/include/Acts/Seeding/SeedFinderFTFConfig.hpp b/Core/include/Acts/Seeding/SeedFinderFTFConfig.hpp index 16252495ed2..c3e3134d464 100644 --- a/Core/include/Acts/Seeding/SeedFinderFTFConfig.hpp +++ b/Core/include/Acts/Seeding/SeedFinderFTFConfig.hpp @@ -35,6 +35,7 @@ template struct SeedFinderFTFConfig { float m_phiSliceWidth; float m_nMaxPhiSlice; bool m_useClusterWidth = false; + bool m_LRTmode = true ; //eventually want to set from full chaing std::string fastrack_input_file; std::vector input_vector; diff --git a/Core/include/Acts/Seeding/TrigBase.hpp b/Core/include/Acts/Seeding/TrigBase.hpp new file mode 100644 index 00000000000..0d035da497b --- /dev/null +++ b/Core/include/Acts/Seeding/TrigBase.hpp @@ -0,0 +1,126 @@ +#include + + +#define MAX_SILICON_LAYER_NUM 19 +#define OffsetEndcapPixels 7 +#define OffsetBarrelSCT 3 +#define OffsetEndcapSCT 10 + +template class TrigSiSpacePointBase { + + public: + + // using cylindrical co-ordinates, no. errors + TrigSiSpacePointBase(long layer, + double r, double phi, double z, + double dr=0.0, double dz=0.0, const space_point_t* offlineSpacePoint = nullptr) : + m_layer(layer), + m_r(r), m_phi(phi), m_z(z), + m_dr(dr), m_dz(dz), + m_offlineSpacePoint(offlineSpacePoint) + { + m_x = r * std::cos(phi); + m_y = r * std::sin(phi); + m_barCode=-1; + + + + if (m_offlineSpacePoint) { + if (m_offlineSpacePoint->sourceLinks().size() == 1) { // pixels have 1 SL + m_isPixel = true; + } + else { + m_isPixel = false; + } + } + else { + m_isPixel = false;//Arbitrarily choose value when no offline spacepoint + } + } + + // Destructor + virtual ~TrigSiSpacePointBase() = default; + + // Methods to set data members + void r( const double r ) {m_r = r; } + void phi(const double phi) {m_phi = phi;} + void z( const double z ) {m_z = z; } + void x( const double x ) {m_x = x; } + void y( const double y ) {m_y = y; } + void dr( const double dr ) {m_dr = dr; } + void dz( const double dz ) {m_dz = dz; } + + void barCode(int code) {m_barCode = code;} + + double r() const {return m_r;} + double phi() const {return m_phi;} + double z() const {return m_z;} + double dr() const {return m_dr;} + double dz() const {return m_dz;} + double x() const {return m_x;} + double y() const {return m_y;} + long layer() const {return m_layer;} + + bool isPixel() const {return m_isPixel;} + bool isSCT() const {return !m_isPixel;} + + // Methods to calculate associated values + + double eta(double z0) const { + double zr = (m_z-z0)/m_r; + return log(zr+std::sqrt(1.+zr*zr)); + } + + int barCode() const {return m_barCode;} + const space_point_t* offlineSpacePoint() const {return m_offlineSpacePoint;} + + protected: + + long m_layer; + + double m_r; + double m_x; + double m_y; + + double m_phi; + double m_z; + double m_dr; + double m_dz; + + int m_barCode; //MC truth association + bool m_isPixel; //Stores whether spacepoint is Pixel or SCT + + const space_point_t* m_offlineSpacePoint; +}; + + +template class TrigInDetTriplet { + + public: + TrigInDetTriplet() = delete; //to prevent creation w/o initialization + + TrigInDetTriplet(TrigSiSpacePointBase s1, TrigSiSpacePointBase s2, TrigSiSpacePointBase s3, float Q) : + m_s1(std::move(s1)), m_s2(std::move(s2)), m_s3(std::move(s3)), m_Q(Q) {}; + + TrigInDetTriplet(TrigInDetTriplet* t) : + m_s1(t->m_s1), m_s2(t->m_s2), m_s3(t->m_s3), m_Q(t->m_Q) {}; + + const TrigSiSpacePointBase& s1() const {return m_s1;} + const TrigSiSpacePointBase& s2() const {return m_s2;} + const TrigSiSpacePointBase& s3() const {return m_s3;} + float Q() const {return m_Q;} + void Q(double newQ) {m_Q = newQ;} + + protected: + + TrigSiSpacePointBase m_s1; + TrigSiSpacePointBase m_s2; + TrigSiSpacePointBase m_s3; + float m_Q;//Quality +}; + + + + + + diff --git a/Examples/Algorithms/TrackFinding/src/SeedingFTFAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/SeedingFTFAlgorithm.cpp index e0a3e00da3d..54a054f0694 100644 --- a/Examples/Algorithms/TrackFinding/src/SeedingFTFAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/SeedingFTFAlgorithm.cpp @@ -107,8 +107,9 @@ ActsExamples::ProcessCode ActsExamples::SeedingFTFAlgorithm::execute( finder.loadSpacePoints(FTF_spacePoints); + finder.createSeeds(); //currently doesnt return anything // still to develop - SimSeedContainer seeds = finder.createSeeds( + SimSeedContainer seeds = finder.createSeeds_old( m_cfg.seedFinderOptions, FTF_spacePoints, create_coordinates); m_outputSeeds(ctx, std::move(seeds));