TrackCalorimetry_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // 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.
15 ////////////////////////////////////////////////////////////////////////
16 
21 #include "fhiclcpp/ParameterSet.h"
22 
23 #include <memory>
24 
25 #include "TrackCalorimetryAlg.h"
30 #include "lardata/DetectorInfoServices/ServicePack.h" // lar::extractProviders()
34 
35 namespace calo {
36  class TrackCalorimetry;
37 }
38 
40 public:
41  explicit TrackCalorimetry(fhicl::ParameterSet const& p);
42  // The destructor generated by the compiler is fine for classes
43  // without bare pointers or other resource use.
44 
45  // Plugins should not be copied or assigned.
46  TrackCalorimetry(TrackCalorimetry const&) = delete;
50 
51 private:
52  // Required functions.
53  void produce(art::Event& e) override;
54 
57 
59 };
60 
62  : EDProducer{p}
63  , fTrackModuleLabel(p.get<std::string>("TrackModuleLabel"))
64  , fHitModuleLabel(p.get<std::string>("HitModuleLabel"))
65  , fTrackCaloAlg(p.get<fhicl::ParameterSet>("TrackCalorimetryAlg"))
66 {
67  fTrackModuleLabel = p.get<std::string>("TrackModuleLabel");
68  fHitModuleLabel = p.get<std::string>("HitModuleLabel");
69 
70  produces<std::vector<anab::Calorimetry>>();
71  produces<art::Assns<recob::Track, anab::Calorimetry>>();
72 }
73 
74 void
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 
void produce(art::Event &e) override
TrackCalorimetry(fhicl::ParameterSet const &p)
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
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)
art framework interface to geometry description
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
static int max(int a, int b)
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
Provides recob::Track data product.
TrackCalorimetryAlg fTrackCaloAlg
calorimetry
TrackCalorimetry & operator=(TrackCalorimetry const &)=delete