evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
EvtTwoBodyKine.cpp
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4 * *
5 * This file is part of EvtGen. *
6 * *
7 * EvtGen is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * EvtGen is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19 ***********************************************************************/
20 
22 
23 #include "EvtGenBase/EvtPatches.hh"
24 #include "EvtGenBase/EvtReport.hh"
25 
26 #include <assert.h>
27 #include <iostream>
28 #include <math.h>
29 using std::endl;
30 using std::ostream;
31 
32 EvtTwoBodyKine::EvtTwoBodyKine() : _mA( 0. ), _mB( 0. ), _mAB( 0. )
33 {
34 }
35 
36 EvtTwoBodyKine::EvtTwoBodyKine( double mA, double mB, double mAB ) :
37  _mA( mA ), _mB( mB ), _mAB( mAB )
38 {
39  if ( mAB < mA + mB ) {
40  EvtGenReport( EVTGEN_INFO, "EvtGen" )
41  << mAB << " < " << mA << " + " << mB << endl;
42  assert( 0 );
43  }
44 }
45 
46 double EvtTwoBodyKine::m( Index i ) const
47 {
48  double ret = _mAB;
49  if ( A == i )
50  ret = _mA;
51  else if ( B == i )
52  ret = _mB;
53 
54  return ret;
55 }
56 
57 double EvtTwoBodyKine::p( Index i ) const
58 {
59  double p0 = 0.;
60 
61  if ( i == AB ) {
62  double x = _mAB * _mAB - _mA * _mA - _mB * _mB;
63  double y = 2 * _mA * _mB;
64  p0 = sqrt( x * x - y * y ) / 2. / _mAB;
65  } else if ( i == A ) {
66  double x = _mA * _mA - _mAB * _mAB - _mB * _mB;
67  double y = 2 * _mAB * _mB;
68  p0 = sqrt( x * x - y * y ) / 2. / _mA;
69  } else {
70  double x = _mB * _mB - _mAB * _mAB - _mA * _mA;
71  double y = 2 * _mAB * _mA;
72  p0 = sqrt( x * x - y * y ) / 2. / _mB;
73  }
74 
75  return p0;
76 }
77 
78 double EvtTwoBodyKine::e( Index i, Index j ) const
79 {
80  double ret = m( i );
81  if ( i != j ) {
82  double pD = p( j );
83  ret = sqrt( ret * ret + pD * pD );
84  }
85  return ret;
86 }
87 
88 void EvtTwoBodyKine::print( ostream& os ) const
89 {
90  os << " mA = " << _mA << endl;
91  os << " mB = " << _mB << endl;
92  os << "mAB = " << _mAB << endl;
93 }
94 
95 ostream& operator<<( ostream& os, const EvtTwoBodyKine& p )
96 {
97  p.print( os );
98  return os;
99 }
void print(std::ostream &os) const
ostream & operator<<(ostream &os, const EvtTwoBodyKine &p)
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
double mAB() const
double mA() const
double mB() const
double m(Index i) const
double e(Index i, Index j) const
double p(Index i=AB) const