StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StGlauberUtilities.cxx
1 /****************************************************************************************************
2  * $Id: StGlauberUtilities.cxx,v 1.2 2012/04/25 04:42:37 hmasui Exp $
3  * $Log: StGlauberUtilities.cxx,v $
4  * Revision 1.2 2012/04/25 04:42:37 hmasui
5  * Moved several functions from StFastGlauberMcMaker. Added namespace GlauberUtilities
6  *
7  *
8 ****************************************************************************************************/
9 //----------------------------------------------------------------------------------------------------
10 // Random number generators for
11 // - impact parameter (dN/db = b) in 0 < r < 20 fm
12 // - radius from several different density profile
13 // - phi & theta angles for nucleons
14 //----------------------------------------------------------------------------------------------------
15 
16 #include <assert.h>
17 
18 #include "TClass.h"
19 #include "TError.h"
20 #include "TF1.h"
21 #include "TMath.h"
22 #include "TRandom.h"
23 #include "TRandom3.h"
24 
25 #include "StMessMgr.h"
26 #include "StGlauberUtilities.h"
27 
28 ClassImp(StGlauberUtilities)
29 
30 namespace GlauberUtilities {
31  //____________________________________________________________________________________________________
32  // Woods-saxon density profile (1D for spherical nuclei)
33  Double_t WoodsSaxon(Double_t* x, Double_t* par)
34  {
35  const Double_t r = x[0] ;
36  const Double_t R = par[0] ;
37  const Double_t d = par[1] ;
38 
39  return r*r/(1.0+TMath::Exp((r-R)/d)) ;
40  }
41 
42  //____________________________________________________________________________________________________
43  // Woods-saxon density profile (2D for deformed nuclei)
44  Double_t WoodsSaxon2D(Double_t* x, Double_t* par)
45  {
46  const Double_t r = x[0] ;
47  const Double_t cosTheta = x[1] ;
48  const Double_t R0 = par[0] ;
49  const Double_t d = par[1] ;
50  const Double_t beta2 = par[2] ; // Parameter for deformation (beta2=0 --> Standard woods-saxon density)
51  const Double_t beta4 = par[3] ; // Parameter for deformation (beta4=0 --> Standard woods-saxon density)
52  const Double_t beta6 = 0.0 ;
53 
54  const Double_t cosTheta2 = cosTheta * cosTheta ;
55  const Double_t cosTheta4 = cosTheta2 * cosTheta2 ;
56 
57  // Spherical harmonics (l=2, m=0) Y20(theta) = 1/4 sqrt(5/pi) * (3cos^2(theta) - 1)
58  const Double_t Y20 = TMath::Sqrt(5.0/TMath::Pi()) / 4.0 * (3.0 * cosTheta2 - 1.0 ) ;
59  const Double_t Y40 = TMath::Sqrt(1.0/TMath::Pi()) * 3.0 / 16.0 * (35.0*cosTheta4 - 30.0*cosTheta2 + 3.0);
60  // const Double_t Y60 = TMath::Sqrt(13.0/TMath::Pi()) / 32.0 * (231.0*cosTheta4*cosTheta2 - 315.0*cosTheta4 + 105.0*cosTheta2 - 5.0) ;
61  const Double_t Y60 = 0.0 ;
62 
63  const Double_t R = R0 * (1.0 + beta2 * Y20 + beta4 * Y40 + beta6 * Y60 ) ;
64 
65  return r*r/(1.0+TMath::Exp((r-R)/d)) ;
66  }
67 
68  //____________________________________________________________________________________________________
69  // Step function
70  Double_t StepFunction(Double_t* x, Double_t* par)
71  {
72  Double_t dx = x[0] ;
73  Double_t dy = x[1] ;
74  Double_t dz = x[2] ;
75  Double_t position = TMath::Sqrt(dx*dx + dy*dy + dz*dz);
76  Double_t sigma = par[0] ;
77 
78  const Double_t pi = TMath::Pi() ;
79  const Double_t r2 = sigma/pi ;
80  const Double_t r = TMath::Sqrt(r2);
81  // return (r - position < 0.0) ? 0.0 : 1.0 ;
82 
83  const Double_t V = 4.0*pi*r2*r/3.0 ;
84  return (r - position < 0.0) ? 0.0 : 1.0/V ;
85  }
86 
87  //____________________________________________________________________________________________________
88  // Gaussian function
89  Double_t Gaussian(Double_t* x, Double_t* par)
90  {
91  Double_t dx = x[0] ;
92  Double_t dy = x[1] ;
93  Double_t dz = x[2] ;
94  Double_t r = TMath::Sqrt(dx*dx + dy*dy + dz*dz) ;
95  Double_t sigma2 = par[0]*par[0] ;
96  const Double_t norm = 2.0*TMath::Pi()*sigma2 ;
97 
98  return 1.0/TMath::Power(norm, 3.0/2.0) * TMath::Exp(-0.5*r*r/sigma2);
99  }
100 }
101 
102  StGlauberUtilities* StGlauberUtilities::mInstance = 0 ;
103  const UShort_t StGlauberUtilities::mDebugLevel = 20 ;
104 
105 //____________________________________________________________________________________________________
106 // Get singleton
107 StGlauberUtilities* StGlauberUtilities::instance()
108 {
109  if(!mInstance){
110  mInstance = new StGlauberUtilities() ;
111  }
112 
113  return mInstance ;
114 }
115 
116 //____________________________________________________________________________________________________
117 // Default constructor
118 StGlauberUtilities::StGlauberUtilities()
119 {
120  LOG_INFO << "StGlauberUtilities Initialize StGlauberUtilities" << endm;
121 
123  mRandom = new TRandom3() ;
124  mRandom->SetSeed(0);
125  LOG_INFO << "StGlauberUtilities Set random number seed = " << mRandom->GetSeed() << endm;
126 
128  mImpactParameter = new TF1("mImpactParameter", "x", 0, 20.0);
129  LOG_INFO << "StGlauberUtilities Set impact parameter distributions: "
130  << mImpactParameter->GetXmin()
131  << " < b < "
132  << mImpactParameter->GetXmax()
133  << " fm" << endm;
134 
135  mDebug = 0 ;
136 }
137 
138 //____________________________________________________________________________________________________
139 // Default destructor
140 StGlauberUtilities::~StGlauberUtilities()
141 {
142 }
143 
144 //____________________________________________________________________________________________________
146 {
149  if(!mImpactParameter){
150  Error("StGlauberUtilities::GetImpactParameter", "cannot find impact parameter distribution (TF1). abort");
151  assert(0);
152  }
153  const Double_t b = mImpactParameter->GetRandom() ;
154 
155  if( mDebug > 0 ){
156  LOG_INFO << "StGlauberUtilities::GetImpactParameter Generate random b = "
157  << b
158  << " (fm)" << endm;
159  }
160 
161  return b ;
162 }
163 
164 //____________________________________________________________________________________________________
166 {
167  return mImpactParameter->GetXmax() ;
168 }
169 
170 //____________________________________________________________________________________________________
172 {
175  const Double_t theta = TMath::ACos(mRandom->Rndm()*2.0-1.0);
176 
177  if( mDebug > 0 ){
178  LOG_INFO << "StGlauberUtilities::GetTheta Generate random theta = " << theta << endm;
179  }
180 
181  return theta ;
182 }
183 
184 //____________________________________________________________________________________________________
186 {
188  const Double_t phi = mRandom->Rndm()*TMath::Pi()*2.0 - TMath::Pi() ;
189 
190  if( mDebug > 0 ){
191  LOG_INFO << "StGlauberUtilities::GetPhi Generate random phi = " << phi << endm;
192  }
193 
194  return phi ;
195 }
196 
197 //____________________________________________________________________________________________________
199 {
201  return mRandom->Rndm() ;
202 }
203 //____________________________________________________________________________________________________
205 {
207  return mRandom->Uniform(0,2);
208 }
209 
210 //____________________________________________________________________________________________________
211 void StGlauberUtilities::SetDebug(const UInt_t debug)
212 {
213  mDebug = debug ;
214  LOG_INFO << "StGlauberUtilities::SetDebug Set debug level = " << mDebug << endm;
215 }
216 
Definition: FJcore.h:367
Double_t GetTheta() const
Get theta (polar angle)
Double_t GetMaximumImpactParameter() const
Get maximum impact parameter.
Double_t GetImpactParameter() const
Default destructor.
Double_t GetUniform() const
Get uniform distribution in 0 &lt; x &lt; 1.
void SetDebug(const UInt_t debug)
Set debug level.
Double_t GetUniform2() const
Double_t GetPhi() const
Get phi (azimuthal angle)