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