Public Member Functions | Private Member Functions | Private Attributes | List of all members
mono::Track3D Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-26/Monopole/Track3D.h"

Public Member Functions

 Track3D ()
 
 Track3D (Track2D const &xz_track, Track2D const &yz_track)
 
TVector3 start () const
 
TVector3 velocity () const
 
double dxdz () const
 
double dydz () const
 
double dzdt (geo::View_t view) const
 
double r2_xt () const
 
double r2_yt () const
 
double r2_zt (geo::View_t view) const
 
double beta () const
 
double max_time_gap_xz () const
 
double max_time_gap_yz () const
 
rb::Cluster cluster () const
 

Private Member Functions

double get_covariance (double const &a, double const &mean_a, double const &b, double const &mean_b) const
 
double get_variance (double const &a, double const &mean_a) const
 
bool time_fit (Track2D const &track, double &dvdt, double &dzdt, double &r2_vt, double &r2_zt) const
 
double time_gap (art::PtrVector< rb::CellHit > const &hits) const
 

Private Attributes

double default_value_
 
double x0_
 
double y0_
 
double z0_
 
double dxdz_
 
double dydz_
 
double dxdt_
 
double dydt_
 
double dzdt_
 
double dzdt_x_track_
 
double dzdt_y_track_
 
double r2_xt_
 
double r2_yt_
 
double r2_zt_x_track_
 
double r2_zt_y_track_
 
double max_time_gap_xz_
 
double max_time_gap_yz_
 
double beta_
 
Track2D x_track_
 
Track2D y_track_
 
rb::Cluster cluster_
 

Detailed Description

Definition at line 21 of file Track3D.h.

Constructor & Destructor Documentation

mono::Track3D::Track3D ( )

Definition at line 18 of file Track3D.cxx.

19 {
20 }
mono::Track3D::Track3D ( Track2D const &  xz_track,
Track2D const &  yz_track 
)

Definition at line 24 of file Track3D.cxx.

References abs(), rb::Cluster::Add(), rb::Cluster::AllCells(), beta_, mono::Track2D::cluster, cluster_, dxdt_, dxdz_, dydt_, dydz_, dzdt_, dzdt_x_track_, dzdt_y_track_, mono::Track2D::intercept, max_time_gap_xz_, max_time_gap_yz_, util::pythag(), r2_xt_, r2_yt_, r2_zt_x_track_, r2_zt_y_track_, mono::Track2D::slope, mono::Constants::SPEED_OF_LIGHT, time_fit(), time_gap(), velocity(), x0_, rb::Cluster::XCells(), y0_, rb::Cluster::YCells(), and z0_.

