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