LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lcvn::PixelMapProducer< T, U > Class Template Reference

Producer algorithm for PixelMap, input to CVN neural net. More...

#include "PixelMapProducer.h"

Public Member Functions

 PixelMapProducer (unsigned int nWire, unsigned int nTdc, double tRes, double threshold=0.)
 
 PixelMapProducer ()
 
 PixelMapProducer (const fhicl::ParameterSet &pset)
 
void SetMultipleDrifts ()
 
unsigned int NROI ()
 
virtual Boundary DefineBoundary (detinfo::DetectorPropertiesData const &detProp, const std::vector< const T * > &cluster)
 Get boundaries for pixel map representation of cluster. More...
 
virtual void ConvertLocaltoGlobal (geo::WireID wireid, unsigned int &globalWire, unsigned int &globalPlane) const
 
virtual void ConvertLocaltoGlobalTDC (geo::WireID wireid, double localTDC, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
 
unsigned int NWire () const
 
unsigned int NTdc () const
 
double TRes () const
 
virtual PixelMap CreateMap (detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< T >> &cluster)
 
virtual PixelMap CreateMap (detinfo::DetectorPropertiesData const &detProp, const std::vector< const T * > &cluster)
 
virtual PixelMap CreateMapGivenBoundary (detinfo::DetectorPropertiesData const &detProp, const std::vector< const T * > &cluster, const Boundary &bound)
 

Protected Attributes

unsigned int fNWire
 Number of wires, length for pixel maps. More...
 
unsigned int fNTdc
 Number of tdcs, width of pixel map. More...
 
double fTRes
 Timing resolution for pixel map. More...
 
unsigned int fTotHits
 Total hits in the pixel map. More...
 
double fThreshold
 Charge threshold to consider for hits/waveforms etc. More...
 
bool fMultipleDrifts
 True if making the pixel map requires handling for multiple drift regions. More...
 
geo::GeometryCore const * fGeometry
 

Detailed Description

template<class T, class U>
class lcvn::PixelMapProducer< T, U >

Producer algorithm for PixelMap, input to CVN neural net.

Definition at line 86 of file PixelMapProducer.h.

Constructor & Destructor Documentation

template<class T , class U >
lcvn::PixelMapProducer< T, U >::PixelMapProducer ( unsigned int  nWire,
unsigned int  nTdc,
double  tRes,
double  threshold = 0. 
)

Definition at line 107 of file PixelMapProducer.cxx.

References lcvn::PixelMapProducer< T, U >::fGeometry.

111  : fNWire(nWire), fNTdc(nTdc), fTRes(tRes), fThreshold(threshold), fMultipleDrifts(false)
112  {
113 
115  }
double fThreshold
Charge threshold to consider for hits/waveforms etc.
unsigned int fNTdc
Number of tdcs, width of pixel map.
unsigned int fNWire
Number of wires, length for pixel maps.
double fTRes
Timing resolution for pixel map.
geo::GeometryCore const * fGeometry
bool fMultipleDrifts
True if making the pixel map requires handling for multiple drift regions.
template<class T , class U >
lcvn::PixelMapProducer< T, U >::PixelMapProducer ( )
template<class T , class U >
lcvn::PixelMapProducer< T, U >::PixelMapProducer ( const fhicl::ParameterSet pset)

Definition at line 124 of file PixelMapProducer.cxx.

References lcvn::PixelMapProducer< T, U >::fGeometry.

125  : fNWire(pset.get<unsigned int>("WireLength"))
126  , fNTdc(pset.get<unsigned int>("TdcWidth"))
127  , fTRes(pset.get<double>("TimeResolution"))
128  , fThreshold(pset.get<double>("Threshold"))
129  , fMultipleDrifts(pset.get<bool>("MultipleDrifts"))
130  {
132  }
T get(std::string const &key) const
Definition: ParameterSet.h:314
double fThreshold
Charge threshold to consider for hits/waveforms etc.
unsigned int fNTdc
Number of tdcs, width of pixel map.
unsigned int fNWire
Number of wires, length for pixel maps.
double fTRes
Timing resolution for pixel map.
geo::GeometryCore const * fGeometry
bool fMultipleDrifts
True if making the pixel map requires handling for multiple drift regions.

Member Function Documentation

template<class T , class U >
void lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobal ( geo::WireID  wireid,
unsigned int &  globalWire,
unsigned int &  globalPlane 
) const
virtual

Definition at line 302 of file PixelMapProducer.cxx.

References geo::PlaneID::Plane, and geo::WireID::Wire.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary(), and lcvn::PixelMapProducer< T, U >::DefineBoundary().

305  {
306  globalWire = wireid.Wire;
307  globalPlane = wireid.Plane;
308  }
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
template<class T , class U >
void lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobalTDC ( geo::WireID  wireid,
double  localTDC,
unsigned int &  globalWire,
unsigned int &  globalPlane,
double &  globalTDC 
) const
virtual

Definition at line 311 of file PixelMapProducer.cxx.

References geo::PlaneID::Plane, and geo::WireID::Wire.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary(), and lcvn::PixelMapProducer< T, U >::DefineBoundary().

316  {
317  globalWire = wireid.Wire;
318  globalPlane = wireid.Plane;
319  globalTDC = localTDC;
320  }
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
template<class T , class U >
PixelMap lcvn::PixelMapProducer< T, U >::CreateMap ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< art::Ptr< T >> &  cluster 
)
virtual

