]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TEvtGen/EvtGenBase/EvtTwoBodyKine.cxx
Removing some meaningeless const (coverity)
[u/mrichter/AliRoot.git] / TEvtGen / EvtGenBase / EvtTwoBodyKine.cxx
1 #include "EvtGenBase/EvtPatches.hh"
2 /*******************************************************************************
3  * Project: BaBar detector at the SLAC PEP-II B-factory
4  * Package: EvtGenBase
5  *    File: $Id: EvtTwoBodyKine.cc,v 1.8 2004/12/21 19:58:50 ryd Exp $
6  *  Author: Alexei Dvoretskii, dvoretsk@slac.stanford.edu, 2001-2002
7  *
8  * Copyright (C) 2002 Caltech
9  *******************************************************************************/
10
11 #include <iostream>
12 #include <assert.h>
13 #include <math.h>
14 #include "EvtGenBase/EvtTwoBodyKine.hh"
15 #include "EvtGenBase/EvtReport.hh"
16 using std::endl;
17 using std::ostream;
18
19
20 EvtTwoBodyKine::EvtTwoBodyKine()
21   : _mA(0.), _mB(0.), _mAB(0.)
22 {}
23
24 EvtTwoBodyKine::EvtTwoBodyKine(double mA, double mB, double mAB)
25   : _mA(mA), _mB(mB), _mAB(mAB)
26 {
27   if(mAB < mA + mB) {
28
29     report(INFO,"EvtGen") << mAB << " < " << mA << " + " << mB << endl;
30     assert(0);
31   }
32 }
33
34 EvtTwoBodyKine::EvtTwoBodyKine(const EvtTwoBodyKine& other)
35   : _mA(other._mA), _mB(other._mB), _mAB(other._mAB)
36 {}
37
38 EvtTwoBodyKine::~EvtTwoBodyKine()
39 {}
40
41
42 double EvtTwoBodyKine::m(Index i) const
43 {
44   double ret = _mAB;
45   if(A == i) ret = _mA;
46   else
47     if(B == i) ret = _mB;
48   
49   return ret;
50 }
51
52
53 double EvtTwoBodyKine::p(Index i) const
54
55   double p0 = 0.;
56
57   if(i == AB) {
58
59     double x = _mAB*_mAB - _mA*_mA - _mB*_mB;
60     double y = 2*_mA*_mB;
61     p0 = sqrt(x*x - y*y)/2./_mAB;
62   }
63   else 
64     if(i == A) {
65
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     }
70     else {
71
72       double x = _mB*_mB - _mAB*_mAB - _mA*_mA;
73       double y = 2*_mAB*_mA;
74       p0 = sqrt(x*x - y*y)/2./_mB;
75     }
76
77   return p0;
78 }
79
80
81 double EvtTwoBodyKine::e(Index i, Index j) const
82 {
83   double ret = m(i);
84   if(i != j) {
85
86     double pD = p(j);
87     ret = sqrt(ret*ret + pD*pD);
88   }
89   return ret;
90 }
91
92
93 void EvtTwoBodyKine::print(ostream& os) const
94 {
95   os << " mA = " << _mA << endl;
96   os << " mB = " << _mB << endl;
97   os << "mAB = " << _mAB << endl;
98 }
99
100
101 ostream& operator<<(ostream& os, const EvtTwoBodyKine& p)
102 {
103   p.print(os);
104   return os;
105 }