24  :
25  default_value_ (-9999),
38  x_track_ (x_track),
39  y_track_ (y_track)
40 {
41  x0_ = x_track.intercept;
42  y0_ = y_track.intercept;
43  z0_ = 0.0;
44 
45  dxdz_ = x_track.slope;
46  dydz_ = y_track.slope;
47 
48  bool xt_fit_valid =
50  bool yt_fit_valid =
52 
53  if (xt_fit_valid && yt_fit_valid)
54  {
57  beta_ = velocity / Constants::SPEED_OF_LIGHT;
58  }
59 
60 
61  /*
62  Hit Matching
63 
64  Note that this can be done here or at the beginning of the constructor,
65  but it does not affect the x_track and y_track themselves, which are used
66  for the fit.
67  */
68  for (auto const& x_hit : x_track.cluster.AllCells())
69  {
70  bool has_match = false;
71  for (auto const& y_hit : y_track.cluster.AllCells())
72  if (abs(int(x_hit->Plane()) - int(y_hit->Plane())) <= 1)
73  has_match = true;
74 
75  if (has_match)
76  cluster_.Add(x_hit);
77  }
78 
79  for (auto const& y_hit : y_track.cluster.AllCells())
80  {
81  bool has_match = false;
82  for (auto const& x_hit : x_track.cluster.AllCells())
83  if (abs(int(x_hit->Plane()) - int(y_hit->Plane())) <= 1)
84  has_match = true;
85 
86  if (has_match)
87  cluster_.Add(y_hit);
88  }
89 
92 }
double time_gap(art::PtrVector< rb::CellHit > const &hits) const
Definition: Track3D.cxx:266
double max_time_gap_yz_
Definition: Track3D.h:67
const art::PtrVector< rb::CellHit > & XCells() const
Get all cells from the x-view.
Definition: Cluster.h:124
double z0_
Definition: Track3D.h:61
double r2_xt_
Definition: Track3D.h:65
double x0_
Definition: Track3D.h:61
double y0_
Definition: Track3D.h:61
void abs(TH1 *hist)
const double SPEED_OF_LIGHT
Definition: Constants.h:8
double dzdt_y_track_
Definition: Track3D.h:64
bool time_fit(Track2D const &track, double &dvdt, double &dzdt, double &r2_vt, double &r2_zt) const
Definition: Track3D.cxx:193
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Definition: Cluster.cxx:84
double dydz_
Definition: Track3D.h:62
double dzdt_x_track_
Definition: Track3D.h:64
const art::PtrVector< rb::CellHit > & YCells() const
Get all cells from the x-view.
Definition: Cluster.h:126
double dxdz_
Definition: Track3D.h:62
TVector3 velocity() const
Definition: Track3D.cxx:103
double r2_zt_y_track_
Definition: Track3D.h:66
double max_time_gap_xz_
Definition: Track3D.h:67
double r2_zt_x_track_
Definition: Track3D.h:66
Track2D y_track_
Definition: Track3D.h:70
double dxdt_
Definition: Track3D.h:63
rb::Cluster cluster_
Definition: Track3D.h:71
double dzdt_
Definition: Track3D.h:63
double r2_yt_
Definition: Track3D.h:65
double pythag(double x, double y)
2D Euclidean distance
Definition: MathUtil.h:29
Track2D x_track_
Definition: Track3D.h:70
double default_value_
Definition: Track3D.h:59
double dydt_
Definition: Track3D.h:63
double beta_
Definition: Track3D.h:68

Member Function Documentation

double mono::Track3D::beta ( ) const

Definition at line 178 of file Track3D.cxx.

References beta_.

Referenced by mono::MonopoleTrack::filter().

179 {
180  return beta_;
181 }
double beta_
Definition: Track3D.h:68
rb::Cluster mono::Track3D::cluster ( ) const

Definition at line 185 of file Track3D.cxx.

References cluster_, and time_fit().

Referenced by mono::MonopoleTrack::filter(), mono::Monopole::n_mc_hits(), and mono::operator<<().

186 {
187  return cluster_;
188 }
rb::Cluster cluster_
Definition: Track3D.h:71
double mono::Track3D::dxdz ( ) const

Definition at line 110 of file Track3D.cxx.

References dxdz_.

Referenced by mono::operator<<().

111 {
112  return dxdz_;
113 }
double dxdz_
Definition: Track3D.h:62
double mono::Track3D::dydz ( ) const

Definition at line 117 of file Track3D.cxx.

References dydz_.

Referenced by mono::operator<<().

118 {
119  return dydz_;
120 }
double dydz_
Definition: Track3D.h:62
double mono::Track3D::dzdt ( geo::View_t  view) const

Definition at line 124 of file Track3D.cxx.

References default_value_, dzdt_x_track_, dzdt_y_track_, kX, and kY.

