1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////////
18 // AliGlauberNucleus implementation
19 // support class for Glauber MC
21 // origin: PHOBOS experiment
22 // alification: Mikolaj Krzewicki, Nikhef, mikolaj.krzewicki@cern.ch
24 ////////////////////////////////////////////////////////////////////////////////
26 #include <Riostream.h>
30 #include <TObjArray.h>
33 #include "AliGlauberNucleon.h"
34 #include "AliGlauberNucleus.h"
36 ClassImp(AliGlauberNucleus)
38 //______________________________________________________________________________
39 AliGlauberNucleus::AliGlauberNucleus(Option_t* iname, Int_t iN, Double_t iR, Double_t ia, Double_t iw, TF1* ifunc) :
40 fN(iN),fR(iR),fA(ia),fW(iw),fMinDist(-1),
41 fF(0),fTrials(0),fFunction(ifunc),
45 cout << "Setting up nucleus " << iname << endl;
50 //______________________________________________________________________________
51 AliGlauberNucleus::~AliGlauberNucleus()
59 //______________________________________________________________________________
60 void AliGlauberNucleus::Draw(Double_t xs, Int_t col)
62 Double_t r = 0.5*sqrt(xs/TMath::Pi()/10.);
68 for (Int_t i = 0;i<fNucleons->GetEntries();++i) {
69 AliGlauberNucleon* gn = (AliGlauberNucleon*) fNucleons->At(i);
71 if (gn->IsSpectator()) e.SetLineStyle(3);
72 e.DrawEllipse(gn->GetX(),gn->GetY(),r,r,0,360,0,"");
76 //______________________________________________________________________________
77 void AliGlauberNucleus::Lookup(Option_t* name)
81 if (TString(name) == "p") {fN = 1; fR = 0.6; fA = 0; fW = 0; fF = 0;}
82 else if (TString(name) == "d") {fN = 2; fR = 0.01; fA = 0.5882; fW = 0; fF = 1;}
83 else if (TString(name) == "dh") {fN = 2; fR = 0.01; fA = 0.5882; fW = 0; fF = 3;}
84 else if (TString(name) == "dhh") {fN = 2; fR = 0.01; fA = 0.5882; fW = 0; fF = 4;}
85 else if (TString(name) == "O") {fN = 16; fR = 2.608; fA = 0.513; fW = -0.051; fF = 1;}
86 else if (TString(name) == "Si") {fN = 28; fR = 3.34; fA = 0.580; fW = -0.233; fF = 1;}
87 else if (TString(name) == "S") {fN = 32; fR = 2.54; fA = 2.191; fW = 0.16; fF = 2;}
88 else if (TString(name) == "Ca") {fN = 40; fR = 3.766; fA = 0.586; fW = -0.161; fF = 1;}
89 else if (TString(name) == "Ni") {fN = 58; fR = 4.309; fA = 0.517; fW = -0.1308; fF = 1;}
90 else if (TString(name) == "Cu") {fN = 63; fR = 4.2; fA = 0.596; fW = 0; fF = 1;}
91 else if (TString(name) == "W") {fN = 186; fR = 6.58; fA = 0.480; fW = 0; fF = 1;}
92 else if (TString(name) == "Au") {fN = 197; fR = 6.38; fA = 0.535; fW = 0; fF = 1;}
93 else if (TString(name) == "Pb") {fN = 208; fR = 6.62; fA = 0.546; fW = 0; fF = 1;}
94 else if (TString(name) == "U") {fN = 238; fR = 6.81; fA = 0.6; fW = 0; fF = 1;}
96 cout << "Could not find nucleus " << name << endl;
103 fFunction = new TF1("prot","x*x*exp(-x/[0])",0,10);
104 fFunction->SetParameter(0,fR);
107 fFunction = new TF1(name,"x*x*(1+[2]*(x/[0])**2)/(1+exp((x-[0])/[1]))",0,15);
108 fFunction->SetParameters(fR,fA,fW);
111 fFunction = new TF1("3pg","x*x*(1+[2]*(x/[0])**2)/(1+exp((x**2-[0]**2)/[1]**2))",0,15);
112 fFunction->SetParameters(fR,fA,fW);
115 fFunction = new TF1("f3","x*x*([0]*[1]*([0]+[1]))/(2*pi*(pow([0]-[1],2)))*pow((exp(-[0]*x)-exp(-[1]*x))/x,2)",0,10);
116 fFunction->SetParameters(1/4.38,1/.85);
118 case 4: // Hulthen HIJING
119 fFunction = new TF1("f4","x*x*([0]*[1]*([0]+[1]))/(2*pi*(pow([0]-[1],2)))*pow((exp(-[0]*x)-exp(-[1]*x))/x,2)",0,20);
120 fFunction->SetParameters(2/4.38,2/.85);
123 cerr << "Could not find function type " << fF << endl;
128 //______________________________________________________________________________
129 void AliGlauberNucleus::SetR(Double_t ir)
135 fFunction->SetParameter(0,fR);
138 fFunction->SetParameter(0,fR);
141 fFunction->SetParameter(0,fR);
146 //______________________________________________________________________________
147 void AliGlauberNucleus::SetA(Double_t ia)
155 fFunction->SetParameter(1,fA);
158 fFunction->SetParameter(1,fA);
163 //______________________________________________________________________________
164 void AliGlauberNucleus::SetW(Double_t iw)
172 fFunction->SetParameter(2,fW);
175 fFunction->SetParameter(2,fW);
180 //______________________________________________________________________________
181 void AliGlauberNucleus::ThrowNucleons(Double_t xshift)
184 fNucleons=new TObjArray(fN);
185 fNucleons->SetOwner();
186 for(Int_t i=0;i<fN;i++) {
187 AliGlauberNucleon *nucleon=new AliGlauberNucleon();
188 fNucleons->Add(nucleon);
198 Bool_t hulthen = (TString(GetName())=="dh");
199 if (fN==2 && hulthen) { //special treatmeant for Hulten
201 Double_t r = fFunction->GetRandom()/2;
202 Double_t phi = gRandom->Rndm() * 2 * TMath::Pi() ;
203 Double_t ctheta = 2*gRandom->Rndm() - 1 ;
204 Double_t stheta = sqrt(1-ctheta*ctheta);
206 AliGlauberNucleon *nucleon1=(AliGlauberNucleon*)(fNucleons->At(0));
207 AliGlauberNucleon *nucleon2=(AliGlauberNucleon*)(fNucleons->At(1));
209 nucleon1->SetXYZ(r * stheta * cos(phi) + xshift,
210 r * stheta * sin(phi),
213 nucleon2->SetXYZ(-nucleon1->GetX() + 2*xshift,
220 for (Int_t i = 0; i<fN; i++) {
221 AliGlauberNucleon *nucleon=(AliGlauberNucleon*)(fNucleons->At(i));
225 Double_t r = fFunction->GetRandom();
226 Double_t phi = gRandom->Rndm() * 2 * TMath::Pi() ;
227 Double_t ctheta = 2*gRandom->Rndm() - 1 ;
228 Double_t stheta = TMath::Sqrt(1-ctheta*ctheta);
229 Double_t x = r * stheta * cos(phi) + xshift;
230 Double_t y = r * stheta * sin(phi);
231 Double_t z = r * ctheta;
232 nucleon->SetXYZ(x,y,z);
233 if(fMinDist<0) break;
235 for (Int_t j = 0; j<i; j++) {
236 AliGlauberNucleon *other=(AliGlauberNucleon*)fNucleons->At(j);
237 Double_t xo=other->GetX();
238 Double_t yo=other->GetY();
239 Double_t zo=other->GetZ();
240 Double_t dist = TMath::Sqrt((x-xo)*(x-xo)+
249 if (test) break; //found nucleuon outside of mindist
252 sumx += nucleon->GetX();
253 sumy += nucleon->GetY();
254 sumz += nucleon->GetZ();
257 if(1) { // set the centre-of-mass to be at zero (+xshift)
261 for (Int_t i = 0; i<fN; i++) {
262 AliGlauberNucleon *nucleon=(AliGlauberNucleon*)(fNucleons->At(i));
263 nucleon->SetXYZ(nucleon->GetX()-sumx-xshift,
264 nucleon->GetY()-sumy,
265 nucleon->GetZ()-sumz);