LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
sim::LArVoxelID Class Reference

#include "LArVoxelID.h"

Public Member Functions

 LArVoxelID (const int x=0, const int y=0, const int z=0, const int t=0)
 Expert constructor based on actual bins. More...
 
 LArVoxelID (const TLorentzVector &v)
 Standard constructors. More...
 
 LArVoxelID (const double x, const double y, const double z, const double t)
 
virtual ~LArVoxelID ()
 Destructor. More...
 
int XBin () const
 
int YBin () const
 
int ZBin () const
 
int TBin () const
 
double X () const
 
double Y () const
 
double Z () const
 
double T () const
 
double operator[] (const int) const
 
 operator TLorentzVector () const
 
 operator TVector3 () const
 
bool operator< (const LArVoxelID &) const
 
bool operator== (const LArVoxelID &) const
 Test for equality. Handy, but not usually necessary. More...
 

Private Attributes

std::vector< int > fbins
 

Friends

std::ostream & operator<< (std::ostream &output, const LArVoxelID &)
 

Detailed Description

Definition at line 54 of file LArVoxelID.h.

Constructor & Destructor Documentation

sim::LArVoxelID::LArVoxelID ( const int  x = 0,
const int  y = 0,
const int  z = 0,
const int  t = 0 
)

Expert constructor based on actual bins.

Definition at line 27 of file LArVoxelID.cxx.

References fbins, x, y, and z.

28  {
29  fbins = std::vector<int>(4);
30  fbins[0] = x;
31  fbins[1] = y;
32  fbins[2] = z;
33  fbins[3] = t;
34  }
Float_t x
Definition: compare.C:6
std::vector< int > fbins
Definition: LArVoxelID.h:84
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
sim::LArVoxelID::LArVoxelID ( const TLorentzVector &  v)
explicit

Standard constructors.

Definition at line 38 of file LArVoxelID.cxx.

References fbins.

39  {
40  // Copy each axis from the vector and convert it to a bin.
41  fbins = std::vector<int>(4);
43  for (Ssiz_t a = 0; a != 4; ++a) {
44  fbins[a] = voxelCalc->AxisToBin(a, coord[a]);
45  }
46  }
std::vector< int > fbins
Definition: LArVoxelID.h:84
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
sim::LArVoxelID::LArVoxelID ( const double  x,
const double  y,
const double  z,
const double  t 
)

Definition at line 49 of file LArVoxelID.cxx.

References fbins, sim::LArVoxelCalculator::TAxisToBin(), sim::LArVoxelCalculator::XAxisToBin(), sim::LArVoxelCalculator::YAxisToBin(), and sim::LArVoxelCalculator::ZAxisToBin().

50  {
52 
53  // Convert each axis into its corresponding bin.
54  fbins = std::vector<int>(4);
55  fbins[0] = voxelCalc->XAxisToBin(x);
56  fbins[1] = voxelCalc->YAxisToBin(y);
57  fbins[2] = voxelCalc->ZAxisToBin(z);
58  fbins[3] = voxelCalc->TAxisToBin(t);
59  }
Float_t x
Definition: compare.C:6
std::vector< int > fbins
Definition: LArVoxelID.h:84
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
int ZAxisToBin(const double value) const
int XAxisToBin(const double value) const
int TAxisToBin(const double value) const
int YAxisToBin(const double value) const
sim::LArVoxelID::~LArVoxelID ( )
virtual

Destructor.

Definition at line 63 of file LArVoxelID.cxx.

63 {}

Member Function Documentation

sim::LArVoxelID::operator TLorentzVector ( ) const

Definition at line 158 of file LArVoxelID.cxx.

References T(), X(), Y(), and Z().

159  {
160  return TLorentzVector(X(), Y(), Z(), T());
161  }
double Y() const
Definition: LArVoxelID.cxx:75
double Z() const
Definition: LArVoxelID.cxx:82
double X() const
Definition: LArVoxelID.cxx:68
double T() const
Definition: LArVoxelID.cxx:89
sim::LArVoxelID::operator TVector3 ( ) const

Definition at line 164 of file LArVoxelID.cxx.

References X(), Y(), and Z().

165  {
166  return TVector3(X(), Y(), Z());
167  }
double Y() const
Definition: LArVoxelID.cxx:75
double Z() const
Definition: LArVoxelID.cxx:82
double X() const
Definition: LArVoxelID.cxx:68
bool sim::LArVoxelID::operator< ( const LArVoxelID other) const

The comparison operator. This a key function, since it establishes the sort order of the voxels in a list.

Definition at line 123 of file LArVoxelID.cxx.

References fbins.

