]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenReaderCwn.cxx
Correction to the ALTRO mapping inside the inner ROC (Stefan Kniege)
[u/mrichter/AliRoot.git] / EVGEN / AliGenReaderCwn.cxx
CommitLineData
f24650c5 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
88cb7938 17/* $Id$ */
f24650c5 18
19// Read the old ALICE event format based on CW-ntuples
20// http://consult.cern.ch/alice/Internal_Notes/1995/32/abstract
21// .cwn file have to be converted to .root using h2root
22// Use SetFileName(file) to read from "file"
23// Author: andreas.morsch@cern.ch
24
25#include <TFile.h>
f24650c5 26#include <TParticle.h>
88cb7938 27#include <TTree.h>
acc86a24 28#include <TVirtualMC.h>
f24650c5 29
30#include "AliGenReaderCwn.h"
88cb7938 31
706938e6 32ClassImp(AliGenReaderCwn)
f24650c5 33
1c56e311 34AliGenReaderCwn::AliGenReaderCwn():
35 fNcurrent(0),
36 fNparticle(0),
37 fNparticleMax(0),
38 fTreeNtuple(0),
39 fNihead(0),
40 fNrhead(0),
41 fIdpart(0),
42 fTheta(0.),
43 fPhi(0.),
44 fP(0.),
45 fE(0.)
f24650c5 46{
47// Default constructor
f24650c5 48}
49
1c56e311 50AliGenReaderCwn::AliGenReaderCwn(const AliGenReaderCwn &reader):
51 AliGenReader(reader),
52 fNcurrent(0),
53 fNparticle(0),
54 fNparticleMax(0),
55 fTreeNtuple(0),
56 fNihead(0),
57 fNrhead(0),
58 fIdpart(0),
59 fTheta(0.),
60 fPhi(0.),
61 fP(0.),
62 fE(0.)
63{
64 // Copy constructor
65 reader.Copy(*this);
66}
67
68
ae872676 69AliGenReaderCwn::~AliGenReaderCwn()
70{
71 delete fTreeNtuple;
72}
73
f24650c5 74void AliGenReaderCwn::Init()
75{
76//
77// reset the existing file environment and open a new root file if
78// the pointer to the Fluka tree is null
79
80 TFile *pFile=0;
81 if (!pFile) {
82 pFile = new TFile(fFileName);
83 pFile->cd();
84 printf("\n I have opened %s file \n", fFileName);
85 }
86// get the tree address in the Fluka boundary source file
87 fTreeNtuple = (TTree*)gDirectory->Get("h888");
88
89 TTree *h2=fTreeNtuple;
90//Set branch addresses
91 h2->SetBranchAddress("Nihead",&fNihead);
92 h2->SetBranchAddress("Ihead",fIhead);
93 h2->SetBranchAddress("Nrhead",&fNrhead);
94 h2->SetBranchAddress("Rhead",fRhead);
95 h2->SetBranchAddress("Idpart",&fIdpart);
96 h2->SetBranchAddress("Theta",&fTheta);
97 h2->SetBranchAddress("Phi",&fPhi);
98 h2->SetBranchAddress("P",&fP);
99 h2->SetBranchAddress("E",&fE);
100}
101
102Int_t AliGenReaderCwn::NextEvent()
103{
104// Read the next event
105 Int_t nTracks;
106 fNparticle = 0;
107 TFile* pFile = fTreeNtuple->GetCurrentFile();
108 pFile->cd();
109
110 Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
111 if (fNcurrent < nentries) {
f24650c5 112 fNcurrent++;
113
114 Int_t i5=fIhead[4];
115 Int_t i6=fIhead[5];
116 if (i5==0) {
117 printf("\n This should never happen !\n");
118 nTracks = 0;
119 } else {
120 printf("\n Next event contains %d tracks! \n", i6);
121 nTracks = i6;
122 }
123 fNparticleMax = nTracks;
124 return nTracks;
f24650c5 125 }
4facea7f 126
f24650c5 127 return 0;
128}
129
130TParticle* AliGenReaderCwn::NextParticle()
131{
132//
133//
134 Float_t prwn;
135 Float_t p[4];
136// Read the next particle
137 if (fCode == kGEANT3) fIdpart=gMC->PDGFromId(fIdpart);
138 Double_t amass = TDatabasePDG::Instance()->GetParticle(fIdpart)->Mass();
139 if(fE<=amass) {
140 Warning("Generate","Particle %d E = %f mass = %f %f %f \n",
141 fIdpart,fE,amass, fPhi, fTheta);
142 prwn=0;
143 } else {
144 prwn=sqrt((fE+amass)*(fE-amass));
145 }
146
147 fTheta *= TMath::Pi()/180.;
148 fPhi = (fPhi-180)*TMath::Pi()/180.;
149 p[0] = prwn*TMath::Sin(fTheta)*TMath::Cos(fPhi);
150 p[1] = prwn*TMath::Sin(fTheta)*TMath::Sin(fPhi);
151 p[2] = prwn*TMath::Cos(fTheta);
152 p[3] = fE;
159ec319 153 TParticle* particle = new TParticle(fIdpart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3], 0., 0., 0., 0.);
f24650c5 154 fNcurrent++;
155 fNparticle++;
156 return particle;
157}
158
159
160
ae872676 161AliGenReaderCwn& AliGenReaderCwn::operator=(const AliGenReaderCwn& rhs)
162{
163// Assignment operator
198bb1c7 164 rhs.Copy(*this);
ae872676 165 return *this;
166}
f24650c5 167
dc1d768c 168void AliGenReaderCwn::Copy(TObject&) const
198bb1c7 169{
170 //
171 // Copy
172 //
173 Fatal("Copy","Not implemented!\n");
174}
175
176
f24650c5 177
178