]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTCrab.cxx
Processing of all events in the files
[u/mrichter/AliRoot.git] / HBTAN / AliHBTCrab.cxx
CommitLineData
dd82cadc 1#include "AliHBTCrab.h"
2//______________________________________________________________________
3/////////////////////////////////////////////////////////////////////////
4// //
5// AliRoot wrapper to CRAB //
6// taken from http://www.nscl.msu.edu/~pratt/freecodes/crab/home.html //
7// written by Scott Pratt //
8// //
9/////////////////////////////////////////////////////////////////////////
f93c53d8 10
dd82cadc 11#include "AliHBTPair.h"
12
13#include <TMath.h>
14#include <TPDGCode.h>
15
16#include "volya_complex.h"
17
18//#include <complex>
19//using namespace std;
20AliHBTCrab* AliHBTCrab::fgCrab = 0x0;
21
22const Double_t AliHBTCrab::fgkWcons = 1./0.1973;
23const Double_t AliHBTCrab::fgkROOT2=1.41421356237309504880;
8882f543 24#ifdef __DECCXX
25const complex AliHBTCrab::ci(0.0,1.0);
26#else
dd82cadc 27const double_complex AliHBTCrab::ci(0.0,1.0);
8882f543 28#endif
dd82cadc 29
30/************************************************************/
31
32AliHBTCrab* AliHBTCrab::Instance()
33{
34// returns instance of class
35 if (fgCrab == 0x0)
36 {
37 fgCrab = new AliHBTCrab();
38 }
39 return fgCrab;
40}
41//===================================================================
42void AliHBTCrab::Set()
43{
44 //sets this as weighitng class
45 Info("Set","Setting CRAB as Weighing Class");
46
47 if ( fgWeights == 0x0 )
48 {
49 fgWeights = AliHBTCrab::Instance();
50 return;
51 }
52 if ( fgWeights == AliHBTCrab::Instance() ) return;
53 delete fgWeights;
54 fgWeights = AliHBTCrab::Instance();
55}
56//===================================================================
57
58AliHBTCrab::AliHBTCrab():
59fBreitWigner(kFALSE),
60fReducedMom(kTRUE),
61fMaxMomentum(100.0)
62{
63 //ctor
64}
65//===================================================================
66void AliHBTCrab::Init(Int_t pid1,Int_t pid2)
67{
68 MASS1 = TDatabasePDG::Instance()->GetParticle(pid1)->Mass();
69 MASS2 = TDatabasePDG::Instance()->GetParticle(pid2)->Mass();
70 INTERACTION_WSYM = 1.0;
71 INTERACTION_WANTI = 0.0;
72 INTERACTION_WNOSYM = 0.0;
73 INTERACTION_DELK = 1.0;
74 INTERACTION_NKMAX = 100;
75
76 fPid1 = pid1;
77 fPid2 = pid2;
78
79}
80
81Bool_t AliHBTCrab::SetConfig(const AliHBTPair* pair)
82{
83 Int_t pdg1 = pair->Particle1()->GetPdgCode();
84 Int_t pdg2 = pair->Particle2()->GetPdgCode();
85
86 if ( ( pdg1 == fPid1) && ( pdg2 == fPid2) ) return kFALSE;
87 else Init (pdg1,pdg2);
88
89 return kTRUE;
90}
91//===================================================================
92
93Double_t AliHBTCrab::GetWeight(const AliHBTPair* partpair)
94{
95 Double_t qred, r, qdotr, mom;
96 Int_t test;
97
98 SetConfig(partpair);
99
100 get_com_quantities(partpair, &qred, &r, &qdotr, &mom, &test);
101 if(test==0)
102 {
103 Info("GetWeight","Test is 0");
104 }
105 Double_t corr = corrcalc(qred,qdotr,r);
106
107 return corr;
108}
109//===================================================================
110
111void AliHBTCrab::get_com_quantities(const AliHBTPair* pair,
112 double *qred,double *r,double *qdotr,double *mom, int *test)
113 {
114//************************************
115// ALICE //
116
117 double p1[4];
118 double p2[4];
119 double r1[4];
120 double r2[4];
121
122 static const Double_t cmtofm = 1.e13;
f93c53d8 123// static const Double_t cmtoOneOverGeV = cmtofm*fgkWcons;
dd82cadc 124
125 AliHBTParticle *part1 = pair->Particle1();
126 AliHBTParticle *part2 = pair->Particle2();
127
128 p1[0] = part1->Energy()*1000.0;
129 p1[1] = part1->Px()*1000.0;
130 p1[2] = part1->Py()*1000.0;
131 p1[3] = part1->Pz()*1000.0;
132
133 p2[0] = part2->Energy()*1000.0;
134 p2[1] = part2->Px()*1000.0;
135 p2[2] = part2->Py()*1000.0;
136 p2[3] = part2->Pz()*1000.0;
137
138 r1[0] = part1->T();
139 r1[1] = part1->Vx()*cmtofm;
140 r1[2] = part1->Vy()*cmtofm;
141 r1[3] = part1->Vz()*cmtofm;
142
143 r2[0] = part2->T();
144 r2[1] = part2->Vx()*cmtofm;
145 r2[2] = part2->Vy()*cmtofm;
146 r2[3] = part2->Vz()*cmtofm;
147
148// END OF ALICE STUFF
149
150// This code is written by Scott Pratt
151// taken from http://www.nscl.msu.edu/~pratt/freecodes/crab/home.html
152 int alpha;
153 double kdotr;
f93c53d8 154 double momtest;
dd82cadc 155 if (fReducedMom)
156 {
f93c53d8 157 momtest=4.0*fMaxMomentum*fMaxMomentum;
dd82cadc 158 }
159 else
160 {
f93c53d8 161 momtest=fMaxMomentum*fMaxMomentum;
dd82cadc 162 }
163
164 double ptot2,pdotr,pp,rr;
165
166 if ( part1->GetPdgCode() == part2->GetPdgCode() )
167 {
168 *test=1;
169 *mom=-(p2[0]-p1[0])*(p2[0]-p1[0]);
170 for(alpha=1;alpha<4;alpha++){
171 *mom=*mom+(p2[alpha]-p1[alpha])*(p2[alpha]-p1[alpha]);
172 }
173 //#if ! defined MIXED_PAIRS_FOR_DENOM
174 // if(*mom>momtest){
175 // *test=0;
176 // return;
177 // }
178 //#endif
179 pp=(p1[0]+p2[0]);
180 rr=(r2[0]-r1[0]);
181 pdotr=pp*rr;
182 kdotr=(p2[0]-p1[0])*rr;
183 ptot2=pp*pp;
184 *r=-rr*rr;
185 for(alpha=1;alpha<4;alpha++){
186 pp=(p1[alpha]+p2[alpha]);
187 rr=(r2[alpha]-r1[alpha]);
188 pdotr=pdotr-pp*rr;
189 kdotr=kdotr-(p2[alpha]-p1[alpha])*rr;
190 ptot2=ptot2-pp*pp;
191 *r=*r+rr*rr;
192 }
193 *mom=sqrt(*mom);
194 *qred=0.5**mom;
195
196 if (fReducedMom)
197 {
198 *mom=*qred;
199 }
200
201 *qdotr=0.5*kdotr;
202 *r=sqrt(*r+pdotr*pdotr/ptot2);
203 }
204 else //identical
205 {
206 // const double kdotp=MASS2*MASS2-MASS1*MASS1;
207 const double kdotp = part2->GetMass()*part2->GetMass()- part1->GetMass()*part1->GetMass();
208 *test=1;
209 *mom=-(p2[0]-p1[0])*(p2[0]-p1[0]);
210 ptot2=(p1[0]+p2[0])*(p1[0]+p2[0]);
211 for(alpha=1;alpha<4;alpha++){
212 *mom=*mom+(p2[alpha]-p1[alpha])*(p2[alpha]-p1[alpha]);
213 ptot2=ptot2-(p1[alpha]+p2[alpha])*(p1[alpha]+p2[alpha]);
214 }
215 *mom=*mom+kdotp*kdotp/ptot2;
216 //#if ! defined MIXED_PAIRS_FOR_DENOM
217 // if(*mom>momtest){
218 // *test=0;
219 // return;
220 // }
221 //#endif
222 pp=(p1[0]+p2[0]);
223 rr=(r2[0]-r1[0]);
224 pdotr=pp*rr;
225 kdotr=(p2[0]-p1[0])*rr;
226 *r=-rr*rr;
227 for(alpha=1;alpha<4;alpha++){
228 pp=(p1[alpha]+p2[alpha]);
229 rr=(r2[alpha]-r1[alpha]);
230 pdotr=pdotr-pp*rr;
231 kdotr=kdotr-(p2[alpha]-p1[alpha])*rr;
232 *r=*r+rr*rr;
233 }
234 kdotr=(-kdotr+kdotp*pdotr/ptot2);
235 *mom=sqrt(*mom);
236 *qred=0.5**mom;
237
238 if (fReducedMom)
239 {
240 *mom=*qred;
241 }
242
243 *qdotr=0.5*kdotr;
244 *r=sqrt(*r+pdotr*pdotr/ptot2);
245 }//not identical
246
247 return;
248}
249
250
251//===================================================================
252
253double AliHBTCrab::corrcalc(double trueqred,double trueqdotr,double truer)
254{
255//#define REDUCED_MOM
256// This code is written by Scott Pratt
257// taken from http://www.nscl.msu.edu/~pratt/freecodes/crab/home.html
f93c53d8 258 double eta,arg,corr0;
259// double xx,xxprime,xxjj,p1,zk;
260// int jj,kk,ipart,ipartcount,ispin;
261 int kk;
262 double wsym_leftover,wanti_leftover,wnosym_leftover;
dd82cadc 263 double qred,qdotr,r;
f93c53d8 264// const double rmass=MASS1*MASS2/(MASS1+MASS2);
8882f543 265#ifdef __DECCXX
266 complex cphi1,cphi2,cphis,cphia;
267#else
dd82cadc 268 double_complex cphi1,cphi2,cphis,cphia;
8882f543 269#endif
dd82cadc 270
3294e9ff 271 arg=trueqdotr/197.323-2.0*TMath::Pi()*TMath::Floor(trueqdotr/(197.323*2.0*TMath::Pi()));
dd82cadc 272 cphi1=exp(ci*arg);
273 cphis=fgkROOT2*real(cphi1);
274 cphia=ci*fgkROOT2*imag(cphi1);
275 corr0=real(INTERACTION_WSYM*cphis*conj(cphis)
276 +INTERACTION_WANTI*cphia*conj(cphia)
277 +INTERACTION_WNOSYM*cphi1*conj(cphi1));
278 goto OUTSIDE_INTERACTION_RANGE;
279
280#ifdef REDUCED_MOM
3294e9ff 281 kk=(int)TMath::Floor(trueqred/INTERACTION_DELK);
dd82cadc 282 qred=(0.5+kk)*INTERACTION_DELK;
283#else
3294e9ff 284 kk=(int)TMath::Floor(2.0*trueqred/INTERACTION_DELK);
dd82cadc 285 qred=(0.5+kk)*INTERACTION_DELK/2.0;
286#endif
287 qdotr=trueqdotr*qred/trueqred;
288 if(kk>=INTERACTION_NKMAX){
289 corr0=1.0;
290 goto OUTSIDE_INTERACTION_RANGE;
291 }
292 r=truer;
293
294 eta=0.0;
3294e9ff 295 arg=qdotr/197.323-2.0*TMath::Pi()*TMath::Floor(qdotr/(197.323*2.0*TMath::Pi()));
dd82cadc 296 cphi1=exp(ci*arg);
297 cphi2=conj(cphi1);
298
299 cphis=(cphi1+cphi2)/fgkROOT2;
300 cphia=(cphi1-cphi2)/fgkROOT2;
301 corr0=0.0;
302 /* If there are corrections for strong interactions, add the
303 change for each partial wave. If npartial = 0 then there
304 are no strong int. corrections. */
305 wsym_leftover=INTERACTION_WSYM;
306 wanti_leftover=INTERACTION_WANTI;
307 wnosym_leftover=INTERACTION_WNOSYM;
308
309 corr0=corr0+real(wsym_leftover*cphis*conj(cphis)
310 +wanti_leftover*cphia*conj(cphia)
311 +wnosym_leftover*cphi1*conj(cphi1));
312OUTSIDE_INTERACTION_RANGE:
313
314#ifdef BREIT_WIGNER
315 corr0=corr0+bwcalc(trueqred,truer);
316#endif
317
318 return corr0;
319}
320
8882f543 321#ifdef __DECCXX
322complex AliHBTCrab::cgamma(complex c){
323#else
dd82cadc 324double_complex AliHBTCrab::cgamma(double_complex c){
8882f543 325#endif
dd82cadc 326 /* This calc.s gamma functions which are in the form gamma(n+i*y)
327 where n is an int and y is real. */
328// This code is written by Scott Pratt
329// taken from http://www.nscl.msu.edu/~pratt/freecodes/crab/home.html
8882f543 330#ifdef __DECCXX
331 complex cg,cphase;
332#else
dd82cadc 333 double_complex cg,cphase;
8882f543 334#endif
dd82cadc 335 int mm,j;
336 double x,y,phase,delp,cgmag;
337 x=real(c);
338 y=imag(c);
339 phase=-TMath::E()*y;
340 for(j=1;j<=100000;j++){
341 delp=(y/(double)j)-atan(y/(double)j);
342 phase=phase+delp;
3294e9ff 343 if(TMath::Abs(delp)<1E-10) goto CGAMMA_ESCAPE;
dd82cadc 344 }
345 printf("oops not accurate enough, increase jmax\n");
346CGAMMA_ESCAPE:
3294e9ff 347 phase=phase-2.0*TMath::Pi()*TMath::Floor(phase/(2.0*TMath::Pi()));
dd82cadc 348 cphase=exp(ci*phase);
349 cgmag=sqrt(TMath::Pi()*y/sinh(TMath::Pi()*y));
3294e9ff 350 mm=(int)TMath::Floor(x+0.5);
dd82cadc 351 cg=cgmag*cphase;
352 if(mm<1){
353 for(j=1;j<=-mm+1;j++){
354 cg=cg/(1.0+(double)(-j)+ci*y);
355 }
356 }
357 if(mm>1) {
358 for(j=1;j<=mm-1;j++){
359 cg=cg*((double)(j)+ci*y);
360 }
361 }
362 return cg;
363}
364//===================================================================
365