14 {
15
16
17
18
19 std::map<int, double> mapLayerWeigthedX;
20 std::map<int, double> mapLayerWeigthedY;
21 std::map<int, double> mapLayerZ1;
22 std::map<int, double> mapLayerZ2;
23 std::map<int, double> mapLayerSumWeigthsX;
24 std::map<int, double> mapLayerSumWeigthsY;
25
26
27
31 double hitEnergy =
34 int layer = hit.GetLayerNumber();
35
36
37 if (hit.IsX()) {
38 if (!mapLayerWeigthedX.contains(layer)) {
39 mapLayerWeigthedX[layer] = 0.;
40 mapLayerSumWeigthsX[layer] = 0.;
41 }
42 mapLayerWeigthedX[layer] += hit.GetX() * hitEnergy;
43 mapLayerSumWeigthsX[layer] += hitEnergy;
44 mapLayerZ1[layer] = hit.GetZ();
45 }
46 if (hit.IsY()) {
47 if (!mapLayerWeigthedY.contains(layer)) {
48 mapLayerWeigthedY[layer] = 0.;
49 mapLayerSumWeigthsY[layer] = 0.;
50 }
51 mapLayerWeigthedY[layer] += hit.GetY() * hitEnergy;
52 mapLayerSumWeigthsY[layer] += hitEnergy;
53 mapLayerZ2[layer] = hit.GetZ();
54 }
55 }
56
57 auto const& [minLayerX, weightedMinX] = *mapLayerWeigthedX.begin();
58 double minX = weightedMinX / mapLayerSumWeigthsX[minLayerX];
59 double minZ1 = mapLayerZ1[minLayerX];
60
61 auto const& [minLayerY, weightedMinY] = *mapLayerWeigthedY.begin();
62 double minY = weightedMinY / mapLayerSumWeigthsY[minLayerY];
63 double minZ2 = mapLayerZ1[minLayerY];
64
65 double minZ = (minZ1 + minZ2) / 2.;
66
68
69 auto const& [maxLayerX, weightedMaxX] = *mapLayerWeigthedX.rbegin();
70 double maxX = weightedMaxX / mapLayerSumWeigthsX[maxLayerX];
71 double maxZ1 = mapLayerZ1[maxLayerX];
72
73 auto const& [maxLayerY, weightedMaxY] = *mapLayerWeigthedY.rbegin();
74 double maxY = weightedMaxY / mapLayerSumWeigthsY[maxLayerY];
75 double maxZ2 = mapLayerZ1[maxLayerY];
76
77 double maxZ = (maxZ1 + maxZ2) / 2.;
78
80
81
84 TVector3 direction = end - start;
85 double eta = direction.Eta();
86 double phi = direction.Phi();
88}
void SetStartPoint(const double &x, const double &y, const double &z)
void SetEndPoint(const double &x, const double &y, const double &z)
std::array< double, 3 > _end
void SetEtaPhiE(double &eta, double &phi, double &e)
std::array< double, 3 > _start