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 Revision 1.3 2002/10/21 09:20:51 alibrary
20 Introduce Riostream.h and remove unused variables
22 Revision 1.2 2001/11/12 14:31:00 morsch
23 Memory leaks fixed. (M. Bondila)
25 Revision 1.1 2001/11/09 09:10:46 morsch
26 Realisation of AliGenReader that reads the old cwn event format.
30 // Read the old ALICE event format based on CW-ntuples
31 // http://consult.cern.ch/alice/Internal_Notes/1995/32/abstract
32 // .cwn file have to be converted to .root using h2root
33 // Use SetFileName(file) to read from "file"
34 // Author: andreas.morsch@cern.ch
38 #include <TParticle.h>
40 #include "AliGenReaderCwn.h"
42 ClassImp(AliGenReaderCwn);
45 AliGenReaderCwn::AliGenReaderCwn()
47 // Default constructor
52 AliGenReaderCwn::~AliGenReaderCwn()
57 void AliGenReaderCwn::Init()
60 // reset the existing file environment and open a new root file if
61 // the pointer to the Fluka tree is null
65 pFile = new TFile(fFileName);
67 printf("\n I have opened %s file \n", fFileName);
69 // get the tree address in the Fluka boundary source file
70 fTreeNtuple = (TTree*)gDirectory->Get("h888");
72 TTree *h2=fTreeNtuple;
73 //Set branch addresses
74 h2->SetBranchAddress("Nihead",&fNihead);
75 h2->SetBranchAddress("Ihead",fIhead);
76 h2->SetBranchAddress("Nrhead",&fNrhead);
77 h2->SetBranchAddress("Rhead",fRhead);
78 h2->SetBranchAddress("Idpart",&fIdpart);
79 h2->SetBranchAddress("Theta",&fTheta);
80 h2->SetBranchAddress("Phi",&fPhi);
81 h2->SetBranchAddress("P",&fP);
82 h2->SetBranchAddress("E",&fE);
85 Int_t AliGenReaderCwn::NextEvent()
87 // Read the next event
90 TFile* pFile = fTreeNtuple->GetCurrentFile();
93 Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
94 if (fNcurrent < nentries) {
100 printf("\n This should never happen !\n");
103 printf("\n Next event contains %d tracks! \n", i6);
106 fNparticleMax = nTracks;
113 TParticle* AliGenReaderCwn::NextParticle()
119 // Read the next particle
120 if (fCode == kGEANT3) fIdpart=gMC->PDGFromId(fIdpart);
121 Double_t amass = TDatabasePDG::Instance()->GetParticle(fIdpart)->Mass();
123 Warning("Generate","Particle %d E = %f mass = %f %f %f \n",
124 fIdpart,fE,amass, fPhi, fTheta);
127 prwn=sqrt((fE+amass)*(fE-amass));
130 fTheta *= TMath::Pi()/180.;
131 fPhi = (fPhi-180)*TMath::Pi()/180.;
132 p[0] = prwn*TMath::Sin(fTheta)*TMath::Cos(fPhi);
133 p[1] = prwn*TMath::Sin(fTheta)*TMath::Sin(fPhi);
134 p[2] = prwn*TMath::Cos(fTheta);
136 TParticle* particle = new TParticle(fIdpart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3], 0., 0., 0., 0.);
144 AliGenReaderCwn& AliGenReaderCwn::operator=(const AliGenReaderCwn& rhs)
146 // Assignment operator