24 std::vector<ldmx::SimCalorimeterHit> ecal_sim_hits =
29 std::sort(ecal_sim_hits.begin(), ecal_sim_hits.end(),
32 return lhs.getID() < rhs.getID();
35 std::vector<ldmx::EcalHit> ecal_rec_hits =
event.getCollection<
ldmx::EcalHit>(
39 std::sort(ecal_rec_hits.begin(), ecal_rec_hits.end(),
41 return lhs.getID() < rhs.getID();
45 int num_noise_hits{0};
46 double total_rec_energy{0.};
47 int num_mod_with_0hits{0};
48 int num_mod_with_1hits{0};
49 int num_mod_with_2hits{0};
50 int num_mod_with_more_than_2hits{0};
51 std::vector<int> my_costum_mod_ids;
53 std::set<int> my_costum_mod_ids_set;
61 int layer = ecal_id.
layer() + 1;
63 int my_mod_costum_id = layer * 100 + module_id;
65 my_costum_mod_ids.push_back(my_mod_costum_id);
66 my_costum_mod_ids_set.insert(my_mod_costum_id);
69 total_rec_energy += rec_hit.getEnergy();
72 if (rec_hit.isNoise()) {
79 int raw_id = rec_hit.getID();
82 double sim_pos_x_weighted = 0.;
83 double sim_pos_y_weighted = 0.;
84 double sim_pos_z_weighted = 0.;
88 double total_sim_energy_dep = 0.;
90 if (raw_id == sim_hit.getID()) {
91 num_sim_hits += sim_hit.getNumberOfContribs();
92 total_sim_energy_dep += sim_hit.getEdep();
93 sim_pos_x_weighted += sim_hit.getPosition()[0] * sim_hit.getEdep();
94 sim_pos_y_weighted += sim_hit.getPosition()[1] * sim_hit.getEdep();
95 sim_pos_z_weighted += sim_hit.getPosition()[2] * sim_hit.getEdep();
97 }
else if (raw_id < sim_hit.getID()) {
103 sim_pos_x_weighted /= total_sim_energy_dep;
104 sim_pos_y_weighted /= total_sim_energy_dep;
105 sim_pos_z_weighted /= total_sim_energy_dep;
106 auto residual_x = rec_hit.getXPos() - sim_pos_x_weighted;
107 auto residual_y = rec_hit.getYPos() - sim_pos_y_weighted;
108 auto residual_z = rec_hit.getZPos() - sim_pos_z_weighted;
117 rec_hit.getAmplitude());
119 rec_hit.getEnergy());
122 std::map<int, int> module_hits;
123 for (
const int& my_costum_mod_id : my_costum_mod_ids) {
124 module_hits[my_costum_mod_id]++;
129 num_mod_with_0hits =
num_layers_ * 7 - my_costum_mod_ids_set.size();
131 for (
const auto& module_hit : module_hits) {
132 if (module_hit.second == 1) {
133 num_mod_with_1hits++;
134 }
else if (module_hit.second == 2) {
135 num_mod_with_2hits++;
136 }
else if (module_hit.second > 2) {
138 num_mod_with_more_than_2hits++;
149 if (num_mod_with_1hits > 0)
151 if (num_mod_with_2hits > 0)
153 if (num_mod_with_more_than_2hits > 0)
155 num_mod_with_more_than_2hits);
164 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.