125 {
126  if (view == geo::View_t::kX)
127  return dzdt_x_track_;
128 
129  if (view == geo::View_t::kY)
130  return dzdt_y_track_;
131 
132  return default_value_;
133 }
double dzdt_y_track_
Definition: Track3D.h:64
const Var kY([](const caf::SRProxy *sr){float tmp=0.f;if(sr->mc.nu.empty()) return tmp;tmp=sr->mc.nu[0].y;return tmp;})
double dzdt_x_track_
Definition: Track3D.h:64
Definition: geo.h:1
double default_value_
Definition: Track3D.h:59
double mono::Track3D::get_covariance ( double const &  a,
double const &  mean_a,
double const &  b,
double const &  mean_b 
) const
private

Definition at line 299 of file Track3D.cxx.

Referenced by get_variance(), and time_fit().

301 {
302  return (a - mean_a) * (b - mean_b);
303 }
const double a
const hit & b
Definition: hits.cxx:21
double mono::Track3D::get_variance ( double const &  a,
double const &  mean_a 
) const
private

Definition at line 291 of file Track3D.cxx.

References get_covariance().

Referenced by time_fit(), and time_gap().

292 {
293  return (a - mean_a) * (a - mean_a);
294 }
const double a
double mono::Track3D::max_time_gap_xz ( ) const

Definition at line 164 of file Track3D.cxx.

References max_time_gap_xz_.

165 {
166  return max_time_gap_xz_;
167 }
double max_time_gap_xz_
Definition: Track3D.h:67
double mono::Track3D::max_time_gap_yz ( ) const

Definition at line 171 of file Track3D.cxx.

References max_time_gap_yz_.

172 {
173  return max_time_gap_yz_;
174 }
double max_time_gap_yz_
Definition: Track3D.h:67
double mono::Track3D::r2_xt ( ) const

Definition at line 137 of file Track3D.cxx.

References r2_xt_.

138 {
139  return r2_xt_;
140 }
double r2_xt_
Definition: Track3D.h:65
double mono::Track3D::r2_yt ( ) const

Definition at line 144 of file Track3D.cxx.

References r2_yt_.

145 {
146  return r2_yt_;
147 }
double r2_yt_
Definition: Track3D.h:65
double mono::Track3D::r2_zt ( geo::View_t  view) const

Definition at line 151 of file Track3D.cxx.

References default_value_, kX, kY, r2_zt_x_track_, and r2_zt_y_track_.

152 {
153  if (view == geo::View_t::kX)
154  return r2_zt_x_track_;
155 
156  if (view == geo::View_t::kY)
157  return r2_zt_y_track_;
158 
159  return default_value_;
160 }
const Var kY([](const caf::SRProxy *sr){float tmp=0.f;if(sr->mc.nu.empty()) return tmp;tmp=sr->mc.nu[0].y;return tmp;})
double r2_zt_y_track_
Definition: Track3D.h:66
double r2_zt_x_track_
Definition: Track3D.h:66
Definition: geo.h:1
double default_value_
Definition: Track3D.h:59
TVector3 mono::Track3D::start ( ) const

Definition at line 96 of file Track3D.cxx.

References x0_, y0_, and z0_.

97 {
98  return TVector3(x0_, y0_, z0_);
99 }
double z0_
Definition: Track3D.h:61
double x0_
Definition: Track3D.h:61
double y0_
Definition: Track3D.h:61
bool mono::Track3D::time_fit ( Track2D const &  track,
double &  dvdt,
double &  dzdt,
double &  r2_vt,
double &  r2_zt 
) const
private

Definition at line 193 of file Track3D.cxx.

References rb::Cluster::AllCells(), geo::GeometryBase::CellInfo(), geo::GeometryBase::CellTpos(), mono::Track2D::cluster, default_value_, get_covariance(), get_variance(), extractScale::mean, rb::Cluster::NCell(), cet::pow(), confusionMatrixTree::t, registry_explorer::v, variance(), and test::z.

Referenced by cluster(), and Track3D().

