WCVertex_module.cc
Go to the documentation of this file.
1 ///
2 /// \file WCVertex_module.cc
3 /// \brief Place a vertex on a cosmic ray track.
4 /// \author messier@indiana.edu
5 /// \version $Id:$
6 ///
13 
14 #include "RecoBase/FilterList.h"
15 #include "RecoBase/Cluster.h"
16 #include "RecoBase/Vertex.h"
17 #include "Utilities/AssociationUtil.h"
19 #include "Geometry/Geometry.h"
20 #include "GeometryObjects/Geo.h"
21 
22 namespace wcvtx {
23  ///
24  /// Module to associate wire chamber vertex with every slice in the event
25  ///
26  class WCVertex : public art::EDProducer {
27  private:
28  // folder labels
29  std::string fSliceLabel; ///< Where to get slices?
30  std::string fVertexLabel; ///< Vertex to grab
31 
32  public:
33  //..................................................................
34  explicit WCVertex(fhicl::ParameterSet const &pset):
35  fSliceLabel (pset.get< std::string >("SliceLabel")),
36  fVertexLabel (pset.get< std::string >("VertexLabel"))
37  {
38  //this->produces< std::vector<rb::Vertex> > ();
39  this->produces< art::Assns<rb::Vertex, rb::Cluster> >();
40  }
41 
42  //..................................................................
43  virtual ~WCVertex() { }
44 
45  //..................................................................
46  void beginJob() { }
47 
48  //..................................................................
50  //
51  // Associate the WC vertex with every single slice in event.
52  // This is a super hacky way to do this, but you don't know a priori
53  // which slice has the particle that caused the trigger.
54  //
55  std::unique_ptr< art::Assns<rb::Vertex, rb::Cluster> >
56  vtx_to_slice(new art::Assns<rb::Vertex, rb::Cluster>);
57  std::vector<art::Ptr<rb::Cluster>> slicevec;
58  //
59  // Find the slices
60  //
62  evt.getByLabel(fSliceLabel,slice);
63 
64  for(unsigned int i = 0; i < slice->size(); ++i) {
65  art::Ptr<rb::Cluster> sptr(slice, i);
66  slicevec.push_back(sptr);
67  }
68 
70  evt.getByLabel(fVertexLabel,vtxHandle);
71  art::Ptr<rb::Vertex>vtx(vtxHandle, 0);
72 
73  util::CreateAssn(*this, evt, vtx, slicevec, *vtx_to_slice);
74  evt.put(std::move(vtx_to_slice));
75  }
76 
77  //......................................................................
78  void endJob() { }
79  };
80 }
81 ////////////////////////////////////////////////////////////////////////
82 namespace wcvtx
83 {
85 }
86 ////////////////////////////////////////////////////////////////////////
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
WCVertex(fhicl::ParameterSet const &pset)
std::string fSliceLabel
Where to get slices?
void produce(art::Event &evt)
DEFINE_ART_MODULE(TestTMapFile)
std::string fVertexLabel
Vertex to grab.
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Encapsulate the geometry of one entire detector (near, far, ndos)
int evt
Collect Geo headers and supply basic geometry functions.
Vertex location in position and time.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Encapsulate the geometry of one entire detector (near, far, ndos)
enum BeamMode string