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.4 2002/03/22 08:25:33 morsch
19 TreeE connected correctly.
21 Revision 1.3 2001/12/12 11:21:37 morsch
22 Dummy copy constructor added.
24 Revision 1.2 2001/11/12 14:31:00 morsch
25 Memory leaks fixed. (M. Bondila)
27 Revision 1.1 2001/11/09 09:11:24 morsch
28 Realisation of AliGenReader that reads the kine tree (TreeK).
33 #include <TParticle.h>
35 #include "AliGenReaderTreeK.h"
37 #include "AliHeader.h"
40 ClassImp(AliGenReaderTreeK);
43 AliGenReaderTreeK::AliGenReaderTreeK():AliGenReader()
45 // Default constructor
56 AliGenReaderTreeK::AliGenReaderTreeK(const AliGenReaderTreeK &reader)
62 AliGenReaderTreeK::~AliGenReaderTreeK()
68 void AliGenReaderTreeK::Init()
71 // Connect base file and file to read from
73 TTree *ali = gAlice->TreeE();
75 fBaseFile = ali->GetCurrentFile();
77 printf("\n Warning: Basefile cannot be found !\n");
79 if (!fFile) fFile = new TFile(fFileName);
82 Int_t AliGenReaderTreeK::NextEvent()
84 // Read the next event
85 // cd to file with old kine tree
86 if (!fBaseFile) Init();
88 // Connect header tree
89 if (!fTreeE) fTreeE = (TTree*)gDirectory->Get("TE");
90 if (fHeader) delete fHeader;
92 fTreeE->SetBranchAddress("Header", &fHeader);
94 fTreeE->GetEntry(fNcurrent);
96 if (fStack) delete fStack;
97 fStack = fHeader->Stack();
98 fStack->GetEvent(fNcurrent);
99 // cd back to base file
104 Int_t ntrack = fStack->GetNtrack();
105 printf("\n Next event contains %d particles", ntrack);
110 TParticle* AliGenReaderTreeK::NextParticle()
112 // Return next particle
113 TParticle* part = fStack->Particle(fNparticle);
118 void AliGenReaderTreeK::RewindEvent()
120 // Go back to the first particle of the event
125 AliGenReaderTreeK& AliGenReaderTreeK::operator=(const AliGenReaderTreeK& rhs)
127 // Assignment operator