All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
sbnd::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)
 
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 35 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.h.

Constructor & Destructor Documentation

sbnd::TPCGeoAlg::TPCGeoAlg ( )

Definition at line 6 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

6  {
7 
8  fMinX = 99999;
9  fMinY = 99999;
10  fMinZ = 99999;
11  fMaxX = -99999;
12  fMaxY = -99999;
13  fMaxZ = -99999;
14  fCpaWidth = 0;
15 
16  fGeometryService = lar::providerFrom<geo::Geometry>();
17 
18  for(size_t cryo_i = 0; cryo_i < fGeometryService->Ncryostats(); cryo_i++){
19  const geo::CryostatGeo& cryostat = fGeometryService->Cryostat(cryo_i);
20 
21  for (size_t tpc_i = 0; tpc_i < cryostat.NTPC(); tpc_i++)
22  {
23  const geo::TPCGeo& tpcg = cryostat.TPC(tpc_i);
24  if (tpcg.MinX() < fMinX) fMinX = tpcg.MinX();
25  if (tpcg.MaxX() > fMaxX) fMaxX = tpcg.MaxX();
26  if (tpcg.MinY() < fMinY) fMinY = tpcg.MinY();
27  if (tpcg.MaxY() > fMaxY) fMaxY = tpcg.MaxY();
28  if (tpcg.MinZ() < fMinZ) fMinZ = tpcg.MinZ();
29  if (tpcg.MaxZ() > fMaxZ) fMaxZ = tpcg.MaxZ();
30  fCpaWidth = std::min(std::abs(tpcg.MinX()), std::abs(tpcg.MaxX()));
31  }
32  }
33 }
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.
sbnd::TPCGeoAlg::~TPCGeoAlg ( )

Definition at line 36 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

36  {
37 
38 }

Member Function Documentation

double sbnd::TPCGeoAlg::CpaWidth ( ) const
bool sbnd::TPCGeoAlg::CrossesApa ( const simb::MCParticle &  particle)

Definition at line 236 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 216 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

216  {
217  bool enters = false;
218  bool startOutside = false;
219  bool endOutside = false;
220  for(size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
221  double x = particle.Vx(i);
222  double y = particle.Vy(i);
223  double z = particle.Vz(i);
224  if(x > fMinX && y > fMinY && z > fMinZ && x < fMaxX && y < fMaxY && z < fMaxZ){
225  enters = true;
226  }
227  else if(i == 0) startOutside = true;
228  else if(i == particle.NumberTrajectoryPoints()-1) endOutside = true;
229  }
230  if(startOutside && enters && endOutside) return true;
231  return false;
232 }
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 > sbnd::TPCGeoAlg::CrossingPoints ( const simb::MCParticle &  particle)

Definition at line 255 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

255  {
256  bool first = true;
257  TVector3 start (-99999, -99999, -99999);
258  TVector3 end (-99999, -99999, -99999);
259  for(size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
260  double x = particle.Vx(i);
261  double y = particle.Vy(i);
262  double z = particle.Vz(i);
263  if(x > fMinX && y > fMinY && z > fMinZ && x < fMaxX && y < fMaxY && z < fMaxZ){
264  if(first){
265  first = false;
266  start.SetXYZ(x, y, z);
267  }
268  end.SetXYZ(x, y, z);
269  }
270  }
271  return std::make_pair(start, end);
272 }
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 sbnd::TPCGeoAlg::DetectedInTPC ( std::vector< art::Ptr< recob::Hit >>  hits)

Definition at line 100 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 111 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 196 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 72 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 76 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 80 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 141 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

141  {
142  if(point.X() < (tpc.MinX()-buffer) || point.X() > (tpc.MaxX()+buffer)
143  || point.Y() < (tpc.MinY()-buffer) || point.Y() > (tpc.MaxY()+buffer)
144  || point.Z() < (tpc.MinZ()-buffer) || point.Z() > (tpc.MaxZ()+buffer)) return false;
145  return true;
146 }
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 sbnd::TPCGeoAlg::InVolume ( const simb::MCParticle &  particle)

Definition at line 168 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 182 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 149 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 274 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

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

Definition at line 127 of file sbndcode/sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.cc.

127  {
128  // If there are no hits then return 0
129  if(hits.size() == 0) return std::make_pair(0, 0);
130 
131  // If the track is stitched (in multiple TPCs) return 0
132  if(DetectedInTPC(hits) == -1) return std::make_pair(0, 0);
133 
134  // Work out the drift direction
135  geo::TPCID tpcID = hits[0]->WireID().asTPCID();
136  const geo::TPCGeo& tpcGeo = fGeometryService->GetElement(tpcID);
137  return std::make_pair(tpcGeo.MinX(), tpcGeo.MaxX());
138 }
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
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
int DetectedInTPC(std::vector< art::Ptr< recob::Hit >> hits)

Member Data Documentation

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

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