20 std::vector<ldmx::SimCalorimeterHit> ecal_sim_hits =
25 std::sort(ecal_sim_hits.begin(), ecal_sim_hits.end(),
28 return lhs.getID() < rhs.getID();
31 std::vector<ldmx::EcalHit> ecal_rec_hits =
event.getCollection<
ldmx::EcalHit>(
35 std::sort(ecal_rec_hits.begin(), ecal_rec_hits.end(),
37 return lhs.getID() < rhs.getID();
41 int num_noise_hits{0};
42 double total_rec_energy{0.};
43 int num_mod_with_0hits{0};
44 int num_mod_with_1hits{0};
45 int num_mod_with_2hits{0};
46 int num_mod_with_more_than_2hits{0};
47 std::vector<int> my_costum_mod_ids;
49 std::set<int> my_costum_mod_ids_set;
57 int layer = ecal_id.
layer() + 1;
59 int my_mod_costum_id = layer * 100 + module_id;
61 my_costum_mod_ids.push_back(my_mod_costum_id);
62 my_costum_mod_ids_set.insert(my_mod_costum_id);
65 total_rec_energy += rec_hit.getEnergy();
68 if (rec_hit.isNoise()) {
75 int raw_id = rec_hit.getID();
78 double sim_pos_x_weighted = 0.;
79 double sim_pos_y_weighted = 0.;
80 double sim_pos_z_weighted = 0.;
84 double total_sim_energy_dep = 0.;
86 if (raw_id == sim_hit.getID()) {
87 num_sim_hits += sim_hit.getNumberOfContribs();
88 total_sim_energy_dep += sim_hit.getEdep();
89 sim_pos_x_weighted += sim_hit.getPosition()[0] * sim_hit.getEdep();
90 sim_pos_y_weighted += sim_hit.getPosition()[1] * sim_hit.getEdep();
91 sim_pos_z_weighted += sim_hit.getPosition()[2] * sim_hit.getEdep();
93 }
else if (raw_id < sim_hit.getID()) {
99 sim_pos_x_weighted /= total_sim_energy_dep;
100 sim_pos_y_weighted /= total_sim_energy_dep;
101 sim_pos_z_weighted /= total_sim_energy_dep;
102 auto residual_x = rec_hit.getXPos() - sim_pos_x_weighted;
103 auto residual_y = rec_hit.getYPos() - sim_pos_y_weighted;
104 auto residual_z = rec_hit.getZPos() - sim_pos_z_weighted;
113 rec_hit.getAmplitude());
115 rec_hit.getEnergy());
118 std::map<int, int> module_hits;
119 for (
const int &my_costum_mod_id : my_costum_mod_ids) {
120 module_hits[my_costum_mod_id]++;
125 num_mod_with_0hits =
num_layers_ * 7 - my_costum_mod_ids_set.size();
127 for (
const auto &module_hit : module_hits) {
128 if (module_hit.second == 1) {
129 num_mod_with_1hits++;
130 }
else if (module_hit.second == 2) {
131 num_mod_with_2hits++;
132 }
else if (module_hit.second > 2) {
134 num_mod_with_more_than_2hits++;
145 if (num_mod_with_1hits > 0)
147 if (num_mod_with_2hits > 0)
149 if (num_mod_with_more_than_2hits > 0)
151 num_mod_with_more_than_2hits);
160 if (total_rec_energy > 6000.) {
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.