]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HBTAN/AliHBTLLWeights.cxx
Too Fast -> ESD modifications not yet commited
[u/mrichter/AliRoot.git] / HBTAN / AliHBTLLWeights.cxx
1 #include "AliHBTLLWeights.h"
2 /**************************************************************************
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  *                                                                        *
5  * Author: The ALICE Off-line Project.                                    *
6  * Contributors are mentioned in the code where appropriate.              *
7  *                                                                        *
8  * Permission to use, copy, modify and distribute this software and its   *
9  * documentation strictly for non-commercial purposes is hereby granted   *
10  * without fee, provided that the above copyright notice appears in all   *
11  * copies and that both the copyright notice and this permission notice   *
12  * appear in the supporting documentation. The authors make no claims     *
13  * about the suitability of this software for any purpose. It is          *
14  * provided "as is" without express or implied warranty.                  *
15  **************************************************************************/
16
17 //_________________________________________________________________________
18 ///////////////////////////////////////////////////////////////////////////
19 //
20 //  class AliHBTLLWeights
21 //
22 //  This class introduces the weight's calculation 
23 //  according to the Lednicky's algorithm.
24 //  
25 //  
26 //  fsiw.f, fsiini.f  
27 //
28 //  Description from fortran code by author R. Lednicky
29 //
30 //  Calculates final state interaction (FSI) weights                     
31 //  WEIF = weight due to particle - (effective) nucleus FSI (p-N)
32 //  WEI  = weight due to p-p-N FSI
33 //  WEIN = weight due to p-p FSI; note that WEIN=WEI if I3C=0;
34 //                                note that if I3C=1 the calculation of
35 //                                WEIN can be skipped by putting J=0
36 //.......................................................................
37 //  Correlation Functions:
38 //  CF(p-p-N)   = sum(WEI)/sum(WEIF)
39 //  CF(p-p)     = sum(WEIN)/sum(1); here the nucleus is completely
40 //                                  inactive
41 //  CF(p-p-"N") = sum(WEIN*WEIF')/sum(WEIF'), where WEIN and WEIF'
42 //                are not correlated (calculated at different emission
43 //                points, e.g., for different events);
44 //                thus here the nucleus affects one-particle
45 //                spectra but not the correlation
46 //.......................................................................
47 //  User must supply data file <fn> on unit NUNIT (e.g. =11) specifying
48 //  LL   : particle pair
49 //  NS   : approximation used to calculate Bethe-Salpeter amplitude
50 //  ITEST: test switch
51 //         If ITEST=1 then also following parameters are required
52 //  ICH  : 1(0) Coulomb interaction between the two particles ON (OFF)
53 //  IQS  : 1(0) quantum statistics for the two particles ON (OFF)
54 //  ISI  : 1(0) strong interaction between the two particles ON (OFF)
55 //  I3C  : 1(0) Coulomb interaction with residual nucleus ON (OFF)
56 //  This data file can contain other information useful for the user.
57 //  It is read by subroutines READINT4 and READREA8(4) (or READ_FILE).
58 //  -------------------------------------------------------------------
59 //-   LL       1  2  3  4   5    6   7  8  9 10  11  12  13  14 15 16 17
60 //-   part. 1: n  p  n alfa pi+ pi0 pi+ n  p pi+ pi+ pi+ pi- K+ K+ K+ K-
61 //-   part. 2: n  p  p alfa pi- pi0 pi+ d  d  K-  K+  p   p  K- K+ p  p
62 //   NS=1 y/n: +  +  +  +   +    -   -  -  -  -   -   -   -  -  -  -  -
63 //  -------------------------------------------------------------------
64 //-   LL       18  19 20  21  22 23 24 25 26    27     28
65 //-   part. 1:  d  d   t  t   K0 K0  d p  p      p      n
66 //-   part. 2:  d alfa t alfa K0 K0b t t alfa lambda lambda
67 //   NS=1 y/n:  -  -   -  -   -  -   - -  -      +      +
68 //  -------------------------------------------------------------------
69 //   NS=1  Square well potential,
70 //   NS=3  not used
71 //   NS=4  scattered wave approximated by the spherical wave,
72 //   NS=2  same as NS=4 but the approx. of equal emission times in PRF
73 //       not required (t=0 approx. used in all other cases).
74 //   Note: if NS=2,4, the B-S amplitude diverges at zero distance r* in
75 //       the two-particle c.m.s.; user can specify a cutoff AA in
76 //       SUBROUTINE FSIINI, for example:
77 //       IF(NS.EQ.2.OR.NS.EQ.4)AA=5.D0 !! in 1/GeV --> AA=1. fm
78 //  ------------------------------------------------------------------
79 //  ITEST=1 any values of parameters ICH, IQS, ISI, I3C are allowed
80 //          and should be given in data file <fn>
81 //  ITEST=0 physical values of these parameters are put automatically
82 //          in FSIINI (their values are not required in data file)
83 //=====================================================================
84 //  At the beginning of calculation user should call FSIINI,
85 //  which reads LL, NS, ITEST (and eventually ICH, IQS, ISI, I3C)
86 //  and initializes various parameters.
87 //  In particular the constants in
88 //    COMMON/FSI_CONS/PI,PI2,SPI,DR,W
89 //  may be useful for the user:
90 //   W=1/.1973D0    ! from fm to 1/GeV
91 //   PI=4*DATAN(1.D0)
92 //   PI2=2*PI
93 //   SPI=DSQRT(PI)
94 //   DR=180.D0/PI   ! from radian to degree
95 //    _______________________________________________________
96 //  !! |Important note: all real quantities are assumed REAL*8 | !!
97 //    -------------------------------------------------------
98 //  For each event user should fill in the following information
99 //  in COMMONs (all COMMONs in FSI calculation start with FSI_):
100 //  ...................................................................
101 //   COMMON/FSI_POC/AMN,AM1,AM2,CN,C1,C2,AC1,AC2
102 //  Only
103 //       AMN  = mass of the effective nucleus   [GeV/c**2]
104 //       CN   = charge of the effective nucleus [elem. charge units]
105 //  are required
106 //  ...................................................................
107 //   COMMON/FSI_MOM/P1X,P1Y,P1Z,E1,P1, !part. momenta in the rest frame 
108 //  1               P2X,P2Y,P2Z,E2,P2  !of effective nucleus (NRF)
109 //  Only the components
110 //                      PiX,PiY,PiZ  [GeV/c]
111 //  in NRF are required.
112 //  To make the corresponding Lorentz transformation user can use the
113 //  subroutines LTRAN and LTRANB
114 //  ...................................................................
115 //  COMMON/FSI_COOR/X1,Y1,Z1,T1,R1,     ! 4-coord. of emission
116 //  1               X2,Y2,Z2,T2,R2      ! points in NRF
117 //  The componets
118 //                     Xi,Yi,Zi  [fm]
119 //  and emission times
120 //                        Ti   [fm/c]
121 //  should be given in NRF with the origin assumed at the center
122 //  of the effective nucleus. If the effect of residual nucleus is
123 //  not calculated within FSIW, the NRF can be any fixed frame.
124 //  --------------------------------------------------------------------
125 //  Before calling FSIW the user must call
126 //   CALL LTRAN12
127 //  Besides Lorentz transformation to pair rest frame:
128 //  (p1-p2)/2 --> k* it also transforms 4-coordinates of
129 //  emission points from fm to 1/GeV and calculates Ei,Pi and Ri.
130 //  Note that |k*|=AK in COMMON/FSI_PRF/
131 //  --------------------------------------------------------------------
132 //  After making some additional filtering using k* (say k* < k*max)
133 //  or direction of vector k*,
134 //  user can finally call FSIW to calculate the FSI weights
135 //  to be used to construct the correlation function
136 //======================================================================
137
138
139 /*******************************************************************/
140 /******      ROUTINES    USED    FOR     COMMUNUCATION      ********/
141 /********************     WITH      FORTRAN     ********************/
142 /*******************************************************************/
143 #ifndef WIN32
144 # define led_bldata led_bldata_
145 # define fsiini fsiini_
146 # define ltran12 ltran12_
147 # define fsiw fsiw_
148 # define setpdist setpdist_
149 # define type_of_call
150 #else
151 # define led_bldata LED_BLDATA
152 # define fsiini FSIINI
153 # define ltran12 LTRAN12
154 # define fsiw FSIW
155 # define setpdist SETPDIST
156 # define type_of_call _stdcall
157 #endif
158 /****************************************************************/
159 extern "C" void type_of_call led_bldata(); 
160 extern "C" void type_of_call fsiini();
161 extern "C" void type_of_call ltran12();
162 extern "C" void type_of_call fsiw();
163 extern "C" void type_of_call setpdist(Double_t& r);
164 /**************************************************************/
165
166 #include "AliHBTPair.h"
167 #include "AliHBTParticle.h"
168 #include "WLedCOMMONS.h"
169 #include <TRandom.h>   
170 #include <TMath.h>     
171 #include <TPDGCode.h>
172
173
174 ClassImp(AliHBTLLWeights)  
175  
176 AliHBTLLWeights* AliHBTLLWeights::fgLLWeights = 0x0; 
177 const Double_t AliHBTLLWeights::fgkWcons = 1./0.1973;
178
179 AliHBTLLWeights::AliHBTLLWeights():
180  fTest(kTRUE),
181  fColoumbSwitch(kTRUE),
182  fQuantStatSwitch(kTRUE),
183  fStrongInterSwitch(kTRUE),
184  fColWithResidNuclSwitch(kFALSE),
185  fNuclMass(0.0),
186  fNuclCharge(0.0),
187  fRandomPosition(kFALSE),
188  fRadius(0.0),
189  fOneMinusLambda(0.0),
190  fPID1(0),
191  fPID2(0),
192  fSigma(0.0)
193 {
194 // Default Constructor 
195 }
196 /**************************************************************/
197
198 AliHBTLLWeights::AliHBTLLWeights(const AliHBTLLWeights &/*source*/):
199  AliHBTWeights(),
200  fTest(kTRUE),
201  fColoumbSwitch(kTRUE),
202  fQuantStatSwitch(kTRUE),
203  fStrongInterSwitch(kTRUE),
204  fColWithResidNuclSwitch(kFALSE),
205  fNuclMass(0.0),
206  fNuclCharge(0.0),
207  fRandomPosition(kFALSE),
208  fRadius(0.0),
209  fOneMinusLambda(0.0),
210  fPID1(0),
211  fPID2(0),
212  fSigma(0.0)
213 {
214   //Copy ctor needed by the coding conventions but not used
215   Fatal("AliHBTLLWeights","copy ctor not implemented");
216 }
217 /************************************************************/
218
219 AliHBTLLWeights& AliHBTLLWeights::operator=(const AliHBTLLWeights& /*source*/)
220 {
221   //Assignment operator needed by the coding conventions but not used
222   Fatal("AliHBTLLWeights","assignment operator not implemented");
223   return * this;
224 }
225 /************************************************************/
226
227 AliHBTLLWeights* AliHBTLLWeights::Instance()
228 {     
229 // returns instance of class 
230  if (fgLLWeights) 
231   {
232     return fgLLWeights;
233   } 
234  else 
235   {
236    fgLLWeights = new AliHBTLLWeights();            
237    return fgLLWeights; 
238   } 
239 }     
240 /************************************************************/
241
242 void AliHBTLLWeights::Set()
243 {
244  //sets this as weighitng class
245  Info("Set","Setting Lednicky-Lyuboshitz as Weighing Class");
246  
247  if ( fgWeights == 0x0 )  
248   {
249     fgWeights = AliHBTLLWeights::Instance();
250     return;
251   }  
252  if ( fgWeights == AliHBTLLWeights::Instance() ) return;
253  delete fgWeights;
254  fgWeights = AliHBTLLWeights::Instance();
255 }
256 /************************************************************/
257
258 Double_t AliHBTLLWeights::GetWeight(const AliHBTPair* partpair)
259 {
260 // calculates weight for a pair
261   static const Double_t kcmtofm = 1.e13;
262   static const Double_t kcmtoOneOverGeV = kcmtofm*fgkWcons;  
263   
264   AliHBTParticle *part1 = partpair->Particle1();
265   AliHBTParticle *part2 = partpair->Particle2();
266
267   if ( (part1 == 0x0) || (part2 == 0x0))
268    {
269      Error("GetWeight","Null particle pointer");
270      return 0.0;
271    }
272
273
274 //takes a lot of time
275   if ( (part1->Px() == part2->Px()) && 
276        (part1->Py() == part2->Py()) && 
277        (part1->Pz() == part2->Pz()) )
278    {
279      return 0.0;
280    }
281
282   if ((!fRandomPosition) && 
283       (part1->Vx()  == part2->Vx()) && 
284       (part1->Vy()  == part2->Vy()) && 
285       (part1->Vz()  == part2->Vz()) )
286     {        
287       return 0.0;
288     }
289
290   if(fOneMinusLambda)//implemetation of non-zero intetcept parameter 
291    {
292      if( gRandom->Rndm() < fOneMinusLambda ) return 1.0;
293    }
294     
295   FSI_MOM.P1X = part1->Px();
296   FSI_MOM.P1Y = part1->Py();
297   FSI_MOM.P1Z = part1->Pz();
298       
299   FSI_MOM.P2X = part2->Px();
300   FSI_MOM.P2Y = part2->Py();
301   FSI_MOM.P2Z = part2->Pz();
302
303   FSI_COOR.X1 = part1->Vx()*kcmtoOneOverGeV;
304   FSI_COOR.Y1 = part1->Vy()*kcmtoOneOverGeV;
305   FSI_COOR.Z1 = part1->Vz()*kcmtoOneOverGeV;
306   FSI_COOR.T1 = part1->T();
307
308   FSI_COOR.X2 = part2->Vx()*kcmtoOneOverGeV;
309   FSI_COOR.Y2 = part2->Vy()*kcmtoOneOverGeV;
310   FSI_COOR.Z2 = part2->Vz()*kcmtoOneOverGeV;
311   FSI_COOR.T2 = part2->T();
312   
313   ltran12();
314
315   //this must  be after ltran12 because it would overwrite what we set below
316   if (fRandomPosition)
317    {
318      Double_t rxcm = fSigma*gRandom->Gaus();
319      Double_t rycm = fSigma*gRandom->Gaus();
320      Double_t rzcm = fSigma*gRandom->Gaus();
321
322      FSI_PRF.X=rxcm*fgkWcons;
323      FSI_PRF.Y=rycm*fgkWcons;
324      FSI_PRF.Z=rzcm*fgkWcons;
325      FSI_PRF.T=0.;
326
327      Double_t rps=rxcm*rxcm+rycm*rycm+rzcm*rzcm;
328      Double_t rp=TMath::Sqrt(rps);
329      setpdist(rp);
330    }
331                
332   fsiw();
333   return LEDWEIGHT.WEIN;
334 }
335 /************************************************************/
336
337 void AliHBTLLWeights::Init()
338 {
339 //initial parameters of model
340
341   FSI_NS.NS = fApproximationModel;      
342   
343   LEDWEIGHT.ITEST = fTest;  
344   if(fTest)
345    {
346      FSI_NS.ICH = fColoumbSwitch;
347      FSI_NS.ISI = fStrongInterSwitch;
348      FSI_NS.IQS = fQuantStatSwitch;
349      FSI_NS.I3C = fColWithResidNuclSwitch;
350      LEDWEIGHT.IRANPOS = fRandomPosition;
351    }
352  
353   if ( (fPID1 == 0) || (fPID2 == 0) )
354    {
355      Fatal("Init","Particles types are not set");
356      return;//pro forma
357    }
358   FSI_NS.LL = GetPairCode(fPID1,fPID2);
359        
360   if (FSI_NS.LL == 0) 
361    {
362      Fatal("Init","Particles types are not supported");
363      return;//pro forma
364    }
365
366
367   TParticlePDG* tpart1 = TDatabasePDG::Instance()->GetParticle(fPID1);
368   if (tpart1 == 0x0)
369    {
370      Fatal("init","We can not find particle with ID=%d in PDG DataBase",fPID1);
371      return;
372    }
373       
374   FSI_POC.AM1=tpart1->Mass();
375   FSI_POC.C1=tpart1->Charge(); 
376
377   TParticlePDG* tpart2 = TDatabasePDG::Instance()->GetParticle(fPID2);
378 //lv
379   if (tpart2 == 0x0)
380    {
381      Fatal("init","We can not find particle with ID=%d in our DataBase",fPID2);
382      return;
383    }
384
385   FSI_POC.AM2=tpart2->Mass();
386   FSI_POC.C1=tpart2->Charge();
387
388   led_bldata();
389   fsiini();
390
391
392 //constants for radii simulation 
393
394   if(fRandomPosition)
395    {
396      fSigma =TMath::Sqrt(2.)*fRadius;     
397    } 
398
399 /************************************************************/
400
401 Int_t AliHBTLLWeights::GetPairCode(const AliHBTPair* partpair)
402 {
403 //returns Code corresponding to that pair
404  return GetPairCode(partpair->Particle1()->GetPdgCode(),partpair->Particle2()->GetPdgCode());
405 }
406 /************************************************************/
407
408 Int_t AliHBTLLWeights::GetPairCode(Int_t pid1,Int_t pid2)
409 {
410 // returns code corresponding to the pair of PIDs
411 //   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
412 //   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
413 //   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
414 //   NS=1 y/n:  +  +  +  +   +    -   -  -  -  -   -   -   -  -  -  -  -   -  -    -    -    -  -   - -  -      -      -
415
416 //alphas, deuterons and tyts are NOT supported here
417
418   Int_t chargefactor = 1;
419   Int_t hpid; //pid in higher row
420   Int_t lpid; //pid in lower row
421   Int_t code; //pairCode
422   
423   Bool_t swap;
424   
425 //determine the order of selcetion in switch  
426   if (TMath::Abs(pid1) < TMath::Abs(pid2) ) 
427    {
428     if (pid1<0) chargefactor=-1;
429     hpid=pid2*chargefactor;
430     lpid=pid1*chargefactor;
431     swap = kFALSE;
432    } 
433   else 
434    {
435     if (pid2<0) chargefactor=-1;
436     hpid=pid1*chargefactor;
437     lpid=pid2*chargefactor;
438     swap = kTRUE;
439    }
440
441 //mlv
442    hpid=pid1;
443    lpid=pid2;
444
445
446 //Determine the pair code
447   switch (hpid) //switch on first  particle id
448    {
449      case kNeutron:
450       switch (lpid)
451        {
452          case kNeutron: 
453            code = 1;  //neutron neutron
454            break;
455         
456          case kProton: 
457            code = 3;  //neutron proton
458            break;
459            
460          case kLambda0: 
461            code = 28;  //neutron lambda
462            break;
463            
464          default: 
465            return 0; //given pair not supported
466            break;
467        }
468       break;
469
470      case kProton:
471       switch (lpid)
472        {
473          case kProton:
474            code = 2; //proton proton
475            break;
476            
477          case kLambda0: 
478            code = 27;//proton lambda
479            break;
480            
481          default: 
482            return 0; //given pair not supported
483            break;
484            
485        }
486       break;
487
488      case kPiPlus:
489      
490       switch (lpid)
491        {
492          case kPiPlus:
493            code = 7; //piplus piplus
494            break;
495
496          case kPiMinus:
497            code = 5; //piplus piminus
498            break;
499         
500          case kKMinus:
501            code = 10; //piplus Kminus
502            break;
503
504          case kKPlus:
505            code = 11; //piplus Kplus
506            break;
507
508          case kProton:
509            code = 12; //piplus proton
510            chargefactor*=-1;
511            break;
512
513          default: 
514            return 0; //given pair not supported
515            break;
516        }
517       break;
518      case kPi0:
519       switch (lpid)
520        {
521          case kPi0:
522            code = 6;
523            break;
524            
525          default: 
526            return 0; //given pair not supported
527            break;
528        }
529       break;
530       
531      case kKPlus:
532       switch (lpid)
533        {
534          case kKMinus:
535            code = 14; //Kplus Kminus
536            break;
537
538          case kKPlus:
539            code = 15; //Kplus Kplus
540            break;
541
542          case kProton:
543            code = 16; //Kplus proton
544            break;
545            
546          default: 
547            return 0; //given pair not supported
548            break;
549        }
550       break;
551       
552      case kKMinus:
553       switch (lpid)
554        {
555          case kProton:
556            code = 17; //Kminus proton
557            chargefactor*=1;
558            break;
559            
560          default: 
561            return 0; //given pair not supported
562            break;
563        }
564       break;
565       
566      case kK0:
567       switch (lpid)
568        {
569          case kK0:
570            code = 2; //Kzero Kzero
571            break;
572          
573          case kK0Bar:
574            code = 17; //Kzero KzeroBar
575            break;
576
577          default: 
578            return 0; //given pair not supported
579            break;
580        }
581       break;
582
583      default: return 0;
584    }
585   return code;
586 }
587 /************************************************************/
588
589 void AliHBTLLWeights::SetTest(Bool_t rtest)
590 {
591   //Sets fTest member
592   fTest = rtest;
593
594 /************************************************************/
595
596 void AliHBTLLWeights::SetColoumb(Bool_t col)
597 {
598   // (ICH in fortran code) Coulomb interaction between the two particles ON (OFF)
599   fColoumbSwitch = col;
600 }
601 /************************************************************/
602
603 void AliHBTLLWeights::SetQuantumStatistics(Bool_t qss)
604 {
605   //IQS: quantum statistics for the two particles ON (OFF) 
606   //if non-identical particles automatically off
607   fQuantStatSwitch = qss;
608 }
609 /************************************************************/
610
611 void AliHBTLLWeights::SetStrongInterSwitch(Bool_t sis)
612 {
613   //ISI: strong interaction between the two particles ON (OFF)
614   fStrongInterSwitch = sis;
615 }
616 /************************************************************/
617
618 void AliHBTLLWeights::SetColWithResidNuclSwitch(Bool_t crn)
619 {
620   //I3C: Coulomb interaction with residual nucleus ON (OFF)  
621   fColWithResidNuclSwitch = crn;
622 }
623 /************************************************************/
624
625 void AliHBTLLWeights::SetApproxModel(Int_t ap)
626 {
627   //sets  Model of Approximation (NS in Fortran code)
628   fApproximationModel=ap;
629 }
630 /************************************************************/
631      
632 void AliHBTLLWeights::SetRandomPosition(Bool_t rp)
633
634  //ON=kTRUE(OFF=kFALSE)
635  //ON -- calculation of the Gauss source radii 
636  //if the generator don't allows the source generation (for example MeVSim)
637  //if ON the following parameters are requested:
638  fRandomPosition = rp;
639 }
640 /************************************************************/
641
642 void AliHBTLLWeights::SetR1dw(Double_t R)
643 {
644   //spherical source model radii
645   fRadius=R;
646 }
647 /************************************************************/
648
649 void AliHBTLLWeights::SetParticlesTypes(Int_t pid1, Int_t pid2)
650 {
651   //set AliRoot particles types   
652   fPID1 = pid1; 
653   fPID2 = pid2;
654 }
655 /************************************************************/
656     
657 void AliHBTLLWeights::SetNucleusCharge(Double_t ch)
658 {
659   // not used now  (see comments in fortran code)
660   fNuclCharge=ch;
661 }
662 /************************************************************/
663
664 void AliHBTLLWeights::SetNucleusMass(Double_t mass)
665 {
666   // (see comments in fortran code)
667   fNuclMass=mass;
668 }