LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TCShower_module.cc
Go to the documentation of this file.
1 // Class: TCShower
3 // Plugin Type: producer (art v2_11_02)
4 // File: TCShower_module.cc
5 //
6 // Generated at Fri Jun 8 14:55:04 2018 by Rory Fitzpatrick using cetskelgen
7 // from cetlib version v3_03_01.
8 //
9 // Contact: roryfitz@umich.edu
10 //
11 // module produces showers by selecting tracks surround by many
12 // showerLike trajectories as defined by trajcluster with negative
13 // cluster IDs
15 
24 #include "fhiclcpp/ParameterSet.h"
27 
37 
39 
43 
46 
47 #include "TH1F.h"
48 
49 #include <memory>
50 
51 namespace shower {
52  class TCShower;
53 }
54 
56 public:
57  explicit TCShower(fhicl::ParameterSet const & p);
58 
59  TCShower(TCShower const &) = delete;
60  TCShower(TCShower &&) = delete;
61  TCShower & operator = (TCShower const &) = delete;
62  TCShower & operator = (TCShower &&) = delete;
63 
64  // Required functions.
65  void produce(art::Event& e) override;
66 
67  // Selected optional functions.
68  void beginJob() override;
69 
70 private:
73 
75 
76  std::string fClusterModuleLabel;
77  std::string fTrackModuleLabel;
78  std::string fHitModuleLabel;
79  std::string fSliceModuleLabel;
80  std::string fVertexModuleLabel;
82 
83 };
84 
85 // -----------------------------------------------------
86 
88  fTCAlg(pset.get< fhicl::ParameterSet >("TCAlg") ),
89  fClusterModuleLabel (pset.get< std::string >("ClusterModuleLabel", "trajcluster" ) ),
90  fTrackModuleLabel (pset.get< std::string >("TrackModuleLabel", "trajclusterKalmanTrack" ) ),
91  fHitModuleLabel (pset.get< std::string >("HitModuleLabel", "trajcluster" ) ),
92  fSliceModuleLabel (pset.get< std::string >("SliceModuleLabel", "dbcluster3d" ) ),
93  fVertexModuleLabel (pset.get< std::string >("VertexModuleLabel", "trajcluster" ) ),
94  fCalorimetryModuleLabel (pset.get< std::string >("CalorimetryModuleLabel") ) {
95 
96  produces<std::vector<recob::Shower> >();
97  produces<art::Assns<recob::Shower, recob::Hit> >();
98  produces<art::Assns<recob::Slice, recob::Shower> >();
99 }
100 
101 // -----------------------------------------------------
102 
104  std::unique_ptr<std::vector<recob::Shower> > showers(new std::vector<recob::Shower>);
105  std::unique_ptr<art::Assns<recob::Shower, recob::Hit> > hitShowerAssociations(new art::Assns<recob::Shower, recob::Hit>);
106  std::unique_ptr<art::Assns<recob::Slice, recob::Shower> > sliceShowerAssociations(new art::Assns<recob::Slice, recob::Shower>);
107 
108  // slices
109  art::Handle< std::vector<recob::Slice> > sliceListHandle;
110  std::vector<art::Ptr<recob::Slice> > slicelist;
111  if (evt.getByLabel(fSliceModuleLabel,sliceListHandle))
112  art::fill_ptr_vector(slicelist, sliceListHandle);
113 
114  int foundShower = -1;
115 
116  if (slicelist.size()) { // use slices
117  for (size_t i = 0; i < slicelist.size(); ++i) {
118  std::cout << "---------- slice " << i << " ----------" << std::endl;
119 
120  foundShower = getShowersWithSlices(evt, slicelist[i]);
121 
122  if (foundShower) {
123  std::cout << "FOUND SHOWER " << foundShower << std::endl;
124  std::cout << "shower hits " << fTCAlg.showerHits.size() << std::endl;
125 
127  showers->back().set_id(showers->size()-1);
128 
129  util::CreateAssn(*this, evt, *(showers.get()), fTCAlg.showerHits, *(hitShowerAssociations.get()) );
130  util::CreateAssn(*this, evt, *showers, slicelist[i], *sliceShowerAssociations );
131  }
132 
133  } // loop through slices
134  } // with slices
135  else {
136  foundShower = getShowersWithoutSlices(evt);
137 
138  if (foundShower) {
140  showers->back().set_id(showers->size()-1);
141 
142  util::CreateAssn(*this, evt, *(showers.get()), fTCAlg.showerHits, *(hitShowerAssociations.get()) );
143 
144  }
145 
146  } // no slices
147 
148  evt.put(std::move(showers));
149  evt.put(std::move(hitShowerAssociations));
150  evt.put(std::move(sliceShowerAssociations));
151 
152 } // produce
153 
154 // -----------------------------------------------------
156  art::Handle< std::vector<recob::Hit> > hitListHandle;
157  evt.getByLabel(fHitModuleLabel,hitListHandle);
158 
159  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
160  evt.getByLabel(fClusterModuleLabel,clusterListHandle);
161 
162  art::Handle< std::vector<recob::Track> > trackListHandle;
163  evt.getByLabel(fTrackModuleLabel,trackListHandle);
164 
165  art::Handle< std::vector<recob::Slice> > sliceListHandle;
166  evt.getByLabel(fSliceModuleLabel,sliceListHandle);
167 
169  evt.getByLabel(fVertexModuleLabel,vtxListHandle);
170 
172  evt.getByLabel(fHitModuleLabel,pfpListHandle);
173 
174  art::FindManyP<recob::Hit> hitslice_fm(sliceListHandle, evt, fHitModuleLabel);
175  art::FindManyP<recob::PFParticle> pfpslice_fm(sliceListHandle, evt, fHitModuleLabel);
176  art::FindManyP<recob::Cluster> clsslice_fm(sliceListHandle, evt, fHitModuleLabel);
177  art::FindManyP<recob::Cluster> clspfp_fm(pfpListHandle, evt, fHitModuleLabel);
178  art::FindManyP<recob::Vertex> vtxpfp_fm(pfpListHandle, evt, fVertexModuleLabel);
179  // art::FindManyP<recob::EndPoint2D> vx2cls_fm(clusterListHandle, evt, fClusterModuleLabel);
180 
181  std::vector<art::Ptr<recob::Hit> > hitlist;
182  std::vector<art::Ptr<recob::Cluster> > clusterlist;
183  std::vector<art::Ptr<recob::Vertex> > vertexlist;
184  std::vector<art::Ptr<recob::EndPoint2D> > vx2list;
185 
186  // get all hits with hit-slice association
187  hitlist = hitslice_fm.at(thisslice.key());
188 
189  // get all clusters with cluster-slice association
190  clusterlist = clsslice_fm.at(thisslice.key());
191 
192  std::vector<art::Ptr<recob::PFParticle> > pfplist = pfpslice_fm.at(thisslice.key());
193 
194  for (size_t i = 0; i < pfplist.size(); ++i) {
195  // std::vector<art::Ptr<recob::Track> > thistracklist = trkpfp_fm.at(pfplist[i].key());
196  std::vector<art::Ptr<recob::Vertex> > thisvtxlist = vtxpfp_fm.at(pfplist[i].key());
197  // get all verticies with slice-pfparticle, pfparticle-vertex
198  for (size_t j = 0; j < thisvtxlist.size(); ++j) {
199  vertexlist.push_back(thisvtxlist[j]);
200  } // loop through tracks
201  } // loop through pfparticles
202 
203 
204  // get associations
205  art::FindManyP<recob::Hit> cls_fm(clusterListHandle, evt, fClusterModuleLabel);
206  art::FindManyP<recob::PFParticle> hit_fm(hitListHandle, evt, fHitModuleLabel);
207  art::FindManyP<recob::Cluster> hitcls_fm(hitListHandle, evt, fClusterModuleLabel);
208  art::FindManyP<recob::Track> trkpfp_fm(pfpListHandle, evt, fTrackModuleLabel);
209 
210  art::FindManyP<anab::Calorimetry> fmcal(trackListHandle, evt, fCalorimetryModuleLabel);
211 
212  return fTCAlg.makeShowers(pfplist, vertexlist, clusterlist, hitlist, cls_fm, clspfp_fm, vtxpfp_fm, hit_fm, hitcls_fm, trkpfp_fm, fmcal);
213 
214 }
215 
216 // -----------------------------------------------------
218 
219  // pfparticles
221  std::vector<art::Ptr<recob::PFParticle> > pfplist;
222  if (evt.getByLabel(fHitModuleLabel,pfpListHandle))
223  art::fill_ptr_vector(pfplist, pfpListHandle);
224 
225  art::Handle< std::vector<recob::Hit> > hitListHandle;
226  std::vector<art::Ptr<recob::Hit> > hitlist;
227  if (evt.getByLabel(fHitModuleLabel,hitListHandle))
228  art::fill_ptr_vector(hitlist, hitListHandle);
229 
230  art::Handle< std::vector<recob::Cluster> > clusterListHandle;
231  std::vector<art::Ptr<recob::Cluster> > clusterlist;
232  if (evt.getByLabel(fClusterModuleLabel,clusterListHandle))
233  art::fill_ptr_vector(clusterlist, clusterListHandle);
234 
236  std::vector<art::Ptr<recob::Vertex> > vertexlist;
237  if (evt.getByLabel(fVertexModuleLabel,vtxListHandle))
238  art::fill_ptr_vector(vertexlist, vtxListHandle);
239 
240  art::Handle< std::vector<recob::Track> > trackListHandle;
241  evt.getByLabel(fTrackModuleLabel,trackListHandle);
242 
243  // get associations
244  art::FindManyP<recob::Cluster> clspfp_fm(pfpListHandle, evt, fHitModuleLabel);
245  art::FindManyP<recob::Vertex> vtxpfp_fm(pfpListHandle, evt, fVertexModuleLabel);
246  art::FindManyP<recob::Hit> cls_fm(clusterListHandle, evt, fClusterModuleLabel);
247  art::FindManyP<recob::PFParticle> hit_fm(hitListHandle, evt, fHitModuleLabel);
248  art::FindManyP<recob::Cluster> hitcls_fm(hitListHandle, evt, fClusterModuleLabel);
249  art::FindManyP<recob::Track> trkpfp_fm(pfpListHandle, evt, fTrackModuleLabel);
250 
251  art::FindManyP<anab::Calorimetry> fmcal(trackListHandle, evt, fCalorimetryModuleLabel);
252 
253  return fTCAlg.makeShowers(pfplist, vertexlist, clusterlist, hitlist, cls_fm, clspfp_fm, vtxpfp_fm, hit_fm, hitcls_fm, trkpfp_fm, fmcal);
254 
255  return 0;
256 
257 }
258 
259 // -----------------------------------------------------
262 }
263 
264 // -----------------------------------------------------
265 
key_type key() const
Definition: Ptr.h:356
shower::TCShowerAlg fTCAlg
std::vector< double > totalEnergyErr
Definition: TCShowerAlg.h:58
int getShowersWithoutSlices(art::Event &evt)
std::vector< double > dEdx
Definition: TCShowerAlg.h:59
Declaration of signal hit object.
std::string fVertexModuleLabel
std::vector< art::Ptr< recob::Hit > > showerHits
Definition: TCShowerAlg.h:62
TCShower(fhicl::ParameterSet const &p)
Class to keep data related to recob::Hit associated with recob::Track.
STL namespace.
std::string fSliceModuleLabel
void beginJob() override
TCShower & operator=(TCShower const &)=delete
std::string fTrackModuleLabel
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
Provides recob::Track data product.
void produce(art::Event &e) override
parameter set interface
std::string fHitModuleLabel
std::string fClusterModuleLabel
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.
Declaration of cluster object.
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::string fCalorimetryModuleLabel
std::vector< double > totalEnergy
Definition: TCShowerAlg.h:57
int makeShowers(std::vector< art::Ptr< recob::PFParticle > > pfplist, std::vector< art::Ptr< recob::Vertex > > vertexlist, std::vector< art::Ptr< recob::Cluster > > clusterlist, std::vector< art::Ptr< recob::Hit > > hitlist, art::FindManyP< recob::Hit > cls_fm, art::FindManyP< recob::Cluster > clspfp_fm, art::FindManyP< recob::Vertex > vtxpfp_fm, art::FindManyP< recob::PFParticle > hit_fm, art::FindManyP< recob::Cluster > hitcls_fm, art::FindManyP< recob::Track > trkpfp_fm, art::FindManyP< anab::Calorimetry > fmcal)
Definition: TCShowerAlg.cxx:50
TCEvent evt
Definition: DataStructs.cxx:5
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Float_t e
Definition: plot.C:34
std::vector< double > dEdxErr
Definition: TCShowerAlg.h:60
Definition: fwd.h:25
art framework interface to geometry description
int getShowersWithSlices(art::Event &evt, art::Ptr< recob::Slice > thisslice)