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>
27 #include "AliJetAODReader.h"
28 #include "AliJetAODReaderHeader.h"
29 #include "AliAODEvent.h"
30 #include "AliAODTrack.h"
32 ClassImp(AliJetAODReader)
34 AliJetAODReader::AliJetAODReader():
45 //____________________________________________________________________________
47 AliJetAODReader::~AliJetAODReader()
55 //____________________________________________________________________________
57 void AliJetAODReader::OpenInputFiles()
59 // Open the necessary input files
61 fChain = new TChain("aodTree");
63 // get directory and pattern name from the header
64 const char* dirName=fReaderHeader->GetDirectory();
65 const char* pattern=fReaderHeader->GetPattern();
67 // // Add files matching patters to the chain
69 void *dir = gSystem->OpenDirectory(dirName);
70 const char *name = 0x0;
71 int naod = ((AliJetAODReaderHeader*) fReaderHeader)->GetNaod();
73 while ((name = gSystem->GetDirEntry(dir))){
74 if (a>=naod) continue;
76 if (strstr(name,pattern)){
78 sprintf(path,"%s/%s/aod.root",dirName,name);
79 fChain->AddFile(path);
84 gSystem->FreeDirectory(dir);
88 fChain->SetBranchAddress("AOD",&fAOD);
90 int nMax = fChain->GetEntries();
92 printf("\n AliJetAODReader: Total number of events in chain= %d \n",nMax);
94 // set number of events in header
95 if (fReaderHeader->GetLastEvent() == -1)
96 fReaderHeader->SetLastEvent(nMax);
98 Int_t nUsr = fReaderHeader->GetLastEvent();
99 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
103 //____________________________________________________________________________
105 void AliJetAODReader::ConnectTree(TTree* tree, TObject* /*data*/) {
107 // For AOD reader it's needed only to set the number of events
108 fChain = (TChain*) tree;
110 Int_t nMax = fChain->GetEntries();
111 printf("\n AliJetAODReader: Total number of events in chain= %5d \n", nMax);
112 // set number of events in header
113 if (fReaderHeader->GetLastEvent() == -1)
114 fReaderHeader->SetLastEvent(nMax);
116 Int_t nUsr = fReaderHeader->GetLastEvent();
117 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
121 //____________________________________________________________________________
123 Bool_t AliJetAODReader::FillMomentumArray(Int_t /*event*/)
125 // Clear momentum array
127 fDebug = fReaderHeader->GetDebug();
133 // get number of tracks in event (for the loop)
134 Int_t nt = fAOD->GetNTracks();
135 printf("Fill Momentum Array %5d ", nt);
137 // temporary storage of signal and pt cut flag
138 Int_t* sflag = new Int_t[nt];
139 Int_t* cflag = new Int_t[nt];
141 // get cuts set by user
142 Float_t ptMin = fReaderHeader->GetPtCut();
143 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
144 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
150 for (Int_t it = 0; it < nt; it++) {
151 AliAODTrack *track = fAOD->GetTrack(it);
153 Double_t mom[3] = {track->Px(),track->Py(),track->Pz()};
154 p3.SetXYZ(mom[0],mom[1],mom[2]);
157 if ( pt < ptMin ) continue; // checking pt cut
158 if ( (eta > etaMax) || (eta < etaMin)) continue; // checking eta cut
161 new ((*fMomentumArray)[aodTrack++]) TLorentzVector(p3,p3.Mag());
164 // set the signal flags
165 fSignalFlag.Set(aodTrack,sflag);
166 fCutFlag.Set(aodTrack,cflag);