17 #include "art/Framework/Core/EDProducer.h"
18 #include "art/Framework/Core/ModuleMacros.h"
19 #include "art/Framework/Principal/Event.h"
20 #include "art/Framework/Principal/Handle.h"
21 #include "art/Framework/Services/Registry/ServiceHandle.h"
22 #include "fhiclcpp/ParameterSet.h"
37 class TrackCalorimetry;
54 void produce(art::Event&
e)
override;
64 , fTrackModuleLabel(
p.get<std::string>(
"TrackModuleLabel"))
65 , fHitModuleLabel(
p.get<std::string>(
"HitModuleLabel"))
66 , fTrackCaloAlg(
p.get<fhicl::ParameterSet>(
"TrackCalorimetryAlg"))
68 fTrackModuleLabel =
p.get<std::string>(
"TrackModuleLabel");
69 fHitModuleLabel =
p.get<std::string>(
"HitModuleLabel");
71 produces<std::vector<anab::Calorimetry>>();
72 produces<art::Assns<recob::Track, anab::Calorimetry>>();
79 art::Handle<std::vector<recob::Track>> trackHandle;
80 e.getByLabel(fTrackModuleLabel, trackHandle);
81 std::vector<recob::Track>
const& trackVector(*trackHandle);
84 art::Handle<std::vector<recob::Hit>> hitHandle;
85 e.getByLabel(fHitModuleLabel, hitHandle);
86 std::vector<recob::Hit>
const& hitVector(*hitHandle);
89 art::Handle<art::Assns<recob::Track, recob::Hit>> assnTrackHitHandle;
90 e.getByLabel(fTrackModuleLabel, assnTrackHitHandle);
91 std::vector<std::vector<size_t>> hit_indices_per_track =
95 std::unique_ptr<std::vector<anab::Calorimetry>> caloPtr(
new std::vector<anab::Calorimetry>);
96 std::vector<anab::Calorimetry>& caloVector(*caloPtr);
101 std::vector<size_t> assnTrackCaloVector;
102 std::unique_ptr<art::Assns<recob::Track, anab::Calorimetry>> assnTrackCaloPtr(
103 new art::Assns<recob::Track, anab::Calorimetry>);
105 auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
106 auto const det_prop =
107 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e, clock_data);
108 fTrackCaloAlg.ExtractCalorimetry(
113 hit_indices_per_track,
116 lar::extractProviders<geo::Geometry, detinfo::LArPropertiesService>());
119 for (
size_t calo_iter = 0; calo_iter < assnTrackCaloVector.size(); calo_iter++) {
120 if (assnTrackCaloVector[calo_iter] == std::numeric_limits<size_t>::max())
continue;
121 art::Ptr<recob::Track> trk_ptr(trackHandle, assnTrackCaloVector[calo_iter]);
125 e.put(std::move(caloPtr));
126 e.put(std::move(assnTrackCaloPtr));
Utilities to manage ProviderPack objects with art.
std::string fHitModuleLabel
void produce(art::Event &e) override
TrackCalorimetry(fhicl::ParameterSet const &p)
process_name can override from command line with o or output calo
Provides recob::Track data product.
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
TrackCalorimetryAlg fTrackCaloAlg
std::string fTrackModuleLabel
art framework interface to geometry description
TrackCalorimetry & operator=(TrackCalorimetry const &)=delete