]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HBTAN/AliHBTLLWeights.cxx
Corrections to obey the coding conventions
[u/mrichter/AliRoot.git] / HBTAN / AliHBTLLWeights.cxx
1 /* $Id$ */
2
3 //------------------------------------------------------------------
4 // This class introduces the weight's calculation 
5 // according to the Lednicky's algorithm.
6 // The detailed description of the algorithm can be found 
7 // in comments to fortran code:
8 // fsiw.f, fsiini.f
9 // Author:
10 //------------------------------------------------------------------
11
12 #include <TMath.h>
13 #include <TPDGCode.h>
14 #include <TRandom.h>
15
16 #include "AliHBTLLWeights.h"
17 #include "AliHBTPair.h"
18 #include "AliHBTParticle.h"
19 #include "WLedCOMMONS.h"
20
21 /*******************************************************************/
22 /******      ROUTINES    USED    FOR     COMMUNUCATION      ********/
23 /********************     WITH      FORTRAN     ********************/
24 /*******************************************************************/
25 #ifndef WIN32
26 # define led_bldata led_bldata_
27 # define fsiini fsiini_
28 # define ltran12 ltran12_
29 # define fsiw fsiw_
30 # define type_of_call
31 #else
32 # define led_bldata LED_BLDATA
33 # define fsiini FSIINI
34 # define ltran12 LTRAN12
35 # define fsiw FSIW
36 # define type_of_call _stdcall
37 #endif
38 /****************************************************************/
39 extern "C" void type_of_call led_bldata(); 
40 extern "C" void type_of_call fsiini();
41 extern "C" void type_of_call ltran12();
42 extern "C" void type_of_call fsiw();
43 /**************************************************************/
44
45 ClassImp(AliHBTLLWeights)  
46  
47 AliHBTLLWeights* AliHBTLLWeights::fgLLWeights=NULL; 
48
49 AliHBTLLWeights::AliHBTLLWeights()
50 {
51   // Default Constructor 
52   fPID1 = 0;
53   fPID2 = 0;
54   SetRandomPosition();
55   SetColWithResidNuclSwitch();
56   SetStrongInterSwitch();
57   SetQuantumStatistics();
58   SetColoumb();
59   SetTest();
60   
61 }
62
63
64 AliHBTLLWeights* AliHBTLLWeights::Instance()
65 {
66   // Instantiates new object or returns a pointer to already exitsing one
67   if (fgLLWeights) {
68     return fgLLWeights;
69   } else {
70     fgLLWeights = new AliHBTLLWeights();
71     return fgLLWeights;
72   }
73 }
74                                             
75
76 Double_t AliHBTLLWeights::GetWeight(const AliHBTPair* partpair)
77 {
78   // Returns the weignt of the pair "partpair"
79   AliHBTParticle *part1 = partpair->Particle1();
80   AliHBTParticle *part2 = partpair->Particle2();
81
82   if ( (part1 == 0x0) || (part2 == 0x0))
83     {
84       Error("GetWeight","Null particle pointer");
85       return 0.0;
86     }
87   
88    
89   Double_t part1Momentum[]={part1->Px(),part1->Py(),part1->Pz()};
90   Double_t part2Momentum[]={part2->Px(),part2->Py(),part2->Pz()};
91   
92   if ( (part1->Px() == part2->Px()) && 
93        (part1->Py() == part2->Py()) && 
94        (part1->Pz() == part2->Pz()) )
95     {
96       return 0.0;
97     }
98   
99              
100   if ((!fRandomPosition) && 
101       (part1->Vx()  == part2->Vx()) && (part1->Vy()  == part2->Vy())
102       && (part1->Vz()  == part2->Vz()) )
103     {        
104       return 0.0;
105     }
106   
107   
108   
109   FSI_MOM.P1X=part1Momentum[0];
110   FSI_MOM.P1Y=part1Momentum[1];
111   FSI_MOM.P1Z=part1Momentum[2];
112   
113   FSI_MOM.P2X=part2Momentum[0];
114   FSI_MOM.P2Y=part2Momentum[1];
115   FSI_MOM.P2Z=part2Momentum[2];
116   
117   if (fRandomPosition){
118     
119     Double_t rxcm = fsigma*gRandom->Gaus();
120     Double_t rycm = fsigma*gRandom->Gaus();
121     Double_t rzcm = fsigma*gRandom->Gaus();   
122     
123     FSI_PRF.X=rxcm*fwcons;
124     FSI_PRF.Y=rycm*fwcons;
125     FSI_PRF.Z=rzcm*fwcons;
126     FSI_PRF.T=0.;
127     
128     Double_t rps=rxcm*rxcm+rycm*rycm+rzcm*rzcm;
129     Double_t rp=TMath::Sqrt(rps);
130     FSI_PRF.RP=rp;
131     FSI_PRF.RPS=rps;
132     
133   }        
134   
135   ltran12();
136   fsiw();
137   
138   return LEDWEIGHT.WEIN;
139   
140 }
141
142 /************************************************************/
143 void AliHBTLLWeights::Init()
144 {
145   //---------------------------------------------------------------------  
146   //initial parameters of model
147   
148   FSI_NS.NS = fApproximationModel;      
149   
150   if(!ftest){LEDWEIGHT.ITEST=0;}
151   
152   if(ftest){
153     LEDWEIGHT.ITEST=1;
154     if(fColoumbSwitch){FSI_NS.ICH =1;}
155     else{FSI_NS.ICH=0;}
156     if(fStrongInterSwitch){FSI_NS.ISI=1;}
157     else{FSI_NS.ISI=0;}
158     if(fQuantStatSwitch){FSI_NS.IQS=1;}
159     else{FSI_NS.IQS=0;}
160     if(fColWithResidNuclSwitch){FSI_NS.I3C=1;}
161     else{FSI_NS.I3C=0;}
162   }
163   
164   if(fRandomPosition){LEDWEIGHT.IRANPOS=1;}
165   else{LEDWEIGHT.IRANPOS=0;}
166   
167   
168   if ( (fPID1 == 0) || (fPID2 == 0) )
169     {
170       Fatal("Init","Particles types are not set");
171       return;//pro forma
172     }
173   
174   FSI_NS.LL = GetPairCode(fPID1,fPID2);
175   
176   if (FSI_NS.LL == 0) 
177     {
178       Fatal("Init","Particles types are not supported");
179       return;//pro forma
180     }
181   
182   
183   TParticlePDG* tpart1 = TDatabasePDG::Instance()->GetParticle(fPID1);
184   if (tpart1 == 0x0)
185     {
186       Fatal("init","We can not find particle with ID=%d in our DataBase",fPID1);
187       return;
188     }
189   
190   FSI_POC.AM1=tpart1->Mass();
191   FSI_POC.C1=tpart1->Charge(); 
192   
193   TParticlePDG* tpart2 = TDatabasePDG::Instance()->GetParticle(fPID2);
194   //mlv
195   
196   
197   
198   if (tpart2 == 0x0)
199     {
200       Fatal("init","We can not find particle with ID=%d in our DataBase",fPID2);
201       return;
202     }
203   
204   FSI_POC.AM2=tpart2->Mass();
205   FSI_POC.C1=tpart2->Charge();
206   
207   led_bldata();
208   fsiini();
209   
210   
211   //constants for radii simulation 
212   
213   if(fRandomPosition){
214     fsigma =TMath::Sqrt(2.)*fRadius;     
215     fwcons =FSI_CONS.W;
216   } 
217
218
219 Int_t AliHBTLLWeights::GetPairCode(const AliHBTPair* partpair)
220 {
221   // Return the code of the pair "partpair"
222   return GetPairCode(partpair->Particle1()->GetPdgCode(),partpair->Particle2()->GetPdgCode());
223 }
224
225 Int_t AliHBTLLWeights::GetPairCode(Int_t pid1,Int_t pid2)
226 {
227   //   pairCode   1  2  3  4   5    6   7  8  9 10  11  12  13  14 15 16 17 18  19  20   21   22  23 24 25 26    27     28
228   //   hpid:      n  p  n alfa pi+ pi0 pi+ n  p pi+ pi+ pi+ pi- K+ K+ K+ K-  d  d    t   t    K0  K0  d p  p      p      n
229   //   lpid:      n  p  p alfa pi- pi0 pi+ d  d  K-  K+  p   p  K- K+ p  p   d alfa  t  alfa  K0  K0b t t alfa lambda lambda
230   //   NS=1 y/n:  +  +  +  +   +    -   -  -  -  -   -   -   -  -  -  -  -   -  -    -    -    -  -   - -  -      -      -
231   
232   //alphas, deuterons and tyts are NOT supported here
233   
234   Int_t chargefactor = 1;
235   Int_t hpid; //pid in higher row
236   Int_t lpid; //pid in lower row
237   Int_t code; //pairCode
238   
239   Bool_t swap;
240   
241   //determine the order of selcetion in switch  
242   if (TMath::Abs(pid1) < TMath::Abs(pid2) ) 
243     {
244       if (pid1<0) chargefactor=-1;
245       hpid=pid2*chargefactor;
246       lpid=pid1*chargefactor;
247       swap = kFALSE;
248     } 
249   else 
250     {
251       if (pid2<0) chargefactor=-1;
252       hpid=pid1*chargefactor;
253       lpid=pid2*chargefactor;
254       swap = kTRUE;
255     }
256   
257   //mlv
258   hpid=pid1;
259   lpid=pid2;
260   
261   
262   //Determine the pair code
263   switch (hpid) //switch on first  particle id
264     {
265     case kNeutron:
266       switch (lpid)
267         {
268         case kNeutron: 
269           code = 1;  //neutron neutron
270           break;
271           
272         case kProton: 
273           code = 3;  //neutron proton
274           break;
275           
276         case kLambda0: 
277           code = 28;  //neutron lambda
278           break;
279           
280         default: 
281           return 0; //given pair not supported
282           break;
283         }
284       break;
285       
286     case kProton:
287       switch (lpid)
288         {
289         case kProton:
290           code = 2; //proton proton
291           break;
292           
293         case kLambda0: 
294           code = 27;//proton lambda
295           break;
296           
297         default: 
298           return 0; //given pair not supported
299           break;
300           
301         }
302       break;
303       
304     case kPiPlus:
305       
306       switch (lpid)
307         {
308         case kPiPlus:
309           code = 7; //piplus piplus
310           break;
311           
312         case kPiMinus:
313           code = 5; //piplus piminus
314           break;
315           
316         case kKMinus:
317           code = 10; //piplus Kminus
318           break;
319           
320         case kKPlus:
321           code = 11; //piplus Kplus
322           break;
323           
324         case kProton:
325           code = 12; //piplus proton
326           chargefactor*=-1;
327           break;
328           
329         default: 
330           return 0; //given pair not supported
331           break;
332         }
333       break;
334     case kPi0:
335       switch (lpid)
336         {
337         case kPi0:
338           code = 6;
339           break;
340           
341         default: 
342           return 0; //given pair not supported
343           break;
344         }
345       break;
346       
347     case kKPlus:
348       switch (lpid)
349         {
350         case kKMinus:
351           code = 14; //Kplus Kminus
352           break;
353           
354         case kKPlus:
355           code = 15; //Kplus Kplus
356           break;
357           
358         case kProton:
359           code = 16; //Kplus proton
360           break;
361           
362         default: 
363           return 0; //given pair not supported
364           break;
365         }
366       break;
367       
368     case kKMinus:
369       switch (lpid)
370         {
371         case kProton:
372           code = 17; //Kminus proton
373           chargefactor*=1;
374           break;
375           
376         default: 
377           return 0; //given pair not supported
378           break;
379         }
380       break;
381       
382     case kK0:
383       switch (lpid)
384         {
385         case kK0:
386           code = 2; //Kzero Kzero
387           break;
388           
389         case kK0Bar:
390           code = 17; //Kzero KzeroBar
391           break;
392           
393         default: 
394           return 0; //given pair not supported
395           break;
396         }
397       break;
398       
399     default: return 0;
400     }
401   return code;
402 }
403