CVNMapperSim_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file CVNMapperSim_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 CVNMapperSim : public art::EDProducer {
36  public:
37  explicit CVNMapperSim(fhicl::ParameterSet const& pset);
38  ~CVNMapperSim();
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  /// ADC threshold for calculating charge from wires directly
74  double fThreshold;
75 
76  /// PixelMapProducer does the work for us
78 
79  };
80 
81 
82 
83  //.......................................................................
85  fHitsModuleLabel (pset.get<std::string> ("HitsModuleLabel")),
86  fClusterPMLabel(pset.get<std::string> ("ClusterPMLabel")),
87  fMinClusterHits(pset.get<unsigned short> ("MinClusterHits")),
88  fTdcWidth (pset.get<unsigned short> ("TdcWidth")),
89  fWireLength (pset.get<unsigned short> ("WireLength")),
90  fTimeResolution (pset.get<unsigned short> ("TimeResolution")),
91  fUnwrappedPixelMap(pset.get<unsigned short> ("UnwrappedPixelMap")),
92  fThreshold (pset.get<double>("Threshold")),
94  {
95 
96  produces< std::vector<cvn::PixelMap> >(fClusterPMLabel);
97 
98  }
99 
100  //......................................................................
102  {
103  //======================================================================
104  // Clean up any memory allocated by your module
105  //======================================================================
106  }
107 
108  //......................................................................
110  { }
111 
112  //......................................................................
114  {
115  }
116 
117  //......................................................................
119  {
120  // Use unwrapped pixel maps if requested
121  // 0 means no unwrap, 1 means unwrap in wire, 2 means unwrap in wire and time
123 
124  std::vector< art::Ptr< sim::SimChannel > > hitlist;
125  auto hitListHandle = evt.getHandle< std::vector< sim::SimChannel > >(fHitsModuleLabel);
126  if (hitListHandle)
127  art::fill_ptr_vector(hitlist, hitListHandle);
128  // unsigned short nhits = hitlist.size();
129 
130  //Declaring containers for things to be stored in event
131  std::unique_ptr< std::vector<cvn::PixelMap> >
132  pmCol(new std::vector<cvn::PixelMap>);
133 
134  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt);
135  PixelMap pm = fProducer.CreateMap(detProp, hitlist);
136  std::cout << "NROI : " << fProducer.NROI() << std::endl;
138  pmCol->push_back(pm);
139  //pm.Print();
140  //Boundary bound = pm.Bound();
141  //}
142  evt.put(std::move(pmCol), fClusterPMLabel);
143  //std::cout<<"Map Complete!"<<std::endl;
144  }
145 
146  //----------------------------------------------------------------------
147 
148 
149 
151 } // end namespace cvn
152 ////////////////////////////////////////////////////////////////////////
std::string fHitsModuleLabel
Module lablel for input clusters.
unsigned short fMinClusterHits
Minimum number of hits for cluster to be converted to pixel map.
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
void produce(art::Event &evt)
PixelMapSimProducer fProducer
PixelMapProducer does the work for us.
PixelMap for CVN.
Utility class for truth labels.
void SetUnwrapped(unsigned short unwrap)
unsigned short fWireLength
Length of pixel map in wires.
PixelMapSimProducer for CVN.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
std::string fClusterPMLabel
Instance lablel for cluster pixelmaps.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
PixelMap CreateMap(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< sim::SimChannel > > &slice)
unsigned short fUnwrappedPixelMap
Use unwrapped pixel maps?
double fThreshold
ADC threshold for calculating charge from wires directly.
PixelMap, basic input to CVN neural net.
Definition: PixelMap.h:22
Producer algorithm for PixelMap, input to CVN neural net.
CVNMapperSim(fhicl::ParameterSet const &pset)
double fTimeResolution
Length of pixel map in wires.
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
QTextStream & endl(QTextStream &s)
unsigned short fTdcWidth
Width of pixel map in tdcs.