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 hitE = eh->getEnergy();
16 TVector3 hitpos = hex.getStripCenterPosition(eh->getID());
17 double hitX = hitpos.x();
18 double hitY = hitpos.y();
19 double hitZ = hitpos.z();
20 double hitT = eh->getTime();
21 // Based on weight for Center-of-Gravity by hitpos*hiE/totalE
22 double newE = hitE + centroid_.E();
23 double newCentroidX = (centroid_.Px() * centroid_.E() + hitE * hitX) / newE;
24 double newCentroidY = (centroid_.Py() * centroid_.E() + hitE * hitY) / newE;
25 double newCentroidZ = (centroid_.Pz() * centroid_.E() + hitE * hitZ) / newE;
26
27 if (time_ < hitT) {
28 time_ = hitT;
29 }
30 centroid_.SetPxPyPzE(newCentroidX, newCentroidY, newCentroidZ, newE);
31 hits_.push_back(eh);
32}
33
34void WorkingCluster::add(const WorkingCluster& wc) {
35 double clusterE = wc.centroid().E();
36 double centroidX = wc.centroid().Px();
37 double centroidY = wc.centroid().Py();
38 double centroidZ = wc.centroid().Pz();
39
40 double newE = clusterE + centroid_.E();
41 double newCentroidX =
42 (centroid_.Px() * centroid_.E() + clusterE * centroidX) / newE;
43 double newCentroidY =
44 (centroid_.Py() * centroid_.E() + clusterE * centroidY) / newE;
45 double newCentroidZ =
46 (centroid_.Pz() * centroid_.E() + clusterE * centroidZ) / newE;
47
48 centroid_.SetPxPyPzE(newCentroidX, newCentroidY, newCentroidZ, newE);
49 /*if(wc.GetTime() > time_){
50 time_ = wc.GetTime();
51 }*/
52
53 std::vector<const ldmx::HcalHit*> clusterHits = wc.getHits();
54
55 for (unsigned int i = 0; i < clusterHits.size(); i++) {
56 hits_.push_back(clusterHits[i]);
57 }
58}
59} // 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:23