]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenBox.cxx
The operator[] is replaced by At() or AddAt() in case of TObjArray.
[u/mrichter/AliRoot.git] / EVGEN / AliGenBox.cxx
CommitLineData
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
16/*
17$Log$
a99cf51f 18Revision 1.5 2000/12/21 16:24:06 morsch
19Coding convention clean-up
20
675e9664 21Revision 1.4 2000/11/30 07:12:49 alibrary
22Introducing new Rndm and QA classes
23
65fb704d 24Revision 1.3 2000/10/02 21:28:06 fca
25Removal of useless dependecies via forward declarations
26
94de3818 27Revision 1.2 2000/07/11 18:24:55 fca
28Coding convention corrections + few minor bug fixes
29
aee8290b 30Revision 1.1 2000/06/09 20:22:58 morsch
31Same class as previously in AliSimpleGen.cxx
32All coding rule violations except RS3 corrected (AM)
33
790bbabf 34*/
35
790bbabf 36
790bbabf 37
675e9664 38// Generator for particles in a preset
39// kinematic range (flat distribution)
40// Note that for a given theta pt and p are not independent
41// Range for only one variable (pt or p) should be given.
42//
43// Comments and suggestions: andreas.morsch@cern.ch
790bbabf 44//
45//Begin_Html
46/*
47<img src="picts/AliGeneratorClass.gif">
48</pre>
49<br clear=left>
50<font size=+2 color=red>
51<p>The responsible person for this module is
52<a href="mailto:andreas.morsch@cern.ch">Andreas Morsch</a>.
53</font>
54<pre>
55*/
56//End_Html
57// //
58///////////////////////////////////////////////////////////////////
59
60#include "AliGenBox.h"
61#include "AliRun.h"
62#include "AliConst.h"
63#include "AliPDG.h"
64
65ClassImp(AliGenBox)
66
67//_____________________________________________________________________________
68AliGenBox::AliGenBox()
69 :AliGenerator()
70{
71 //
72 // Default constructor
73 //
74 fIpart=0;
75}
76
77//_____________________________________________________________________________
78AliGenBox::AliGenBox(Int_t npart)
79 :AliGenerator(npart)
80{
81 //
82 // Standard constructor
83 //
84 fName="Box";
85 fTitle="Box particle generator";
86 // Generate Proton by default
87 fIpart=kProton;
88}
89
90//_____________________________________________________________________________
91
92void AliGenBox::Generate()
93{
94 //
95 // Generate one trigger
96 //
97
98 Float_t polar[3]= {0,0,0};
99 //
100 Float_t origin[3];
101 Float_t p[3];
102 Int_t i, j, nt;
103 Double_t pmom, theta, phi, pt;
104 //
105 Float_t random[6];
106 //
107 for (j=0;j<3;j++) origin[j]=fOrigin[j];
aee8290b 108 if(fVertexSmear==kPerEvent) {
65fb704d 109 Rndm(random,6);
790bbabf 110 for (j=0;j<3;j++) {
111 origin[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
112 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
113 }
114 }
115 for(i=0;i<fNpart;i++) {
65fb704d 116 Rndm(random,3);
790bbabf 117 theta=fThetaMin+random[0]*(fThetaMax-fThetaMin);
118 if(TestBit(kMomentumRange)) {
119 pmom=fPMin+random[1]*(fPMax-fPMin);
120 pt=pmom*TMath::Sin(theta);
121 } else {
122
123 pt=fPtMin+random[1]*(fPtMax-fPtMin);
124 pmom=pt/TMath::Sin(theta);
125 }
126 phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
127 p[0] = pt*TMath::Cos(phi);
128 p[1] = pt*TMath::Sin(phi);
129 p[2] = pmom*TMath::Cos(theta);
130
aee8290b 131 if(fVertexSmear==kPerTrack) {
65fb704d 132 Rndm(random,6);
790bbabf 133 for (j=0;j<3;j++) {
134 origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
135 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
136 }
137 }
a99cf51f 138 SetTrack(fTrackIt,-1,fIpart,p,origin,polar,0,kPPrimary,nt);
790bbabf 139 }
140}
141
142//_____________________________________________________________________________
143
144void AliGenBox::Init()
145{
146// Initialisation, check consistency of selected ranges
147 if(TestBit(kPtRange)&&TestBit(kMomentumRange))
148 Fatal("Init","You should not set the momentum range and the pt range!\n");
149 if((!TestBit(kPtRange))&&(!TestBit(kMomentumRange)))
150 Fatal("Init","You should set either the momentum or the pt range!\n");
151}
152