]>
Commit | Line | Data |
---|---|---|
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 | /* $Id$ */ | |
17 | // | |
18 | // Realisation of AliGenReader to be used with AliGenExtFile | |
19 | // It reads Hijing events from a ntuple like event structure. | |
20 | // The event format is defined in Init() | |
21 | // NextEvent() is used to loop over events and NextParticle() to loop over particles. | |
22 | // Author: andreas.morsch@cern.ch | |
23 | // | |
24 | #include <TFile.h> | |
25 | #include <TParticle.h> | |
26 | #include <TDatabasePDG.h> | |
27 | #include <TTree.h> | |
28 | ||
29 | #include "AliGenReaderEcalHijing.h" | |
30 | ||
31 | ClassImp(AliGenReaderEcalHijing) | |
32 | ||
33 | AliGenReaderEcalHijing::AliGenReaderEcalHijing(): | |
34 | fNcurrent(0), | |
35 | fNparticle(0), | |
36 | fTreeNtuple(0), | |
37 | fNjatt(0), | |
38 | fNahij(0), | |
39 | fNphij(0) | |
40 | { | |
41 | // Default constructor | |
42 | for (Int_t i = 0; i < 10000; i++) { | |
43 | fKhij[i] = 0; | |
44 | fPxhij[i] = 0.; | |
45 | fPyhij[i] = 0.; | |
46 | fPzhij[i] = 0.; | |
47 | fEhij[i] = 0.; | |
48 | } | |
49 | } | |
50 | ||
51 | AliGenReaderEcalHijing::AliGenReaderEcalHijing(const AliGenReaderEcalHijing &reader): | |
52 | AliGenReader(reader), | |
53 | fNcurrent(0), | |
54 | fNparticle(0), | |
55 | fTreeNtuple(0), | |
56 | fNjatt(0), | |
57 | fNahij(0), | |
58 | fNphij(0) | |
59 | { | |
60 | // Copy constructor | |
61 | for (Int_t i = 0; i < 10000; i++) { | |
62 | fKhij[i] = 0; | |
63 | fPxhij[i] = 0.; | |
64 | fPyhij[i] = 0.; | |
65 | fPzhij[i] = 0.; | |
66 | fEhij[i] = 0.; | |
67 | } | |
68 | reader.Copy(*this); | |
69 | } | |
70 | ||
71 | void AliGenReaderEcalHijing::Init() | |
72 | { | |
73 | // | |
74 | // reset the existing file environment and open a new root file if | |
75 | // the pointer to the Fluka tree is null | |
76 | ||
77 | TFile *pFile=0; | |
78 | if (!pFile) { | |
79 | pFile = new TFile(fFileName); | |
80 | pFile->cd(); | |
81 | printf("\n I have opened %s file \n", fFileName); | |
82 | } | |
83 | // get the tree address in the Fluka boundary source file | |
84 | fTreeNtuple = (TTree*)gDirectory->Get("h2"); | |
85 | TTree *h2=fTreeNtuple; | |
86 | h2->SetMakeClass(1); | |
87 | //Set branch addresses | |
88 | h2->SetBranchAddress("njatt", &fNjatt); | |
89 | h2->SetBranchAddress("nahij", &fNahij); | |
90 | h2->SetBranchAddress("nphij", &fNphij); | |
91 | h2->SetBranchAddress("khij", fKhij) ; | |
92 | h2->SetBranchAddress("pxhij", fPxhij); | |
93 | h2->SetBranchAddress("pyhij", fPyhij); | |
94 | h2->SetBranchAddress("pzhij", fPzhij); | |
95 | h2->SetBranchAddress("ehij", fEhij) ; | |
96 | } | |
97 | ||
98 | Int_t AliGenReaderEcalHijing::NextEvent() | |
99 | { | |
100 | // Read the next event | |
101 | Int_t nTracks=0, nread=0; | |
102 | ||
103 | TFile* pFile = fTreeNtuple->GetCurrentFile(); | |
104 | pFile->cd(); | |
105 | ||
106 | Int_t nentries = (Int_t) fTreeNtuple->GetEntries(); | |
107 | if (fNcurrent < nentries) { | |
108 | Int_t nb = (Int_t)fTreeNtuple->GetEvent(fNcurrent); | |
109 | nread += nb; | |
110 | fNcurrent++; | |
111 | printf("\n Next event contains %d tracks! \n", fNphij); | |
112 | nTracks = fNphij; | |
113 | fNparticle = 0; | |
114 | return nTracks; | |
115 | } | |
116 | return 0; | |
117 | } | |
118 | ||
119 | TParticle* AliGenReaderEcalHijing::NextParticle() | |
120 | { | |
121 | // Read the next particle | |
122 | ||
123 | Float_t p[4]; | |
124 | Int_t ipart = fKhij[fNparticle]; | |
125 | p[0] = fPxhij[fNparticle]; | |
126 | p[1] = fPyhij[fNparticle]; | |
127 | p[2] = fPzhij[fNparticle]; | |
128 | p[3] = fEhij[fNparticle]; | |
129 | ||
130 | Double_t amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass(); | |
131 | ||
132 | if(p[3] <= amass) { | |
133 | Warning("Generate","Particle %d E = %f mass = %f \n", | |
134 | ipart, p[3], amass); | |
135 | } | |
136 | TParticle* particle = | |
137 | new TParticle(ipart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3], | |
138 | 0., 0., 0., 0.); | |
139 | fNparticle++; | |
140 | return particle; | |
141 | } | |
142 | ||
143 | ||
144 | ||
145 | AliGenReaderEcalHijing& AliGenReaderEcalHijing::operator=(const AliGenReaderEcalHijing& rhs) | |
146 | { | |
147 | // Assignment operator | |
148 | rhs.Copy(*this); | |
149 | return (*this); | |
150 | } | |
151 | ||
152 | void AliGenReaderEcalHijing::Copy(TObject&) const | |
153 | { | |
154 | // | |
155 | // Copy | |
156 | // | |
157 | Fatal("Copy","Not implemented!\n"); | |
158 | } | |
159 | ||
160 | ||
161 | ||
162 | ||
163 | ||
164 |