LArSoft  v10_04_05
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 ()=default
 
 PixelMapProducer (const fhicl::ParameterSet &pset)
 
unsigned int NWire () const
 
unsigned int NTdc () const
 
double TRes () const
 
unsigned int TotHits () const
 
double Threshold () const
 
bool MultipleDrifts () const
 
void SetTotHits (unsigned int tothits)
 
void SetMultipleDrifts (bool multipledrifts=true)
 
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
 
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)
 

Private 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...
 

Detailed Description

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

Producer algorithm for PixelMap, input to CVN neural net.

Definition at line 81 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 102 of file PixelMapProducer.cxx.

106  : fNWire(nWire), fNTdc(nTdc), fTRes(tRes), fThreshold(threshold), fMultipleDrifts(false)
107  {}
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.
bool fMultipleDrifts
True if making the pixel map requires handling for multiple drift regions.
template<class T , class U >
lcvn::PixelMapProducer< T, U >::PixelMapProducer ( )
default
template<class T , class U >
lcvn::PixelMapProducer< T, U >::PixelMapProducer ( const fhicl::ParameterSet pset)

Definition at line 110 of file PixelMapProducer.cxx.

111  : fNWire(pset.get<unsigned int>("WireLength"))
112  , fNTdc(pset.get<unsigned int>("TdcWidth"))
113  , fTRes(pset.get<double>("TimeResolution"))
114  , fThreshold(pset.get<double>("Threshold"))
115  , fMultipleDrifts(pset.get<bool>("MultipleDrifts"))
116  {}
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.
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 282 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().

285  {
286  globalWire = wireid.Wire;
287  globalPlane = wireid.Plane;
288  }
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:430
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:373
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 291 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().

296  {
297  globalWire = wireid.Wire;
298  globalPlane = wireid.Plane;
299  globalTDC = localTDC;
300  }
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:430
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:373
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 119 of file PixelMapProducer.cxx.

121  {
122  std::vector<const T*> newCluster;
123  for (const art::Ptr<T> hit : cluster) {
124  newCluster.push_back(hit.get());
125  }
126  return CreateMap(detProp, newCluster);
127  }
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 130 of file PixelMapProducer.cxx.

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

132  {
133  Boundary bound = DefineBoundary(detProp, cluster);
134  return CreateMapGivenBoundary(detProp, cluster, bound);
135  }
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 138 of file PixelMapProducer.cxx.

References lcvn::PixelMap::Add(), lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobal(), lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobalTDC(), geo::WireID::first(), 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().

142  {
143  PixelMap pm(fNWire, fNTdc, bound);
144 
145  for (size_t iHit = 0; iHit < cluster.size(); ++iHit) {
146 
147  U wraphit(*(cluster[iHit]), fThreshold);
148  Waveform wf = wraphit.GetWaveform();
149  geo::WireID wireid = wraphit.GetID();
150 
151  unsigned int tempWire = wireid.Wire;
152  unsigned int tempPlane = wireid.Plane;
153 
154  if (!fMultipleDrifts) ConvertLocaltoGlobal(wireid, tempWire, tempPlane);
155 
156  for (auto& pulse : wf) {
157  // Leigh: Simple modification to unwrap the collection view wire plane
158  for (auto& i : pulse) {
159  const double pe = i.second;
160  double temptdc = i.first;
161  if (fMultipleDrifts)
162  ConvertLocaltoGlobalTDC(wireid, i.first, tempWire, tempPlane, temptdc);
163 
164  const unsigned int wire = tempWire;
165  const unsigned int wirePlane = tempPlane;
166  const double tdc = temptdc;
167 
168  pm.Add(wire, tdc, wirePlane, pe);
169  }
170  }
171  }
172  pm.SetTotHits(fTotHits);
173  return pm;
174  }
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:430
static constexpr auto first()
Definition: geo_types.h:442
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:373
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 184 of file PixelMapProducer.cxx.

References util::abs(), lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobal(), lcvn::PixelMapProducer< T, U >::ConvertLocaltoGlobalTDC(), geo::WireID::first(), 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().

