LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Calorimetry.cxx
Go to the documentation of this file.
1 //
3 // \brief Definition of Calorimetry analysis object
4 //
5 // \author brebel@fnal.gov, tjyang@fnal.gov
7 
9 #include "cetlib_except/exception.h"
10 
11 #include <iomanip>
12 #include <iostream>
13 
14 namespace anab {
15 
16  //----------------------------------------------------------------------
17  Calorimetry::Calorimetry() : fKineticEnergy(0.), fRange(0.)
18  {
19  fdEdx.clear();
20  fdQdx.clear();
21  fResidualRange.clear();
22  fDeadWireResR.clear();
23  fTrkPitch.clear();
24  fXYZ.clear();
25  fTpIndices.clear();
26  }
27 
28  //----------------------------------------------------------------------
30  std::vector<float> const& dEdx,
31  std::vector<float> const& dQdx,
32  std::vector<float> const& resRange,
33  std::vector<float> const& deadwire,
34  float Range,
35  float TrkPitch,
36  geo::PlaneID planeID)
37  {
38 
40  fRange = Range;
41  for (size_t i = 0; i != dQdx.size(); ++i) {
42  fTrkPitch.push_back(TrkPitch);
43  fXYZ.push_back({-999., -999., -999.});
44  }
45  if (dEdx.size() != resRange.size())
46  throw cet::exception("anab::Calorimetry") << "dE/dx and residual range vectors "
47  << "have different sizes, this is a problem.\n";
48  fdEdx.resize(dEdx.size());
49  fdQdx.resize(dQdx.size());
50  fResidualRange.resize(resRange.size());
51  for (size_t i = 0; i < dEdx.size(); ++i) {
52  fdEdx[i] = dEdx[i];
53  fdQdx[i] = dQdx[i];
54  fResidualRange[i] = resRange[i];
55  }
56 
57  fDeadWireResR.resize(deadwire.size());
58  for (size_t i = 0; i < deadwire.size(); ++i) {
59  fDeadWireResR[i] = deadwire[i];
60  }
61 
62  fPlaneID = planeID;
63  }
64 
65  //----------------------------------------------------------------------
67  std::vector<float> const& dEdx,
68  std::vector<float> const& dQdx,
69  std::vector<float> const& resRange,
70  std::vector<float> const& deadwire,
71  float Range,
72  std::vector<float> const& TrkPitch,
73  geo::PlaneID planeID)
74  {
75 
76  fPlaneID = planeID;
78  fRange = Range;
79  fTrkPitch = TrkPitch;
80  if (dEdx.size() != resRange.size())
81  throw cet::exception("anab::Calorimetry") << "dE/dx and residual range vectors "
82  << "have different sizes, this is a problem.\n";
83  for (size_t i = 0; i != dQdx.size(); ++i) {
84  fXYZ.push_back({-999., -999., -999.});
85  }
86  fdEdx.resize(dEdx.size());
87  fdQdx.resize(dQdx.size());
88  fResidualRange.resize(resRange.size());
89  for (size_t i = 0; i < dEdx.size(); ++i) {
90  fdEdx[i] = dEdx[i];
91  fdQdx[i] = dQdx[i];
92  fResidualRange[i] = resRange[i];
93  }
94 
95  fDeadWireResR.resize(deadwire.size());
96  for (size_t i = 0; i < deadwire.size(); ++i) {
97  fDeadWireResR[i] = deadwire[i];
98  }
99  }
100 
101  //----------------------------------------------------------------------
103  std::vector<float> const& dEdx,
104  std::vector<float> const& dQdx,
105  std::vector<float> const& resRange,
106  std::vector<float> const& deadwire,
107  float Range,
108  std::vector<float> const& TrkPitch,
109  std::vector<anab::Point_t> const& XYZ,
110  geo::PlaneID planeID)
111  : Calorimetry(KineticEnergy,
112  dEdx,
113  dQdx,
114  resRange,
115  deadwire,
116  Range,
117  TrkPitch,
118  XYZ,
119  std::vector<size_t>(),
120  planeID)
121  {}
122  //----------------------------------------------------------------------
124  std::vector<float> const& dEdx,
125  std::vector<float> const& dQdx,
126  std::vector<float> const& resRange,
127  std::vector<float> const& deadwire,
128  float Range,
129  std::vector<float> const& TrkPitch,
130  std::vector<anab::Point_t> const& XYZ,
131  std::vector<size_t> const& TpIndices,
132  geo::PlaneID planeID)
133  {
134 
135  if (dEdx.size() != resRange.size() || dEdx.size() != dQdx.size() ||
136  dEdx.size() != TrkPitch.size() || dEdx.size() != XYZ.size() ||
137  (TpIndices.size() > 0 && dEdx.size() != TpIndices.size()))
138  throw cet::exception("anab::Calorimetry") << "Input vectors "
139  << "have different sizes, this is a problem.\n";
140  fPlaneID = planeID;
142  fRange = Range;
143  fTrkPitch = TrkPitch;
144  fdEdx = dEdx;
145  fdQdx = dQdx;
146  fResidualRange = resRange;
147  fXYZ = XYZ;
149  fDeadWireResR = deadwire;
150  }
151 
152  //----------------------------------------------------------------------
153  // ostream operator.
154  //
155  std::ostream& operator<<(std::ostream& o, Calorimetry const& a)
156  {
157  o << "Kinetic Energy: " << a.fKineticEnergy << "\n Range: " << a.fRange << std::endl;
158 
159  for (size_t n = 0; n < a.fdEdx.size(); ++n)
160  o << "dE/dx=" << a.fdEdx[n] << " Residual range=" << a.fResidualRange[n]
161  << " dQ/dx=" << a.fdQdx[n] << " (x,y,z)=(" << a.fXYZ[n].X() << "," << a.fXYZ[n].Y() << ","
162  << a.fXYZ[n].Z() << ")"
163  << " pitch=" << a.fTrkPitch[n] << " planeID=(" << a.fPlaneID.Cryostat << ","
164  << a.fPlaneID.TPC << "," << a.fPlaneID.Plane << ")" << std::endl;
165 
166  return o;
167  }
168 
169 }
friend std::ostream & operator<<(std::ostream &o, Calorimetry const &a)
std::vector< float > fDeadWireResR
dead wire residual range, collection plane
Definition: Calorimetry.h:30
std::vector< size_t > fTpIndices
indices of original trajectory points on track
Definition: Calorimetry.h:35
std::vector< float > fdEdx
dE/dx, should be same size as fResidualRange
Definition: Calorimetry.h:27
float fKineticEnergy
determined kinetic energy
Definition: Calorimetry.h:26
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
std::vector< float > fdQdx
dQ/dx
Definition: Calorimetry.h:28
const std::vector< Point_t > & XYZ() const
Definition: Calorimetry.h:132
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:211
STL namespace.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
std::vector< float > fTrkPitch
track pitch on collection plane
Definition: Calorimetry.h:32
const std::vector< float > & dQdx() const
Definition: Calorimetry.h:101
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
std::vector< float > fResidualRange
range from end of track
Definition: Calorimetry.h:29
const std::vector< float > & dEdx() const
Definition: Calorimetry.h:97
const std::vector< size_t > & TpIndices() const
Definition: Calorimetry.h:136
float fRange
total range of track
Definition: Calorimetry.h:31
std::vector< Point_t > fXYZ
coordinates of space points; for a discussion on the object type for coordinates see recob::tracking:...
Definition: Calorimetry.h:34
const float & KineticEnergy() const
Definition: Calorimetry.h:113
Char_t n[5]
geo::PlaneID fPlaneID
Definition: Calorimetry.h:38
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:399
const float & Range() const
Definition: Calorimetry.h:117
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33