]>
Commit | Line | Data |
---|---|---|
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 | |
925e6570 | 32 | ClassImp(AliGenReaderCwn) |
f24650c5 | 33 | |
34 | ||
35 | AliGenReaderCwn::AliGenReaderCwn() | |
36 | { | |
37 | // Default constructor | |
38 | fNcurrent = 0; | |
39 | fTreeNtuple = 0; | |
40 | } | |
41 | ||
ae872676 | 42 | AliGenReaderCwn::~AliGenReaderCwn() |
43 | { | |
44 | delete fTreeNtuple; | |
45 | } | |
46 | ||
f24650c5 | 47 | void AliGenReaderCwn::Init() |
48 | { | |
49 | // | |
50 | // reset the existing file environment and open a new root file if | |
51 | // the pointer to the Fluka tree is null | |
52 | ||
53 | TFile *pFile=0; | |
54 | if (!pFile) { | |
55 | pFile = new TFile(fFileName); | |
56 | pFile->cd(); | |
57 | printf("\n I have opened %s file \n", fFileName); | |
58 | } | |
59 | // get the tree address in the Fluka boundary source file | |
60 | fTreeNtuple = (TTree*)gDirectory->Get("h888"); | |
61 | ||
62 | TTree *h2=fTreeNtuple; | |
63 | //Set branch addresses | |
64 | h2->SetBranchAddress("Nihead",&fNihead); | |
65 | h2->SetBranchAddress("Ihead",fIhead); | |
66 | h2->SetBranchAddress("Nrhead",&fNrhead); | |
67 | h2->SetBranchAddress("Rhead",fRhead); | |
68 | h2->SetBranchAddress("Idpart",&fIdpart); | |
69 | h2->SetBranchAddress("Theta",&fTheta); | |
70 | h2->SetBranchAddress("Phi",&fPhi); | |
71 | h2->SetBranchAddress("P",&fP); | |
72 | h2->SetBranchAddress("E",&fE); | |
73 | } | |
74 | ||
75 | Int_t AliGenReaderCwn::NextEvent() | |
76 | { | |
77 | // Read the next event | |
78 | Int_t nTracks; | |
79 | fNparticle = 0; | |
80 | TFile* pFile = fTreeNtuple->GetCurrentFile(); | |
81 | pFile->cd(); | |
82 | ||
83 | Int_t nentries = (Int_t) fTreeNtuple->GetEntries(); | |
84 | if (fNcurrent < nentries) { | |
f24650c5 | 85 | fNcurrent++; |
86 | ||
87 | Int_t i5=fIhead[4]; | |
88 | Int_t i6=fIhead[5]; | |
89 | if (i5==0) { | |
90 | printf("\n This should never happen !\n"); | |
91 | nTracks = 0; | |
92 | } else { | |
93 | printf("\n Next event contains %d tracks! \n", i6); | |
94 | nTracks = i6; | |
95 | } | |
96 | fNparticleMax = nTracks; | |
97 | return nTracks; | |
f24650c5 | 98 | } |
4facea7f | 99 | |
f24650c5 | 100 | return 0; |
101 | } | |
102 | ||
103 | TParticle* AliGenReaderCwn::NextParticle() | |
104 | { | |
105 | // | |
106 | // | |
107 | Float_t prwn; | |
108 | Float_t p[4]; | |
109 | // Read the next particle | |
110 | if (fCode == kGEANT3) fIdpart=gMC->PDGFromId(fIdpart); | |
111 | Double_t amass = TDatabasePDG::Instance()->GetParticle(fIdpart)->Mass(); | |
112 | if(fE<=amass) { | |
113 | Warning("Generate","Particle %d E = %f mass = %f %f %f \n", | |
114 | fIdpart,fE,amass, fPhi, fTheta); | |
115 | prwn=0; | |
116 | } else { | |
117 | prwn=sqrt((fE+amass)*(fE-amass)); | |
118 | } | |
119 | ||
120 | fTheta *= TMath::Pi()/180.; | |
121 | fPhi = (fPhi-180)*TMath::Pi()/180.; | |
122 | p[0] = prwn*TMath::Sin(fTheta)*TMath::Cos(fPhi); | |
123 | p[1] = prwn*TMath::Sin(fTheta)*TMath::Sin(fPhi); | |
124 | p[2] = prwn*TMath::Cos(fTheta); | |
125 | p[3] = fE; | |
159ec319 | 126 | TParticle* particle = new TParticle(fIdpart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3], 0., 0., 0., 0.); |
f24650c5 | 127 | fNcurrent++; |
128 | fNparticle++; | |
129 | return particle; | |
130 | } | |
131 | ||
132 | ||
133 | ||
ae872676 | 134 | AliGenReaderCwn& AliGenReaderCwn::operator=(const AliGenReaderCwn& rhs) |
135 | { | |
136 | // Assignment operator | |
198bb1c7 | 137 | rhs.Copy(*this); |
ae872676 | 138 | return *this; |
139 | } | |
f24650c5 | 140 | |
dc1d768c | 141 | void AliGenReaderCwn::Copy(TObject&) const |
198bb1c7 | 142 | { |
143 | // | |
144 | // Copy | |
145 | // | |
146 | Fatal("Copy","Not implemented!\n"); | |
147 | } | |
148 | ||
149 | ||
f24650c5 | 150 | |
151 |