From 2f82fea79e85d4680b67b17a2e55d341ce0ab20c Mon Sep 17 00:00:00 2001 From: Riccardo Triozzi Date: Wed, 23 Jul 2025 10:27:00 +0200 Subject: [PATCH 1/4] CAFMaker changes to accomodate for Pandora track/shower discrimination changes --- sbncode/CAFMaker/FillReco.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index f47265c1e..b3b479695 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -918,8 +918,8 @@ namespace caf // Pfo Characterisation features srpfp.pfochar.setDefault(); - CopyPropertyIfSet(propertiesMap, "LArThreeDChargeFeatureTool_EndFraction", srpfp.pfochar.chgendfrac); - CopyPropertyIfSet(propertiesMap, "LArThreeDChargeFeatureTool_FractionalSpread", srpfp.pfochar.chgfracspread); + CopyPropertyIfSet(propertiesMap, "LArThreeDChargeFeatureTool_ICARUS_EndFraction", srpfp.pfochar.chgendfrac); + CopyPropertyIfSet(propertiesMap, "LArThreeDChargeFeatureTool_ICARUS_FractionalSpread", srpfp.pfochar.chgfracspread); CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_DiffStraightLineMean", srpfp.pfochar.linfitdiff); CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_Length", srpfp.pfochar.linfitlen); CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_MaxFitGapLength", srpfp.pfochar.linfitgaplen); @@ -928,9 +928,9 @@ namespace caf CopyPropertyIfSet(propertiesMap, "LArThreeDPCAFeatureTool_SecondaryPCARatio", srpfp.pfochar.pca2ratio); CopyPropertyIfSet(propertiesMap, "LArThreeDPCAFeatureTool_TertiaryPCARatio", srpfp.pfochar.pca3ratio); CopyPropertyIfSet(propertiesMap, "LArThreeDVertexDistanceFeatureTool_VertexDistance", srpfp.pfochar.vtxdist); - CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_HaloTotalRatio", srpfp.pfochar.halototratio); - CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_Concentration", srpfp.pfochar.concentration); - CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_Conicalness", srpfp.pfochar.conicalness); + CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_ICARUS_HaloTotalRatio", srpfp.pfochar.halototratio); + CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_ICARUS_Concentration", srpfp.pfochar.concentration); + CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_ICARUS_Conicalness", srpfp.pfochar.conicalness); } if (t0) { srpfp.t0 = t0->Time() / 1e3; /* ns -> us */ From 25d087663de3450bf7aee11a194385e80e100f10 Mon Sep 17 00:00:00 2001 From: Riccardo Triozzi Date: Thu, 31 Jul 2025 18:38:35 +0200 Subject: [PATCH 2/4] refactored code to allow for configurable BDT tool names --- sbncode/CAFMaker/CAFMakerParams.h | 86 +++++++++++++++++++++++++++++ sbncode/CAFMaker/CAFMaker_module.cc | 17 +++++- sbncode/CAFMaker/FillReco.cxx | 27 ++++----- sbncode/CAFMaker/FillReco.h | 19 ++++++- 4 files changed, 134 insertions(+), 15 deletions(-) diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index d05eb8b9b..d735fb5a1 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -424,6 +424,92 @@ namespace caf 25. }; + struct PFOCharLabels_t { + Atom EndFractionName { + Name("EndFractionName"), + Comment("Provide the tool name for the EndFraction BDT variable."), + "LArThreeDChargeFeatureTool_EndFraction" + }; + + Atom FractionalSpreadName { + Name("FractionalSpreadName"), + Comment("Provide the tool name for the FractionalSpread BDT variable."), + "LArThreeDChargeFeatureTool_FractionalSpread" + }; + + Atom DiffStraightLineMeanName { + Name("DiffStraightLineMeanName"), + Comment("Provide the tool name for the DiffStraightLineMean BDT variable."), + "LArThreeDChargeFeatureTool_DiffStraightLineMean" + }; + + Atom LengthName { + Name("LengthName"), + Comment("Provide the tool name for the Length BDT variable."), + "LArThreeDChargeFeatureTool_Length" + }; + + Atom MaxFitGapLengthName { + Name("MaxFitGapLengthName"), + Comment("Provide the tool name for the MaxFitGapLength BDT variable."), + "LArThreeDChargeFeatureTool_MaxFitGapLength" + }; + + Atom SlidingLinearFitRMSName { + Name("SlidingLinearFitRMSName"), + Comment("Provide the tool name for the SlidingLinearFitRMS BDT variable."), + "LArThreeDChargeFeatureTool_SlidingLinearFitRMS" + }; + + Atom AngleDiffName { + Name("AngleDiffName"), + Comment("Provide the tool name for the AngleDiff BDT variable."), + "LArThreeDChargeFeatureTool_AngleDiff" + }; + + Atom SecondaryPCARatioName { + Name("SecondaryPCARatioName"), + Comment("Provide the tool name for the SecondaryPCARatio BDT variable."), + "LArThreeDChargeFeatureTool_SecondaryPCARatio" + }; + + Atom TertiaryPCARatioName { + Name("TertiaryPCARatioName"), + Comment("Provide the tool name for the TertiaryPCARatio BDT variable."), + "LArThreeDChargeFeatureTool_TertiaryPCARatio" + }; + + Atom VertexDistanceName { + Name("VertexDistanceName"), + Comment("Provide the tool name for the VertexDistance BDT variable."), + "LArThreeDChargeFeatureTool_VertexDistanceName" + }; + + Atom HaloTotalRatioName { + Name("HaloTotalRatioName"), + Comment("Provide the tool name for the HaloTotalRatio BDT variable."), + "LArThreeDChargeFeatureTool_HaloTotalRatioName" + }; + + Atom ConcentrationName { + Name("ConcentrationName"), + Comment("Provide the tool name for the Concentration BDT variable."), + "LArThreeDChargeFeatureTool_Concentration" + + }; + + Atom ConicalnessName { + Name("ConicalnessName"), + Comment("Provide the tool name for the Conicalness BDT variable."), + "LArThreeDChargeFeatureTool_Conicalness" + }; + }; + + Table PFOCharLabels { + Name("PFOCharLabels"), + Comment("Provide tool names for the Pandora track/shower discrimination BDT variables.") + }; + Atom ReferencePMTFromTriggerToBeam { Name("ReferencePMTFromTriggerToBeam"), Comment("Whether to switch the reference time of PMT reco from 'trigger' to 'beam spill' time."), diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 2728b395f..7dbc3adc8 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -2098,7 +2098,22 @@ void CAFMaker::produce(art::Event& evt) noexcept { } const larpandoraobj::PFParticleMetadata *pfpMeta = (fmPFPMeta.at(iPart).empty()) ? NULL : fmPFPMeta.at(iPart).at(0).get(); - FillPFPVars(thisParticle, primary, pfpMeta, thisPFPT0, pfp); + const caf::PFOCharLabelsStruct pfoCharLabels { + fParams.PFOCharLabels().EndFractionName(), + fParams.PFOCharLabels().FractionalSpreadName(), + fParams.PFOCharLabels().DiffStraightLineMeanName(), + fParams.PFOCharLabels().LengthName(), + fParams.PFOCharLabels().MaxFitGapLengthName(), + fParams.PFOCharLabels().SlidingLinearFitRMSName(), + fParams.PFOCharLabels().AngleDiffName(), + fParams.PFOCharLabels().SecondaryPCARatioName(), + fParams.PFOCharLabels().TertiaryPCARatioName(), + fParams.PFOCharLabels().VertexDistanceName(), + fParams.PFOCharLabels().HaloTotalRatioName(), + fParams.PFOCharLabels().ConcentrationName(), + fParams.PFOCharLabels().ConicalnessName() + }; + FillPFPVars(thisParticle, primary, pfpMeta, thisPFPT0, pfp, pfoCharLabels); if (fmCNNScores.isValid()) { const sbn::PFPCNNScore *cnnScores = fmCNNScores.at(iPart).at(0).get(); diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index b3b479695..258a4b6fe 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -895,6 +895,7 @@ namespace caf const larpandoraobj::PFParticleMetadata *pfpMeta, const art::Ptr t0, caf::SRPFP& srpfp, + const PFOCharLabelsStruct& pfoCharLabels, bool allowEmpty) { srpfp.id = particle.Self(); @@ -918,19 +919,19 @@ namespace caf // Pfo Characterisation features srpfp.pfochar.setDefault(); - CopyPropertyIfSet(propertiesMap, "LArThreeDChargeFeatureTool_ICARUS_EndFraction", srpfp.pfochar.chgendfrac); - CopyPropertyIfSet(propertiesMap, "LArThreeDChargeFeatureTool_ICARUS_FractionalSpread", srpfp.pfochar.chgfracspread); - CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_DiffStraightLineMean", srpfp.pfochar.linfitdiff); - CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_Length", srpfp.pfochar.linfitlen); - CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_MaxFitGapLength", srpfp.pfochar.linfitgaplen); - CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_SlidingLinearFitRMS", srpfp.pfochar.linfitrms); - CopyPropertyIfSet(propertiesMap, "LArThreeDOpeningAngleFeatureTool_AngleDiff", srpfp.pfochar.openanglediff); - CopyPropertyIfSet(propertiesMap, "LArThreeDPCAFeatureTool_SecondaryPCARatio", srpfp.pfochar.pca2ratio); - CopyPropertyIfSet(propertiesMap, "LArThreeDPCAFeatureTool_TertiaryPCARatio", srpfp.pfochar.pca3ratio); - CopyPropertyIfSet(propertiesMap, "LArThreeDVertexDistanceFeatureTool_VertexDistance", srpfp.pfochar.vtxdist); - CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_ICARUS_HaloTotalRatio", srpfp.pfochar.halototratio); - CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_ICARUS_Concentration", srpfp.pfochar.concentration); - CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_ICARUS_Conicalness", srpfp.pfochar.conicalness); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.EndFractionName, srpfp.pfochar.chgendfrac); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.FractionalSpreadName, srpfp.pfochar.chgfracspread); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.DiffStraightLineMeanName, srpfp.pfochar.linfitdiff); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.LengthName, srpfp.pfochar.linfitlen); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.MaxFitGapLengthName, srpfp.pfochar.linfitgaplen); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.SlidingLinearFitRMSName, srpfp.pfochar.linfitrms); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.AngleDiffName, srpfp.pfochar.openanglediff); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.SecondaryPCARatioName, srpfp.pfochar.pca2ratio); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.TertiaryPCARatioName, srpfp.pfochar.pca3ratio); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.VertexDistanceName, srpfp.pfochar.vtxdist); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.HaloTotalRatioName, srpfp.pfochar.halototratio); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.ConcentrationName, srpfp.pfochar.concentration); + CopyPropertyIfSet(propertiesMap, pfoCharLabels.ConicalnessName, srpfp.pfochar.conicalness); } if (t0) { srpfp.t0 = t0->Time() / 1e3; /* ns -> us */ diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index c6df1ab39..766d0ab09 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -118,12 +118,29 @@ namespace caf caf::SRHit& srhit, bool allowEmpty = false); + struct PFOCharLabelsStruct { + std::string EndFractionName; + std::string FractionalSpreadName; + std::string DiffStraightLineMeanName; + std::string LengthName; + std::string MaxFitGapLengthName; + std::string SlidingLinearFitRMSName; + std::string AngleDiffName; + std::string SecondaryPCARatioName; + std::string TertiaryPCARatioName; + std::string VertexDistanceName; + std::string HaloTotalRatioName; + std::string ConcentrationName; + std::string ConicalnessName; + }; + void FillPFPVars(const recob::PFParticle &particle, const recob::PFParticle *primary, const larpandoraobj::PFParticleMetadata *pfpMeta, const art::Ptr t0, caf::SRPFP& srpfp, - bool allowEmpty= false); + const PFOCharLabelsStruct& pfoCharLabels, + bool allowEmpty = false); void FillCNNScores(const recob::PFParticle &particle, const sbn::PFPCNNScore *cnnscore, From 33845ea196995a575fdf376bbd19511308e55c20 Mon Sep 17 00:00:00 2001 From: Riccardo Triozzi Date: Fri, 1 Aug 2025 01:01:45 +0200 Subject: [PATCH 3/4] moved changes to fhicl::OptionalTable --- sbncode/CAFMaker/CAFMakerParams.h | 3 ++- sbncode/CAFMaker/CAFMaker_module.cc | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index d735fb5a1..83b15fb8b 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -16,6 +16,7 @@ namespace caf template using Atom = fhicl::Atom; template using Sequence = fhicl::Sequence; template using Table = fhicl::Table; + template using OptionalTable = fhicl::OptionalTable; using Comment = fhicl::Comment; using Name = fhicl::Name; using string = std::string; @@ -505,7 +506,7 @@ namespace caf }; }; - Table PFOCharLabels { + OptionalTable PFOCharLabels { Name("PFOCharLabels"), Comment("Provide tool names for the Pandora track/shower discrimination BDT variables.") }; diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 7dbc3adc8..f1187f917 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -2098,20 +2098,22 @@ void CAFMaker::produce(art::Event& evt) noexcept { } const larpandoraobj::PFParticleMetadata *pfpMeta = (fmPFPMeta.at(iPart).empty()) ? NULL : fmPFPMeta.at(iPart).at(0).get(); + caf::CAFMakerParams::PFOCharLabels_t const& pfoCharParams + = fParams.PFOCharLabels().value_or(caf::CAFMakerParams::PFOCharLabels_t{}); const caf::PFOCharLabelsStruct pfoCharLabels { - fParams.PFOCharLabels().EndFractionName(), - fParams.PFOCharLabels().FractionalSpreadName(), - fParams.PFOCharLabels().DiffStraightLineMeanName(), - fParams.PFOCharLabels().LengthName(), - fParams.PFOCharLabels().MaxFitGapLengthName(), - fParams.PFOCharLabels().SlidingLinearFitRMSName(), - fParams.PFOCharLabels().AngleDiffName(), - fParams.PFOCharLabels().SecondaryPCARatioName(), - fParams.PFOCharLabels().TertiaryPCARatioName(), - fParams.PFOCharLabels().VertexDistanceName(), - fParams.PFOCharLabels().HaloTotalRatioName(), - fParams.PFOCharLabels().ConcentrationName(), - fParams.PFOCharLabels().ConicalnessName() + pfoCharParams.EndFractionName(), + pfoCharParams.FractionalSpreadName(), + pfoCharParams.DiffStraightLineMeanName(), + pfoCharParams.LengthName(), + pfoCharParams.MaxFitGapLengthName(), + pfoCharParams.SlidingLinearFitRMSName(), + pfoCharParams.AngleDiffName(), + pfoCharParams.SecondaryPCARatioName(), + pfoCharParams.TertiaryPCARatioName(), + pfoCharParams.VertexDistanceName(), + pfoCharParams.HaloTotalRatioName(), + pfoCharParams.ConcentrationName(), + pfoCharParams.ConicalnessName() }; FillPFPVars(thisParticle, primary, pfpMeta, thisPFPT0, pfp, pfoCharLabels); From 3b02294e7eec002a0cfc4eb4f0a0901ca62a0136 Mon Sep 17 00:00:00 2001 From: Riccardo Triozzi Date: Wed, 20 Aug 2025 15:41:12 +0200 Subject: [PATCH 4/4] fixed default tool names --- sbncode/CAFMaker/CAFMakerParams.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index 83b15fb8b..25a758770 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -441,68 +441,68 @@ namespace caf Atom DiffStraightLineMeanName { Name("DiffStraightLineMeanName"), Comment("Provide the tool name for the DiffStraightLineMean BDT variable."), - "LArThreeDChargeFeatureTool_DiffStraightLineMean" + "LArThreeDLinearFitFeatureTool_DiffStraightLineMean" }; Atom LengthName { Name("LengthName"), Comment("Provide the tool name for the Length BDT variable."), - "LArThreeDChargeFeatureTool_Length" + "LArThreeDLinearFitFeatureTool_Length" }; Atom MaxFitGapLengthName { Name("MaxFitGapLengthName"), Comment("Provide the tool name for the MaxFitGapLength BDT variable."), - "LArThreeDChargeFeatureTool_MaxFitGapLength" + "LArThreeDLinearFitFeatureTool_MaxFitGapLength" }; Atom SlidingLinearFitRMSName { Name("SlidingLinearFitRMSName"), Comment("Provide the tool name for the SlidingLinearFitRMS BDT variable."), - "LArThreeDChargeFeatureTool_SlidingLinearFitRMS" + "LArThreeDLinearFitFeatureTool_SlidingLinearFitRMS" }; Atom AngleDiffName { Name("AngleDiffName"), Comment("Provide the tool name for the AngleDiff BDT variable."), - "LArThreeDChargeFeatureTool_AngleDiff" + "LArThreeDOpeningAngleFeatureTool_AngleDiff" }; Atom SecondaryPCARatioName { Name("SecondaryPCARatioName"), Comment("Provide the tool name for the SecondaryPCARatio BDT variable."), - "LArThreeDChargeFeatureTool_SecondaryPCARatio" + "LArThreeDPCAFeatureTool_SecondaryPCARatio" }; Atom TertiaryPCARatioName { Name("TertiaryPCARatioName"), Comment("Provide the tool name for the TertiaryPCARatio BDT variable."), - "LArThreeDChargeFeatureTool_TertiaryPCARatio" + "LArThreeDPCAFeatureTool_TertiaryPCARatio" }; Atom VertexDistanceName { Name("VertexDistanceName"), Comment("Provide the tool name for the VertexDistance BDT variable."), - "LArThreeDChargeFeatureTool_VertexDistanceName" + "LArThreeDVertexDistanceFeatureTool_VertexDistance" }; Atom HaloTotalRatioName { Name("HaloTotalRatioName"), Comment("Provide the tool name for the HaloTotalRatio BDT variable."), - "LArThreeDChargeFeatureTool_HaloTotalRatioName" + "LArConeChargeFeatureTool_HaloTotalRatio" }; Atom ConcentrationName { Name("ConcentrationName"), Comment("Provide the tool name for the Concentration BDT variable."), - "LArThreeDChargeFeatureTool_Concentration" + "LArConeChargeFeatureTool_Concentration" }; Atom ConicalnessName { Name("ConicalnessName"), Comment("Provide the tool name for the Conicalness BDT variable."), - "LArThreeDChargeFeatureTool_Conicalness" + "LArConeChargeFeatureTool_Conicalness" }; };