]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenReaderEcalJets.cxx
Configuration of pt-kick added.
[u/mrichter/AliRoot.git] / EVGEN / AliGenReaderEcalJets.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 Revision 1.1  2002/01/08 09:59:34  morsch
19 Readers for EMCAL primary particle input.
20
21 */
22
23 #include <TFile.h>
24 #include <TTree.h>
25 #include <TParticle.h>
26
27 #include "AliGenReaderEcalJets.h"
28 #include "AliMC.h"
29 ClassImp(AliGenReaderEcalJets)
30
31
32 AliGenReaderEcalJets::AliGenReaderEcalJets() 
33 {
34 // Default constructor
35     fNcurrent   = 0;
36     fTreeNtuple = 0;
37 }
38
39 void AliGenReaderEcalJets::Init() 
40 {
41 //
42 // reset the existing file environment and open a new root file if
43 // the pointer to the Fluka tree is null
44     
45     TFile *pFile=0;
46     if (!pFile) {
47         pFile = new TFile(fFileName);
48         pFile->cd();
49         printf("\n I have opened %s file \n", fFileName);
50     }
51 // get the tree address in the Fluka boundary source file
52     fTreeNtuple = (TTree*)gDirectory->Get("h1");
53     TTree *h1=fTreeNtuple;
54     h1->SetMakeClass(1);
55 //Set branch addresses
56     h1->SetBranchAddress("nev",   &fNev);
57     h1->SetBranchAddress("x",      fX);
58     h1->SetBranchAddress("xtyp",   fXtyp);
59     h1->SetBranchAddress("npart", &fNpart);
60     h1->SetBranchAddress("xpt",    fXpt);
61     h1->SetBranchAddress("xeta",   fXeta);
62     h1->SetBranchAddress("xphi",   fXphi);
63     h1->SetBranchAddress("xid",    fXid);
64     h1->SetBranchAddress("njet",  &fNjet);
65     h1->SetBranchAddress("jet",    fJet);
66     h1->SetBranchAddress("jeta",   fJeta);
67     h1->SetBranchAddress("jphi",   fJphi);
68     h1->SetBranchAddress("nsjet", &fNsjet);
69     h1->SetBranchAddress("jset",   fJset);
70     h1->SetBranchAddress("jseta",  fJseta);
71     h1->SetBranchAddress("jsphi",  fJsphi);
72     h1->SetBranchAddress("npjet", &fNpjet);
73     h1->SetBranchAddress("jpet",   fJpet);
74     h1->SetBranchAddress("jpeta",  fJpeta);
75     h1->SetBranchAddress("jpphi",  fJpphi);
76 }
77
78 Int_t AliGenReaderEcalJets::NextEvent() 
79 {
80 // Read the next event  
81     Int_t nTracks=0, nread=0;
82     
83     TFile* pFile = fTreeNtuple->GetCurrentFile();
84     pFile->cd();
85
86     Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
87     if (fNcurrent < nentries) {
88         Int_t nb = (Int_t)fTreeNtuple->GetEvent(fNcurrent);
89         nread += nb;
90         fNcurrent++;
91         printf("\n Next event contains %d tracks! \n", fNpjet);
92         nTracks    = fNpjet;
93         fNparticle = 0;
94         return nTracks;
95     }
96     return 0;
97 }
98
99 TParticle* AliGenReaderEcalJets::NextParticle() 
100 {
101     Float_t p[4];
102 // Read the next particle
103     Int_t    ipart  = fXid[fNparticle];
104     Float_t  pt     = fXpt[fNparticle];
105     Float_t  eta    = fXeta[fNparticle];
106     Float_t  phi    = fXphi[fNparticle];
107     Float_t  theta  = 2.*TMath::ATan(TMath::Exp(-eta));
108     Double_t amass  = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
109
110     p[0] = pt*TMath::Sin(phi);
111     p[1] = pt*TMath::Cos(phi);      
112     p[2] = pt/TMath::Cos(theta);
113     p[3] = TMath::Sqrt(pt*pt+p[2]*p[2]+amass*amass);
114     
115
116     TParticle* particle = 
117         new TParticle(ipart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3], 
118                       0., 0., 0., 0.);
119     fNparticle++;
120     return particle;
121 }
122
123
124
125 AliGenReaderEcalJets& AliGenReaderEcalJets::operator=(const  AliGenReaderEcalJets& rhs)
126 {
127 // Assignment operator
128     return *this;
129 }
130
131
132
133
134
135