LDMX Software
IntermediateCluster.cxx
1
2#include "Ecal/IntermediateCluster.h"
3
4#include <iostream>
5
6namespace ecal {
7
8IntermediateCluster::IntermediateCluster(const ldmx::EcalHit& eh, int layer)
9 : layer_{layer}, hits_{}, centroid_{} {
10 add(eh);
11}
12
13void IntermediateCluster::add(const ldmx::EcalHit& eh) {
14 hits_.push_back(&eh);
15
16 double hit_e = eh.getEnergy();
17 double hit_x = eh.getXPos();
18 double hit_y = eh.getYPos();
19 double hit_z = eh.getZPos();
20
21 double new_e = hit_e + centroid_.E();
22 centroid_.SetXYZT((centroid_.x() * centroid_.E() + hit_e * hit_x) / new_e,
23 (centroid_.y() * centroid_.E() + hit_e * hit_y) / new_e,
24 (centroid_.z() * centroid_.E() + hit_e * hit_z) / new_e,
25 new_e);
26}
27
28void IntermediateCluster::add(const ldmx::EcalHit* eh) {
29 if (eh != nullptr) add(*eh);
30}
31
32void IntermediateCluster::add(const IntermediateCluster& wc) {
33 double new_e = wc.centroid().E() + centroid_.E();
34 centroid_.SetXYZT(
35 (centroid_.x() * centroid_.E() + wc.centroid().x() * wc.centroid().E()) /
36 new_e,
37 (centroid_.y() * centroid_.E() + wc.centroid().y() * wc.centroid().E()) /
38 new_e,
39 (centroid_.z() * centroid_.E() + wc.centroid().z() * wc.centroid().E()) /
40 new_e,
41 new_e);
42
43 for (const auto eh : wc.getHits()) {
44 hits_.push_back(eh);
45 }
46}
47// Set layer of the cluster centroid
48void IntermediateCluster::setLayer(int layer) { layer_ = layer; }
49
50// Get layer of the cluster centroid
51int IntermediateCluster::getLayer() const { return layer_; }
52
53} // namespace ecal
float getEnergy() const
Get the calorimetric energy of the hit, corrected for sampling factors [MeV].
float getYPos() const
Get the Y position of the hit [mm].
float getZPos() const
Get the Z position of the hit [mm].
float getXPos() const
Get the X position of the hit [mm].
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19