LDMX Software
CascadeHistory.cxx
Go to the documentation of this file.
1
6
7#include <iostream>
8
9namespace ldmx {
10
11void CascadeHistory::clear() {
12 incident_track_id_ = -1;
13 target_a_ = 0;
14 target_z_ = 0;
15 steps_.clear();
16}
17
18const CascadeStep* CascadeHistory::getStepByHistoryId(int historyId) const {
19 for (const auto& step : steps_) {
20 if (step.getHistoryId() == historyId) {
21 return &step;
22 }
23 }
24 return nullptr;
25}
26
27const CascadeStep* CascadeHistory::getIncidentStep() const {
28 for (const auto& step : steps_) {
29 if (step.getGeneration() == 0 && step.getParentId() == -1) {
30 return &step;
31 }
32 }
33 return steps_.empty() ? nullptr : &steps_.front();
34}
35
36std::vector<const CascadeStep*> CascadeHistory::getStepsAtGeneration(
37 int generation) const {
38 std::vector<const CascadeStep*> result;
39 for (const auto& step : steps_) {
40 if (step.getGeneration() == generation) {
41 result.push_back(&step);
42 }
43 }
44 return result;
45}
46
47std::vector<const CascadeStep*> CascadeHistory::getInteractingSteps() const {
48 std::vector<const CascadeStep*> result;
49 for (const auto& step : steps_) {
50 if (step.didInteract()) {
51 result.push_back(&step);
52 }
53 }
54 return result;
55}
56
57std::vector<const CascadeStep*> CascadeHistory::getEscapedSteps() const {
58 std::vector<const CascadeStep*> result;
59 for (const auto& step : steps_) {
60 if (step.didEscape()) {
61 result.push_back(&step);
62 }
63 }
64 return result;
65}
66
67int CascadeHistory::getMaxGeneration() const {
68 int max_gen = -1;
69 for (const auto& step : steps_) {
70 if (step.getGeneration() > max_gen) {
71 max_gen = step.getGeneration();
72 }
73 }
74 return max_gen;
75}
76
77int CascadeHistory::getNumInteractions() const {
78 int count = 0;
79 for (const auto& step : steps_) {
80 if (step.didInteract()) {
81 ++count;
82 }
83 }
84 return count;
85}
86
87void CascadeHistory::print() const {
88 std::cout << "CascadeHistory: " << steps_.size() << " steps"
89 << ", target A=" << target_a_ << " Z=" << target_z_
90 << ", incident track=" << incident_track_id_ << "\n";
91
92 for (const auto& step : steps_) {
93 std::cout << " [" << step.getHistoryId() << "] "
94 << "PDG=" << step.getPdgId() << " gen=" << step.getGeneration()
95 << " zone=" << step.getZone() << " E=" << step.getEnergy()
96 << " MeV";
97 if (step.getParentId() >= 0) {
98 std::cout << " parent=" << step.getParentId();
99 }
100 if (step.didInteract()) {
101 std::cout << " -> " << step.getNumDaughters() << " daughters";
102 }
103 if (step.didEscape()) {
104 std::cout << " [escaped]";
105 }
106 std::cout << "\n";
107 }
108}
109
110} // namespace ldmx
Container for the complete history of a Bertini intranuclear cascade.