LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TrackCalorimetry_module.cc
Go to the documentation of this file.
1 // Class: TrackCalorimetry
3 // Module Type: producer
4 // File: TrackCalorimetry_module.cc
5 //
6 // Title: Track Calorimetry Algorithim Class
7 // Author: Wes Ketchum (wketchum@lanl.gov), based on code the Calorimetry_module
8 //
9 // Description: Algorithm that produces a calorimetry object given a track
10 // Input: recob::Track, Assn<recob::Spacepoint,recob::Track>, Assn<recob::Hit,recob::Track>
11 // Output: anab::Calorimetry, (and Assn<anab::Calorimetry,recob::Track>)
12 //
13 // Generated at Tue Oct 21 15:54:15 2014 by Wesley Ketchum using artmod
14 // from cetpkgsupport v1_07_01.
16 
22 #include "fhiclcpp/ParameterSet.h"
23 
24 #include <memory>
25 
26 #include "TrackCalorimetryAlg.h"
31 #include "lardata/DetectorInfoServices/ServicePack.h" // lar::extractProviders()
35 
36 namespace calo {
37  class TrackCalorimetry;
38 }
39 
41 public:
42  explicit TrackCalorimetry(fhicl::ParameterSet const& p);
43  // The destructor generated by the compiler is fine for classes
44  // without bare pointers or other resource use.
45 
46  // Plugins should not be copied or assigned.
47  TrackCalorimetry(TrackCalorimetry const&) = delete;
51 
52 private:
53  // Required functions.
54  void produce(art::Event& e) override;
55 
56  std::string fTrackModuleLabel;
57  std::string fHitModuleLabel;
58 
60 };
61 
63  : EDProducer{p}
64  , fTrackModuleLabel(p.get<std::string>("TrackModuleLabel"))
65  , fHitModuleLabel(p.get<std::string>("HitModuleLabel"))
66  , fTrackCaloAlg(p.get<fhicl::ParameterSet>("TrackCalorimetryAlg"))
67 {
68  fTrackModuleLabel = p.get<std::string>("TrackModuleLabel");
69  fHitModuleLabel = p.get<std::string>("HitModuleLabel");
70 
71  produces<std::vector<anab::Calorimetry>>();
72  produces<art::Assns<recob::Track, anab::Calorimetry>>();
73 }
74 
76 {
77 
79  e.getByLabel(fTrackModuleLabel, trackHandle);
80  std::vector<recob::Track> const& trackVector(*trackHandle);
81 
82  // Get Hits from event.
84  e.getByLabel(fHitModuleLabel, hitHandle);
85  std::vector<recob::Hit> const& hitVector(*hitHandle);
86 
87  // Get track<-->hit associations
89  e.getByLabel(fTrackModuleLabel, assnTrackHitHandle);
90  std::vector<std::vector<size_t>> hit_indices_per_track =
91  util::GetAssociatedVectorManyI(assnTrackHitHandle, trackHandle);
92 
93  // Make the container for the calo product to put onto the event.
94  std::unique_ptr<std::vector<anab::Calorimetry>> caloPtr(new std::vector<anab::Calorimetry>);
95  std::vector<anab::Calorimetry>& caloVector(*caloPtr);
96 
97  // Make a container for the track<-->calo associations.
98  // One entry per track, with entry equal to index in calorimetry collection of
99  // associated object.
100  std::vector<size_t> assnTrackCaloVector;
101  std::unique_ptr<art::Assns<recob::Track, anab::Calorimetry>> assnTrackCaloPtr(
103 
104  auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
105  auto const det_prop =
108  clock_data,
109  det_prop,
110  trackVector,
111  hitVector,
112  hit_indices_per_track,
113  caloVector,
114  assnTrackCaloVector,
115  lar::extractProviders<geo::Geometry, detinfo::LArPropertiesService>());
116 
117  //Make the associations for ART
118  for (size_t calo_iter = 0; calo_iter < assnTrackCaloVector.size(); calo_iter++) {
119  if (assnTrackCaloVector[calo_iter] == std::numeric_limits<size_t>::max()) continue;
120  art::Ptr<recob::Track> trk_ptr(trackHandle, assnTrackCaloVector[calo_iter]);
121  util::CreateAssn(e, caloVector, trk_ptr, *assnTrackCaloPtr, calo_iter);
122  }
123 
124  e.put(std::move(caloPtr));
125  e.put(std::move(assnTrackCaloPtr));
126 }
127 
Utilities to manage ProviderPack objects with art.
void produce(art::Event &e) override
TrackCalorimetry(fhicl::ParameterSet const &p)
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
void ExtractCalorimetry(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, std::vector< recob::Track > const &, std::vector< recob::Hit > const &, std::vector< std::vector< size_t >> const &, std::vector< anab::Calorimetry > &, std::vector< size_t > &, Providers_t providers)
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
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.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
TrackCalorimetryAlg fTrackCaloAlg
Float_t e
Definition: plot.C:35
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U >> h, art::Handle< std::vector< T >> index_p)
art framework interface to geometry description
calorimetry
TrackCalorimetry & operator=(TrackCalorimetry const &)=delete