186  {
187  std::vector<double> tmin_0;
188  std::vector<double> tmin_1;
189  std::vector<double> tmin_2;
190 
191  std::vector<int> wire_0, bwire_0;
192  std::vector<int> wire_1, bwire_1;
193  std::vector<int> wire_2, bwire_2;
194 
195  std::vector<double> tsum = {0., 0., 0.};
196  std::vector<double> tsize = {0., 0., 0.};
197 
198  for (size_t iHit = 0; iHit < cluster.size(); ++iHit) {
199  U wraphit(*(cluster[iHit]), fThreshold);
200  Waveform wf = wraphit.GetWaveform();
201  geo::WireID wireid = wraphit.GetID();
202 
203  unsigned int tempWire = wireid.Wire;
204  unsigned int tempPlane = wireid.Plane;
205 
206  if (!fMultipleDrifts) ConvertLocaltoGlobal(wireid, tempWire, tempPlane);
207 
208  for (auto& pulse : wf) {
209  double min_tick = (double)INT_MAX;
210  for (auto& i : pulse) {
211  double temptdc = i.first;
212 
213  if (fMultipleDrifts)
214  ConvertLocaltoGlobalTDC(wireid, i.first, tempWire, tempPlane, temptdc);
215 
216  if (temptdc < min_tick) min_tick = temptdc;
217 
218  tsum[tempPlane] += temptdc;
219  tsize[tempPlane] += 1.;
220  }
221 
222  if (!(pulse.empty())) {
223  if (tempPlane == 0) {
224  tmin_0.push_back(min_tick);
225  wire_0.push_back(tempWire);
226  }
227  if (tempPlane == 1) {
228  tmin_1.push_back(min_tick);
229  wire_0.push_back(tempWire);
230  }
231  if (tempPlane == 2) {
232  tmin_2.push_back(min_tick);
233  wire_0.push_back(tempWire);
234  }
235  }
236  } // end loop over pulses on single wire
237  } // end loop over struck wires
238 
239  double tmean_0 = tsum[0] / tsize[0];
240  double tmean_1 = tsum[1] / tsize[1];
241  double tmean_2 = tsum[2] / tsize[2];
242 
243  for (int i = 0; i < (int)wire_0.size(); i++) {
244  if (std::abs(tmin_0[i] - tmean_0) < (double)fTRes) bwire_0.push_back(wire_0[i]);
245  }
246  for (int i = 0; i < (int)wire_1.size(); i++) {
247  if (std::abs(tmin_1[i] - tmean_1) < (double)fTRes) bwire_1.push_back(wire_1[i]);
248  }
249  for (int i = 0; i < (int)wire_2.size(); i++) {
250  if (std::abs(tmin_2[i] - tmean_2) < (double)fTRes) bwire_2.push_back(wire_2[i]);
251  }
252 
253  std::cout << "Boundary wire vector sizes: " << bwire_0.size() << ", " << bwire_1.size() << ", "
254  << bwire_2.size() << std::endl;
255 
256  int minwire_0 = 0;
257  int minwire_1 = 0;
258  int minwire_2 = 0;
259  auto minwireelement_0 = std::min_element(bwire_0.begin(), bwire_0.end());
260  auto minwireelement_1 = std::min_element(bwire_1.begin(), bwire_1.end());
261  auto minwireelement_2 = std::min_element(bwire_2.begin(), bwire_2.end());
262 
263  if (bwire_0.size() > 0) {
264  minwire_0 = *minwireelement_0 - 1;
265  std::cout << "minwire 0: " << (*minwireelement_0 - 1) << std::endl;
266  }
267  if (bwire_1.size() > 0) {
268  minwire_1 = *minwireelement_1 - 1;
269  std::cout << "minwire 1: " << (*minwireelement_1 - 1) << std::endl;
270  }
271  if (bwire_2.size() > 0) {
272  minwire_2 = *minwireelement_2 - 1;
273  std::cout << "minwire 2: " << (*minwireelement_2 - 1) << std::endl;
274  }
275 
276  fTotHits = bwire_0.size() + bwire_1.size() + bwire_2.size();
277 
278  return Boundary(fNWire, fTRes, minwire_0, minwire_1, minwire_2, tmean_0, tmean_1, tmean_2);
279  }
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:430
static constexpr auto first()
Definition: geo_types.h:442
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:373
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 >
bool lcvn::PixelMapProducer< T, U >::MultipleDrifts ( ) const
inline

Definition at line 94 of file PixelMapProducer.h.

94 { return fMultipleDrifts; }
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 >::NTdc ( ) const
inline

Definition at line 90 of file PixelMapProducer.h.

90 { 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 89 of file PixelMapProducer.h.

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

Definition at line 97 of file PixelMapProducer.h.

References lar::dump::vector().

97 { fMultipleDrifts = multipledrifts; }
bool fMultipleDrifts
True if making the pixel map requires handling for multiple drift regions.
template<class T , class U >
void lcvn::PixelMapProducer< T, U >::SetTotHits ( unsigned int  tothits)
inline

Definition at line 96 of file PixelMapProducer.h.

96 { fTotHits = tothits; }
unsigned int fTotHits
Total hits in the pixel map.
template<class T , class U >
double lcvn::PixelMapProducer< T, U >::Threshold ( ) const
inline

Definition at line 93 of file PixelMapProducer.h.

References lcvn::HitHelper::fThreshold.

93 { return fThreshold; }
double fThreshold
Charge threshold to consider for hits/waveforms etc.
template<class T , class U >
unsigned int lcvn::PixelMapProducer< T, U >::TotHits ( ) const
inline

Definition at line 92 of file PixelMapProducer.h.

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

Definition at line 91 of file PixelMapProducer.h.

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

Member Data Documentation

template<class T , class U >
bool lcvn::PixelMapProducer< T, U >::fMultipleDrifts
private

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

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 >::fNTdc
private

Number of tdcs, width of pixel map.

Definition at line 124 of file PixelMapProducer.h.

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

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

Number of wires, length for pixel maps.

Definition at line 123 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
private

Charge threshold to consider for hits/waveforms etc.

Definition at line 127 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
private
template<class T , class U >
double lcvn::PixelMapProducer< T, U >::fTRes
private

Timing resolution for pixel map.

Definition at line 125 of file PixelMapProducer.h.

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


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