196 {
197  dvdt = default_value_;
199  double N = track.cluster.NCell();
200  // we need at least two hits to get a non-zero variance
201  if (N <= 2)
202  return false;
203 
205 
206  std::map<std::string, double> mean = { {"v", 0.0}, {"z", 0.0}, {"t", 0.0} };
207  for (auto const& hit : track.cluster.AllCells())
208  {
209  double xyz[3];
210  geometry->CellInfo(hit->Plane(), hit->Cell(), NULL, xyz);
211  TVector3 hit_vector(xyz);
212 
213  mean.at("v") += geometry->CellTpos(hit->Plane(), hit->Cell()) / N;
214  mean.at("z") += hit_vector.z() / N;
215  mean.at("t") += hit->TNS() / N;
216  }
217 
218  std::map<std::string, double> variance =
219  { {"t", 0.0}, {"v", 0.0}, {"z", 0.0}, {"vt", 0.0}, {"zt", 0.0} };
220  for (auto const& hit : track.cluster.AllCells())
221  {
222  double xyz[3];
223  geometry->CellInfo(hit->Plane(), hit->Cell(), NULL, xyz);
224  TVector3 hit_vector(xyz);
225  double v = geometry->CellTpos(hit->Plane(), hit->Cell());
226  double z = hit_vector.z();
227  double t = hit->TNS();
228 
229  variance.at("t") += get_variance(t, mean.at("t")) / (N - 1);
230  variance.at("v") += get_variance(v, mean.at("v")) / (N - 1);
231  variance.at("z") += get_variance(z, mean.at("z")) / (N - 1);
232  variance.at("vt") +=
233  get_covariance(v, mean.at("v"), t, mean.at("t")) / (N - 1);
234  variance.at("zt") +=
235  get_covariance(z, mean.at("z"), t, mean.at("t")) / (N - 1);
236  }
237 
238  if (variance.at("t") == 0 || variance.at("v") == 0 || variance.at("z") == 0)
239  return false;
240  // throw art::Exception(art::errors::InvalidNumber)
241  // << "Monopole/Track3D.cxx\n"
242  // << "Variance is zero. Aborting.\n" << std::endl;
243 
244 
245  //
246  // Set all of the results:
247  //
248  dvdt = variance.at("vt") / variance.at("t");
249  dzdt = variance.at("zt") / variance.at("t");
250 
251  // The intercept is currently not used.
252  // double v0 = mean.at("v") - dvdt * mean.at("t");
253  // double z0 = mean.at("z") - dzdt * mean.at("t");
254 
255  // Calculate the squared correlation coefficienct (r^2):
256  r2_vt =
257  std::pow(variance.at("vt"), 2) / (variance.at("v") * variance.at("t"));
258  r2_zt =
259  std::pow(variance.at("zt"), 2) / (variance.at("z") * variance.at("t"));
260 
261  return true;
262 }
double CellTpos(unsigned int ip, unsigned int ic, double w=0.0) const
double get_variance(double const &a, double const &mean_a) const
Definition: Track3D.cxx:291
constexpr T pow(T x)
Definition: pow.h:75
Definition: event.h:19
void CellInfo(unsigned int ip, unsigned int ic, View_t *view=0, double *pos=0, double *dpos=0) const
z
Definition: test.py:28
double dzdt(geo::View_t view) const
Definition: Track3D.cxx:124
Definition: structs.h:12
double r2_zt(geo::View_t view) const
Definition: Track3D.cxx:151
double default_value_
Definition: Track3D.h:59
double get_covariance(double const &a, double const &mean_a, double const &b, double const &mean_b) const
Definition: Track3D.cxx:299
double variance(Eigen::VectorXd x)
double mono::Track3D::time_gap ( art::PtrVector< rb::CellHit > const &  hits) const
private

Definition at line 266 of file Track3D.cxx.

References default_value_, get_variance(), std::max(), fillBadChanDBTables::result, and plot_timing_data::times.

Referenced by Track3D().

