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 **************************************************************************/
18 // ESD reader for jet analysis
19 // Author: Mercedes Lopez Noriega
20 // mercedes.lopez.noriega@cern.ch
24 #include <Riostream.h>
26 #include <TLorentzVector.h>
27 #include "AliJetESDReader.h"
28 #include "AliJetESDReaderHeader.h"
30 #include "AliESDtrack.h"
32 ClassImp(AliJetESDReader)
34 AliJetESDReader::AliJetESDReader()
43 //____________________________________________________________________________
45 AliJetESDReader::~AliJetESDReader()
51 //____________________________________________________________________________
53 void AliJetESDReader::OpenInputFiles()
57 fChain = new TChain("esdTree");
58 fChainMC = new TChain("mcStackTree");
60 // get directory and pattern name from the header
61 const char* dirName=fReaderHeader->GetDirectory();
62 const char* pattern=fReaderHeader->GetPattern();
64 // Add files matching patters to the chain
65 void *dir = gSystem->OpenDirectory(dirName);
66 const char *name = 0x0;
67 while ((name = gSystem->GetDirEntry(dir))){
68 if (strstr(name,pattern)){
69 printf("Adding %s\n",name);
71 sprintf(path,"%s/%s",dirName,name);
72 fChain->AddFile(path,-1,"esdTree");
73 fChainMC->AddFile(path,-1,"mcStackTree");
77 gSystem ->FreeDirectory(dir);
78 fChain ->SetBranchAddress("ESD", &fESD);
79 fChainMC->SetBranchAddress("Header", &fAliHeader);
80 fChainMC->SetBranchAddress("Stack", &fArrayMC);
82 int nMax = fChain->GetEntries();
83 printf("\nTotal number of events in chain= %d",nMax);
85 // set number of events in header
86 if (fReaderHeader->GetLastEvent() == -1)
87 fReaderHeader->SetLastEvent(nMax);
89 Int_t nUsr = fReaderHeader->GetLastEvent();
90 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
94 //____________________________________________________________________________
96 void AliJetESDReader::FillMomentumArray(Int_t event)
98 // Fills the momentum array
102 Double_t p[3]; // track 3 momentum vector
104 // clear momentum array
106 // get event from chain
107 fChain->GetEntry(event);
108 fChainMC->GetEntry(event);
109 // get number of tracks in event (for the loop)
110 nt = fESD->GetNumberOfTracks();
111 // get cuts set by user
112 Float_t ptMin = ((AliJetESDReaderHeader*) fReaderHeader)->GetPtCut();
115 for (Int_t it = 0; it < nt; it++) {
116 AliESDtrack *track = fESD->GetTrack(it);
117 UInt_t status = track->GetStatus();
118 if ((status & AliESDtrack::kITSrefit) == 0) continue; // quality check
120 if (((AliJetESDReaderHeader*) fReaderHeader)->ReadSignalOnly() && TMath::Abs(track->GetLabel()) > 10000) continue;
123 pt = TMath::Sqrt(p[0] * p[0] + p[1] * p[1]); // pt of the track
125 if (pt < ptMin) continue; //check cuts
127 new ((*fMomentumArray)[goodTrack])
128 TLorentzVector(p[0], p[1], p[2],
129 TMath::Sqrt(pt * pt +p[2] * p[2]));
133 printf("\nIn event %d, number of good tracks %d \n", event, goodTrack);