LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
sim::LArVoxelList Class Reference

#include "LArVoxelList.h"

Public Types

typedef std::map< LArVoxelID, LArVoxelDatalist_type
 
typedef list_type::key_type key_type
 
typedef list_type::mapped_type mapped_type
 
typedef list_type::value_type value_type
 
typedef list_type::iterator iterator
 
typedef list_type::const_iterator const_iterator
 
typedef list_type::reverse_iterator reverse_iterator
 
typedef list_type::const_reverse_iterator const_reverse_iterator
 
typedef list_type::size_type size_type
 
typedef list_type::difference_type difference_type
 
typedef list_type::key_compare key_compare
 
typedef list_type::allocator_type allocator_type
 

Public Member Functions

 LArVoxelList ()
 
virtual ~LArVoxelList ()
 
void Add (const key_type &key, const double &energy)
 
void Add (const key_type &key, const double &energy, const int &id)
 
void Add (const LArVoxelList &)
 
LArVoxelListoperator+= (const LArVoxelList &other)
 
const LArVoxelList operator+ (const LArVoxelList &other) const
 
LArVoxelListoperator*= (const double &value)
 
const LArVoxelList operator* (const double &value) const
 
void Cut (const double &)
 Apply an energy cut to the voxels. More...
 
const key_typeID (const size_type) const
 
double Energy (const size_type) const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
size_type size () const
 
bool empty () const
 
void swap (LArVoxelList &other)
 
void clear ()
 
iterator find (const key_type &key)
 
const_iterator find (const key_type &key) const
 
iterator upper_bound (const key_type &key)
 
const_iterator upper_bound (const key_type &key) const
 
iterator lower_bound (const key_type &key)
 
const_iterator lower_bound (const key_type &key) const
 
mapped_typeoperator[] (const key_type &key)
 
const mapped_typeoperator[] (const key_type &key) const
 
mapped_typeat (const key_type &key)
 
const mapped_typeat (const key_type &key) const
 
void insert (const key_type &key, const mapped_type &value)
 
size_type erase (const key_type &key)
 

Private Attributes

list_type m_voxelList
 A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy) More...
 

Friends

const LArVoxelList operator* (const double &value, const LArVoxelList &list)
 
std::ostream & operator<< (std::ostream &output, const LArVoxelList &)
 

Detailed Description

Definition at line 68 of file LArVoxelList.h.

Member Typedef Documentation

typedef list_type::allocator_type sim::LArVoxelList::allocator_type

Definition at line 84 of file LArVoxelList.h.

typedef list_type::const_iterator sim::LArVoxelList::const_iterator

Definition at line 78 of file LArVoxelList.h.

typedef list_type::const_reverse_iterator sim::LArVoxelList::const_reverse_iterator

Definition at line 80 of file LArVoxelList.h.

typedef list_type::difference_type sim::LArVoxelList::difference_type

Definition at line 82 of file LArVoxelList.h.

typedef list_type::iterator sim::LArVoxelList::iterator

Definition at line 77 of file LArVoxelList.h.

typedef list_type::key_compare sim::LArVoxelList::key_compare

Definition at line 83 of file LArVoxelList.h.

typedef list_type::key_type sim::LArVoxelList::key_type

Definition at line 74 of file LArVoxelList.h.

