]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenReaderEcalHijing.cxx
AliRICHDetectV1 added.
[u/mrichter/AliRoot.git] / EVGEN / AliGenReaderEcalHijing.cxx
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 /*
17 $Log$
18 */
19
20 #include <TFile.h>
21 #include <TTree.h>
22 #include <TParticle.h>
23
24 #include "AliGenReaderEcalHijing.h"
25 #include "AliMC.h"
26 ClassImp(AliGenReaderEcalHijing)
27
28
29 AliGenReaderEcalHijing::AliGenReaderEcalHijing() 
30 {
31 // Default constructor
32     fNcurrent   = 0;
33     fTreeNtuple = 0;
34 }
35
36 void AliGenReaderEcalHijing::Init() 
37 {
38 //
39 // reset the existing file environment and open a new root file if
40 // the pointer to the Fluka tree is null
41     
42     TFile *pFile=0;
43     if (!pFile) {
44         pFile = new TFile(fFileName);
45         pFile->cd();
46         printf("\n I have opened %s file \n", fFileName);
47     }
48 // get the tree address in the Fluka boundary source file
49     fTreeNtuple = (TTree*)gDirectory->Get("h2");
50     TTree *h2=fTreeNtuple;
51     h2->SetMakeClass(1);
52 //Set branch addresses
53     h2->SetBranchAddress("njatt", &fNjatt);
54     h2->SetBranchAddress("nahij", &fNahij);
55     h2->SetBranchAddress("nphij", &fNphij);
56     h2->SetBranchAddress("khij",   fKhij) ;
57     h2->SetBranchAddress("pxhij",  fPxhij);
58     h2->SetBranchAddress("pyhij",  fPyhij);
59     h2->SetBranchAddress("pzhij",  fPzhij);
60     h2->SetBranchAddress("ehij",   fEhij) ;
61 }
62
63 Int_t AliGenReaderEcalHijing::NextEvent() 
64 {
65 // Read the next event  
66     Int_t nTracks, nread;
67     
68     TFile* pFile = fTreeNtuple->GetCurrentFile();
69     pFile->cd();
70
71     Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
72     if (fNcurrent < nentries) {
73         Int_t nb = (Int_t)fTreeNtuple->GetEvent(fNcurrent);
74         nread += nb;
75         fNcurrent++;
76         printf("\n Next event contains %d tracks! \n", fNphij);
77         nTracks    = fNphij;
78         fNparticle = 0;
79         return nTracks;
80     }
81     return 0;
82 }
83
84 TParticle* AliGenReaderEcalHijing::NextParticle() 
85 {
86     Float_t p[4];
87 // Read the next particle
88     Int_t ipart = fKhij[fNparticle];
89     p[0] = fPxhij[fNparticle];
90     p[1] = fPyhij[fNparticle];      
91     p[2] = fPzhij[fNparticle];
92     p[3] = fEhij[fNparticle];
93     
94     Double_t amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
95
96     if(p[3] <= amass) {
97         Warning("Generate","Particle %d  E = %f mass = %f \n",
98                 ipart, p[3], amass);
99     } 
100     TParticle* particle = 
101         new TParticle(ipart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3], 
102                       0., 0., 0., 0.);
103     fNparticle++;
104     return particle;
105 }
106
107
108
109 AliGenReaderEcalHijing& AliGenReaderEcalHijing::operator=(const  AliGenReaderEcalHijing& rhs)
110 {
111 // Assignment operator
112     return *this;
113 }
114
115
116
117
118
119