Option kNoDecayHeavy added.
[u/mrichter/AliRoot.git] / EVGEN / AliGenReaderTreeK.cxx
CommitLineData
8020fb14 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
314a87b5 18Revision 1.3 2001/12/12 11:21:37 morsch
19Dummy copy constructor added.
20
43342f51 21Revision 1.2 2001/11/12 14:31:00 morsch
22Memory leaks fixed. (M. Bondila)
23
ae872676 24Revision 1.1 2001/11/09 09:11:24 morsch
25Realisation of AliGenReader that reads the kine tree (TreeK).
26
8020fb14 27*/
28#include <TFile.h>
29#include <TTree.h>
30#include <TParticle.h>
31
32#include "AliGenReaderTreeK.h"
33#include "AliStack.h"
34#include "AliHeader.h"
35#include "AliRun.h"
36
37ClassImp(AliGenReaderTreeK);
38
39
40AliGenReaderTreeK::AliGenReaderTreeK():AliGenReader()
41{
42// Default constructor
43 fFileName = NULL;
44 fStack = 0;
45 fHeader = 0;
46 fNcurrent = 0;
47 fNparticle = 0;
48 fFile = 0;
49 fBaseFile = 0;
ae872676 50 fTreeE = 0;
51}
52
43342f51 53AliGenReaderTreeK::AliGenReaderTreeK(const AliGenReaderTreeK &reader)
54{
55 ;
56}
57
58
ae872676 59AliGenReaderTreeK::~AliGenReaderTreeK()
60{
61// Destructor
62 delete fTreeE;
8020fb14 63}
64
65void AliGenReaderTreeK::Init()
66{
67// Initialization
68// Connect base file and file to read from
69
70 TTree *ali = gAlice->TreeE();
71 if (ali) {
72 fBaseFile = ali->GetCurrentFile();
73 } else {
74 printf("\n Warning: Basefile cannot be found !\n");
75 }
314a87b5 76 if (!fFile) fFile = new TFile(fFileName);
8020fb14 77}
78
79Int_t AliGenReaderTreeK::NextEvent()
80{
314a87b5 81// Read the next event
8020fb14 82// cd to file with old kine tree
83 if (!fBaseFile) Init();
8020fb14 84 fFile->cd();
314a87b5 85// Connect header tree
86 if (!fTreeE) fTreeE = (TTree*)gDirectory->Get("TE");
8020fb14 87 if (fHeader) delete fHeader;
88 fHeader = 0;
ae872676 89 fTreeE->SetBranchAddress("Header", &fHeader);
8020fb14 90// Get next event
ae872676 91 fTreeE->GetEntry(fNcurrent);
314a87b5 92// Connect Stack
93 if (fStack) delete fStack;
8020fb14 94 fStack = fHeader->Stack();
95 fStack->GetEvent(fNcurrent);
8020fb14 96// cd back to base file
97 fBaseFile->cd();
98//
99 fNcurrent++;
100 fNparticle = 0;
101 Int_t ntrack = fStack->GetNtrack();
102 printf("\n Next event contains %d particles", ntrack);
314a87b5 103//
8020fb14 104 return ntrack;
105}
106
107TParticle* AliGenReaderTreeK::NextParticle()
108{
109// Return next particle
110 TParticle* part = fStack->Particle(fNparticle);
111 fNparticle++;
112 return part;
113}
114
115
116
ae872676 117AliGenReaderTreeK& AliGenReaderTreeK::operator=(const AliGenReaderTreeK& rhs)
118{
119// Assignment operator
120 return *this;
121}
8020fb14 122
123
124