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