LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArVoxelCalculator.cc
Go to the documentation of this file.
1 
11 
16 
17 // Framework includes
19 
20 #include "fhiclcpp/ParameterSet.h"
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  //----------------------------------------------------------------------------
43  {
44  return std::min(m_voxelSize[0], std::min(m_voxelSize[1], m_voxelSize[2]));
45  }
46 
47  //----------------------------------------------------------------------------
51  int LArVoxelCalculator::AxisToBin(const int axis, const double coord) const
52  {
53  // We have to be careful of how to handle the case when coord -
54  // offset < 0. The standard floor() function rounds the number in
55  // the correct direction.
56  return static_cast<int>(floor((coord - m_voxelOffset[axis]) / m_voxelSize[axis]));
57  }
58 
59  //----------------------------------------------------------------------------
63  double LArVoxelCalculator::BinToAxis(const int axis, const int bin) const
64  {
65  return (static_cast<double>(bin) + 0.5) * m_voxelSize[axis] + m_voxelOffset[axis];
66  }
67 
68 } // namespace sim
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:314
double SuggestedStepSize() const
float bin[41]
Definition: plottest35.C:14
Monte Carlo Simulation.
int AxisToBin(const int, const double) const
double BinToAxis(const int, const int) const
LArVoxelCalculator(fhicl::ParameterSet const &pset)