124  {
125  // What is a good sort order for voxels in the list? I'm not sure.
126  // For now, pick an ordering but be prepared to change it: sort by
127  // T, Z, X, then Y.
128 
129  if (fbins[3] < other.fbins[3]) return true;
130 
131  if (fbins[3] == other.fbins[3]) {
132  if (fbins[2] < other.fbins[2]) return true;
133 
134  if (fbins[2] == other.fbins[2]) {
135  if (fbins[0] < other.fbins[0]) return true;
136 
137  if (fbins[0] == other.fbins[0]) {
138  if (fbins[1] < other.fbins[1]) return true;
139  }
140  }
141  }
142 
143  return false;
144  }
std::vector< int > fbins
Definition: LArVoxelID.h:84
bool sim::LArVoxelID::operator== ( const LArVoxelID other) const

Test for equality. Handy, but not usually necessary.

Definition at line 148 of file LArVoxelID.cxx.

References fbins.

149  {
150  if (fbins[0] == other.fbins[0] && fbins[1] == other.fbins[1] && fbins[2] == other.fbins[2] &&
151  fbins[3] == other.fbins[3])
152  return true;
153 
154  return false;
155  }
std::vector< int > fbins
Definition: LArVoxelID.h:84
double sim::LArVoxelID::operator[] ( const int  i) const

Definition at line 96 of file LArVoxelID.cxx.

References T(), X(), Y(), and Z().

97  {
98  switch (i) {
99  case 0: return X(); break;
100  case 1: return Y(); break;
101  case 2: return Z(); break;
102  case 3: return T(); break;
103  }
104  // I suppose I should put some error processing here; for now
105  // I'll just return zero.
106  return 0;
107  }
double Y() const
Definition: LArVoxelID.cxx:75
double Z() const
Definition: LArVoxelID.cxx:82
double X() const
Definition: LArVoxelID.cxx:68
double T() const
Definition: LArVoxelID.cxx:89
double sim::LArVoxelID::T ( ) const

Definition at line 89 of file LArVoxelID.cxx.

References fbins, and sim::LArVoxelCalculator::TBinToAxis().

Referenced by operator TLorentzVector(), and operator[]().

90  {
92  return voxelCalc->TBinToAxis(fbins[3]);
93  }
std::vector< int > fbins
Definition: LArVoxelID.h:84
double TBinToAxis(const int value) const
int sim::LArVoxelID::TBin ( ) const
inline

Definition at line 141 of file LArVoxelID.h.

References fbins.

142 {
143  return fbins[3];
144 }
std::vector< int > fbins
Definition: LArVoxelID.h:84
double sim::LArVoxelID::X ( ) const

The accessors I expect to be used: The values of the co-ordinates at the bin centers.

Definition at line 68 of file LArVoxelID.cxx.

References fbins, and sim::LArVoxelCalculator::XBinToAxis().

Referenced by evdb_tool::DrawLArVoxel3D::Draw(), evd::SimulationDrawer::MCTruth3D(), evd::SimulationDrawer::MCTruthOrtho(), operator TLorentzVector(), operator TVector3(), and operator[]().

69  {
71  return voxelCalc->XBinToAxis(fbins[0]);
72  }
std::vector< int > fbins
Definition: LArVoxelID.h:84
double XBinToAxis(const int value) const
int sim::LArVoxelID::XBin ( ) const
inline

Definition at line 129 of file LArVoxelID.h.

References fbins.

130 {
131  return fbins[0];
132 }
std::vector< int > fbins
Definition: LArVoxelID.h:84
double sim::LArVoxelID::Y ( ) const
int sim::LArVoxelID::YBin ( ) const
inline

Definition at line 133 of file LArVoxelID.h.

References fbins.

134 {
135  return fbins[1];
136 }
std::vector< int > fbins
Definition: LArVoxelID.h:84
double sim::LArVoxelID::Z ( ) const
int sim::LArVoxelID::ZBin ( ) const
inline

Definition at line 137 of file LArVoxelID.h.

References fbins.

138 {
139  return fbins[2];
140 }
std::vector< int > fbins
Definition: LArVoxelID.h:84

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  output,
const LArVoxelID id 
)
friend

Put the contents on the output stream. We have a choice: write the bin number, or write the position represented by the bins. For now, let's pick writing the positions.

Definition at line 113 of file LArVoxelID.cxx.

114  {
115  output << "(" << id.X() << "," << id.Y() << "," << id.Z() << "," << id.T() << ")";
116 
117  return output;
118  }

Member Data Documentation

std::vector<int> sim::LArVoxelID::fbins
private

Definition at line 84 of file LArVoxelID.h.

Referenced by LArVoxelID(), operator<(), operator==(), T(), TBin(), X(), XBin(), Y(), YBin(), Z(), and ZBin().


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