LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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.

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

Standard constructors.

Definition at line 42 of file LArVoxelID.cxx.

References fbins.

43  {
44  // Copy each axis from the vector and convert it to a bin.
45  fbins = std::vector<int>(4);
47  for ( Ssiz_t a = 0; a != 4; ++a ){
48  fbins[a] = voxelCalc->AxisToBin( a, coord[a] );
49  }
50  }
std::vector< int > fbins
Definition: LArVoxelID.h:91
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 53 of file LArVoxelID.cxx.

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

54  {
56 
57  // Convert each axis into its corresponding bin.
58  fbins = std::vector<int>(4);
59  fbins[0] = voxelCalc->XAxisToBin( x );
60  fbins[1] = voxelCalc->YAxisToBin( y );
61  fbins[2] = voxelCalc->ZAxisToBin( z );
62  fbins[3] = voxelCalc->TAxisToBin( t );
63  }
Float_t x
Definition: compare.C:6
std::vector< int > fbins
Definition: LArVoxelID.h:91
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
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 67 of file LArVoxelID.cxx.

67 {}

Member Function Documentation

sim::LArVoxelID::operator TLorentzVector ( ) const

Definition at line 172 of file LArVoxelID.cxx.

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

173  {
174  return TLorentzVector( X(), Y(), Z(), T() );
175  }
double Y() const
Definition: LArVoxelID.cxx:79
double Z() const
Definition: LArVoxelID.cxx:86
double X() const
Definition: LArVoxelID.cxx:72
double T() const
Definition: LArVoxelID.cxx:93
sim::LArVoxelID::operator TVector3 ( ) const

Definition at line 178 of file LArVoxelID.cxx.

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

179  {
180  return TVector3( X(), Y(), Z() );
181  }
double Y() const
Definition: LArVoxelID.cxx:79
double Z() const
Definition: LArVoxelID.cxx:86
double X() const
Definition: LArVoxelID.cxx:72
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 135 of file LArVoxelID.cxx.

References fbins.

136  {
137  // What is a good sort order for voxels in the list? I'm not sure.
138  // For now, pick an ordering but be prepared to change it: sort by
139  // T, Z, X, then Y.
140 
141  if ( fbins[3] < other.fbins[3] ) return true;
142 
143  if ( fbins[3] == other.fbins[3] ){
144  if ( fbins[2] < other.fbins[2] ) return true;
145 
146  if ( fbins[2] == other. fbins[2] ){
147  if ( fbins[0] < other.fbins[0] ) return true;
148 
149  if ( fbins[0] == other.fbins[0] ){
150  if ( fbins[1] < other.fbins[1] ) return true;
151  }
152  }
153  }
154 
155  return false;
156  }
std::vector< int > fbins
Definition: LArVoxelID.h:91
bool sim::LArVoxelID::operator== ( const LArVoxelID other) const

Test for equality. Handy, but not usually necessary.

Definition at line 160 of file LArVoxelID.cxx.

References fbins.

161  {
162  if ( fbins[0] == other.fbins[0] &&
163  fbins[1] == other.fbins[1] &&
164  fbins[2] == other.fbins[2] &&
165  fbins[3] == other.fbins[3] )
166  return true;
167 
168  return false;
169  }
std::vector< int > fbins
Definition: LArVoxelID.h:91
double sim::LArVoxelID::operator[] ( const int  i) const

Definition at line 100 of file LArVoxelID.cxx.

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

101  {
102  switch (i){
103  case 0:
104  return X(); break;
105  case 1:
106  return Y(); break;
107  case 2:
108  return Z(); break;
109  case 3:
110  return T(); break;
111  }
112  // I suppose I should put some error processing here; for now
113  // I'll just return zero.
114  return 0;
115  }
double Y() const
Definition: LArVoxelID.cxx:79
double Z() const
Definition: LArVoxelID.cxx:86
double X() const
Definition: LArVoxelID.cxx:72
double T() const
Definition: LArVoxelID.cxx:93
double sim::LArVoxelID::T ( ) const

Definition at line 93 of file LArVoxelID.cxx.

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

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

94  {
96  return voxelCalc->TBinToAxis(fbins[3]);
97  }
std::vector< int > fbins
Definition: LArVoxelID.h:91
double TBinToAxis(const int value) const
int sim::LArVoxelID::TBin ( ) const
inline

Definition at line 146 of file LArVoxelID.h.

References fbins.

146 { return fbins[3]; }
std::vector< int > fbins
Definition: LArVoxelID.h:91
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 72 of file LArVoxelID.cxx.

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

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

73  {
75  return voxelCalc->XBinToAxis(fbins[0]);
76  }
std::vector< int > fbins
Definition: LArVoxelID.h:91
double XBinToAxis(const int value) const
int sim::LArVoxelID::XBin ( ) const
inline

Definition at line 143 of file LArVoxelID.h.

References fbins.

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

Definition at line 144 of file LArVoxelID.h.

References fbins.

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

Definition at line 145 of file LArVoxelID.h.

References fbins.

145 { return fbins[2]; }
std::vector< int > fbins
Definition: LArVoxelID.h:91

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 121 of file LArVoxelID.cxx.

122  {
123  output << "(" << id.X()
124  << "," << id.Y()
125  << "," << id.Z()
126  << "," << id.T()
127  << ")";
128 
129  return output;
130  }

Member Data Documentation

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

Definition at line 91 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: