All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
9 
10 #include <ostream>
11 
12 namespace sim {
13 
14  //----------------------------------------------------------------------------
15  // Constructor; take care of any initializations.
17  : fenergy(0)
18  {}
19 
20  //----------------------------------------------------------------------------
21  // Destructor.
23 
24  //----------------------------------------------------------------------------
26  {
28  std::advance(i,index);
29  return (*i).first;
30  }
31 
32  //----------------------------------------------------------------------------
34  {
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  //----------------------------------------------------------------------------
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
void Add(const mapped_type &energy, const key_type &trackID)
Definition: LArVoxelData.h:224
iterator end()
Definition: VectorMap.h:198
const LArVoxelData operator*(const double &value, const LArVoxelData &data)
list_type::mapped_type mapped_type
Definition: LArVoxelData.h:78
iterator begin()
Definition: LArVoxelData.h:242
mapped_type UnassignedEnergy() const
Definition: LArVoxelData.h:197
list_type ftrackEnergy
Definition: LArVoxelData.h:101
iterator begin()
Definition: VectorMap.h:188
Encapsulates the information we want store for a voxel.
mapped_type fenergy
Definition: LArVoxelData.h:96
LArVoxelData & operator*=(const double &value)
virtual ~LArVoxelData()
mapped_type Energy() const
Definition: LArVoxelData.h:203
list_type::key_type key_type
Definition: LArVoxelData.h:77
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
list_type::const_iterator const_iterator
Definition: LArVoxelData.h:81
temporary value
sim::LArVoxelID VoxelID() const
Definition: LArVoxelData.h:195
list_type::size_type size_type
Definition: LArVoxelData.h:84
std::ostream & operator<<(std::ostream &output, const LArVoxelData &data)
const key_type & TrackID(const size_type) const
list_type::iterator iterator
Definition: LArVoxelData.h:80