Definition at line 135 of file PixelMapProducer.cxx.

137  {
138  std::vector<const T*> newCluster;
139  for (const art::Ptr<T> hit : cluster) {
140  newCluster.push_back(hit.get());
141  }
142  return CreateMap(detProp, newCluster);
143  }
virtual PixelMap CreateMap(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< T >> &cluster)
Detector simulation of raw signals on wires.
Definition: fwd.h:26
template<class T , class U >
PixelMap lcvn::PixelMapProducer< T, U >::CreateMap ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< const T * > &  cluster 
)
virtual

Definition at line 146 of file PixelMapProducer.cxx.

References lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary(), and lcvn::PixelMapProducer< T, U >::DefineBoundary().

148  {
149  Boundary bound = DefineBoundary(detProp, cluster);
150  return CreateMapGivenBoundary(detProp, cluster, bound);
151  }
virtual PixelMap CreateMapGivenBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const T * > &cluster, const Boundary &bound)
virtual Boundary DefineBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const T * > &cluster)
Get boundaries for pixel map representation of cluster.
template<class T , class U >
PixelMap lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< const T * > &  cluster,
const Boundary bound 
)
virtual

Definition at line 154 of file PixelMapProducer.cxx.

References lcvn::PixelMap::Add(), lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobal(), lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobalTDC(), lcvn::PixelMapProducer< T, U >::fMultipleDrifts, lcvn::PixelMapProducer< T, U >::fNTdc, lcvn::PixelMapProducer< T, U >::fNWire, lcvn::PixelMapProducer< T, U >::fThreshold, lcvn::PixelMapProducer< T, U >::fTotHits, geo::PlaneID::Plane, lcvn::PixelMap::SetTotHits(), and geo::WireID::Wire.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMap().

158  {
159 
160  PixelMap pm(fNWire, fNTdc, bound);
161 
162  for (size_t iHit = 0; iHit < cluster.size(); ++iHit) {
163 
164  U wraphit(*(cluster[iHit]), fThreshold);
165  Waveform wf = wraphit.GetWaveform();
166  geo::WireID wireid = wraphit.GetID();
167 
168  unsigned int tempWire = wireid.Wire;
169  unsigned int tempPlane = wireid.Plane;
170 
171  if (!fMultipleDrifts) ConvertLocaltoGlobal(wireid, tempWire, tempPlane);
172 
173  for (auto& pulse : wf) {
174  // Leigh: Simple modification to unwrap the collection view wire plane
175  for (auto& i : pulse) {
176  const double pe = i.second;
177  double temptdc = i.first;
178  if (fMultipleDrifts)
179  ConvertLocaltoGlobalTDC(wireid, i.first, tempWire, tempPlane, temptdc);
180 
181  const unsigned int wire = tempWire;
182  const unsigned int wirePlane = tempPlane;
183  const double tdc = temptdc;
184 
185  pm.Add(wire, tdc, wirePlane, pe);
186  }
187  }
188  }
189  pm.SetTotHits(fTotHits);
190  return pm;
191  }
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
virtual void ConvertLocaltoGlobalTDC(geo::WireID wireid, double localTDC, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
double fThreshold
Charge threshold to consider for hits/waveforms etc.
unsigned int fNTdc
Number of tdcs, width of pixel map.
virtual void ConvertLocaltoGlobal(geo::WireID wireid, unsigned int &globalWire, unsigned int &globalPlane) const
unsigned int fNWire
Number of wires, length for pixel maps.
unsigned int fTotHits
Total hits in the pixel map.
std::vector< std::map< double, double > > Waveform
bool fMultipleDrifts
True if making the pixel map requires handling for multiple drift regions.
template<class T , class U >
Boundary lcvn::PixelMapProducer< T, U >::DefineBoundary ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< const T * > &  cluster 
)
virtual

