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 // Author: Davide Perrino <davide.perrino@cern.ch>
20 //-------------------------------------------------------------------------
23 #include <Riostream.h>
25 #include <TLorentzVector.h>
29 #include "AliJetAODReader.h"
30 #include "AliJetAODReaderHeader.h"
31 #include "AliAODEvent.h"
32 #include "AliAODTrack.h"
34 ClassImp(AliJetAODReader)
36 AliJetAODReader::AliJetAODReader():
47 //____________________________________________________________________________
49 AliJetAODReader::~AliJetAODReader()
57 //____________________________________________________________________________
59 void AliJetAODReader::OpenInputFiles()
61 // Open the necessary input files
63 fChain = new TChain("aodTree");
65 // get directory and pattern name from the header
66 const char* dirName=fReaderHeader->GetDirectory();
67 const char* pattern=fReaderHeader->GetPattern();
69 // // Add files matching patters to the chain
71 void *dir = gSystem->OpenDirectory(dirName);
72 const char *name = 0x0;
73 int naod = ((AliJetAODReaderHeader*) fReaderHeader)->GetNaod();
75 while ((name = gSystem->GetDirEntry(dir))){
76 if (a>=naod) continue;
78 if (strstr(name,pattern)){
80 sprintf(path,"%s/%s/aod.root",dirName,name);
81 fChain->AddFile(path);
86 gSystem->FreeDirectory(dir);
90 fChain->SetBranchAddress("AOD",&fAOD);
92 int nMax = fChain->GetEntries();
94 printf("\n AliJetAODReader: Total number of events in chain= %d \n",nMax);
96 // set number of events in header
97 if (fReaderHeader->GetLastEvent() == -1)
98 fReaderHeader->SetLastEvent(nMax);
100 Int_t nUsr = fReaderHeader->GetLastEvent();
101 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
105 //____________________________________________________________________________
107 void AliJetAODReader::ConnectTree(TTree* tree, TObject* /*data*/) {
109 // For AOD reader it's needed only to set the number of events
110 fChain = (TChain*) tree;
112 Int_t nMax = fChain->GetEntries();
113 printf("\n AliJetAODReader: Total number of events in chain= %5d \n", nMax);
114 // set number of events in header
115 if (fReaderHeader->GetLastEvent() == -1)
116 fReaderHeader->SetLastEvent(nMax);
118 Int_t nUsr = fReaderHeader->GetLastEvent();
119 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
123 //____________________________________________________________________________
125 Bool_t AliJetAODReader::FillMomentumArray()
127 // Clear momentum array
129 fDebug = fReaderHeader->GetDebug();
135 // get number of tracks in event (for the loop)
136 Int_t nt = fAOD->GetNTracks();
137 printf("AOD tracks: %5d ", nt);
139 // temporary storage of signal and pt cut flag
140 Int_t* sflag = new Int_t[nt];
141 Int_t* cflag = new Int_t[nt];
143 // get cuts set by user
144 Float_t ptMin = fReaderHeader->GetPtCut();
145 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
146 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
147 UInt_t filterMask = ((AliJetAODReaderHeader*)fReaderHeader)->GetTestFilterMask();
153 for (Int_t it = 0; it < nt; it++) {
154 AliAODTrack *track = fAOD->GetTrack(it);
156 Double_t mom[3] = {track->Px(),track->Py(),track->Pz()};
157 p3.SetXYZ(mom[0],mom[1],mom[2]);
160 if((filterMask>0)&&!(track->TestFilterBit(filterMask)))continue;
161 if ( pt < ptMin ) continue; // checking pt cut
162 if ( (eta > etaMax) || (eta < etaMin)) continue; // checking eta cut
165 new ((*fMomentumArray)[aodTrack++]) TLorentzVector(p3,p3.Mag());
168 printf("Used AOD tracks: %5d ", aodTrack);
169 // set the signal flags
170 fSignalFlag.Set(aodTrack,sflag);
171 fCutFlag.Set(aodTrack,cflag);