LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
LArVoxelID.cxx
Go to the documentation of this file.
1 
11 
15 
19 #include <TLorentzVector.h>
20 
21 #include <iostream>
22 
23 namespace sim {
24 
25  //----------------------------------------------------------------------------
28  const int y,
29  const int z,
30  const int t )
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  }
39 
40  //----------------------------------------------------------------------------
42  LArVoxelID::LArVoxelID( const TLorentzVector& coord )
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  }
51 
52  //----------------------------------------------------------------------------
53  LArVoxelID::LArVoxelID( const double x, const double y, const double z, const double t )
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  }
64 
65  //----------------------------------------------------------------------------
68 
69  //----------------------------------------------------------------------------
72  double LArVoxelID::X() const
73  {
75  return voxelCalc->XBinToAxis(fbins[0]);
76  }
77 
78  //----------------------------------------------------------------------------
79  double LArVoxelID::Y() const
80  {
82  return voxelCalc->YBinToAxis(fbins[1]);
83  }
84 
85  //----------------------------------------------------------------------------
86  double LArVoxelID::Z() const
87  {
89  return voxelCalc->ZBinToAxis(fbins[2]);
90  }
91 
92  //----------------------------------------------------------------------------
93  double LArVoxelID::T() const
94  {
96  return voxelCalc->TBinToAxis(fbins[3]);
97  }
98 
99  //----------------------------------------------------------------------------
100  double LArVoxelID::operator[]( const int i ) const
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  }
116 
117  //----------------------------------------------------------------------------
121  std::ostream& operator<< ( std::ostream& output, const LArVoxelID& id )
122  {
123  output << "(" << id.X()
124  << "," << id.Y()
125  << "," << id.Z()
126  << "," << id.T()
127  << ")";
128 
129  return output;
130  }
131 
132  //----------------------------------------------------------------------------
135  bool LArVoxelID::operator<( const LArVoxelID& other ) const
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  }
157 
158  //----------------------------------------------------------------------------
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  }
170 
171  //----------------------------------------------------------------------------
172  LArVoxelID::operator TLorentzVector() const
173  {
174  return TLorentzVector( X(), Y(), Z(), T() );
175  }
176 
177  //----------------------------------------------------------------------------
178  LArVoxelID::operator TVector3() const
179  {
180  return TVector3( X(), Y(), Z() );
181  }
182 
183 
184 } // namespace sim
Float_t x
Definition: compare.C:6
std::vector< int > fbins
Definition: LArVoxelID.h:91
LArVoxelID(const int x=0, const int y=0, const int z=0, const int t=0)
Expert constructor based on actual bins.
Definition: LArVoxelID.cxx:27
double YBinToAxis(const int value) const
Encapsulates calculation of LArVoxelID and LArVoxel parameters.
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
bool operator<(const LArVoxelID &) const
Definition: LArVoxelID.cxx:135
int ZAxisToBin(const double value) const
double operator[](const int) const
Definition: LArVoxelID.cxx:100
virtual ~LArVoxelID()
Destructor.
Definition: LArVoxelID.cxx:67
double TBinToAxis(const int value) const
int XAxisToBin(const double value) const
double Y() const
Definition: LArVoxelID.cxx:79
int TAxisToBin(const double value) const
bool operator==(const LArVoxelID &) const
Test for equality. Handy, but not usually necessary.
Definition: LArVoxelID.cxx:160
friend std::ostream & operator<<(std::ostream &output, const LArVoxelID &)
Definition: LArVoxelID.cxx:121
Monte Carlo Simulation.
double Z() const
Definition: LArVoxelID.cxx:86
double X() const
Definition: LArVoxelID.cxx:72
double XBinToAxis(const int value) const
double T() const
Definition: LArVoxelID.cxx:93
double ZBinToAxis(const int value) const
Unique identifier for a given LAr voxel.
int YAxisToBin(const double value) const