]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/AliJetESDReader.cxx
track matching macros from Alberto
[u/mrichter/AliRoot.git] / JETAN / AliJetESDReader.cxx
CommitLineData
99e5fe42 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
1994c1b0 15
16//-------------------------------------------------------------------------
99e5fe42 17// Jet ESD Reader
18// ESD reader for jet analysis
83a444b1 19// Author: Mercedes Lopez Noriega (mercedes.lopez.noriega@cern.ch)
1994c1b0 20//-------------------------------------------------------------------------
21
99e5fe42 22
23#include <Riostream.h>
24#include <TSystem.h>
25#include <TLorentzVector.h>
83a444b1 26#include <TVector3.h>
99e5fe42 27#include "AliJetESDReader.h"
28#include "AliJetESDReaderHeader.h"
29#include "AliESD.h"
30#include "AliESDtrack.h"
31
32ClassImp(AliJetESDReader)
33
1b7d5d7e 34AliJetESDReader::AliJetESDReader():
35 fMass(0),
36 fSign(0)
99e5fe42 37{
38 // Constructor
99e5fe42 39 fReaderHeader = 0x0;
99e5fe42 40}
41
42//____________________________________________________________________________
43
44AliJetESDReader::~AliJetESDReader()
45{
46 // Destructor
99e5fe42 47}
48
49//____________________________________________________________________________
50
51void AliJetESDReader::OpenInputFiles()
99e5fe42 52{
53 // chain for the ESDs
54 fChain = new TChain("esdTree");
99e5fe42 55
56 // get directory and pattern name from the header
57 const char* dirName=fReaderHeader->GetDirectory();
58 const char* pattern=fReaderHeader->GetPattern();
59
60 // Add files matching patters to the chain
61 void *dir = gSystem->OpenDirectory(dirName);
62 const char *name = 0x0;
1994c1b0 63 int nesd = fReaderHeader->GetNesd();
64 int a = 0;
99e5fe42 65 while ((name = gSystem->GetDirEntry(dir))){
1994c1b0 66 if (a>=nesd) continue;
99e5fe42 67 if (strstr(name,pattern)){
68 printf("Adding %s\n",name);
69 char path[256];
70 sprintf(path,"%s/%s",dirName,name);
83a444b1 71 fChain->AddFile(path,-1);
1994c1b0 72 a++;
73 }
99e5fe42 74 }
1994c1b0 75 printf("%d ESDs added\n",a);
76
77 gSystem->FreeDirectory(dir);
78 fChain->SetBranchAddress("ESD", &fESD);
79
99e5fe42 80 int nMax = fChain->GetEntries();
81 printf("\nTotal number of events in chain= %d",nMax);
1994c1b0 82
99e5fe42 83 // set number of events in header
84 if (fReaderHeader->GetLastEvent() == -1)
85 fReaderHeader->SetLastEvent(nMax);
86 else {
87 Int_t nUsr = fReaderHeader->GetLastEvent();
88 fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr));
89 }
90}
91
92//____________________________________________________________________________
93
94void AliJetESDReader::FillMomentumArray(Int_t event)
95{
1994c1b0 96 // Fill momentum array
97
99e5fe42 98 Int_t goodTrack = 0;
99 Int_t nt = 0;
83a444b1 100 Float_t pt, eta;
101 TVector3 p3;
1994c1b0 102
99e5fe42 103 // clear momentum array
104 ClearArray();
1994c1b0 105
99e5fe42 106 // get event from chain
107 fChain->GetEntry(event);
1994c1b0 108
99e5fe42 109 // get number of tracks in event (for the loop)
110 nt = fESD->GetNumberOfTracks();
1994c1b0 111
112 // temporary storage of signal and pt cut flag
83a444b1 113 Int_t* sflag = new Int_t[nt];
114 Int_t* cflag = new Int_t[nt];
1994c1b0 115
99e5fe42 116 // get cuts set by user
83a444b1 117 Float_t ptMin = fReaderHeader->GetPtCut();
118 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
119 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
1994c1b0 120
99e5fe42 121 //loop over tracks
122 for (Int_t it = 0; it < nt; it++) {
1994c1b0 123 AliESDtrack *track = fESD->GetTrack(it);
124 UInt_t status = track->GetStatus();
125
126 Double_t mom[3];
127 track->GetPxPyPz(mom);
128 p3.SetXYZ(mom[0],mom[1],mom[2]);
129 pt = p3.Pt();
1b7d5d7e 130 if ((status & AliESDtrack::kTPCrefit) == 0) continue; // quality check
131 //if ((status & AliESDtrack::kITSrefit) == 0) continue; // quality check
1994c1b0 132 if (((AliJetESDReaderHeader*) fReaderHeader)->ReadSignalOnly()
1b7d5d7e 133 && TMath::Abs(track->GetLabel()) > 10000) continue; // quality check
1994c1b0 134 if (((AliJetESDReaderHeader*) fReaderHeader)->ReadBkgdOnly()
1b7d5d7e 135 && TMath::Abs(track->GetLabel()) < 10000) continue; // quality check
1994c1b0 136 eta = p3.Eta();
137 if ( (eta > etaMax) || (eta < etaMin)) continue; // checking eta cut
138
139 new ((*fMomentumArray)[goodTrack]) TLorentzVector(p3,p3.Mag());
140 sflag[goodTrack]=0;
141 if (TMath::Abs(track->GetLabel()) < 10000) sflag[goodTrack]=1;
142 cflag[goodTrack]=0;
143 if (pt > ptMin) cflag[goodTrack]=1; // pt cut
144 goodTrack++;
99e5fe42 145 }
8011d399 146 // set the signal flags
83a444b1 147 fSignalFlag.Set(goodTrack,sflag);
148 fCutFlag.Set(goodTrack,cflag);
99e5fe42 149}
150
151