Logo ROOT  
Reference Guide
LorentzVector.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Authors: W. Brown, M. Fischler, L. Moneta 2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 , LCG ROOT MathLib Team *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header file for class LorentzVector
12 //
13 // Created by: moneta at Tue May 31 17:06:09 2005
14 // Major mods by: fischler at Wed Jul 20 2005
15 //
16 // Last update: $Id$
17 //
18 #ifndef ROOT_Math_GenVector_LorentzVector
19 #define ROOT_Math_GenVector_LorentzVector 1
20 
22 
24 
26 
27 #include <cmath>
28 #include <string>
29 
30 namespace ROOT {
31 
32  namespace Math {
33 
34 //__________________________________________________________________________________________
35  /**
36  Class describing a generic LorentzVector in the 4D space-time,
37  using the specified coordinate system for the spatial vector part.
38  The metric used for the LorentzVector is (-,-,-,+).
39  In the case of LorentzVector we don't distinguish the concepts
40  of points and displacement vectors as in the 3D case,
41  since the main use case for 4D Vectors is to describe the kinematics of
42  relativistic particles. A LorentzVector behaves like a
43  DisplacementVector in 4D. The Minkowski components could be viewed as
44  v and t, or for kinematic 4-vectors, as p and E.
45 
46  ROOT provides specialisations and aliases to them of the ROOT::Math::LorentzVector template:
47  - ROOT::Math::PtEtaPhiMVector based on pt (rho),eta,phi and M (t) coordinates in double precision
48  - ROOT::Math::PtEtaPhiEVector based on pt (rho),eta,phi and E (t) coordinates in double precision
49  - ROOT::Math::PxPyPzMVector based on px,py,pz and M (mass) coordinates in double precision
50  - ROOT::Math::PxPyPzEVector based on px,py,pz and E (energy) coordinates in double precision
51  - ROOT::Math::XYZTVector based on x,y,z,t coordinates (cartesian) in double precision (same as PxPyPzEVector)
52  - ROOT::Math::XYZTVectorF based on x,y,z,t coordinates (cartesian) in float precision (same as PxPyPzEVector but float)
53 
54 More details about the GenVector package can be found [here](Vector.html).
55 
56 
57  @ingroup GenVector
58  */
59  template< class CoordSystem >
60  class LorentzVector {
61 
62  public:
63 
64  // ------ ctors ------
65 
66  typedef typename CoordSystem::Scalar Scalar;
67  typedef CoordSystem CoordinateType;
68 
69  /**
70  default constructor of an empty vector (Px = Py = Pz = E = 0 )
71  */
73 
74  /**
75  generic constructors from four scalar values.
76  The association between values and coordinate depends on the
77  coordinate system. For PxPyPzE4D,
78  \param a scalar value (Px)
79  \param b scalar value (Py)
80  \param c scalar value (Pz)
81  \param d scalar value (E)
82  */
84  const Scalar & b,
85  const Scalar & c,
86  const Scalar & d) :
87  fCoordinates(a , b, c, d) { }
88 
89  /**
90  constructor from a LorentzVector expressed in different
91  coordinates, or using a different Scalar type
92  */
93  template< class Coords >
94  explicit LorentzVector(const LorentzVector<Coords> & v ) :
95  fCoordinates( v.Coordinates() ) { }
96 
97  /**
98  Construct from a foreign 4D vector type, for example, HepLorentzVector
99  Precondition: v must implement methods x(), y(), z(), and t()
100  */
101  template<class ForeignLorentzVector>
102  explicit LorentzVector( const ForeignLorentzVector & v) :
103  fCoordinates(PxPyPzE4D<Scalar>( v.x(), v.y(), v.z(), v.t() ) ) { }
104 
105 #ifdef LATER
106  /**
107  construct from a generic linear algebra vector implementing operator []
108  and with a size of at least 4. This could be also a C array
109  In this case v[0] is the first data member
110  ( Px for a PxPyPzE4D base)
111  \param v LA vector
112  \param index0 index of first vector element (Px)
113  */
114  template< class LAVector >
115  explicit LorentzVector(const LAVector & v, size_t index0 ) {
116  fCoordinates = CoordSystem ( v[index0], v[index0+1], v[index0+2], v[index0+3] );
117  }
118 #endif
119 
120 
121  // ------ assignment ------
122 
123  /**
124  Assignment operator from a lorentz vector of arbitrary type
125  */
126  template< class OtherCoords >
128  fCoordinates = v.Coordinates();
129  return *this;
130  }
131 
132  /**
133  assignment from any other Lorentz vector implementing
134  x(), y(), z() and t()
135  */
136  template<class ForeignLorentzVector>
137  LorentzVector & operator = ( const ForeignLorentzVector & v) {
138  SetXYZT( v.x(), v.y(), v.z(), v.t() );
139  return *this;
140  }
141 
142 #ifdef LATER
143  /**
144  assign from a generic linear algebra vector implementing operator []
145  and with a size of at least 4
146  In this case v[0] is the first data member
147  ( Px for a PxPyPzE4D base)
148  \param v LA vector
149  \param index0 index of first vector element (Px)
150  */
151  template< class LAVector >
152  LorentzVector & AssignFrom(const LAVector & v, size_t index0=0 ) {
153  fCoordinates.SetCoordinates( v[index0], v[index0+1], v[index0+2], v[index0+3] );
154  return *this;
155  }
156 #endif
157 
158  // ------ Set, Get, and access coordinate data ------
159 
160  /**
161  Retrieve a const reference to the coordinates object
162  */
163  const CoordSystem & Coordinates() const {
164  return fCoordinates;
165  }
166 
167  /**
168  Set internal data based on an array of 4 Scalar numbers
169  */
171  fCoordinates.SetCoordinates(src);
172  return *this;
173  }
174 
175  /**
176  Set internal data based on 4 Scalar numbers
177  */
179  fCoordinates.SetCoordinates(a, b, c, d);
180  return *this;
181  }
182 
183  /**
184  Set internal data based on 4 Scalars at *begin to *end
185  */
186  template< class IT >
188  IT a = begin; IT b = ++begin; IT c = ++begin; IT d = ++begin;
189  (void)end;
190  assert (++begin==end);
191  SetCoordinates (*a,*b,*c,*d);
192  return *this;
193  }
194 
195  /**
196  get internal data into 4 Scalar numbers
197  */
198  void GetCoordinates( Scalar& a, Scalar& b, Scalar& c, Scalar & d ) const
199  { fCoordinates.GetCoordinates(a, b, c, d); }
200 
201  /**
202  get internal data into an array of 4 Scalar numbers
203  */
204  void GetCoordinates( Scalar dest[] ) const
205  { fCoordinates.GetCoordinates(dest); }
206 
207  /**
208  get internal data into 4 Scalars at *begin to *end
209  */
210  template <class IT>
211  void GetCoordinates( IT begin, IT end ) const
212  { IT a = begin; IT b = ++begin; IT c = ++begin; IT d = ++begin;
213  (void)end;
214  assert (++begin==end);
215  GetCoordinates (*a,*b,*c,*d);
216  }
217 
218  /**
219  get internal data into 4 Scalars at *begin
220  */
221  template <class IT>
222  void GetCoordinates( IT begin ) const {
223  Scalar a,b,c,d = 0;
224  GetCoordinates (a,b,c,d);
225  *begin++ = a;
226  *begin++ = b;
227  *begin++ = c;
228  *begin = d;
229  }
230 
231  /**
232  set the values of the vector from the cartesian components (x,y,z,t)
233  (if the vector is held in another coordinates, like (Pt,eta,phi,m)
234  then (x, y, z, t) are converted to that form)
235  */
237  fCoordinates.SetPxPyPzE(xx,yy,zz,tt);
238  return *this;
239  }
241  fCoordinates.SetPxPyPzE(xx,yy,zz,ee);
242  return *this;
243  }
244 
245  // ------------------- Equality -----------------
246 
247  /**
248  Exact equality
249  */
250  bool operator==(const LorentzVector & rhs) const {
251  return fCoordinates==rhs.fCoordinates;
252  }
253  bool operator!= (const LorentzVector & rhs) const {
254  return !(operator==(rhs));
255  }
256 
257  // ------ Individual element access, in various coordinate systems ------
258 
259  // individual coordinate accessors in various coordinate systems
260 
261  /**
262  spatial X component
263  */
264  Scalar Px() const { return fCoordinates.Px(); }
265  Scalar X() const { return fCoordinates.Px(); }
266  /**
267  spatial Y component
268  */
269  Scalar Py() const { return fCoordinates.Py(); }
270  Scalar Y() const { return fCoordinates.Py(); }
271  /**
272  spatial Z component
273  */
274  Scalar Pz() const { return fCoordinates.Pz(); }
275  Scalar Z() const { return fCoordinates.Pz(); }
276  /**
277  return 4-th component (time, or energy for a 4-momentum vector)
278  */
279  Scalar E() const { return fCoordinates.E(); }
280  Scalar T() const { return fCoordinates.E(); }
281  /**
282  return magnitude (mass) squared M2 = T**2 - X**2 - Y**2 - Z**2
283  (we use -,-,-,+ metric)
284  */
285  Scalar M2() const { return fCoordinates.M2(); }
286  /**
287  return magnitude (mass) using the (-,-,-,+) metric.
288  If M2 is negative (space-like vector) a GenVector_exception
289  is suggested and if continuing, - sqrt( -M2) is returned
290  */
291  Scalar M() const { return fCoordinates.M();}
292  /**
293  return the spatial (3D) magnitude ( sqrt(X**2 + Y**2 + Z**2) )
294  */
295  Scalar R() const { return fCoordinates.R(); }
296  Scalar P() const { return fCoordinates.R(); }
297  /**
298  return the square of the spatial (3D) magnitude ( X**2 + Y**2 + Z**2 )
299  */
300  Scalar P2() const { return P() * P(); }
301  /**
302  return the square of the transverse spatial component ( X**2 + Y**2 )
303  */
304  Scalar Perp2( ) const { return fCoordinates.Perp2();}
305 
306  /**
307  return the transverse spatial component sqrt ( X**2 + Y**2 )
308  */
309  Scalar Pt() const { return fCoordinates.Pt(); }
310  Scalar Rho() const { return fCoordinates.Pt(); }
311 
312  /**
313  return the transverse mass squared
314  \f[ m_t^2 = E^2 - p{_z}^2 \f]
315  */
316  Scalar Mt2() const { return fCoordinates.Mt2(); }
317 
318  /**
319  return the transverse mass
320  \f[ \sqrt{ m_t^2 = E^2 - p{_z}^2} X sign(E^ - p{_z}^2) \f]
321  */
322  Scalar Mt() const { return fCoordinates.Mt(); }
323 
324  /**
325  return the transverse energy squared
326  \f[ e_t = \frac{E^2 p_{\perp}^2 }{ |p|^2 } \f]
327  */
328  Scalar Et2() const { return fCoordinates.Et2(); }
329 
330  /**
331  return the transverse energy
332  \f[ e_t = \sqrt{ \frac{E^2 p_{\perp}^2 }{ |p|^2 } } X sign(E) \f]
333  */
334  Scalar Et() const { return fCoordinates.Et(); }
335 
336  /**
337  azimuthal Angle
338  */
339  Scalar Phi() const { return fCoordinates.Phi();}
340 
341  /**
342  polar Angle
343  */
344  Scalar Theta() const { return fCoordinates.Theta(); }
345 
346  /**
347  pseudorapidity
348  \f[ \eta = - \ln { \tan { \frac { \theta} {2} } } \f]
349  */
350  Scalar Eta() const { return fCoordinates.Eta(); }
351 
352  /**
353  get the spatial components of the Vector in a
354  DisplacementVector based on Cartesian Coordinates
355  */
357  return ::ROOT::Math::DisplacementVector3D<Cartesian3D<Scalar> >( X(), Y(), Z() );
358  }
359 
360  // ------ Operations combining two Lorentz vectors ------
361 
362  /**
363  scalar (Dot) product of two LorentzVector vectors (metric is -,-,-,+)
364  Enable the product using any other LorentzVector implementing
365  the x(), y() , y() and t() member functions
366  \param q any LorentzVector implementing the x(), y() , z() and t()
367  member functions
368  \return the result of v.q of type according to the base scalar type of v
369  */
370 
371  template< class OtherLorentzVector >
372  Scalar Dot(const OtherLorentzVector & q) const {
373  return t()*q.t() - x()*q.x() - y()*q.y() - z()*q.z();
374  }
375 
376  /**
377  Self addition with another Vector ( v+= q )
378  Enable the addition with any other LorentzVector
379  \param q any LorentzVector implementing the x(), y() , z() and t()
380  member functions
381  */
382  template< class OtherLorentzVector >
383  inline LorentzVector & operator += ( const OtherLorentzVector & q)
384  {
385  SetXYZT( x() + q.x(), y() + q.y(), z() + q.z(), t() + q.t() );
386  return *this;
387  }
388 
389  /**
390  Self subtraction of another Vector from this ( v-= q )
391  Enable the addition with any other LorentzVector
392  \param q any LorentzVector implementing the x(), y() , z() and t()
393  member functions
394  */
395  template< class OtherLorentzVector >
396  LorentzVector & operator -= ( const OtherLorentzVector & q) {
397  SetXYZT( x() - q.x(), y() - q.y(), z() - q.z(), t() - q.t() );
398  return *this;
399  }
400 
401  /**
402  addition of two LorentzVectors (v3 = v1 + v2)
403  Enable the addition with any other LorentzVector
404  \param v2 any LorentzVector implementing the x(), y() , z() and t()
405  member functions
406  \return a new LorentzVector of the same type as v1
407  */
408  template<class OtherLorentzVector>
409  LorentzVector operator + ( const OtherLorentzVector & v2) const
410  {
412  v3 += v2;
413  return v3;
414  }
415 
416  /**
417  subtraction of two LorentzVectors (v3 = v1 - v2)
418  Enable the subtraction of any other LorentzVector
419  \param v2 any LorentzVector implementing the x(), y() , z() and t()
420  member functions
421  \return a new LorentzVector of the same type as v1
422  */
423  template<class OtherLorentzVector>
424  LorentzVector operator - ( const OtherLorentzVector & v2) const {
426  v3 -= v2;
427  return v3;
428  }
429 
430  //--- scaling operations ------
431 
432  /**
433  multiplication by a scalar quantity v *= a
434  */
436  fCoordinates.Scale(a);
437  return *this;
438  }
439 
440  /**
441  division by a scalar quantity v /= a
442  */
444  fCoordinates.Scale(1/a);
445  return *this;
446  }
447 
448  /**
449  product of a LorentzVector by a scalar quantity
450  \param a scalar quantity of type a
451  \return a new mathcoreLorentzVector q = v * a same type as v
452  */
453  LorentzVector operator * ( const Scalar & a) const {
454  LorentzVector tmp(*this);
455  tmp *= a;
456  return tmp;
457  }
458 
459  /**
460  Divide a LorentzVector by a scalar quantity
461  \param a scalar quantity of type a
462  \return a new mathcoreLorentzVector q = v / a same type as v
463  */
465  LorentzVector<CoordSystem> tmp(*this);
466  tmp /= a;
467  return tmp;
468  }
469 
470  /**
471  Negative of a LorentzVector (q = - v )
472  \return a new LorentzVector with opposite direction and time
473  */
475  //LorentzVector<CoordinateType> v(*this);
476  //v.Negate();
477  return operator*( Scalar(-1) );
478  }
480  return *this;
481  }
482 
483  // ---- Relativistic Properties ----
484 
485  /**
486  Rapidity relative to the Z axis: .5 log [(E+Pz)/(E-Pz)]
487  */
488  Scalar Rapidity() const {
489  // TODO - It would be good to check that E > Pz and use the Throw()
490  // mechanism or at least load a NAN if not.
491  // We should then move the code to a .cpp file.
492  const Scalar ee = E();
493  const Scalar ppz = Pz();
494  return Scalar(0.5) * log((ee + ppz) / (ee - ppz));
495  }
496 
497  /**
498  Rapidity in the direction of travel: atanh (|P|/E)=.5 log[(E+P)/(E-P)]
499  */
501  // TODO - It would be good to check that E > P and use the Throw()
502  // mechanism or at least load a NAN if not.
503  const Scalar ee = E();
504  const Scalar pp = P();
505  return Scalar(0.5) * log((ee + pp) / (ee - pp));
506  }
507 
508  /**
509  Determine if momentum-energy can represent a physical massive particle
510  */
511  bool isTimelike( ) const {
512  Scalar ee = E(); Scalar pp = P(); return ee*ee > pp*pp;
513  }
514 
515  /**
516  Determine if momentum-energy can represent a massless particle
517  */
518  bool isLightlike( Scalar tolerance
519  = 100*std::numeric_limits<Scalar>::epsilon() ) const {
520  Scalar ee = E(); Scalar pp = P(); Scalar delta = ee-pp;
521  if ( ee==0 ) return pp==0;
522  return delta*delta < tolerance * ee*ee;
523  }
524 
525  /**
526  Determine if momentum-energy is spacelike, and represents a tachyon
527  */
528  bool isSpacelike( ) const {
529  Scalar ee = E(); Scalar pp = P(); return ee*ee < pp*pp;
530  }
531 
533 
534  /**
535  The beta vector for the boost that would bring this vector into
536  its center of mass frame (zero momentum)
537  */
539  if (E() == 0) {
540  if (P() == 0) {
541  return BetaVector();
542  } else {
543  // TODO - should attempt to Throw with msg about
544  // boostVector computed for LorentzVector with t=0
545  return -Vect()/E();
546  }
547  }
548  if (M2() <= 0) {
549  // TODO - should attempt to Throw with msg about
550  // boostVector computed for a non-timelike LorentzVector
551  }
552  return -Vect()/E();
553  }
554 
555  /**
556  The beta vector for the boost that would bring this vector into
557  its center of mass frame (zero momentum)
558  */
559  template <class Other4Vector>
560  BetaVector BoostToCM(const Other4Vector& v ) const {
561  Scalar eSum = E() + v.E();
562  DisplacementVector3D< Cartesian3D<Scalar> > vecSum = Vect() + v.Vect();
563  if (eSum == 0) {
564  if (vecSum.Mag2() == 0) {
565  return BetaVector();
566  } else {
567  // TODO - should attempt to Throw with msg about
568  // boostToCM computed for two 4-vectors with combined t=0
569  return BetaVector(vecSum/eSum);
570  }
571  // TODO - should attempt to Throw with msg about
572  // boostToCM computed for two 4-vectors with combined e=0
573  }
574  return BetaVector (vecSum * (-1./eSum));
575  }
576 
577  //beta and gamma
578 
579  /**
580  Return beta scalar value
581  */
582  Scalar Beta() const {
583  if ( E() == 0 ) {
584  if ( P2() == 0)
585  // to avoid Nan
586  return 0;
587  else {
588  GenVector::Throw ("LorentzVector::Beta() - beta computed for LorentzVector with t = 0. Return an Infinite result");
589  return 1./E();
590  }
591  }
592  if ( M2() <= 0 ) {
593  GenVector::Throw ("LorentzVector::Beta() - beta computed for non-timelike LorentzVector . Result is physically meaningless" );
594  }
595  return P() / E();
596  }
597  /**
598  Return Gamma scalar value
599  */
600  Scalar Gamma() const {
601  const Scalar v2 = P2();
602  const Scalar t2 = E() * E();
603  if (E() == 0) {
604  if ( P2() == 0) {
605  return 1;
606  } else {
607  GenVector::Throw ("LorentzVector::Gamma() - gamma computed for LorentzVector with t = 0. Return a zero result");
608 
609  }
610  }
611  if ( t2 < v2 ) {
612  GenVector::Throw ("LorentzVector::Gamma() - gamma computed for a spacelike LorentzVector. Imaginary result");
613  return 0;
614  }
615  else if ( t2 == v2 ) {
616  GenVector::Throw ("LorentzVector::Gamma() - gamma computed for a lightlike LorentzVector. Infinite result");
617  }
618  return Scalar(1) / sqrt(Scalar(1) - v2 / t2);
619  } /* gamma */
620 
621 
622  // Method providing limited backward name compatibility with CLHEP ----
623 
624  Scalar x() const { return fCoordinates.Px(); }
625  Scalar y() const { return fCoordinates.Py(); }
626  Scalar z() const { return fCoordinates.Pz(); }
627  Scalar t() const { return fCoordinates.E(); }
628  Scalar px() const { return fCoordinates.Px(); }
629  Scalar py() const { return fCoordinates.Py(); }
630  Scalar pz() const { return fCoordinates.Pz(); }
631  Scalar e() const { return fCoordinates.E(); }
632  Scalar r() const { return fCoordinates.R(); }
633  Scalar theta() const { return fCoordinates.Theta(); }
634  Scalar phi() const { return fCoordinates.Phi(); }
635  Scalar rho() const { return fCoordinates.Rho(); }
636  Scalar eta() const { return fCoordinates.Eta(); }
637  Scalar pt() const { return fCoordinates.Pt(); }
638  Scalar perp2() const { return fCoordinates.Perp2(); }
639  Scalar mag2() const { return fCoordinates.M2(); }
640  Scalar mag() const { return fCoordinates.M(); }
641  Scalar mt() const { return fCoordinates.Mt(); }
642  Scalar mt2() const { return fCoordinates.Mt2(); }
643 
644 
645  // Methods requested by CMS ---
646  Scalar energy() const { return fCoordinates.E(); }
647  Scalar mass() const { return fCoordinates.M(); }
648  Scalar mass2() const { return fCoordinates.M2(); }
649 
650 
651  /**
652  Methods setting a Single-component
653  Work only if the component is one of which the vector is represented.
654  For example SetE will work for a PxPyPzE Vector but not for a PxPyPzM Vector.
655  */
656  LorentzVector<CoordSystem>& SetE ( Scalar a ) { fCoordinates.SetE (a); return *this; }
657  LorentzVector<CoordSystem>& SetEta( Scalar a ) { fCoordinates.SetEta(a); return *this; }
658  LorentzVector<CoordSystem>& SetM ( Scalar a ) { fCoordinates.SetM (a); return *this; }
659  LorentzVector<CoordSystem>& SetPhi( Scalar a ) { fCoordinates.SetPhi(a); return *this; }
660  LorentzVector<CoordSystem>& SetPt ( Scalar a ) { fCoordinates.SetPt (a); return *this; }
661  LorentzVector<CoordSystem>& SetPx ( Scalar a ) { fCoordinates.SetPx (a); return *this; }
662  LorentzVector<CoordSystem>& SetPy ( Scalar a ) { fCoordinates.SetPy (a); return *this; }
663  LorentzVector<CoordSystem>& SetPz ( Scalar a ) { fCoordinates.SetPz (a); return *this; }
664 
665  private:
666 
667  CoordSystem fCoordinates; // internal coordinate system
668 
669 
670  }; // LorentzVector<>
671 
672 
673 
674  // global nethods
675 
676  /**
677  Scale of a LorentzVector with a scalar quantity a
678  \param a scalar quantity of typpe a
679  \param v mathcore::LorentzVector based on any coordinate system
680  \return a new mathcoreLorentzVector q = v * a same type as v
681  */
682  template< class CoordSystem >
683  inline LorentzVector<CoordSystem> operator *
684  ( const typename LorentzVector<CoordSystem>::Scalar & a,
685  const LorentzVector<CoordSystem>& v) {
687  tmp *= a;
688  return tmp;
689  }
690 
691  // ------------- I/O to/from streams -------------
692 
693  template< class char_t, class traits_t, class Coords >
694  inline
695  std::basic_ostream<char_t,traits_t> &
696  operator << ( std::basic_ostream<char_t,traits_t> & os
697  , LorentzVector<Coords> const & v
698  )
699  {
700  if( !os ) return os;
701 
702  typename Coords::Scalar a, b, c, d;
703  v.GetCoordinates(a, b, c, d);
704 
705  if( detail::get_manip( os, detail::bitforbit ) ) {
706  detail::set_manip( os, detail::bitforbit, '\00' );
707  // TODO: call MF's bitwise-accurate functions on each of a, b, c, d
708  }
709  else {
710  os << detail::get_manip( os, detail::open ) << a
711  << detail::get_manip( os, detail::sep ) << b
712  << detail::get_manip( os, detail::sep ) << c
713  << detail::get_manip( os, detail::sep ) << d
715  }
716 
717  return os;
718 
719  } // op<< <>()
720 
721 
722  template< class char_t, class traits_t, class Coords >
723  inline
724  std::basic_istream<char_t,traits_t> &
725  operator >> ( std::basic_istream<char_t,traits_t> & is
727  )
728  {
729  if( !is ) return is;
730 
731  typename Coords::Scalar a, b, c, d;
732 
733  if( detail::get_manip( is, detail::bitforbit ) ) {
734  detail::set_manip( is, detail::bitforbit, '\00' );
735  // TODO: call MF's bitwise-accurate functions on each of a, b, c
736  }
737  else {
738  detail::require_delim( is, detail::open ); is >> a;
739  detail::require_delim( is, detail::sep ); is >> b;
740  detail::require_delim( is, detail::sep ); is >> c;
741  detail::require_delim( is, detail::sep ); is >> d;
743  }
744 
745  if( is )
746  v.SetCoordinates(a, b, c, d);
747  return is;
748 
749  } // op>> <>()
750 
751 
752 
753  } // end namespace Math
754 
755 } // end namespace ROOT
756 
757 #include <sstream>
758 namespace cling
759 {
760 template<typename CoordSystem>
761 std::string printValue(const ROOT::Math::LorentzVector<CoordSystem> *v)
762 {
763  std::stringstream s;
764  s << *v;
765  return s.str();
766 }
767 
768 } // end namespace cling
769 
770 #endif
771 
772 //#include "Math/GenVector/LorentzVectorOperations.h"
773 
774 
775 
ROOT::Math::DisplacementVector3D::Mag2
Scalar Mag2() const
Magnitute squared ( r^2 in spherical coordinate)
Definition: DisplacementVector3D.h:324
c
#define c(i)
Definition: RSha256.hxx:101
ROOT::Math::LorentzVector::operator*
LorentzVector operator*(const Scalar &a) const
product of a LorentzVector by a scalar quantity
Definition: LorentzVector.h:453
ROOT::Math::LorentzVector::Y
Scalar Y() const
Definition: LorentzVector.h:270
ROOT::Math::LorentzVector::operator+
LorentzVector operator+() const
Definition: LorentzVector.h:479
ROOT::Math::LorentzVector::ColinearRapidity
Scalar ColinearRapidity() const
Rapidity in the direction of travel: atanh (|P|/E)=.5 log[(E+P)/(E-P)].
Definition: LorentzVector.h:500
ROOT::Math::LorentzVector::r
Scalar r() const
Definition: LorentzVector.h:632
ROOT::Math::LorentzVector::Mt2
Scalar Mt2() const
return the transverse mass squared
Definition: LorentzVector.h:316
ROOT::Math::LorentzVector::BoostToCM
BetaVector BoostToCM() const
The beta vector for the boost that would bring this vector into its center of mass frame (zero moment...
Definition: LorentzVector.h:538
tt
auto * tt
Definition: textangle.C:16
ROOT::Math::LorentzVector::energy
Scalar energy() const
Definition: LorentzVector.h:646
ROOT::Math::LorentzVector::Mt
Scalar Mt() const
return the transverse mass
Definition: LorentzVector.h:322
ROOT::Math::LorentzVector::SetPx
LorentzVector< CoordSystem > & SetPx(Scalar a)
Definition: LorentzVector.h:661
ROOT::Math::LorentzVector::phi
Scalar phi() const
Definition: LorentzVector.h:634
ROOT::Math::LorentzVector::SetCoordinates
LorentzVector< CoordSystem > & SetCoordinates(Scalar a, Scalar b, Scalar c, Scalar d)
Set internal data based on 4 Scalar numbers.
Definition: LorentzVector.h:178
ROOT::Math::LorentzVector::Et2
Scalar Et2() const
return the transverse energy squared
Definition: LorentzVector.h:328
ROOT::Math::LorentzVector::isSpacelike
bool isSpacelike() const
Determine if momentum-energy is spacelike, and represents a tachyon.
Definition: LorentzVector.h:528
ROOT::Math::LorentzVector::Vect
::ROOT::Math::DisplacementVector3D< Cartesian3D< Scalar > > Vect() const
get the spatial components of the Vector in a DisplacementVector based on Cartesian Coordinates
Definition: LorentzVector.h:356
dest
#define dest(otri, vertexptr)
Definition: triangle.c:1040
ROOT::Math::LorentzVector::mt2
Scalar mt2() const
Definition: LorentzVector.h:642
ROOT::Math::LorentzVector::operator-=
LorentzVector & operator-=(const OtherLorentzVector &q)
Self subtraction of another Vector from this ( v-= q ) Enable the addition with any other LorentzVect...
Definition: LorentzVector.h:396
ROOT::Math::LorentzVector::rho
Scalar rho() const
Definition: LorentzVector.h:635
ROOT::Math::LorentzVector::SetXYZT
LorentzVector< CoordSystem > & SetXYZT(Scalar xx, Scalar yy, Scalar zz, Scalar tt)
set the values of the vector from the cartesian components (x,y,z,t) (if the vector is held in anothe...
Definition: LorentzVector.h:236
ROOT::Math::LorentzVector::pz
Scalar pz() const
Definition: LorentzVector.h:630
ROOT::Math::LorentzVector::pt
Scalar pt() const
Definition: LorentzVector.h:637
ROOT::Math::LorentzVector::mag2
Scalar mag2() const
Definition: LorentzVector.h:639
ROOT::Math::LorentzVector::perp2
Scalar perp2() const
Definition: LorentzVector.h:638
ROOT::Math::LorentzVector::BetaVector
DisplacementVector3D< Cartesian3D< Scalar > > BetaVector
Definition: LorentzVector.h:532
ROOT::Math::LorentzVector::GetCoordinates
void GetCoordinates(Scalar dest[]) const
get internal data into an array of 4 Scalar numbers
Definition: LorentzVector.h:204
ROOT::Math::LorentzVector::operator-
LorentzVector operator-() const
Negative of a LorentzVector (q = - v )
Definition: LorentzVector.h:474
ROOT::Math::LorentzVector::GetCoordinates
void GetCoordinates(IT begin, IT end) const
get internal data into 4 Scalars at *begin to *end
Definition: LorentzVector.h:211
ROOT::Math::LorentzVector::fCoordinates
CoordSystem fCoordinates
Definition: LorentzVector.h:667
log
double log(double)
ROOT::Math::LorentzVector::Theta
Scalar Theta() const
polar Angle
Definition: LorentzVector.h:344
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
ROOT::Math::LorentzVector::mag
Scalar mag() const
Definition: LorentzVector.h:640
ROOT::Math::LorentzVector::Coordinates
const CoordSystem & Coordinates() const
Retrieve a const reference to the coordinates object.
Definition: LorentzVector.h:163
ROOT::Math::operator<<
std::ostream & operator<<(std::ostream &os, const AxisAngle &a)
Stream Output and Input.
Definition: AxisAngle.cxx:91
ROOT::Math::LorentzVector::theta
Scalar theta() const
Definition: LorentzVector.h:633
ROOT::Math::LorentzVector::Eta
Scalar Eta() const
pseudorapidity
Definition: LorentzVector.h:350
ROOT::Math::LorentzVector::operator!=
bool operator!=(const LorentzVector &rhs) const
Definition: LorentzVector.h:253
ROOT::Math::LorentzVector::isTimelike
bool isTimelike() const
Determine if momentum-energy can represent a physical massive particle.
Definition: LorentzVector.h:511
ROOT::Math::LorentzVector::LorentzVector
LorentzVector(const LorentzVector< Coords > &v)
constructor from a LorentzVector expressed in different coordinates, or using a different Scalar type
Definition: LorentzVector.h:94
ROOT::Math::LorentzVector::eta
Scalar eta() const
Definition: LorentzVector.h:636
ROOT::Math::detail::open
@ open
Definition: GenVectorIO.h:35
ROOT::Math::LorentzVector::Dot
Scalar Dot(const OtherLorentzVector &q) const
scalar (Dot) product of two LorentzVector vectors (metric is -,-,-,+) Enable the product using any ot...
Definition: LorentzVector.h:372
v
@ v
Definition: rootcling_impl.cxx:3635
ROOT::Math::LorentzVector::LorentzVector
LorentzVector()
default constructor of an empty vector (Px = Py = Pz = E = 0 )
Definition: LorentzVector.h:72
b
#define b(i)
Definition: RSha256.hxx:100
ROOT::Math::operator>>
std::basic_istream< char_t, traits_t > & operator>>(std::basic_istream< char_t, traits_t > &is, DisplacementVector2D< T, U > &v)
Definition: DisplacementVector2D.h:508
ROOT::Math::detail::get_manip
char_t get_manip(std::basic_ios< char_t, traits_t > &ios, manip_t m)
Definition: GenVectorIO.h:54
ROOT::Math::LorentzVector::SetCoordinates
LorentzVector< CoordSystem > & SetCoordinates(const Scalar src[])
Set internal data based on an array of 4 Scalar numbers.
Definition: LorentzVector.h:170
ROOT::Math::LorentzVector::mass
Scalar mass() const
Definition: LorentzVector.h:647
ROOT::Math::LorentzVector::SetCoordinates
LorentzVector< CoordSystem > & SetCoordinates(IT begin, IT end)
Set internal data based on 4 Scalars at *begin to *end.
Definition: LorentzVector.h:187
ROOT::Math::LorentzVector::LorentzVector
LorentzVector(const Scalar &a, const Scalar &b, const Scalar &c, const Scalar &d)
generic constructors from four scalar values.
Definition: LorentzVector.h:83
q
float * q
Definition: THbookFile.cxx:89
ROOT::Math::LorentzVector::GetCoordinates
void GetCoordinates(IT begin) const
get internal data into 4 Scalars at *begin
Definition: LorentzVector.h:222
ROOT::Math::LorentzVector::operator=
LorentzVector & operator=(const LorentzVector< OtherCoords > &v)
Assignment operator from a lorentz vector of arbitrary type.
Definition: LorentzVector.h:127
ROOT::Math::LorentzVector::SetPy
LorentzVector< CoordSystem > & SetPy(Scalar a)
Definition: LorentzVector.h:662
ROOT::Math::LorentzVector::SetM
LorentzVector< CoordSystem > & SetM(Scalar a)
Definition: LorentzVector.h:658
ROOT::Math::LorentzVector::SetE
LorentzVector< CoordSystem > & SetE(Scalar a)
Methods setting a Single-component Work only if the component is one of which the vector is represent...
Definition: LorentzVector.h:656
ROOT::Math::GenVector::Throw
void Throw(const char *)
function throwing exception, by creating internally a GenVector_exception only when needed
Definition: GenVector_exception.h:80
ROOT::Math::LorentzVector::Scalar
CoordSystem::Scalar Scalar
Definition: LorentzVector.h:66
ROOT::Math::sqrt
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
Definition: UnaryOperators.h:281
ROOT::Math::LorentzVector::x
Scalar x() const
Definition: LorentzVector.h:624
ROOT::Math::LorentzVector::Phi
Scalar Phi() const
azimuthal Angle
Definition: LorentzVector.h:339
epsilon
REAL epsilon
Definition: triangle.c:617
ROOT::Math::LorentzVector::operator+=
LorentzVector & operator+=(const OtherLorentzVector &q)
Self addition with another Vector ( v+= q ) Enable the addition with any other LorentzVector.
Definition: LorentzVector.h:383
ROOT::Math::LorentzVector::Et
Scalar Et() const
return the transverse energy
Definition: LorentzVector.h:334
a
auto * a
Definition: textangle.C:12
ROOT::Math::LorentzVector::SetPhi
LorentzVector< CoordSystem > & SetPhi(Scalar a)
Definition: LorentzVector.h:659
ROOT::Math::LorentzVector::E
Scalar E() const
return 4-th component (time, or energy for a 4-momentum vector)
Definition: LorentzVector.h:279
ROOT::Math::detail::set_manip
void set_manip(std::basic_ios< char_t, traits_t > &ios, manip_t m, char_t ch)
Definition: GenVectorIO.h:74
ROOT::Math::detail::bitforbit
@ bitforbit
Definition: GenVectorIO.h:35
ROOT::Math::LorentzVector::X
Scalar X() const
Definition: LorentzVector.h:265
ROOT::Math::LorentzVector::SetPt
LorentzVector< CoordSystem > & SetPt(Scalar a)
Definition: LorentzVector.h:660
ROOT::Math::LorentzVector::Rho
Scalar Rho() const
Definition: LorentzVector.h:310
ROOT::Math::LorentzVector::operator==
bool operator==(const LorentzVector &rhs) const
Exact equality.
Definition: LorentzVector.h:250
ROOT::Math::LorentzVector::GetCoordinates
void GetCoordinates(Scalar &a, Scalar &b, Scalar &c, Scalar &d) const
get internal data into 4 Scalar numbers
Definition: LorentzVector.h:198
ROOT::Math::LorentzVector::P
Scalar P() const
Definition: LorentzVector.h:296
ROOT::Math::LorentzVector::e
Scalar e() const
Definition: LorentzVector.h:631
ROOT::Math::LorentzVector::Gamma
Scalar Gamma() const
Return Gamma scalar value.
Definition: LorentzVector.h:600
ROOT::Math::LorentzVector::Z
Scalar Z() const
Definition: LorentzVector.h:275
void
typedef void((*Func_t)())
PxPyPzE4D.h
ROOT::Math::LorentzVector::Py
Scalar Py() const
spatial Y component
Definition: LorentzVector.h:269
ROOT::Math::LorentzVector::y
Scalar y() const
Definition: LorentzVector.h:625
ROOT::Math::LorentzVector::R
Scalar R() const
return the spatial (3D) magnitude ( sqrt(X**2 + Y**2 + Z**2) )
Definition: LorentzVector.h:295
ROOT::Math::detail::close
@ close
Definition: GenVectorIO.h:35
ROOT::Math::LorentzVector::isLightlike
bool isLightlike(Scalar tolerance=100 *std::numeric_limits< Scalar >::epsilon()) const
Determine if momentum-energy can represent a massless particle.
Definition: LorentzVector.h:518
ROOT::Math::LorentzVector::Beta
Scalar Beta() const
Return beta scalar value.
Definition: LorentzVector.h:582
DisplacementVector3D.h
ROOT::Math::LorentzVector::T
Scalar T() const
Definition: LorentzVector.h:280
ROOT::Math::LorentzVector::Rapidity
Scalar Rapidity() const
Rapidity relative to the Z axis: .5 log [(E+Pz)/(E-Pz)].
Definition: LorentzVector.h:488
ROOT::Math::LorentzVector::Pz
Scalar Pz() const
spatial Z component
Definition: LorentzVector.h:274
ROOT::Math::LorentzVector::LorentzVector
LorentzVector(const ForeignLorentzVector &v)
Construct from a foreign 4D vector type, for example, HepLorentzVector Precondition: v must implement...
Definition: LorentzVector.h:102
ROOT::Math::LorentzVector::BoostToCM
BetaVector BoostToCM(const Other4Vector &v) const
The beta vector for the boost that would bring this vector into its center of mass frame (zero moment...
Definition: LorentzVector.h:560
ROOT::Math::LorentzVector::operator/
LorentzVector< CoordSystem > operator/(const Scalar &a) const
Divide a LorentzVector by a scalar quantity.
Definition: LorentzVector.h:464
ROOT::Math::Scalar
Rotation3D::Scalar Scalar
Definition: Rotation3DxAxial.cxx:69
v3
@ v3
Definition: rootcling_impl.cxx:3639
ROOT::Math::LorentzVector::Pt
Scalar Pt() const
return the transverse spatial component sqrt ( X**2 + Y**2 )
Definition: LorentzVector.h:309
v2
@ v2
Definition: rootcling_impl.cxx:3638
ROOT::Math::LorentzVector::mass2
Scalar mass2() const
Definition: LorentzVector.h:648
ROOT::Math::LorentzVector::P2
Scalar P2() const
return the square of the spatial (3D) magnitude ( X**2 + Y**2 + Z**2 )
Definition: LorentzVector.h:300
ROOT::Math::LorentzVector::M
Scalar M() const
return magnitude (mass) using the (-,-,-,+) metric.
Definition: LorentzVector.h:291
ROOT::Math::LorentzVector::SetEta
LorentzVector< CoordSystem > & SetEta(Scalar a)
Definition: LorentzVector.h:657
ROOT::Math::LorentzVector::mt
Scalar mt() const
Definition: LorentzVector.h:641
ROOT::Math::LorentzVector::px
Scalar px() const
Definition: LorentzVector.h:628
ROOT::Math::DisplacementVector3D
Class describing a generic displacement vector in 3 dimensions.
Definition: DisplacementVector3D.h:67
d
#define d(i)
Definition: RSha256.hxx:102
ROOT::Math::LorentzVector::Perp2
Scalar Perp2() const
return the square of the transverse spatial component ( X**2 + Y**2 )
Definition: LorentzVector.h:304
ROOT::Math::LorentzVector::t
Scalar t() const
Definition: LorentzVector.h:627
ROOT::Math::LorentzVector::operator*=
LorentzVector & operator*=(Scalar a)
multiplication by a scalar quantity v *= a
Definition: LorentzVector.h:435
ROOT::Math::LorentzVector::z
Scalar z() const
Definition: LorentzVector.h:626
ROOT::Math::detail::sep
@ sep
Definition: GenVectorIO.h:35
ROOT::Math::LorentzVector::Px
Scalar Px() const
spatial X component
Definition: LorentzVector.h:264
ROOT::Math::LorentzVector::M2
Scalar M2() const
return magnitude (mass) squared M2 = T**2 - X**2 - Y**2 - Z**2 (we use -,-,-,+ metric)
Definition: LorentzVector.h:285
ROOT::Math::detail::require_delim
std::basic_istream< char_t, traits_t > & require_delim(std::basic_istream< char_t, traits_t > &is, manip_t m)
Definition: GenVectorIO.h:113
GenVectorIO.h
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Math::LorentzVector::CoordinateType
CoordSystem CoordinateType
Definition: LorentzVector.h:67
Math
Namespace for new Math classes and functions.
ROOT::Math::LorentzVector::SetPxPyPzE
LorentzVector< CoordSystem > & SetPxPyPzE(Scalar xx, Scalar yy, Scalar zz, Scalar ee)
Definition: LorentzVector.h:240
ROOT::Math::PxPyPzE4D
Class describing a 4D cartesian coordinate system (x, y, z, t coordinates) or momentum-energy vectors...
Definition: PxPyPzE4D.h:42
ROOT::Math::LorentzVector::operator/=
LorentzVector & operator/=(Scalar a)
division by a scalar quantity v /= a
Definition: LorentzVector.h:443
ROOT::Math::LorentzVector
Definition: LorentzVector.h:60
ROOT::Math::LorentzVector::py
Scalar py() const
Definition: LorentzVector.h:629
ROOT::Math::LorentzVector::SetPz
LorentzVector< CoordSystem > & SetPz(Scalar a)
Definition: LorentzVector.h:663