]>
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 | |
b45b0c92 | 19 | // Authors: Mercedes Lopez Noriega (mercedes.lopez.noriega@cern.ch) |
20 | // Magali Estienne <magali.estienne@IReS.in2p3.fr> | |
1994c1b0 | 21 | //------------------------------------------------------------------------- |
22 | ||
99e5fe42 | 23 | |
24 | #include <Riostream.h> | |
25 | #include <TSystem.h> | |
26 | #include <TLorentzVector.h> | |
83a444b1 | 27 | #include <TVector3.h> |
b45b0c92 | 28 | #include <TGeoManager.h> |
29 | ||
99e5fe42 | 30 | #include "AliJetESDReader.h" |
31 | #include "AliJetESDReaderHeader.h" | |
32 | #include "AliESD.h" | |
33 | #include "AliESDtrack.h" | |
5b81d1ce | 34 | //#include "AliEMCALGeometry.h" |
35 | #include "AliJetDummyGeo.h" | |
b45b0c92 | 36 | #include "AliJetFillUnitArrayTracks.h" |
37 | #include "AliJetUnitArray.h" | |
99e5fe42 | 38 | |
39 | ClassImp(AliJetESDReader) | |
40 | ||
1b7d5d7e | 41 | AliJetESDReader::AliJetESDReader(): |
b45b0c92 | 42 | AliJetReader(), |
43 | fGeom(0), | |
44 | fChain(0x0), | |
45 | fESD(0x0), | |
46 | fHadCorr(0x0), | |
47 | fTpcGrid(0x0), | |
48 | fEmcalGrid(0x0), | |
49 | fPtCut(0), | |
50 | fHCorrection(0), | |
51 | fNumUnits(0), | |
52 | fDebug(0), | |
53 | fNIn(0), | |
54 | fOpt(0), | |
55 | fNeta(0), | |
56 | fNphi(0), | |
57 | fArrayInitialised(0) | |
99e5fe42 | 58 | { |
59 | // Constructor | |
b45b0c92 | 60 | SetEMCALGeometry(); |
99e5fe42 | 61 | } |
62 | ||
63 | //____________________________________________________________________________ | |
64 | ||
65 | AliJetESDReader::~AliJetESDReader() | |
66 | { | |
67 | // Destructor | |
b45b0c92 | 68 | delete fChain; |
69 | delete fESD; | |
70 | delete fTpcGrid; | |
71 | delete fEmcalGrid; | |
99e5fe42 | 72 | } |
73 | ||
74 | //____________________________________________________________________________ | |
75 | ||
76 | void AliJetESDReader::OpenInputFiles() | |
99e5fe42 | 77 | { |
78 | // chain for the ESDs | |
79 | fChain = new TChain("esdTree"); | |
99e5fe42 | 80 | |
81 | // get directory and pattern name from the header | |
7d0f353c | 82 | const char* dirName=fReaderHeader->GetDirectory(); |
83 | const char* pattern=fReaderHeader->GetPattern(); | |
99e5fe42 | 84 | |
7d0f353c | 85 | // // Add files matching patters to the chain |
86 | ||
87 | void *dir = gSystem->OpenDirectory(dirName); | |
88 | const char *name = 0x0; | |
b45b0c92 | 89 | int nesd = ((AliJetESDReaderHeader*) fReaderHeader)->GetNesd(); |
7d0f353c | 90 | int a = 0; |
91 | while ((name = gSystem->GetDirEntry(dir))){ | |
92 | if (a>=nesd) continue; | |
93 | ||
94 | if (strstr(name,pattern)){ | |
95 | char path[256]; | |
96 | sprintf(path,"%s/%s/AliESDs.root",dirName,name); | |
97 | fChain->AddFile(path); | |
98 | a++; | |
99 | } | |
100 | } | |
1994c1b0 | 101 | |
102 | gSystem->FreeDirectory(dir); | |
7d0f353c | 103 | |
104 | ||
105 | fESD = 0; | |
1994c1b0 | 106 | fChain->SetBranchAddress("ESD", &fESD); |
107 | ||
99e5fe42 | 108 | int nMax = fChain->GetEntries(); |
7d0f353c | 109 | |
99e5fe42 | 110 | printf("\nTotal number of events in chain= %d",nMax); |
1994c1b0 | 111 | |
99e5fe42 | 112 | // set number of events in header |
113 | if (fReaderHeader->GetLastEvent() == -1) | |
114 | fReaderHeader->SetLastEvent(nMax); | |
115 | else { | |
116 | Int_t nUsr = fReaderHeader->GetLastEvent(); | |
117 | fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr)); | |
118 | } | |
119 | } | |
120 | ||
7d0f353c | 121 | void AliJetESDReader::ConnectTree(TTree* tree) { |
b45b0c92 | 122 | // Connect the tree |
7d0f353c | 123 | fChain = (TChain*) tree; |
124 | ||
125 | fChain->SetBranchAddress("ESD", &fESD); | |
126 | Int_t nMax = fChain->GetEntries(); | |
127 | printf("\nTotal number of events in chain= %5d", nMax); | |
128 | // set number of events in header | |
129 | if (fReaderHeader->GetLastEvent() == -1) | |
130 | fReaderHeader->SetLastEvent(nMax); | |
131 | else { | |
132 | Int_t nUsr = fReaderHeader->GetLastEvent(); | |
133 | fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr)); | |
134 | } | |
135 | } | |
136 | ||
99e5fe42 | 137 | //____________________________________________________________________________ |
138 | ||
7d0f353c | 139 | Bool_t AliJetESDReader::FillMomentumArray(Int_t event) |
99e5fe42 | 140 | { |
1994c1b0 | 141 | // Fill momentum array |
142 | ||
99e5fe42 | 143 | Int_t goodTrack = 0; |
144 | Int_t nt = 0; | |
83a444b1 | 145 | Float_t pt, eta; |
146 | TVector3 p3; | |
1994c1b0 | 147 | |
99e5fe42 | 148 | // clear momentum array |
7d0f353c | 149 | ClearArray(); |
b45b0c92 | 150 | fDebug = fReaderHeader->GetDebug(); |
151 | InitParameters(); | |
99e5fe42 | 152 | // get event from chain |
7d0f353c | 153 | fChain->GetTree()->GetEntry(event); |
154 | ||
155 | if (!fESD) { | |
156 | return kFALSE; | |
157 | } | |
1994c1b0 | 158 | |
99e5fe42 | 159 | // get number of tracks in event (for the loop) |
160 | nt = fESD->GetNumberOfTracks(); | |
1994c1b0 | 161 | // temporary storage of signal and pt cut flag |
83a444b1 | 162 | Int_t* sflag = new Int_t[nt]; |
163 | Int_t* cflag = new Int_t[nt]; | |
1994c1b0 | 164 | |
99e5fe42 | 165 | // get cuts set by user |
7d0f353c | 166 | Float_t ptMin = fReaderHeader->GetPtCut(); |
83a444b1 | 167 | Float_t etaMin = fReaderHeader->GetFiducialEtaMin(); |
168 | Float_t etaMax = fReaderHeader->GetFiducialEtaMax(); | |
1994c1b0 | 169 | |
99e5fe42 | 170 | //loop over tracks |
171 | for (Int_t it = 0; it < nt; it++) { | |
7d0f353c | 172 | AliESDtrack *track = fESD->GetTrack(it); |
173 | UInt_t status = track->GetStatus(); | |
174 | ||
175 | Double_t mom[3]; | |
176 | track->GetPxPyPz(mom); | |
177 | p3.SetXYZ(mom[0],mom[1],mom[2]); | |
178 | pt = p3.Pt(); | |
b45b0c92 | 179 | if ((status & AliESDtrack::kTPCrefit) == 0) continue; // quality check |
180 | if ((status & AliESDtrack::kITSrefit) == 0) continue; // quality check | |
7d0f353c | 181 | if (((AliJetESDReaderHeader*) fReaderHeader)->ReadSignalOnly() |
b45b0c92 | 182 | && TMath::Abs(track->GetLabel()) > 10000) continue; // quality check |
7d0f353c | 183 | if (((AliJetESDReaderHeader*) fReaderHeader)->ReadBkgdOnly() |
b45b0c92 | 184 | && TMath::Abs(track->GetLabel()) < 10000) continue; // quality check |
7d0f353c | 185 | eta = p3.Eta(); |
b45b0c92 | 186 | if ( (eta > etaMax) || (eta < etaMin)) continue; // checking eta cut |
7d0f353c | 187 | |
188 | new ((*fMomentumArray)[goodTrack]) TLorentzVector(p3,p3.Mag()); | |
189 | sflag[goodTrack]=0; | |
190 | if (TMath::Abs(track->GetLabel()) < 10000) sflag[goodTrack]=1; | |
191 | cflag[goodTrack]=0; | |
192 | if (pt > ptMin) cflag[goodTrack]=1; // pt cut | |
193 | goodTrack++; | |
99e5fe42 | 194 | } |
8011d399 | 195 | // set the signal flags |
83a444b1 | 196 | fSignalFlag.Set(goodTrack,sflag); |
197 | fCutFlag.Set(goodTrack,cflag); | |
b45b0c92 | 198 | |
199 | // | |
200 | // | |
201 | AliJetFillUnitArrayTracks *fillUAFromTracks = new AliJetFillUnitArrayTracks(); | |
202 | fillUAFromTracks->SetReaderHeader(fReaderHeader); | |
203 | fillUAFromTracks->SetMomentumArray(fMomentumArray); | |
204 | fillUAFromTracks->SetTPCGrid(fTpcGrid); | |
205 | fillUAFromTracks->SetEMCalGrid(fEmcalGrid); | |
206 | fillUAFromTracks->SetHadCorrection(fHCorrection); | |
207 | fillUAFromTracks->SetHadCorrector(fHadCorr); | |
208 | fNeta = fillUAFromTracks->GetNeta(); | |
209 | fNphi = fillUAFromTracks->GetNphi(); | |
210 | fillUAFromTracks->SetActive(kFALSE); | |
211 | // TPC only or Digits+TPC or Clusters+TPC | |
212 | if(fOpt%2==!0 && fOpt!=0){ | |
213 | fillUAFromTracks->SetActive(kTRUE); | |
214 | fillUAFromTracks->SetUnitArray(fUnitArray); | |
215 | fillUAFromTracks->ExecuteTask("tpc"); | |
216 | } | |
217 | delete fillUAFromTracks; | |
7d0f353c | 218 | return kTRUE; |
99e5fe42 | 219 | } |
220 | ||
b45b0c92 | 221 | |
222 | void AliJetESDReader::SetEMCALGeometry() | |
223 | { | |
224 | // Define EMCAL geometry to be able to read ESDs | |
5b81d1ce | 225 | fGeom = AliJetDummyGeo::GetInstance(); |
b45b0c92 | 226 | if (fGeom == 0) |
5b81d1ce | 227 | fGeom = AliJetDummyGeo::GetInstance("SHISH_77_TRD1_2X2_FINAL_110DEG","EMCAL"); |
b45b0c92 | 228 | |
229 | // To be setted to run some AliEMCALGeometry functions | |
230 | TGeoManager::Import("geometry.root"); | |
231 | fGeom->GetTransformationForSM(); | |
232 | ||
233 | printf("\n EMCal Geometry set ! \n"); | |
234 | ||
235 | } | |
7d0f353c | 236 | |
b45b0c92 | 237 | void AliJetESDReader::InitParameters() |
238 | { | |
239 | // Initialise parameters | |
240 | fHCorrection = 0; // For hadron correction | |
241 | fHadCorr = 0; // For hadron correction | |
242 | fNumUnits = fGeom->GetNCells(); // Number of cells in EMCAL | |
243 | if(fDebug>1) printf("\n EMCal parameters initiated ! \n"); | |
244 | } | |
245 | ||
246 | void AliJetESDReader::InitUnitArray() | |
247 | { | |
248 | //Initialises unit arrays | |
249 | Int_t nElements = fTpcGrid->GetNEntries(); | |
250 | if(fArrayInitialised) delete [] fUnitArray; | |
251 | if(fTpcGrid->GetGridType()==0) | |
252 | fUnitArray = new AliJetUnitArray[nElements]; | |
253 | if(fTpcGrid->GetGridType()==1) | |
254 | fUnitArray = new AliJetUnitArray[fNumUnits+nElements]; | |
255 | fArrayInitialised = 1; | |
256 | } | |
7d0f353c | 257 | |
99e5fe42 | 258 |