]>
Commit | Line | Data |
---|---|---|
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 | ||
32 | ClassImp(AliJetESDReader) | |
33 | ||
1994c1b0 | 34 | AliJetESDReader::AliJetESDReader() |
99e5fe42 | 35 | { |
36 | // Constructor | |
99e5fe42 | 37 | fReaderHeader = 0x0; |
38 | fMass = 0; | |
39 | fSign = 0; | |
40 | } | |
41 | ||
42 | //____________________________________________________________________________ | |
43 | ||
44 | AliJetESDReader::~AliJetESDReader() | |
45 | { | |
46 | // Destructor | |
99e5fe42 | 47 | } |
48 | ||
49 | //____________________________________________________________________________ | |
50 | ||
51 | void AliJetESDReader::OpenInputFiles() | |
1994c1b0 | 52 | |
99e5fe42 | 53 | { |
54 | // chain for the ESDs | |
55 | fChain = new TChain("esdTree"); | |
99e5fe42 | 56 | |
57 | // get directory and pattern name from the header | |
58 | const char* dirName=fReaderHeader->GetDirectory(); | |
59 | const char* pattern=fReaderHeader->GetPattern(); | |
60 | ||
61 | // Add files matching patters to the chain | |
62 | void *dir = gSystem->OpenDirectory(dirName); | |
63 | const char *name = 0x0; | |
1994c1b0 | 64 | int nesd = fReaderHeader->GetNesd(); |
65 | int a = 0; | |
99e5fe42 | 66 | while ((name = gSystem->GetDirEntry(dir))){ |
1994c1b0 | 67 | if (a>=nesd) continue; |
99e5fe42 | 68 | if (strstr(name,pattern)){ |
69 | printf("Adding %s\n",name); | |
70 | char path[256]; | |
71 | sprintf(path,"%s/%s",dirName,name); | |
83a444b1 | 72 | fChain->AddFile(path,-1); |
1994c1b0 | 73 | a++; |
74 | } | |
99e5fe42 | 75 | } |
1994c1b0 | 76 | printf("%d ESDs added\n",a); |
77 | ||
78 | gSystem->FreeDirectory(dir); | |
79 | fChain->SetBranchAddress("ESD", &fESD); | |
80 | ||
99e5fe42 | 81 | int nMax = fChain->GetEntries(); |
82 | printf("\nTotal number of events in chain= %d",nMax); | |
1994c1b0 | 83 | |
99e5fe42 | 84 | // set number of events in header |
85 | if (fReaderHeader->GetLastEvent() == -1) | |
86 | fReaderHeader->SetLastEvent(nMax); | |
87 | else { | |
88 | Int_t nUsr = fReaderHeader->GetLastEvent(); | |
89 | fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr)); | |
90 | } | |
91 | } | |
92 | ||
93 | //____________________________________________________________________________ | |
94 | ||
95 | void AliJetESDReader::FillMomentumArray(Int_t event) | |
96 | { | |
1994c1b0 | 97 | // Fill momentum array |
98 | ||
99e5fe42 | 99 | Int_t goodTrack = 0; |
100 | Int_t nt = 0; | |
83a444b1 | 101 | Float_t pt, eta; |
102 | TVector3 p3; | |
1994c1b0 | 103 | |
99e5fe42 | 104 | // clear momentum array |
105 | ClearArray(); | |
1994c1b0 | 106 | |
99e5fe42 | 107 | // get event from chain |
108 | fChain->GetEntry(event); | |
1994c1b0 | 109 | |
99e5fe42 | 110 | // get number of tracks in event (for the loop) |
111 | nt = fESD->GetNumberOfTracks(); | |
1994c1b0 | 112 | |
113 | // temporary storage of signal and pt cut flag | |
83a444b1 | 114 | Int_t* sflag = new Int_t[nt]; |
115 | Int_t* cflag = new Int_t[nt]; | |
1994c1b0 | 116 | |
99e5fe42 | 117 | // get cuts set by user |
83a444b1 | 118 | Float_t ptMin = fReaderHeader->GetPtCut(); |
119 | Float_t etaMin = fReaderHeader->GetFiducialEtaMin(); | |
120 | Float_t etaMax = fReaderHeader->GetFiducialEtaMax(); | |
1994c1b0 | 121 | |
99e5fe42 | 122 | //loop over tracks |
123 | for (Int_t it = 0; it < nt; it++) { | |
1994c1b0 | 124 | AliESDtrack *track = fESD->GetTrack(it); |
125 | UInt_t status = track->GetStatus(); | |
126 | ||
127 | Double_t mom[3]; | |
128 | track->GetPxPyPz(mom); | |
129 | p3.SetXYZ(mom[0],mom[1],mom[2]); | |
130 | pt = p3.Pt(); | |
131 | if (((status & AliESDtrack::kITSrefit) == 0) || | |
132 | ((status & AliESDtrack::kTPCrefit) == 0)) continue; // quality check | |
133 | if (((AliJetESDReaderHeader*) fReaderHeader)->ReadSignalOnly() | |
134 | && TMath::Abs(track->GetLabel()) > 10000) continue; // quality check | |
135 | if (((AliJetESDReaderHeader*) fReaderHeader)->ReadBkgdOnly() | |
136 | && TMath::Abs(track->GetLabel()) < 10000) continue; // quality check | |
137 | eta = p3.Eta(); | |
138 | if ( (eta > etaMax) || (eta < etaMin)) continue; // checking eta cut | |
139 | ||
140 | new ((*fMomentumArray)[goodTrack]) TLorentzVector(p3,p3.Mag()); | |
141 | sflag[goodTrack]=0; | |
142 | if (TMath::Abs(track->GetLabel()) < 10000) sflag[goodTrack]=1; | |
143 | cflag[goodTrack]=0; | |
144 | if (pt > ptMin) cflag[goodTrack]=1; // pt cut | |
145 | goodTrack++; | |
99e5fe42 | 146 | } |
8011d399 | 147 | // set the signal flags |
83a444b1 | 148 | fSignalFlag.Set(goodTrack,sflag); |
149 | fCutFlag.Set(goodTrack,cflag); | |
99e5fe42 | 150 | } |
151 | ||
152 |