correct the trigger name for PbPb
[u/mrichter/AliRoot.git] / EVGEN / AliGenReaderEcalJets.cxx
CommitLineData
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 Pythia Jet 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>
c180f65d 26#include <TDatabasePDG.h>
88cb7938 27#include <TTree.h>
b152a071 28
29#include "AliGenReaderEcalJets.h"
88cb7938 30
b152a071 31ClassImp(AliGenReaderEcalJets)
32
33
1c56e311 34AliGenReaderEcalJets::AliGenReaderEcalJets():
35 fNcurrent(0),
36 fNparticle(0),
37 fNev(0),
38 fNpart(0),
39 fNjet(0),
40 fNsjet(0),
41 fNpjet(0),
42 fTreeNtuple(0)
b152a071 43{
44// Default constructor
1c56e311 45}
46
47 AliGenReaderEcalJets::AliGenReaderEcalJets(const AliGenReaderEcalJets &reader)
48 :AliGenReader(reader),
49 fNcurrent(0),
50 fNparticle(0),
51 fNev(0),
52 fNpart(0),
53 fNjet(0),
54 fNsjet(0),
55 fNpjet(0),
56 fTreeNtuple(0)
57{
58 // Copy Constructor
59 reader.Copy(*this);
b152a071 60}
61
62void AliGenReaderEcalJets::Init()
63{
64//
65// reset the existing file environment and open a new root file if
66// the pointer to the Fluka tree is null
67
68 TFile *pFile=0;
69 if (!pFile) {
70 pFile = new TFile(fFileName);
71 pFile->cd();
72 printf("\n I have opened %s file \n", fFileName);
73 }
74// get the tree address in the Fluka boundary source file
75 fTreeNtuple = (TTree*)gDirectory->Get("h1");
76 TTree *h1=fTreeNtuple;
77 h1->SetMakeClass(1);
78//Set branch addresses
79 h1->SetBranchAddress("nev", &fNev);
80 h1->SetBranchAddress("x", fX);
81 h1->SetBranchAddress("xtyp", fXtyp);
82 h1->SetBranchAddress("npart", &fNpart);
83 h1->SetBranchAddress("xpt", fXpt);
84 h1->SetBranchAddress("xeta", fXeta);
85 h1->SetBranchAddress("xphi", fXphi);
86 h1->SetBranchAddress("xid", fXid);
87 h1->SetBranchAddress("njet", &fNjet);
88 h1->SetBranchAddress("jet", fJet);
89 h1->SetBranchAddress("jeta", fJeta);
90 h1->SetBranchAddress("jphi", fJphi);
91 h1->SetBranchAddress("nsjet", &fNsjet);
92 h1->SetBranchAddress("jset", fJset);
93 h1->SetBranchAddress("jseta", fJseta);
94 h1->SetBranchAddress("jsphi", fJsphi);
95 h1->SetBranchAddress("npjet", &fNpjet);
96 h1->SetBranchAddress("jpet", fJpet);
97 h1->SetBranchAddress("jpeta", fJpeta);
98 h1->SetBranchAddress("jpphi", fJpphi);
99}
100
101Int_t AliGenReaderEcalJets::NextEvent()
102{
103// Read the next event
58323221 104 Int_t nTracks=0, nread=0;
b152a071 105
106 TFile* pFile = fTreeNtuple->GetCurrentFile();
107 pFile->cd();
108
109 Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
110 if (fNcurrent < nentries) {
111 Int_t nb = (Int_t)fTreeNtuple->GetEvent(fNcurrent);
112 nread += nb;
113 fNcurrent++;
114 printf("\n Next event contains %d tracks! \n", fNpjet);
115 nTracks = fNpjet;
116 fNparticle = 0;
117 return nTracks;
118 }
119 return 0;
120}
121
122TParticle* AliGenReaderEcalJets::NextParticle()
123{
b152a071 124// Read the next particle
93de1f83 125
126 Float_t p[4];
b152a071 127 Int_t ipart = fXid[fNparticle];
128 Float_t pt = fXpt[fNparticle];
129 Float_t eta = fXeta[fNparticle];
130 Float_t phi = fXphi[fNparticle];
131 Float_t theta = 2.*TMath::ATan(TMath::Exp(-eta));
132 Double_t amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
133
134 p[0] = pt*TMath::Sin(phi);
135 p[1] = pt*TMath::Cos(phi);
136 p[2] = pt/TMath::Cos(theta);
137 p[3] = TMath::Sqrt(pt*pt+p[2]*p[2]+amass*amass);
138
139
140 TParticle* particle =
141 new TParticle(ipart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3],
142 0., 0., 0., 0.);
143 fNparticle++;
144 return particle;
145}
146
147
148
149AliGenReaderEcalJets& AliGenReaderEcalJets::operator=(const AliGenReaderEcalJets& rhs)
150{
151// Assignment operator
198bb1c7 152 rhs.Copy(*this);
153 return (*this);
b152a071 154}
155
dc1d768c 156void AliGenReaderEcalJets::Copy(TObject&) const
198bb1c7 157{
158 //
159 // Copy
160 //
161 Fatal("Copy","Not implemented!\n");
162}
163
164
b152a071 165
166
167
168
169