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 **************************************************************************/
18 // Realisation of AliGenReader to be used with AliGenExtFile
19 // It reads Hijing 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
25 #include <TParticle.h>
27 #include <TVirtualMC.h>
29 #include "AliGenReaderEcalHijing.h"
31 ClassImp(AliGenReaderEcalHijing)
34 AliGenReaderEcalHijing::AliGenReaderEcalHijing()
36 // Default constructor
41 void AliGenReaderEcalHijing::Init()
44 // reset the existing file environment and open a new root file if
45 // the pointer to the Fluka tree is null
49 pFile = new TFile(fFileName);
51 printf("\n I have opened %s file \n", fFileName);
53 // get the tree address in the Fluka boundary source file
54 fTreeNtuple = (TTree*)gDirectory->Get("h2");
55 TTree *h2=fTreeNtuple;
57 //Set branch addresses
58 h2->SetBranchAddress("njatt", &fNjatt);
59 h2->SetBranchAddress("nahij", &fNahij);
60 h2->SetBranchAddress("nphij", &fNphij);
61 h2->SetBranchAddress("khij", fKhij) ;
62 h2->SetBranchAddress("pxhij", fPxhij);
63 h2->SetBranchAddress("pyhij", fPyhij);
64 h2->SetBranchAddress("pzhij", fPzhij);
65 h2->SetBranchAddress("ehij", fEhij) ;
68 Int_t AliGenReaderEcalHijing::NextEvent()
70 // Read the next event
71 Int_t nTracks=0, nread=0;
73 TFile* pFile = fTreeNtuple->GetCurrentFile();
76 Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
77 if (fNcurrent < nentries) {
78 Int_t nb = (Int_t)fTreeNtuple->GetEvent(fNcurrent);
81 printf("\n Next event contains %d tracks! \n", fNphij);
89 TParticle* AliGenReaderEcalHijing::NextParticle()
91 // Read the next particle
94 Int_t ipart = fKhij[fNparticle];
95 p[0] = fPxhij[fNparticle];
96 p[1] = fPyhij[fNparticle];
97 p[2] = fPzhij[fNparticle];
98 p[3] = fEhij[fNparticle];
100 Double_t amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
103 Warning("Generate","Particle %d E = %f mass = %f \n",
106 TParticle* particle =
107 new TParticle(ipart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3],
115 AliGenReaderEcalHijing& AliGenReaderEcalHijing::operator=(const AliGenReaderEcalHijing& rhs)
117 // Assignment operator
122 void AliGenReaderEcalHijing::Copy(TObject&) const
127 Fatal("Copy","Not implemented!\n");