Skip to content

Commit 202064e

Browse files
committed
clean up intermediate vectors
1 parent 19250d1 commit 202064e

1 file changed

Lines changed: 9 additions & 19 deletions

File tree

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,15 +1445,6 @@ void CAFMaker::produce(art::Event& evt) noexcept {
14451445
art::fill_ptr_vector(simchannels, simchannel_handle);
14461446
}
14471447

1448-
// get sim energy deposits if they're there
1449-
::art::Handle<std::vector<sim::SimEnergyDeposit>> sed_handle;
1450-
GetByLabelStrict(evt, fParams.SimEnergyDepositLabel().encode(), sed_handle);
1451-
1452-
std::vector<art::Ptr<sim::SimEnergyDeposit>> seds;
1453-
if (sed_handle.isValid()){
1454-
art::fill_ptr_vector(seds, sed_handle);
1455-
}
1456-
14571448
art::Handle<std::vector<simb::MCFlux>> mcflux_handle;
14581449
GetByLabelStrict(evt, std::string("generator"), mcflux_handle);
14591450

@@ -1648,6 +1639,9 @@ void CAFMaker::produce(art::Event& evt) noexcept {
16481639
} // end for fm
16491640
} // end for i (mctruths)
16501641

1642+
// get sim energy deposits if they're there
1643+
::art::Handle<std::vector<sim::SimEnergyDeposit>> sed_handle;
1644+
GetByLabelStrict(evt, fParams.SimEnergyDepositLabel().encode(), sed_handle);
16511645

16521646
if (!isRealData && sed_handle.isValid()){
16531647
art::ServiceHandle<cheat::ParticleInventoryService> pi_serv;
@@ -1661,18 +1655,17 @@ void CAFMaker::produce(art::Event& evt) noexcept {
16611655
srtruthbranch.dep.push_back(init);
16621656
}
16631657

1664-
for (size_t n_dep=0; n_dep < seds.size(); n_dep++){
1665-
auto sed = seds[n_dep];
1666-
const auto trackID = sed->TrackID();
1658+
for (sim::SimEnergyDeposit const& sed: *sed_handle){
1659+
const auto trackID = sed.TrackID();
16671660

16681661
art::Ptr<simb::MCTruth> mctruth = pi_serv->TrackIdToMCTruth_P(trackID);
16691662
auto it = std::find(mctruths.begin(), mctruths.end(), mctruth);
16701663
if (it == mctruths.end()) continue;
16711664

16721665
auto idx = std::distance(mctruths.begin(), it);
1673-
srtruthbranch.dep.at(idx).energy += sed->Energy()*1e-3; // GeV
1674-
srtruthbranch.dep.at(idx).photons += sed->NumPhotons();
1675-
srtruthbranch.dep.at(idx).electrons += sed->NumElectrons();
1666+
srtruthbranch.dep.at(idx).energy += sed.Energy()*1e-3; // GeV
1667+
srtruthbranch.dep.at(idx).photons += sed.NumPhotons();
1668+
srtruthbranch.dep.at(idx).electrons += sed.NumElectrons();
16761669
}
16771670
}
16781671

@@ -2091,10 +2084,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
20912084
art::FindOneP<sbn::LightCalo> foLightCalo =
20922085
FindOnePStrict<sbn::LightCalo>(sliceList,evt,
20932086
fParams.LightCaloLabel() + slice_tag_suff);
2094-
const sbn::LightCalo *slcLightCalo = nullptr;
2095-
if (foLightCalo.isValid()) {
2096-
slcLightCalo = foLightCalo.at(0).get();
2097-
}
2087+
const sbn::LightCalo *slcLightCalo = foLightCalo.isValid()? foLightCalo.at(0).get() : nullptr;
20982088

20992089
art::FindOneP<lcvn::Result> foCVNResult =
21002090
FindOnePStrict<lcvn::Result>(sliceList, evt,

0 commit comments

Comments
 (0)