RegPixelMap3DProducer.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file RegPixelMap3DProducer.h
3 /// \brief RegPixelMap3DProducer for RegCNN modified from PixelMapProducer.h
4 /// \author Wenjie Wu - wenjieww@uci.edu
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include <iostream>
8 #include <ostream>
9 #include <list>
10 #include <algorithm>
11 
12 #include "larcorealg/Geometry/Exceptions.h" // geo::InvalidWireError
15 #include "TVector2.h"
16 
17 namespace cnn
18 {
19  RegPixelMap3DProducer::RegPixelMap3DProducer(int nbinsX, int nbinsY, int nbinsZ,
20  double XResolution, double YResolution, double ZResolution,
21  bool Cropped, bool ProngOnly):
22  fNBinsX(nbinsX),
23  fNBinsY(nbinsY),
24  fNBinsZ(nbinsZ),
25  fLengthX(nbinsX*XResolution),
26  fLengthY(nbinsY*YResolution),
27  fLengthZ(nbinsZ*ZResolution),
28  fCropped(Cropped),
29  fProngOnly(ProngOnly)
30  {
31  }
32 
33 
35  detinfo::DetectorPropertiesData const& detProp,
37  art::FindManyP<recob::SpacePoint> const& fmSPFromHits,
38  art::FindManyP<recob::Track> const& fmtrkhit,
39  const std::vector<float> &vtx)
40  {
41 
42  RegCNNBoundary3D bound = Define3DBoundary(detProp, cluster, vtx);
43 
44  return Create3DMapGivenBoundaryBySP(clockData, detProp, cluster, bound, fmSPFromHits, fmtrkhit, fCropped, fProngOnly);
45  }
46 
47 
49  detinfo::DetectorPropertiesData const& detProp,
51  const RegCNNBoundary3D& bound,
52  art::FindManyP<recob::SpacePoint> const& fmSPFromHits,
53  art::FindManyP<recob::Track> const& fmtrkhit,
54  const bool& Cropped,
55  const bool& ProngOnly)
56  {
57  std::cout<<"create 3D pixel maps"<<std::endl;
58 
59  RegPixelMap3D pm(bound, Cropped, ProngOnly);
60 
61  if (!fmSPFromHits.isValid()) return pm;
62 
63  // Loop over hit
64  unsigned int nhits = cluster.size();
65  for (unsigned int ihit= 0; ihit< nhits; ++ihit) {
66  // Get hit
67  art::Ptr<recob::Hit> hit = cluster.at(ihit);
68  std::vector<art::Ptr<recob::SpacePoint> > sp = fmSPFromHits.at(ihit);
69 
70  std::vector<float> coordinates(3);
71  if (!sp.empty()) {
72  coordinates[0] = sp[0]->XYZ()[0];
73  coordinates[1] = sp[0]->XYZ()[1];
74  coordinates[2] = sp[0]->XYZ()[2];
75  if (coordinates[0] == -999) continue;
76  }
77 
78  std::vector<float> shifted_coordinates(3);
79  shifted_coordinates[0] = coordinates[0] - bound.Center(0) + bound.Length(0)/2;
80  shifted_coordinates[1] = coordinates[1] - bound.Center(1) + bound.Length(1)/2;
81  shifted_coordinates[2] = coordinates[2] - bound.Center(2) + bound.Length(2)/8;
82  //std::cout<<"HELLO ===> "<<shifted_coordinates[0];
83  //std::cout<<", "<<shifted_coordinates[1];
84  //std::cout<<", "<<shifted_coordinates[2]<<std::endl;
85 
86  float correctedHitCharge = (hit->Integral()*TMath::Exp((sampling_rate(clockData)*hit->PeakTime()) / (detProp.ElectronLifetime()*1.e3) ) );
87 
88  int hit_prong_tag = -1;
89  if (fmtrkhit.isValid() && fmtrkhit.at(ihit).size()!=0) {
90  hit_prong_tag = fmtrkhit.at(ihit)[0]->ID();
91  }
92 
93  pm.AddHit(shifted_coordinates[0], shifted_coordinates[1], shifted_coordinates[2], correctedHitCharge, hit_prong_tag);
94  }
95 
96  pm.Finish();
97 
98  return pm;
99  }
100 
102  detinfo::DetectorPropertiesData const& detProp,
104  art::FindManyP<recob::SpacePoint> const& fmSPFromHits,
105  art::FindManyP<recob::Shower> const& fmshwhit,
106  const std::vector<float> &vtx)
107  {
108 
109  RegCNNBoundary3D bound = Define3DBoundary(detProp, cluster, vtx);
110 
111  return Create3DMapGivenBoundaryBySP(clockData, detProp, cluster, bound, fmSPFromHits, fmshwhit, fCropped, fProngOnly);
112  }
113 
114 
116  detinfo::DetectorPropertiesData const& detProp,
118  const RegCNNBoundary3D& bound,
119  art::FindManyP<recob::SpacePoint> const& fmSPFromHits,
120  art::FindManyP<recob::Shower> const& fmshwhit,
121  const bool& Cropped,
122  const bool& ProngOnly)
123  {
124  std::cout<<"create 3D pixel maps, tag by Shower"<<std::endl;
125 
126  RegPixelMap3D pm(bound, Cropped, ProngOnly);
127 
128  if (!fmSPFromHits.isValid()) return pm;
129 
130  // Loop over hit
131  unsigned int nhits = cluster.size();
132  for (unsigned int ihit= 0; ihit< nhits; ++ihit) {
133  // Get hit
134  art::Ptr<recob::Hit> hit = cluster.at(ihit);
135  std::vector<art::Ptr<recob::SpacePoint> > sp = fmSPFromHits.at(ihit);
136 
137  std::vector<float> coordinates(3);
138  if (!sp.empty()) {
139  coordinates[0] = sp[0]->XYZ()[0];
140  coordinates[1] = sp[0]->XYZ()[1];
141  coordinates[2] = sp[0]->XYZ()[2];
142  if (coordinates[0] == -999) continue;
143  }
144 
145  std::vector<float> shifted_coordinates(3);
146  shifted_coordinates[0] = coordinates[0] - bound.Center(0) + bound.Length(0)/2;
147  shifted_coordinates[1] = coordinates[1] - bound.Center(1) + bound.Length(1)/2;
148  shifted_coordinates[2] = coordinates[2] - bound.Center(2) + bound.Length(2)/8;
149  //std::cout<<"HELLO ===> "<<shifted_coordinates[0];
150  //std::cout<<", "<<shifted_coordinates[1];
151  //std::cout<<", "<<shifted_coordinates[2]<<std::endl;
152 
153  float correctedHitCharge = (hit->Integral()*TMath::Exp((sampling_rate(clockData)*hit->PeakTime()) / (detProp.ElectronLifetime()*1.e3) ) );
154 
155  int hit_prong_tag = -1;
156  if (fmshwhit.isValid() && fmshwhit.at(ihit).size()!=0) {
157  hit_prong_tag = fmshwhit.at(ihit)[0]->ID();
158  }
159 
160  pm.AddHit(shifted_coordinates[0], shifted_coordinates[1], shifted_coordinates[2], correctedHitCharge, hit_prong_tag);
161  }
162 
163  pm.Finish();
164 
165  return pm;
166  }
167 
168 
169 
172  const std::vector<float> &vtx)
173  {
176  vtx[0], vtx[1], vtx[2]);
177 
178  return bound;
179  }
180 
181  std::ostream& operator<<(std::ostream& os, const RegPixelMap3DProducer& p)
182  {
183  os << "RegPixelMapProducer...... ";
184  return os;
185  }
186 
187 }
float Center(const unsigned int &axis) const
coordinates
Definition: geo_types.h:121
RegCNNBoundary3D Define3DBoundary(detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > const &cluster, const std::vector< float > &vtx)
Get boundaries for pixel map representation of cluster.
RegPixelMap3D Create3DMap(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > const &cluster, art::FindManyP< recob::SpacePoint > const &fmSPFromHits, art::FindManyP< recob::Track > const &fmtrkhit, const std::vector< float > &vtx)
Producer algorithm for RegPixelMap3D, input to CVN neural net.
RegPixelMap3DProducer(int nbinsX, int nbinsY, int nbinsZ, double XResolution, double YResolution, double ZResolution, bool Cropped, bool ProngOnly)
struct vector vector
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:224
Cluster finding and building.
RegPixelMap3D Create3DMapGivenBoundaryBySP(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > const &cluster, const RegCNNBoundary3D &bound, art::FindManyP< recob::SpacePoint > const &fmSPFromHits, art::FindManyP< recob::Track > const &fmtrkhit, const bool &Cropped, const bool &ProngOnly)
Collection of exceptions for Geometry system.
p
Definition: test.py:223
RegPixelMap3DProducer for RegCNN modified from PixelMapProducer.h.
Detector simulation of raw signals on wires.
Defines an enumeration for cellhit classification.
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
Contains all timing reference information for the detector.
void AddHit(float rel_x, float rel_y, float rel_z, float charge, int hit_prong_tag)
std::ostream & operator<<(std::ostream &os, const RegPixelMap3DProducer &p)
RegPixelMap3D, input to 3D CNN neural net.
Definition: RegPixelMap3D.h:22
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
double Length(const unsigned int &axis) const
QTextStream & endl(QTextStream &s)