LDMX Software
trigger::ClusterGeometry Class Reference

Public Member Functions

int getId (int cell_id, int module_id)
 
float getDist (int id1, int id2)
 
void addTp (int tid, int cell_id, int module_id, float x, float y)
 
void addNeighbor (int id1, int id2)
 
bool checkNeighbor (int id1, int id2)
 
void initialize ()
 

Public Attributes

bool is_initialized_ = false
 
std::map< std::pair< int, int >, int > reverse_id_map_
 
std::map< int, std::pair< int, int > > id_map_
 
std::map< int, std::pair< float, float > > positions_
 
std::map< std::pair< int, int >, float > distances_
 
std::map< int, std::vector< int > > neighbors_
 

Detailed Description

Definition at line 14 of file IdealClusterBuilder.h.

Member Function Documentation

◆ addNeighbor()

void trigger::ClusterGeometry::addNeighbor ( int id1,
int id2 )

Definition at line 16 of file IdealClusterBuilder.cxx.

16 {
17 neighbors_[id1].push_back(id2);
18 neighbors_[id2].push_back(id1);
19 // cout << "Nbs: " << id1 << " " << id2 << endl;
20}

◆ addTp()

void trigger::ClusterGeometry::addTp ( int tid,
int cell_id,
int module_id,
float x,
float y )

Definition at line 10 of file IdealClusterBuilder.cxx.

11 {
12 id_map_[tid] = std::make_pair(cell_id, module_id);
13 reverse_id_map_[std::make_pair(cell_id, module_id)] = tid;
14 positions_[tid] = std::make_pair(x, y);
15}

◆ checkNeighbor()

bool trigger::ClusterGeometry::checkNeighbor ( int id1,
int id2 )

Definition at line 21 of file IdealClusterBuilder.cxx.

21 {
22 // true if neighbors
23 auto& ns = neighbors_[id1];
24 return std::find(ns.begin(), ns.end(), id2) != ns.end();
25}

◆ getDist()

float trigger::ClusterGeometry::getDist ( int id1,
int id2 )
inline

Definition at line 34 of file IdealClusterBuilder.h.

34 {
35 return distances_[std::make_pair(id1, id2)];
36 }

◆ getId()

int trigger::ClusterGeometry::getId ( int cell_id,
int module_id )
inline

Definition at line 31 of file IdealClusterBuilder.h.

31 {
32 return reverse_id_map_[std::make_pair(cell_id, module_id)];
33 }

◆ initialize()

void trigger::ClusterGeometry::initialize ( )

Definition at line 26 of file IdealClusterBuilder.cxx.

26 {
27 // calculate pairwise distances
28 distances_.clear();
29 for (auto pair1 = id_map_.begin(); pair1 != id_map_.end(); pair1++) {
30 for (auto pair2 = pair1; pair2 != id_map_.end(); pair2++) {
31 if (pair1 == pair2) continue;
32 auto& id1 = pair1->first;
33 auto& id2 = pair2->first;
34 auto& xy1 = positions_[id1];
35 auto& xy2 = positions_[id2];
36 float d =
37 sqrt(pow(xy1.first - xy2.first, 2) + pow(xy1.second - xy2.second, 2));
38 distances_[std::make_pair(id1, id2)] = d;
39 distances_[std::make_pair(id2, id1)] = d;
40 }
41 }
42 // find neighbors
43 float n_dist = 1.8 * getDist(getId(0, 0), getId(1, 0));
44 for (auto pair1 = id_map_.begin(); pair1 != id_map_.end(); pair1++) {
45 for (auto pair2 = pair1; pair2 != id_map_.end(); pair2++) {
46 if (pair1 == pair2) continue;
47 if (getDist(pair1->first, pair2->first) < n_dist)
48 addNeighbor(pair1->first, pair2->first);
49 }
50 }
51 is_initialized_ = true;
52}

Member Data Documentation

◆ distances_

std::map<std::pair<int, int>, float> trigger::ClusterGeometry::distances_

Definition at line 26 of file IdealClusterBuilder.h.

◆ id_map_

std::map<int, std::pair<int, int> > trigger::ClusterGeometry::id_map_

Definition at line 20 of file IdealClusterBuilder.h.

◆ is_initialized_

bool trigger::ClusterGeometry::is_initialized_ = false

Definition at line 16 of file IdealClusterBuilder.h.

◆ neighbors_

std::map<int, std::vector<int> > trigger::ClusterGeometry::neighbors_

Definition at line 29 of file IdealClusterBuilder.h.

◆ positions_

std::map<int, std::pair<float, float> > trigger::ClusterGeometry::positions_

Definition at line 23 of file IdealClusterBuilder.h.

◆ reverse_id_map_

std::map<std::pair<int, int>, int> trigger::ClusterGeometry::reverse_id_map_

Definition at line 19 of file IdealClusterBuilder.h.


The documentation for this class was generated from the following files: