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