Added hard partons.
[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>
20
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),
39 fPhiMin(0),fPhiMax(2*TMath::Pi())
40{
5d60c8f9 41 //Constructor
d7c6ab14 42}
43
44AliJetParticlesReader::AliJetParticlesReader(TObjArray *dirs)
45 : TNamed(),
46 fEventParticles(0),
47 fOwner(kTRUE),
48 fDirs(dirs),
49 fCurrentEvent(0),
50 fCurrentDir(0),
51 fNEventsRead(0),
52 fFirst(0),
53 fLast(0),
54 fPtMin(0),fPtMax(1000),
55 fEtaMin(-1),fEtaMax(1),
56 fPhiMin(0),fPhiMax(2*TMath::Pi())
57{
58}
59
60AliJetParticlesReader::~AliJetParticlesReader()
61{
5d60c8f9 62 //Constructor
d7c6ab14 63 if((fOwner) && (fEventParticles)) delete fEventParticles;
64}
65
66Int_t AliJetParticlesReader::Next()
67{
68 //moves to next event
d7c6ab14 69 //if asked to read up to event nb. fLast,
70 //and it is overcome, report no more events
71 if ((fNEventsRead > fLast) && (fLast > 0) ) return kFALSE;
72
73 do //if asked to read from event fFirst, rewind to it
74 {
75 if ( ReadNext() == kFALSE)
76 return kFALSE; //if no more evets, return it
77 } while (fNEventsRead < fFirst);
78
79 //here we have event
80
81 return kTRUE;
82}
83
84TString& AliJetParticlesReader::GetDirName(Int_t entry)
85{
86 //returns directory name of entry to read
d7c6ab14 87 TString* retval;//return value
88 if (fDirs == 0)
89 {
90 retval = new TString(".");
91 return *retval;
04a02430 92 }
d7c6ab14 93
94 if ((entry>fDirs->GetEntries()) || (entry<0))
04a02430 95 //if out of bounds return empty string
96 //note that entry==0 is accepted even if array is empty (size=0)
d7c6ab14 97 {
98 Error("GetDirName","Entry out of bounds");
99 retval = new TString();
100 return *retval;
101 }
102
103 if (fDirs->GetEntries() == 0)
104 {
105 retval = new TString(".");
106 return *retval;
107 }
108
109 TClass *objclass = fDirs->At(entry)->IsA();
110 TClass *stringclass = TObjString::Class();
111
112 TObjString *dir = (TObjString*)objclass->DynamicCast(stringclass,fDirs->At(entry));
113 if(dir == 0)
114 {
115 Error("GetDirName","Object in TObjArray is not a TObjString");
116 retval = new TString();
117 return *retval;
118 }
119
120 //Info("GetDirName","Returned ok %s",dir->String().Data());
121 return dir->String();
122}
123