]>
Commit | Line | Data |
---|---|---|
b152a071 | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
b152a071 | 17 | |
18 | #include <TFile.h> | |
b152a071 | 19 | #include <TParticle.h> |
88cb7938 | 20 | #include <TTree.h> |
21 | #include <TVirtualMC.h> | |
b152a071 | 22 | |
23 | #include "AliGenReaderEcalHijing.h" | |
88cb7938 | 24 | |
b152a071 | 25 | ClassImp(AliGenReaderEcalHijing) |
26 | ||
27 | ||
28 | AliGenReaderEcalHijing::AliGenReaderEcalHijing() | |
29 | { | |
30 | // Default constructor | |
31 | fNcurrent = 0; | |
32 | fTreeNtuple = 0; | |
33 | } | |
34 | ||
35 | void AliGenReaderEcalHijing::Init() | |
36 | { | |
37 | // | |
38 | // reset the existing file environment and open a new root file if | |
39 | // the pointer to the Fluka tree is null | |
40 | ||
41 | TFile *pFile=0; | |
42 | if (!pFile) { | |
43 | pFile = new TFile(fFileName); | |
44 | pFile->cd(); | |
45 | printf("\n I have opened %s file \n", fFileName); | |
46 | } | |
47 | // get the tree address in the Fluka boundary source file | |
48 | fTreeNtuple = (TTree*)gDirectory->Get("h2"); | |
49 | TTree *h2=fTreeNtuple; | |
50 | h2->SetMakeClass(1); | |
51 | //Set branch addresses | |
52 | h2->SetBranchAddress("njatt", &fNjatt); | |
53 | h2->SetBranchAddress("nahij", &fNahij); | |
54 | h2->SetBranchAddress("nphij", &fNphij); | |
55 | h2->SetBranchAddress("khij", fKhij) ; | |
56 | h2->SetBranchAddress("pxhij", fPxhij); | |
57 | h2->SetBranchAddress("pyhij", fPyhij); | |
58 | h2->SetBranchAddress("pzhij", fPzhij); | |
59 | h2->SetBranchAddress("ehij", fEhij) ; | |
60 | } | |
61 | ||
62 | Int_t AliGenReaderEcalHijing::NextEvent() | |
63 | { | |
64 | // Read the next event | |
58323221 | 65 | Int_t nTracks=0, nread=0; |
b152a071 | 66 | |
67 | TFile* pFile = fTreeNtuple->GetCurrentFile(); | |
68 | pFile->cd(); | |
69 | ||
70 | Int_t nentries = (Int_t) fTreeNtuple->GetEntries(); | |
71 | if (fNcurrent < nentries) { | |
72 | Int_t nb = (Int_t)fTreeNtuple->GetEvent(fNcurrent); | |
73 | nread += nb; | |
74 | fNcurrent++; | |
75 | printf("\n Next event contains %d tracks! \n", fNphij); | |
76 | nTracks = fNphij; | |
77 | fNparticle = 0; | |
78 | return nTracks; | |
79 | } | |
80 | return 0; | |
81 | } | |
82 | ||
83 | TParticle* AliGenReaderEcalHijing::NextParticle() | |
84 | { | |
85 | Float_t p[4]; | |
86 | // Read the next particle | |
87 | Int_t ipart = fKhij[fNparticle]; | |
88 | p[0] = fPxhij[fNparticle]; | |
89 | p[1] = fPyhij[fNparticle]; | |
90 | p[2] = fPzhij[fNparticle]; | |
91 | p[3] = fEhij[fNparticle]; | |
92 | ||
93 | Double_t amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass(); | |
94 | ||
95 | if(p[3] <= amass) { | |
96 | Warning("Generate","Particle %d E = %f mass = %f \n", | |
97 | ipart, p[3], amass); | |
98 | } | |
99 | TParticle* particle = | |
100 | new TParticle(ipart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3], | |
101 | 0., 0., 0., 0.); | |
102 | fNparticle++; | |
103 | return particle; | |
104 | } | |
105 | ||
106 | ||
107 | ||
108 | AliGenReaderEcalHijing& AliGenReaderEcalHijing::operator=(const AliGenReaderEcalHijing& rhs) | |
109 | { | |
110 | // Assignment operator | |
198bb1c7 | 111 | rhs.Copy(*this); |
112 | return (*this); | |
113 | } | |
114 | ||
115 | void AliGenReaderEcalHijing::Copy(AliGenReaderEcalHijing&) const | |
116 | { | |
117 | // | |
118 | // Copy | |
119 | // | |
120 | Fatal("Copy","Not implemented!\n"); | |
b152a071 | 121 | } |
122 | ||
123 | ||
124 | ||
125 | ||
126 | ||
127 |