]>
Commit | Line | Data |
---|---|---|
fe17d4cb | 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 | //======================================================================== | |
15 | // | |
16 | // Class AliEMCALTracker | |
17 | // ----------------------- | |
18 | // Implementation of the track matching method between barrel tracks and | |
19 | // EMCAL clusters. | |
20 | // Besides algorithm implementation, some cuts are required to be set | |
21 | // in order to define, for each track, an acceptance window where clusters | |
22 | // are searched to find best match (if any). | |
23 | // The class accepts as input an ESD container, and works directly on it, | |
24 | // simply setting, for each of its tracks, the fEMCALindex flag, for each | |
25 | // track which is matched to a cluster. | |
26 | // In order to use method, one must launch PropagateBack(). | |
27 | // | |
28 | // ------------------------------------------------------------------------ | |
29 | // author: A. Pulvirenti (alberto.pulvirenti@ct.infn.it) | |
5970dfe2 | 30 | // Revised by Rongrong 2010-05-31 (rongrong.ma@cern.ch) |
fe17d4cb | 31 | //========================================================================= |
32 | ||
33 | #include <Riostream.h> | |
34 | #include <iomanip> | |
35 | ||
36 | #include <TFile.h> | |
37 | #include <TTree.h> | |
fe17d4cb | 38 | #include <TList.h> |
39 | #include <TString.h> | |
40 | #include <TVector3.h> | |
41 | #include <TClonesArray.h> | |
c61f0e70 | 42 | #include <TGeoMatrix.h> |
fe17d4cb | 43 | |
44 | #include "AliLog.h" | |
af885e0f | 45 | #include "AliESDEvent.h" |
fe17d4cb | 46 | #include "AliESDtrack.h" |
89ffc0b0 | 47 | #include "AliESDCaloCluster.h" |
fe17d4cb | 48 | #include "AliEMCALRecPoint.h" |
49 | #include "AliRunLoader.h" | |
50 | #include "AliEMCALTrack.h" | |
51 | #include "AliEMCALLoader.h" | |
c61f0e70 | 52 | #include "AliEMCALGeometry.h" |
8ba062b1 | 53 | #include "AliEMCALReconstructor.h" |
54 | #include "AliEMCALRecParam.h" | |
55 | #include "AliCDBEntry.h" | |
56 | #include "AliCDBManager.h" | |
3e3faf55 | 57 | #include "AliEMCALReconstructor.h" |
ee602376 | 58 | #include "AliEMCALRecoUtils.h" |
c61f0e70 | 59 | |
fe17d4cb | 60 | #include "AliEMCALTracker.h" |
61 | ||
62 | ClassImp(AliEMCALTracker) | |
8ba062b1 | 63 | |
fe17d4cb | 64 | // |
65 | //------------------------------------------------------------------------------ | |
66 | // | |
67 | AliEMCALTracker::AliEMCALTracker() | |
8fc351e3 | 68 | : AliTracker(), |
69 | fCutPt(0), | |
70 | fCutNITS(0), | |
71 | fCutNTPC(50), | |
da34fafe | 72 | fStep(20), |
8fc351e3 | 73 | fTrackCorrMode(kTrackCorrMMB), |
74 | fClusterWindow(50), | |
75 | fCutEta(0.025), | |
76 | fCutPhi(0.05), | |
77 | fTracks(0), | |
78 | fClusters(0), | |
79 | fGeom(0) | |
fe17d4cb | 80 | { |
5970dfe2 | 81 | // |
82 | // Default constructor. | |
83 | // Initializes all simple data members to default values, | |
84 | // and all collections to NULL. | |
85 | // Output file name is set to a default value. | |
86 | // | |
0832a2bf | 87 | InitParameters(); |
fe17d4cb | 88 | } |
89 | // | |
90 | //------------------------------------------------------------------------------ | |
91 | // | |
92 | AliEMCALTracker::AliEMCALTracker(const AliEMCALTracker& copy) | |
93 | : AliTracker(), | |
5970dfe2 | 94 | fCutPt(copy.fCutPt), |
dcd86c5d | 95 | fCutNITS(copy.fCutNITS), |
96 | fCutNTPC(copy.fCutNTPC), | |
5970dfe2 | 97 | fStep(copy.fStep), |
98 | fTrackCorrMode(copy.fTrackCorrMode), | |
8fc351e3 | 99 | fClusterWindow(copy.fClusterWindow), |
5970dfe2 | 100 | fCutEta(copy.fCutEta), |
101 | fCutPhi(copy.fCutPhi), | |
fe17d4cb | 102 | fTracks((TObjArray*)copy.fTracks->Clone()), |
103 | fClusters((TObjArray*)copy.fClusters->Clone()), | |
c61f0e70 | 104 | fGeom(copy.fGeom) |
fe17d4cb | 105 | { |
5970dfe2 | 106 | // |
107 | // Copy constructor | |
108 | // Besides copying all parameters, duplicates all collections. | |
109 | // | |
fe17d4cb | 110 | } |
111 | // | |
112 | //------------------------------------------------------------------------------ | |
113 | // | |
114 | AliEMCALTracker& AliEMCALTracker::operator=(const AliEMCALTracker& copy) | |
115 | { | |
5970dfe2 | 116 | // |
117 | // Assignment operator. | |
118 | // Besides copying all parameters, duplicates all collections. | |
119 | // | |
120 | ||
121 | fCutPt = copy.fCutPt; | |
8fc351e3 | 122 | fClusterWindow = copy.fClusterWindow; |
5970dfe2 | 123 | fCutEta = copy.fCutEta; |
124 | fCutPhi = copy.fCutPhi; | |
125 | fStep = copy.fStep; | |
126 | fTrackCorrMode = copy.fTrackCorrMode; | |
127 | ||
128 | fCutNITS = copy.fCutNITS; | |
129 | fCutNTPC = copy.fCutNTPC; | |
130 | ||
131 | fTracks = (TObjArray*)copy.fTracks->Clone(); | |
132 | fClusters = (TObjArray*)copy.fClusters->Clone(); | |
133 | fGeom = copy.fGeom; | |
134 | ||
135 | return (*this); | |
fe17d4cb | 136 | } |
137 | // | |
138 | //------------------------------------------------------------------------------ | |
139 | // | |
8ba062b1 | 140 | void AliEMCALTracker::InitParameters() |
141 | { | |
5970dfe2 | 142 | // |
143 | // Retrieve initialization parameters | |
144 | // | |
8ba062b1 | 145 | |
146 | // Check if the instance of AliEMCALRecParam exists, | |
3e3faf55 | 147 | const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam(); |
3a2a23e1 | 148 | |
ba6de5ea | 149 | if(!recParam){ |
150 | AliFatal("Reconstruction parameters for EMCAL not set!"); | |
8ba062b1 | 151 | } |
41f05b8c | 152 | else{ |
5970dfe2 | 153 | |
154 | fCutEta = recParam->GetMthCutEta(); | |
155 | fCutPhi = recParam->GetMthCutPhi(); | |
8fc351e3 | 156 | fStep = recParam->GetExtrapolateStep(); |
5970dfe2 | 157 | fCutPt = recParam->GetTrkCutPt(); |
8fc351e3 | 158 | fCutNITS = recParam->GetTrkCutNITS(); |
159 | fCutNTPC = recParam->GetTrkCutNTPC(); | |
41f05b8c | 160 | } |
3e3faf55 | 161 | |
8ba062b1 | 162 | } |
5970dfe2 | 163 | |
c61f0e70 | 164 | // |
165 | //------------------------------------------------------------------------------ | |
166 | // | |
fe17d4cb | 167 | void AliEMCALTracker::Clear(Option_t* option) |
168 | { | |
169 | // | |
170 | // Clearing method | |
044225d9 | 171 | // Deletes all objects in arrays and the arrays themselves |
fe17d4cb | 172 | // |
173 | ||
174 | TString opt(option); | |
175 | Bool_t clearTracks = opt.Contains("TRACKS"); | |
176 | Bool_t clearClusters = opt.Contains("CLUSTERS"); | |
fe17d4cb | 177 | if (opt.Contains("ALL")) { |
178 | clearTracks = kTRUE; | |
179 | clearClusters = kTRUE; | |
fe17d4cb | 180 | } |
181 | ||
5970dfe2 | 182 | //fTracks is a collection of esdTrack |
183 | //When clearing this array, the linked objects should not be deleted | |
fe17d4cb | 184 | if (fTracks != 0x0 && clearTracks) { |
5970dfe2 | 185 | fTracks->Clear(); |
044225d9 | 186 | delete fTracks; |
187 | fTracks = 0; | |
fe17d4cb | 188 | } |
189 | if (fClusters != 0x0 && clearClusters) { | |
044225d9 | 190 | fClusters->Delete(); |
191 | delete fClusters; | |
192 | fClusters = 0; | |
fe17d4cb | 193 | } |
fe17d4cb | 194 | } |
195 | // | |
196 | //------------------------------------------------------------------------------ | |
197 | // | |
198 | Int_t AliEMCALTracker::LoadClusters(TTree *cTree) | |
199 | { | |
200 | // | |
201 | // Load EMCAL clusters in the form of AliEMCALRecPoint, | |
202 | // from simulation temporary files. | |
203 | // (When included in reconstruction chain, this method is used automatically) | |
204 | // | |
205 | ||
206 | Clear("CLUSTERS"); | |
207 | ||
bce21ea7 | 208 | cTree->SetBranchStatus("*",0); //disable all branches |
209 | cTree->SetBranchStatus("EMCALECARP",1); //Enable only the branch we need | |
210 | ||
fe17d4cb | 211 | TBranch *branch = cTree->GetBranch("EMCALECARP"); |
212 | if (!branch) { | |
c61f0e70 | 213 | AliError("Can't get the branch with the EMCAL clusters"); |
fe17d4cb | 214 | return 1; |
215 | } | |
216 | ||
9596d957 | 217 | TClonesArray *clusters = new TClonesArray("AliEMCALRecPoint", 1000); |
fe17d4cb | 218 | branch->SetAddress(&clusters); |
fe17d4cb | 219 | |
bce21ea7 | 220 | //cTree->GetEvent(0); |
221 | branch->GetEntry(0); | |
9596d957 | 222 | Int_t nClusters = (Int_t)clusters->GetEntries(); |
bce21ea7 | 223 | if(fClusters) fClusters->Delete(); |
224 | else fClusters = new TObjArray(0); | |
fe17d4cb | 225 | for (Int_t i = 0; i < nClusters; i++) { |
226 | AliEMCALRecPoint *cluster = (AliEMCALRecPoint*)clusters->At(i); | |
227 | if (!cluster) continue; | |
fe17d4cb | 228 | AliEMCALMatchCluster *matchCluster = new AliEMCALMatchCluster(i, cluster); |
229 | fClusters->AddLast(matchCluster); | |
230 | } | |
3d9e8b15 | 231 | |
2ad4424e | 232 | branch->SetAddress(0); |
233 | clusters->Delete(); | |
234 | delete clusters; | |
235 | ||
5970dfe2 | 236 | AliInfo(Form("Collected %d RecPoints from Tree", fClusters->GetEntries())); |
fe17d4cb | 237 | |
238 | return 0; | |
239 | } | |
240 | // | |
241 | //------------------------------------------------------------------------------ | |
242 | // | |
af885e0f | 243 | Int_t AliEMCALTracker::LoadClusters(AliESDEvent *esd) |
fe17d4cb | 244 | { |
5970dfe2 | 245 | // |
246 | // Load EMCAL clusters in the form of AliESDCaloClusters, | |
247 | // from an AliESD object. | |
248 | // | |
249 | ||
250 | // make sure that tracks/clusters collections are empty | |
251 | Clear("CLUSTERS"); | |
252 | fClusters = new TObjArray(0); | |
253 | ||
254 | Int_t nClusters = esd->GetNumberOfCaloClusters(); | |
255 | for (Int_t i=0; i<nClusters; i++) | |
256 | { | |
257 | AliESDCaloCluster *cluster = esd->GetCaloCluster(i); | |
258 | if (!cluster || !cluster->IsEMCAL()) continue ; | |
259 | AliEMCALMatchCluster *matchCluster = new AliEMCALMatchCluster(i, cluster); | |
260 | fClusters->AddLast(matchCluster); | |
261 | } | |
262 | ||
263 | AliInfo(Form("Collected %d clusters from ESD", fClusters->GetEntries())); | |
264 | return 0; | |
fe17d4cb | 265 | } |
266 | // | |
267 | //------------------------------------------------------------------------------ | |
268 | // | |
af885e0f | 269 | Int_t AliEMCALTracker::LoadTracks(AliESDEvent *esd) |
fe17d4cb | 270 | { |
5970dfe2 | 271 | // |
272 | // Load ESD tracks. | |
273 | // | |
fe17d4cb | 274 | |
5970dfe2 | 275 | Clear("TRACKS"); |
276 | fTracks = new TObjArray(0); | |
fe17d4cb | 277 | |
5970dfe2 | 278 | Int_t nTracks = esd->GetNumberOfTracks(); |
8fc351e3 | 279 | //Bool_t isKink=kFALSE; |
5970dfe2 | 280 | for (Int_t i = 0; i < nTracks; i++) |
281 | { | |
282 | AliESDtrack *esdTrack = esd->GetTrack(i); | |
283 | // set by default the value corresponding to "no match" | |
284 | esdTrack->SetEMCALcluster(kUnmatched); | |
8fc351e3 | 285 | esdTrack->ResetStatus(AliESDtrack::kEMCALmatch); |
5970dfe2 | 286 | |
287 | //Select good quaulity tracks | |
288 | if(esdTrack->Pt()<fCutPt) continue; | |
289 | if(esdTrack->GetNcls(1)<fCutNTPC)continue; | |
290 | ||
5970dfe2 | 291 | //Loose geometric cut |
292 | Double_t phi = esdTrack->Phi()*TMath::RadToDeg(); | |
d874f457 | 293 | if(TMath::Abs(esdTrack->Eta())>0.8 || phi <= 20 || phi >= 240 ) continue; |
5970dfe2 | 294 | |
295 | fTracks->AddLast(esdTrack); | |
296 | } | |
297 | ||
298 | AliInfo(Form("Collected %d tracks", fTracks->GetEntries())); | |
299 | return 0; | |
300 | } | |
301 | // | |
302 | //------------------------------------------------------------------------------ | |
303 | // | |
304 | void AliEMCALTracker::SetTrackCorrectionMode(Option_t *option) | |
305 | { | |
306 | // | |
307 | // Set track correction mode | |
308 | // gest the choice in string format and converts into | |
309 | // internal enum | |
310 | // | |
311 | ||
312 | TString opt(option); | |
313 | opt.ToUpper(); | |
314 | ||
315 | if (!opt.CompareTo("NONE")) | |
316 | { | |
317 | fTrackCorrMode = kTrackCorrNone; | |
318 | } | |
319 | else if (!opt.CompareTo("MMB")) | |
320 | { | |
321 | fTrackCorrMode = kTrackCorrMMB; | |
322 | } | |
323 | else | |
324 | { | |
325 | cerr << "E-AliEMCALTracker::SetTrackCorrectionMode '" << option << "': Unrecognized option" << endl; | |
326 | } | |
fe17d4cb | 327 | } |
328 | // | |
329 | //------------------------------------------------------------------------------ | |
330 | // | |
af885e0f | 331 | Int_t AliEMCALTracker::PropagateBack(AliESDEvent* esd) |
fe17d4cb | 332 | { |
333 | // | |
334 | // Main operation method. | |
335 | // Gets external AliESD containing tracks to be matched. | |
336 | // After executing match finding, stores in the same ESD object all infos | |
337 | // and releases the object for further reconstruction steps. | |
338 | // | |
3d9e8b15 | 339 | // |
340 | // Note: should always return 0=OK, because otherwise all tracking | |
341 | // is aborted for this event | |
5970dfe2 | 342 | |
fe17d4cb | 343 | if (!esd) { |
344 | AliError("NULL ESD passed"); | |
345 | return 1; | |
346 | } | |
347 | ||
5970dfe2 | 348 | // step 1: collect clusters |
c61f0e70 | 349 | Int_t okLoadClusters, nClusters; |
fe17d4cb | 350 | if (!fClusters || (fClusters && fClusters->IsEmpty())) { |
fe17d4cb | 351 | okLoadClusters = LoadClusters(esd); |
fe17d4cb | 352 | } |
c61f0e70 | 353 | nClusters = fClusters->GetEntries(); |
5970dfe2 | 354 | |
355 | // step 2: collect ESD tracks | |
356 | Int_t nTracks, okLoadTracks; | |
357 | okLoadTracks = LoadTracks(esd); | |
c61f0e70 | 358 | nTracks = fTracks->GetEntries(); |
fe17d4cb | 359 | |
5970dfe2 | 360 | // step 3: for each track, find the closest cluster as matched within residual cuts |
361 | Int_t index=-1; | |
362 | for (Int_t it = 0; it < nTracks; it++) | |
363 | { | |
364 | AliESDtrack *track = (AliESDtrack*)fTracks->At(it); | |
365 | index = FindMatchedCluster(track); | |
366 | if (index>-1) | |
367 | { | |
368 | AliEMCALMatchCluster *cluster = (AliEMCALMatchCluster*)fClusters->At(index); | |
369 | track->SetEMCALcluster(cluster->Index()); | |
952d023a | 370 | track->SetStatus(AliESDtrack::kEMCALmatch); |
5970dfe2 | 371 | } |
372 | } | |
fe17d4cb | 373 | |
374 | return 0; | |
375 | } | |
fe17d4cb | 376 | |
377 | // | |
378 | //------------------------------------------------------------------------------ | |
379 | // | |
5970dfe2 | 380 | Int_t AliEMCALTracker::FindMatchedCluster(AliESDtrack *track) |
381 | { | |
382 | // | |
383 | // For each track, extrapolate it to all the clusters | |
384 | // Find the closest one as matched if the residuals (dEta, dPhi) satisfy the cuts | |
385 | // | |
17773e2e | 386 | |
ee602376 | 387 | Float_t maxEta=fCutEta; |
388 | Float_t maxPhi=fCutPhi; | |
5970dfe2 | 389 | Int_t index = -1; |
390 | ||
391 | // If the esdFriend is available, use the TPCOuter point as the starting point of extrapolation | |
392 | // Otherwise use the TPCInner point | |
8108ab9e | 393 | AliExternalTrackParam *trkParam = 0; |
5970dfe2 | 394 | const AliESDfriendTrack* friendTrack = track->GetFriendTrack(); |
395 | if(friendTrack && friendTrack->GetTPCOut()) | |
396 | trkParam = const_cast<AliExternalTrackParam*>(friendTrack->GetTPCOut()); | |
397 | else | |
398 | trkParam = const_cast<AliExternalTrackParam*>(track->GetInnerParam()); | |
399 | if(!trkParam) return index; | |
400 | ||
8fc351e3 | 401 | |
402 | AliExternalTrackParam trkParamTmp(*trkParam); | |
ee602376 | 403 | Float_t eta, phi; |
404 | if(!AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&trkParamTmp, 430., track->GetMass(), fStep, eta, phi)) return index; | |
8fc351e3 | 405 | if(TMath::Abs(eta)>0.75 || (phi) < 70*TMath::DegToRad() || (phi) > 190*TMath::DegToRad()) return index; |
406 | ||
5970dfe2 | 407 | //Perform extrapolation |
408 | Double_t trkPos[3]; | |
8fc351e3 | 409 | trkParamTmp.GetXYZ(trkPos); |
5970dfe2 | 410 | Int_t nclusters = fClusters->GetEntries(); |
411 | for(Int_t ic=0; ic<nclusters; ic++) | |
412 | { | |
5970dfe2 | 413 | AliEMCALMatchCluster *cluster = (AliEMCALMatchCluster*)fClusters->At(ic); |
8fc351e3 | 414 | Float_t clsPos[3] = {cluster->X(),cluster->Y(),cluster->Z()}; |
415 | Double_t dR = TMath::Sqrt(TMath::Power(trkPos[0]-clsPos[0],2)+TMath::Power(trkPos[1]-clsPos[1],2)+TMath::Power(trkPos[2]-clsPos[2],2)); | |
416 | if(dR > fClusterWindow) continue; | |
417 | ||
418 | AliExternalTrackParam trkParTmp(trkParamTmp); | |
419 | ||
ee602376 | 420 | Float_t tmpEta, tmpPhi; |
da34fafe | 421 | if(!AliEMCALRecoUtils::ExtrapolateTrackToPosition(&trkParTmp, clsPos,track->GetMass(), 5, tmpEta, tmpPhi)) continue; |
5970dfe2 | 422 | if(TMath::Abs(tmpPhi)<TMath::Abs(maxPhi) && TMath::Abs(tmpEta)<TMath::Abs(maxEta)) |
423 | { | |
424 | maxPhi=tmpPhi; | |
425 | maxEta=tmpEta; | |
426 | index=ic; | |
427 | } | |
5970dfe2 | 428 | } |
429 | return index; | |
fe17d4cb | 430 | } |
5970dfe2 | 431 | |
fe17d4cb | 432 | // |
433 | //------------------------------------------------------------------------------ | |
434 | // | |
435 | void AliEMCALTracker::UnloadClusters() | |
436 | { | |
437 | // | |
044225d9 | 438 | // Free memory from all arrays |
439 | // This method is called after the local tracking step | |
440 | // so we can safely delete everything | |
fe17d4cb | 441 | // |
442 | ||
044225d9 | 443 | Clear(); |
fe17d4cb | 444 | } |
04475328 | 445 | |
fe17d4cb | 446 | // |
447 | //------------------------------------------------------------------------------ | |
448 | // | |
449 | AliEMCALTracker::AliEMCALMatchCluster::AliEMCALMatchCluster(Int_t index, AliEMCALRecPoint *recPoint) | |
450 | : fIndex(index), | |
fe17d4cb | 451 | fX(0.), |
452 | fY(0.), | |
453 | fZ(0.) | |
454 | { | |
455 | // | |
456 | // Translates an AliEMCALRecPoint object into the internal format. | |
457 | // Index of passed cluster in its native array must be specified. | |
458 | // | |
459 | TVector3 clpos; | |
460 | recPoint->GetGlobalPosition(clpos); | |
461 | ||
462 | fX = clpos.X(); | |
463 | fY = clpos.Y(); | |
464 | fZ = clpos.Z(); | |
465 | } | |
466 | // | |
467 | //------------------------------------------------------------------------------ | |
468 | // | |
469 | AliEMCALTracker::AliEMCALMatchCluster::AliEMCALMatchCluster(Int_t index, AliESDCaloCluster *caloCluster) | |
470 | : fIndex(index), | |
fe17d4cb | 471 | fX(0.), |
472 | fY(0.), | |
473 | fZ(0.) | |
474 | { | |
475 | // | |
476 | // Translates an AliESDCaloCluster object into the internal format. | |
477 | // Index of passed cluster in its native array must be specified. | |
478 | // | |
53e430a3 | 479 | Float_t clpos[3]= {0., 0., 0.}; |
7592dfc4 | 480 | caloCluster->GetPosition(clpos); |
fe17d4cb | 481 | |
482 | fX = (Double_t)clpos[0]; | |
483 | fY = (Double_t)clpos[1]; | |
484 | fZ = (Double_t)clpos[2]; | |
485 | } |