LDMX Software
CLUE.h
Go to the documentation of this file.
1
7#ifndef ECAL_CLUE_H_
8#define ECAL_CLUE_H_
9
10#include <math.h>
11
12#include <limits>
13#include <memory>
14
15#include "Ecal/Event/EcalHit.h"
17#include "Framework/Logger.h"
18
19namespace ecal {
20
21class CLUE {
22 enableLogging("CLUE");
23
24 public:
25 struct Density {
26 double x_;
27 double y_;
28 double z_;
29 double total_energy_;
30 int index_;
31
32 // index of density this density is follower of
33 // set to index of spatially closest density with higher energy; -1 if seed
34 int follower_of_;
35 // 2D separation distance to density that this is follower of
36 double delta_;
37 // separation in z to density that this is follower of
38 double z_delta_;
39 // 2D cluster ID
40 int cluster_id_;
41 // layer of density
42 int layer_;
43 // hits in this density
44 std::vector<const ldmx::EcalHit*> hits_;
45
46 Density() {}
47
48 Density(float xx, float yy) : x_(xx), y_(yy) {
49 total_energy_ = 0.;
50 index_ = -1;
51 follower_of_ = -1;
52 delta_ = std::numeric_limits<float>::max();
53 z_delta_ = std::numeric_limits<float>::max();
54 cluster_id_ = -1;
55 layer_ = -1;
56 z_ = 0.;
57 hits_ = {};
58 }
59 };
60
65 template <typename T>
66 T dist(T x1, T y1, T x2, T y2);
67 // 3D version
68 template <typename T>
69 T dist(T x1, T y1, T z1, T x2, T y2, T z2);
70 std::vector<std::vector<const ldmx::EcalHit*>> createLayers(
71 const std::vector<const ldmx::EcalHit*>& hits);
72 float roundToDecimal(float x, int num_decimal_precision_digits);
73 std::vector<std::shared_ptr<Density>> setup(
74 const std::vector<const ldmx::EcalHit*>& hits);
75
76 // get distance between clusters in the first layers, proxy for electron sep.
77 void electronSeparation(std::vector<ldmx::EcalHit> hits);
78
79 // connectingLayers marks if we're currently doing 3D clustering (i.e.
80 // connecting seeds between layers) otherwise, layerTag tells us which layer
81 // number we're working on
82 std::vector<std::vector<const ldmx::EcalHit*>> clustering(
83 std::vector<std::shared_ptr<Density>>& densities, bool connectingLayers,
84 int layerTag = 0);
85
86 std::vector<std::shared_ptr<Density>> setupForClue3D();
87
88 void convertToIntermediateClusters(
89 std::vector<std::vector<const ldmx::EcalHit*>>& clusters);
90
91 void cluster(const std::vector<ldmx::EcalHit>& hits, double dc, double rc,
92 double deltac, double deltao, int nbrOfLayers,
93 bool reclustering);
94
95 std::vector<double> getCentroidDistances() const {
96 return centroid_distances_;
97 }
98
99 int getNLoops() const { return clustering_loops_; }
100
101 int getInitialClusterNbr() const { return initial_cluster_nbr_; }
102
103 std::vector<IntermediateCluster> getClusters() const {
104 return final_clusters_;
105 }
106
107 // First layer centroids are available for potential future combination with
108 // TS
109 std::vector<IntermediateCluster> getFirstLayerCentroids() const {
110 return first_layer_centroids_;
111 }
112
113 private:
114 int clustering_loops_;
115
116 bool reclustering_;
117
118 double dc_;
119 double rhoc_;
120 double deltac_;
121 double deltao_;
122 double dm_;
123
124 // layers in Ecal
125 int max_layers_{32};
126 int nbr_of_layers_;
127
128 std::vector<double> layer_rho_c_;
129 std::vector<double> layer_delta_c_;
130 // containment radius for the different layers of the ECal
131 std::vector<double> radius_{
132 5.723387467629167, 5.190678018534044, 5.927290663506518,
133 6.182560329200212, 7.907549398117859, 8.606100542857211,
134 10.93381822596916, 12.043201938160239, 14.784548371508041,
135 16.102403056546482, 18.986402399412817, 20.224453740305716,
136 23.048820910305643, 24.11202594672678, 26.765135236851666,
137 27.78700483852502, 30.291794353801293, 31.409870873194464,
138 33.91006482486666, 35.173073672355926, 38.172422630271,
139 40.880288341493205, 44.696485719120005, 49.23802839743545,
140 53.789910813378675, 60.87843355562641, 66.32931132415688,
141 75.78117972604727, 86.04697356716805, 96.90360704034346};
142
143 std::vector<double> centroid_distances_;
144 IntermediateCluster event_centroid_;
145
146 std::vector<IntermediateCluster> first_layer_centroids_;
147
148 int seed_index_{0};
149 std::vector<std::vector<std::shared_ptr<Density>>> seeds_;
150
151 int initial_cluster_nbr_{-1};
152 std::vector<IntermediateCluster> final_clusters_;
153 std::vector<std::pair<double, double>> layer_centroid_separations_;
154};
155} // namespace ecal
156
157#endif
Type alias for Ecal cluster reconstruction.
recon::WorkingCluster< ldmx::EcalHit > IntermediateCluster
Type alias for WorkingCluster specialized for EcalHit.
T dist(T x1, T y1, T x2, T y2)
Euclidean distance between two points.
Definition CLUE.cxx:22