]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/AliJetParticlesReader.cxx
Using AliLog (F.Carminati)
[u/mrichter/AliRoot.git] / JETAN / AliJetParticlesReader.cxx
CommitLineData
d7c6ab14 1// $Id$
2
3//_________________________________________________________________________
4///////////////////////////////////////////////////////////////////////////
5d60c8f9 5// //
6// class AliJetParticlesReader //
7// //
8// This reader reads tracks from Event Summary Data //
9// taken from Piotr.Skowronski@cern.ch //
10// more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html //
11// //
12// loizides@ikf.uni-frankfurt.de //
d7c6ab14 13///////////////////////////////////////////////////////////////////////////
14
5d60c8f9 15#include <TClass.h>
d7c6ab14 16#include <TObjArray.h>
17#include <TClonesArray.h>
d7c6ab14 18#include <TString.h>
19#include <TObjString.h>
5f0d5628 20#include <TTree.h>
d7c6ab14 21#include "AliJetEventParticles.h"
22#include "AliJetParticlesReader.h"
23
24
25ClassImp(AliJetParticlesReader)
26
27AliJetParticlesReader::AliJetParticlesReader()
28 : TNamed(),
29 fEventParticles(0),
30 fOwner(kTRUE),
31 fDirs(0),
32 fCurrentEvent(0),
33 fCurrentDir(0),
34 fNEventsRead(0),
35 fFirst(0),
36 fLast(0),
37 fPtMin(0),fPtMax(1000),
38 fEtaMin(-1),fEtaMax(1),
5f0d5628 39 fPhiMin(0),fPhiMax(2*TMath::Pi()),
40 fNewTree(0),
41 fTree(0)
d7c6ab14 42{
5d60c8f9 43 //Constructor
d7c6ab14 44}
45
46AliJetParticlesReader::AliJetParticlesReader(TObjArray *dirs)
47 : TNamed(),
48 fEventParticles(0),
49 fOwner(kTRUE),
50 fDirs(dirs),
51 fCurrentEvent(0),
52 fCurrentDir(0),
53 fNEventsRead(0),
54 fFirst(0),
55 fLast(0),
56 fPtMin(0),fPtMax(1000),
57 fEtaMin(-1),fEtaMax(1),
5f0d5628 58 fPhiMin(0),fPhiMax(2*TMath::Pi()),
59 fNewTree(0),
60 fTree(0)
d7c6ab14 61{
62}
63
64AliJetParticlesReader::~AliJetParticlesReader()
65{
5d60c8f9 66 //Constructor
d7c6ab14 67 if((fOwner) && (fEventParticles)) delete fEventParticles;
68}
69
70Int_t AliJetParticlesReader::Next()
71{
72 //moves to next event
d7c6ab14 73 //if asked to read up to event nb. fLast,
74 //and it is overcome, report no more events
75 if ((fNEventsRead > fLast) && (fLast > 0) ) return kFALSE;
76
77 do //if asked to read from event fFirst, rewind to it
78 {
79 if ( ReadNext() == kFALSE)
80 return kFALSE; //if no more evets, return it
81 } while (fNEventsRead < fFirst);
82
83 //here we have event
5f0d5628 84 if(fTree && fEventParticles){
85 if(fNewTree){
b9a6a391 86 fTree->Branch("particles","AliJetEventParticles",&fEventParticles,32000,99);
5f0d5628 87 fNewTree=0;
88 }
a86edc4e 89 fEventParticles->SetEventNr(fCurrentDir*1000+fCurrentEvent);
5f0d5628 90 fTree->Fill();
91 }
d7c6ab14 92 return kTRUE;
93}
94
95TString& AliJetParticlesReader::GetDirName(Int_t entry)
96{
97 //returns directory name of entry to read
d7c6ab14 98 TString* retval;//return value
99 if (fDirs == 0)
100 {
101 retval = new TString(".");
102 return *retval;
04a02430 103 }
d7c6ab14 104
105 if ((entry>fDirs->GetEntries()) || (entry<0))
04a02430 106 //if out of bounds return empty string
107 //note that entry==0 is accepted even if array is empty (size=0)
d7c6ab14 108 {
109 Error("GetDirName","Entry out of bounds");
110 retval = new TString();
111 return *retval;
112 }
113
114 if (fDirs->GetEntries() == 0)
115 {
116 retval = new TString(".");
117 return *retval;
118 }
119
120 TClass *objclass = fDirs->At(entry)->IsA();
121 TClass *stringclass = TObjString::Class();
122
123 TObjString *dir = (TObjString*)objclass->DynamicCast(stringclass,fDirs->At(entry));
124 if(dir == 0)
125 {
126 Error("GetDirName","Object in TObjArray is not a TObjString");
127 retval = new TString();
128 return *retval;
129 }
130
131 //Info("GetDirName","Returned ok %s",dir->String().Data());
132 return dir->String();
133}
134