diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index 0250e740f..7bc433426 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -483,6 +483,12 @@ namespace caf "simdrift" }; + Atom SimEnergyDepositLabel { + Name("SimEnergyDepositLabel"), + Comment("Label of input sim::SimEnergyDeposit objects."), + art::InputTag("ionandscint", "priorSCE","G4") + }; + Atom FillTrueParticles { Name("FillTrueParticles"), Comment("Whether to fill the rec.true_particles branch. The information on true particles" @@ -634,6 +640,12 @@ namespace caf Comment("Label of CVN scores."), "cvn" }; + + Atom LightCaloLabel { + Name("LightCaloLabel"), + Comment("Label of light calorimetry producer"), + "lightcalo" + }; }; } diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 9f2c01590..6e9f4caca 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -97,6 +97,7 @@ #include "lardataobj/RecoBase/MCSFitResult.h" #include "lardataobj/RecoBase/Cluster.h" #include "lardataobj/AnalysisBase/MVAOutput.h" +#include "lardataobj/Simulation/SimEnergyDeposit.h" #include "nusimdata/SimulationBase/MCFlux.h" #include "nusimdata/SimulationBase/MCTruth.h" @@ -120,6 +121,7 @@ #include "sbnobj/Common/Reco/OpT0FinderResult.h" #include "sbnobj/SBND/CRT/CRTVeto.hh" #include "sbnobj/Common/Reco/CorrectedOpFlashTiming.h" +#include "sbnobj/Common/Reco/LightCalo.h" #include "sbnobj/SBND/Timing/TimingInfo.hh" #include "sbnobj/SBND/Timing/FrameShiftInfo.hh" @@ -1637,6 +1639,36 @@ void CAFMaker::produce(art::Event& evt) noexcept { } // end for fm } // end for i (mctruths) + // get sim energy deposits if they're there + ::art::Handle> sed_handle; + GetByLabelStrict(evt, fParams.SimEnergyDepositLabel().encode(), sed_handle); + + if (!isRealData && sed_handle.isValid()){ + art::ServiceHandle pi_serv; + + srtruthbranch.dep.reserve(mctruths.size()); + for (size_t n=0; n mctruth = pi_serv->TrackIdToMCTruth_P(trackID); + auto it = std::find(mctruths.begin(), mctruths.end(), mctruth); + if (it == mctruths.end()) continue; + + auto idx = std::distance(mctruths.begin(), it); + srtruthbranch.dep.at(idx).energy += sed.Energy()*1e-3; // GeV + srtruthbranch.dep.at(idx).photons += sed.NumPhotons(); + srtruthbranch.dep.at(idx).electrons += sed.NumElectrons(); + } + } + // get the number of events generated in the gen stage unsigned n_gen_evt = 0; for (const art::ProcessConfiguration &process: evt.processHistory()) { @@ -2049,6 +2081,10 @@ void CAFMaker::produce(art::Event& evt) noexcept { if (fmCorrectedOpFlash.isValid()) slcCorrectedOpFlash = fmCorrectedOpFlash.at(0); + art::FindOneP foLightCalo = + FindOnePStrict(sliceList,evt, + fParams.LightCaloLabel() + slice_tag_suff); + const sbn::LightCalo *slcLightCalo = foLightCalo.isValid()? foLightCalo.at(0).get() : nullptr; art::FindOneP foCVNResult = FindOnePStrict(sliceList, evt, @@ -2308,6 +2344,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { FillSliceCRUMBS(slcCRUMBS, recslc); FillSliceOpT0Finder(slcOpT0, recslc); FillSliceBarycenter(slcHits, slcSpacePoints, recslc); + FillSliceLightCalo(slcLightCalo, recslc); FillTPCPMTBarycenterMatch(barycenterMatch, recslc); FillCorrectedOpFlashTiming(slcCorrectedOpFlash, recslc); FillCVNScores(cvnResult, recslc); diff --git a/sbncode/CAFMaker/CMakeLists.txt b/sbncode/CAFMaker/CMakeLists.txt index 5dd4f2a8f..b5a9b342b 100644 --- a/sbncode/CAFMaker/CMakeLists.txt +++ b/sbncode/CAFMaker/CMakeLists.txt @@ -25,6 +25,7 @@ art_make_library( LIBRARY_NAME sbncode_CAFMaker caf_RecoUtils lardataobj::AnalysisBase lardataobj::RecoBase + lardataobj::Simulation larrecodnn::CVN_func larcorealg::Geometry larcore::Geometry_Geometry_service diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 46396a2c1..2bb279b87 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -693,6 +693,17 @@ namespace caf } } + void FillSliceLightCalo(const sbn::LightCalo *lightcalo, + caf::SRSlice &slice) + { + if (lightcalo != nullptr) { + slice.lightcalo.charge = lightcalo->charge; + slice.lightcalo.light = lightcalo->light; + slice.lightcalo.energy = lightcalo->energy; + slice.lightcalo.bestplane = lightcalo->bestplane; + } + } + void FillSliceBarycenter(const std::vector> &inputHits, const std::vector> &inputPoints, caf::SRSlice &slice) diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index 46704181a..6401aa01d 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -48,7 +48,7 @@ #include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh" #include "sbnobj/SBND/Timing/TimingInfo.hh" #include "sbnobj/SBND/Timing/FrameShiftInfo.hh" - +#include "sbnobj/Common/Reco/LightCalo.h" #include "nusimdata/SimulationBase/MCParticle.h" #include "nusimdata/SimulationBase/MCTruth.h" @@ -110,6 +110,9 @@ namespace caf void FillSliceOpT0Finder(const std::vector> &opt0_v, caf::SRSlice &slice); + void FillSliceLightCalo(const sbn::LightCalo *lightcalo, + caf::SRSlice& slice); + void FillSliceBarycenter(const std::vector> &inputHits, const std::vector> &inputPoints, caf::SRSlice &slice);