diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index 53589b2ac..0250e740f 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -255,6 +255,12 @@ namespace caf "pandoraPid" }; + Atom TrackLikePidLabel { + Name("TrackLikePidLabel"), + Comment("Base label of track likelihood particle-id producer."), + "pandoraLikePid" + }; + Atom TrackScatterClosestApproachLabel { Name("TrackScatterClosestApproachLabel"), Comment("Base label of track track scatter closestapproach producer."), diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index c59aa8193..9f2c01590 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -2179,6 +2179,10 @@ void CAFMaker::produce(art::Event& evt) noexcept { FindManyPStrict(slcTracks, evt, fParams.TrackChi2PidLabel() + slice_tag_suff); + art::FindManyP fmLikePID = + FindManyPStrict(slcTracks, evt, + fParams.TrackLikePidLabel() + slice_tag_suff); + art::FindManyP fmScatterClosestApproach = FindManyPStrict(slcTracks, evt, fParams.TrackScatterClosestApproachLabel() + slice_tag_suff); @@ -2470,6 +2474,9 @@ void CAFMaker::produce(art::Event& evt) noexcept { if (fmChi2PID.isValid()) { FillTrackChi2PID(fmChi2PID.at(iPart), trk); } + if (fmLikePID.isValid()) { + FillTrackLikePID(fmLikePID.at(iPart), trk); + } if (fmScatterClosestApproach.isValid() && fmScatterClosestApproach.at(iPart).size()==1) { FillTrackScatterClosestApproach(fmScatterClosestApproach.at(iPart).front(), trk); } diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 7830b48b6..46396a2c1 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -951,6 +951,48 @@ namespace caf } } + void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikelihoodPID &srlikepid) { + + // Loop over algorithm scores and extract the ones we want. + // Get the ndof from any likelihood pid algorithm + srlikepid.setDefault(); + + std::vector const& AlgScoresVec = particle_id.ParticleIDAlgScores(); + for (anab::sParticleIDAlgScores const& AlgScore: AlgScoresVec){ + if (AlgScore.fAlgName == "Likelihood"){ + switch (std::abs(AlgScore.fAssumedPdg)) { + case 13: // lambda_mu + srlikepid.lambda_muon = AlgScore.fValue; + srlikepid.pid_ndof = AlgScore.fNdf; + break; + case 211: // lambda_pi + srlikepid.lambda_pion = AlgScore.fValue; + srlikepid.pid_ndof = AlgScore.fNdf; + break; + case 2212: // lambda_pr + srlikepid.lambda_proton = AlgScore.fValue; + srlikepid.pid_ndof = AlgScore.fNdf; + break; + } + } + } + } + + void FillTrackLikePID(const std::vector>& particleIDs, + caf::SRTrack& srtrack, + bool allowEmpty) + { + // get the particle ID's + for (art::Ptr const& pidPtr: particleIDs) { + const anab::ParticleID &particle_id = *pidPtr; + if (particle_id.PlaneID()) { + unsigned plane_id = particle_id.PlaneID().Plane; + assert(plane_id < 3); + FillPlaneLikePID(particle_id, srtrack.likepid[plane_id]); + } + } + } + void FillTrackPlaneCalo(const anab::Calorimetry &calo, const std::vector> &hits, bool fill_calo_points, float fillhit_rrstart, float fillhit_rrend, diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index b1f8d9b05..46704181a 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -228,6 +228,10 @@ namespace caf void FillTrackChi2PID(const std::vector> particleIDs, caf::SRTrack& srtrack, bool allowEmpty = false); + void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikelihoodPID &srlikepid); + void FillTrackLikePID(const std::vector>& particleIDs, + caf::SRTrack& srtrack, + bool allowEmpty = false); void FillTrackPlaneCalo(const anab::Calorimetry &calo, const std::vector> &hits,