LDMX Software
WorkingCluster.cxx
1
2#include "Hcal/WorkingCluster.h"
3
4#include <iostream>
5
6namespace hcal {
7
8WorkingCluster::WorkingCluster(const ldmx::HcalHit* eh,
9 const ldmx::HcalGeometry& hex) {
10 add(eh, hex);
11}
12
13void WorkingCluster::add(const ldmx::HcalHit* eh,
14 const ldmx::HcalGeometry& hex) {
15 double hit_e = eh->getEnergy();
16 ROOT::Math::XYZVector hitpos = hex.getStripCenterPosition(eh->getID());
17 double hit_x = hitpos.x();
18 double hit_y = hitpos.y();
19 double hit_z = hitpos.z();
20 double hit_t = eh->getTime();
21 // Based on weight for Center-of-Gravity by hitpos*hiE/totalE
22 double new_e = hit_e + centroid_.E();
23 double new_centroid_x =
24 (centroid_.Px() * centroid_.E() + hit_e * hit_x) / new_e;
25 double new_centroid_y =
26 (centroid_.Py() * centroid_.E() + hit_e * hit_y) / new_e;
27 double new_centroid_z =
28 (centroid_.Pz() * centroid_.E() + hit_e * hit_z) / new_e;
29
30 if (time_ < hit_t) {
31 time_ = hit_t;
32 }
33 centroid_.SetPxPyPzE(new_centroid_x, new_centroid_y, new_centroid_z, new_e);
34 hits_.push_back(eh);
35}
36
37void WorkingCluster::add(const WorkingCluster& wc) {
38 double cluster_e = wc.centroid().E();
39 double centroid_x = wc.centroid().Px();
40 double centroid_y = wc.centroid().Py();
41 double centroid_z = wc.centroid().Pz();
42
43 double new_e = cluster_e + centroid_.E();
44 double new_centroid_x =
45 (centroid_.Px() * centroid_.E() + cluster_e * centroid_x) / new_e;
46 double new_centroid_y =
47 (centroid_.Py() * centroid_.E() + cluster_e * centroid_y) / new_e;
48 double new_centroid_z =
49 (centroid_.Pz() * centroid_.E() + cluster_e * centroid_z) / new_e;
50
51 centroid_.SetPxPyPzE(new_centroid_x, new_centroid_y, new_centroid_z, new_e);
52 /*if(wc.GetTime() > time_){
53 time_ = wc.GetTime();
54 }*/
55
56 std::vector<const ldmx::HcalHit*> cluster_hits = wc.getHits();
57
58 for (unsigned int i = 0; i < cluster_hits.size(); i++) {
59 hits_.push_back(cluster_hits[i]);
60 }
61}
62} // namespace hcal
float getEnergy() const
Get the calorimetric energy of the hit, corrected for sampling factors [MeV].
float getTime() const
Get the time of the hit [ns].
int getID() const
Get the detector ID.
Implementation of HCal strip readout.
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:24
A very simple wrapper enabling us to more easily tell the output stream to style the input word in he...