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