MINT2
phaseSpaceIntegrals.cpp
Go to the documentation of this file.
1 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
2 // status: Mon 9 Feb 2009 19:17:58 GMT
4 
6 #include "Mint/lambda.h"
7 
8 #include <iostream>
9 #include <cmath>
10 
11 #include "TF2.h"
12 
13 using namespace std;
14 
17 
21 
22 double d4body_by_ds12(Double_t* x, Double_t* p){
23  bool dbThis=false;
24  double s12 = x[0];
25  if(s12 < 0) return 0;
26  double m12 = sqrt(s12);
27  double mum = p[0];
28  double m1 = p[1];
29  double m2 = p[2];
30  double m3 = p[3];
31  double m4 = p[4];
32 
33  if(dbThis) cout << " d4body_by_ds12 called with "
34  << mum << ", "
35  << m1 << ", "
36  << m2 << ", "
37  << m3 << ", "
38  << m4 << endl;
39 
41 
42  double p3val = p3.getVal(mum, m12, m3, m4);
43  double p2val = phaseSpaceIntegral2body(m12, m1, m2);
44  if(dbThis){
45  cout << " d4body_by_ds12: returning " << p2val << " * " << p3val
46  << " = " << p2val * p3val
47  << endl;
48  }
49  return p2val * p3val;
50 }
51 
52 double d3body_by_ds12(Double_t* x, Double_t* p){
53  bool dbThis=false;
54 
55  double s12 = x[0];
56  if(s12 < 0) return 0;
57  double m12 = sqrt(s12);
58  double mum = p[0];
59  double m1 = p[1];
60  double m2 = p[2];
61  double m3 = p[3];
62  if(dbThis) cout << " d3body_by_ds12 called with "
63  << mum << ", "
64  << m1 << ", "
65  << m2 << ", "
66  << m3 << endl;
67 
68  return phaseSpaceIntegral2body(mum, m12, m3)
69  * phaseSpaceIntegral2body(m12, m1, m2);
70 }
71 
72 double d_ps4_by_ds12ds34_withFct(Double_t* x, Double_t* p) {
73  //bool dbThis=false;
74 
75  double rho12 = x[0];
76  double rho34 = x[1];
77  double s12= Global_s12Fct->coordTransformToS(rho12);
78  double s34= Global_s34Fct->coordTransformToS(rho34);
79 
80 
81  if(s12 < 0) return 0;
82  double m12 = sqrt(s12);
83  if(m12 < p[1] + p[2]) return 0;
84 
85  if(s34 < 0) return 0;
86  double m34 = sqrt(s34);
87  if(m34 < p[3] + p[4]) return 0;
88  if(m12 + m34 > p[0]) return 0;
89 
90 
91  double ps1 = phaseSpaceIntegral2body(p[0]
92  , m12
93  , m34);
94 
95  if(ps1 <=0) return 0;
96 
97  double ps2 = phaseSpaceIntegral2body(m12
98  , p[1]
99  , p[2]);
100 
101  if(ps2 <=0) return 0;
102 
103  double ps3 = phaseSpaceIntegral2body(m34
104  , p[3]
105  , p[4]);
106  if(ps3 <=0) return 0;
107 
108 
109  double fct12 = Global_s12Fct->transformedFctValue(rho12);
110  double fct34 = Global_s34Fct->transformedFctValue(rho34);
111 
112  return fct12 * fct34 * ps1*ps2*ps3;
113 }
114 
115 double d_ps4_by_ds123ds12_withFct(Double_t* x, Double_t* p){
116 
117 
118  double rho123 = x[0];
119  double rho12 = x[1];
120 
121  double s123 = Global_s123Fct->coordTransformToS(rho123);
122  double s12 = Global_s12Fct->coordTransformToS(rho12);
123 
124 
125 
126  if(s123 < 0) return 0;
127  double m123 = sqrt(s123);
128  if(m123 + p[4] > p[0]) return 0;
129  if(m123 < p[1] + p[2] + p[3]) return 0;
130 
131  if(s12 < 0) return 0;
132  double m12 = sqrt(s12);
133  if(m12 + p[3] > m123)return 0;
134  if(m12 < p[1] + p[2]) return 0;
135 
136 
137  double ps1 = phaseSpaceIntegral2body(p[0]
138  , m123
139  , p[4]);
140 
141  if(ps1 <=0) return 0;
142 
143 
144  double ps2 = phaseSpaceIntegral2body(m123
145  , sqrt(s12)
146  , p[3]);
147 
148  if(ps2 <=0) return 0;
149 
150  double ps3 = phaseSpaceIntegral2body(m12
151  , p[1]
152  , p[2]);
153 
154  if(ps3 <=0) return 0;
155 
156  double fct123 = Global_s123Fct->transformedFctValue(rho123);
157  double fct12 = Global_s12Fct->transformedFctValue(rho12);
158 
159  return fct123*fct12 * ps1*ps2*ps3;
160 
161 }
162 
163 /* now inlined, see header.
164 double phaseSpaceIntegral2body(const DalitzEventPattern& _pat){
165  if(_pat.size() != 3){
166  cout << "phaseSpaceIntegral2body: wrong pattern " << _pat << endl;
167  }
168  double mum = _pat[0].mass();
169  double d1 = _pat[1].mass();
170  double d2 = _pat[2].mass();
171  return phaseSpaceIntegral2body(mum, d1, d2);
172 }
173 
174 double phaseSpaceIntegral2body(double mum, double d1, double d2){
175  if(mum <=0 ) return 0;
176  if(mum < d1 + d2) return 0;
177 
178  double la = lambda(mum*mum, d1*d1, d2*d2);
179  if(la <= 0) return 0;
180 
181  return pi * sqrt(la)/(2*mum*mum);
182 
183 }
184 */
185 
186 
188  if(0 == _f){
189  _f = new TF1("d3body_by_ds12", d3body_by_ds12
190  , 0, 10*GeV*GeV
191  , 4
192  );
193  }
194  if(0 == _f){
195  cout << "phaseSpaceIntegral3body::phaseSpaceIntegral3body()"
196  << " failed to get TF1!!!" << endl;
197  }
198 }
199 
200 
202  if(_pat.size() != 4){
203  cout << "phaseSpaceIntegral3body: wrong pattern " << _pat << endl;
204  }
205  double mum = _pat[0].mass();
206  double d1 = _pat[1].mass();
207  double d2 = _pat[2].mass();
208  double d3 = _pat[3].mass();
209 
210  return getVal(mum, d1, d2, d3);
211 }
212 
213 double PhaseSpaceIntegral3body::getVal(double mum, double d1
214  , double d2, double d3){
215  bool dbThis=false;
216  double min_m12 = (d1 + d2);
217  double max_m12 = (mum - d3);
218  if(dbThis)cout << "PhaseSpaceIntegral3body::getVal : from, to "
219  << min_m12 << ", " << max_m12 << endl;
220  if(min_m12 >= max_m12) return 0;
221 
222  double min_s12 = min_m12*min_m12;
223  double max_s12 = max_m12*max_m12;
224 
225  Double_t para[4]={mum, d1, d2, d3};
226 
227  _f->SetParameters(para);
228 
229 
230  /*
231  Int_t np = 1000;
232  double x[np];
233  double w[np];
234  _f->CalcGaussLegendreSamplingPoints(np,x,w,1e-15);
235  double returnVal = _f->IntegralFast(np,x,w, min_s12, max_s12, para);
236  */
237 
238  double returnVal = _f->Integral(min_s12, max_s12);//, para);
239  if(dbThis) cout << "PhaseSpaceIntegral3body::getVal() returning "
240  << returnVal << endl;
241  return returnVal;
242 }
243 
244 
245 
247  if(0 == _f){
248  _f = new TF1("d4body_by_ds12", d4body_by_ds12
249  , 0, 10*GeV*GeV
250  , 5
251  );
252  }
253  if(0 == _f){
254  cout << "phaseSpaceIntegral4body::phaseSpaceIntegral3body()"
255  << " failed to get TF1!!!" << endl;
256  }
257 }
258 
259 
261  if(_pat.size() != 5){
262  cout << "phaseSpaceIntegral4body: wrong pattern " << _pat << endl;
263  }
264  double mum = _pat[0].mass();
265  double d1 = _pat[1].mass();
266  double d2 = _pat[2].mass();
267  double d3 = _pat[3].mass();
268  double d4 = _pat[4].mass();
269  return getVal(mum, d1, d2, d3, d4);
270 }
272  , double d1, double d2
273  , double d3, double d4){
274 
275  bool dbThis = false;
276 
277  double min_m12 = (d1 + d2);
278  double max_m12 = (mum - d3 - d4);
279  if(dbThis)cout << "PhaseSpaceIntegral4body::getVal : from, to "
280  << min_m12 << ", " << max_m12 << endl;
281  if(min_m12 >= max_m12) return 0;
282 
283  double min_s12 = min_m12*min_m12;
284  double max_s12 = max_m12*max_m12;
285 
286  Double_t para[5]={mum, d1, d2, d3, d4};
287 
288  _f->SetParameters(para);
289 
290  Int_t np = 1000;
291  double xpts[1000];
292  double wpts[1000];
293  _f->CalcGaussLegendreSamplingPoints(np,xpts,wpts,1e-15);
294  return _f->IntegralFast(np,xpts,wpts, min_s12, max_s12, para);
295  // return _f->Integral(min_s12, max_s12, para);
296 }
298  if(_pat.size() != 5){
299  cout << "phaseSpaceIntegral4body: wrong pattern " << _pat << endl;
300  }
301  double mum = _pat[0].mass();
302  double d1 = _pat[1].mass();
303  double d2 = _pat[2].mass();
304  double d3 = _pat[3].mass();
305  double d4 = _pat[4].mass();
306  return getValCheck(mum, d1, d2, d3, d4);
307 }
308 double PhaseSpaceIntegral4body::getValCheck(double mum, double d1
309  , double d2, double d3
310  , double d4){
311 
312  bool dbThis = false;
313 
314  double min_m12 = (d1 + d2);
315  double max_m12 = (mum - d3 - d4);
316  if(dbThis)cout << "PhaseSpaceIntegral4body::getVal : from, to "
317  << min_m12 << ", " << max_m12 << endl;
318  if(min_m12 >= max_m12) return 0;
319 
320  double min_s12 = min_m12*min_m12;
321  double max_s12 = max_m12*max_m12;
322 
323  Double_t para[5]={mum, d1, d2, d3, d4};
324 
325  _f->SetParameters(para);
326 
327  int NSteps = 10000;
328  double sum = 0;
329  double dx = (max_s12 - min_s12)/((double)NSteps);
330 
331  for(int i=0; i< NSteps; i++){
332  double dim = 0.5 + (double) i;
333  double x = min_s12 + dx*dim;
334  sum += _f->Eval(x);
335  }
336  return sum*dx;
337 }
338 
339 
342  , IGenFct* s34f
343  , const DalitzEventPattern& pat
344  )
345  : _s12Fct(s12f)
346  , _s34Fct(s34f)
347  , _pat(pat)
348 {
349 }
350 
353  , IGenFct* s12f
354  , const DalitzEventPattern& pat
355  )
356  : _s123Fct(s123f)
357  , _s12Fct(s12f)
358  , _pat(pat)
359 {
360 }
361 
363  bool dbThis=true;
364 
365  double xmi = _s12Fct->getRhoMi();
366  double xma = _s12Fct->getRhoMa();
367 
368  double ymi = _s34Fct->getRhoMi();
369  double yma = _s34Fct->getRhoMa();
370 
371  const int numParticles=5;
372 
375 
376  Double_t p[numParticles];
377  for(int i=0; i < numParticles; i++){
378  p[i] = _pat[i].mass();
379  }
380 
381  TF2 intFunc("d_ps4_by_ds12ds34_withFct"
383  , xmi, xma
384  , ymi, yma
385  , numParticles
386  );
387 
388 
389  intFunc.SetParameters(p);
390 
391  Double_t a[2];
392  Double_t b[2];
393  a[0]=xmi; b[0]=xma;
394  a[1]=ymi; b[1]=yma;
395 
396  Int_t nDim = 2;
397  Int_t mipt = 4000000;
398  Int_t mapt = 400000000;
399  Double_t epsilon = 1.e-8;
400  Double_t relerr = -1;
401  Int_t nfnevl = 9999;
402  Int_t iFail = -9999;
403  double returnVal = intFunc.IntegralMultiple(nDim, a, b
404  , mipt, mapt
405  , epsilon, relerr
406  , nfnevl, iFail);
407  if(dbThis){
408  cout << "12, 34: just called : "
409  << " intFunc.IntegralMultiple( " << nDim
410  << ", " << a[0] << "-" << b[0]
411  << ", " << a[1] << "-" << b[1]
412  << ", " << mipt <<", " << mapt
413  << ", " << epsilon << ", " << relerr
414  << ", " << nfnevl << ", " << iFail
415  << " );"
416  << " = " << returnVal << endl;
417  // cout << " ..... compare with: " << intFunc.Integral(xmi, xma, ymi, yma) << endl;
418 
419  }
420  return returnVal;
421 
422 }
423 
425  bool dbThis=true;
426 
427  double xmi = _s123Fct->getRhoMi();
428  double xma = _s123Fct->getRhoMa();
429 
430  double ymi = _s12Fct->getRhoMi();
431  double yma = _s12Fct->getRhoMa();
432 
433  const int numParticles=5;
434 
437 
438  TF2 intFunc("d_ps4_by_ds13ds12_withFct"
440  , xmi, xma
441  , ymi, yma
442  , numParticles
443  );
444 
445  Double_t p[numParticles];
446  for(int i=0; i < numParticles; i++){
447  p[i] = _pat[i].mass();
448  }
449 
450  intFunc.SetParameters(p);
451 
452  Double_t a[2];
453  Double_t b[2];
454  a[0]=xmi; b[0]=xma;
455  a[1]=ymi; b[1]=yma;
456 
457  Int_t nDim = 2;
458  Int_t mipt = 4000000;
459  Int_t mapt = 400000000;
460  Double_t epsilon = 1.e-8;
461  Double_t relerr = -1;
462  Int_t nfnevl = 9999;
463  Int_t iFail = -9999;
464  double returnVal = intFunc.IntegralMultiple(nDim, a, b
465  , mipt, mapt
466  , epsilon, relerr
467  , nfnevl, iFail);
468 
469  if(dbThis){
470  cout << "123, 12: just called : "
471  << " intFunc.IntegralMultiple( " << nDim
472  << ", " << a[0] << "-" << b[0]
473  << ", " << a[1] << "-" << b[1]
474  << ", " << mipt <<", " << mapt
475  << ", " << epsilon << ", " << relerr
476  << ", " << nfnevl << ", " << iFail
477  << " );"
478  << " = " << returnVal << endl;
479  // cout << " ..... compare with: " << intFunc.Integral(xmi, xma, ymi, yma) << endl;
480  }
481 
482  return returnVal;
483 
484  // return intFunc.Integral(xmi, xma, ymi, yma);
485 
486 }
487 
489 
490  if(pat.numDaughters() < 2 ){
491  return 0;
492  }else if(pat.numDaughters() == 2 ){
493  return phaseSpaceIntegral2body(pat);
494  }else if(pat.numDaughters() == 3){
496  return p3.getVal(pat);
497  }else if(pat.numDaughters() == 4){
499  return p4.getVal(pat);
500  }else{
501  return -9999;
502  }
503 
504 }
505 
506 //
507 //
508 
509 
IGenFct * Global_s34Fct
double d4body_by_ds12(Double_t *x, Double_t *p)
IGenFct * Global_s12Fct
virtual double transformedFctValue(double rho) const
Definition: IGenFct.h:34
double phaseSpaceIntegral2body(double mum, double d1, double d2)
PhaseSpaceIntegral4bodyWith_s123s12(IGenFct *s123f, IGenFct *s12f, const DalitzEventPattern &pat)
double getVal(const DalitzEventPattern &_pat)
PhaseSpaceIntegral4bodyWith_s12s34(IGenFct *s12f, IGenFct *s34f, const DalitzEventPattern &pat)
static const double m2
double getValCheck(const DalitzEventPattern &_pat)
static const double GeV
double phaseSpaceIntegral_upTo4body(const DalitzEventPattern &pat)
double d3body_by_ds12(Double_t *x, Double_t *p)
unsigned int size() const
virtual double getRhoMi() const
Definition: IGenFct.h:38
double d_ps4_by_ds123ds12_withFct(Double_t *x, Double_t *p)
double getVal(const DalitzEventPattern &_pat)
IGenFct * Global_s123Fct
static const double m3
virtual double coordTransformToS(double rho) const
Definition: IGenFct.h:33
double d_ps4_by_ds12ds34_withFct(Double_t *x, Double_t *p)
virtual double getRhoMa() const
Definition: IGenFct.h:39