All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Calorimetry.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // \brief Definition of Calorimetry analysis object
4 //
5 // \author brebel@fnal.gov, tjyang@fnal.gov
6 ////////////////////////////////////////////////////////////////////////
7 
9 #include "cetlib_except/exception.h"
10 
11 #include <iostream>
12 #include <iomanip>
13 
14 namespace anab{
15 
16  //----------------------------------------------------------------------
18  : fKineticEnergy(0.)
19  , fRange(0.)
20  {
21  fdEdx.clear();
22  fdQdx.clear();
23  fResidualRange.clear();
24  fDeadWireResR.clear();
25  fTrkPitch.clear();
26  fXYZ.clear();
27  fTpIndices.clear();
28  }
29 
30 
31  //----------------------------------------------------------------------
32  Calorimetry::Calorimetry(float KineticEnergy,
33  std::vector<float> const& dEdx,
34  std::vector<float> const& dQdx,
35  std::vector<float> const& resRange,
36  std::vector<float> const& deadwire,
37  float Range,
38  float TrkPitch,
39  geo::PlaneID planeID)
40  {
41 
43  fRange = Range;
44  for(size_t i=0; i!=dQdx.size(); ++i){
45  fTrkPitch.push_back(TrkPitch);
46  fXYZ.push_back({-999.,-999.,-999.});
47  }
48  if(dEdx.size() != resRange.size())
49  throw cet::exception("anab::Calorimetry") << "dE/dx and residual range vectors "
50  << "have different sizes, this is a problem.\n";
51  fdEdx.resize(dEdx.size());
52  fdQdx.resize(dQdx.size());
53  fResidualRange.resize(resRange.size());
54  for(size_t i = 0; i < dEdx.size(); ++i){
55  fdEdx[i] = dEdx[i];
56  fdQdx[i] = dQdx[i];
57  fResidualRange[i] = resRange[i];
58  }
59 
60  fDeadWireResR.resize(deadwire.size());
61  for(size_t i = 0; i<deadwire.size(); ++i){
62  fDeadWireResR[i] = deadwire[i];
63  }
64 
65  fPlaneID = planeID;
66  }
67 
68 
69  //----------------------------------------------------------------------
70  Calorimetry::Calorimetry(float KineticEnergy,
71  std::vector<float> const& dEdx,
72  std::vector<float> const& dQdx,
73  std::vector<float> const& resRange,
74  std::vector<float> const& deadwire,
75  float Range,
76  std::vector<float> const& TrkPitch,
77  geo::PlaneID planeID)
78  {
79 
80  fPlaneID = planeID;
82  fRange = Range;
83  fTrkPitch = TrkPitch;
84  if(dEdx.size() != resRange.size())
85  throw cet::exception("anab::Calorimetry") << "dE/dx and residual range vectors "
86  << "have different sizes, this is a problem.\n";
87  for(size_t i=0; i!=dQdx.size(); ++i){
88  fXYZ.push_back({-999.,-999.,-999.});
89  }
90  fdEdx.resize(dEdx.size());
91  fdQdx.resize(dQdx.size());
92  fResidualRange.resize(resRange.size());
93  for(size_t i = 0; i < dEdx.size(); ++i){
94  fdEdx[i] = dEdx[i];
95  fdQdx[i] = dQdx[i];
96  fResidualRange[i] = resRange[i];
97  }
98 
99  fDeadWireResR.resize(deadwire.size());
100  for(size_t i = 0; i<deadwire.size(); ++i){
101  fDeadWireResR[i] = deadwire[i];
102  }
103 
104  }
105 
106  //----------------------------------------------------------------------
107  Calorimetry::Calorimetry(float KineticEnergy,
108  std::vector<float> const& dEdx,
109  std::vector<float> const& dQdx,
110  std::vector<float> const& resRange,
111  std::vector<float> const& deadwire,
112  float Range,
113  std::vector<float> const& TrkPitch,
114  std::vector<anab::Point_t> const& XYZ,
115  geo::PlaneID planeID)
116  : Calorimetry(KineticEnergy, dEdx, dQdx, resRange, deadwire, Range, TrkPitch, XYZ, std::vector<size_t>(),planeID) { }
117  //----------------------------------------------------------------------
118  Calorimetry::Calorimetry(float KineticEnergy,
119  std::vector<float> const& dEdx,
120  std::vector<float> const& dQdx,
121  std::vector<float> const& resRange,
122  std::vector<float> const& deadwire,
123  float Range,
124  std::vector<float> const& TrkPitch,
125  std::vector<anab::Point_t> const& XYZ,
126  std::vector<size_t> const& TpIndices,
127  geo::PlaneID planeID)
128  {
129 
130  if( dEdx.size() != resRange.size() ||
131  dEdx.size() != dQdx.size() ||
132  dEdx.size() != TrkPitch.size() ||
133  dEdx.size() != XYZ.size() ||
134  (TpIndices.size()>0 && dEdx.size() != TpIndices.size()) )
135  throw cet::exception("anab::Calorimetry") << "Input vectors "
136  << "have different sizes, this is a problem.\n";
137  fPlaneID = planeID;
139  fRange = Range;
140  fTrkPitch = TrkPitch;
141  fdEdx = dEdx;
142  fdQdx = dQdx;
143  fResidualRange = resRange;
144  fXYZ = XYZ;
146  fDeadWireResR = deadwire;
147  }
148 
149  //----------------------------------------------------------------------
150  // ostream operator.
151  //
152  std::ostream& operator<< (std::ostream & o, Calorimetry const& a)
153  {
154  o << "Kinetic Energy: " << a.fKineticEnergy
155  << "\n Range: " << a.fRange << std::endl;
156 
157  for(size_t n = 0; n < a.fdEdx.size(); ++n)
158  o << "dE/dx=" << a.fdEdx[n]
159  << " Residual range=" << a.fResidualRange[n]
160  << " dQ/dx=" << a.fdQdx[n]
161  << " (x,y,z)=(" << a.fXYZ[n].X() << "," << a.fXYZ[n].Y() << "," << a.fXYZ[n].Z() << ")"
162  << " pitch=" << a.fTrkPitch[n]
163  << " planeID=(" << a.fPlaneID.Cryostat << "," << a.fPlaneID.TPC << "," << a.fPlaneID.Plane << ")"
164  << std::endl;
165 
166  return o;
167  }
168 
169 }
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
std::ostream & operator<<(std::ostream &o, Calorimetry const &a)
std::vector< float > fDeadWireResR
dead wire residual range, collection plane
Definition: Calorimetry.h:31
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:28
float fKineticEnergy
determined kinetic energy
Definition: Calorimetry.h:27
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::vector< float > fdQdx
dQ/dx
Definition: Calorimetry.h:29
const std::vector< Point_t > & XYZ() const
Definition: Calorimetry.h:114
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
process_name gaushit a
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:33
const std::vector< float > & dQdx() const
Definition: Calorimetry.h:102
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
std::vector< float > fResidualRange
range from end of track
Definition: Calorimetry.h:30
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2687
const std::vector< float > & dEdx() const
Definition: Calorimetry.h:101
const std::vector< size_t > & TpIndices() const
Definition: Calorimetry.h:115
float fRange
total range of track
Definition: Calorimetry.h:32
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:105
geo::PlaneID fPlaneID
Definition: Calorimetry.h:38
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
const float & Range() const
Definition: Calorimetry.h:106