Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larsim
larsim
Simulation
LArVoxelList.cxx
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
/// \file LArVoxelList.cxx
3
/// \brief Container of LArVoxelID, energy information.
4
///
5
/// \author seligman@nevis.columbia.edu
6
////////////////////////////////////////////////////////////////////////
7
8
#include "
larsim/Simulation/LArVoxelList.h
"
9
10
#include <iterator>
11
#include <iostream>
12
#include <cmath>
13
14
namespace
sim
{
15
16
//----------------------------------------------------------------------------
17
// Nothing special need be done for the constructor or destructor.
18
LArVoxelList::LArVoxelList
() {}
19
20
//----------------------------------------------------------------------------
21
LArVoxelList::~LArVoxelList
() {}
22
23
//----------------------------------------------------------------------------
24
void
LArVoxelList::Add
(
const
LArVoxelList
&
other
)
25
{
26
// Go through "other" list, adding its voxels to "this" list.
27
for
(
const_iterator
i = other.
m_voxelList
.begin(); i !=
m_voxelList
.end(); ++i ){
28
m_voxelList
[ (*i).first ] += (*i).second;
29
}
30
}
31
32
//----------------------------------------------------------------------------
33
LArVoxelList
&
LArVoxelList::operator*=
(
const
double
&
value
)
34
{
35
// Multiply each voxel energy by the value.
36
for
(
iterator
i =
m_voxelList
.begin(); i !=
m_voxelList
.end(); ++i ){
37
(*i).second *=
value
;
38
}
39
return
(*
this
);
40
}
41
42
//----------------------------------------------------------------------------
43
/// Just in case: define the result of "scalar * LArVoxelList" to be
44
/// the same as "LArVoxelList * scalar".
45
const
LArVoxelList
operator*
(
const
double
&
value
,
const
LArVoxelList
& list)
46
{
47
return
LArVoxelList
(list) *=
value
;
48
}
49
50
//----------------------------------------------------------------------------
51
/// Apply an energy cut to the voxels.
52
void
LArVoxelList::Cut
(
const
double
& cut )
53
{
54
// The safest way to do this is to create a list of voxel IDs that
55
// fail the cut, then delete those IDs.
56
57
// Define a list of IDs.
58
typedef
std::vector< key_type > keyList_type;
59
keyList_type keyList;
60
61
// Add each ID that fails the cut to the list.
62
for
(
const_iterator
i =
m_voxelList
.begin(); i !=
m_voxelList
.end(); ++i ){
63
if
( (*i).second.Energy() < cut ) {
64
keyList.push_back( (*i).first );
65
}
66
}
67
68
// Go through the list, deleting the voxels that are on the list.
69
for
(
keyList_type::const_iterator
i = keyList.begin(); i != keyList.end(); ++i ){
70
m_voxelList
.erase( (*i) );
71
}
72
}
73
74
//----------------------------------------------------------------------------
75
const
LArVoxelList::key_type
&
LArVoxelList::ID
(
const
size_type
index
)
const
76
{
77
const_iterator
i =
m_voxelList
.begin();
78
std::advance(i,index);
79
return
(*i).first;
80
}
81
82
//----------------------------------------------------------------------------
83
double
LArVoxelList::Energy
(
const
size_type
index
)
const
84
{
85
const_iterator
i =
m_voxelList
.begin();
86
std::advance(i,index);
87
return
(*i).second.Energy();
88
}
89
90
//----------------------------------------------------------------------------
91
std::ostream&
operator<<
( std::ostream&
output
,
const
LArVoxelList
& list )
92
{
93
// Determine a field width for the voxel number.
94
LArVoxelList::size_type
numberOfVoxels = list.
size
();
95
int
numberOfDigits = (
int
) std::log10( (
double
) numberOfVoxels ) + 1;
96
97
// A simple header.
98
output.width( numberOfDigits );
99
output <<
"#"
<<
": < ID, energy >"
<<
std::endl
;
100
101
// Write each voxel on a separate line.
102
LArVoxelList::size_type
nVoxel = 0;
103
for
(
LArVoxelList::const_iterator
voxel = list.
begin
(); voxel != list.
end
(); ++voxel, ++nVoxel ){
104
output.
width
( numberOfDigits );
105
output << nVoxel <<
": "
106
<<
"< "
<< (*voxel).first
107
<<
", "
<< (*voxel).second
108
<<
" >\n"
;
109
}
110
111
return
output
;
112
}
113
114
}
// namespace sim
sim::LArVoxelList::operator*
const LArVoxelList operator*(const double &value) const
Definition:
LArVoxelList.h:111
make_norm_csv.output
list output
Definition:
make_norm_csv.py:48
sim::LArVoxelList::size
size_type size() const
Definition:
LArVoxelList.h:140
LArVoxelList.h
Container of LAr voxel information.
QTextStream::width
int width() const
Definition:
qtextstream.h:247
const_iterator
intermediate_table::const_iterator const_iterator
Definition:
intermediate_table.cc:28
sim::LArVoxelList::m_voxelList
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition:
LArVoxelList.h:167
sim::LArVoxelList::LArVoxelList
LArVoxelList()
Definition:
LArVoxelList.cxx:18
sim::LArVoxelList
Definition:
LArVoxelList.h:68
sim::LArVoxelList::begin
iterator begin()
Definition:
LArVoxelList.h:131
sim::LArVoxelList::const_iterator
list_type::const_iterator const_iterator
Definition:
LArVoxelList.h:79
sim::LArVoxelList::operator<<
friend std::ostream & operator<<(std::ostream &output, const LArVoxelList &)
Definition:
LArVoxelList.cxx:91
sim::LArVoxelList::Energy
double Energy(const size_type) const
Definition:
LArVoxelList.cxx:83
fhicl::other
Definition:
exception.h:26
sim::LArVoxelList::end
iterator end()
Definition:
LArVoxelList.h:133
sim::LArVoxelList::Cut
void Cut(const double &)
Apply an energy cut to the voxels.
Definition:
LArVoxelList.cxx:52
sim::LArVoxelList::iterator
list_type::iterator iterator
Definition:
LArVoxelList.h:78
sim
Code to link reconstructed objects back to the MC truth information.
Definition:
PedestalAdditionService.h:17
sim::LArVoxelList::size_type
list_type::size_type size_type
Definition:
LArVoxelList.h:82
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
sim::LArVoxelList::operator*=
LArVoxelList & operator*=(const double &value)
Definition:
LArVoxelList.cxx:33
sim::LArVoxelList::key_type
list_type::key_type key_type
Definition:
LArVoxelList.h:75
ValidateOpDetReco.index
index
Definition:
ValidateOpDetReco.py:379
sim::LArVoxelList::Add
void Add(const key_type &key, const double &energy)
Definition:
LArVoxelList.h:94
sim::LArVoxelList::ID
const key_type & ID(const size_type) const
Definition:
LArVoxelList.cxx:75
submit_mcc.value
value
Definition:
submit_mcc.py:159
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
sim::LArVoxelList::~LArVoxelList
virtual ~LArVoxelList()
Definition:
LArVoxelList.cxx:21
Generated by
1.8.11