LArSoft  v06_85_00
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  }
26 
27 
28  //----------------------------------------------------------------------
30  std::vector<double> const& dEdx,
31  std::vector<double> const& dQdx,
32  std::vector<double> const& resRange,
33  std::vector<double> const& deadwire,
34  double Range,
35  double 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  TVector3 v(-999,-999,-999);
44  fXYZ.push_back(v);
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<double> const& dEdx,
70  std::vector<double> const& dQdx,
71  std::vector<double> const& resRange,
72  std::vector<double> const& deadwire,
73  double Range,
74  std::vector<double> 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  TVector3 v(-999,-999,-999);
87  fXYZ.push_back(v);
88  }
89  fdEdx.resize(dEdx.size());
90  fdQdx.resize(dQdx.size());
91  fResidualRange.resize(resRange.size());
92  for(size_t i = 0; i < dEdx.size(); ++i){
93  fdEdx[i] = dEdx[i];
94  fdQdx[i] = dQdx[i];
95  fResidualRange[i] = resRange[i];
96  }
97 
98  fDeadWireResR.resize(deadwire.size());
99  for(size_t i = 0; i<deadwire.size(); ++i){
100  fDeadWireResR[i] = deadwire[i];
101  }
102 
103  }
104 
105  //----------------------------------------------------------------------
107  std::vector<double> const& dEdx,
108  std::vector<double> const& dQdx,
109  std::vector<double> const& resRange,
110  std::vector<double> const& deadwire,
111  double Range,
112  std::vector<double> const& TrkPitch,
113  std::vector<TVector3> const& XYZ,
114  geo::PlaneID planeID)
115  {
116 
117  fPlaneID = planeID;
119  fRange = Range;
120  fTrkPitch = TrkPitch;
121  if(dEdx.size() != resRange.size())
122  throw cet::exception("anab::Calorimetry") << "dE/dx and residual range vectors "
123  << "have different sizes, this is a problem.\n";
124  for(size_t i=0; i!=dQdx.size(); ++i){
125  fXYZ.push_back(TVector3(-999,-999,-999));
126  }
127  fdEdx.resize(dEdx.size());
128  fdQdx.resize(dQdx.size());
129  fResidualRange.resize(resRange.size());
130  fXYZ.resize(XYZ.size());
131  for(size_t i = 0; i < dEdx.size(); ++i){
132  fdEdx[i] = dEdx[i];
133  fdQdx[i] = dQdx[i];
134  fResidualRange[i] = resRange[i];
135  fXYZ[i] = XYZ[i];
136  }
137 
138  fDeadWireResR.resize(deadwire.size());
139  for(size_t i = 0; i<deadwire.size(); ++i){
140  fDeadWireResR[i] = deadwire[i];
141  }
142 
143  }
144 
145  //----------------------------------------------------------------------
146  // ostream operator.
147  //
148  std::ostream& operator<< (std::ostream & o, Calorimetry const& a)
149  {
150  o << "Kinetic Energy: " << a.fKineticEnergy
151  << "\n Range: " << a.fRange << std::endl;
152 
153  for(size_t n = 0; n < a.fdEdx.size(); ++n)
154  o << "dE/dx=" << a.fdEdx[n]
155  << " Residual range=" << a.fResidualRange[n]
156  << " dQ/dx=" << a.fdQdx[n]
157  << " (x,y,z)=(" << a.fXYZ[n].X() << "," << a.fXYZ[n].Y() << "," << a.fXYZ[n].Z() << ")"
158  << " pitch=" << a.fTrkPitch[n]
159  << " planeID=(" << a.fPlaneID.Cryostat << "," << a.fPlaneID.TPC << "," << a.fPlaneID.Plane << ")"
160  << std::endl;
161 
162  return o;
163  }
164 
165 }
friend std::ostream & operator<<(std::ostream &o, Calorimetry const &a)
double fRange
total range of track
Definition: Calorimetry.h:32
std::vector< TVector3 > fXYZ
coordinates of space points
Definition: Calorimetry.h:34
const double & KineticEnergy() const
Definition: Calorimetry.h:92
The data type to uniquely identify a Plane.
Definition: geo_types.h:250
std::vector< double > fdQdx
dQ/dx
Definition: Calorimetry.h:29
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:130
const std::vector< TVector3 > & XYZ() const
Definition: Calorimetry.h:101
std::vector< double > fdEdx
dE/dx, should be same size as fResidualRange
Definition: Calorimetry.h:28
std::vector< double > fResidualRange
range from end of track
Definition: Calorimetry.h:30
double fKineticEnergy
determined kinetic energy
Definition: Calorimetry.h:27
const std::vector< double > & dQdx() const
Definition: Calorimetry.h:89
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
std::vector< double > fTrkPitch
track pitch on collection plane
Definition: Calorimetry.h:33
std::vector< double > fDeadWireResR
dead wire residual range, collection plane
Definition: Calorimetry.h:31
Char_t n[5]
geo::PlaneID fPlaneID
Definition: Calorimetry.h:37
const double & Range() const
Definition: Calorimetry.h:93
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:203
const std::vector< double > & dEdx() const
Definition: Calorimetry.h:88
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33