Some type definitions to make life easier, and to help "hide" the implementation details. (If you're not familiar with STL, you can ignore these definitions.)

Definition at line 73 of file LArVoxelList.h.

typedef list_type::mapped_type sim::LArVoxelList::mapped_type

Definition at line 75 of file LArVoxelList.h.

typedef list_type::reverse_iterator sim::LArVoxelList::reverse_iterator

Definition at line 79 of file LArVoxelList.h.

typedef list_type::size_type sim::LArVoxelList::size_type

Definition at line 81 of file LArVoxelList.h.

typedef list_type::value_type sim::LArVoxelList::value_type

Definition at line 76 of file LArVoxelList.h.

Constructor & Destructor Documentation

sim::LArVoxelList::LArVoxelList ( )

Definition at line 18 of file LArVoxelList.cxx.

Referenced by sim::operator*(), operator*(), and operator+().

18 {}
sim::LArVoxelList::~LArVoxelList ( )
virtual

Definition at line 21 of file LArVoxelList.cxx.

21 {}

Member Function Documentation

void sim::LArVoxelList::Add ( const key_type key,
const double &  energy 
)
inline

Definition at line 93 of file LArVoxelList.h.

References m_voxelList.

Referenced by Add(), sim::SimListUtils::GetLArVoxelList(), and operator+=().

93 { m_voxelList[key].Add(energy); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
double energy
Definition: plottest35.C:25
void sim::LArVoxelList::Add ( const key_type key,
const double &  energy,
const int &  id 
)
inline

Definition at line 94 of file LArVoxelList.h.

References Add(), and m_voxelList.

95  {
96  m_voxelList[key].Add(energy, id);
97  }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
double energy
Definition: plottest35.C:25
void sim::LArVoxelList::Add ( const LArVoxelList other)

Definition at line 24 of file LArVoxelList.cxx.

References m_voxelList.

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  }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
mapped_type& sim::LArVoxelList::at ( const key_type key)
inline

Definition at line 154 of file LArVoxelList.h.

References m_voxelList.

154 { return m_voxelList.at(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const mapped_type& sim::LArVoxelList::at ( const key_type key) const
inline

Definition at line 155 of file LArVoxelList.h.

References m_voxelList.

155 { return m_voxelList.at(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
iterator sim::LArVoxelList::begin ( )
inline

Definition at line 130 of file LArVoxelList.h.

References m_voxelList.

Referenced by evdb_tool::DrawLArVoxel3D::Draw(), evd::SimulationDrawer::MCTruth3D(), evd::SimulationDrawer::MCTruthOrtho(), and sim::operator<<().

130 { return m_voxelList.begin(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const_iterator sim::LArVoxelList::begin ( ) const
inline

Definition at line 131 of file LArVoxelList.h.

References m_voxelList.

131 { return m_voxelList.begin(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
void sim::LArVoxelList::clear ( )
inline

Definition at line 142 of file LArVoxelList.h.

References m_voxelList.

142 { m_voxelList.clear(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
void sim::LArVoxelList::Cut ( const double &  cut)

Apply an energy cut to the voxels.

Definition at line 52 of file LArVoxelList.cxx.

References m_voxelList.

Referenced by operator*().

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) { keyList.push_back((*i).first); }
64  }
65 
66  // Go through the list, deleting the voxels that are on the list.
67  for (keyList_type::const_iterator i = keyList.begin(); i != keyList.end(); ++i) {
68  m_voxelList.erase((*i));
69  }
70  }
intermediate_table::const_iterator const_iterator
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
bool sim::LArVoxelList::empty ( ) const
inline

Definition at line 140 of file LArVoxelList.h.

References m_voxelList.

140 { return m_voxelList.empty(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
iterator sim::LArVoxelList::end ( void  )
inline

Definition at line 132 of file LArVoxelList.h.

References m_voxelList.

Referenced by evdb_tool::DrawLArVoxel3D::Draw(), evd::SimulationDrawer::MCTruth3D(), evd::SimulationDrawer::MCTruthOrtho(), and sim::operator<<().

132 { return m_voxelList.end(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const_iterator sim::LArVoxelList::end ( void  ) const
inline

Definition at line 133 of file LArVoxelList.h.

References m_voxelList.

133 { return m_voxelList.end(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
double sim::LArVoxelList::Energy ( const size_type  index) const

Definition at line 81 of file LArVoxelList.cxx.

References m_voxelList.

Referenced by operator*().

82  {
83  const_iterator i = m_voxelList.begin();
84  std::advance(i, index);
85  return (*i).second.Energy();
86  }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
size_type sim::LArVoxelList::erase ( const key_type key)
inline

Definition at line 163 of file LArVoxelList.h.

References m_voxelList.

163 { return m_voxelList.erase(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
iterator sim::LArVoxelList::find ( const key_type key)
inline

Definition at line 144 of file LArVoxelList.h.

References m_voxelList.

Referenced by sim::SimListUtils::GetLArVoxelList().

144 { return m_voxelList.find(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const_iterator sim::LArVoxelList::find ( const key_type key) const
inline

Definition at line 145 of file LArVoxelList.h.

References m_voxelList.

145 { return m_voxelList.find(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const LArVoxelList::key_type & sim::LArVoxelList::ID ( const size_type  index) const

Definition at line 73 of file LArVoxelList.cxx.

References m_voxelList.

Referenced by operator*().

74  {
75  const_iterator i = m_voxelList.begin();
76  std::advance(i, index);
77  return (*i).first;
78  }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
void sim::LArVoxelList::insert ( const key_type key,
const mapped_type value 
)
inline

Definition at line 161 of file LArVoxelList.h.

References m_voxelList, and value.

161 { m_voxelList[key] = value; }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
double value
Definition: spectrum.C:18
iterator sim::LArVoxelList::lower_bound ( const key_type key)
inline

Definition at line 148 of file LArVoxelList.h.

References m_voxelList.

148 { return m_voxelList.lower_bound(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const_iterator sim::LArVoxelList::lower_bound ( const key_type key) const
inline

Definition at line 149 of file LArVoxelList.h.

References m_voxelList.

149 { return m_voxelList.lower_bound(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const LArVoxelList sim::LArVoxelList::operator* ( const double &  value) const
inline

Definition at line 113 of file LArVoxelList.h.

References Cut(), Energy(), ID(), LArVoxelList(), operator<<, and value.

113 { return LArVoxelList(*this) *= value; }
double value
Definition: spectrum.C:18
LArVoxelList & sim::LArVoxelList::operator*= ( const double &  value)

Definition at line 33 of file LArVoxelList.cxx.

References m_voxelList, and value.

Referenced by operator+().

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  }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
double value
Definition: spectrum.C:18
const LArVoxelList sim::LArVoxelList::operator+ ( const LArVoxelList other) const
inline

Definition at line 107 of file LArVoxelList.h.

References LArVoxelList(), operator*=(), fhicl::other, and value.

108  {
109  return LArVoxelList(*this) += other;
110  }
LArVoxelList& sim::LArVoxelList::operator+= ( const LArVoxelList other)
inline

Definition at line 102 of file LArVoxelList.h.

References Add().

103  {
104  this->Add(other);
105  return *this;
106  }
void Add(const key_type &key, const double &energy)
Definition: LArVoxelList.h:93
mapped_type& sim::LArVoxelList::operator[] ( const key_type key)
inline

Definition at line 151 of file LArVoxelList.h.

References m_voxelList.

151 { return m_voxelList[key]; }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const mapped_type& sim::LArVoxelList::operator[] ( const key_type key) const
inline

Definition at line 153 of file LArVoxelList.h.

References m_voxelList.

153 { return m_voxelList.at(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
reverse_iterator sim::LArVoxelList::rbegin ( )
inline

Definition at line 134 of file LArVoxelList.h.

References m_voxelList.

134 { return m_voxelList.rbegin(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const_reverse_iterator sim::LArVoxelList::rbegin ( ) const
inline

Definition at line 135 of file LArVoxelList.h.

References m_voxelList.

135 { return m_voxelList.rbegin(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
reverse_iterator sim::LArVoxelList::rend ( )
inline

Definition at line 136 of file LArVoxelList.h.

References m_voxelList.

136 { return m_voxelList.rend(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const_reverse_iterator sim::LArVoxelList::rend ( ) const
inline

Definition at line 137 of file LArVoxelList.h.

References m_voxelList.

137 { return m_voxelList.rend(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
size_type sim::LArVoxelList::size ( void  ) const
inline

Definition at line 139 of file LArVoxelList.h.

References m_voxelList.

Referenced by evdb_tool::DrawLArVoxel3D::Draw(), evd::SimulationDrawer::MCTruth3D(), evd::SimulationDrawer::MCTruthOrtho(), and sim::operator<<().

139 { return m_voxelList.size(); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
void sim::LArVoxelList::swap ( LArVoxelList other)
inline

Definition at line 141 of file LArVoxelList.h.

References m_voxelList.

141 { m_voxelList.swap(other.m_voxelList); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
iterator sim::LArVoxelList::upper_bound ( const key_type key)
inline

Definition at line 146 of file LArVoxelList.h.

References m_voxelList.

146 { return m_voxelList.upper_bound(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166
const_iterator sim::LArVoxelList::upper_bound ( const key_type key) const
inline

Definition at line 147 of file LArVoxelList.h.

References m_voxelList.

147 { return m_voxelList.upper_bound(key); }
list_type m_voxelList
A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)
Definition: LArVoxelList.h:166

Friends And Related Function Documentation

const LArVoxelList operator* ( const double &  value,
const LArVoxelList list 
)
friend

Just in case: define the result of "scalar * LArVoxelList" to be the same as "LArVoxelList * scalar".

Definition at line 45 of file LArVoxelList.cxx.

46  {
47  return LArVoxelList(list) *= value;
48  }
double value
Definition: spectrum.C:18
std::ostream& operator<< ( std::ostream &  output,
const LArVoxelList list 
)
friend

Definition at line 89 of file LArVoxelList.cxx.

Referenced by operator*().

90  {
91  // Determine a field width for the voxel number.
92  LArVoxelList::size_type numberOfVoxels = list.size();
93  int numberOfDigits = (int)std::log10((double)numberOfVoxels) + 1;
94 
95  // A simple header.
96  output.width(numberOfDigits);
97  output << "#"
98  << ": < ID, energy >" << std::endl;
99 
100  // Write each voxel on a separate line.
101  LArVoxelList::size_type nVoxel = 0;
102  for (LArVoxelList::const_iterator voxel = list.begin(); voxel != list.end();
103  ++voxel, ++nVoxel) {
104  output.width(numberOfDigits);
105  output << nVoxel << ": "
106  << "< " << (*voxel).first << ", " << (*voxel).second << " >\n";
107  }
108 
109  return output;
110  }
list_type::const_iterator const_iterator
Definition: LArVoxelList.h:78
list_type::size_type size_type
Definition: LArVoxelList.h:81

Member Data Documentation

list_type sim::LArVoxelList::m_voxelList
private

A sorted list of <LArVoxelID,double> pairs = (voxel ID, energy)

Definition at line 166 of file LArVoxelList.h.

Referenced by Add(), at(), begin(), clear(), Cut(), empty(), end(), Energy(), erase(), find(), ID(), insert(), lower_bound(), operator*=(), operator[](), rbegin(), rend(), size(), swap(), and upper_bound().


The documentation for this class was generated from the following files: