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.3 2001/12/12 11:21:37 morsch
19 Dummy copy constructor added.
21 Revision 1.2 2001/11/12 14:31:00 morsch
22 Memory leaks fixed. (M. Bondila)
24 Revision 1.1 2001/11/09 09:11:24 morsch
25 Realisation of AliGenReader that reads the kine tree (TreeK).
30 #include <TParticle.h>
32 #include "AliGenReaderTreeK.h"
34 #include "AliHeader.h"
37 ClassImp(AliGenReaderTreeK);
40 AliGenReaderTreeK::AliGenReaderTreeK():AliGenReader()
42 // Default constructor
53 AliGenReaderTreeK::AliGenReaderTreeK(const AliGenReaderTreeK &reader)
59 AliGenReaderTreeK::~AliGenReaderTreeK()
65 void AliGenReaderTreeK::Init()
68 // Connect base file and file to read from
70 TTree *ali = gAlice->TreeE();
72 fBaseFile = ali->GetCurrentFile();
74 printf("\n Warning: Basefile cannot be found !\n");
76 if (!fFile) fFile = new TFile(fFileName);
79 Int_t AliGenReaderTreeK::NextEvent()
81 // Read the next event
82 // cd to file with old kine tree
83 if (!fBaseFile) Init();
85 // Connect header tree
86 if (!fTreeE) fTreeE = (TTree*)gDirectory->Get("TE");
87 if (fHeader) delete fHeader;
89 fTreeE->SetBranchAddress("Header", &fHeader);
91 fTreeE->GetEntry(fNcurrent);
93 if (fStack) delete fStack;
94 fStack = fHeader->Stack();
95 fStack->GetEvent(fNcurrent);
96 // cd back to base file
101 Int_t ntrack = fStack->GetNtrack();
102 printf("\n Next event contains %d particles", ntrack);
107 TParticle* AliGenReaderTreeK::NextParticle()
109 // Return next particle
110 TParticle* part = fStack->Particle(fNparticle);
117 AliGenReaderTreeK& AliGenReaderTreeK::operator=(const AliGenReaderTreeK& rhs)
119 // Assignment operator