All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
sbn::TPCGeoAlg Class Reference

#include <TPCGeoAlg.h>

Public Member Functions

 TPCGeoAlg ()
 
 ~TPCGeoAlg ()
 
double MinX () const
 
double MinY () const
 
double MinZ () const
 
double MaxX () const
 
double MaxY () const
 
double MaxZ () const
 
double CpaWidth () const
 
bool InFiducial (geo::Point_t point, double fiducial)
 
bool InFiducial (geo::Point_t point, double fiducial, double fiducialTop)
 
bool InFiducial (geo::Point_t point, double minXCut, double minYCut, double minZCut, double maxXCut, double maxYCut, double maxZCut)
 
bool InsideTPC (geo::Point_t point, const geo::TPCGeo &tpc, double buffer=0.)
 
int DetectedInTPC (std::vector< art::Ptr< recob::Hit >> hits)
 
int DriftDirectionFromHits (std::vector< art::Ptr< recob::Hit >> hits)
 
std::pair< double, double > XLimitsFromHits (std::vector< art::Ptr< recob::Hit >> hits)
 
double MinDistToWall (geo::Point_t point) const
 
bool InVolume (const simb::MCParticle &particle)
 
bool IsContained (const simb::MCParticle &particle)
 
bool EntersVolume (const simb::MCParticle &particle)
 
bool CrossesVolume (const simb::MCParticle &particle)
 
bool CrossesApa (const simb::MCParticle &particle)
 
std::pair< TVector3, TVector3 > CrossingPoints (const simb::MCParticle &particle)
 
double TpcLength (const simb::MCParticle &particle)
 

Private Attributes

double fMinX
 
double fMinY
 
double fMinZ
 
double fMaxX
 
double fMaxY
 
double fMaxZ
 
double fCpaWidth
 
geo::GeometryCore const * fGeometryService
 

Detailed Description

Definition at line 36 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.h.

Constructor & Destructor Documentation

sbn::TPCGeoAlg::TPCGeoAlg ( )

Definition at line 7 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

7  {
8 
9  fMinX = 99999;
10  fMinY = 99999;
11  fMinZ = 99999;
12  fMaxX = -99999;
13  fMaxY = -99999;
14  fMaxZ = -99999;
15  fCpaWidth = 0;
16 
17  fGeometryService = lar::providerFrom<geo::Geometry>();
18 
19  for(size_t cryo_i = 0; cryo_i < fGeometryService->Ncryostats(); cryo_i++){
20  const geo::CryostatGeo& cryostat = fGeometryService->Cryostat(cryo_i);
21 
22  for (size_t tpc_i = 0; tpc_i < cryostat.NTPC(); tpc_i++)
23  {
24  const geo::TPCGeo& tpcg = cryostat.TPC(tpc_i);
25  if (tpcg.MinX() < fMinX) fMinX = tpcg.MinX();
26  if (tpcg.MaxX() > fMaxX) fMaxX = tpcg.MaxX();
27  if (tpcg.MinY() < fMinY) fMinY = tpcg.MinY();
28  if (tpcg.MaxY() > fMaxY) fMaxY = tpcg.MaxY();
29  if (tpcg.MinZ() < fMinZ) fMinZ = tpcg.MinZ();
30  if (tpcg.MaxZ() > fMaxZ) fMaxZ = tpcg.MaxZ();
31  fCpaWidth = std::min(std::abs(tpcg.MinX()), std::abs(tpcg.MaxX()));
32  }
33  }
34 }
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
Geometry information for a single TPC.
Definition: TPCGeo.h:38
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
T abs(T value)
double MinZ() const
Returns the world z coordinate of the start of the box.
unsigned int NTPC() const
Number of TPCs in this cryostat.
Definition: CryostatGeo.h:181
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
double MaxY() const
Returns the world y coordinate of the end of the box.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:93
double MaxZ() const
Returns the world z coordinate of the end of the box.
double MinY() const
Returns the world y coordinate of the start of the box.
geo::GeometryCore const * fGeometryService
sbn::TPCGeoAlg::~TPCGeoAlg ( )

Definition at line 37 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

37  {
38 
39 }

Member Function Documentation

