]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - EVGEN/AliGenBox.cxx
add GetNAcceptedClusters() function
[u/mrichter/AliRoot.git] / EVGEN / AliGenBox.cxx
... / ...
CommitLineData
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
16/* $Id$ */
17
18
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.
23// Comments and suggestions: andreas.morsch@cern.ch
24
25
26#include "TPDGCode.h"
27
28#include "AliConst.h"
29#include "AliGenBox.h"
30#include "AliRun.h"
31#include "AliGenEventHeader.h"
32#include "TDatabasePDG.h"
33#include "AliPDG.h"
34
35ClassImp(AliGenBox)
36
37//_____________________________________________________________________________
38AliGenBox::AliGenBox()
39 :AliGenerator(),
40 fIpart(0),
41 fEtaMin(0),
42 fEtaMax(0)
43{
44 //
45 // Default constructor
46 //
47}
48
49//_____________________________________________________________________________
50AliGenBox::AliGenBox(Int_t npart)
51 :AliGenerator(npart),
52 fIpart(kProton),
53 fEtaMin(0),
54 fEtaMax(0)
55{
56 //
57 // Standard constructor
58 //
59 fName = "Box";
60 fTitle = "Box particle generator";
61}
62
63//_____________________________________________________________________________
64
65void AliGenBox::Generate() {
66 //
67 // Generate one trigger (fNpart particles)
68 //
69 GenerateN(1);
70}
71
72//_____________________________________________________________________________
73void AliGenBox::GenerateN(Int_t ntimes)
74{
75 //
76 // Generate ntimes triggers
77 // total ntimes*fNpart particles
78 //
79
80 Float_t polar[3]= {0,0,0};
81 //
82 Float_t origin[3];
83 Float_t time;
84 Float_t p[3];
85 Int_t i, j, nt;
86 Double_t pmom, theta, phi, pt;
87 Double_t y, mt;
88 //
89 Float_t random[6];
90 //
91 for (j=0;j<3;j++) origin[j]=fOrigin[j];
92 time = fTimeOrigin;
93 if(fVertexSmear==kPerEvent) {
94 Vertex();
95 for (j=0;j<3;j++) origin[j]=fVertex[j];
96 time = fTime;
97 }
98
99 Double_t m = TDatabasePDG::Instance()->GetParticle(fIpart)->Mass();
100
101 Int_t mult = fNpart*ntimes;
102 for(i=0;i<mult;i++) {
103 Rndm(random,3);
104
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);
121 } else {
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 {
133
134 pt=fPtMin+random[1]*(fPtMax-fPtMin);
135 pmom=pt/TMath::Sin(theta);
136 }
137
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 }
143
144 if(fVertexSmear==kPerTrack) {
145 Rndm(random,6);
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 }
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]));
155 }
156 PushTrack(fTrackIt,-1,fIpart,p,origin,polar,time,kPPrimary,nt, 1., 1);
157 }
158
159 AliGenEventHeader* header = new AliGenEventHeader("BOX");
160 header->SetPrimaryVertex(fVertex);
161 header->SetNProduced(mult);
162 header->SetInteractionTime(fTime);
163
164 // Passes header either to the container or to gAlice
165 if (fContainer) {
166 header->SetName(fName);
167 fContainer->AddHeader(header);
168 } else {
169 gAlice->SetGenEventHeader(header);
170 }
171}
172
173//_____________________________________________________________________________
174
175void 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");
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");
186}
187