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.4.1 2002/06/10 14:57:41 hristov
21 Revision 1.5 2002/04/26 10:37:23 morsch
22 Method RewindEvent() added. (N. Carrer)
24 Revision 1.4 2002/03/22 08:25:33 morsch
25 TreeE connected correctly.
27 Revision 1.3 2001/12/12 11:21:37 morsch
28 Dummy copy constructor added.
30 Revision 1.2 2001/11/12 14:31:00 morsch
31 Memory leaks fixed. (M. Bondila)
33 Revision 1.1 2001/11/09 09:11:24 morsch
34 Realisation of AliGenReader that reads the kine tree (TreeK).
39 #include <TParticle.h>
41 #include "AliGenReaderTreeK.h"
43 #include "AliHeader.h"
46 ClassImp(AliGenReaderTreeK);
49 AliGenReaderTreeK::AliGenReaderTreeK():AliGenReader()
51 // Default constructor
62 AliGenReaderTreeK::AliGenReaderTreeK(const AliGenReaderTreeK &reader)
68 AliGenReaderTreeK::~AliGenReaderTreeK()
74 void AliGenReaderTreeK::Init()
77 // Connect base file and file to read from
79 TTree *ali = gAlice->TreeE();
81 fBaseFile = ali->GetCurrentFile();
83 printf("\n Warning: Basefile cannot be found !\n");
85 if (!fFile) fFile = new TFile(fFileName);
88 Int_t AliGenReaderTreeK::NextEvent()
90 // Read the next event
91 // cd to file with old kine tree
92 if (!fBaseFile) Init();
94 // Connect header tree
95 if (!fTreeE) fTreeE = (TTree*)gDirectory->Get("TE");
96 if (fHeader) delete fHeader;
98 fTreeE->SetBranchAddress("Header", &fHeader);
100 fTreeE->GetEntry(fNcurrent);
102 if (fStack) delete fStack;
103 fStack = fHeader->Stack();
104 fStack->GetEvent(fNcurrent);
105 // cd back to base file
110 Int_t ntrack = fStack->GetNtrack();
111 printf("\n Next event contains %d particles", ntrack);
116 TParticle* AliGenReaderTreeK::NextParticle()
118 // Return next particle
119 TParticle* part = fStack->Particle(fNparticle);
124 void AliGenReaderTreeK::RewindEvent()
126 // Go back to the first particle of the event
131 AliGenReaderTreeK& AliGenReaderTreeK::operator=(const AliGenReaderTreeK& rhs)
133 // Assignment operator