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