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