00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014
00015 #include <vector>
00016 #include <stdlib.h>
00017 #include <math.h>
00018 #include "QvecBase.h"
00019
00020 int QvecBase::NERR=0;
00021
00022
00023 QvecBase::QvecBase()
00024 {
00025 _locked = 0;
00026 setA4V(0.,0.,0.,0.);
00027 _qch = 0;
00028 oVertex = NULL;
00029 eVertex = NULL;
00030 }
00031
00032
00033 QvecBase::QvecBase(const QvecBase& origin)
00034 {
00035 _A4V = origin._A4V;
00036 _locked = origin._locked;
00037 _qch = origin._qch;
00038 }
00039
00040
00041
00042
00043
00044
00045 bool QvecBase::operator<(const QvecBase& other) const
00046 {
00047 if(SortCriterium>3)
00048 return ( QPT() < other.QPT());
00049 else
00050 return (_A4V[SortCriterium] < other._A4V[SortCriterium]);
00051 }
00052
00053 float QvecBase::sign(float k)const{return k/fabs(k);}
00054
00055
00056 HepLorentzVector QvecBase::A4V()const{ return _A4V; }
00057
00058
00059 void QvecBase::setA4V(float x, float y, float z, float e)
00060 {
00061 _A4V.setPx(x);
00062 _A4V.setPy(y);
00063 _A4V.setPz(z);
00064 _A4V.setE(e);
00065 }
00066
00067
00068
00069 QvecBase QvecBase::operator+(const QvecBase j)const
00070 {
00071 HepLorentzVector A4Temp = A4V() + j.A4V();
00072 QvecBase Temp;
00073 Temp.setA4V(A4Temp);
00074 Temp.setQCH(QCH() + j.QCH());
00075 return Temp;
00076 }
00077
00078
00079 float QvecBase::QCH()const{return _qch;}
00080 float QvecBase::QX() const{return A4V().px();}
00081 float QvecBase::QY() const{return A4V().py();}
00082 float QvecBase::QZ() const{return A4V().pz();}
00083 float QvecBase::QP() const{return A4V().rho();}
00084 float QvecBase::QE() const{return A4V().e();}
00085 float QvecBase::QM() const{return A4V().m();}
00086 float QvecBase::QCT()const{ return A4V().cosTheta();}
00087 float QvecBase::QPH()const{ return A4V().phi(); }
00088 float QvecBase::QPT()const{ return A4V().perp();}
00089 float QvecBase::QBETA() const{ return A4V().rho()/A4V().e();}
00090 float QvecBase::QGAMMA()const{ return 1./sqrt((1.-QBETA())*(1.+QBETA())); }
00091
00092
00093 float QvecBase::QMSQ2(const QvecBase j) const
00094 {
00095 HepLorentzVector A4Temp = A4V() + j.A4V();
00096 return A4Temp.m2();
00097 }
00098
00099 float QvecBase::QM2(const QvecBase j) const
00100 {
00101 HepLorentzVector A4Temp = A4V() + j.A4V();
00102 return A4Temp.m();
00103 }
00104
00105 float QvecBase::QDMSQ(const QvecBase j) const
00106 {
00107 HepLorentzVector A4Temp = A4V() - j.A4V();
00108 return A4Temp.m2();
00109 }
00110
00111 float QvecBase::QPPAR(const QvecBase j) const{ return QDOT3(j)/j.A4V().rho();}
00112 float QvecBase::QPPER(const QvecBase j) const{ return A4V().perp(j.A4V().vect()); }
00113 float QvecBase::QDOT3(const QvecBase j) const{ return A4V().vect().dot(j.A4V().vect());}
00114 float QvecBase::QDOT4(const QvecBase j) const{ return A4V().dot(j.A4V());}
00115
00116 float QvecBase::QCOSA(const QvecBase j) const
00117 {
00118 return cos(A4V().angle(j.A4V().vect()));
00119 }
00120
00121 float QvecBase::QDECA2(const QvecBase j)const
00122 {
00123 double P_1[4], P_2[4];
00124 P_1[0] = (double) A4V().px();
00125 P_1[1] = (double) A4V().py();
00126 P_1[2] = (double) A4V().pz();
00127 P_1[3] = (double) A4V().e();
00128 double PMAG = sqrt(pow(P_1[0],2) + pow(P_1[1],2) + pow(P_1[2],2));
00129 P_2[0] = (double) j.A4V().px();
00130 P_2[1] = (double) j.A4V().py();
00131 P_2[2] = (double) j.A4V().pz();
00132 P_2[3] = (double) j.A4V().e();
00133 double PP = sqrt( pow((P_1[0]+P_2[0]),2) + pow((P_1[1]+P_2[1]),2)
00134 + pow((P_1[2]+P_2[2]),2));
00135 double BETA = PP / ( P_1[3]+P_2[3] );
00136 double PPAR = ( P_1[0] *(P_1[0]+P_2[0]) + P_1[1] *(P_1[1]+P_2[1])
00137 + P_1[2] *(P_1[2]+P_2[2]) )/PP;
00138 PP = PPAR - BETA * P_1[3];
00139 return (float) (PP / sqrt(pow(PP,2.) + (PMAG-PPAR)*(PMAG+PPAR)*(1.-BETA)*(1.+BETA)));
00140 }
00141
00142 HepDouble QvecBase::DECAY_ANG(const QvecBase j) const
00143 {
00144 cout << "before addition" << endl;
00145 QvecBase temp= (*this) + j;
00146 cout << "after addition" << endl;
00147 HepLorentzVector v = temp.A4V();
00148 cout << "v written" << endl;
00149 HepLorentzVector v1 = A4V();
00150 cout << "v = " << v << " v1 = " << v1 << endl;
00151 v1.boost(-v.boostVector());
00152 cout << "boosted v1 = " << v1 << endl;
00153 return cos(v.angle(v1.vect()));
00154 }
00155
00156
00157
00158 float QvecBase::QDECAN(const QvecBase j) const
00159 {
00160 float PP =A4V().rho();
00161 float BETA = PP / A4V().e();
00162 float PPAR = (A4V().px() * j.A4V().px() + A4V().py() * j.A4V().py() + A4V().pz() * j.A4V().pz()) / PP;
00163 PP = PPAR - BETA * j.A4V().e();
00164 float Q_DECAN = pow(PP,2) + (j.A4V().rho() - PPAR) * (j.A4V().rho() + PPAR) *
00165 (1. - BETA) * (1. + BETA);
00166 if (Q_DECAN > 0.)
00167 { return PP / sqrt (Q_DECAN); }
00168 else
00169 {NERR++;
00170 if (NERR <= 10)
00171 { cout << endl << "_QDECAN_ 2nd particle is not a decay product of 1st" << endl; }
00172 return 1.;
00173 }
00174 }
00175
00176
00177
00178 void QvecBase::Lock(bool recurse) { _locked = 1 ; }
00179 void QvecBase::unLock(bool recurse) { _locked = 0 ; }
00180 int QvecBase::isLocked()const{ return _locked; }
00181
00182
00183
00184 int QvecBase::SortCriterium = 3;