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