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 **************************************************************************/
18 Revision 1.18 2001/11/12 14:31:00 morsch
19 Memory leaks fixed. (M. Bondila)
21 Revision 1.17 2001/11/09 09:12:58 morsch
22 Generalization by using AliGenReader object to read particles from file.
24 Revision 1.16 2001/07/27 17:09:35 morsch
25 Use local SetTrack, KeepTrack and SetHighWaterMark methods
26 to delegate either to local stack or to stack owned by AliRun.
27 (Piotr Skowronski, A.M.)
29 Revision 1.15 2001/01/23 13:29:37 morsch
30 Add method SetParticleCode and enum type Code_t to handle both PDG (new ntuples)
31 and GEANT3 codes (old ntuples) in input file.
33 Revision 1.14 2000/12/21 16:24:06 morsch
34 Coding convention clean-up
36 Revision 1.13 2000/11/30 07:12:50 alibrary
37 Introducing new Rndm and QA classes
39 Revision 1.12 2000/10/27 13:54:45 morsch
40 Remove explicite reference to input file from constuctor.
42 Revision 1.11 2000/10/02 21:28:06 fca
43 Removal of useless dependecies via forward declarations
45 Revision 1.10 2000/07/11 18:24:55 fca
46 Coding convention corrections + few minor bug fixes
48 Revision 1.9 2000/06/14 15:20:09 morsch
51 Revision 1.8 2000/06/09 20:36:44 morsch
52 All coding rule violations except RS3 corrected
54 Revision 1.7 2000/02/16 14:56:27 morsch
55 Convert geant particle code into pdg code before putting particle on the stack.
57 Revision 1.6 1999/11/09 07:38:48 fca
58 Changes for compatibility with version 2.23 of ROOT
60 Revision 1.5 1999/09/29 09:24:12 fca
61 Introduction of the Copyright and cvs Log
66 // Event generator that using an instance of type AliGenReader
67 // reads particles from a file and applies cuts.
71 #include "AliGenExtFile.h"
74 #include <TParticle.h>
79 ClassImp(AliGenExtFile)
80 AliGenExtFile::AliGenExtFile()
90 AliGenExtFile::AliGenExtFile(Int_t npart)
95 fTitle = "Primaries from ext. File";
99 AliGenExtFile::AliGenExtFile(const AliGenExtFile & ExtFile)
103 //____________________________________________________________
104 AliGenExtFile::~AliGenExtFile()
110 //___________________________________________________________
111 void AliGenExtFile::Init()
114 if (fReader) fReader->Init();
118 void AliGenExtFile::Generate()
120 // Generate particles
122 Float_t polar[3] = {0,0,0};
124 Float_t origin[3] = {0,0,0};
129 for (j=0;j<3;j++) origin[j]=fOrigin[j];
130 if(fVertexSmear == kPerTrack) {
132 for (j = 0; j < 3; j++) {
133 origin[j] += fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
134 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
138 Int_t nTracks = fReader->NextEvent();
140 printf("\n No more events !!! !\n");
144 for (i = 0; i < nTracks; i++) {
145 TParticle* iparticle = fReader->NextParticle();
146 Double_t theta = iparticle->Theta();
147 Double_t phi = iparticle->Phi();
148 if (phi > TMath::Pi()) phi -= 2.*TMath::Pi();
149 Double_t pmom = iparticle->P();
150 Double_t pz = iparticle->Pz();
151 Double_t e = iparticle->Energy();
152 Double_t pt = iparticle->Pt();
157 } else if ((e+pz) == 0.) {
160 y = 0.5*TMath::Log((e+pz)/(e-pz));
163 if(theta < fThetaMin || theta > fThetaMax ||
164 phi < fPhiMin || phi > fPhiMax ||
165 pmom < fPMin || pmom > fPMax ||
166 pt < fPtMin || pt > fPtMax ||
167 y < fYMin || y > fYMax )
169 printf("\n Not selected %d %f %f %f %f %f", i, theta, phi, pmom, pt, y);
173 p[0] = iparticle->Px();
174 p[1] = iparticle->Py();
175 p[2] = iparticle->Pz();
176 Int_t idpart = iparticle->GetPdgCode();
177 if(fVertexSmear==kPerTrack) {
179 for (j = 0; j < 3; j++) {
181 +fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
182 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
185 SetTrack(fTrackIt,-1,idpart,p,origin,polar,0,kPPrimary,nt);
189 // Get AliRun object or create it
191 gAlice = (AliRun*)pFile->Get("gAlice");
192 if (gAlice) printf("AliRun object found on file\n");
193 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
195 TTree *fAli=gAlice->TreeK();
196 if (fAli) pFile =fAli->GetCurrentFile();
201 AliGenExtFile& AliGenExtFile::operator=(const AliGenExtFile& rhs)
203 // Assignment operator