Skip to content

Commit b644a6b

Browse files
committed
Merge branch 'feature/lynnt_lightcalorimetry'
2 parents 673c34e + e7948df commit b644a6b

5 files changed

Lines changed: 65 additions & 1 deletion

File tree

sbncode/CAFMaker/CAFMakerParams.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,12 @@ namespace caf
483483
"simdrift"
484484
};
485485

486+
Atom<art::InputTag> SimEnergyDepositLabel {
487+
Name("SimEnergyDepositLabel"),
488+
Comment("Label of input sim::SimEnergyDeposit objects."),
489+
art::InputTag("ionandscint", "priorSCE","G4")
490+
};
491+
486492
Atom<bool> FillTrueParticles {
487493
Name("FillTrueParticles"),
488494
Comment("Whether to fill the rec.true_particles branch. The information on true particles"
@@ -634,6 +640,12 @@ namespace caf
634640
Comment("Label of CVN scores."),
635641
"cvn"
636642
};
643+
644+
Atom<string> LightCaloLabel {
645+
Name("LightCaloLabel"),
646+
Comment("Label of light calorimetry producer"),
647+
"lightcalo"
648+
};
637649

638650
Atom<std::string> fBlipTag {
639651
Name("BlipTag"),

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
#include "lardataobj/RecoBase/MCSFitResult.h"
9999
#include "lardataobj/RecoBase/Cluster.h"
100100
#include "lardataobj/AnalysisBase/MVAOutput.h"
101+
#include "lardataobj/Simulation/SimEnergyDeposit.h"
101102

102103
#include "nusimdata/SimulationBase/MCFlux.h"
103104
#include "nusimdata/SimulationBase/MCTruth.h"
@@ -121,6 +122,7 @@
121122
#include "sbnobj/Common/Reco/OpT0FinderResult.h"
122123
#include "sbnobj/SBND/CRT/CRTVeto.hh"
123124
#include "sbnobj/Common/Reco/CorrectedOpFlashTiming.h"
125+
#include "sbnobj/Common/Reco/LightCalo.h"
124126
#include "sbnobj/SBND/Timing/TimingInfo.hh"
125127
#include "sbnobj/SBND/Timing/FrameShiftInfo.hh"
126128

@@ -1650,6 +1652,36 @@ void CAFMaker::produce(art::Event& evt) noexcept {
16501652
} // end for fm
16511653
} // end for i (mctruths)
16521654

1655+
// get sim energy deposits if they're there
1656+
::art::Handle<std::vector<sim::SimEnergyDeposit>> sed_handle;
1657+
GetByLabelStrict(evt, fParams.SimEnergyDepositLabel().encode(), sed_handle);
1658+
1659+
if (!isRealData && sed_handle.isValid()){
1660+
art::ServiceHandle<cheat::ParticleInventoryService> pi_serv;
1661+
1662+
srtruthbranch.dep.reserve(mctruths.size());
1663+
for (size_t n=0; n<mctruths.size();n++){
1664+
SRTrueDeposit init;
1665+
init.electrons = 0;
1666+
init.photons = 0;
1667+
init.energy = 0;
1668+
srtruthbranch.dep.push_back(init);
1669+
}
1670+
1671+
for (sim::SimEnergyDeposit const& sed: *sed_handle){
1672+
const auto trackID = sed.TrackID();
1673+
1674+
art::Ptr<simb::MCTruth> mctruth = pi_serv->TrackIdToMCTruth_P(trackID);
1675+
auto it = std::find(mctruths.begin(), mctruths.end(), mctruth);
1676+
if (it == mctruths.end()) continue;
1677+
1678+
auto idx = std::distance(mctruths.begin(), it);
1679+
srtruthbranch.dep.at(idx).energy += sed.Energy()*1e-3; // GeV
1680+
srtruthbranch.dep.at(idx).photons += sed.NumPhotons();
1681+
srtruthbranch.dep.at(idx).electrons += sed.NumElectrons();
1682+
}
1683+
}
1684+
16531685
// get the number of events generated in the gen stage
16541686
unsigned n_gen_evt = 0;
16551687
for (const art::ProcessConfiguration &process: evt.processHistory()) {
@@ -2072,6 +2104,10 @@ void CAFMaker::produce(art::Event& evt) noexcept {
20722104
if (fmCorrectedOpFlash.isValid())
20732105
slcCorrectedOpFlash = fmCorrectedOpFlash.at(0);
20742106

2107+
art::FindOneP<sbn::LightCalo> foLightCalo =
2108+
FindOnePStrict<sbn::LightCalo>(sliceList,evt,
2109+
fParams.LightCaloLabel() + slice_tag_suff);
2110+
const sbn::LightCalo *slcLightCalo = foLightCalo.isValid()? foLightCalo.at(0).get() : nullptr;
20752111

20762112
art::FindOneP<lcvn::Result> foCVNResult =
20772113
FindOnePStrict<lcvn::Result>(sliceList, evt,
@@ -2334,6 +2370,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
23342370
FillSliceCRUMBS(slcCRUMBS, recslc);
23352371
FillSliceOpT0Finder(slcOpT0, recslc);
23362372
FillSliceBarycenter(slcHits, slcSpacePoints, recslc);
2373+
FillSliceLightCalo(slcLightCalo, recslc);
23372374
FillTPCPMTBarycenterMatch(barycenterMatch, recslc);
23382375
FillCorrectedOpFlashTiming(slcCorrectedOpFlash, recslc);
23392376
FillCVNScores(cvnResult, recslc);

sbncode/CAFMaker/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ art_make_library( LIBRARY_NAME sbncode_CAFMaker
2525
caf_RecoUtils
2626
lardataobj::AnalysisBase
2727
lardataobj::RecoBase
28+
lardataobj::Simulation
2829
larrecodnn::CVN_func
2930
larcorealg::Geometry
3031
larcore::Geometry_Geometry_service

sbncode/CAFMaker/FillReco.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,17 @@ namespace caf
699699
}
700700
}
701701

702+
void FillSliceLightCalo(const sbn::LightCalo *lightcalo,
703+
caf::SRSlice &slice)
704+
{
705+
if (lightcalo != nullptr) {
706+
slice.lightcalo.charge = lightcalo->charge;
707+
slice.lightcalo.light = lightcalo->light;
708+
slice.lightcalo.energy = lightcalo->energy;
709+
slice.lightcalo.bestplane = lightcalo->bestplane;
710+
}
711+
}
712+
702713
void FillSliceBarycenter(const std::vector<art::Ptr<recob::Hit>> &inputHits,
703714
const std::vector<art::Ptr<recob::SpacePoint>> &inputPoints,
704715
caf::SRSlice &slice)

sbncode/CAFMaker/FillReco.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh"
5050
#include "sbnobj/SBND/Timing/TimingInfo.hh"
5151
#include "sbnobj/SBND/Timing/FrameShiftInfo.hh"
52-
52+
#include "sbnobj/Common/Reco/LightCalo.h"
5353
#include "nusimdata/SimulationBase/MCParticle.h"
5454
#include "nusimdata/SimulationBase/MCTruth.h"
5555

@@ -111,6 +111,9 @@ namespace caf
111111
void FillSliceOpT0Finder(const std::vector<art::Ptr<sbn::OpT0Finder>> &opt0_v,
112112
caf::SRSlice &slice);
113113

114+
void FillSliceLightCalo(const sbn::LightCalo *lightcalo,
115+
caf::SRSlice& slice);
116+
114117
void FillSliceBarycenter(const std::vector<art::Ptr<recob::Hit>> &inputHits,
115118
const std::vector<art::Ptr<recob::SpacePoint>> &inputPoints,
116119
caf::SRSlice &slice);

0 commit comments

Comments
 (0)