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