]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenBox.cxx
Additional initialization. Do not remove fHeader, it is done in AliRunLoader
[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
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"
790bbabf 32
33ClassImp(AliGenBox)
34
35//_____________________________________________________________________________
36AliGenBox::AliGenBox()
37 :AliGenerator()
38{
39 //
40 // Default constructor
41 //
42 fIpart=0;
43}
44
45//_____________________________________________________________________________
46AliGenBox::AliGenBox(Int_t npart)
47 :AliGenerator(npart)
48{
49 //
50 // Standard constructor
51 //
8b31bfac 52 fName = "Box";
53 fTitle = "Box particle generator";
790bbabf 54 // Generate Proton by default
55 fIpart=kProton;
56}
57
58//_____________________________________________________________________________
59
60void AliGenBox::Generate()
61{
62 //
63 // Generate one trigger
64 //
65
66 Float_t polar[3]= {0,0,0};
67 //
68 Float_t origin[3];
69 Float_t p[3];
70 Int_t i, j, nt;
71 Double_t pmom, theta, phi, pt;
72 //
73 Float_t random[6];
74 //
75 for (j=0;j<3;j++) origin[j]=fOrigin[j];
aee8290b 76 if(fVertexSmear==kPerEvent) {
c8f7f6f9 77 Vertex();
78 for (j=0;j<3;j++) origin[j]=fVertex[j];
790bbabf 79 }
c8f7f6f9 80
790bbabf 81 for(i=0;i<fNpart;i++) {
65fb704d 82 Rndm(random,3);
790bbabf 83 theta=fThetaMin+random[0]*(fThetaMax-fThetaMin);
84 if(TestBit(kMomentumRange)) {
85 pmom=fPMin+random[1]*(fPMax-fPMin);
86 pt=pmom*TMath::Sin(theta);
87 } else {
88
89 pt=fPtMin+random[1]*(fPtMax-fPtMin);
90 pmom=pt/TMath::Sin(theta);
91 }
92 phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
93 p[0] = pt*TMath::Cos(phi);
94 p[1] = pt*TMath::Sin(phi);
95 p[2] = pmom*TMath::Cos(theta);
96
aee8290b 97 if(fVertexSmear==kPerTrack) {
65fb704d 98 Rndm(random,6);
790bbabf 99 for (j=0;j<3;j++) {
100 origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
101 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
102 }
103 }
642f15cf 104 PushTrack(fTrackIt,-1,fIpart,p,origin,polar,0,kPPrimary,nt);
790bbabf 105 }
42cca6d4 106
107 AliGenEventHeader* header = new AliGenEventHeader("BOX");
108 header->SetPrimaryVertex(fVertex);
109 gAlice->SetGenEventHeader(header);
790bbabf 110}
111
112//_____________________________________________________________________________
113
114void AliGenBox::Init()
115{
116// Initialisation, check consistency of selected ranges
117 if(TestBit(kPtRange)&&TestBit(kMomentumRange))
118 Fatal("Init","You should not set the momentum range and the pt range!\n");
119 if((!TestBit(kPtRange))&&(!TestBit(kMomentumRange)))
120 Fatal("Init","You should set either the momentum or the pt range!\n");
121}
122