1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
26 #include <TParticle.h>
27 #include <TDatabasePDG.h>
29 #include <TVirtualMC.h>
31 #include "AliGenReaderCwn.h"
33 ClassImp(AliGenReaderCwn)
35 AliGenReaderCwn::AliGenReaderCwn():
48 // Default constructor
50 for (i = 0; i < 6; i++) fRhead[i] = 0.;
51 for (i = 0; i < 12; i++) fIhead[i] = 0;
55 AliGenReaderCwn::AliGenReaderCwn(const AliGenReaderCwn &reader):
71 for (i = 0; i < 6; i++) fRhead[i] = 0.;
72 for (i = 0; i < 12; i++) fIhead[i] = 0;
77 AliGenReaderCwn::~AliGenReaderCwn()
82 void AliGenReaderCwn::Init()
85 // reset the existing file environment and open a new root file if
86 // the pointer to the Fluka tree is null
90 pFile = new TFile(fFileName);
92 printf("\n I have opened %s file \n", fFileName);
94 // get the tree address in the Fluka boundary source file
95 fTreeNtuple = (TTree*)gDirectory->Get("h888");
97 TTree *h2=fTreeNtuple;
98 //Set branch addresses
99 h2->SetBranchAddress("Nihead",&fNihead);
100 h2->SetBranchAddress("Ihead",fIhead);
101 h2->SetBranchAddress("Nrhead",&fNrhead);
102 h2->SetBranchAddress("Rhead",fRhead);
103 h2->SetBranchAddress("Idpart",&fIdpart);
104 h2->SetBranchAddress("Theta",&fTheta);
105 h2->SetBranchAddress("Phi",&fPhi);
106 h2->SetBranchAddress("P",&fP);
107 h2->SetBranchAddress("E",&fE);
110 Int_t AliGenReaderCwn::NextEvent()
112 // Read the next event
115 TFile* pFile = fTreeNtuple->GetCurrentFile();
118 Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
119 if (fNcurrent < nentries) {
125 printf("\n This should never happen !\n");
128 printf("\n Next event contains %d tracks! \n", i6);
131 fNparticleMax = nTracks;
138 TParticle* AliGenReaderCwn::NextParticle()
140 // Read next particle
144 // Read the next particle
145 if (fCode == kGEANT3) fIdpart=gMC->PDGFromId(fIdpart);
146 Double_t amass = TDatabasePDG::Instance()->GetParticle(fIdpart)->Mass();
148 Warning("Generate","Particle %d E = %f mass = %f %f %f \n",
149 fIdpart,fE,amass, fPhi, fTheta);
152 prwn=sqrt((fE+amass)*(fE-amass));
155 fTheta *= TMath::Pi()/180.;
156 fPhi = (fPhi-180)*TMath::Pi()/180.;
157 p[0] = prwn*TMath::Sin(fTheta)*TMath::Cos(fPhi);
158 p[1] = prwn*TMath::Sin(fTheta)*TMath::Sin(fPhi);
159 p[2] = prwn*TMath::Cos(fTheta);
161 TParticle* particle = new TParticle(fIdpart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3], 0., 0., 0., 0.);
169 AliGenReaderCwn& AliGenReaderCwn::operator=(const AliGenReaderCwn& rhs)
171 // Assignment operator
176 void AliGenReaderCwn::Copy(TObject&) const
181 Fatal("Copy","Not implemented!\n");