All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArVoxelID.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file LArVoxelID.h
3 /// \brief Unique identifier for a given LAr voxel.
4 ///
5 /// \author seligman@nevis.columbia.edu
6 ////////////////////////////////////////////////////////////////////////
7 
8 /// This class defines a unique identifier for a given volume element
9 /// ("voxel") in the LAr volume. It is sortable, can be tested for
10 /// equality, and is persistent under ROOT I/O.
11 
12 /// (Actually, the term "voxel" is a mis-nomer, since we're also
13 /// keeping track of the time slice. What's a four-dimensional volume
14 /// element? A "tesseract element or "tessel"?)
15 
18 #include "art/Framework/Services/Registry/ServiceHandle.h"
19 #include <TLorentzVector.h>
20 
21 #include <ostream>
22 
23 namespace sim {
24 
25  //----------------------------------------------------------------------------
26  /// Expert constructor based on actual bins.
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  //----------------------------------------------------------------------------
41  /// Standard constructors.
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);
46  art::ServiceHandle<sim::LArVoxelCalculator const> voxelCalc;
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  {
55  art::ServiceHandle<sim::LArVoxelCalculator const> voxelCalc;
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  //----------------------------------------------------------------------------
66  /// Destructor.
68 
69  //----------------------------------------------------------------------------
70  /// The accessors I expect to be used: The values of the
71  /// co-ordinates at the bin centers.
72  double LArVoxelID::X() const
73  {
74  art::ServiceHandle<sim::LArVoxelCalculator const> voxelCalc;
75  return voxelCalc->XBinToAxis(fbins[0]);
76  }
77 
78  //----------------------------------------------------------------------------
79  double LArVoxelID::Y() const
80  {
81  art::ServiceHandle<sim::LArVoxelCalculator const> voxelCalc;
82  return voxelCalc->YBinToAxis(fbins[1]);
83  }
84 
85  //----------------------------------------------------------------------------
86  double LArVoxelID::Z() const
87  {
88  art::ServiceHandle<sim::LArVoxelCalculator const> voxelCalc;
89  return voxelCalc->ZBinToAxis(fbins[2]);
90  }
91 
92  //----------------------------------------------------------------------------
93  double LArVoxelID::T() const
94  {
95  art::ServiceHandle<sim::LArVoxelCalculator const> voxelCalc;
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  //----------------------------------------------------------------------------
118  /// Put the contents on the output stream. We have a choice: write
119  /// the bin number, or write the position represented by the bins.
120  /// For now, let's pick writing the positions.
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  //----------------------------------------------------------------------------
133  /// The comparison operator. This a key function, since it
134  /// establishes the sort order of the voxels in a list.
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  //----------------------------------------------------------------------------
159  /// Test for equality. Handy, but not usually necessary.
160  bool LArVoxelID::operator==( const LArVoxelID& other ) const
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
std::vector< int > fbins
Definition: LArVoxelID.h:91
process_name opflash particleana ie ie ie z
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
process_name opflash particleana ie x
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.
bool operator<(const LArVoxelID &) const
Definition: LArVoxelID.cxx:135
double operator[](const int) const
Definition: LArVoxelID.cxx:100
virtual ~LArVoxelID()
Destructor.
Definition: LArVoxelID.cxx:67
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
process_name gaushit a
process_name opflash particleana ie ie y
double Y() const
Definition: LArVoxelID.cxx:79
bool operator==(const LArVoxelID &) const
Test for equality. Handy, but not usually necessary.
Definition: LArVoxelID.cxx:160
double Z() const
Definition: LArVoxelID.cxx:86
double X() const
Definition: LArVoxelID.cxx:72
double T() const
Definition: LArVoxelID.cxx:93
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
std::ostream & operator<<(std::ostream &output, const LArVoxelData &data)
Unique identifier for a given LAr voxel.