double sbn::TPCGeoAlg::CpaWidth ( ) const

Definition at line 67 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

67  {
68  return fCpaWidth;
69 }
bool sbn::TPCGeoAlg::CrossesApa ( const simb::MCParticle &  particle)

Definition at line 237 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

237  {
238  for(size_t i = 0; i < particle.NumberTrajectoryPoints()-1; i++){
239  double x = particle.Vx(i);
240  double y = particle.Vy(i);
241  double z = particle.Vz(i);
242  double x1 = particle.Vx(i+1);
243  double y1 = particle.Vy(i+1);
244  double z1 = particle.Vz(i+1);
245  if(y >= fMinY && z >= fMinZ && y <= fMaxY && z <= fMaxZ
246  && y1 >= fMinY && z1 >= fMinZ && y1 <= fMaxY && z1 <= fMaxZ){
247  if(x <= fMinX && x1 >= fMinX) return true;
248  if(x >= fMinX && x1 <= fMinX) return true;
249  if(x <= fMaxX && x1 >= fMaxX) return true;
250  if(x >= fMaxX && x1 <= fMaxX) return true;
251  }
252  }
253  return false;
254 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
process_name opflash particleana ie ie y
bool sbn::TPCGeoAlg::CrossesVolume ( const simb::MCParticle &  particle)

Definition at line 217 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

217  {
218  bool enters = false;
219  bool startOutside = false;
220  bool endOutside = false;
221  for(size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
222  double x = particle.Vx(i);
223  double y = particle.Vy(i);
224  double z = particle.Vz(i);
225  if(x > fMinX && y > fMinY && z > fMinZ && x < fMaxX && y < fMaxY && z < fMaxZ){
226  enters = true;
227  }
228  else if(i == 0) startOutside = true;
229  else if(i == particle.NumberTrajectoryPoints()-1) endOutside = true;
230  }
231  if(startOutside && enters && endOutside) return true;
232  return false;
233 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
process_name opflash particleana ie ie y
std::pair< TVector3, TVector3 > sbn::TPCGeoAlg::CrossingPoints ( const simb::MCParticle &  particle)

Definition at line 256 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

256  {
257  bool first = true;
258  TVector3 start (-99999, -99999, -99999);
259  TVector3 end (-99999, -99999, -99999);
260  for(size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
261  double x = particle.Vx(i);
262  double y = particle.Vy(i);
263  double z = particle.Vz(i);
264  if(x > fMinX && y > fMinY && z > fMinZ && x < fMaxX && y < fMaxY && z < fMaxZ){
265  if(first){
266  first = false;
267  start.SetXYZ(x, y, z);
268  }
269  end.SetXYZ(x, y, z);
270  }
271  }
272  return std::make_pair(start, end);
273 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
process_name opflash particleana ie ie y
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
int sbn::TPCGeoAlg::DetectedInTPC ( std::vector< art::Ptr< recob::Hit >>  hits)

Definition at line 101 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

101  {
102  // Return tpc of hit collection or -1 if in multiple
103  if(hits.size() == 0) return -1;
104  int tpc = hits[0]->WireID().TPC;
105  for(size_t i = 0; i < hits.size(); i++){
106  if((int)hits[i]->WireID().TPC != tpc) return -1;
107  }
108  return tpc;
109 }
int sbn::TPCGeoAlg::DriftDirectionFromHits ( std::vector< art::Ptr< recob::Hit >>  hits)

Definition at line 112 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

112  {
113  // If there are no hits then return 0
114  if(hits.size() == 0) return 0;
115 
116  // If the track is stitched (in multiple TPCs) return 0
117  if(DetectedInTPC(hits) == -1) return 0;
118 
119  // Work out the drift direction
120  geo::TPCID tpcID = hits[0]->WireID().asTPCID();
121  const geo::TPCGeo& tpcGeo = fGeometryService->GetElement(tpcID);
122  double driftDirection = tpcGeo.DetectDriftDirection();
123  if(std::abs(driftDirection) != 1) driftDirection = 0;
124  return driftDirection;
125 }
CryostatGeo const & GetElement(geo::CryostatID const &cryoid) const
Geometry information for a single TPC.
Definition: TPCGeo.h:38
T abs(T value)
int DetectedInTPC(std::vector< art::Ptr< recob::Hit >> hits)
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
short int DetectDriftDirection() const
Returns the expected drift direction based on geometry.
Definition: TPCGeo.cxx:157
geo::GeometryCore const * fGeometryService
bool sbn::TPCGeoAlg::EntersVolume ( const simb::MCParticle &  particle)

Definition at line 197 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

197  {
198  bool enters = false;
199  bool startOutside = false;
200  bool endOutside = false;
201  for(size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
202  double x = particle.Vx(i);
203  double y = particle.Vy(i);
204  double z = particle.Vz(i);
205  if(x > fMinX && y > fMinY && z > fMinZ && x < fMaxX && y < fMaxY && z < fMaxZ){
206  enters = true;
207  }
208  else if(i == 0) startOutside = true;
209  else if(i == particle.NumberTrajectoryPoints()-1) endOutside = true;
210  }
211  if(enters && (startOutside || endOutside)) return true;
212  return false;
213 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
process_name opflash particleana ie ie y
bool sbn::TPCGeoAlg::InFiducial ( geo::Point_t  point,
double  fiducial 
)

Definition at line 73 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

73  {
74  return InFiducial(point, fiducial, fiducial);
75 }
bool InFiducial(geo::Point_t point, double fiducial)
bool sbn::TPCGeoAlg::InFiducial ( geo::Point_t  point,
double  fiducial,
double  fiducialTop 
)

Definition at line 77 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

77  {
78  return InFiducial(point, fiducial, fiducial, fiducial, fiducial, fiducialTop, fiducial);
79 }
bool InFiducial(geo::Point_t point, double fiducial)
bool sbn::TPCGeoAlg::InFiducial ( geo::Point_t  point,
double  minXCut,
double  minYCut,
double  minZCut,
double  maxXCut,
double  maxYCut,
double  maxZCut 
)

Definition at line 81 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

82  {
83 
84  double xmin = fMinX + minXCut;
85  double xmax = fMaxX - maxXCut;
86  double ymin = fMinY + minYCut;
87  double ymax = fMaxY - maxYCut;
88  double zmin = fMinZ + minZCut;
89  double zmax = fMaxZ - maxZCut;
90 
91  double x = point.X();
92  double y = point.Y();
93  double z = point.Z();
94  if(x>xmin && x<xmax && y>ymin && y<ymax && z>zmin && z<zmax) return true;
95 
96  return false;
97 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
process_name opflash particleana ie ie y
bool sbn::TPCGeoAlg::InsideTPC ( geo::Point_t  point,
const geo::TPCGeo tpc,
double  buffer = 0. 
)

Definition at line 142 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

142  {
143  if(point.X() < (tpc.MinX()-buffer) || point.X() > (tpc.MaxX()+buffer)
144  || point.Y() < (tpc.MinY()-buffer) || point.Y() > (tpc.MaxY()+buffer)
145  || point.Z() < (tpc.MinZ()-buffer) || point.Z() > (tpc.MaxZ()+buffer)) return false;
146  return true;
147 }
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxY() const
Returns the world y coordinate of the end of the box.
double MaxZ() const
Returns the world z coordinate of the end of the box.
double MinY() const
Returns the world y coordinate of the start of the box.
bool sbn::TPCGeoAlg::InVolume ( const simb::MCParticle &  particle)

Definition at line 169 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

169  {
170  for(size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
171  double x = particle.Vx(i);
172  double y = particle.Vy(i);
173  double z = particle.Vz(i);
174  if(x > fMinX && y > fMinY && z > fMinZ && x < fMaxX && y < fMaxY && z < fMaxZ){
175  return true;
176  }
177  }
178  return false;
179 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
process_name opflash particleana ie ie y
bool sbn::TPCGeoAlg::IsContained ( const simb::MCParticle &  particle)

Definition at line 183 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

183  {
184  for(size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
185  double x = particle.Vx(i);
186  double y = particle.Vy(i);
187  double z = particle.Vz(i);
188  if(x < fMinX || y < fMinY || z < fMinZ || x > fMaxX || y > fMaxY || z > fMaxZ){
189  return false;
190  }
191  }
192  return true;
193 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
process_name opflash particleana ie ie y
double sbn::TPCGeoAlg::MaxX ( ) const

Definition at line 55 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

55  {
56  return fMaxX;
57 }
double sbn::TPCGeoAlg::MaxY ( ) const

Definition at line 59 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

59  {
60  return fMaxY;
61 }
double sbn::TPCGeoAlg::MaxZ ( ) const

Definition at line 63 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

63  {
64  return fMaxZ;
65 }
double sbn::TPCGeoAlg::MinDistToWall ( geo::Point_t  point) const

Definition at line 150 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

150  {
151 
152  std::vector<double> dists;
153 
154  dists.push_back(std::abs(point.X() - fMinX));
155  dists.push_back(std::abs(point.X() - fMaxX));
156  dists.push_back(std::abs(point.Y() - fMinY));
157  dists.push_back(std::abs(point.Y() - fMaxY));
158  dists.push_back(std::abs(point.Z() - fMinZ));
159  dists.push_back(std::abs(point.Z() - fMaxZ));
160 
161  std::sort(dists.begin(), dists.end());
162 
163  return dists[0];
164 
165 }
T abs(T value)
double sbn::TPCGeoAlg::MinX ( ) const

Definition at line 43 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

43  {
44  return fMinX;
45 }
double sbn::TPCGeoAlg::MinY ( ) const

Definition at line 47 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

47  {
48  return fMinY;
49 }
double sbn::TPCGeoAlg::MinZ ( ) const

Definition at line 51 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

51  {
52  return fMinZ;
53 }
double sbn::TPCGeoAlg::TpcLength ( const simb::MCParticle &  particle)

Definition at line 275 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

275  {
276  bool first = true;
277  double length = 0;
278  TVector3 point, disp;
279  for(size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
280  double x = particle.Vx(i);
281  double y = particle.Vy(i);
282  double z = particle.Vz(i);
283  if(x > fMinX && y > fMinY && z > fMinZ && x < fMaxX && y < fMaxY && z < fMaxZ){
284  point.SetXYZ(x, y, z);
285  if(!first){
286  disp -= point;
287  length += disp.Mag();
288  }
289  first = false;
290  disp = point;
291  }
292  }
293  return length;
294 }
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
process_name opflash particleana ie ie y
std::pair< double, double > sbn::TPCGeoAlg::XLimitsFromHits ( std::vector< art::Ptr< recob::Hit >>  hits)

Definition at line 128 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.cc.

128  {
129  // If there are no hits then return 0
130  if(hits.size() == 0) return std::make_pair(0, 0);
131 
132  // If the track is stitched (in multiple TPCs) return 0
133  if(DetectedInTPC(hits) == -1) return std::make_pair(0, 0);
134 
135  // Work out the drift direction
136  geo::TPCID tpcID = hits[0]->WireID().asTPCID();
137  const geo::TPCGeo& tpcGeo = fGeometryService->GetElement(tpcID);
138  return std::make_pair(tpcGeo.MinX(), tpcGeo.MaxX());
139 }
CryostatGeo const & GetElement(geo::CryostatID const &cryoid) const
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
Geometry information for a single TPC.
Definition: TPCGeo.h:38
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
int DetectedInTPC(std::vector< art::Ptr< recob::Hit >> hits)
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
geo::GeometryCore const * fGeometryService

Member Data Documentation

double sbn::TPCGeoAlg::fCpaWidth
private

Definition at line 92 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.h.

geo::GeometryCore const* sbn::TPCGeoAlg::fGeometryService
private

Definition at line 94 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.h.

double sbn::TPCGeoAlg::fMaxX
private

Definition at line 89 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.h.

double sbn::TPCGeoAlg::fMaxY
private

Definition at line 90 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.h.

double sbn::TPCGeoAlg::fMaxZ
private

Definition at line 91 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.h.

double sbn::TPCGeoAlg::fMinX
private

Definition at line 86 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.h.

double sbn::TPCGeoAlg::fMinY
private

Definition at line 87 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.h.

double sbn::TPCGeoAlg::fMinZ
private

Definition at line 88 of file sbncode/sbncode/GeometryTools/TPCGeoAlg.h.


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