]>
Commit | Line | Data |
---|---|---|
586f2bc3 | 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 | // Jet AOD Reader | |
18 | // AOD reader for jet analysis | |
e53baffe | 19 | // This is the reader which must be used if the jet analysis task |
20 | // is executed after the ESD filter task, in order to read its output | |
21 | // | |
586f2bc3 | 22 | // Author: Davide Perrino <davide.perrino@cern.ch> |
23 | //------------------------------------------------------------------------- | |
24 | ||
25 | ||
26 | #include <Riostream.h> | |
27 | #include <TSystem.h> | |
28 | #include <TLorentzVector.h> | |
29 | #include <TVector3.h> | |
ee7de0dd | 30 | #include <TChain.h> |
31 | ||
586f2bc3 | 32 | #include "AliJetAODReader.h" |
33 | #include "AliJetAODReaderHeader.h" | |
34 | #include "AliAODEvent.h" | |
35 | #include "AliAODTrack.h" | |
36 | ||
37 | ClassImp(AliJetAODReader) | |
38 | ||
39 | AliJetAODReader::AliJetAODReader(): | |
40 | AliJetReader(), | |
41 | fChain(0x0), | |
42 | fAOD(0x0), | |
43 | fRef(new TRefArray), | |
44 | fDebug(0), | |
45 | fOpt(0) | |
46 | { | |
47 | // Constructor | |
48 | } | |
49 | ||
50 | //____________________________________________________________________________ | |
51 | ||
52 | AliJetAODReader::~AliJetAODReader() | |
53 | { | |
54 | // Destructor | |
55 | delete fChain; | |
56 | delete fAOD; | |
57 | delete fRef; | |
58 | } | |
59 | ||
60 | //____________________________________________________________________________ | |
61 | ||
62 | void AliJetAODReader::OpenInputFiles() | |
63 | { | |
64 | // Open the necessary input files | |
65 | // chain for the AODs | |
66 | fChain = new TChain("aodTree"); | |
67 | ||
68 | // get directory and pattern name from the header | |
69 | const char* dirName=fReaderHeader->GetDirectory(); | |
70 | const char* pattern=fReaderHeader->GetPattern(); | |
71 | ||
72 | // // Add files matching patters to the chain | |
73 | ||
74 | void *dir = gSystem->OpenDirectory(dirName); | |
75 | const char *name = 0x0; | |
76 | int naod = ((AliJetAODReaderHeader*) fReaderHeader)->GetNaod(); | |
77 | int a = 0; | |
78 | while ((name = gSystem->GetDirEntry(dir))){ | |
79 | if (a>=naod) continue; | |
80 | ||
81 | if (strstr(name,pattern)){ | |
82 | char path[256]; | |
83 | sprintf(path,"%s/%s/aod.root",dirName,name); | |
84 | fChain->AddFile(path); | |
85 | a++; | |
86 | } | |
87 | } | |
88 | ||
89 | gSystem->FreeDirectory(dir); | |
90 | ||
91 | ||
92 | fAOD = 0; | |
93 | fChain->SetBranchAddress("AOD",&fAOD); | |
94 | ||
95 | int nMax = fChain->GetEntries(); | |
96 | ||
3bfae526 | 97 | if(fDebug>1)printf("\n AliJetAODReader::OpenInputFiles Total number of events in chain= %d \n",nMax); |
586f2bc3 | 98 | |
99 | // set number of events in header | |
100 | if (fReaderHeader->GetLastEvent() == -1) | |
101 | fReaderHeader->SetLastEvent(nMax); | |
102 | else { | |
103 | Int_t nUsr = fReaderHeader->GetLastEvent(); | |
104 | fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr)); | |
105 | } | |
106 | } | |
107 | ||
108 | //____________________________________________________________________________ | |
109 | ||
110 | void AliJetAODReader::ConnectTree(TTree* tree, TObject* /*data*/) { | |
111 | // Connect the tree | |
112 | // For AOD reader it's needed only to set the number of events | |
113 | fChain = (TChain*) tree; | |
114 | ||
115 | Int_t nMax = fChain->GetEntries(); | |
3bfae526 | 116 | if(fDebug>1)printf("\n AliJetAODReader::ConnectTree Total number of events in chain= %5d \n", nMax); |
586f2bc3 | 117 | // set number of events in header |
118 | if (fReaderHeader->GetLastEvent() == -1) | |
119 | fReaderHeader->SetLastEvent(nMax); | |
120 | else { | |
121 | Int_t nUsr = fReaderHeader->GetLastEvent(); | |
122 | fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr)); | |
123 | } | |
124 | } | |
125 | ||
126 | //____________________________________________________________________________ | |
127 | ||
9e4cc50d | 128 | Bool_t AliJetAODReader::FillMomentumArray() |
586f2bc3 | 129 | { |
130 | // Clear momentum array | |
131 | ClearArray(); | |
e53baffe | 132 | fRef->Clear(); |
586f2bc3 | 133 | fDebug = fReaderHeader->GetDebug(); |
134 | ||
135 | if (!fAOD) { | |
136 | return kFALSE; | |
137 | } | |
138 | ||
139 | // get number of tracks in event (for the loop) | |
140 | Int_t nt = fAOD->GetNTracks(); | |
3bfae526 | 141 | if(fDebug>2)printf(" AliJetAODReader::FillMomentumArray AOD tracks: %5d \t", nt); |
586f2bc3 | 142 | |
143 | // temporary storage of signal and pt cut flag | |
144 | Int_t* sflag = new Int_t[nt]; | |
145 | Int_t* cflag = new Int_t[nt]; | |
146 | ||
147 | // get cuts set by user | |
148 | Float_t ptMin = fReaderHeader->GetPtCut(); | |
149 | Float_t etaMin = fReaderHeader->GetFiducialEtaMin(); | |
150 | Float_t etaMax = fReaderHeader->GetFiducialEtaMax(); | |
d61f057d | 151 | UInt_t filterMask = ((AliJetAODReaderHeader*)fReaderHeader)->GetTestFilterMask(); |
e53baffe | 152 | |
586f2bc3 | 153 | //loop over tracks |
154 | Int_t aodTrack = 0; | |
155 | Float_t pt, eta; | |
156 | TVector3 p3; | |
d61f057d | 157 | |
586f2bc3 | 158 | for (Int_t it = 0; it < nt; it++) { |
d61f057d | 159 | AliAODTrack *track = fAOD->GetTrack(it); |
e53baffe | 160 | UInt_t status = track->GetStatus(); |
d61f057d | 161 | |
162 | Double_t mom[3] = {track->Px(),track->Py(),track->Pz()}; | |
163 | p3.SetXYZ(mom[0],mom[1],mom[2]); | |
164 | pt = p3.Pt(); | |
165 | eta = p3.Eta(); | |
e53baffe | 166 | if (status == 0) continue; |
d61f057d | 167 | if((filterMask>0)&&!(track->TestFilterBit(filterMask)))continue; |
d61f057d | 168 | if ( (eta > etaMax) || (eta < etaMin)) continue; // checking eta cut |
e53baffe | 169 | |
170 | new ((*fMomentumArray)[aodTrack]) TLorentzVector(p3,p3.Mag()); | |
171 | sflag[aodTrack] = (TMath::Abs(track->GetLabel()) < 10000) ? 1 : 0; | |
172 | cflag[aodTrack] = ( pt > ptMin ) ? 1: 0; | |
173 | aodTrack++; | |
d61f057d | 174 | fRef->Add(track); |
586f2bc3 | 175 | } |
3bfae526 | 176 | if(fDebug>2)printf("Used AOD tracks: %5d \n", aodTrack); |
586f2bc3 | 177 | // set the signal flags |
178 | fSignalFlag.Set(aodTrack,sflag); | |
179 | fCutFlag.Set(aodTrack,cflag); | |
d61f057d | 180 | |
680ed75f | 181 | delete [] sflag; |
182 | delete [] cflag; | |
d61f057d | 183 | |
586f2bc3 | 184 | return kTRUE; |
185 | } |