8 #include <Math/Point3D.h>
9 #include <Math/Point3Dfwd.h>
10 #include <Math/Vector3D.h>
12 #include <TMatrixDSymfwd.h>
13 #include <TMatrixTSym.h>
28 std::vector<AtHit> hitTBArray;
43 Double_t driftVel = 1.0;
44 Double_t samplingRate = 0.320;
45 Double_t d_t = 0.0009;
46 Double_t d_l = 0.0009;
47 Double_t D_T = TMath::Sqrt((2.0 * d_t) / driftVel);
48 Double_t D_L = TMath::Sqrt((2.0 * d_l) / driftVel);
50 if (hitArray.size() > 0) {
52 auto refPos = hitArray.at(0).GetPosition();
55 for (
auto iHit = 0; iHit < hitArray.size(); ++iHit) {
57 auto hit = hitArray.at(iHit);
60 Double_t distRef = TMath::Sqrt((hit.GetPosition() - refPos).Mag2());
62 if (distRef < distance) {
73 Double_t clusterQ = 0.0;
76 hitArray.begin(), hitArray.end(), std::back_inserter(hitTBArray),
77 [&refPos, radius](
AtHit &hitIn) { return TMath::Sqrt((hitIn.GetPosition() - refPos).Mag2()) < radius; });
81 if (hitTBArray.size() > 0) {
82 double x = 0,
y = 0, z = 0;
83 double sigma_x = 0, sigma_y = 0, sigma_z = 0;
86 std::shared_ptr<AtHitCluster> hitCluster = std::make_shared<AtHitCluster>();
89 std::for_each(hitTBArray.begin(), hitTBArray.end(),
90 [&x, &
y, &z, &hitQ, &timeStamp, &sigma_x, &sigma_y, &sigma_z, &D_T, &D_L, &driftVel,
91 &samplingRate](
AtHit &hitInQ) {
92 XYZPoint pos = hitInQ.GetPosition();
93 x += pos.X() * hitInQ.GetCharge();
94 y += pos.Y() * hitInQ.GetCharge();
96 hitQ += hitInQ.GetCharge();
97 timeStamp += hitInQ.GetTimeStamp();
101 sigma_x += hitInQ.GetCharge() *
102 TMath::Sqrt(TMath::Power(0.2, 2) +
103 pos.Z() * TMath::Power(D_T, 2));
105 sigma_z += TMath::Sqrt((1.0 / 6.0) * TMath::Power(driftVel * samplingRate, 2) +
106 pos.Z() * TMath::Power(D_L, 2));
110 z /= hitTBArray.size();
111 timeStamp /= hitTBArray.size();
115 sigma_z /= hitTBArray.size();
118 Bool_t checkDistance = kTRUE;
122 if (TMath::Sqrt((iClusterHit.GetPosition() - clustPos).Mag2()) < distance) {
124 checkDistance = kFALSE;
138 cov(0, 0) = TMath::Power(sigma_x, 2);
139 cov(1, 1) = TMath::Power(sigma_y, 2);
140 cov(2, 2) = TMath::Power(sigma_z, 2);
161 refPos = hitArray.at(iHit).GetPosition();
170 std::vector<std::shared_ptr<AtHitCluster>> hitClusterBuffer;
174 if (hitClusterArray->size() > 2) {
176 for (
auto iHitCluster = 0; iHitCluster < hitClusterArray->size() - 1;
180 XYZPoint clusBack = hitClusterArray->at(iHitCluster).GetPosition();
181 XYZPoint clusForw = hitClusterArray->at(iHitCluster + 1).GetPosition();
182 XYZPoint clusMidPos = clusBack + (clusForw - clusBack) * 0.5;
183 std::vector<XYZPoint> renormClus{clusBack, clusMidPos};
185 if (iHitCluster == (hitClusterArray->size() - 2))
186 renormClus.push_back(clusForw);
189 for (
auto iClus : renormClus) {
191 std::copy_if(hitArray.begin(), hitArray.end(), std::back_inserter(hitTBArray),
192 [&iClus, radius](
AtHit &hitIn) {
193 return TMath::Sqrt((hitIn.GetPosition() - iClus).Mag2()) < radius;
196 if (hitTBArray.size() > 0) {
197 double x = 0,
y = 0, z = 0;
198 double sigma_x = 0, sigma_y = 0, sigma_z = 0;
201 std::shared_ptr<AtHitCluster> hitCluster = std::make_shared<AtHitCluster>();
204 std::for_each(hitTBArray.begin(), hitTBArray.end(),
205 [&x, &
y, &z, &hitQ, &timeStamp, &sigma_x, &sigma_y, &sigma_z, &D_T, &D_L, &driftVel,
206 &samplingRate](
AtHit &hitInQ) {
207 auto pos = hitInQ.GetPosition();
208 x += pos.X() * hitInQ.GetCharge();
209 y += pos.Y() * hitInQ.GetCharge();
211 hitQ += hitInQ.GetCharge();
212 timeStamp += hitInQ.GetTimeStamp();
218 TMath::Sqrt(TMath::Power(0.2, 2) +
219 pos.Z() * TMath::Power(D_T, 2));
221 sigma_z += TMath::Sqrt((1.0 / 6.0) * TMath::Power(driftVel * samplingRate, 2) +
222 pos.Z() * TMath::Power(D_L, 2));
226 z /= hitTBArray.size();
227 timeStamp /= hitTBArray.size();
231 sigma_z /= hitTBArray.size();
233 TVector3 clustPos(x,
y, z);
242 cov(0, 0) = TMath::Power(sigma_x, 2);
243 cov(1, 1) = TMath::Power(sigma_y, 2);
244 cov(2, 2) = TMath::Power(sigma_z, 2);
247 hitClusterBuffer.push_back(hitCluster);
259 for (
auto iHitClusterRe : hitClusterBuffer) {