]>
Commit | Line | Data |
---|---|---|
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$ | |
d1d1da57 | 18 | Revision 1.4 2002/03/22 08:25:33 morsch |
19 | TreeE connected correctly. | |
20 | ||
314a87b5 | 21 | Revision 1.3 2001/12/12 11:21:37 morsch |
22 | Dummy copy constructor added. | |
23 | ||
43342f51 | 24 | Revision 1.2 2001/11/12 14:31:00 morsch |
25 | Memory leaks fixed. (M. Bondila) | |
26 | ||
ae872676 | 27 | Revision 1.1 2001/11/09 09:11:24 morsch |
28 | Realisation of AliGenReader that reads the kine tree (TreeK). | |
29 | ||
8020fb14 | 30 | */ |
31 | #include <TFile.h> | |
32 | #include <TTree.h> | |
33 | #include <TParticle.h> | |
34 | ||
35 | #include "AliGenReaderTreeK.h" | |
36 | #include "AliStack.h" | |
37 | #include "AliHeader.h" | |
38 | #include "AliRun.h" | |
39 | ||
40 | ClassImp(AliGenReaderTreeK); | |
41 | ||
42 | ||
43 | AliGenReaderTreeK::AliGenReaderTreeK():AliGenReader() | |
44 | { | |
45 | // Default constructor | |
46 | fFileName = NULL; | |
47 | fStack = 0; | |
48 | fHeader = 0; | |
49 | fNcurrent = 0; | |
50 | fNparticle = 0; | |
51 | fFile = 0; | |
52 | fBaseFile = 0; | |
ae872676 | 53 | fTreeE = 0; |
54 | } | |
55 | ||
43342f51 | 56 | AliGenReaderTreeK::AliGenReaderTreeK(const AliGenReaderTreeK &reader) |
57 | { | |
58 | ; | |
59 | } | |
60 | ||
61 | ||
ae872676 | 62 | AliGenReaderTreeK::~AliGenReaderTreeK() |
63 | { | |
64 | // Destructor | |
65 | delete fTreeE; | |
8020fb14 | 66 | } |
67 | ||
68 | void AliGenReaderTreeK::Init() | |
69 | { | |
70 | // Initialization | |
71 | // Connect base file and file to read from | |
72 | ||
73 | TTree *ali = gAlice->TreeE(); | |
74 | if (ali) { | |
75 | fBaseFile = ali->GetCurrentFile(); | |
76 | } else { | |
77 | printf("\n Warning: Basefile cannot be found !\n"); | |
78 | } | |
314a87b5 | 79 | if (!fFile) fFile = new TFile(fFileName); |
8020fb14 | 80 | } |
81 | ||
82 | Int_t AliGenReaderTreeK::NextEvent() | |
83 | { | |
314a87b5 | 84 | // Read the next event |
8020fb14 | 85 | // cd to file with old kine tree |
86 | if (!fBaseFile) Init(); | |
8020fb14 | 87 | fFile->cd(); |
314a87b5 | 88 | // Connect header tree |
89 | if (!fTreeE) fTreeE = (TTree*)gDirectory->Get("TE"); | |
8020fb14 | 90 | if (fHeader) delete fHeader; |
91 | fHeader = 0; | |
ae872676 | 92 | fTreeE->SetBranchAddress("Header", &fHeader); |
8020fb14 | 93 | // Get next event |
ae872676 | 94 | fTreeE->GetEntry(fNcurrent); |
314a87b5 | 95 | // Connect Stack |
96 | if (fStack) delete fStack; | |
8020fb14 | 97 | fStack = fHeader->Stack(); |
98 | fStack->GetEvent(fNcurrent); | |
8020fb14 | 99 | // cd back to base file |
100 | fBaseFile->cd(); | |
101 | // | |
102 | fNcurrent++; | |
103 | fNparticle = 0; | |
104 | Int_t ntrack = fStack->GetNtrack(); | |
105 | printf("\n Next event contains %d particles", ntrack); | |
314a87b5 | 106 | // |
8020fb14 | 107 | return ntrack; |
108 | } | |
109 | ||
110 | TParticle* AliGenReaderTreeK::NextParticle() | |
111 | { | |
112 | // Return next particle | |
113 | TParticle* part = fStack->Particle(fNparticle); | |
114 | fNparticle++; | |
115 | return part; | |
116 | } | |
117 | ||
d1d1da57 | 118 | void AliGenReaderTreeK::RewindEvent() |
119 | { | |
120 | // Go back to the first particle of the event | |
121 | fNparticle = 0; | |
122 | } | |
8020fb14 | 123 | |
124 | ||
ae872676 | 125 | AliGenReaderTreeK& AliGenReaderTreeK::operator=(const AliGenReaderTreeK& rhs) |
126 | { | |
127 | // Assignment operator | |
128 | return *this; | |
129 | } | |
8020fb14 | 130 | |
131 | ||
132 |