Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larsim
larsim
Simulation
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
18
#include "
art/Framework/Services/Registry/ServiceDefinitionMacros.h
"
19
20
#include "
larsim/Simulation/LArVoxelCalculator.h
"
21
22
#include <cmath>
23
24
namespace
sim
{
25
26
//----------------------------------------------------------------------------
27
LArVoxelCalculator::LArVoxelCalculator
(
fhicl::ParameterSet
const
& pset)
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.
42
double
LArVoxelCalculator::SuggestedStepSize
()
const
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
72
DEFINE_ART_SERVICE
(
sim::LArVoxelCalculator
)
sim::LArVoxelCalculator::m_voxelOffset
vector_type const m_voxelOffset
Definition:
LArVoxelCalculator.h:86
sim::LArVoxelCalculator
Definition:
LArVoxelCalculator.h:30
sim::LArVoxelCalculator::m_voxelSize
vector_type const m_voxelSize
The sizes of the voxels in (x,y,z,t). Units are (mm,ns).
Definition:
LArVoxelCalculator.h:82
LArVoxelCalculator.h
Encapsulates calculation of LArVoxelID and LArVoxel parameters.
geo::vect::coord
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
Definition:
geo_vectors_utils.h:1682
sim::LArVoxelCalculator::m_energyCut
double const m_energyCut
Definition:
LArVoxelCalculator.h:90
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
sim::LArVoxelCalculator::SuggestedStepSize
double SuggestedStepSize() const
Definition:
LArVoxelCalculator_service.cc:42
sim
Code to link reconstructed objects back to the MC truth information.
Definition:
PedestalAdditionService.h:17
DEFINE_ART_SERVICE
#define DEFINE_ART_SERVICE(svc)
Definition:
ServiceDefinitionMacros.h:36
sim::LArVoxelCalculator::AxisToBin
int AxisToBin(const int, const double) const
Definition:
LArVoxelCalculator_service.cc:51
cet::sqlite::min
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition:
statistics.h:55
sim::LArVoxelCalculator::BinToAxis
double BinToAxis(const int, const int) const
Definition:
LArVoxelCalculator_service.cc:64
bin
QTextStream & bin(QTextStream &s)
Definition:
qtextstream.cpp:2006
ServiceDefinitionMacros.h
sim::LArVoxelCalculator::LArVoxelCalculator
LArVoxelCalculator(fhicl::ParameterSet const &pset)
Definition:
LArVoxelCalculator_service.cc:27
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11