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 // ESD reader for jet analysis
19 // Author: Mercedes Lopez Noriega (mercedes.lopez.noriega@cern.ch)
20 //-------------------------------------------------------------------------
23 #include <Riostream.h>
25 #include <TLorentzVector.h>
27 #include "AliJetESDReader.h"
28 #include "AliJetESDReaderHeader.h"
30 #include "AliESDtrack.h"
32 ClassImp(AliJetESDReader)
34 AliJetESDReader::AliJetESDReader():
42 //____________________________________________________________________________
44 AliJetESDReader::~AliJetESDReader()
49 //____________________________________________________________________________
51 void AliJetESDReader::OpenInputFiles()
54 fChain = new TChain("esdTree");
56 // get directory and pattern name from the header
57 const char* dirName=fReaderHeader->GetDirectory();
58 const char* pattern=fReaderHeader->GetPattern();
60 // Add files matching patters to the chain
61 void *dir = gSystem->OpenDirectory(dirName);
62 const char *name = 0x0;
63 int nesd = fReaderHeader->GetNesd();
65 while ((name = gSystem->GetDirEntry(dir))){
66 if (a>=nesd) continue;
67 if (strstr(name,pattern)){
68 printf("Adding %s\n",name);
70 sprintf(path,"%s/%s",dirName,name);
71 fChain->AddFile(path,-1);
75 printf("%d ESDs added\n",a);
77 gSystem->FreeDirectory(dir);
78 fChain->SetBranchAddress("ESD", &fESD);
80 int nMax = fChain->GetEntries();
81 printf("\nTotal number of events in chain= %d",nMax);
83 // set number of events in header
84 if (fReaderHeader->GetLastEvent() == -1)
85 fReaderHeader->SetLastEvent(nMax);
87 Int_t nUsr = fReaderHeader->GetLastEvent();
88 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
92 //____________________________________________________________________________
94 void AliJetESDReader::FillMomentumArray(Int_t event)
96 // Fill momentum array
103 // clear momentum array
106 // get event from chain
107 fChain->GetEntry(event);
109 // get number of tracks in event (for the loop)
110 nt = fESD->GetNumberOfTracks();
112 // temporary storage of signal and pt cut flag
113 Int_t* sflag = new Int_t[nt];
114 Int_t* cflag = new Int_t[nt];
116 // get cuts set by user
117 Float_t ptMin = fReaderHeader->GetPtCut();
118 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
119 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
122 for (Int_t it = 0; it < nt; it++) {
123 AliESDtrack *track = fESD->GetTrack(it);
124 UInt_t status = track->GetStatus();
127 track->GetPxPyPz(mom);
128 p3.SetXYZ(mom[0],mom[1],mom[2]);
130 if ((status & AliESDtrack::kTPCrefit) == 0) continue; // quality check
131 //if ((status & AliESDtrack::kITSrefit) == 0) continue; // quality check
132 if (((AliJetESDReaderHeader*) fReaderHeader)->ReadSignalOnly()
133 && TMath::Abs(track->GetLabel()) > 10000) continue; // quality check
134 if (((AliJetESDReaderHeader*) fReaderHeader)->ReadBkgdOnly()
135 && TMath::Abs(track->GetLabel()) < 10000) continue; // quality check
137 if ( (eta > etaMax) || (eta < etaMin)) continue; // checking eta cut
139 new ((*fMomentumArray)[goodTrack]) TLorentzVector(p3,p3.Mag());
141 if (TMath::Abs(track->GetLabel()) < 10000) sflag[goodTrack]=1;
143 if (pt > ptMin) cflag[goodTrack]=1; // pt cut
146 // set the signal flags
147 fSignalFlag.Set(goodTrack,sflag);
148 fCutFlag.Set(goodTrack,cflag);