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 // Realisations of the AliGenReader interface to be used with AliGenExFile.
19 // NextEvent() loops over events
20 // and NextParticle() loops over particles.
21 // This implementation reads various StarLight output formats
22 // Author: andreas.morsch@cern.ch
24 #include <TVirtualMC.h>
25 #include <TDatabasePDG.h>
26 #include <TParticle.h>
28 #include "AliGenReaderSL.h"
33 ClassImp(AliGenReaderSL)
36 AliGenReaderSL& AliGenReaderSL::operator=(const AliGenReaderSL& rhs)
38 // Assignment operator
43 void AliGenReaderSL::Copy(TObject&) const
48 Fatal("Copy","Not implemented!\n");
51 void AliGenReaderSL::Init()
54 if( !(fFile = fopen(fFileName,"r")) ) {
55 printf("Couldn't open input file: %s \n", fFileName);
57 printf("File %s opened \n", fFileName);
63 Int_t AliGenReaderSL::NextEvent()
65 // Read the next event
74 // GAMMAENERGIES: 27.6431
75 // VERTEX: 0 0 0 0 1 0 0 23
90 Float_t eGamma1, eGamma2;
94 nb = fscanf(fFile,"%6s %d %d %d ",linelabel, &i1, &ntrk, &i2);
95 if (nb == 0) return (0);
97 //printf("Event line: %s i1 = %5d ntrk = %5d i2 = %5d \n", linelabel, i1, ntrk, i2);
101 nb = fscanf(fFile, "%14s %f ",linelabel, &eGamma1);
102 } else if (fFormat == 2) {
103 nb = fscanf(fFile, "%14s %f %f ",linelabel, &eGamma1, &eGamma2);
105 if (nb == 0) return (0);
106 // printf("Gamma line: %s Egamma1 = %13.3f Egamma2 = %13.3f \n", linelabel, eGamma1, eGamma2);
109 nb = fscanf(fFile, "%7s %lf %lf %lf %lf %d %d %d %d",
110 linelabel, &x1, &x2, &x3, &x4, &i1, &i2, &i3, &nvtx);
111 // printf("Vertex line: %s (x = %13.3f, y = %13.3f, z = %13.3f, t = %13.3f) i1 = %5d i2 = %5d i3 = %5d nvtx = %5d \n",
112 // linelabel, x1, x2, x3, x4, i1, i2, i3, nvtx);
113 if (nb == 0) return (0);
114 if(ntrk != nvtx) printf("ERROR: ntrk = %5d nvtx = %5d \n", ntrk, nvtx);
116 return (fNParticles);
120 TParticle* AliGenReaderSL::NextParticle()
122 // Read next particle
126 static TParticle particle;
131 nb = fscanf(fFile, "%d %d %d %f %f %f ", &ievent, &ipart, &pdg, &px, &py, &pz);
132 // printf("%5d %5d %5d %13.3f %13.3f %13.3f \n", ievent, ipart, pdg, px, py, pz);
134 if (pdg == 8) pdg = 211;
135 if (pdg == 9) pdg = -211;
143 nb = fscanf(fFile,"%6s %d %f %f %f %d %d %d %d",
144 tracklabel, &i1, &px, &py, &pz, &i2, &i3, &i4, &pdg);
145 // printf("Particle %5d %13.3f %13.3f %13.3f \n", pdg, px, py, pz);
147 if (nb == 0) return (0x0);
149 Double_t mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
150 Float_t e = TMath::Sqrt(px * px + py * py + pz * pz + mass * mass);
151 particle.SetMomentum(px, py, pz, e);
152 particle.SetPdgCode(pdg);
153 particle.SetFirstMother(-1);
154 particle.SetLastMother(-1);
155 particle.SetBit(kTransportBit);
159 void AliGenReaderSL::RewindEvent()