Skip to content

Commit ee878b1

Browse files
committed
add sim energy deposit info and light calo info
1 parent 30569b2 commit ee878b1

5 files changed

Lines changed: 75 additions & 1 deletion

File tree

sbncode/CAFMaker/CAFMakerParams.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,12 @@ namespace caf
465465
"simdrift"
466466
};
467467

468+
Atom<art::InputTag> SimEnergyDepositLabel {
469+
Name("SimEnergyDepositLabel"),
470+
Comment("Label of input sim::SimEnergyDeposit objects."),
471+
art::InputTag("ionandscint", "priorSCE","G4")
472+
};
473+
468474
Atom<bool> FillTrueParticles {
469475
Name("FillTrueParticles"),
470476
Comment("Whether to fill the rec.true_particles branch. The information on true particles"
@@ -616,6 +622,12 @@ namespace caf
616622
Comment("Label of CVN scores."),
617623
"cvn"
618624
};
625+
626+
Atom<string> LightCaloLabel {
627+
Name("LightCaloLabel"),
628+
Comment("Label of light calorimetry producer"),
629+
"lightcalo"
630+
};
619631

620632
};
621633
}

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
#include "lardataobj/RecoBase/MCSFitResult.h"
9898
#include "lardataobj/RecoBase/Cluster.h"
9999
#include "lardataobj/AnalysisBase/MVAOutput.h"
100+
#include "lardataobj/Simulation/SimEnergyDeposit.h"
100101

101102
#include "nusimdata/SimulationBase/MCFlux.h"
102103
#include "nusimdata/SimulationBase/MCTruth.h"
@@ -119,6 +120,7 @@
119120
#include "sbnobj/Common/Reco/CRUMBSResult.h"
120121
#include "sbnobj/Common/Reco/OpT0FinderResult.h"
121122
#include "sbnobj/Common/Reco/CorrectedOpFlashTiming.h"
123+
#include "sbnobj/Common/Reco/LightCalo.h"
122124
#include "sbnobj/SBND/Timing/TimingInfo.hh"
123125
#include "sbnobj/SBND/Timing/FrameShiftInfo.hh"
124126

@@ -1422,6 +1424,15 @@ void CAFMaker::produce(art::Event& evt) noexcept {
14221424
art::fill_ptr_vector(simchannels, simchannel_handle);
14231425
}
14241426

1427+
// get sim energy deposits if they're there
1428+
::art::Handle<std::vector<sim::SimEnergyDeposit>> sed_handle;
1429+
GetByLabelStrict(evt, fParams.SimEnergyDepositLabel().encode(), sed_handle);
1430+
1431+
std::vector<art::Ptr<sim::SimEnergyDeposit>> seds;
1432+
if (sed_handle.isValid()){
1433+
art::fill_ptr_vector(seds, sed_handle);
1434+
}
1435+
14251436
art::Handle<std::vector<simb::MCFlux>> mcflux_handle;
14261437
GetByLabelStrict(evt, std::string("generator"), mcflux_handle);
14271438

@@ -1614,6 +1625,34 @@ void CAFMaker::produce(art::Event& evt) noexcept {
16141625
} // end for fm
16151626
} // end for i (mctruths)
16161627

1628+
1629+
if (!isRealData && sed_handle.isValid()){
1630+
art::ServiceHandle<cheat::ParticleInventoryService> pi_serv;
1631+
1632+
srtruthbranch.dep.reserve(mctruths.size());
1633+
for (size_t n=0; n<mctruths.size();n++){
1634+
SRTrueDeposit init;
1635+
init.electrons = 0;
1636+
init.photons = 0;
1637+
init.energy = 0;
1638+
srtruthbranch.dep.push_back(init);
1639+
}
1640+
1641+
for (size_t n_dep=0; n_dep < seds.size(); n_dep++){
1642+
auto sed = seds[n_dep];
1643+
const auto trackID = sed->TrackID();
1644+
1645+
art::Ptr<simb::MCTruth> mctruth = pi_serv->TrackIdToMCTruth_P(trackID);
1646+
auto it = std::find(mctruths.begin(), mctruths.end(), mctruth);
1647+
if (it == mctruths.end()) continue;
1648+
1649+
auto idx = std::distance(mctruths.begin(), it);
1650+
srtruthbranch.dep.at(idx).energy += sed->Energy()*1e-3; // GeV
1651+
srtruthbranch.dep.at(idx).photons += sed->NumPhotons();
1652+
srtruthbranch.dep.at(idx).electrons += sed->NumElectrons();
1653+
}
1654+
}
1655+
16171656
// get the number of events generated in the gen stage
16181657
unsigned n_gen_evt = 0;
16191658
for (const art::ProcessConfiguration &process: evt.processHistory()) {
@@ -1995,6 +2034,13 @@ void CAFMaker::produce(art::Event& evt) noexcept {
19952034
if (fmCorrectedOpFlash.isValid())
19962035
slcCorrectedOpFlash = fmCorrectedOpFlash.at(0);
19972036

2037+
art::FindOneP<sbn::LightCalo> foLightCalo =
2038+
FindOnePStrict<sbn::LightCalo>(sliceList,evt,
2039+
fParams.LightCaloLabel() + slice_tag_suff);
2040+
const sbn::LightCalo *slcLightCalo = nullptr;
2041+
if (foLightCalo.isValid()) {
2042+
slcLightCalo = foLightCalo.at(0).get();
2043+
}
19982044

19992045
art::FindOneP<lcvn::Result> foCVNResult =
20002046
FindOnePStrict<lcvn::Result>(sliceList, evt,
@@ -2250,6 +2296,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
22502296
FillSliceCRUMBS(slcCRUMBS, recslc);
22512297
FillSliceOpT0Finder(slcOpT0, recslc);
22522298
FillSliceBarycenter(slcHits, slcSpacePoints, recslc);
2299+
FillSliceLightCalo(slcLightCalo, recslc);
22532300
FillTPCPMTBarycenterMatch(barycenterMatch, recslc);
22542301
FillCorrectedOpFlashTiming(slcCorrectedOpFlash, recslc);
22552302
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
@@ -634,6 +634,17 @@ namespace caf
634634
}
635635
}
636636

637+
void FillSliceLightCalo(const sbn::LightCalo *lightcalo,
638+
caf::SRSlice &slice)
639+
{
640+
if (lightcalo != nullptr) {
641+
slice.lightcalo.charge = lightcalo->charge;
642+
slice.lightcalo.light = lightcalo->light;
643+
slice.lightcalo.energy = lightcalo->energy;
644+
slice.lightcalo.bestplane = lightcalo->bestplane;
645+
}
646+
}
647+
637648
void FillSliceBarycenter(const std::vector<art::Ptr<recob::Hit>> &inputHits,
638649
const std::vector<art::Ptr<recob::SpacePoint>> &inputPoints,
639650
caf::SRSlice &slice)

sbncode/CAFMaker/FillReco.h

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

@@ -108,6 +108,9 @@ namespace caf
108108
void FillSliceOpT0Finder(const std::vector<art::Ptr<sbn::OpT0Finder>> &opt0_v,
109109
caf::SRSlice &slice);
110110

111+
void FillSliceLightCalo(const sbn::LightCalo *lightcalo,
112+
caf::SRSlice& slice);
113+
111114
void FillSliceBarycenter(const std::vector<art::Ptr<recob::Hit>> &inputHits,
112115
const std::vector<art::Ptr<recob::SpacePoint>> &inputPoints,
113116
caf::SRSlice &slice);

0 commit comments

Comments
 (0)