LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArVoxelData.cxx
Go to the documentation of this file.
1 
9 
10 #include <ostream>
11 
12 namespace sim {
13 
14  //----------------------------------------------------------------------------
15  // Constructor; take care of any initializations.
16  LArVoxelData::LArVoxelData() : fenergy(0) {}
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  (*i).second *= value;
59  }
60  fenergy *= value;
61 
62  return (*this);
63  }
64 
65  //----------------------------------------------------------------------------
68  const LArVoxelData operator*(const double& value, const LArVoxelData& data)
69  {
70  return LArVoxelData(data) *= value;
71  }
72 
73  //----------------------------------------------------------------------------
74  std::ostream& operator<<(std::ostream& output, const LArVoxelData& data)
75  {
76  output << "Voxel: " << data.VoxelID() << std::endl;
77 
78  double unassigned = data.UnassignedEnergy();
79  // Display the total energy then the breakdown of
80  // the sum.
81  output << data.Energy() << " = <ID,E>=";
82  for (LArVoxelData::const_iterator i = data.begin(); i != data.end(); ++i) {
83  if (i != data.begin()) output << ",";
84 
85  output << "<" << (*i).first << "," << (*i).second << ">";
86  }
87  if (unassigned > 0) output << ",<*," << unassigned << ">";
88 
89  return output;
90  }
91 
92 } // namespace sim
void Add(const mapped_type &energy, const key_type &trackID)
Definition: LArVoxelData.h:238
const LArVoxelData operator*(const double &value) const
Definition: LArVoxelData.h:256
iterator end()
Definition: VectorMap.h:187
list_type::mapped_type mapped_type
Definition: LArVoxelData.h:77
iterator begin()
Definition: LArVoxelData.h:260
mapped_type UnassignedEnergy() const
Definition: LArVoxelData.h:204
list_type ftrackEnergy
Definition: LArVoxelData.h:100
iterator begin()
Definition: VectorMap.h:183
Encapsulates the information we want store for a voxel.
mapped_type fenergy
Definition: LArVoxelData.h:95
Monte Carlo Simulation.
double value
Definition: spectrum.C:18
LArVoxelData & operator*=(const double &value)
virtual ~LArVoxelData()
mapped_type Energy() const
Definition: LArVoxelData.h:215
list_type::key_type key_type
Definition: LArVoxelData.h:76
list_type::const_iterator const_iterator
Definition: LArVoxelData.h:80
sim::LArVoxelID VoxelID() const
Definition: LArVoxelData.h:196
friend std::ostream & operator<<(std::ostream &output, const LArVoxelData &)
list_type::size_type size_type
Definition: LArVoxelData.h:83
const key_type & TrackID(const size_type) const
list_type::iterator iterator
Definition: LArVoxelData.h:79