RecoDemo_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief A quick reco producer module for the summer 2017 YN tutorial session.
3 /// \author mbaird42@fnal.gov
4 ////////////////////////////////////////////////////////////////////////
5 
6 #include <string>
7 #include <vector>
8 
9 // Framework includes
16 
17 #include "Geometry/Geometry.h"
18 #include "RecoBase/Cluster.h"
19 #include "RecoBase/Vertex.h"
20 
21 #include "Utilities/AssociationUtil.h"
22 
23 // ROOT includes
24 #include "TVector3.h"
25 
26 
27 /// Tutorial modules
28 namespace recodemo
29 {
30  class RecoDemo : public art::EDProducer
31  {
32  public:
33  explicit RecoDemo(const fhicl::ParameterSet& pset);
34  ~RecoDemo();
35 
36  void produce(art::Event& evt); // DIFF - art::Event is not const
37 
38  void reconfigure(const fhicl::ParameterSet& pset);
39 
40  void beginJob();
41 
42  protected:
45 
46  };
47 }
48 
49 
50 ////////////////////////////////////////////////////////////////////////
51 namespace recodemo
52 {
53  //.......................................................................
55  {
56  this->reconfigure(pset);
57 
58  // DIFF - need to declare what this module intends to put into the event
59  this->produces<std::vector<rb::Vertex> >();
60  this->produces<art::Assns<rb::Vertex, rb::Cluster> >();
61  }
62 
63  //......................................................................
65  {
66  }
67 
68  //......................................................................
70  {
71  fAString = pset.get<std::string>("AString");
72  fSlicerLabel = pset.get<std::string>("SlicerLabel");
73  }
74 
75  //......................................................................
77  {
78  }
79 
80  //......................................................................
81  void RecoDemo::produce(art::Event& evt) // DIFF - again, the art::Event is not const
82  {
83  // DIFF - Declare a container for vertex objects to be stored in the art::event
84  std::unique_ptr<std::vector<rb::Vertex> > vertexcol(new std::vector<rb::Vertex>);
85 
86  // DIFF - Declare the associations between the object you are making and the slice it "belongs to"
87  std::unique_ptr<art::Assns<rb::Vertex, rb::Cluster> > assns(new art::Assns<rb::Vertex, rb::Cluster>);
88 
89  // Pull out the time slices and shuffle them into a useful container
91  evt.getByLabel(fSlicerLabel, slices);
92 
93 
94  for (unsigned int i = 0; i < slices->size(); ++i) {
95 
96  // pick out just the current slice
97  const rb::Cluster& slice = (*slices)[i];
98 
99  // Just make a veretex from the average values for this slice
100  rb::Vertex vert(slice.MeanX(), slice.MeanY(), slice.MeanZ(), slice.MeanTNS());
101 
102  // DIFF - Add the vertex to the vector of all verticies
103  vertexcol->push_back(vert);
104 
105  // Creating an association requires an art:Ptr...
106  art::Ptr<rb::Cluster> artslice(slices,i);
107 
108  // DIFF - Make the association between this vertex and the slice it came from
109  util::CreateAssn(*this, evt, *vertexcol, artslice, *assns);
110 
111  }
112 
113 
114 
115  // DIFF - put the stuff you made into the event
116  evt.put(std::move(vertexcol));
117  evt.put(std::move(assns));
118  }
119 
120 } // end namespace recodemo
121 
122 
123 ////////////////////////////////////////////////////////////////////////
124 namespace recodemo
125 {
127 }
A 3D position and time representing an interaction vertex.
Definition: Vertex.h:15
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.
void reconfigure(const fhicl::ParameterSet &pset)
A collection of associated CellHits.
Definition: Cluster.h:47
double MeanZ(rb::AveragingScheme scheme=kDefaultScheme) const
Definition: Cluster.h:233
DEFINE_ART_MODULE(TestTMapFile)
RecoDemo(const fhicl::ParameterSet &pset)
double MeanX(rb::AveragingScheme scheme=kDefaultScheme) const
Definition: Cluster.h:231
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
A quick reco producer module for the summer 2017 YN tutorial session.
double MeanY(rb::AveragingScheme scheme=kDefaultScheme) const
Definition: Cluster.h:232
T get(std::string const &key) const
Definition: ParameterSet.h:231
void produce(art::Event &evt)
Vertex location in position and time.
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
double MeanTNS(rb::AveragingScheme scheme=kDefaultScheme) const
Definition: Cluster.cxx:554
std::string fSlicerLabel
Encapsulate the geometry of one entire detector (near, far, ndos)