From 3a01359187e524e5266f8b565801b2e4bc6cf4ca Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Fri, 27 Oct 2023 12:41:59 -0500 Subject: [PATCH 1/5] Add barycenter match into CAF --- sbncode/CAFMaker/CAFMakerParams.h | 6 ++++++ sbncode/CAFMaker/CAFMaker_module.cc | 12 ++++++++++++ sbncode/CAFMaker/FillReco.cxx | 26 ++++++++++++++++++++++++++ sbncode/CAFMaker/FillReco.h | 4 ++++ 4 files changed, 48 insertions(+) diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index fc02d5ff9..0e675ce31 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -272,6 +272,12 @@ namespace caf "crtpmt" // this variable exists in icaruscode, pretty sure it does not yet exist in sbnd }; + Atom BarycenterMatchLabel { + Name("BarycenterMatchLabel"), + Comment("Label of Slice-OpFlash matching via barycenters."), + "barycentermatch" + }; + Atom OpFlashLabel { Name("OpFlashLabel"), Comment("Label of PMT flash."), diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index e6efee59d..93d47bded 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -446,6 +446,9 @@ void CAFMaker::FixPMTReferenceTimes(StandardRecord &rec, double PMT_reference_ti s.fmatch.time += PMT_reference_time; s.fmatch_a.time += PMT_reference_time; s.fmatch_b.time += PMT_reference_time; + + s.barycenterFM.flashTime +=PMT_reference_time; + s.barycenterFM.flashFirstHit +=PMT_reference_time; } // TODO: fix more? @@ -1452,6 +1455,14 @@ void CAFMaker::produce(art::Event& evt) noexcept { FindManyPStrict(fmPFPart, evt, fParams.FlashMatchLabel() + slice_tag_suff); + art::FindOneP foBarycenterMatch = + FindOnePStrict(sliceList, evt, + fParams.BarycenterMatchLabel() + slice_tag_suff); + const sbn::BarycenterMatch *barycenterMatch = nullptr; + if (foBarycenterMatch.isValid()) { + barycenterMatch = foBarycenterMatch.at(0).get(); + } + art::FindManyP fmPFPMeta = FindManyPStrict(fmPFPart, evt, fParams.PFParticleLabel() + slice_tag_suff); @@ -1644,6 +1655,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { FillSliceCRUMBS(slcCRUMBS, recslc); FillSliceOpT0Finder(slcOpT0, recslc); FillSliceBarycenter(slcHits, slcSpacePoints, recslc); + FillBarycenterMatch(barycenterMatch, recslc); // select slice if (!SelectSlice(recslc, fParams.CutClearCosmic())) continue; diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 5145f0792..5fd3de961 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -900,6 +900,32 @@ namespace caf srhit.spacepoint.pfpID = particle.Self(); srhit.spacepoint.ID = spacepoint.ID(); } + + void FillBarycenterMatch(const sbn::BarycenterMatch *matchInfo, + caf::SRSlice& slice) + { + slice.barycenterFM.setDefault(); + + if ( matchInfo != nullptr ) { + slice.barycenterFM.chargeTotal = matchInfo->chargeTotal; + slice.barycenterFM.chargeCenterXLocal = matchInfo->chargeCenterXLocal; + slice.barycenterFM.chargeCenter = SRVector3D (matchInfo->chargeCenter.x(), matchInfo->chargeCenter.y(), matchInfo->chargeCenter.z()); + slice.barycenterFM.chargeWidth = SRVector3D (matchInfo->chargeWidth.x(), matchInfo->chargeWidth.y(), matchInfo->chargeWidth.z()); + slice.barycenterFM.flashFirstHit = matchInfo->flashFirstHit; + slice.barycenterFM.flashTime = matchInfo->flashTime; + slice.barycenterFM.flashPEs = matchInfo->flashPEs; + slice.barycenterFM.flashCenter = SRVector3D (matchInfo->flashCenter.x(), matchInfo->flashCenter.y(), matchInfo->flashCenter.z()); + slice.barycenterFM.flashWidth = SRVector3D (matchInfo->flashWidth.x(), matchInfo->flashWidth.y(), matchInfo->flashWidth.z()); + slice.barycenterFM.deltaT = matchInfo->deltaT; + slice.barycenterFM.deltaY = matchInfo->deltaY; + slice.barycenterFM.deltaZ = matchInfo->deltaZ; + slice.barycenterFM.radius = matchInfo->radius; + slice.barycenterFM.overlapY = matchInfo->overlapY; + slice.barycenterFM.overlapZ = matchInfo->overlapZ; + slice.barycenterFM.deltaZ_Trigger = matchInfo->deltaZ_Trigger; + } + } + //...................................................................... void SetNuMuCCPrimary(std::vector &recs, diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index 6af1a5c69..dbd4e5dca 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -34,6 +34,7 @@ #include "sbnobj/Common/Reco/StoppingChi2Fit.h" #include "sbnobj/Common/Reco/CRUMBSResult.h" #include "sbnobj/Common/Reco/OpT0FinderResult.h" +#include "sbnobj/Common/Reco/BarycenterMatch.h" #include "sbnobj/Common/CRT/CRTHit.hh" #include "sbnobj/Common/CRT/CRTTrack.hh" #include "sbnobj/Common/CRT/CRTPMTMatching.hh" @@ -201,6 +202,9 @@ namespace caf caf::SRCRTPMTMatch &srmatch, bool allowEmpty = false); + void FillBarycenterMatch(const sbn::BarycenterMatch *matchInfo, + caf::SRSlice& slice); + template void CopyPropertyIfSet( const std::map& props, const std::string& search, U& value ); } From 09779ccd41f24446577302bdef7458150271dac8 Mon Sep 17 00:00:00 2001 From: JackSmedley <85366220+JackSmedley@users.noreply.github.com> Date: Fri, 17 Nov 2023 10:34:14 -0600 Subject: [PATCH 2/5] One line initialization looks nicer Co-authored-by: Gianluca Petrillo --- sbncode/CAFMaker/CAFMaker_module.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 93d47bded..62462c8c9 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -1458,10 +1458,8 @@ void CAFMaker::produce(art::Event& evt) noexcept { art::FindOneP foBarycenterMatch = FindOnePStrict(sliceList, evt, fParams.BarycenterMatchLabel() + slice_tag_suff); - const sbn::BarycenterMatch *barycenterMatch = nullptr; - if (foBarycenterMatch.isValid()) { - barycenterMatch = foBarycenterMatch.at(0).get(); - } + const sbn::BarycenterMatch *barycenterMatch + = foBarycenterMatch.isValid()? foBarycenterMatch.at(0).get(): nullptr; art::FindManyP fmPFPMeta = FindManyPStrict(fmPFPart, evt, From 5f28c373008300fef6bfbfb65fcc02fd0351c90a Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Fri, 17 Nov 2023 12:32:42 -0600 Subject: [PATCH 3/5] Add Y-dimension into trigger match --- sbncode/CAFMaker/FillReco.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 5fd3de961..aceb2132c 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -923,6 +923,8 @@ namespace caf slice.barycenterFM.overlapY = matchInfo->overlapY; slice.barycenterFM.overlapZ = matchInfo->overlapZ; slice.barycenterFM.deltaZ_Trigger = matchInfo->deltaZ_Trigger; + slice.barycenterFM.deltaY_Trigger = matchInfo->deltaY_Trigger; + slice.barycenterFM.radius_Trigger = matchInfo->radius_Trigger; } } From 62aab7840ec96b8bda49130773133ba39105be62 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Sat, 18 Nov 2023 13:37:48 -0600 Subject: [PATCH 4/5] Change name to be more descriptive --- sbncode/CAFMaker/CAFMakerParams.h | 6 +++--- sbncode/CAFMaker/CAFMaker_module.cc | 12 ++++++------ sbncode/CAFMaker/FillReco.cxx | 2 +- sbncode/CAFMaker/FillReco.h | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index 0e675ce31..9dc4c681e 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -272,10 +272,10 @@ namespace caf "crtpmt" // this variable exists in icaruscode, pretty sure it does not yet exist in sbnd }; - Atom BarycenterMatchLabel { - Name("BarycenterMatchLabel"), + Atom TPCPMTBarycenterMatchLabel { + Name("TPCPMTBarycenterMatchLabel"), Comment("Label of Slice-OpFlash matching via barycenters."), - "barycentermatch" + "tpcpmtbarycentermatch" }; Atom OpFlashLabel { diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 62462c8c9..7033e8086 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -1455,11 +1455,11 @@ void CAFMaker::produce(art::Event& evt) noexcept { FindManyPStrict(fmPFPart, evt, fParams.FlashMatchLabel() + slice_tag_suff); - art::FindOneP foBarycenterMatch = - FindOnePStrict(sliceList, evt, - fParams.BarycenterMatchLabel() + slice_tag_suff); - const sbn::BarycenterMatch *barycenterMatch - = foBarycenterMatch.isValid()? foBarycenterMatch.at(0).get(): nullptr; + art::FindOneP foTPCPMTBarycenterMatch = + FindOnePStrict(sliceList, evt, + fParams.TPCPMTBarycenterMatchLabel() + slice_tag_suff); + const sbn::TPCPMTBarycenterMatch *barycenterMatch + = foTPCPMTBarycenterMatch.isValid()? foTPCPMTBarycenterMatch.at(0).get(): nullptr; art::FindManyP fmPFPMeta = FindManyPStrict(fmPFPart, evt, @@ -1653,7 +1653,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { FillSliceCRUMBS(slcCRUMBS, recslc); FillSliceOpT0Finder(slcOpT0, recslc); FillSliceBarycenter(slcHits, slcSpacePoints, recslc); - FillBarycenterMatch(barycenterMatch, recslc); + FillTPCPMTBarycenterMatch(barycenterMatch, recslc); // select slice if (!SelectSlice(recslc, fParams.CutClearCosmic())) continue; diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index aceb2132c..0655b1c02 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -901,7 +901,7 @@ namespace caf srhit.spacepoint.ID = spacepoint.ID(); } - void FillBarycenterMatch(const sbn::BarycenterMatch *matchInfo, + void FillTPCPMTBarycenterMatch(const sbn::TPCPMTBarycenterMatch *matchInfo, caf::SRSlice& slice) { slice.barycenterFM.setDefault(); diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index dbd4e5dca..ff68916a1 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -34,7 +34,7 @@ #include "sbnobj/Common/Reco/StoppingChi2Fit.h" #include "sbnobj/Common/Reco/CRUMBSResult.h" #include "sbnobj/Common/Reco/OpT0FinderResult.h" -#include "sbnobj/Common/Reco/BarycenterMatch.h" +#include "sbnobj/Common/Reco/TPCPMTBarycenterMatch.h" #include "sbnobj/Common/CRT/CRTHit.hh" #include "sbnobj/Common/CRT/CRTTrack.hh" #include "sbnobj/Common/CRT/CRTPMTMatching.hh" @@ -202,7 +202,7 @@ namespace caf caf::SRCRTPMTMatch &srmatch, bool allowEmpty = false); - void FillBarycenterMatch(const sbn::BarycenterMatch *matchInfo, + void FillTPCPMTBarycenterMatch(const sbn::TPCPMTBarycenterMatch *matchInfo, caf::SRSlice& slice); template From be697144f0d890063a40d7fb8139a64b3d65ef41 Mon Sep 17 00:00:00 2001 From: Jack Smedley Date: Mon, 20 Nov 2023 21:37:40 -0600 Subject: [PATCH 5/5] Set default label to empty in cafmaker params --- sbncode/CAFMaker/CAFMakerParams.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index 9dc4c681e..77918945a 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -275,7 +275,7 @@ namespace caf Atom TPCPMTBarycenterMatchLabel { Name("TPCPMTBarycenterMatchLabel"), Comment("Label of Slice-OpFlash matching via barycenters."), - "tpcpmtbarycentermatch" + "" //Empty by default, configured in icaruscode cafmaker_defs }; Atom OpFlashLabel {