LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 
24 #include "fhiclcpp/ParameterSet.h"
26 
27 #include <memory>
28 
33 #include "lardata/DetectorInfoServices/ServicePack.h" // lar::extractProviders()
34 #include "TrackCalorimetryAlg.h"
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;
49  TrackCalorimetry & operator = (TrackCalorimetry const &) = delete;
51 
52  // Required functions.
53  void produce(art::Event & e) override;
54 
55  // Selected optional functions.
56  void reconfigure(fhicl::ParameterSet const & p) ;
57 
58 private:
59 
60  std::string fTrackModuleLabel;
61  std::string fHitModuleLabel;
62 
64 
65 };
66 
68  fTrackModuleLabel(p.get<std::string>("TrackModuleLabel")),
69  fHitModuleLabel(p.get<std::string>("HitModuleLabel")),
70  fTrackCaloAlg(p.get<fhicl::ParameterSet>("TrackCalorimetryAlg"))
71 {
72  this->reconfigure(p);
73 
74  produces< std::vector<anab::Calorimetry> >();
75  produces< art::Assns<recob::Track, anab::Calorimetry> >();
76 }
77 
79 {
80  fTrackModuleLabel = p.get<std::string>("TrackModuleLabel");
81  fHitModuleLabel = p.get<std::string>("HitModuleLabel");
82 
83  fTrackCaloAlg.reconfigure(p.get<fhicl::ParameterSet>("TrackCalorimetryAlg"));
84 }
85 
87 {
88 
90  e.getByLabel(fTrackModuleLabel,trackHandle);
91  std::vector<recob::Track> const& trackVector(*trackHandle);
92 
93  //Get Hits from event.
95  e.getByLabel(fHitModuleLabel, hitHandle);
96  std::vector<recob::Hit> const& hitVector(*hitHandle);
97 
98  //Get track<-->hit associations
100  e.getByLabel(fTrackModuleLabel,assnTrackHitHandle);
101  std::vector< std::vector<size_t> >
102  hit_indices_per_track = util::GetAssociatedVectorManyI(assnTrackHitHandle,
103  trackHandle);
104 
105  //Make the container for the calo product to put onto the event.
106  std::unique_ptr< std::vector<anab::Calorimetry> > caloPtr(new std::vector<anab::Calorimetry>);
107  std::vector<anab::Calorimetry> & caloVector(*caloPtr);
108 
109  //Make a container for the track<-->calo associations.
110  //One entry per track, with entry equal to index in calorimetry collection of associated object.
111  std::vector<size_t> assnTrackCaloVector;
112  std::unique_ptr< art::Assns<recob::Track,anab::Calorimetry> > assnTrackCaloPtr(new art::Assns<recob::Track,anab::Calorimetry>);
113 
114  fTrackCaloAlg.ExtractCalorimetry(trackVector,
115  hitVector,hit_indices_per_track,
116  caloVector,assnTrackCaloVector,
119  );
120 
121  //Make the associations for ART
122  for(size_t calo_iter=0; calo_iter<assnTrackCaloVector.size(); calo_iter++){
123  if(assnTrackCaloVector[calo_iter]==std::numeric_limits<size_t>::max()) continue;
124  art::Ptr<recob::Track> trk_ptr(trackHandle,assnTrackCaloVector[calo_iter]);
125  util::CreateAssn(*this, e, caloVector, trk_ptr, *assnTrackCaloPtr, calo_iter);
126  }
127 
128  e.put(std::move(caloPtr));
129  e.put(std::move(assnTrackCaloPtr));
130 
131 }
132 
Utilities to manage ProviderPack objects with art.
ProviderPackFromServices< Services... > extractProviders()
Returns a provider pack with providers from specified services.
Definition: ServicePack.h:54
void produce(art::Event &e) override
TrackCalorimetry(fhicl::ParameterSet const &p)
STL namespace.
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Int_t max
Definition: plot.C:27
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
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.
The geometry of one entire detector, as served by art.
Definition: Geometry.h:110
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::vector< std::vector< size_t > > GetAssociatedVectorManyI(art::Handle< art::Assns< T, U > > h, art::Handle< std::vector< T > > index_p)
void reconfigure(fhicl::ParameterSet const &p)
void reconfigure(fhicl::ParameterSet const &p)
TrackCalorimetryAlg fTrackCaloAlg
void ExtractCalorimetry(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)
Float_t e
Definition: plot.C:34
art framework interface to geometry description
calorimetry
TrackCalorimetry & operator=(TrackCalorimetry const &)=delete