FairRoot/PandaRoot
mzfunctions_pp_to_pipi_vandewi.cxx
Go to the documentation of this file.
1 
7 //c/c++
8 #include <stdlib.h>
9 #include <iostream>
10 #include <fstream>
11 #include <sstream>
12 #include <cmath>
13 
14 //ranlux
15 #include "ranlxs.h"
16 #include "ranlxd.h"
17 
18 void ranlxs(float r[], int n);
19 void ranlxd(double r[], int n);
20 
21 void rlxs_init(int level, int seed);
22 void rlxd_init(int level, int seed);
23 
24 //mz general
25 #include "mzparameters.h"
26 #include "mzfunctions.h"
27 
28 //mz for pp_to_pipi_vandewi
29 #include "pipisigmas.h"
31 
32 using namespace std;
33 
34 void mz_pp_to_pipi_vandewi_init(int seed, double P,
35  double cos_theta_min,
36  double cos_theta_max)
37 {
38 
39  double p_a=pz[0]; //momentum range
40  double p_b=pz[19];
41  double p_c=pz[20];
42  double p_d=pz[38];
43 
44  double P_PANDA_THRESHOLD=1.5; //pbar momentum threshold in PANDA
45 
46  double M=mp; //proton mass
47 
48  double p_p[4]; //lab frame: 4-mom p (proton target)
49  double pbar_p[4]; //lab frame: 4-mom pbar (anti-proton beam)
50  double pbarp_p[4]; //lab frame: 4-mom pbarpsystem
51  double E; //lab frame: energy pbar
52  double S; //invariant mass square pbarpsystem
53  double sqrt_S; //invariant mass pbarpsystem
54 
55  int p_flag; //momentum extrapolation flag
56  int i_min; //lower site in p-lattice for input momentum P
57 
58  //checking parameter range...
59  printf("\n\n");
60  printf("###########################################################\n");
61 
62  if( !( (P>=p_a)&&(P<=p_d) ) ){
63  printf("ERROR: P (anti-proton momentum) out of range \n");
64  printf(" => P should be contained in the interval [%4.2f,%5.2f] GeV\n",p_a,p_d);
65  printf("\n\n");
66  exit(1);
67  }
68 
69 
70  if(P<P_PANDA_THRESHOLD){
71  printf("WARNING: P (anti-proton momentum) smaller than PANDA threshold %4.2f GeV \n", P_PANDA_THRESHOLD);
72  printf("\n\n");
73  }
74 
75 
76  if( !( (cos_theta_min>=-1.0)&&(cos_theta_max>cos_theta_min)&&(cos_theta_max<=1.0) ) ){
77  printf("ERROR: cos(theta*) range NOT allowed \n");
78  printf(" => cos(theta*) range [cos(theta*) min, cos(theta*) max]\n");
79  printf(" should be contained within [-1.0,1.0]\n");
80  printf("\n\n");
81  exit(1);
82  }
83 
84 
85  if( ((P>=p_a)&&(P<p_c))&&( (cos_theta_min<-0.94)||(cos_theta_max>0.94)) ){
86  printf("WARNING: in the momentum range [%4.2f,%5.2f) GeV,\n",p_a,p_c);
87  printf(" it is recommended to keep cos(theta*) range within the interval [-0.94,0.94]\n");
88  printf(" to avoid potentially large extrapolations in the cross section\n");
89  printf("\n\n");
90  }
91 
92 
93 
94  //initial state kinematic
95 
96  //4-mom of p (lab frame)
97  p_p[0]=M;
98  p_p[1]=0.;
99  p_p[2]=0.;
100  p_p[3]=0.;
101 
102  //4-mom of pbar (lab frame)
103  E=pow((P*P+M*M),0.5);
104 
105  pbar_p[0]=E;
106  pbar_p[1]=0.;
107  pbar_p[2]=0.;
108  pbar_p[3]=P;
109 
110  //4-mom pbarpsystem (lab frame)
111  for(int i=0; i<4; i++){
112  pbarp_p[i]=p_p[i]+pbar_p[i];
113  }
114 
115  //invariant mass pbarpsystem (cms energy)
116  S=mzvmod2(4,pbarp_p);
117  sqrt_S=pow(S,0.5);
118 
119  //print out kinematics
120  printf("Initial state kinematics\n");
121  printf("------------------------\n");
122  printf("\n");
123  printf("=> CM energy square: S = %5.2f GeV^2 \n", S);
124  printf(" CM energy: sqrt(S) = %5.2f GeV \n", sqrt_S);
125  printf("\n\n\n\n");
126 
127 
128 
129  //determining kinematic range and cross section parametrization...
130 
131  printf("Kinematic regime and cross section parametrization\n");
132  printf("--------------------------------------------------\n");
133  printf("\n");
134 
135  if( (P>=p_a)&&(P<=p_b) ){
136  printf("%5.2f < P < %5.2f GeV => low energy regime\n", p_a, p_b);
137  printf("cross section parametrization: Legendre polynomial series\n");
138  printf("\n\n");
139  }
140 
141  if( (P>p_b)&&(P<p_c) ){
142  printf("%5.2f < P < %5.2f GeV => GAP energy regime\n", p_b, p_c);
143  printf("cross section parametrization: extrapolation Legendre polynomial series / Regge description\n");
144  printf("\n\n");
145  }
146 
147  if( (P>=p_c)&&(P<=pz[24]) ){
148  printf("%5.2f < P < %5.2f GeV => transition energy regime\n", p_c, pz[24]);
149  printf("cross section parametrization: Regge description\n");
150  printf("\n\n");
151  }
152 
153 
154  if( (P>pz[24])&&(P<=p_d) ){
155  printf("%5.2f < P < %5.2f GeV => high energy regime\n", pz[24],p_d);
156  printf("cross section parametrization: Regge description\n");
157  printf("\n\n");
158  }
159 
160 
161  //determining if some cross section extrapolation is needed...
162 
163  mz_pp_to_pipi_get_p_lattice_site(P, i_min, p_flag);
164 
165 
166  if(p_flag==0){
167  printf("P at lattice site: no cross section extrapolation needed \n");
168  printf("\n\n\n\n");
169  }
170 
171  if(p_flag==1){
172  printf("P NOT at lattice site: extrapolating cross section between momenta %5.2f and %5.2f GeV\n", pz[i_min], pz[i_min+1]);
173  printf("\n\n\n\n");
174  }
175 
176  printf("###########################################################\n");
177  printf("\n\n");
178 
179  //initialize RANLUX
180  rlxd_init(1,seed);
181 }
182 
183 void mz_pp_to_pipi_get_p_lattice_site(double P, int& i_min, int& iflag)
184 {
201  for(int i=0; i < dim_pz; i++){
202  if(P==pz[i]){
203  iflag=0;
204  i_min=i;
205  }
206  if(i<(dim_pz-1)){
207  if( (P>pz[i])&&(P<pz[i+1]) ){
208  iflag=1;
209  i_min=i;
210  }
211  }
212  }
213 
214 }
215 
216 void mz_pp_to_pipi_get_costheta_lattice_site(double cos_theta, int& k_min, int& kflag)
217 {
234  double a=(2.0)/(200.0); //lattice spacing in cos(theta*)
235  double diff;
236 
237  //checking arguments range...
238 
239  if( !((cos_theta>=-1.0)&&(cos_theta<=1.0)) ){
240  printf("ERROR: function mz_pp_to_pipi_get_costheta_lattice_site\n");
241  printf(" called with argument cos_theta out of range \n");
242  printf(" => cos_theta should be contained in the interval [-1.0,1.0]\n");
243  printf("\n\n");
244  exit(1);
245  }
246 
247 
248  //calculate lower cos(theta*) lattice site for input cos_theta
249  k_min=int( (cos_theta+1.0)/(a) );
250 
251  //decide whether or not extrapolation is needed
252  kflag=0;
253  diff=cos_theta -1.0*(-1.0 +a*(double)(k_min));
254  if(diff>0.0) kflag=1;
255 }
256 
258 {
272  double max;
273  int i_min, p_flag;
274 
275  if( (P>=pz[0])&&(P<pz[1]) ) max=300.0; // legendre zone
276  if( (P>=pz[1])&&(P<pz[2]) ) max=300.0;
277  if( (P>=pz[2])&&(P<pz[3]) ) max=150.0;
278  if( (P>=pz[3])&&(P<pz[4]) ) max=150.0;
279  if( (P>=pz[4])&&(P<pz[5]) ) max=120.0;
280  if( (P>=pz[5])&&(P<pz[6]) ) max=160.0;
281  if( (P>=pz[6])&&(P<pz[7]) ) max=160.0;
282  if( (P>=pz[7])&&(P<pz[8]) ) max=100.0;
283  if( (P>=pz[8])&&(P<pz[9]) ) max=130.0;
284  if( (P>=pz[9])&&(P<pz[10]) ) max=130.0;
285  if( (P>=pz[10])&&(P<pz[11]) ) max=90.0;
286  if( (P>=pz[11])&&(P<pz[12]) ) max=90.0;
287  if( (P>=pz[12])&&(P<pz[13]) ) max=65.0;
288  if( (P>=pz[13])&&(P<pz[14]) ) max=65.0;
289  if( (P>=pz[14])&&(P<pz[15]) ) max=65.0;
290  if( (P>=pz[15])&&(P<pz[16]) ) max=70.0;
291  if( (P>=pz[16])&&(P<pz[17]) ) max=70.0;
292  if( (P>=pz[17])&&(P<pz[18]) ) max=65.0;
293  if( (P>=pz[18])&&(P<=pz[19]) ) max=23.0;
294  //
295  if( (P>pz[19])&&(P<pz[20]) ) max=50.0; // legendre/vandewi extrapolation zone
296  //
297  if( (P>=pz[20])&&(P<=pz[38]) ){ // vandewi zone
298  mz_pp_to_pipi_get_p_lattice_site(P, i_min, p_flag);
299  max=sigmas_dt[i_min-20][200]*1.10;
300  }
301 
302  return max;
303 }
304 
305 double mz_pp_to_pipi_vandewi_sigma_legendre(int i, double cos_theta)
306 {
322  double sigma;
323  double sum=0.0;
324 
325  //checking arguments range...
326 
327  if( !((i>=0)&&(i<=19)) ){
328  printf("ERROR: function mz_pp_to_pipi_vandewi_sigma_legendre\n");
329  printf(" called with argument i out of range \n");
330  printf(" => i should be contained in the interval [0,19]\n");
331  printf("\n\n");
332  exit(1);
333  }
334 
335 
336  //calculate the cross section using the fit coeficients
337  for(int k=0; k<11; k++){
338  sum=sum+fitlegendre[i][k]*mz_legendre_polynomial(k,cos_theta);
339  }
340 
341  sigma=sum;
342 
343  return sigma;
344 }
345 
346 double mz_pp_to_pipi_sigma(double P, double cos_theta)
347 {
362  double sigma;
363 
364  int i_min, iflag;
365  int k_min, kflag;
366  double x1,y1,x2,y2;
367  double factor=2.77207297; //conversion dsigma/d(cos\theta*) -> dsigma/dt at p=2.43 GeV
368 
369  double sigma_1,sigma_2;
370  double a=(2.0)/(200.0); //lattice spacing in cos(theta*)
371 
372  //checking arguments range...
373 
374  if( !((cos_theta>=-1.0)&&(cos_theta<=1.0)) ){
375  printf("ERROR: function mz_pp_to_pipi_vandewi_sigma\n");
376  printf(" called with argument cos_theta out of range \n");
377  printf(" => cos_theta should be contained in the interval [-1.0,1.0]\n");
378  printf("\n\n");
379  exit(1);
380  }
381 
382 
383  //get momentum-lattice site
384  mz_pp_to_pipi_get_p_lattice_site(P, i_min, iflag);
385 
386  //get cos(theta*) lattice site
387  mz_pp_to_pipi_get_costheta_lattice_site(cos_theta, k_min, kflag);
388 
389 
390 
391  //legendre zone
392  if( (P>=pz[0])&&(P<=pz[19]) ){
393  if(iflag==0){ //NO p-extrapolation
394  sigma=mz_pp_to_pipi_vandewi_sigma_legendre(i_min,cos_theta);
395  }
396  if(iflag==1){ //YES p_extrapolation
397  x1=pz[i_min];
398  y1=mz_pp_to_pipi_vandewi_sigma_legendre(i_min,cos_theta);
399  x2=pz[i_min+1];
400  y2=mz_pp_to_pipi_vandewi_sigma_legendre(i_min+1,cos_theta);
401  sigma=mz_linear_extrapolation(x1,y1,x2,y2,P);
402  }
403  }
404 
405 
406  //legendre/vandewi extrapolation zone
407  if( (P>pz[19])&&(P<pz[20]) ){
408  if(kflag==0){ //NO cos(theta*) extrapolation
409  x1=pz[19];
410  y1=mz_pp_to_pipi_vandewi_sigma_legendre(19,cos_theta)*factor;
411  x2=pz[20];
412  y2=sigmas_dt[0][k_min];
413  sigma=mz_linear_extrapolation(x1,y1,x2,y2,P);
414  }
415  //
416  if(kflag==1){ //YES cos(theta*) extrapolation
417  sigma_1=mz_pp_to_pipi_vandewi_sigma_legendre(19,cos_theta)*factor;
418  //
419  x1=-1.0+a*(double)(k_min);
420  y1=sigmas_dt[0][k_min];
421  x2=-1.0+a*(double)(k_min+1);
422  y2=sigmas_dt[0][k_min+1];
423  sigma_2=mz_linear_extrapolation(x1,y1,x2,y2,cos_theta);
424  //
425  x1=pz[19];
426  y1=sigma_1;
427  x2=pz[20];
428  y2=sigma_2;
429  sigma=mz_linear_extrapolation(x1,y1,x2,y2,P);
430  }
431  }
432 
433 
434  //vandewi zone
435  if( (P>=pz[20])&&(P<=pz[38]) ){
436  if( (iflag==0)&&(kflag==0) ){ //NO p-extrapolation NO cos(theta*)-extrapolation
437  sigma=sigmas_dt[i_min-20][k_min];
438  }
439  //
440  if( (iflag==0)&&(kflag==1) ){ //NO p-extrapolation YES cos(theta*)-extrapolation
441  x1=-1.0+a*(double)(k_min);
442  y1=sigmas_dt[i_min-20][k_min];
443  x2=-1.0+a*(double)(k_min+1);
444  y2=sigmas_dt[i_min-20][k_min+1];
445  sigma=mz_linear_extrapolation(x1,y1,x2,y2,cos_theta);
446  }
447  //
448  if( (iflag==1)&&(kflag==0) ){ //YES p-extrapolation NO cos(theta*)-extrapolation
449  x1=pz[i_min];
450  y1=sigmas_dt[i_min-20][k_min];
451  x2=pz[i_min+1];
452  y2=sigmas_dt[i_min+1-20][k_min];
453  sigma=mz_linear_extrapolation(x1,y1,x2,y2,P);
454  }
455  //
456  if( (iflag==1)&&(kflag==1) ){ //YES p-extrapolation YES cos(theta*)-extrapolation
457  x1=-1.0+a*(double)(k_min);
458  y1=sigmas_dt[i_min-20][k_min];
459  x2=-1.0+a*(double)(k_min+1);
460  y2=sigmas_dt[i_min-20][k_min+1];
461  sigma_1=mz_linear_extrapolation(x1,y1,x2,y2,cos_theta);
462  //
463  x1=-1.0+a*(double)(k_min);
464  y1=sigmas_dt[i_min+1-20][k_min];
465  x2=-1.0+a*(double)(k_min+1);
466  y2=sigmas_dt[i_min+1-20][k_min+1];
467  sigma_2=mz_linear_extrapolation(x1,y1,x2,y2,cos_theta);
468  //
469  x1=pz[i_min];
470  y1=sigma_1;
471  x2=pz[i_min+1];
472  y2=sigma_2;
473  sigma=mz_linear_extrapolation(x1,y1,x2,y2,P);
474  }
475  }
476 
477  return sigma;
478 }
479 
480 void mz_pp_to_pipi_vandewi_event(double P, double cos_theta_min, double cos_theta_max, double* piplus_p, double* piminus_p)
481 {
499  double M=mp; //proton mass
500  double PI=acos(-1.0);
501 
502  double p_p[4]; //lab frame: 4-mom p (proton target)
503  double pbar_p[4]; //lab frame: 4-mom pbar (anti-proton beam)
504  double pbarp_p[4]; //lab frame: 4-mom pbarpsystem
505  double E; //lab frame: energy pbar
506  double S; //invariant mass square pbarpsystem
507  double sqrt_S; //invariant mass pbarpsystem
508 
509  int flag;
510  double x,y;
511  double max;
512  double prob;
513  double costheta, theta, phi;
514 
515  double piplus_pcm[4]; //CMS frame: 4-mom pi+
516  double piminus_pcm[4]; //CMS frame: 4-mom pi-
517 
518 
519 
520  //initial state kinematic
521 
522  //4-mom of p (lab frame)
523  p_p[0]=M;
524  p_p[1]=0.;
525  p_p[2]=0.;
526  p_p[3]=0.;
527 
528  //4-mom of pbar (lab frame)
529  E=pow((P*P+M*M),0.5);
530 
531  pbar_p[0]=E;
532  pbar_p[1]=0.;
533  pbar_p[2]=0.;
534  pbar_p[3]=P;
535 
536  //4-mom pbarpsystem (lab frame)
537  for(int i=0; i<4; i++){
538  pbarp_p[i]=p_p[i]+pbar_p[i];
539  }
540 
541  //invariant mass pbarpsystem (cms energy)
542  S=mzvmod2(4,pbarp_p);
543  sqrt_S=pow(S,0.5);
544 
545 
546  //get upper bound to cross section for pbar momentum P
548 
549 
550  flag=0;
551 
552  while(flag==0){
553  x=mzrnd(cos_theta_min,cos_theta_max); //random cos(theta*) in range [cos_theta_min,cos_theta_max]
554  y=mzrnd(0.0,max); //random in range [0.0,upper bound to the cross section]
555  prob=mz_pp_to_pipi_sigma(P,x); //cross section at generated cos(theta*)
556 
557  if(y<prob){ //accept event
558  flag=1;
559 
560  costheta=x;
561  if(costheta > 1.0) costheta=1.0; //just make sure about range...
562  if(costheta < -1.0) costheta=-1.0;
563  theta=acos(costheta); //theta* pi-
564  phi=mzrnd(0.0,2.0*PI); //phi pi-
565 
566  //build pi- 4-momentum in CMS frame
567  piminus_pcm[0]=sqrt_S/2.0;
568  piminus_pcm[1]=pow(S/4.0-mpi*mpi,0.5)*sin(theta)*cos(phi);
569  piminus_pcm[2]=pow(S/4.0-mpi*mpi,0.5)*sin(theta)*sin(phi);
570  piminus_pcm[3]=pow(S/4.0-mpi*mpi,0.5)*cos(theta);
571 
572  //build pi+ 4-momentum in CMS frame
573  piplus_pcm[0]=piminus_pcm[0];
574  piplus_pcm[1]=-1.0*piminus_pcm[1];
575  piplus_pcm[2]=-1.0*piminus_pcm[2];
576  piplus_pcm[3]=-1.0*piminus_pcm[3];
577 
578  //boost pi- and pi+ 4-momenta to lab frame
579  mzboost(1,pbarp_p,piplus_pcm,piplus_p);
580  mzboost(1,pbarp_p,piminus_pcm,piminus_p);
581  }
582 
583  }
584 
585 }
586 
friend F32vec4 acos(const F32vec4 &a)
Definition: P4_F32vec4.h:113
void ranlxd(double r[], int n)
Definition: ranlxd.cxx:571
double mz_pp_to_pipi_sigma(double P, double cos_theta)
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
double mz_pp_to_pipi_vandewi_sigma_legendre(int i, double cos_theta)
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
static const double mpi
Definition: mzparameters.h:15
double r
Definition: RiemannTest.C:14
void mz_pp_to_pipi_get_p_lattice_site(double P, int &i_min, int &iflag)
Int_t i
Definition: run_full.C:25
exit(0)
double mzvmod2(int n, double *p)
Definition: mzfunctions.cxx:93
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
void ranlxs(float r[], int n)
Definition: ranlxs.cxx:566
int n
Double_t sigma[nsteps]
Definition: dedx_bands.C:65
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
void mz_pp_to_pipi_vandewi_event(double P, double cos_theta_min, double cos_theta_max, double *piplus_p, double *piminus_p)
void mz_pp_to_pipi_get_costheta_lattice_site(double cos_theta, int &k_min, int &kflag)
static const double mp
Definition: mzparameters.h:11
int dim_pz
Definition: pipisigmas.h:10
double sigmas_dt[19][201]
Definition: pipisigmas.h:80
double mzrnd(double a, double b)
Int_t a
Definition: anaLmdDigi.C:126
const Double_t PI
unsigned int seed
double mz_linear_extrapolation(double x1, double y1, double x2, double y2, double x)
void mzboost(int flag, double *p, double *q, double *q_prime)
double fitlegendre[20][11]
Definition: pipisigmas.h:56
void mz_pp_to_pipi_vandewi_init(int seed, double P, double cos_theta_min, double cos_theta_max)
GeV c P
Double_t x
Double_t y
void rlxs_init(int level, int seed)
Definition: ranlxs.cxx:495
double mz_legendre_polynomial(int n, double x)
void rlxd_init(int level, int seed)
Definition: ranlxd.cxx:501
double pz[39]
Definition: pipisigmas.h:14
double mz_pp_to_pipi_vandewi_maximum_sigma(double P)