]>
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 | ||
d5615b85 | 65 | void AliGenBox::Generate() { |
66 | // | |
67 | // Generate one trigger (fNpart particles) | |
68 | // | |
69 | GenerateN(1); | |
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | void AliGenBox::GenerateN(Int_t ntimes) | |
790bbabf | 74 | { |
75 | // | |
d5615b85 | 76 | // Generate ntimes triggers |
77 | // total ntimes*fNpart particles | |
790bbabf | 78 | // |
79 | ||
80 | Float_t polar[3]= {0,0,0}; | |
81 | // | |
82 | Float_t origin[3]; | |
21391258 | 83 | Float_t time; |
790bbabf | 84 | Float_t p[3]; |
85 | Int_t i, j, nt; | |
86 | Double_t pmom, theta, phi, pt; | |
565cc9c0 | 87 | Double_t y, mt; |
790bbabf | 88 | // |
89 | Float_t random[6]; | |
90 | // | |
91 | for (j=0;j<3;j++) origin[j]=fOrigin[j]; | |
21391258 | 92 | time = fTimeOrigin; |
aee8290b | 93 | if(fVertexSmear==kPerEvent) { |
c8f7f6f9 | 94 | Vertex(); |
95 | for (j=0;j<3;j++) origin[j]=fVertex[j]; | |
21391258 | 96 | time = fTime; |
790bbabf | 97 | } |
c8f7f6f9 | 98 | |
565cc9c0 | 99 | Double_t m = TDatabasePDG::Instance()->GetParticle(fIpart)->Mass(); |
100 | ||
d5615b85 | 101 | Int_t mult = fNpart*ntimes; |
102 | for(i=0;i<mult;i++) { | |
65fb704d | 103 | Rndm(random,3); |
898bb7f8 | 104 | |
565cc9c0 | 105 | if (TestBit(kYRange)) { |
106 | y = fYMin+random[0]*(fYMax-fYMin); | |
107 | ||
108 | if(TestBit(kMomentumRange)) { | |
109 | pmom=fPMin+random[1]*(fPMax-fPMin); | |
110 | mt = TMath::Sqrt(pmom*pmom+m*m)/TMath::CosH(y); | |
111 | pt = TMath::Sqrt(mt*mt - m*m); | |
112 | } else { | |
113 | pt=fPtMin+random[1]*(fPtMax-fPtMin); | |
114 | mt=TMath::Sqrt(pt*pt+m*m); | |
115 | } | |
116 | ||
117 | phi=fPhiMin+random[2]*(fPhiMax-fPhiMin); | |
118 | p[0] = pt*TMath::Cos(phi); | |
119 | p[1] = pt*TMath::Sin(phi); | |
120 | p[2] = mt*TMath::SinH(y); | |
790bbabf | 121 | } else { |
565cc9c0 | 122 | if (TestBit(kThetaRange)) { |
123 | theta = fThetaMin+random[0]*(fThetaMax-fThetaMin); | |
124 | } else { | |
125 | Float_t eta = fEtaMin+random[0]*(fEtaMax-fEtaMin); | |
126 | theta = 2. * TMath::ATan(TMath::Exp(-eta)); | |
127 | } | |
128 | ||
129 | if(TestBit(kMomentumRange)) { | |
130 | pmom=fPMin+random[1]*(fPMax-fPMin); | |
131 | pt=pmom*TMath::Sin(theta); | |
132 | } else { | |
790bbabf | 133 | |
565cc9c0 | 134 | pt=fPtMin+random[1]*(fPtMax-fPtMin); |
135 | pmom=pt/TMath::Sin(theta); | |
136 | } | |
898bb7f8 | 137 | |
565cc9c0 | 138 | phi=fPhiMin+random[2]*(fPhiMax-fPhiMin); |
139 | p[0] = pt*TMath::Cos(phi); | |
140 | p[1] = pt*TMath::Sin(phi); | |
141 | p[2] = pmom*TMath::Cos(theta); | |
142 | } | |
790bbabf | 143 | |
aee8290b | 144 | if(fVertexSmear==kPerTrack) { |
65fb704d | 145 | Rndm(random,6); |
790bbabf | 146 | for (j=0;j<3;j++) { |
147 | origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())* | |
148 | TMath::Sqrt(-2*TMath::Log(random[2*j+1])); | |
149 | } | |
21391258 | 150 | |
151 | Rndm(random,2); | |
152 | time = fTimeOrigin + fOsigma[2]/TMath::Ccgs()* | |
153 | TMath::Cos(2*random[0]*TMath::Pi())* | |
154 | TMath::Sqrt(-2*TMath::Log(random[1])); | |
790bbabf | 155 | } |
21391258 | 156 | PushTrack(fTrackIt,-1,fIpart,p,origin,polar,time,kPPrimary,nt); |
790bbabf | 157 | } |
42cca6d4 | 158 | |
159 | AliGenEventHeader* header = new AliGenEventHeader("BOX"); | |
160 | header->SetPrimaryVertex(fVertex); | |
d5615b85 | 161 | header->SetNProduced(mult); |
21391258 | 162 | header->SetInteractionTime(fTime); |
7cf36cae | 163 | |
164 | // Passes header either to the container or to gAlice | |
165 | if (fContainer) { | |
e052713d | 166 | header->SetName(fName); |
7cf36cae | 167 | fContainer->AddHeader(header); |
168 | } else { | |
169 | gAlice->SetGenEventHeader(header); | |
170 | } | |
790bbabf | 171 | } |
172 | ||
173 | //_____________________________________________________________________________ | |
174 | ||
175 | void AliGenBox::Init() | |
176 | { | |
177 | // Initialisation, check consistency of selected ranges | |
178 | if(TestBit(kPtRange)&&TestBit(kMomentumRange)) | |
179 | Fatal("Init","You should not set the momentum range and the pt range!\n"); | |
180 | if((!TestBit(kPtRange))&&(!TestBit(kMomentumRange))) | |
181 | Fatal("Init","You should set either the momentum or the pt range!\n"); | |
565cc9c0 | 182 | if((TestBit(kYRange)&&TestBit(kThetaRange)) || (TestBit(kYRange)&&TestBit(kEtaRange)) || (TestBit(kEtaRange)&&TestBit(kThetaRange)) ) |
183 | Fatal("Init","You should only set the range of one of these variables: y, eta or theta\n"); | |
184 | if((!TestBit(kYRange)) && (!TestBit(kEtaRange)) && (!TestBit(kThetaRange)) ) | |
185 | Fatal("Init","You should set the range of one of these variables: y, eta or theta\n"); | |
790bbabf | 186 | } |
187 |