Cannot get hit handle
Dear LArSoft experts,
I am getting a strange error when I run an analyzer on the attached art file:
%MSG-s ArtException: PostEndJob 22-Aug-2019 14:37:10 CDT ModuleEndJob cet::exception caught in art ---- OtherArt BEGIN ---- EventProcessorFailure BEGIN EventProcessor: an exception occurred during current event processing ---- EventProcessorFailure BEGIN EndPathExecutor: an exception occurred during current event processing ---- ScheduleExecutionFailure BEGIN Path: ProcessingStopped. ---- LogicError BEGIN Product retrieval via Handle<T> succeeded for product: Branch Type = Event Process Name = Reco ModuleLabel = trajcluster Product ID = 1982930578 Class Name = std::vector<recob::Hit> Friendly Class Name = recob::Hits Product Instance Name = but an attempt to interpret it as an object of type 'std::vector<recob::Hit, std::allocator<recob::Hit> >' failed. cet::exception going through module NeutrinoTrackingEff/pmtrajfittceff run: 20000001 subRun: 0 event: 21 ---- LogicError END Exception going through path end_path ---- ScheduleExecutionFailure END ---- EventProcessorFailure END ---- EventProcessorFailure END ---- OtherArt END %MSG
The command to reproduce this error is:
lar -c standard_ana_dune10kt_1x2x6.fcl prodgenie_nu_dune10kt_1x2x6_detsim_072_reco.root
The analyzer module is NeutrinoTrackingEff_module.cc in larreco. Here are the offending lines:
std::vector<art::Ptr<recob::Hit>> tmp_all_trackHits = track_hits.at(0); std::vector<art::Ptr<recob::Hit>> all_hits; art::Handle<std::vector<recob::Hit>> hithandle; if(event.get(tmp_all_trackHits.id(), hithandle)) art::fill_ptr_vector(all_hits, hithandle);
The exception is thrown on the last line.
Any help/suggestion on solving this problem is highly appreciated.
#4 Updated by Kyle Knoepfel 6 months ago
- % Done changed from 0 to 100
- Status changed from Assigned to Resolved
- Tracker changed from Support to Bug
The problem is understood. The code referenced above uses the
Event::get(ProductID) interface, which will only return the product successfully if the data product has already been read into memory. This is in contrast to
Event::getByLabel, which will read the product off disk if it has not already been read. In this particular workflow, the product in question has not been read off disk, so the
Event::get fails. The art documentation will be updated to better describe the behavior.
The solution is to use
art::Handle<std::vector<recob::Hit>> hithandle; auto const pd = event.getProductDescription(tmp_all_trackHits.id()); if (pd && event.getByLabel(pd->inputTag(), hithandle)) ...
I have pushed this fix to
larreco's HEAD of