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.2 2001/11/12 14:31:00 morsch
19 Memory leaks fixed. (M. Bondila)
21 Revision 1.1 2001/11/09 09:11:24 morsch
22 Realisation of AliGenReader that reads the kine tree (TreeK).
27 #include <TParticle.h>
29 #include "AliGenReaderTreeK.h"
31 #include "AliHeader.h"
34 ClassImp(AliGenReaderTreeK);
37 AliGenReaderTreeK::AliGenReaderTreeK():AliGenReader()
39 // Default constructor
50 AliGenReaderTreeK::AliGenReaderTreeK(const AliGenReaderTreeK &reader)
56 AliGenReaderTreeK::~AliGenReaderTreeK()
62 void AliGenReaderTreeK::Init()
65 // Connect base file and file to read from
67 TTree *ali = gAlice->TreeE();
69 fBaseFile = ali->GetCurrentFile();
71 printf("\n Warning: Basefile cannot be found !\n");
73 fFile = new TFile(fFileName);
76 Int_t AliGenReaderTreeK::NextEvent()
78 // Read the next event
79 // cd to file with old kine tree
80 if (!fBaseFile) Init();
81 if (fStack) delete fStack;
82 fStack = new AliStack(1000);
88 fTreeE = (TTree*)gDirectory->Get("TE");
91 if (fHeader) delete fHeader;
93 fTreeE->SetBranchAddress("Header", &fHeader);
95 fTreeE->GetEntry(fNcurrent);
96 fStack = fHeader->Stack();
97 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);
120 AliGenReaderTreeK& AliGenReaderTreeK::operator=(const AliGenReaderTreeK& rhs)
122 // Assignment operator