LDMX Software
Public Member Functions | Public Attributes | List of all members
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 18 of file IdealClusterBuilder.h.

Member Function Documentation

◆ AddNeighbor()

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

Definition at line 11 of file IdealClusterBuilder.cxx.

11 {
12 if (neighbors.count(id1))
13 neighbors[id1].push_back(id2);
14 else
15 neighbors[id1] = {id2};
16 if (neighbors.count(id2))
17 neighbors[id2].push_back(id1);
18 else
19 neighbors[id2] = {id1};
20 // cout << "Nbs: " << id1 << " " << id2 << endl;
21}

◆ AddTP()

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

Definition at line 5 of file IdealClusterBuilder.cxx.

6 {
7 id_map[tid] = std::make_pair(cell_id, module_id);
8 reverse_id_map[std::make_pair(cell_id, module_id)] = tid;
9 positions[tid] = std::make_pair(x, y);
10}

◆ CheckNeighbor()

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

Definition at line 22 of file IdealClusterBuilder.cxx.

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

◆ GetDist()

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

Definition at line 38 of file IdealClusterBuilder.h.

38 {
39 return distances[std::make_pair(id1, id2)];
40 }

◆ GetID()

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

Definition at line 35 of file IdealClusterBuilder.h.

35 {
36 return reverse_id_map[std::make_pair(cell_id, module_id)];
37 }

◆ Initialize()

void trigger::ClusterGeometry::Initialize ( )

Definition at line 27 of file IdealClusterBuilder.cxx.

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

Member Data Documentation

◆ distances

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

Definition at line 30 of file IdealClusterBuilder.h.

◆ id_map

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

Definition at line 24 of file IdealClusterBuilder.h.

◆ is_initialized

bool trigger::ClusterGeometry::is_initialized = false

Definition at line 20 of file IdealClusterBuilder.h.

◆ neighbors

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

Definition at line 33 of file IdealClusterBuilder.h.

◆ positions

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

Definition at line 27 of file IdealClusterBuilder.h.

◆ reverse_id_map

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

Definition at line 23 of file IdealClusterBuilder.h.


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