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 **************************************************************************/
17 // ESD reader for jet analysis
18 // Author: Mercedes Lopez Noriega (mercedes.lopez.noriega@cern.ch)
20 #include <Riostream.h>
22 #include <TLorentzVector.h>
24 #include "AliJetESDReader.h"
25 #include "AliJetESDReaderHeader.h"
27 #include "AliESDtrack.h"
29 ClassImp(AliJetESDReader)
31 AliJetESDReader::AliJetESDReader()
34 printf("\nIn reader constructor\n");
40 //____________________________________________________________________________
42 AliJetESDReader::~AliJetESDReader()
47 //____________________________________________________________________________
49 void AliJetESDReader::OpenInputFiles()
52 printf("\nOpening files\n");
54 fChain = new TChain("esdTree");
55 fChainMC = new TChain("mcStackTree");
57 // get directory and pattern name from the header
58 const char* dirName=fReaderHeader->GetDirectory();
59 const char* pattern=fReaderHeader->GetPattern();
61 // Add files matching patters to the chain
62 void *dir = gSystem->OpenDirectory(dirName);
63 const char *name = 0x0;
64 while ((name = gSystem->GetDirEntry(dir))){
65 if (strstr(name,pattern)){
66 printf("Adding %s\n",name);
68 sprintf(path,"%s/%s",dirName,name);
69 fChain->AddFile(path,-1);
70 fChainMC->AddFile(path,-1);
74 gSystem ->FreeDirectory(dir);
75 fChain ->SetBranchAddress("ESD", &fESD);
76 fChainMC->SetBranchAddress("Header", &fAliHeader);
77 fChainMC->SetBranchAddress("Stack", &fArrayMC);
79 int nMax = fChain->GetEntries();
80 printf("\nTotal number of events in chain= %d",nMax);
82 // set number of events in header
83 if (fReaderHeader->GetLastEvent() == -1)
84 fReaderHeader->SetLastEvent(nMax);
86 Int_t nUsr = fReaderHeader->GetLastEvent();
87 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
91 //____________________________________________________________________________
93 void AliJetESDReader::FillMomentumArray(Int_t event)
95 // Fill the momentum array for each track
101 // clear momentum array
104 // get event from chain
105 fChain->GetEntry(event);
106 fChainMC->GetEntry(event);
108 // get number of tracks in event (for the loop)
109 nt = fESD->GetNumberOfTracks();
111 // temporary storage of signal and pt cut flag
112 Int_t* sflag = new Int_t[nt];
113 Int_t* cflag = new Int_t[nt];
115 // get cuts set by user
116 Float_t ptMin = fReaderHeader->GetPtCut();
117 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
118 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
121 for (Int_t it = 0; it < nt; it++) {
122 AliESDtrack *track = fESD->GetTrack(it);
123 UInt_t status = track->GetStatus();
126 track->GetPxPyPz(mom);
128 p3.SetXYZ(mom[0],mom[1],mom[2]);
130 if (((status & AliESDtrack::kITSrefit) == 0) ||
131 ((status & AliESDtrack::kTPCrefit) == 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);
150 //printf("\nIn event %d, number of good tracks %d \n", event, goodTrack);