Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions sbncode/CAFMaker/CAFMaker_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ class CAFMaker : public art::EDProducer {
art::FindOneP<T> FindOnePStrict(const U& from, const art::Event& evt,
const art::InputTag& label) const;

template <class T, class U>
art::FindOneP<T> FindOnePStrictSingle(const U& from, const art::Event& evt,
const art::InputTag& label) const;

template <class T, class D, class U>
art::FindOneP<T, D> FindOnePDStrict(const U& from,
const art::Event& evt,
Expand Down Expand Up @@ -1299,6 +1303,14 @@ art::FindOneP<T> CAFMaker::FindOnePStrict(const U& from,
return ret;
}

//......................................................................
template <class T, class U>
art::FindOneP<T> CAFMaker::FindOnePStrictSingle(const U& from,
const art::Event& evt,
const art::InputTag& tag) const {
return FindOnePStrict(std::vector{ from }, evt, tag);
}

//......................................................................
template <class T, class D, class U>
art::FindOneP<T, D> CAFMaker::FindOnePDStrict(const U& from,
Expand Down Expand Up @@ -1791,12 +1803,15 @@ void CAFMaker::produce(art::Event& evt) noexcept {
{
art::Handle<std::vector<sbnd::crt::CRTSpacePoint>> crtspacepoints_handle;
GetByLabelStrict(evt, fParams.CRTSpacePointLabel(), crtspacepoints_handle);
art::FindOneP<sbnd::crt::CRTCluster> foCRTCluster =
FindOnePStrict<sbnd::crt::CRTCluster>(crtspacepoints_handle, evt, fParams.CRTSpacePointLabel());

if (crtspacepoints_handle.isValid()) {
const std::vector<sbnd::crt::CRTSpacePoint> &crtspacepoints = *crtspacepoints_handle;
for (unsigned i = 0; i < crtspacepoints.size(); i++) {
srcrtspacepoints.emplace_back();
FillCRTSpacePoint(crtspacepoints[i], srcrtspacepoints.back());
const art::Ptr<sbnd::crt::CRTCluster> crtcluster = foCRTCluster.at(i);
FillCRTSpacePoint(crtspacepoints[i], crtcluster, srcrtspacepoints.back());
}
}

Expand Down Expand Up @@ -2239,6 +2254,9 @@ void CAFMaker::produce(art::Event& evt) noexcept {
FindOnePDStrict<sbnd::crt::CRTSpacePoint, anab::T0>(slcTracks, evt,
fParams.CRTSpacePointMatchLabel() + slice_tag_suff);

art::Handle<std::vector<sbnd::crt::CRTSpacePoint>> crtspacepoints_handle;
GetByLabelStrict(evt, fParams.CRTSpacePointLabel(), crtspacepoints_handle);

art::FindOneP<sbnd::crt::CRTTrack, anab::T0> foSBNDCRTTrackMatch =
FindOnePDStrict<sbnd::crt::CRTTrack, anab::T0>(slcTracks, evt,
fParams.SBNDCRTTrackMatchLabel() + slice_tag_suff);
Expand Down Expand Up @@ -2515,8 +2533,12 @@ void CAFMaker::produce(art::Event& evt) noexcept {
{
const art::Ptr<sbnd::crt::CRTSpacePoint> crtspacepoint = foCRTSpacePointMatch.at(iPart);

art::FindOneP<sbnd::crt::CRTCluster> foCRTCluster =
FindOnePStrictSingle<sbnd::crt::CRTCluster>(crtspacepoint, evt, fParams.CRTSpacePointLabel());
const art::Ptr<sbnd::crt::CRTCluster>& crtcluster = foCRTCluster.at(0);

if(crtspacepoint.isNonnull())
FillTrackCRTSpacePoint(foCRTSpacePointMatch.data(iPart).ref(), crtspacepoint, trk);
FillTrackCRTSpacePoint(foCRTSpacePointMatch.data(iPart).ref(), crtspacepoint, crtcluster, trk);
}
if(foSBNDCRTTrackMatch.isValid() && fDet == kSBND)
{
Expand Down
17 changes: 14 additions & 3 deletions sbncode/CAFMaker/FillReco.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ namespace caf
}

void FillCRTSpacePoint(const sbnd::crt::CRTSpacePoint &spacepoint,
const art::Ptr<sbnd::crt::CRTCluster> &cluster,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend the interface to pass the object directly instead of its art pointer:

Suggested change
const art::Ptr<sbnd::crt::CRTCluster> &cluster,
const sbnd::crt::CRTCluster &cluster,

That allows in general the use of the function even when an art pointer is not available.
This change should be propagated as upstream as possible (i.e. to FillTrackCRTSpacePoint() interface too).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have done so. It results in moving the dereferencing up to CAFMaker_module.cc. There's probably a neater way of doing that but I'm in a bit of a time crunch.

caf::SRCRTSpacePoint &srspacepoint,
bool allowEmpty)
{
Expand All @@ -173,6 +174,8 @@ namespace caf
srspacepoint.time = spacepoint.Ts0();
srspacepoint.time_err = spacepoint.Ts0Err();
srspacepoint.complete = spacepoint.Complete();
srspacepoint.nhits = cluster->NHits();
srspacepoint.tagger = cluster->Tagger();
}

void FillSBNDCRTTrack(const sbnd::crt::CRTTrack &track,
Expand All @@ -186,6 +189,9 @@ namespace caf
srsbndcrttrack.time_err = track.Ts0Err();
srsbndcrttrack.pe = track.PE();
srsbndcrttrack.tof = track.ToF();

for(auto const& tagger : track.Taggers())
srsbndcrttrack.taggers.push_back(tagger);
}

void FillSBNDCRTVeto(const sbnd::crt::CRTVeto &veto,
Expand Down Expand Up @@ -811,19 +817,24 @@ namespace caf

void FillTrackCRTSpacePoint(const anab::T0 &t0match,
const art::Ptr<sbnd::crt::CRTSpacePoint> &spacepointmatch,
const art::Ptr<sbnd::crt::CRTCluster> &cluster,
caf::SRTrack &srtrack,
bool allowEmpty)
{
srtrack.crtspacepoint.score = t0match.fTriggerConfidence;
FillCRTSpacePoint(*spacepointmatch, srtrack.crtspacepoint.spacepoint);
srtrack.crtspacepoint.matched = true;
srtrack.crtspacepoint.score = t0match.fTriggerConfidence;

FillCRTSpacePoint(*spacepointmatch, cluster, srtrack.crtspacepoint.spacepoint);
}

void FillTrackSBNDCRTTrack(const anab::T0 &t0match,
const art::Ptr<sbnd::crt::CRTTrack> &trackmatch,
caf::SRTrack &srtrack,
bool allowEmpty)
{
srtrack.crtsbndtrack.score = t0match.fTriggerConfidence;
srtrack.crtsbndtrack.matched = true;
srtrack.crtsbndtrack.score = t0match.fTriggerConfidence;

FillSBNDCRTTrack(*trackmatch, srtrack.crtsbndtrack.track);
}

Expand Down
3 changes: 3 additions & 0 deletions sbncode/CAFMaker/FillReco.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "sbnobj/Common/CRT/CRTHit.hh"
#include "sbnobj/Common/CRT/CRTTrack.hh"
#include "sbnobj/SBND/CRT/CRTSpacePoint.hh"
#include "sbnobj/SBND/CRT/CRTCluster.hh"
#include "sbnobj/SBND/CRT/CRTTrack.hh"
#include "sbnobj/SBND/CRT/CRTVeto.hh"
#include "sbnobj/Common/CRT/CRTPMTMatching.hh"
Expand Down Expand Up @@ -206,6 +207,7 @@ namespace caf

void FillTrackCRTSpacePoint(const anab::T0 &t0match,
const art::Ptr<sbnd::crt::CRTSpacePoint> &spacepointmatch,
const art::Ptr<sbnd::crt::CRTCluster> &cluster,
caf::SRTrack &srtrack,
bool allowEmpty = false);

Expand Down Expand Up @@ -277,6 +279,7 @@ namespace caf
bool allowEmpty = false);

void FillCRTSpacePoint(const sbnd::crt::CRTSpacePoint &spacepoint,
const art::Ptr<sbnd::crt::CRTCluster> &cluster,
caf::SRCRTSpacePoint &srspacepoint,
bool allowEmpty = false);

Expand Down