Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larsim
larsim
Simulation
LArVoxelData.cxx
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
/// \file LArVoxelData.cxx
3
/// \brief Encapsulates the information we want store for a voxel.
4
///
5
/// \author seligman@nevis.columbia.edu
6
////////////////////////////////////////////////////////////////////////
7
8
#include "
larsim/Simulation/LArVoxelData.h
"
9
10
#include <ostream>
11
12
namespace
sim
{
13
14
//----------------------------------------------------------------------------
15
// Constructor; take care of any initializations.
16
LArVoxelData::LArVoxelData
()
17
: fenergy(0)
18
{}
19
20
//----------------------------------------------------------------------------
21
// Destructor.
22
LArVoxelData::~LArVoxelData
() {}
23
24
//----------------------------------------------------------------------------
25
const
LArVoxelData::key_type
&
LArVoxelData::TrackID
(
const
size_type
index
)
const
26
{
27
const_iterator
i =
ftrackEnergy
.
begin
();
28
std::advance(i,index);
29
return
(*i).first;
30
}
31
32
//----------------------------------------------------------------------------
33
const
LArVoxelData::mapped_type
&
LArVoxelData::Energy
(
const
size_type
index
)
const
34
{
35
const_iterator
i =
ftrackEnergy
.
begin
();
36
std::advance(i,index);
37
return
(*i).second;
38
}
39
40
//----------------------------------------------------------------------------
41
void
LArVoxelData::Add
(
const
LArVoxelData
&
other
)
42
{
43
// When we add one voxel's data to another, it becomes impossible
44
// to keep the particle<->energy assignments anymore; the most
45
// likely reason to add two voxels is because we're adding events
46
// to make overlays, and so the particles' track numbers change.
47
48
// So if we're adding another LArVoxelData to this one, move all
49
// the energies to "unassigned" in the sum.
50
51
this->
RemoveAllTracks
();
52
fenergy
+= other.
Energy
();
53
}
54
55
//----------------------------------------------------------------------------
56
LArVoxelData
&
LArVoxelData::operator*=
(
const
double
&
value
)
57
{
58
// Multiply all energies by the value.
59
for
(
iterator
i =
ftrackEnergy
.
begin
(),
end
=
ftrackEnergy
.
end
(); i !=
end
; ++i )
60
{
61
(*i).second *=
value
;
62
}
63
fenergy
*=
value
;
64
65
return
(*
this
);
66
}
67
68
//----------------------------------------------------------------------------
69
/// Just in case: define the result of "scalar * LArVoxelData" to be
70
/// the same as "LArVoxelData * scalar".
71
const
LArVoxelData
operator*
(
const
double
&
value
,
const
LArVoxelData
&
data
)
72
{
73
return
LArVoxelData
(data) *=
value
;
74
}
75
76
//----------------------------------------------------------------------------
77
std::ostream&
operator<<
( std::ostream&
output
,
const
LArVoxelData
&
data
)
78
{
79
output <<
"Voxel: "
<< data.
VoxelID
() <<
std::endl
;
80
81
double
unassigned = data.
UnassignedEnergy
();
82
// Display the total energy then the breakdown of
83
// the sum.
84
output << data.
Energy
() <<
" = <ID,E>="
;
85
for
(
LArVoxelData::const_iterator
i = data.
begin
(); i != data.
end
(); ++i){
86
if
( i != data.
begin
() )
87
output <<
","
;
88
89
output <<
"<"
<< (*i).first <<
","
<< (*i).second <<
">"
;
90
}
91
if
( unassigned > 0 )
92
output <<
",<*,"
<< unassigned <<
">"
;
93
94
return
output
;
95
}
96
97
}
// namespace sim
sim::LArVoxelData::Add
void Add(const mapped_type &energy, const key_type &trackID)
Definition:
LArVoxelData.h:224
sim::LArVoxelData::operator*
const LArVoxelData operator*(const double &value) const
Definition:
LArVoxelData.h:238
util::VectorMap::end
iterator end()
Definition:
VectorMap.h:198
make_norm_csv.output
list output
Definition:
make_norm_csv.py:48
sim::LArVoxelData
Definition:
LArVoxelData.h:70
sim::LArVoxelData::end
iterator end()
Definition:
LArVoxelData.h:244
sim::LArVoxelData::RemoveAllTracks
void RemoveAllTracks()
Definition:
LArVoxelData.h:219
sim::LArVoxelData::mapped_type
list_type::mapped_type mapped_type
Definition:
LArVoxelData.h:78
sim::LArVoxelData::begin
iterator begin()
Definition:
LArVoxelData.h:242
sim::LArVoxelData::UnassignedEnergy
mapped_type UnassignedEnergy() const
Definition:
LArVoxelData.h:197
sim::LArVoxelData::ftrackEnergy
list_type ftrackEnergy
Definition:
LArVoxelData.h:101
util::VectorMap::begin
iterator begin()
Definition:
VectorMap.h:188
LArVoxelData.h
Encapsulates the information we want store for a voxel.
sim::LArVoxelData::fenergy
mapped_type fenergy
Definition:
LArVoxelData.h:96
fhicl::other
Definition:
exception.h:26
sim
Code to link reconstructed objects back to the MC truth information.
Definition:
PedestalAdditionService.h:17
make_THn_beam_input.data
data
Definition:
make_THn_beam_input.py:80
sim::LArVoxelData::operator*=
LArVoxelData & operator*=(const double &value)
Definition:
LArVoxelData.cxx:56
sim::LArVoxelData::~LArVoxelData
virtual ~LArVoxelData()
Definition:
LArVoxelData.cxx:22
sim::LArVoxelData::Energy
mapped_type Energy() const
Definition:
LArVoxelData.h:203
sim::LArVoxelData::key_type
list_type::key_type key_type
Definition:
LArVoxelData.h:77
ValidateOpDetReco.index
index
Definition:
ValidateOpDetReco.py:379
sim::LArVoxelData::const_iterator
list_type::const_iterator const_iterator
Definition:
LArVoxelData.h:81
sim::LArVoxelData::VoxelID
sim::LArVoxelID VoxelID() const
Definition:
LArVoxelData.h:195
sim::LArVoxelData::operator<<
friend std::ostream & operator<<(std::ostream &output, const LArVoxelData &)
Definition:
LArVoxelData.cxx:77
sim::LArVoxelData::size_type
list_type::size_type size_type
Definition:
LArVoxelData.h:84
submit_mcc.value
value
Definition:
submit_mcc.py:159
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
sim::LArVoxelData::TrackID
const key_type & TrackID(const size_type) const
Definition:
LArVoxelData.cxx:25
sim::LArVoxelData::LArVoxelData
LArVoxelData()
Definition:
LArVoxelData.cxx:16
sim::LArVoxelData::iterator
list_type::iterator iterator
Definition:
LArVoxelData.h:80
Generated by
1.8.11