Skip to content

Commit

Permalink
first step of implementing necessary classes from FTF and 2 funcitons…
Browse files Browse the repository at this point in the history
…, currently blank inner function
  • Loading branch information
Rosie-Hasan committed Sep 26, 2023
1 parent 9935609 commit b1077d6
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 7 deletions.
22 changes: 20 additions & 2 deletions Core/include/Acts/Seeding/SeedFinderFTF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <array>
#include <iostream>
Expand All @@ -21,6 +22,17 @@

namespace Acts {

template <typename external_spacepoint_t>
struct GNN_TrigTracklet{
public:
GNN_TrigTracklet(std::vector<const TrigSiSpacePointBase<external_spacepoint_t>*>& vSP, std::vector<TrigInDetTriplet<external_spacepoint_t>>& tbuf) : m_track(vSP), m_seeds(tbuf) {};
~GNN_TrigTracklet() {};

std::vector<const TrigSiSpacePointBase<external_spacepoint_t>*> m_track;
std::vector<TrigInDetTriplet<external_spacepoint_t>> m_seeds;

};

template <typename external_spacepoint_t>
class SeedFinderFTF {
public:
Expand All @@ -42,16 +54,18 @@ class SeedFinderFTF {

void loadSpacePoints(const std::vector<FTF_SP<external_spacepoint_t>> &);

void createSeeds();

// create seeeds function
template <typename input_container_t, typename output_container_t,
typename callable_t>
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 <typename input_container_t, typename callable_t>
std::vector<seed_t> createSeeds(const Acts::SeedFinderOptions &options,
std::vector<seed_t> createSeeds_old(const Acts::SeedFinderOptions &options,
const input_container_t &spacePoints,
callable_t &&extract_coordinates) const;

Expand All @@ -61,8 +75,12 @@ class SeedFinderFTF {
// config object
SeedFinderFTFConfig<external_spacepoint_t> m_config;

void runGNN_TrackFinder(std::vector<GNN_TrigTracklet<external_spacepoint_t>>&);

// needs to be memeber of class so can accessed by all memeber functions
TrigFTF_GNN_DataStorage<external_spacepoint_t> *m_storage;

std::vector<TrigInDetTriplet<external_spacepoint_t>> m_triplets;
};

} // namespace Acts
Expand Down
84 changes: 80 additions & 4 deletions Core/include/Acts/Seeding/SeedFinderFTF.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,100 @@ void SeedFinderFTF<external_spacepoint_t>::loadSpacePoints(
m_storage->generatePhiIndexing(1.5 * m_config.m_phiSliceWidth);
}

// still to be developed

template <typename external_spacepoint_t>
void SeedFinderFTF<external_spacepoint_t>::runGNN_TrackFinder(std::vector<GNN_TrigTracklet<external_spacepoint_t>>&){

// 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<TrigFTF_GNN_Edge<external_spacepoint_t>> edgeStorage;

// edgeStorage.reserve(MaxEdges);

// int nEdges = 0;

}


template <typename external_spacepoint_t>
void SeedFinderFTF<external_spacepoint_t>::createSeeds(){

std::vector<GNN_TrigTracklet<external_spacepoint_t>> 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 <typename external_spacepoint_t>
template <typename input_container_t, typename output_container_t,
typename callable_t>
void SeedFinderFTF<external_spacepoint_t>::createSeeds(
void SeedFinderFTF<external_spacepoint_t>::createSeeds_old(
const Acts::SeedFinderOptions &options,
const input_container_t &spacePoints, output_container_t &out_cont,
callable_t &&extract_coordinates) const {}

template <typename external_spacepoint_t>
template <typename input_container_t, typename callable_t>
std::vector<Seed<external_spacepoint_t>>
SeedFinderFTF<external_spacepoint_t>::createSeeds(
SeedFinderFTF<external_spacepoint_t>::createSeeds_old(
const Acts::SeedFinderOptions &options,
const input_container_t &spacePoints,
callable_t &&extract_coordinates) const {
std::vector<seed_t> r;
createSeeds(options, spacePoints, r,
createSeeds_old(options, spacePoints, r,
std::forward<callable_t>(extract_coordinates));
return r;
}
Expand Down
1 change: 1 addition & 0 deletions Core/include/Acts/Seeding/SeedFinderFTFConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ template <typename SpacePoint> 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<TrigInDetSiLayer> input_vector;

Expand Down
126 changes: 126 additions & 0 deletions Core/include/Acts/Seeding/TrigBase.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#include <cmath>


#define MAX_SILICON_LAYER_NUM 19
#define OffsetEndcapPixels 7
#define OffsetBarrelSCT 3
#define OffsetEndcapSCT 10

template <typename space_point_t> 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 <typename space_point_t> class TrigInDetTriplet {

public:
TrigInDetTriplet() = delete; //to prevent creation w/o initialization

TrigInDetTriplet(TrigSiSpacePointBase<space_point_t> s1, TrigSiSpacePointBase<space_point_t> s2, TrigSiSpacePointBase<space_point_t> 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<space_point_t>& s1() const {return m_s1;}
const TrigSiSpacePointBase<space_point_t>& s2() const {return m_s2;}
const TrigSiSpacePointBase<space_point_t>& s3() const {return m_s3;}
float Q() const {return m_Q;}
void Q(double newQ) {m_Q = newQ;}

protected:

TrigSiSpacePointBase<space_point_t> m_s1;
TrigSiSpacePointBase<space_point_t> m_s2;
TrigSiSpacePointBase<space_point_t> m_s3;
float m_Q;//Quality
};






3 changes: 2 additions & 1 deletion Examples/Algorithms/TrackFinding/src/SeedingFTFAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit b1077d6

Please sign in to comment.