1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //-------------------------------------------------------------------------
18 // AOD reader for jet analysis
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
22 // Author: Davide Perrino <davide.perrino@cern.ch>
23 //-------------------------------------------------------------------------
26 #include <Riostream.h>
28 #include <TLorentzVector.h>
32 #include "AliJetAODReader.h"
33 #include "AliJetAODReaderHeader.h"
34 #include "AliAODEvent.h"
35 #include "AliAODTrack.h"
37 ClassImp(AliJetAODReader)
39 AliJetAODReader::AliJetAODReader():
50 //____________________________________________________________________________
52 AliJetAODReader::~AliJetAODReader()
60 //____________________________________________________________________________
62 void AliJetAODReader::OpenInputFiles()
64 // Open the necessary input files
66 fChain = new TChain("aodTree");
68 // get directory and pattern name from the header
69 const char* dirName=fReaderHeader->GetDirectory();
70 const char* pattern=fReaderHeader->GetPattern();
72 // // Add files matching patters to the chain
74 void *dir = gSystem->OpenDirectory(dirName);
75 const char *name = 0x0;
76 int naod = ((AliJetAODReaderHeader*) fReaderHeader)->GetNaod();
78 while ((name = gSystem->GetDirEntry(dir))){
79 if (a>=naod) continue;
81 if (strstr(name,pattern)){
83 sprintf(path,"%s/%s/aod.root",dirName,name);
84 fChain->AddFile(path);
89 gSystem->FreeDirectory(dir);
93 fChain->SetBranchAddress("AOD",&fAOD);
95 int nMax = fChain->GetEntries();
97 printf("\n AliJetAODReader: Total number of events in chain= %d \n",nMax);
99 // set number of events in header
100 if (fReaderHeader->GetLastEvent() == -1)
101 fReaderHeader->SetLastEvent(nMax);
103 Int_t nUsr = fReaderHeader->GetLastEvent();
104 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
108 //____________________________________________________________________________
110 void AliJetAODReader::ConnectTree(TTree* tree, TObject* /*data*/) {
112 // For AOD reader it's needed only to set the number of events
113 fChain = (TChain*) tree;
115 Int_t nMax = fChain->GetEntries();
116 printf("\n AliJetAODReader: Total number of events in chain= %5d \n", nMax);
117 // set number of events in header
118 if (fReaderHeader->GetLastEvent() == -1)
119 fReaderHeader->SetLastEvent(nMax);
121 Int_t nUsr = fReaderHeader->GetLastEvent();
122 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
126 //____________________________________________________________________________
128 Bool_t AliJetAODReader::FillMomentumArray()
130 // Clear momentum array
133 fDebug = fReaderHeader->GetDebug();
139 // get number of tracks in event (for the loop)
140 Int_t nt = fAOD->GetNTracks();
141 printf("AOD tracks: %5d \t", nt);
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];
147 // get cuts set by user
148 Float_t ptMin = fReaderHeader->GetPtCut();
149 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
150 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
151 UInt_t filterMask = ((AliJetAODReaderHeader*)fReaderHeader)->GetTestFilterMask();
158 for (Int_t it = 0; it < nt; it++) {
159 AliAODTrack *track = fAOD->GetTrack(it);
160 UInt_t status = track->GetStatus();
162 Double_t mom[3] = {track->Px(),track->Py(),track->Pz()};
163 p3.SetXYZ(mom[0],mom[1],mom[2]);
166 if (status == 0) continue;
167 if((filterMask>0)&&!(track->TestFilterBit(filterMask)))continue;
168 if ( (eta > etaMax) || (eta < etaMin)) continue; // checking eta cut
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;
176 printf("Used AOD tracks: %5d \n", aodTrack);
177 // set the signal flags
178 fSignalFlag.Set(aodTrack,sflag);
179 fCutFlag.Set(aodTrack,cflag);