Skip to content

Commit

Permalink
does not run still but includes layer numbering and eta mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosie-Hasan committed Aug 4, 2023
1 parent ef01061 commit a26654a
Show file tree
Hide file tree
Showing 11 changed files with 485 additions and 92 deletions.
8 changes: 4 additions & 4 deletions Core/include/Acts/Seeding/GNN_DataStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ class TrigFTF_GNN_EtaBin {
TrigFTF_GNN_EtaBin() {
m_vn.clear();
}
// ~TrigFTF_GNN_EtaBin();

~TrigFTF_GNN_EtaBin() {
// for(std::vector<TrigFTF_GNN_Node<space_point_t>*>::iterator it = m_vn.begin();it!=m_vn.end();++it) {
for(auto i : m_vn){
delete (&i);
}
// for(auto i : m_vn){
// delete (&i);
// }
m_vn.clear();
}

Expand Down
56 changes: 32 additions & 24 deletions Core/include/Acts/Seeding/GNN_Geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
namespace Acts {
class TrigInDetSiLayer {
public:
int m_subdet;//1 : Pixel, 2 : SCT
int m_subdet;//combined ID
int m_type;//0: barrel, +/-n : endcap
float m_refCoord;
float m_minBound, m_maxBound;

TrigInDetSiLayer(int subdet, short int type, float center, float min, float max ) : m_subdet(subdet), m_type(type), m_refCoord(center), m_minBound(min), m_maxBound(max) {

}
};

template <typename space_point_t>
class TrigFTF_GNN_Layer {
public:
// TrigFTF_GNN_Layer(const TrigInDetSiLayer&, float, int);


TrigFTF_GNN_Layer(const TrigInDetSiLayer& ls, float ew, int bin0) : m_layer(ls), m_etaBinWidth(ew) {

Expand Down Expand Up @@ -130,10 +132,9 @@ class TrigFTF_GNN_Layer {
}
}

// ~TrigFTF_GNN_Layer();
~TrigFTF_GNN_Layer() {
m_bins.clear();
}
// ~TrigFTF_GNN_Layer() {
// m_bins.clear();
// }
// int getEtaBin(float, float) const;

int getEtaBin(float zh, float rh) const {
Expand Down Expand Up @@ -233,7 +234,8 @@ class TrigFTF_GNN_Layer {
}


const TrigInDetSiLayer& m_layer;
// const TrigInDetSiLayer& m_layer;
const TrigInDetSiLayer m_layer; //CHECK: changed from ref to copy for saftey
std::vector<int> m_bins;//eta-bin indices
std::vector<float> m_minRadius;
std::vector<float> m_maxRadius;
Expand Down Expand Up @@ -263,10 +265,12 @@ class TrigFTF_GNN_Geometry {
const float max_z0 = 168.0;

m_etaBinWidth = conn->m_etaBin;

for(const auto& layer : layers) {
const TrigFTF_GNN_Layer<space_point_t>* pL = addNewLayer(layer, m_nEtaBins);
m_nEtaBins += pL->num_bins();
// std::cout << " Rosie printing layer vector " << layer.m_subdet << std::endl;


}

//calculating bin tables in the connector...
Expand All @@ -279,7 +283,7 @@ class TrigFTF_GNN_Geometry {

unsigned int src = (*cIt)->m_src;//n2 : the new connectors
unsigned int dst = (*cIt)->m_dst;//n1

const TrigFTF_GNN_Layer<space_point_t>* pL1 = getTrigFTF_GNN_LayerByKey(dst);
const TrigFTF_GNN_Layer<space_point_t>* pL2 = getTrigFTF_GNN_LayerByKey(src);

Expand Down Expand Up @@ -311,29 +315,35 @@ class TrigFTF_GNN_Geometry {
TrigFTF_GNN_Geometry() : m_nEtaBins(0) {
}

// ~TrigFTF_GNN_Geometry();

~TrigFTF_GNN_Geometry() {
for(auto& i : m_layArray) {
// for(std::vector<TrigFTF_GNN_Layer<space_point_t>*>::iterator it = m_layArray.begin();it!=m_layArray.end();++it) {
delete (&i);
std::cout << "start of gnn geo's destructor " << std::endl ;



for(typename std::vector<TrigFTF_GNN_Layer<space_point_t>*>::iterator it = m_layArray.begin();it!=m_layArray.end();++it) {
delete (*it);
}

std::cout << "middle of gnn geo's destructor " << std::endl ;

m_layMap.clear();m_layArray.clear();
std::cout << "end of gnn geo's destructor " << std::endl ;

}


// const TrigFTF_GNN_Layer<space_point_t>* getTrigFTF_GNN_LayerByKey(unsigned int) const;

const TrigFTF_GNN_Layer<space_point_t>* getTrigFTF_GNN_LayerByKey(unsigned int key) const {
typename std::map<unsigned int, TrigFTF_GNN_Layer<space_point_t>*>::const_iterator it = m_layMap.find(key);
if(it == m_layMap.end()) {
// std::cout << "Rosie, printing map info" << m_layMap.size() << std::endl ;

return nullptr;
}
return (*it).second;
}


// const TrigFTF_GNN_Layer<space_point_t>* getTrigFTF_GNN_LayerByIndex(int) const;

return (*it).second;
}

const TrigFTF_GNN_Layer<space_point_t>* getTrigFTF_GNN_LayerByIndex(int idx) const {
return m_layArray.at(idx);
Expand All @@ -343,12 +353,10 @@ class TrigFTF_GNN_Geometry {

protected:

// const TrigFTF_GNN_Layer<space_point_t>* addNewLayer(const TrigInDetSiLayer&, int);

const TrigFTF_GNN_Layer<space_point_t>* addNewLayer(const TrigInDetSiLayer& l, int bin0) {

unsigned int layerKey = l.m_subdet;

unsigned int layerKey = l.m_subdet; //this should be combined ID
// std::cout << " Rosie seeing what key values are " << layerKey << std::endl;
float ew = m_etaBinWidth;

TrigFTF_GNN_Layer<space_point_t>* pHL = new TrigFTF_GNN_Layer<space_point_t>(l, ew, bin0);
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Seeding/SeedFinderFTF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "Acts/Seeding/SeedFinderConfig.hpp"
#include "Acts/Seeding/SeedFinderFTFConfig.hpp"
#include "Acts/Utilities/KDTree.hpp"
#include "Acts/Seeding/GNN_DataStorage.hpp"
// #include "Acts/Seeding/GNN_DataStorage.hpp"


#include <array>
Expand Down
39 changes: 29 additions & 10 deletions Core/include/Acts/Seeding/SeedFinderFTF.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,59 @@ SeedFinderFTF<external_spacepoint_t>::SeedFinderFTF(
// "SeedFinderOrthogonalConfig not in ACTS internal units in "
// "SeedFinderOrthogonal");

std::cout << "in FTF finder constructor 1 " << std::endl ;

std::vector<TrigInDetSiLayer> input_vector ;
std::ifstream input_ifstream(m_config.fastrack_input_file.c_str(), std::ifstream::in) ;
std::cout << "in FTF finder constructor 2 " << std::endl ;

FasTrackConnector input_fastrack(input_ifstream) ;
TrigFTF_GNN_Geometry<external_spacepoint_t> mGNNgeo(input_vector, &input_fastrack);
std::cout << "in FTF finder constructor 3" << std::endl ;

TrigFTF_GNN_Geometry<external_spacepoint_t> mGNNgeo(m_config.input_vector, &input_fastrack);
std::cout << "in FTF finder constructor 4 " << std::endl ;

m_storage = new TrigFTF_GNN_DataStorage(mGNNgeo);
std::cout << "in FTF finder constructor 5 " << std::endl ;



}

template <typename external_spacepoint_t>
SeedFinderFTF<external_spacepoint_t>::~SeedFinderFTF(){
std::cout << "in FTF finder destructor 1 " << std::endl ;

delete m_storage ;
std::cout << "in FTF finder destructor 2 " << std::endl ;

m_storage = nullptr ;
std::cout << "in FTF finder destructor 3 " << std::endl ;

}


//define loadspace points funciton
//when calling put input of vector<simspacepoints>, now can call space_point_t
template <typename external_spacepoint_t>
void SeedFinderFTF<external_spacepoint_t>::loadSpacePoints(const std::vector<FTF_SP<external_spacepoint_t>>& FTF_SP_vect){
std::cout << "in lsp 1" << std::endl ;

// for(auto& FTF_sp : FTF_SP_vect) {
// bool is_Pixel = FTF_sp.SP->isPixel(); //FTF actual object then sim is pointer
// if(!is_Pixel) continue;

// m_storage->addSpacePoint(FTF_sp,(m_config.m_useTrigSeedML > 0) ); //add is a funciton FTFtype

for(auto& FTF_sp : FTF_SP_vect) {
bool is_Pixel = FTF_sp.SP->isPixel(); //FTF actual object then sim is pointer
if(!is_Pixel) continue;
// }
// std::cout << "in lsp 2 " << std::endl ;

m_storage->addSpacePoint(FTF_sp,(m_config.m_useTrigSeedML > 0) ); //add is a funciton FTFtype

}
// m_config.m_phiSliceWidth = 2*M_PI/m_config.m_nMaxPhiSlice;

m_config.m_phiSliceWidth = 2*M_PI/m_config.m_nMaxPhiSlice;
// m_storage->sortByPhi();
// m_storage->generatePhiIndexing(1.5*m_config.m_phiSliceWidth);

m_storage->sortByPhi();
m_storage->generatePhiIndexing(1.5*m_config.m_phiSliceWidth);
std::cout << "end of lsp " << std::endl ;

}

Expand Down
2 changes: 2 additions & 0 deletions Core/include/Acts/Seeding/SeedFinderFTFConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/Seeding/SeedConfirmationRangeConfig.hpp"
#include "Acts/Seeding/GNN_DataStorage.hpp"

#include <memory>

Expand Down Expand Up @@ -106,6 +107,7 @@ struct SeedFinderFTFConfig {
float m_nMaxPhiSlice ;
bool m_useTrigSeedML = false ;
std::string fastrack_input_file ;
std::vector<TrigInDetSiLayer> input_vector ;


////
Expand Down
4 changes: 4 additions & 0 deletions Core/src/TrackFinding/FasTrackConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ FasTrackConnector::FasTrackConnector(std::ifstream& inFile) {
}

FasTrackConnector::~FasTrackConnector() {
std::cout << "start of fastrack destructor " << std::endl ;

for(std::map<int, std::vector<FasTrackConnection*> >::iterator it = m_connMap.begin();it!=m_connMap.end();++it) {
for(std::vector<FasTrackConnection*>::iterator cIt=(*it).second.begin();cIt!=(*it).second.end();++cIt) {
delete (*cIt);
}
(*it).second.clear();
}
m_connMap.clear();
std::cout << "end of fastrack destructor " << std::endl ;


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ActsExamples/EventData/SimSpacePoint.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
#include "ActsExamples/Framework/IAlgorithm.hpp"
#include "Acts/Geometry/TrackingGeometry.hpp"

#include <string>
#include <vector>
Expand All @@ -34,6 +35,14 @@ class SeedingFTFAlgorithm final : public IAlgorithm {

std::string layerMappingFile ;

std::vector<Acts::GeometryIdentifier> geometrySelection;

std::string inputSourceLinks;

std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry;

std::map<std::pair<int, int>,std::pair<int, int>> ACTS_FTF_Map ;

};


Expand All @@ -50,6 +59,15 @@ class SeedingFTFAlgorithm final : public IAlgorithm {
//access to config
const Config& config() const { return m_cfg; }

//own class functions
//make the map
std::map<std::pair<int, int>,std::pair<int, int>> Make_ACTS_FTF_Map() const ;
//make the vector of space points with FTF Info
std::vector<Acts::FTF_SP<SimSpacePoint>> Make_FTF_spacePoints(const AlgorithmContext& ctx, std::map<std::pair<int, int>,std::pair<int, int>> map) const;
//layer numbering
// std::vector<Acts::TrigInDetSiLayer> LayerNumbering(const AlgorithmContext& ctx, std::map<std::pair<int, int>,int> map) const ;

std::vector<Acts::TrigInDetSiLayer> LayerNumbering() const ;

private:
Config m_cfg;
Expand All @@ -59,6 +77,11 @@ class SeedingFTFAlgorithm final : public IAlgorithm {
m_inputSpacePoints{};

WriteDataHandle<SimSeedContainer> m_outputSeeds{this, "OutputSeeds"};

ReadDataHandle<IndexSourceLinkContainer> m_inputSourceLinks{
this, "InputSourceLinks"};


};

} // namespace ActsExamples
58 changes: 58 additions & 0 deletions Examples/Algorithms/TrackFinding/src/LayerNumbering.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

void ActsExamples::FillInputVector(ActsExamples::SeedingFTFAlgorithm::Config cfg) m_cfg(std::move(cfg)) {
///////Hough code ///////////
///(sourceLinks = m_cfg.inputSourceLinks)
///const auto& measurements = m_inputMeasurements(ctx);
for (Acts::GeometryIdentifier geoId : m_cfg.geometrySelection) {
// select volume/layer depending on what is set in the geometry id

auto range = selectLowestNonZeroGeometryObject(sourceLinks, geoId);

auto groupedByModule = makeGroupBy(range, detail::GeometryIdGetter()); /// Iterate over groups of elements belonging to each module/ sensitive surface.

for (auto [moduleGeoId, moduleSourceLinks] : groupedByModule) {
// find corresponding surface
const Acts::Surface* surface =
m_cfg.trackingGeometry->findSurface(moduleGeoId);
if (surface == nullptr) {
ACTS_ERROR("Could not find surface " << moduleGeoId);
return;
}

for (auto& sourceLink : moduleSourceLinks) {

auto [localPos, localCov] = std::visit(
[](const auto& meas) {
auto expander = meas.expander();
Acts::BoundVector par = expander * meas.parameters();
Acts::BoundSymMatrix cov =
expander * meas.covariance() * expander.transpose();
// extract local position
Acts::Vector2 lpar(par[Acts::eBoundLoc0], par[Acts::eBoundLoc1]);
// extract local position covariance.
Acts::SymMatrix2 lcov =
cov.block<2, 2>(Acts::eBoundLoc0, Acts::eBoundLoc0);
return std::make_pair(lpar, lcov);
},
measurements[sourceLink.index()]);

// transform local position to global coordinates
Acts::Vector3 globalFakeMom(1, 1, 1);
Acts::Vector3 globalPos = surface->localToGlobal(ctx.geoContext, localPos, globalFakeMom); //is this the center?


double r = std::hypot(globalPos[Acts::ePos0], globalPos[Acts::ePos1]);
double phi = std::atan2(globalPos[Acts::ePos1], globalPos[Acts::ePos0]);
double z = globalPos[Acts::ePos2];
ResultUnsigned hitlayer = m_cfg.layerIDFinder(r); //is this the layer ACTS layer?? (.value()) //cant find where this is defined
if (hitlayer.ok()) {
std::vector<Index> index;
index.push_back(sourceLink.index());
auto meas = std::shared_ptr<HoughMeasurementStruct>(
new HoughMeasurementStruct(hitlayer.value(), phi, r, z, index, HoughHitType::MEASUREMENT));
houghMeasurementStructs.push_back(meas);
}
}
}
}
}
Loading

0 comments on commit a26654a

Please sign in to comment.