LArVoxelCalculator_service.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file LArVoxelCalculator_service.cc
3 /// \brief Encapsulates calculation of LArVoxelID and LArVoxel parameters
4 ///
5 /// \author brebel@fnal.gov
6 ////////////////////////////////////////////////////////////////////////
7 
8 /// This service encapsulates the calculations associated with
9 /// computing the LArVoxelID, and provides access to the any LArVoxel
10 /// parameters from the input file(s).
11 
12 /// Definition: "Voxels" are three-dimensional "pixels"; basically
13 /// they divide the energy deposition in the LAr into (x,y,z) cubes.
14 /// Well, hyper-cubes actually, since we have to potentially include
15 /// divisions in time as well.
16 
17 // Framework includes
19 
21 
22 #include <cmath>
23 
24 namespace sim {
25 
26  //----------------------------------------------------------------------------
28  : m_voxelSize{pset.get<double>("VoxelSizeX"),
29  pset.get<double>("VoxelSizeY"),
30  pset.get<double>("VoxelSizeZ"),
31  pset.get<double>("VoxelSizeT")}
32  , m_voxelOffset{pset.get<double>("VoxelOffsetX"),
33  pset.get<double>("VoxelOffsetY"),
34  pset.get<double>("VoxelOffsetZ"),
35  pset.get<double>("VoxelOffsetT")}
36  , m_energyCut{pset.get<double>("VoxelEnergyCut")}
37  {}
38 
39  //----------------------------------------------------------------------------
40  /// Returns a Monte-Carlo step size that's reasonable to use so that
41  /// each segment of a track will be contained within a single voxel.
43  {
44  return std::min( m_voxelSize[0], std::min( m_voxelSize[1], m_voxelSize[2] ) );
45  }
46 
47  //----------------------------------------------------------------------------
48  /// Convert a co-ordinate axis (x, y, z, or t) into a bin number.
49  /// The first argument is the axis (x=0, y=1, z=2, t=3) and the
50  /// second is the value on that axis.
51  int LArVoxelCalculator::AxisToBin( const int axis,
52  const double coord ) const
53  {
54  // We have to be careful of how to handle the case when coord -
55  // offset < 0. The standard floor() function rounds the number in
56  // the correct direction.
57  return static_cast<int>( floor( ( coord - m_voxelOffset[axis] ) / m_voxelSize[axis] ) );
58  }
59 
60  //----------------------------------------------------------------------------
61  /// Get the value of an axis at the center of the given bin. The
62  /// first argument is the axis (x=0, y=1, z=2, t=3) and the second
63  /// is the bin number on that axis.
64  double LArVoxelCalculator::BinToAxis( const int axis,
65  const int bin ) const
66  {
67  return ( static_cast<double>(bin) + 0.5 ) * m_voxelSize[axis] + m_voxelOffset[axis];
68  }
69 
70 } // namespace sim
71 
vector_type const m_voxelOffset
vector_type const m_voxelSize
The sizes of the voxels in (x,y,z,t). Units are (mm,ns).
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.
T get(std::string const &key) const
Definition: ParameterSet.h:271
Code to link reconstructed objects back to the MC truth information.
#define DEFINE_ART_SERVICE(svc)
int AxisToBin(const int, const double) const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
double BinToAxis(const int, const int) const
QTextStream & bin(QTextStream &s)
LArVoxelCalculator(fhicl::ParameterSet const &pset)