]>
Commit | Line | Data |
---|---|---|
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 | ||
33 | ClassImp(AliGenBox) | |
34 | ||
35 | //_____________________________________________________________________________ | |
36 | AliGenBox::AliGenBox() | |
37 | :AliGenerator(), | |
38 | fIpart(0), | |
39 | fEtaMin(0), | |
40 | fEtaMax(0) | |
41 | { | |
42 | // | |
43 | // Default constructor | |
44 | // | |
45 | } | |
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliGenBox::AliGenBox(Int_t npart) | |
49 | :AliGenerator(npart), | |
50 | fIpart(kProton), | |
51 | fEtaMin(0), | |
52 | fEtaMax(0) | |
53 | { | |
54 | // | |
55 | // Standard constructor | |
56 | // | |
57 | fName = "Box"; | |
58 | fTitle = "Box particle generator"; | |
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | ||
63 | void AliGenBox::Generate() | |
64 | { | |
65 | // | |
66 | // Generate one trigger | |
67 | // | |
68 | ||
69 | Float_t polar[3]= {0,0,0}; | |
70 | // | |
71 | Float_t origin[3]; | |
72 | Float_t p[3]; | |
73 | Int_t i, j, nt; | |
74 | Double_t pmom, theta, phi, pt; | |
75 | // | |
76 | Float_t random[6]; | |
77 | // | |
78 | for (j=0;j<3;j++) origin[j]=fOrigin[j]; | |
79 | if(fVertexSmear==kPerEvent) { | |
80 | Vertex(); | |
81 | for (j=0;j<3;j++) origin[j]=fVertex[j]; | |
82 | } | |
83 | ||
84 | for(i=0;i<fNpart;i++) { | |
85 | Rndm(random,3); | |
86 | ||
87 | if (TestBit(kThetaRange)) { | |
88 | theta = fThetaMin+random[0]*(fThetaMax-fThetaMin); | |
89 | } else { | |
90 | Float_t eta = fEtaMin+random[0]*(fEtaMax-fEtaMin); | |
91 | theta = 2. * TMath::ATan(TMath::Exp(-eta)); | |
92 | } | |
93 | ||
94 | ||
95 | if(TestBit(kMomentumRange)) { | |
96 | pmom=fPMin+random[1]*(fPMax-fPMin); | |
97 | pt=pmom*TMath::Sin(theta); | |
98 | } else { | |
99 | ||
100 | pt=fPtMin+random[1]*(fPtMax-fPtMin); | |
101 | pmom=pt/TMath::Sin(theta); | |
102 | } | |
103 | ||
104 | phi=fPhiMin+random[2]*(fPhiMax-fPhiMin); | |
105 | p[0] = pt*TMath::Cos(phi); | |
106 | p[1] = pt*TMath::Sin(phi); | |
107 | p[2] = pmom*TMath::Cos(theta); | |
108 | ||
109 | if(fVertexSmear==kPerTrack) { | |
110 | Rndm(random,6); | |
111 | for (j=0;j<3;j++) { | |
112 | origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())* | |
113 | TMath::Sqrt(-2*TMath::Log(random[2*j+1])); | |
114 | } | |
115 | } | |
116 | PushTrack(fTrackIt,-1,fIpart,p,origin,polar,0,kPPrimary,nt); | |
117 | } | |
118 | ||
119 | AliGenEventHeader* header = new AliGenEventHeader("BOX"); | |
120 | header->SetPrimaryVertex(fVertex); | |
121 | header->SetNProduced(fNpart); | |
122 | ||
123 | // Passes header either to the container or to gAlice | |
124 | if (fContainer) { | |
125 | fContainer->AddHeader(header); | |
126 | } else { | |
127 | gAlice->SetGenEventHeader(header); | |
128 | } | |
129 | } | |
130 | ||
131 | //_____________________________________________________________________________ | |
132 | ||
133 | void AliGenBox::Init() | |
134 | { | |
135 | // Initialisation, check consistency of selected ranges | |
136 | if(TestBit(kPtRange)&&TestBit(kMomentumRange)) | |
137 | Fatal("Init","You should not set the momentum range and the pt range!\n"); | |
138 | if((!TestBit(kPtRange))&&(!TestBit(kMomentumRange))) | |
139 | Fatal("Init","You should set either the momentum or the pt range!\n"); | |
140 | } | |
141 |