1 #include "AliHBTCrab.h"
2 //______________________________________________________________________
3 /////////////////////////////////////////////////////////////////////////
5 // AliRoot wrapper to CRAB //
6 // taken from http://www.nscl.msu.edu/~pratt/freecodes/crab/home.html //
7 // written by Scott Pratt //
10 /////////////////////////////////////////////////////////////////////////
12 #include "AliHBTPair.h"
13 #include "AliVAODParticle.h"
14 #include "TDatabasePDG.h"
17 #include "volya_complex.h"
19 AliHBTCrab* AliHBTCrab::fgCrab = 0x0;
21 const Double_t AliHBTCrab::fgkWcons = 1./0.1973;
22 const Double_t AliHBTCrab::fgkROOT2=1.41421356237309504880;
24 const complex AliHBTCrab::fgkCI(0.0,1.0);
26 const doublecomplex AliHBTCrab::fgkCI(0.0,1.0);
29 /************************************************************/
31 AliHBTCrab* AliHBTCrab::Instance()
33 // returns instance of class
36 fgCrab = new AliHBTCrab();
40 //===================================================================
42 void AliHBTCrab::Set()
44 //sets this as weighitng class
45 Info("Set","Setting CRAB as Weighing Class");
47 if ( fgWeights == 0x0 )
49 fgWeights = AliHBTCrab::Instance();
52 if ( fgWeights == AliHBTCrab::Instance() ) return;
54 fgWeights = AliHBTCrab::Instance();
56 //===================================================================
58 AliHBTCrab::AliHBTCrab():
66 Fatal("AliHBTCrab","Do not use constructor directly. Use Instance() instead.");
69 //===================================================================
71 AliHBTCrab::AliHBTCrab(const AliHBTCrab &/*source*/):
79 //===================================================================
80 AliHBTCrab & AliHBTCrab::operator=(const AliHBTCrab& /*source*/)
83 return *AliHBTCrab::Instance();
86 void AliHBTCrab::Init(Int_t pid1,Int_t pid2)
88 //Initialization method
89 fMass1 = TDatabasePDG::Instance()->GetParticle(pid1)->Mass();
90 fMass2 = TDatabasePDG::Instance()->GetParticle(pid2)->Mass();
91 fInteractionWsym = 1.0;
92 fInteractionWanti = 0.0;
93 fInteractionWnosym = 0.0;
94 fInteractionDelk = 1.0;
95 fInteractionNkmax = 100;
100 //===================================================================
102 Bool_t AliHBTCrab::SetConfig(const AliHBTPair* pair)
104 //returns the SetConfig
106 Int_t pdg1 = pair->Particle1()->GetPdgCode();
107 Int_t pdg2 = pair->Particle2()->GetPdgCode();
109 if ( ( pdg1 == fPid1) && ( pdg2 == fPid2) ) return kFALSE;
110 else Init (pdg1,pdg2);
114 //===================================================================
116 Double_t AliHBTCrab::GetWeight(AliHBTPair* partpair)
119 Double_t qred, r, qdotr, mom;
124 GetComQuantities(partpair, &qred, &r, &qdotr, &mom, &test);
127 Info("GetWeight","Test is 0");
129 Double_t corr = CorrCalc(qred,qdotr,r);
133 //===================================================================
135 void AliHBTCrab::GetComQuantities(const AliHBTPair* pair,
136 double *qred,double *r,double *qdotr,double *mom, int *test)
138 //************************************
146 static const Double_t kCmToFm = 1.e13;
147 // static const Double_t cmtoOneOverGeV = kCmToFm*fgkWcons;
149 AliVAODParticle *part1 = pair->Particle1();
150 AliVAODParticle *part2 = pair->Particle2();
152 p1[0] = part1->E()*1000.0;
153 p1[1] = part1->Px()*1000.0;
154 p1[2] = part1->Py()*1000.0;
155 p1[3] = part1->Pz()*1000.0;
157 p2[0] = part2->E()*1000.0;
158 p2[1] = part2->Px()*1000.0;
159 p2[2] = part2->Py()*1000.0;
160 p2[3] = part2->Pz()*1000.0;
163 r1[1] = part1->Vx()*kCmToFm;
164 r1[2] = part1->Vy()*kCmToFm;
165 r1[3] = part1->Vz()*kCmToFm;
168 r2[1] = part2->Vx()*kCmToFm;
169 r2[2] = part2->Vy()*kCmToFm;
170 r2[3] = part2->Vz()*kCmToFm;
172 // END OF ALICE STUFF
174 // This code is written by Scott Pratt
175 // taken from http://www.nscl.msu.edu/~pratt/freecodes/crab/home.html
181 momtest=4.0*fMaxMomentum*fMaxMomentum;
185 momtest=fMaxMomentum*fMaxMomentum;
188 double ptot2,pdotr,pp,rr;
190 if ( part1->GetPdgCode() == part2->GetPdgCode() )
193 *mom=-(p2[0]-p1[0])*(p2[0]-p1[0]);
194 for(alpha=1;alpha<4;alpha++){
195 *mom=*mom+(p2[alpha]-p1[alpha])*(p2[alpha]-p1[alpha]);
197 //#if ! defined MIXED_PAIRS_FOR_DENOM
206 kdotr=(p2[0]-p1[0])*rr;
209 for(alpha=1;alpha<4;alpha++){
210 pp=(p1[alpha]+p2[alpha]);
211 rr=(r2[alpha]-r1[alpha]);
213 kdotr=kdotr-(p2[alpha]-p1[alpha])*rr;
226 *r=sqrt(*r+pdotr*pdotr/ptot2);
230 // const double kdotp=fMass2*fMass2-fMass1*fMass1;
231 const double kdotp = part2->Mass()*part2->Mass()- part1->Mass()*part1->Mass();
233 *mom=-(p2[0]-p1[0])*(p2[0]-p1[0]);
234 ptot2=(p1[0]+p2[0])*(p1[0]+p2[0]);
235 for(alpha=1;alpha<4;alpha++){
236 *mom=*mom+(p2[alpha]-p1[alpha])*(p2[alpha]-p1[alpha]);
237 ptot2=ptot2-(p1[alpha]+p2[alpha])*(p1[alpha]+p2[alpha]);
239 *mom=*mom+kdotp*kdotp/ptot2;
240 //#if ! defined MIXED_PAIRS_FOR_DENOM
249 kdotr=(p2[0]-p1[0])*rr;
251 for(alpha=1;alpha<4;alpha++){
252 pp=(p1[alpha]+p2[alpha]);
253 rr=(r2[alpha]-r1[alpha]);
255 kdotr=kdotr-(p2[alpha]-p1[alpha])*rr;
258 kdotr=(-kdotr+kdotp*pdotr/ptot2);
268 *r=sqrt(*r+pdotr*pdotr/ptot2);
275 //===================================================================
277 double AliHBTCrab::CorrCalc(double trueqred,double trueqdotr,double truer)
279 //#define REDUCED_MOM
280 // This code is written by Scott Pratt
281 // taken from http://www.nscl.msu.edu/~pratt/freecodes/crab/home.html
282 double eta,arg,corr0;
283 // double xx,xxprime,xxjj,p1,zk;
284 // int jj,kk,ipart,ipartcount,ispin;
286 double wsymleftover,wantileftover,wnosymleftover;
288 // const double rmass=fMass1*fMass2/(fMass1+fMass2);
290 complex cphi1,cphi2,cphis,cphia;
292 doublecomplex cphi1,cphi2,cphis,cphia;
295 arg=trueqdotr/197.323-2.0*TMath::Pi()*TMath::Floor(trueqdotr/(197.323*2.0*TMath::Pi()));
296 cphi1=exp(fgkCI*arg);
297 cphis=fgkROOT2*real(cphi1);
298 cphia=fgkCI*fgkROOT2*imag(cphi1);
299 corr0=real(fInteractionWsym*cphis*conj(cphis)
300 +fInteractionWanti*cphia*conj(cphia)
301 +fInteractionWnosym*cphi1*conj(cphi1));
302 goto OUTSIDE_INTERACTION_RANGE;
305 kk=(int)TMath::Floor(trueqred/fInteractionDelk);
306 qred=(0.5+kk)*fInteractionDelk;
308 kk=(int)TMath::Floor(2.0*trueqred/fInteractionDelk);
309 qred=(0.5+kk)*fInteractionDelk/2.0;
311 qdotr=trueqdotr*qred/trueqred;
312 if(kk>=fInteractionNkmax){
314 goto OUTSIDE_INTERACTION_RANGE;
319 arg=qdotr/197.323-2.0*TMath::Pi()*TMath::Floor(qdotr/(197.323*2.0*TMath::Pi()));
320 cphi1=exp(fgkCI*arg);
323 cphis=(cphi1+cphi2)/fgkROOT2;
324 cphia=(cphi1-cphi2)/fgkROOT2;
326 /* If there are corrections for strong interactions, add the
327 change for each partial wave. If npartial = 0 then there
328 are no strong int. corrections. */
329 wsymleftover=fInteractionWsym;
330 wantileftover=fInteractionWanti;
331 wnosymleftover=fInteractionWnosym;
333 corr0=corr0+real(wsymleftover*cphis*conj(cphis)
334 +wantileftover*cphia*conj(cphia)
335 +wnosymleftover*cphi1*conj(cphi1));
336 OUTSIDE_INTERACTION_RANGE:
339 corr0=corr0+bwcalc(trueqred,truer);
346 complex AliHBTCrab::CGamma(complex c){
347 /* This calc.s gamma functions which are in the form gamma(n+i*y)
348 where n is an int and y is real. */
349 // This code is written by Scott Pratt
350 // taken from http://www.nscl.msu.edu/~pratt/freecodes/crab/home.html
352 doublecomplex AliHBTCrab::CGamma(doublecomplex c){
353 /* This calc.s gamma functions which are in the form gamma(n+i*y)
354 where n is an int and y is real. */
355 // This code is written by Scott Pratt
356 // taken from http://www.nscl.msu.edu/~pratt/freecodes/crab/home.html
361 doublecomplex cg,cphase;
364 double x,y,phase,delp,cgmag;
368 for(j=1;j<=100000;j++){
369 delp=(y/(double)j)-atan(y/(double)j);
371 if(TMath::Abs(delp)<1E-10) goto CGamma_ESCAPE;
373 printf("oops not accurate enough, increase jmax\n");
375 phase=phase-2.0*TMath::Pi()*TMath::Floor(phase/(2.0*TMath::Pi()));
376 cphase=exp(fgkCI*phase);
377 cgmag=sqrt(TMath::Pi()*y/sinh(TMath::Pi()*y));
378 mm=(int)TMath::Floor(x+0.5);
381 for(j=1;j<=-mm+1;j++){
382 cg=cg/(1.0+(double)(-j)+fgkCI*y);
386 for(j=1;j<=mm-1;j++){
387 cg=cg*((double)(j)+fgkCI*y);