1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
29 #include "AliGenBox.h"
31 #include "AliGenEventHeader.h"
32 #include "TDatabasePDG.h"
37 //_____________________________________________________________________________
38 AliGenBox::AliGenBox()
45 // Default constructor
49 //_____________________________________________________________________________
50 AliGenBox::AliGenBox(Int_t npart)
57 // Standard constructor
60 fTitle = "Box particle generator";
63 //_____________________________________________________________________________
65 void AliGenBox::Generate() {
67 // Generate one trigger (fNpart particles)
72 //_____________________________________________________________________________
73 void AliGenBox::GenerateN(Int_t ntimes)
76 // Generate ntimes triggers
77 // total ntimes*fNpart particles
80 Float_t polar[3]= {0,0,0};
86 Double_t pmom, theta, phi, pt;
91 for (j=0;j<3;j++) origin[j]=fOrigin[j];
93 if(fVertexSmear==kPerEvent) {
95 for (j=0;j<3;j++) origin[j]=fVertex[j];
99 Double_t m = TDatabasePDG::Instance()->GetParticle(fIpart)->Mass();
101 Int_t mult = fNpart*ntimes;
102 for(i=0;i<mult;i++) {
105 if (TestBit(kYRange)) {
106 y = fYMin+random[0]*(fYMax-fYMin);
108 if(TestBit(kMomentumRange)) {
109 pmom=fPMin+random[1]*(fPMax-fPMin);
110 mt = TMath::Sqrt(pmom*pmom+m*m)/TMath::CosH(y);
111 pt = TMath::Sqrt(mt*mt - m*m);
113 pt=fPtMin+random[1]*(fPtMax-fPtMin);
114 mt=TMath::Sqrt(pt*pt+m*m);
117 phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
118 p[0] = pt*TMath::Cos(phi);
119 p[1] = pt*TMath::Sin(phi);
120 p[2] = mt*TMath::SinH(y);
122 if (TestBit(kThetaRange)) {
123 theta = fThetaMin+random[0]*(fThetaMax-fThetaMin);
125 Float_t eta = fEtaMin+random[0]*(fEtaMax-fEtaMin);
126 theta = 2. * TMath::ATan(TMath::Exp(-eta));
129 if(TestBit(kMomentumRange)) {
130 pmom=fPMin+random[1]*(fPMax-fPMin);
131 pt=pmom*TMath::Sin(theta);
134 pt=fPtMin+random[1]*(fPtMax-fPtMin);
135 pmom=pt/TMath::Sin(theta);
138 phi=fPhiMin+random[2]*(fPhiMax-fPhiMin);
139 p[0] = pt*TMath::Cos(phi);
140 p[1] = pt*TMath::Sin(phi);
141 p[2] = pmom*TMath::Cos(theta);
144 if(fVertexSmear==kPerTrack) {
147 origin[j]=fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
148 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
152 time = fTimeOrigin + fOsigma[2]/TMath::Ccgs()*
153 TMath::Cos(2*random[0]*TMath::Pi())*
154 TMath::Sqrt(-2*TMath::Log(random[1]));
156 PushTrack(fTrackIt,-1,fIpart,p,origin,polar,time,kPPrimary,nt, 1., 1);
159 AliGenEventHeader* header = new AliGenEventHeader("BOX");
160 header->SetPrimaryVertex(fVertex);
161 header->SetNProduced(mult);
162 header->SetInteractionTime(fTime);
164 // Passes header either to the container or to gAlice
166 header->SetName(fName);
167 fContainer->AddHeader(header);
169 gAlice->SetGenEventHeader(header);
173 //_____________________________________________________________________________
175 void AliGenBox::Init()
177 // Initialisation, check consistency of selected ranges
178 if(TestBit(kPtRange)&&TestBit(kMomentumRange))
179 Fatal("Init","You should not set the momentum range and the pt range!\n");
180 if((!TestBit(kPtRange))&&(!TestBit(kMomentumRange)))
181 Fatal("Init","You should set either the momentum or the pt range!\n");
182 if((TestBit(kYRange)&&TestBit(kThetaRange)) || (TestBit(kYRange)&&TestBit(kEtaRange)) || (TestBit(kEtaRange)&&TestBit(kThetaRange)) )
183 Fatal("Init","You should only set the range of one of these variables: y, eta or theta\n");
184 if((!TestBit(kYRange)) && (!TestBit(kEtaRange)) && (!TestBit(kThetaRange)) )
185 Fatal("Init","You should set the range of one of these variables: y, eta or theta\n");