267 {
268  double result = default_value_;
269 
270  std::set<double> times;
271  for (auto const& hit : hits)
272  times.insert(hit->TNS());
273 
274  std::adjacent_find
275  (times.begin(), times.end(), [&](double object, double next_object)
276  {
277  double gap = next_object - object;
278  result = std::max(gap, result);
279 
280  // This return is meaningless, but a boolean return is required by
281  // adjacent find. We choose false, so the loop goes until the end.
282  return false;
283  });
284 
285  return result;
286 }
T max(const caf::Proxy< T > &a, T b)
Definition: novas.h:112
Definition: structs.h:12
double default_value_
Definition: Track3D.h:59
TVector3 mono::Track3D::velocity ( ) const

Definition at line 103 of file Track3D.cxx.

References dxdt_, dydt_, and dzdt_.

Referenced by Track3D().

104 {
105  return TVector3(dxdt_, dydt_, dzdt_);
106 }
double dxdt_
Definition: Track3D.h:63
double dzdt_
Definition: Track3D.h:63
double dydt_
Definition: Track3D.h:63

Member Data Documentation

double mono::Track3D::beta_
private

Definition at line 68 of file Track3D.h.

Referenced by beta(), and Track3D().

rb::Cluster mono::Track3D::cluster_
private

Definition at line 71 of file Track3D.h.

Referenced by cluster(), and Track3D().

double mono::Track3D::default_value_
private

Definition at line 59 of file Track3D.h.

Referenced by dzdt(), r2_zt(), time_fit(), and time_gap().

double mono::Track3D::dxdt_
private

Definition at line 63 of file Track3D.h.

Referenced by Track3D(), and velocity().

double mono::Track3D::dxdz_
private

Definition at line 62 of file Track3D.h.

Referenced by dxdz(), and Track3D().

double mono::Track3D::dydt_
private

Definition at line 63 of file Track3D.h.

Referenced by Track3D(), and velocity().

double mono::Track3D::dydz_
private

Definition at line 62 of file Track3D.h.

Referenced by dydz(), and Track3D().

double mono::Track3D::dzdt_
private

Definition at line 63 of file Track3D.h.

Referenced by Track3D(), and velocity().

double mono::Track3D::dzdt_x_track_
private

Definition at line 64 of file Track3D.h.

Referenced by dzdt(), and Track3D().

double mono::Track3D::dzdt_y_track_
private

Definition at line 64 of file Track3D.h.

Referenced by dzdt(), and Track3D().

double mono::Track3D::max_time_gap_xz_
private

Definition at line 67 of file Track3D.h.

Referenced by max_time_gap_xz(), and Track3D().

double mono::Track3D::max_time_gap_yz_
private

Definition at line 67 of file Track3D.h.

Referenced by max_time_gap_yz(), and Track3D().

double mono::Track3D::r2_xt_
private

Definition at line 65 of file Track3D.h.

Referenced by r2_xt(), and Track3D().

double mono::Track3D::r2_yt_
private

Definition at line 65 of file Track3D.h.

Referenced by r2_yt(), and Track3D().

double mono::Track3D::r2_zt_x_track_
private

Definition at line 66 of file Track3D.h.

Referenced by r2_zt(), and Track3D().

double mono::Track3D::r2_zt_y_track_
private

Definition at line 66 of file Track3D.h.

Referenced by r2_zt(), and Track3D().

double mono::Track3D::x0_
private

Definition at line 61 of file Track3D.h.

Referenced by start(), and Track3D().

Track2D mono::Track3D::x_track_
private

Definition at line 70 of file Track3D.h.

double mono::Track3D::y0_
private

Definition at line 61 of file Track3D.h.

Referenced by start(), and Track3D().

Track2D mono::Track3D::y_track_
private

Definition at line 70 of file Track3D.h.

double mono::Track3D::z0_
private

Definition at line 61 of file Track3D.h.

Referenced by start(), and Track3D().


The documentation for this class was generated from the following files: