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