CVNMapper_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file CVNMapper_module.cc
3 // \brief Producer module for creating CVN PixelMap objects
4 // \author Alexander Radovic - a.radovic@gmail.com
5 ////////////////////////////////////////////////////////////////////////
6 
7 // C/C++ includes
8 #include <iostream>
9 #include <sstream>
10 
11 // Framework includes
15 #include "art_root_io/TFileDirectory.h"
16 #include "art_root_io/TFileService.h"
18 #include "fhiclcpp/ParameterSet.h"
22 
23 // LArSoft includes
25 
29 
30 
31 
32 
33 namespace cvn {
34 
35  class CVNMapper : public art::EDProducer {
36  public:
37  explicit CVNMapper(fhicl::ParameterSet const& pset);
38  ~CVNMapper();
39 
40  void produce(art::Event& evt);
41  void beginJob();
42  void endJob();
43 
44 
45 
46  private:
47  /// Module lablel for input clusters
49 
50  /// Instance lablel for cluster pixelmaps
52 
53  /// Minimum number of hits for cluster to be converted to pixel map
54  unsigned short fMinClusterHits;
55 
56  /// Width of pixel map in tdcs
57  unsigned short fTdcWidth;
58 
59  /// Length of pixel map in wires
60  unsigned short fWireLength;
61 
62  /// Length of pixel map in wires
64 
65  /// Maximum gap in wires at front of cluster to prevent pruning of upstream
66  /// hits
67  //unsigned int fMaxWireGap;
68 
69  /// Use unwrapped pixel maps?
70  // 0 means no unwrap, 1 means unwrap in wire, 2 means unwrap in wire and time
71  unsigned short fUnwrappedPixelMap;
72 
73  /// PixelMapProducer does the work for us
75 
76  };
77 
78 
79 
80  //.......................................................................
82  fHitsModuleLabel (pset.get<std::string> ("HitsModuleLabel")),
83  fClusterPMLabel(pset.get<std::string> ("ClusterPMLabel")),
84  fMinClusterHits(pset.get<unsigned short> ("MinClusterHits")),
85  fTdcWidth (pset.get<unsigned short> ("TdcWidth")),
86  fWireLength (pset.get<unsigned short> ("WireLength")),
87  fTimeResolution (pset.get<unsigned short> ("TimeResolution")),
88  fUnwrappedPixelMap(pset.get<unsigned short> ("UnwrappedPixelMap")),
90  {
91 
92  produces< std::vector<cvn::PixelMap> >(fClusterPMLabel);
93 
94  }
95 
96  //......................................................................
98  {
99  //======================================================================
100  // Clean up any memory allocated by your module
101  //======================================================================
102  }
103 
104  //......................................................................
106  { }
107 
108  //......................................................................
110  {
111  }
112 
113  //......................................................................
115  {
116  // Use unwrapped pixel maps if requested
117  // 0 means no unwrap, 1 means unwrap in wire, 2 means unwrap in wire and time
119 
120  std::vector< art::Ptr< recob::Hit > > hitlist;
121  auto hitListHandle = evt.getHandle< std::vector< recob::Hit > >(fHitsModuleLabel);
122  if (hitListHandle)
123  art::fill_ptr_vector(hitlist, hitListHandle);
124  unsigned short nhits = hitlist.size();
125 
126  //Declaring containers for things to be stored in event
127  std::unique_ptr< std::vector<cvn::PixelMap> >
128  pmCol(new std::vector<cvn::PixelMap>);
129 
130  if (nhits > fMinClusterHits) {
131  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt);
132  PixelMap pm = fProducer.CreateMap(detProp, hitlist);
133  pm.SetTotHits(nhits);
134  pmCol->push_back(pm);
135  }
136  //pm.Print();
137  //Boundary bound = pm.Bound();
138  //}
139  evt.put(std::move(pmCol), fClusterPMLabel);
140  //std::cout<<"Map Complete!"<<std::endl;
141  }
142 
143  //----------------------------------------------------------------------
144 
145 
146 
148 } // end namespace cvn
149 ////////////////////////////////////////////////////////////////////////
unsigned short fTdcWidth
Width of pixel map in tdcs.
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
PixelMapProducer fProducer
PixelMapProducer does the work for us.
unsigned short fWireLength
Length of pixel map in wires.
PixelMap for CVN.
Utility class for truth labels.
void SetTotHits(unsigned int tothits)
Definition: PixelMap.h:67
CVNMapper(fhicl::ParameterSet const &pset)
unsigned short fMinClusterHits
Minimum number of hits for cluster to be converted to pixel map.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
void SetUnwrapped(unsigned short unwrap)
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
std::string fClusterPMLabel
Instance lablel for cluster pixelmaps.
Declaration of signal hit object.
double fTimeResolution
Length of pixel map in wires.
unsigned short fUnwrappedPixelMap
Use unwrapped pixel maps?
std::string fHitsModuleLabel
Module lablel for input clusters.
PixelMap, basic input to CVN neural net.
Definition: PixelMap.h:22
PixelMapProducer for CVN.
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
Producer algorithm for PixelMap, input to CVN neural net.
void produce(art::Event &evt)
PixelMap CreateMap(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Hit > > &slice)