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