]>
Commit | Line | Data |
---|---|---|
790bbabf | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
88cb7938 | 16 | /* $Id$ */ |
790bbabf | 17 | |
790bbabf | 18 | |
675e9664 | 19 | // Generator for particles in a preset |
20 | // kinematic range (flat distribution) | |
21 | // Note that for a given theta pt and p are not independent | |
22 | // Range for only one variable (pt or p) should be given. | |
675e9664 | 23 | // Comments and suggestions: andreas.morsch@cern.ch |
0af12c00 | 24 | |
790bbabf | 25 | |
116cbefd | 26 | #include "TPDGCode.h" |
27 | ||
28 | #include "AliConst.h" | |
790bbabf | 29 | #include "AliGenBox.h" |
30 | #include "AliRun.h" | |
42cca6d4 | 31 | #include "AliGenEventHeader.h" |
565cc9c0 | 32 | #include "TDatabasePDG.h" |
33 | #include "AliPDG.h" | |
790bbabf | 34 | |
35 | ClassImp(AliGenBox) | |
36 | ||
37 | //_____________________________________________________________________________ | |
38 | AliGenBox::AliGenBox() | |
1c56e311 | 39 | :AliGenerator(), |
a8c51211 | 40 | fIpart(0), |
41 | fEtaMin(0), | |
42 | fEtaMax(0) | |
790bbabf | 43 | { |
44 | // | |
45 | // Default constructor | |
46 | // | |
790bbabf | 47 | } |
48 | ||
49 | //_____________________________________________________________________________ | |
50 | AliGenBox::AliGenBox(Int_t npart) | |
1c56e311 | 51 | :AliGenerator(npart), |
a8c51211 | 52 | fIpart(kProton), |
53 | fEtaMin(0), | |
54 | fEtaMax(0) | |
790bbabf | 55 | { |
56 | // | |
57 | // Standard constructor | |
58 | // | |
8b31bfac | 59 | fName = "Box"; |
60 | fTitle = "Box particle generator"; | |
790bbabf | 61 | } |
62 | ||
63 | //_____________________________________________________________________________ | |
64 | ||
65 | void AliGenBox::Generate() | |
66 | { | |
67 | // | |
68 | // Generate one trigger | |
69 | // | |
70 | ||
71 | Float_t polar[3]= {0,0,0}; | |
72 | // | |
73 | Float_t origin[3]; | |
21391258 | 74 | Float_t time; |
790bbabf | 75 | Float_t p[3]; |
76 | Int_t i, j, nt; | |
77 | Double_t pmom, theta, phi, pt; | |
565cc9c0 | 78 | Double_t y, mt; |
790bbabf | 79 | // |
80 | Float_t random[6]; | |
81 | // | |
82 | for (j=0;j<3;j++) origin[j]=fOrigin[j]; | |
21391258 | 83 | time = fTimeOrigin; |
aee8290b | 84 | if(fVertexSmear==kPerEvent) { |
c8f7f6f9 | 85 | Vertex(); |
86 | for (j=0;j<3;j++) origin[j]=fVertex[j]; | |
21391258 | 87 | time = fTime; |
790bbabf | 88 | } |
c8f7f6f9 | 89 | |
565cc9c0 | 90 | Double_t m = TDatabasePDG::Instance()->GetParticle(fIpart)->Mass(); |
91 | ||
790bbabf | 92 | for(i=0;i<fNpart;i++) { |
65fb704d | 93 | Rndm(random,3); |
898bb7f8 | 94 | |
565cc9c0 | 95 | if (TestBit(kYRange)) { |
96 | y = fYMin+random[0]*(fYMax-fYMin); | |
97 | ||
98 | if(TestBit(kMomentumRange)) { | |
99 | pmom=fPMin+random[1]*(fPMax-fPMin); | |
100 | mt = TMath::Sqrt(pmom*pmom+m*m)/TMath::CosH(y); | |
101 | pt = TMath::Sqrt(mt*mt - m*m); | |
102 | } else { | |
103 | pt=fPtMin+random[1]*(fPtMax-fPtMin); | |
104 | mt=TMath::Sqrt(pt*pt+m*m); | |
105 | } | |
106 | ||
107 | phi=fPhiMin+random[2]*(fPhiMax-fPhiMin); | |
108 | p[0] = pt*TMath::Cos(phi); | |
109 | p[1] = pt*TMath::Sin(phi); | |
110 | p[2] = mt*TMath::SinH(y); | |
790bbabf | 111 | } else { |
565cc9c0 | 112 | if (TestBit(kThetaRange)) { |
113 | theta = fThetaMin+random[0]*(fThetaMax-fThetaMin); | |
114 | } else { | |
115 | Float_t eta = fEtaMin+random[0]*(fEtaMax-fEtaMin); | |
116 | theta = 2. * TMath::ATan(TMath::Exp(-eta)); | |
117 | } | |
118 | ||
119 | if(TestBit(kMomentumRange)) { | |
120 | pmom=fPMin+random[1]*(fPMax-fPMin); | |
121 | pt=pmom*TMath::Sin(theta); | |
122 | } else { | |
790bbabf | 123 | |
565cc9c0 | 124 | pt=fPtMin+random[1]*(fPtMax-fPtMin); |
125 | pmom=pt/TMath::Sin(theta); | |
126 | } | |
898bb7f8 | 127 | |
565cc9c0 | 128 | phi=fPhiMin+random[2]*(fPhiMax-fPhiMin); |
129 | p[0] = pt*TMath::Cos(phi); | |
130 | p[1] = pt*TMath::Sin(phi); | |
131 | p[2] = pmom*TMath::Cos(theta); | |
132 | } | |
790bbabf | 133 | |
aee8290b | 134 | if(fVertexSmear==kPerTrack) { |
65fb704d | 135 | Rndm(random,6); |
790bbabf | 136 | for (j=0;j<3;j++) { |
137 | origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())* | |
138 | TMath::Sqrt(-2*TMath::Log(random[2*j+1])); | |
139 | } | |
21391258 | 140 | |
141 | Rndm(random,2); | |
142 | time = fTimeOrigin + fOsigma[2]/TMath::Ccgs()* | |
143 | TMath::Cos(2*random[0]*TMath::Pi())* | |
144 | TMath::Sqrt(-2*TMath::Log(random[1])); | |
790bbabf | 145 | } |
21391258 | 146 | PushTrack(fTrackIt,-1,fIpart,p,origin,polar,time,kPPrimary,nt); |
790bbabf | 147 | } |
42cca6d4 | 148 | |
149 | AliGenEventHeader* header = new AliGenEventHeader("BOX"); | |
150 | header->SetPrimaryVertex(fVertex); | |
7cf36cae | 151 | header->SetNProduced(fNpart); |
21391258 | 152 | header->SetInteractionTime(fTime); |
7cf36cae | 153 | |
154 | // Passes header either to the container or to gAlice | |
155 | if (fContainer) { | |
156 | fContainer->AddHeader(header); | |
157 | } else { | |
158 | gAlice->SetGenEventHeader(header); | |
159 | } | |
790bbabf | 160 | } |
161 | ||
162 | //_____________________________________________________________________________ | |
163 | ||
164 | void AliGenBox::Init() | |
165 | { | |
166 | // Initialisation, check consistency of selected ranges | |
167 | if(TestBit(kPtRange)&&TestBit(kMomentumRange)) | |
168 | Fatal("Init","You should not set the momentum range and the pt range!\n"); | |
169 | if((!TestBit(kPtRange))&&(!TestBit(kMomentumRange))) | |
170 | Fatal("Init","You should set either the momentum or the pt range!\n"); | |
565cc9c0 | 171 | if((TestBit(kYRange)&&TestBit(kThetaRange)) || (TestBit(kYRange)&&TestBit(kEtaRange)) || (TestBit(kEtaRange)&&TestBit(kThetaRange)) ) |
172 | Fatal("Init","You should only set the range of one of these variables: y, eta or theta\n"); | |
173 | if((!TestBit(kYRange)) && (!TestBit(kEtaRange)) && (!TestBit(kThetaRange)) ) | |
174 | Fatal("Init","You should set the range of one of these variables: y, eta or theta\n"); | |
175 | ||
176 | AliPDG::AddParticlesToPdgDataBase(); | |
790bbabf | 177 | } |
178 |