Get boundaries for pixel map representation of cluster.

Definition at line 201 of file PixelMapProducer.cxx.

References util::abs(), lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobal(), lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobalTDC(), lcvn::PixelMapProducer< T, U >::fMultipleDrifts, lcvn::PixelMapProducer< T, U >::fNWire, lcvn::PixelMapProducer< T, U >::fThreshold, lcvn::PixelMapProducer< T, U >::fTotHits, lcvn::PixelMapProducer< T, U >::fTRes, geo::PlaneID::Plane, and geo::WireID::Wire.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMap().

203  {
204 
205  std::vector<double> tmin_0;
206  std::vector<double> tmin_1;
207  std::vector<double> tmin_2;
208 
209  std::vector<int> wire_0, bwire_0;
210  std::vector<int> wire_1, bwire_1;
211  std::vector<int> wire_2, bwire_2;
212 
213  std::vector<double> tsum = {0., 0., 0.};
214  std::vector<double> tsize = {0., 0., 0.};
215 
216  for (size_t iHit = 0; iHit < cluster.size(); ++iHit) {
217  U wraphit(*(cluster[iHit]), fThreshold);
218  Waveform wf = wraphit.GetWaveform();
219  geo::WireID wireid = wraphit.GetID();
220 
221  unsigned int tempWire = wireid.Wire;
222  unsigned int tempPlane = wireid.Plane;
223 
224  if (!fMultipleDrifts) ConvertLocaltoGlobal(wireid, tempWire, tempPlane);
225 
226  for (auto& pulse : wf) {
227  double min_tick = (double)INT_MAX;
228  for (auto& i : pulse) {
229  double temptdc = i.first;
230 
231  if (fMultipleDrifts)
232  ConvertLocaltoGlobalTDC(wireid, i.first, tempWire, tempPlane, temptdc);
233 
234  if (temptdc < min_tick) min_tick = temptdc;
235 
236  tsum[tempPlane] += temptdc;
237  tsize[tempPlane] += 1.;
238  }
239 
240  if (!(pulse.empty())) {
241  if (tempPlane == 0) {
242  tmin_0.push_back(min_tick);
243  wire_0.push_back(tempWire);
244  }
245  if (tempPlane == 1) {
246  tmin_1.push_back(min_tick);
247  wire_0.push_back(tempWire);
248  }
249  if (tempPlane == 2) {
250  tmin_2.push_back(min_tick);
251  wire_0.push_back(tempWire);
252  }
253  }
254  } // end loop over pulses on single wire
255  } // end loop over struck wires
256 
257  double tmean_0 = tsum[0] / tsize[0];
258  double tmean_1 = tsum[1] / tsize[1];
259  double tmean_2 = tsum[2] / tsize[2];
260 
261  for (int i = 0; i < (int)wire_0.size(); i++) {
262  if (std::abs(tmin_0[i] - tmean_0) < (double)fTRes) bwire_0.push_back(wire_0[i]);
263  }
264  for (int i = 0; i < (int)wire_1.size(); i++) {
265  if (std::abs(tmin_1[i] - tmean_1) < (double)fTRes) bwire_1.push_back(wire_1[i]);
266  }
267  for (int i = 0; i < (int)wire_2.size(); i++) {
268  if (std::abs(tmin_2[i] - tmean_2) < (double)fTRes) bwire_2.push_back(wire_2[i]);
269  }
270 
271  std::cout << "Boundary wire vector sizes: " << bwire_0.size() << ", " << bwire_1.size() << ", "
272  << bwire_2.size() << std::endl;
273 
274  int minwire_0 = 0;
275  int minwire_1 = 0;
276  int minwire_2 = 0;
277  auto minwireelement_0 = std::min_element(bwire_0.begin(), bwire_0.end());
278  auto minwireelement_1 = std::min_element(bwire_1.begin(), bwire_1.end());
279  auto minwireelement_2 = std::min_element(bwire_2.begin(), bwire_2.end());
280 
281  if (bwire_0.size() > 0) {
282  minwire_0 = *minwireelement_0 - 1;
283  std::cout << "minwire 0: " << (*minwireelement_0 - 1) << std::endl;
284  }
285  if (bwire_1.size() > 0) {
286  minwire_1 = *minwireelement_1 - 1;
287  std::cout << "minwire 1: " << (*minwireelement_1 - 1) << std::endl;
288  }
289  if (bwire_2.size() > 0) {
290  minwire_2 = *minwireelement_2 - 1;
291  std::cout << "minwire 2: " << (*minwireelement_2 - 1) << std::endl;
292  }
293 
294  fTotHits = bwire_0.size() + bwire_1.size() + bwire_2.size();
295 
296  Boundary bound(fNWire, fTRes, minwire_0, minwire_1, minwire_2, tmean_0, tmean_1, tmean_2);
297 
298  return bound;
299  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
virtual void ConvertLocaltoGlobalTDC(geo::WireID wireid, double localTDC, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
double fThreshold
Charge threshold to consider for hits/waveforms etc.
virtual void ConvertLocaltoGlobal(geo::WireID wireid, unsigned int &globalWire, unsigned int &globalPlane) const
unsigned int fNWire
Number of wires, length for pixel maps.
unsigned int fTotHits
Total hits in the pixel map.
double fTRes
Timing resolution for pixel map.
std::vector< std::map< double, double > > Waveform
bool fMultipleDrifts
True if making the pixel map requires handling for multiple drift regions.
template<class T , class U >
unsigned int lcvn::PixelMapProducer< T, U >::NROI ( )
inline

Definition at line 95 of file PixelMapProducer.h.

95 { return fTotHits; };
unsigned int fTotHits
Total hits in the pixel map.
template<class T , class U >
unsigned int lcvn::PixelMapProducer< T, U >::NTdc ( ) const
inline

Definition at line 112 of file PixelMapProducer.h.

112 { return fNTdc; }
unsigned int fNTdc
Number of tdcs, width of pixel map.
template<class T , class U >
unsigned int lcvn::PixelMapProducer< T, U >::NWire ( ) const
inline

Definition at line 111 of file PixelMapProducer.h.

111 { return fNWire; }
unsigned int fNWire
Number of wires, length for pixel maps.
template<class T , class U >
void lcvn::PixelMapProducer< T, U >::SetMultipleDrifts ( )
inline

Definition at line 94 of file PixelMapProducer.h.

94 { fMultipleDrifts = true; }
bool fMultipleDrifts
True if making the pixel map requires handling for multiple drift regions.
template<class T , class U >
double lcvn::PixelMapProducer< T, U >::TRes ( ) const
inline

Definition at line 113 of file PixelMapProducer.h.

References lar::dump::vector().

113 { return fTRes; }
double fTRes
Timing resolution for pixel map.

Member Data Documentation

template<class T , class U >
geo::GeometryCore const* lcvn::PixelMapProducer< T, U >::fGeometry
protected
template<class T , class U >
bool lcvn::PixelMapProducer< T, U >::fMultipleDrifts
protected

True if making the pixel map requires handling for multiple drift regions.

Definition at line 131 of file PixelMapProducer.h.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary(), and lcvn::PixelMapProducer< T, U >::DefineBoundary().

template<class T , class U >
unsigned int lcvn::PixelMapProducer< T, U >::fNTdc
protected

Number of tdcs, width of pixel map.

Definition at line 126 of file PixelMapProducer.h.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary().

template<class T , class U >
unsigned int lcvn::PixelMapProducer< T, U >::fNWire
protected

Number of wires, length for pixel maps.

Definition at line 125 of file PixelMapProducer.h.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary(), and lcvn::PixelMapProducer< T, U >::DefineBoundary().

template<class T , class U >
double lcvn::PixelMapProducer< T, U >::fThreshold
protected

Charge threshold to consider for hits/waveforms etc.

Definition at line 129 of file PixelMapProducer.h.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary(), and lcvn::PixelMapProducer< T, U >::DefineBoundary().

template<class T , class U >
unsigned int lcvn::PixelMapProducer< T, U >::fTotHits
protected
template<class T , class U >
double lcvn::PixelMapProducer< T, U >::fTRes
protected

Timing resolution for pixel map.

Definition at line 127 of file PixelMapProducer.h.

Referenced by lcvn::PixelMapProducer< T, U >::DefineBoundary().


The documentation for this class was generated from the following files: