Track.cxx
Go to the documentation of this file.
1 #include "DDTMonopole/Track.h"
2 
4 
5 
6 
8  is_ddt_(true), start_ddt_(start), end_ddt_(end), goodness_("not set")
9 {
10  dp_ = static_cast<double>(end.Plane().val) -
11  static_cast<double>(start.Plane().val);
12  dc_ = static_cast<double>(end.Cell().val) -
13  static_cast<double>(start.Cell().val);
14 
15  dt_ = static_cast<int64_t>(end.TDC().val) -
16  static_cast<int64_t>(start.TDC().val);
17 
21 
23 
24  min_plane_ = std::min(start.Plane().val, end.Plane().val);
25  max_plane_ = std::max(start.Plane().val, end.Plane().val);
26  min_cell_ = std::min(start.Cell().val, end.Cell().val);
27  max_cell_ = std::max(start.Cell().val, end.Cell().val);
28 }
29 
30 
31 
33  art::Ptr<rb::CellHit> const& end) :
34  is_ddt_(false), start_rb_(start), end_rb_(end), goodness_("not set")
35 {
36  dp_ = static_cast<double>(end->Plane()) -
37  static_cast<double>(start->Plane());
38  dc_ = static_cast<double>(end->Cell()) -
39  static_cast<double>(start->Cell());
40 
41  dt_ = static_cast<int64_t>(end->TDC()) -
42  static_cast<int64_t>(start->TDC());
43 
47 
49 
50  min_plane_ = std::min(start->Plane(), end->Plane());
51  max_plane_ = std::max(start->Plane(), end->Plane());
52  min_cell_ = std::min(start->Cell(), end->Cell());
53  max_cell_ = std::max(start->Cell(), end->Cell());
54 }
55 
56 
57 
59 {
62 
63  return sqrt(dx*dx + dz*dz);
64 }
65 
66 
67 
69 {
70  double dt_in_nanoseconds = novaddt::smt::Constants::TDC_TICK * dt_;
71 
72  return distance_ / dt_in_nanoseconds;
73 }
74 
75 
76 
78 {
79  if (dp_ == 0)
80  {
81  slope_plane_is_valid_ = false;
82  } else {
83  slope_plane_is_valid_ = true;
86  }
87 
88  if (dt_ == 0)
89  {
90  slope_time_is_valid_ = false;
91  } else {
92  slope_time_is_valid_ = true;
95  }
96 
97  if (dc_ == 0)
98  {
99  slope_cell_is_valid_ = false;
100  } else {
101  slope_cell_is_valid_ = true;
103  }
104 }
105 
106 
107 
108 double mono::Track::distance() const
109 {
110  return distance_;
111 }
112 
113 
114 
115 double mono::Track::time() const
116 {
117  return dt_;
118 }
119 
120 
121 
122 double mono::Track::velocity() const
123 {
124  return velocity_;
125 }
126 
127 
128 
129 double mono::Track::beta() const
130 {
131  return beta_;
132 }
133 
134 
135 
137 {
138  return slope_plane_is_valid_;
139 }
140 
141 
142 
144 {
145  return slope_time_is_valid_;
146 }
147 
148 
149 
151 {
152  return slope_cell_is_valid_;
153 }
154 
155 
156 
158 {
159  if (!slope_plane_is_valid())
160  {
161  std::cerr << "\n\tThe slope is invalid.\n\n"
162  << "Please check Track::slope_is_valid() "
163  << "before accessing Track::slope()." << std::endl;
164  assert(false);
165  }
166 
167  return slope_cell_plane_;
168 }
169 
170 
171 
173 {
174  if (!slope_plane_is_valid())
175  {
176  std::cerr << "\n\tThe slope is invalid.\n\n"
177  << "Please check Track::slope_is_valid() "
178  << "before accessing Track::slope()." << std::endl;
179  assert(false);
180  }
181 
182  return slope_time_plane_;
183 }
184 
185 
186 
188 {
189  if (!slope_time_is_valid())
190  {
191  std::cerr << "\n\tThe slope is invalid.\n\n"
192  << "Please check Track::slope_is_valid() "
193  << "before accessing Track::slope()." << std::endl;
194  assert(false);
195  }
196 
197  return slope_cell_time_;
198 }
199 
200 
201 
203 {
204  if (!slope_time_is_valid())
205  {
206  std::cerr << "\n\tThe slope is invalid.\n\n"
207  << "Please check Track::slope_is_valid() "
208  << "before accessing Track::slope()." << std::endl;
209  assert(false);
210  }
211 
212  return slope_plane_time_;
213 }
214 
215 
216 
218 {
219  if (!slope_cell_is_valid())
220  {
221  std::cerr << "\n\tThe slope is invalid.\n\n"
222  << "Please check Track::slope_is_valid() "
223  << "before accessing Track::slope()." << std::endl;
224  assert(false);
225  }
226 
227  return slope_time_cell_;
228 }
229 
230 
231 
233 {
234  return dp_;
235 }
236 
237 
238 unsigned mono::Track::min_plane() const
239 {
240  return min_plane_;
241 }
242 
243 
244 
245 unsigned mono::Track::max_plane() const
246 {
247  return max_plane_;
248 }
249 
250 
251 
253 {
254  return dc_;
255 }
256 
257 
258 
259 unsigned mono::Track::min_cell() const
260 {
261  return min_cell_;
262 }
263 
264 
265 
266 unsigned mono::Track::max_cell() const
267 {
268  return max_cell_;
269 }
270 
271 
272 
274 {
275  goodness_ = "marked good";
276 }
277 
278 
279 
281 {
282  if (goodness_ == "marked good")
283  return true;
284 
285  return false;
286 }
287 
288 
289 
291 {
292  if (info_.find(name) != info_.end())
293  {
294  std::cerr << "\n\n\t" << name << " has already been set.\n" << std::endl;
295  assert(false);
296  }
297 
298  info_[name] = value;
299 }
300 
301 
302 
303 double mono::Track::get(std::string const& name) const
304 {
305  if (info_.find(name) == info_.end())
306  {
307  std::cerr << "\n\n\t" << name << " does not exist.\n" << std::endl;
308  assert(false);
309  }
310 
311  return info_.at(name);
312 }
313 
314 
315 
317 {
318  if (!is_ddt_)
319  {
320  std::cerr << "\n\tThis object only contains art::Ptr<rb::CellHit> hits, "
321  << "please use start_rb()\n" << std::endl;
322  assert(false);
323  }
324 
325  return start_ddt_;
326 }
327 
328 
329 
331 {
332  if (!is_ddt_)
333  {
334  std::cerr << "\n\tThis object only contains art::Ptr<rb::CellHit> hits, "
335  << "please use end_rb()\n" << std::endl;
336  assert(false);
337  }
338 
339  return end_ddt_;
340 }
341 
342 
343 
345 {
346  if (is_ddt_)
347  {
348  std::cerr << "\n\tThis object only contains novaddt::DAQHit hits, "
349  << "please use start_ddt()\n" << std::endl;
350  assert(false);
351  }
352 
353  return start_rb_;
354 }
355 
356 
357 
359 {
360  if (is_ddt_)
361  {
362  std::cerr << "\n\tThis object only contains novaddt::DAQHit hits, "
363  << "please use end_ddt()\n" << std::endl;
364  assert(false);
365  }
366 
367  return end_rb_;
368 }
double beta() const
Definition: Track.cxx:129
T max(const caf::Proxy< T > &a, T b)
const XML_Char * name
Definition: expat.h:151
int cell_difference() const
Definition: Track.cxx:252
novaddt::DAQHit start_ddt_
Definition: Track.h:75
int plane_difference() const
Definition: Track.cxx:232
art::Ptr< rb::CellHit > start_rb_
Definition: Track.h:76
bool slope_plane_is_valid() const
Definition: Track.cxx:136
std::map< std::string, double > info_
Definition: Track.h:79
unsigned max_plane() const
Definition: Track.cxx:245
void set(std::string const &name, double value)
Definition: Track.cxx:290
std::string goodness_
Definition: Track.h:78
double distance_
Definition: Track.h:67
int32_t TDC() const
The time of the last baseline sample.
Definition: RawDigit.h:94
novaddt::DAQHit start_ddt() const
Definition: Track.cxx:316
value_type val
Definition: BaseProducts.h:34
bool is_ddt_
Definition: Track.h:74
double beta_
Definition: Track.h:67
novaddt::Plane const & Plane() const
Definition: DAQHit.h:70
unsigned short Plane() const
Definition: CellHit.h:39
novaddt::TDC const & TDC() const
Definition: DAQHit.h:74
double slope_time_cell_
Definition: Track.h:67
T sqrt(T number)
Definition: d0nt_math.hpp:156
value_type val
Definition: BaseProducts.h:109
double get(std::string const &name) const
Definition: Track.cxx:303
double slope_cell_time_
Definition: Track.h:67
double dp_
Definition: Track.h:67
OStream cerr
Definition: OStream.cxx:7
const double CELL_WIDTH
Definition: Constants.h:12
novaddt::DAQHit end_ddt_
Definition: Track.h:75
double time() const
Definition: Track.cxx:115
art::Ptr< rb::CellHit > end_rb_
Definition: Track.h:76
double slope_time_plane_
Definition: Track.h:67
bool slope_time_is_valid() const
Definition: Track.cxx:143
bool is_good() const
Definition: Track.cxx:280
double slope_plane_time_
Definition: Track.h:67
unsigned short Cell() const
Definition: CellHit.h:40
double slope_plane_time() const
Definition: Track.cxx:202
unsigned max_cell() const
Definition: Track.cxx:266
const double SPEED_OF_LIGHT
Definition: Constants.h:14
double dx[NP][NC]
const XML_Char int const XML_Char * value
Definition: expat.h:331
double dz[NP][NC]
void mark_as_good()
Definition: Track.cxx:273
double calculate_distance() const
Definition: Track.cxx:58
void calculate_slopes()
Definition: Track.cxx:77
bool slope_time_is_valid_
Definition: Track.h:72
art::Ptr< rb::CellHit > end_rb() const
Definition: Track.cxx:358
novaddt::DAQHit end_ddt() const
Definition: Track.cxx:330
art::Ptr< rb::CellHit > start_rb() const
Definition: Track.cxx:344
value_type val
Definition: BaseProducts.h:84
Track(novaddt::DAQHit const &start, novaddt::DAQHit const &end)
Definition: Track.cxx:7
unsigned min_cell_
Definition: Track.h:65
double velocity_
Definition: Track.h:67
bool slope_cell_is_valid() const
Definition: Track.cxx:150
double calculate_velocity() const
Definition: Track.cxx:68
double dc_
Definition: Track.h:67
double slope_cell_plane() const
Definition: Track.cxx:157
double slope_time_plane() const
Definition: Track.cxx:172
double velocity() const
Definition: Track.cxx:122
double slope_time_cell() const
Definition: Track.cxx:217
unsigned max_cell_
Definition: Track.h:65
double slope_cell_plane_
Definition: Track.h:67
novaddt::Cell const & Cell() const
Definition: DAQHit.h:71
assert(nhit_max >=nhit_nbins)
unsigned min_cell() const
Definition: Track.cxx:259
bool slope_plane_is_valid_
Definition: Track.h:72
double dt_
Definition: Track.h:67
unsigned min_plane_
Definition: Track.h:65
T min(const caf::Proxy< T > &a, T b)
double distance() const
Definition: Track.cxx:108
double slope_cell_time() const
Definition: Track.cxx:187
const double TDC_TICK
Definition: Constants.h:13
unsigned max_plane_
Definition: Track.h:65
const double PLANE_WIDTH
Definition: Constants.h:11
bool slope_cell_is_valid_
Definition: Track.h:72
unsigned min_plane() const
Definition: Track.cxx:238
enum BeamMode string