groups

name language licence
enum - array of labelled values C++ Other
Print a TCut C++ Other
Ternery operator / conditional expression C++ Other
Maximum likelihood, minuit example C++ Other
Commenting code including comments C++ Other
Convert string to integer C++ Other
Distance from a point to a line C++ Other



language: C++
licence: Other

Distance from a point to a line

options: view full snippetsend to code collector
Float_t distance_from_muon(Float_t n_x, Float_t n_y, Float_t n_z,
                           Float_t muon_x, Float_t muon_y, Float_t muon_z,
                           Float_t muon_u, Float_t muon_v, Float_t muon_w) {

  // Calculate the distance of a point (n_x, n_y, n_z) from a line specified
  // by a point (muon_u, muon_v, muon_w) and direction cosines (muon_u, muon_v, muon_w).

  TVector3 ref_point(n_x, n_y, n_z);
  TVector3 line_point(muon_x, muon_y, muon_z);
  TVector3 line_direction_cosines(muon_u, muon_v, muon_w);

  TVector3 v = ref_point - line_point;

  Double_t d = (line_direction_cosines.Cross(v)).Mag()
             / line_direction_cosines.Mag();
	
(Continues...)