FairRoot/PandaRoot
Functions
mzfunctions.h File Reference

Go to the source code of this file.

Functions

double mzdelta (int i, int k)
 
double mzvscalar (int n, double *p, double *q)
 
double mzvmod2 (int n, double *p)
 
void mzboost (int flag, double *p, double *q, double *q_prime)
 
double mzenergy (double m, double p_x, double p_y, double p_z)
 
double mzpolar (double *p)
 
double mzazimuthal (double *p)
 
double mzcospolar (double *p)
 
double mzangle (double *p, double *q)
 
double mzrnd (double a, double b)
 
double mzcomplexmod (double Re_z, double Im_z)
 
double mz_E_to_s (double E)
 
double mz_legendre_polynomial (int n, double x)
 
double mz_linear_extrapolation (double x1, double y1, double x2, double y2, double x)
 

Function Documentation

double mz_E_to_s ( double  E)

function mz_E_to_s

arguments:

E: pbar energy in lab (GeV)

returns:

cm-energy square s of pbar p system

Definition at line 410 of file mzfunctions.cxx.

References exit(), i, mp, mzvmod2(), P, printf(), and s.

410  {
425  double s;
426 
427  double M=mp;
428 
429  double p_p[4]; //lab frame: 4-mom p (proton target)
430  double pbar_p[4]; //lab frame: 4-mom pbar (anti-proton beam)
431  double pbarp_p[4]; //lab frame: 4-mom pbarpsystem
432  double P; //lab frame: pz pbar
433 
434 
435  //check argument range
436  if(E<M){
437  printf("ERROR: function mz_E_to_s called with argument E out of range \n");
438  printf(" => E should be larger than the proton mass M = %5.3f GeV\n",M);
439  printf("\n\n");
440  exit(1);
441  }
442 
443 
444  //4-mom of p (lab frame)
445  p_p[0]=M;
446  p_p[1]=0.;
447  p_p[2]=0.;
448  p_p[3]=0.;
449 
450 
451  //4-mom of pbar (lab frame)
452  P=pow((E*E-M*M),0.5);
453 
454  pbar_p[0]=E;
455  pbar_p[1]=0.;
456  pbar_p[2]=0.;
457  pbar_p[3]=P;
458 
459 
460  //4-mom pbarpsystem (lab frame)
461  for(int i=0; i<4; i++){
462  pbarp_p[i]=p_p[i]+pbar_p[i];
463  }
464 
465  s=mzvmod2(4,pbarp_p);
466 
467  return s;
468 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Int_t i
Definition: run_full.C:25
exit(0)
double mzvmod2(int n, double *p)
Definition: mzfunctions.cxx:93
TLorentzVector s
Definition: Pnd2DStar.C:50
static const double mp
Definition: mzparameters.h:11
GeV c P
double mz_legendre_polynomial ( int  n,
double  x 
)

function mz_legendre_polynomial

INPUT:

n -> polynomial degree, [0,10] x -> independent variable, [-1,1]

returns:

P_{n}(x)

Definition at line 470 of file mzfunctions.cxx.

References exit(), printf(), x, and y.

Referenced by mz_pp_to_pipi_vandewi_sigma_legendre().

470  {
485  double y;
486 
487  //checking parameter range...
488  if( !( (n>=0)&&(n<=10) ) ){
489  printf("ERROR: function mz_legendre_polynomial called with n out of range \n");
490  printf(" => n should be contained in the interval [0,10]\n");
491  printf("\n\n");
492  exit(1);
493  }
494 
495  if( !( (x>=-1.0)&&(x<=1.0) ) ){
496  printf("ERROR: function mz_legendre_polynomial called with x out of range \n");
497  printf(" => x should be contained in the interval [-1.0,1.0]\n");
498  printf("\n\n");
499  exit(1);
500  }
501 
502 
503  if(n==0){
504  y=1.0;
505  }
506 
507  if(n==1){
508  y=x;
509  }
510 
511  if(n==2){
512  y=(1.0/2.0)*(3.0*pow(x,2.0) -1.0);
513  }
514 
515  if(n==3){
516  y=(1.0/2.0)*(5.0*pow(x,3.0) -3.0*x);
517  }
518 
519  if(n==4){
520  y=(1.0/8.0)*(35.0*pow(x,4.0) -30.0*pow(x,2.0) +3.0);
521  }
522 
523  if(n==5){
524  y=(1.0/8.0)*(63.0*pow(x,5.0) -70.0*pow(x,3.0) +15.0*x);
525  }
526 
527  if(n==6){
528  y=(1.0/16.0)*(231.0*pow(x,6.0) -315.0*pow(x,4.0)
529  +105.0*pow(x,2.0) -5.0);
530  }
531 
532  if(n==7){
533  y=(1.0/16.0)*(429.0*pow(x,7.0) -693.0*pow(x,5.0)
534  +315.0*pow(x,3.0) -35.0*x);
535  }
536 
537  if(n==8){
538  y=(1.0/128.0)*(6435.0*pow(x,8.0) -12012.0*pow(x,6.0)
539  +6930.0*pow(x,4.0) -1260.0*pow(x,2.0)
540  +35.0);
541  }
542 
543  if(n==9){
544  y=(1.0/128.0)*(12155.0*pow(x,9.0) -25740.0*pow(x,7.0)
545  +18018.0*pow(x,5.0) -4620.0*pow(x,3.0)
546  +315.0*x);
547  }
548 
549  if(n==10){
550  y=(1.0/256.0)*(46189.0*pow(x,10.0) -109395.0*pow(x,8.0)
551  +90090.0*pow(x,6.0) -30030*pow(x,4.0)
552  +3465.0*pow(x,2.0) -63.0);
553  }
554 
555  return y;
556 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
exit(0)
int n
Double_t x
Double_t y
double mz_linear_extrapolation ( double  x1,
double  y1,
double  x2,
double  y2,
double  x 
)

funtion mz_linear_extrapolation

INPUT:

(x1,y1) first point in (x,y)-plane (x2,y2) second point in (x,y)-plane

x independent variable

RETURNS:

y=f(x), with f the linear function atisfying y1=f(x1) and y2=f(x2)

Definition at line 558 of file mzfunctions.cxx.

References a, b, exit(), printf(), and y.

Referenced by mz_pp_to_pipi_sigma().

561 {
579  double y;
580  double a,b;
581 
582  //checking parameter range...
583  if(x2==x1){
584  printf("ERROR: function mz_linear_extrapolation called with x_2=x_1 \n");
585  printf(" => argument x_2 should be different from argument x_1 \n");
586  printf("\n\n");
587  exit(1);
588  }
589 
590  a = (y1-y2)/(x1-x2);
591  b = y1-a*x1;
592 
593  y = a*x+b;
594 
595  return y;
596 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
TTree * b
exit(0)
Int_t a
Definition: anaLmdDigi.C:126
Double_t x
Double_t y
double mzangle ( double *  p,
double *  q 
)

function mzangle

input: 4-mom p, 4-mom q output: angle between 3-dim components of p, q in range [0,180]

Definition at line 310 of file mzfunctions.cxx.

References acos(), alpha, mzvmod2(), mzvscalar(), and PI.

311 {
320  double PI=acos(-1.0);
321 
322  double alpha;
323 
324  double scalar, pmod, qmod, cosalpha;
325 
326  pmod=pow(mzvmod2(3,p),0.5);
327  qmod=pow(mzvmod2(3,q),0.5);
328 
329  scalar=mzvscalar(3,p,q);
330 
331  if(pmod==0.0){
332  cerr << "WARNING: mzangle called with p[1]=p[2]=p[3]=0.0 " << endl;
333  return 9999.;
334  }
335 
336  if(qmod==0.0){
337  cerr << "WARNING: mzangle called with q[1]=q[2]=q[3]=0.0 " << endl;
338  return 9999.;
339  }
340 
341 
342  cosalpha=scalar/(pmod*qmod);
343 
344  if(cosalpha > 1.0) cosalpha=1.0;
345  if(cosalpha < -1.0) cosalpha=-1.0;
346 
347  alpha=acos(cosalpha) * 180.0 / PI;
348 
349 
350  return alpha;
351 }
friend F32vec4 acos(const F32vec4 &a)
Definition: P4_F32vec4.h:113
double mzvmod2(int n, double *p)
Definition: mzfunctions.cxx:93
Double_t p
Definition: anasim.C:58
const Double_t PI
double mzvscalar(int n, double *p, double *q)
Definition: mzfunctions.cxx:53
double alpha
Definition: f_Init.h:9
double mzazimuthal ( double *  p)

function mzazimuthal

input: 4-mom p output: azimuthal angle phi in range [0,180]

Definition at line 258 of file mzfunctions.cxx.

References acos(), atan2(), phi, and PI.

259 {
267  double PI=acos(-1.0);
268 
269  double phi;
270 
271  if ( (p[1]==0.) && (p[2]==0.0) ) {
272  cerr << "WARNING: mzazimuthal called with p[1]=p[2]=0.0 " << endl;
273  return 9999.;
274  }
275 
276 
277  phi=atan2(p[2],p[1])*180.0/PI;
278 
279 
280  if (phi<0.0) phi = phi + 360.0;
281 
282  return phi;
283 }
friend F32vec4 acos(const F32vec4 &a)
Definition: P4_F32vec4.h:113
Double_t p
Definition: anasim.C:58
const Double_t PI
friend F32vec4 atan2(const F32vec4 &y, const F32vec4 &x)
Definition: P4_F32vec4.h:117
void mzboost ( int  flag,
double *  p,
double *  q,
double *  q_prime 
)

function mzboost

input: flag=0 lab->CM, flag=1 CM->lab p 4-mom of CM particle (M!=0) in lab frame q 4-mom of test particle in lab frame (flag=0) / CM frame (flag=1)

output: q_prime 4-mom of test particle in the CM frame (flag=0) / lab frame (flag=1)

Definition at line 123 of file mzfunctions.cxx.

References i, L, m, mzdelta(), and mzvmod2().

Referenced by mz_pp_to_leplep_vandewi_event(), and mz_pp_to_pipi_vandewi_event().

124 {
135  int i,k;
136 
137  double m;
138  double gamma;
139  double p_uni[4];
140 
141  double L[4][4];
142  double LI[4][4];
143 
144  double mztemp;
145 
146 
147 
148  //computing matrix L(p)
149 
150  m=pow(mzvmod2(4,p),0.5);
151  gamma=p[0]/m;
152 
153 
154  for (i=1; i<=3; i++) {
155  p_uni[i]=p[i]/pow(mzvmod2(3,p),0.5);
156  }
157 
158 
159  L[0][0]=gamma;
160 
161 
162  for (i=1; i<=3; i++) {
163  L[0][i] = p_uni[i] * pow((gamma*gamma - 1.0),0.5);
164  L[i][0] = L[0][i];
165  }
166 
167 
168  for (i=1; i<=3; i++) {
169  for (k=1; k<=3; k++) {
170  L[i][k] = mzdelta(i,k) + (gamma -1.0)*p_uni[i]*p_uni[k];
171  }
172  }
173 
174 
175 
176 
177  //inverting matrix L(p)
178 
179  LI[0][0]=L[0][0];
180 
181  for (i=1; i<=3; i++) {
182  LI[0][i] = -1.0*L[i][0];
183  LI[i][0] = -1.0*L[0][i];
184  }
185 
186  for (i=1; i<=3; i++) {
187  for (k=1; k<=3; k++) {
188  LI[i][k] = L[k][i];
189  }
190  }
191 
192 
193 
194  //boosting 4-mom q
195 
196  for (i=0; i<=3; i++) {
197  mztemp = 0.0;
198  for (k=0; k<=3; k++) {
199  if (flag==0) mztemp = mztemp + LI[i][k]*q[k];
200  if (flag==1) mztemp = mztemp + L[i][k]*q[k];
201  }
202  q_prime[i] =mztemp;
203  }
204 
205 }
double mzdelta(int i, int k)
Definition: mzfunctions.cxx:30
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
double mzvmod2(int n, double *p)
Definition: mzfunctions.cxx:93
Double_t p
Definition: anasim.C:58
double mzcomplexmod ( double  Re_z,
double  Im_z 
)

function mzcomplexmod

arguments:

Re_z = real part of complex number z Im_z = imaginary part of complex number z

returns:

modulus of complex number z

Definition at line 389 of file mzfunctions.cxx.

References y.

389  {
403  double y;
404 
405  y=pow(Re_z*Re_z + Im_z*Im_z,0.5);
406 
407  return y;
408 }
Double_t y
double mzcospolar ( double *  p)

function mzcospolar

input: 4-mom p output: cos of polar angle theta

Definition at line 285 of file mzfunctions.cxx.

References mzvmod2().

286 {
294  double costheta;
295 
296  double pmod;
297 
298  pmod=pow(mzvmod2(3,p),0.5);
299 
300  if(pmod==0.0){
301  cerr << "WARNING: mzcospolar called with p[1]=p[2]=p[3]=0.0 " << endl;
302  return 9999.;
303  }
304 
305  costheta = p[3]/pmod;
306 
307  return costheta;
308 }
double mzvmod2(int n, double *p)
Definition: mzfunctions.cxx:93
Double_t p
Definition: anasim.C:58
double mzdelta ( int  i,
int  k 
)
Author
Manuel Zambrana zambr.nosp@m.ana@.nosp@m.kph.u.nosp@m.ni-m.nosp@m.ainz..nosp@m.de and Dmitry Khaneftd khane.nosp@m.ftd@.nosp@m.kph.u.nosp@m.ni-m.nosp@m.ainz..nosp@m.de

Mainz, May 2011

function mzdelta

input: i,k integers output: kroneker delta(i,k)

Definition at line 30 of file mzfunctions.cxx.

References d.

Referenced by mzboost().

31 {
40  double d;
41 
42  if( k==i )
43  {
44  d=1.0;
45  }
46  else{
47  d=0.0;
48  }
49 
50  return d;
51 }
TObjArray * d
Int_t i
Definition: run_full.C:25
double mzenergy ( double  m,
double  p_x,
double  p_y,
double  p_z 
)

input: mass m, 3-mom components px, py, pz of a particle

output: energy of the particle

Definition at line 207 of file mzfunctions.cxx.

208 {
216  double E;
217 
218  E=pow(m*m +p_x*p_x +p_y*p_y +p_z*p_z,0.5);
219 
220  return E;
221 }
__m128 m
Definition: P4_F32vec4.h:28
double mzpolar ( double *  p)

function mzpolar

input: 4-mom p output: polar angle theta in range [0,180]

Definition at line 223 of file mzfunctions.cxx.

References acos(), mzvmod2(), PI, and theta.

224 {
232  double PI=acos(-1.0);
233 
234  double theta;
235 
236  double pmod;
237  double costheta;
238 
239  pmod=pow(mzvmod2(3,p),0.5);
240 
241  if(pmod==0.0){
242  cerr << "WARNING: mzpolar called with p[1]=p[2]=p[3]=0.0 " << endl;
243  return 9999.;
244  }
245 
246  costheta = p[3]/pmod;
247 
248  if(costheta > 1.0) costheta=1.0;
249  if(costheta < -1.0) costheta=-1.0;
250 
251  theta = acos(costheta) * 180.0 / PI ;
252 
253 
254  return theta;
255 }
friend F32vec4 acos(const F32vec4 &a)
Definition: P4_F32vec4.h:113
double mzvmod2(int n, double *p)
Definition: mzfunctions.cxx:93
Double_t p
Definition: anasim.C:58
const Double_t PI
double mzrnd ( double  a,
double  b 
)

function mzrnd

arguments:

a = inf[a,b] b = sup[a,b]

returns:

random number in interval [a,b]

Definition at line 353 of file mzfunctions.cxx.

References a, exit(), printf(), ranlxd(), x, and y.

Referenced by mz_pp_to_leplep_vandewi_event(), and mz_pp_to_pipi_vandewi_event().

353  {
368  double y;
369 
370  int dim=1;
371  double rvec[dim];
372  double x;
373 
374  //check arguments
375  if(b<=a){
376  printf("ERROR: function mzrnd called with arguments b<=a \n");
377  printf(" => argument b should be larger than argument a \n");
378  printf("\n\n");
379  exit(1);
380  }
381 
382  ranlxd(rvec,dim); //generate random number in interval [0,1]
383  x=rvec[0];
384  y=(b-a)*x + a;
385 
386  return y;
387 }
void ranlxd(double r[], int n)
Definition: ranlxd.cxx:571
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
TTree * b
exit(0)
Int_t a
Definition: anaLmdDigi.C:126
Double_t x
Double_t y
double mzvmod2 ( int  n,
double *  p 
)

function mzvmod2

input: int n, 4-vector p

output:

n=2 -> returns p[1]*p[1] + p[2]*p[2] n=3 -> returns p[1]*p[1] + p[2]*p[2] + p[3]*p[3] n=4 -> returns p[0]*p[0] -p[1]*p[1] -p[2]*p[2] -p[3]*p[3]

Definition at line 93 of file mzfunctions.cxx.

References exit(), m2(), mzvscalar(), and printf().

Referenced by mz_E_to_s(), mz_pp_to_leplep_vandewi_event(), mz_pp_to_pipi_vandewi_event(), mz_pp_to_pipi_vandewi_init(), mzangle(), mzboost(), mzcospolar(), and mzpolar().

94 {
107  double m2;
108 
109 
110  if( !(n==2||n==3||n==4) ){
111  printf("ERROR: function mzvmod2 called with flag n out of range \n");
112  printf(" => n should take the value 2,3 or 4 \n");
113  printf("\n\n");
114  exit(1);
115  }
116 
117 
118  m2 = mzvscalar(n,p,p);
119 
120  return m2;
121 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
exit(0)
int n
Double_t p
Definition: anasim.C:58
TString m2(TString pts, TString exts="e px py pz")
Definition: invexp.C:117
double mzvscalar(int n, double *p, double *q)
Definition: mzfunctions.cxx:53
double mzvscalar ( int  n,
double *  p,
double *  q 
)

function mzvscalar

input: int n, 4-vector p, 4-vector q

output:

n=2 -> returns p[1]*q[1] + p[2]*q[2] n=3 -> returns p[1]*q[1] + p[2]*q[2] + p[3]*q[3] n=4 -> returns p[0]*q[0] -p[1]*q[1] -p[2]*q[2] -p[3]*q[3]

Definition at line 53 of file mzfunctions.cxx.

References exit(), printf(), and s.

Referenced by mzangle(), and mzvmod2().

54 {
67  double s;
68 
69 
70  if( !(n==2||n==3||n==4) ){
71  printf("ERROR: function mzvscalar called with flag n out of range \n");
72  printf(" => n should take the value 2,3 or 4 \n");
73  printf("\n\n");
74  exit(1);
75  }
76 
77 
78  if (n==2) {
79  s = p[1]*q[1] + p[2]*q[2];
80  }
81 
82  if (n==3) {
83  s = p[1]*q[1] + p[2]*q[2] + p[3]*q[3];
84  }
85 
86  if (n==4) {
87  s = p[0]*q[0] -1.0*p[1]*q[1] -1.0*p[2]*q[2] -1.0*p[3]*q[3];
88  }
89 
90  return s;
91 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
exit(0)
TLorentzVector s
Definition: Pnd2DStar.C:50
int n
Double_t p
Definition: anasim.C:58