237 auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(ev);
238 art::ServiceHandle<cheat::BackTrackerService> backtracker;
240 const std::vector<simb::MCParticle> &mcparticle_list = *ev.getValidHandle<std::vector<simb::MCParticle>>(
"largeant");
242 const simb::MCParticle *
muon = NULL;
243 const simb::MCParticle *proton = NULL;
246 for (
unsigned i = 0; i < mcparticle_list.size(); i++) {
247 if (mcparticle_list[i].PdgCode() == 13 && mcparticle_list[i].Process() ==
"primary") {
248 assert(muon == NULL);
249 muon = &mcparticle_list[i];
251 if (mcparticle_list[i].PdgCode() == 2212 && mcparticle_list[i].Process() ==
"primary") {
252 assert(proton == NULL);
253 proton = &mcparticle_list[i];
257 assert(muon != NULL);
258 assert(proton != NULL);
263 std::vector<const sim::IDE*> muon_ides(backtracker->TrackIdToSimIDEs_Ps(muon->TrackId()));
264 for (
const sim::IDE *ide: muon_ides) muonE += ide->energy;
267 std::vector<const sim::IDE*> proton_ides(backtracker->TrackIdToSimIDEs_Ps(proton->TrackId()));
268 for (
const sim::IDE *ide: proton_ides) protonE += ide->energy;
270 const auto &particle_handle = ev.getValidHandle<std::vector<recob::PFParticle>>(
"pandora");
271 const std::vector<recob::PFParticle> &particle_list = *particle_handle;
272 art::FindManyP<recob::Cluster> particles_to_clusters(particle_handle, ev,
"pandora");
273 art::FindManyP<recob::Track> particles_to_tracks(particle_handle, ev,
"pandoraTrack");
278 for (
unsigned i_part = 0; i_part < particle_list.size(); i_part++) {
279 const std::vector<art::Ptr<recob::Cluster>> clusters = particles_to_clusters.at(i_part);
280 art::FindManyP<recob::Hit> clusters_to_hits(clusters, ev,
"pandora");
282 std::vector<art::Ptr<recob::Hit>> hits;
283 for (
unsigned i_clus = 0; i_clus < clusters.size(); i_clus++) {
284 const std::vector<art::Ptr<recob::Hit>> &this_hits = clusters_to_hits.at(i_clus);
285 hits.insert(hits.end(), this_hits.begin(), this_hits.end());
291 float muon_completion =
Completion(*muon, muonE, matches, mcparticle_list);
292 float proton_completion =
Completion(*proton, protonE, matches, mcparticle_list);
294 float muon_purity =
Purity(*muon, totalE, matches, mcparticle_list);
295 float proton_purity =
Purity(*proton, totalE, matches, mcparticle_list);
297 const recob::Track *
track = particles_to_tracks.at(i_part).size() ? particles_to_tracks.at(i_part).at(0).get() : NULL;
299 if (muon_completion > 0.5 && proton_completion > 0.5) {
300 FillReco(0, *muon, *proton, muon_completion, proton_completion, muon_purity, proton_purity);
302 proton_track =
track;
304 else if (muon_completion > 0.5) {
305 FillReco(1, *muon, *proton, muon_completion, proton_completion, muon_purity, proton_purity);
308 else if (proton_completion > 0.5) {
309 FillReco(2, *muon, *proton, muon_completion, proton_completion, muon_purity, proton_purity);
310 proton_track =
track;
313 if (muon_track && proton_track && muon_track != proton_track) {
314 FillVertex(muon->Position().Vect(), muon_track, proton_track);
void FillTrue(const simb::MCParticle &muon, const simb::MCParticle &proton)
void FillReco(unsigned i, const simb::MCParticle &muon, const simb::MCParticle &proton, float muon_completion, float proton_completion, float muon_purity, float proton_purity)
process_name use argoneut_mc_hitfinder track
std::vector< std::pair< int, float > > AllTrueParticleIDEnergyMatches(const detinfo::DetectorClocksData &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
Ionization at a point of the TPC sensitive volume.
process_name can override from command line with o or output muon
float Completion(const simb::MCParticle &particle, float particleE, const std::vector< std::pair< int, float >> &matches, const std::vector< simb::MCParticle > &particles)
float Purity(const simb::MCParticle &particle, float totalE, const std::vector< std::pair< int, float >> &matches, const std::vector< simb::MCParticle > &particles)
void FillVertex(const TVector3 vertex, const recob::Track *muon, const recob::Track *proton)
float TotalHitEnergy(const detinfo::DetectorClocksData &clockData, const std::vector< art::Ptr< recob::Hit > > &hits)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: