LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
LArVoxelData.cxx
Go to the documentation of this file.
1 
9 
10 namespace sim {
11 
12  //----------------------------------------------------------------------------
13  // Constructor; take care of any initializations.
15  : fenergy(0)
16  {}
17 
18  //----------------------------------------------------------------------------
19  // Destructor.
21 
22  //----------------------------------------------------------------------------
24  {
26  std::advance(i,index);
27  return (*i).first;
28  }
29 
30  //----------------------------------------------------------------------------
32  {
34  std::advance(i,index);
35  return (*i).second;
36  }
37 
38  //----------------------------------------------------------------------------
40  {
41  // When we add one voxel's data to another, it becomes impossible
42  // to keep the particle<->energy assignments anymore; the most
43  // likely reason to add two voxels is because we're adding events
44  // to make overlays, and so the particles' track numbers change.
45 
46  // So if we're adding another LArVoxelData to this one, move all
47  // the energies to "unassigned" in the sum.
48 
49  this->RemoveAllTracks();
50  fenergy += other.Energy();
51  }
52 
53  //----------------------------------------------------------------------------
55  {
56  // Multiply all energies by the value.
57  for ( iterator i = ftrackEnergy.begin(), end = ftrackEnergy.end(); i != end; ++i )
58  {
59  (*i).second *= value;
60  }
61  fenergy *= value;
62 
63  return (*this);
64  }
65 
66  //----------------------------------------------------------------------------
69  const LArVoxelData operator*(const double& value, const LArVoxelData& data)
70  {
71  return LArVoxelData(data) *= value;
72  }
73 
74  //----------------------------------------------------------------------------
75  std::ostream& operator<< ( std::ostream& output, const LArVoxelData& data )
76  {
77  output << "Voxel: " << data.VoxelID() << std::endl;
78 
79  double unassigned = data.UnassignedEnergy();
80  // Display the total energy then the breakdown of
81  // the sum.
82  output << data.Energy() << " = <ID,E>=";
83  for ( LArVoxelData::const_iterator i = data.begin(); i != data.end(); ++i){
84  if ( i != data.begin() )
85  output << ",";
86 
87  output << "<" << (*i).first << "," << (*i).second << ">";
88  }
89  if( unassigned > 0 )
90  output << ",<*," << unassigned << ">";
91 
92  return output;
93  }
94 
95 } // namespace sim
void Add(const mapped_type &energy, const key_type &trackID)
Definition: LArVoxelData.h:230
const LArVoxelData operator*(const double &value) const
Definition: LArVoxelData.h:244
iterator end()
Definition: VectorMap.h:198
list_type::mapped_type mapped_type
Definition: LArVoxelData.h:78
iterator begin()
Definition: LArVoxelData.h:248
mapped_type UnassignedEnergy() const
Definition: LArVoxelData.h:203
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
Monte Carlo Simulation.
LArVoxelData & operator*=(const double &value)
std::string value(boost::any const &)
virtual ~LArVoxelData()
mapped_type Energy() const
Definition: LArVoxelData.h:209
list_type::key_type key_type
Definition: LArVoxelData.h:77
list_type::const_iterator const_iterator
Definition: LArVoxelData.h:81
sim::LArVoxelID VoxelID() const
Definition: LArVoxelData.h:201
friend std::ostream & operator<<(std::ostream &output, const LArVoxelData &)
list_type::size_type size_type
Definition: LArVoxelData.h:84
const key_type & TrackID(const size_type) const
list_type::iterator iterator
Definition: LArVoxelData.h:80