]>
Commit | Line | Data |
---|---|---|
b8dc484b | 1 | /************************************************************************** |
48217459 | 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 | **************************************************************************/ | |
b8dc484b | 15 | |
d19b6003 | 16 | /* $Id$ */ |
17 | ||
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
5398f946 | 19 | /// \class AliMUONRecoCheck |
78649106 | 20 | /// Utility class to check reconstruction |
5398f946 | 21 | /// Reconstructed tracks are compared to reference tracks. |
22 | /// The reference tracks are built from AliTrackReference for the | |
23 | /// hit in chamber (0..9) and from kinematics for the vertex parameters. | |
3d1463c8 | 24 | //----------------------------------------------------------------------------- |
b8dc484b | 25 | |
9bdda5f6 | 26 | // 13 Nov 2007: |
27 | // Added a method to create a list of reconstructed AliMUONTrack objects from | |
28 | // ESD data. This is necessary since the track objects that are actually created | |
29 | // during offline reconstruction are no longer stored to disk. | |
30 | // - Artur Szostak <artursz@iafrica.com> | |
103e6575 | 31 | // 25 Jan 2008: |
32 | // Use the new ESDInterface to create MUON objects from ESD data | |
33 | // - Philippe Pillot | |
7c29acf1 | 34 | // |
9bdda5f6 | 35 | |
cc056de1 | 36 | #include "AliMUONRecoCheck.h" |
37 | #include "AliMUONTrack.h" | |
103e6575 | 38 | #include "AliMUONVTrackStore.h" |
39 | #include "AliMUONVCluster.h" | |
40 | #include "AliMUONVClusterStore.h" | |
cc056de1 | 41 | #include "AliMUONConstants.h" |
103e6575 | 42 | #include "AliMUONESDInterface.h" |
933daf4c | 43 | #include "AliMUONTrackParam.h" |
96ebe67e | 44 | #include "AliMCEventHandler.h" |
45 | #include "AliMCEvent.h" | |
b8dc484b | 46 | #include "AliStack.h" |
cc056de1 | 47 | #include "AliTrackReference.h" |
9bdda5f6 | 48 | #include "AliLog.h" |
49 | #include "AliESDEvent.h" | |
50 | #include "AliESDMuonTrack.h" | |
96ebe67e | 51 | |
61fed964 | 52 | #include <TFile.h> |
53 | #include <TTree.h> | |
cc056de1 | 54 | #include <TParticle.h> |
5b1afea0 | 55 | #include <TParticlePDG.h> |
96ebe67e | 56 | #include <Riostream.h> |
57 | ||
5398f946 | 58 | /// \cond CLASSIMP |
b8dc484b | 59 | ClassImp(AliMUONRecoCheck) |
5398f946 | 60 | /// \endcond |
b8dc484b | 61 | |
068e4c36 | 62 | //_____________________________________________________________________________ |
1f2d22de | 63 | AliMUONRecoCheck::AliMUONRecoCheck(const Char_t *esdFileName, const Char_t *pathSim) |
48217459 | 64 | : TObject(), |
96ebe67e | 65 | fMCEventHandler(new AliMCEventHandler()), |
61fed964 | 66 | fESDEvent(new AliESDEvent()), |
67 | fESDTree (0x0), | |
68 | fESDFile (0x0), | |
96ebe67e | 69 | fCurrentEvent(0), |
70 | fTrackRefStore(0x0), | |
71 | fRecoTrackRefStore(0x0), | |
7c29acf1 | 72 | fRecoTrackStore(0x0), |
73 | fESDEventOwner(kTRUE) | |
068e4c36 | 74 | { |
48217459 | 75 | /// Normal ctor |
61fed964 | 76 | |
77 | // TrackRefs and Particules | |
96ebe67e | 78 | fMCEventHandler->SetInputPath(pathSim); |
79 | fMCEventHandler->InitIO(""); | |
61fed964 | 80 | |
81 | // ESD MUON Tracks | |
82 | fESDFile = TFile::Open(esdFileName); // open the file | |
83 | if (!fESDFile || !fESDFile->IsOpen()) { | |
84 | AliError(Form("opening ESD file %s failed", esdFileName)); | |
85 | fESDFile = 0x0; | |
86 | return; | |
87 | } | |
88 | fESDTree = (TTree*) fESDFile->Get("esdTree"); // get the tree | |
89 | if (!fESDTree) { | |
90 | AliError("no ESD tree found"); | |
91 | fESDFile->Close(); | |
92 | fESDFile = 0x0; | |
93 | return; | |
94 | } | |
95 | fESDEvent->ReadFromTree(fESDTree); // link fESDEvent to the tree | |
068e4c36 | 96 | } |
97 | ||
7c29acf1 | 98 | //_____________________________________________________________________________ |
99 | AliMUONRecoCheck::AliMUONRecoCheck(AliESDEvent *esdEvent, AliMCEventHandler *mcEventHandler) | |
100 | : TObject(), | |
101 | fMCEventHandler(0), | |
102 | fESDEvent(0), | |
103 | fESDTree (0x0), | |
104 | fESDFile (0x0), | |
105 | fCurrentEvent(0), | |
106 | fTrackRefStore(0x0), | |
107 | fRecoTrackRefStore(0x0), | |
108 | fRecoTrackStore(0x0), | |
109 | fESDEventOwner(kFALSE) | |
110 | { | |
111 | /// Normal ctor | |
112 | ||
113 | // TrackRefs and Particules | |
114 | fMCEventHandler = mcEventHandler; | |
115 | ||
116 | // ESD MUON Tracks | |
117 | fESDEvent = esdEvent; | |
118 | ||
119 | } | |
120 | ||
b8dc484b | 121 | //_____________________________________________________________________________ |
48217459 | 122 | AliMUONRecoCheck::~AliMUONRecoCheck() |
b8dc484b | 123 | { |
48217459 | 124 | /// Destructor |
7c29acf1 | 125 | if (fESDEventOwner) { |
126 | delete fMCEventHandler; | |
127 | delete fESDEvent; | |
128 | if (fESDFile) fESDFile->Close(); | |
129 | } | |
96ebe67e | 130 | ResetStores(); |
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | void AliMUONRecoCheck::ResetStores() | |
135 | { | |
136 | /// Deletes all the store objects that have been created and resets the pointers to 0x0 | |
137 | delete fTrackRefStore; fTrackRefStore = 0x0; | |
138 | delete fRecoTrackRefStore; fRecoTrackRefStore = 0x0; | |
139 | delete fRecoTrackStore; fRecoTrackStore = 0x0; | |
140 | } | |
141 | ||
a99c3449 | 142 | //_____________________________________________________________________________ |
143 | Int_t AliMUONRecoCheck::GetRunNumber() | |
144 | { | |
145 | /// Return the run number of the current ESD event | |
146 | ||
147 | if (fESDEventOwner && fRecoTrackStore == 0x0) { | |
148 | if (!fESDTree || fESDTree->GetEvent(fCurrentEvent) <= 0) { | |
149 | AliError(Form("fails to read ESD object for event %d: cannot get the run number",fCurrentEvent)); | |
150 | return -1; | |
151 | } | |
152 | } | |
153 | ||
154 | return fESDEvent->GetRunNumber(); | |
155 | } | |
156 | ||
96ebe67e | 157 | //_____________________________________________________________________________ |
158 | Int_t AliMUONRecoCheck::NumberOfEvents() const | |
159 | { | |
160 | /// Return the number of events | |
7c29acf1 | 161 | if (fESDEventOwner && fESDTree) return fESDTree->GetEntries(); |
96ebe67e | 162 | return 0; |
b8dc484b | 163 | } |
164 | ||
48217459 | 165 | //_____________________________________________________________________________ |
a99c3449 | 166 | AliMUONVTrackStore* AliMUONRecoCheck::ReconstructedTracks(Int_t event, Bool_t refit) |
48217459 | 167 | { |
61fed964 | 168 | /// Return a track store containing the reconstructed tracks (converted into |
a99c3449 | 169 | /// MUONTrack objects) for a given event. |
170 | /// Track parameters at each clusters are computed or not depending on the flag "refit". | |
171 | /// If not, only the track parameters at first cluster are valid. | |
7c29acf1 | 172 | |
173 | if (!fESDEventOwner) { | |
a99c3449 | 174 | if (fRecoTrackStore == 0x0) MakeReconstructedTracks(refit); |
7c29acf1 | 175 | return fRecoTrackStore; |
176 | } | |
177 | ||
96ebe67e | 178 | if (event != fCurrentEvent) { |
179 | ResetStores(); | |
180 | fCurrentEvent = event; | |
181 | } | |
182 | ||
183 | if (fRecoTrackStore != 0x0) return fRecoTrackStore; | |
61fed964 | 184 | else { |
185 | if (!fESDTree) return 0x0; | |
186 | if (fESDTree->GetEvent(event) <= 0) { | |
187 | AliError(Form("fails to read ESD object for event %d", event)); | |
188 | return 0x0; | |
9bdda5f6 | 189 | } |
a99c3449 | 190 | MakeReconstructedTracks(refit); |
61fed964 | 191 | return fRecoTrackStore; |
9bdda5f6 | 192 | } |
9bdda5f6 | 193 | } |
194 | ||
195 | //_____________________________________________________________________________ | |
96ebe67e | 196 | AliMUONVTrackStore* AliMUONRecoCheck::TrackRefs(Int_t event) |
b8dc484b | 197 | { |
48217459 | 198 | /// Return a track store containing the track references (converted into |
199 | /// MUONTrack objects) for a given event | |
7c29acf1 | 200 | |
201 | if (!fESDEventOwner) { | |
a99c3449 | 202 | if (fTrackRefStore == 0x0) MakeTrackRefs(); |
7c29acf1 | 203 | return fTrackRefStore; |
204 | } | |
205 | ||
96ebe67e | 206 | if (event != fCurrentEvent) { |
207 | ResetStores(); | |
208 | fCurrentEvent = event; | |
209 | } | |
210 | ||
211 | if (fTrackRefStore != 0x0) return fTrackRefStore; | |
212 | else { | |
61fed964 | 213 | if (!fMCEventHandler->GetEvent(event)) { |
214 | AliError(Form("fails to read MC objects for event %d", event)); | |
215 | return 0x0; | |
216 | } | |
96ebe67e | 217 | MakeTrackRefs(); |
218 | return fTrackRefStore; | |
219 | } | |
b8dc484b | 220 | } |
221 | ||
222 | //_____________________________________________________________________________ | |
f202486b | 223 | AliMUONVTrackStore* AliMUONRecoCheck::ReconstructibleTracks(Int_t event, UInt_t requestedStationMask, Bool_t request2ChInSameSt45) |
b8dc484b | 224 | { |
f202486b | 225 | /// Return a track store containing the reconstructible tracks for a given event, |
226 | /// according to the mask of requested stations and the minimum number of chambers hit in stations 4 & 5. | |
7c29acf1 | 227 | |
228 | if (!fESDEventOwner) { | |
a99c3449 | 229 | if (fRecoTrackRefStore == 0x0) { |
230 | if (TrackRefs(event) == 0x0) return 0x0; | |
f202486b | 231 | MakeReconstructibleTracks(requestedStationMask, request2ChInSameSt45); |
a99c3449 | 232 | } |
7c29acf1 | 233 | return fRecoTrackRefStore; |
234 | } | |
235 | ||
96ebe67e | 236 | if (event != fCurrentEvent) { |
237 | ResetStores(); | |
238 | fCurrentEvent = event; | |
239 | } | |
240 | ||
241 | if (fRecoTrackRefStore != 0x0) return fRecoTrackRefStore; | |
242 | else { | |
243 | if (TrackRefs(event) == 0x0) return 0x0; | |
f202486b | 244 | MakeReconstructibleTracks(requestedStationMask, request2ChInSameSt45); |
96ebe67e | 245 | return fRecoTrackRefStore; |
246 | } | |
48217459 | 247 | } |
b8dc484b | 248 | |
61fed964 | 249 | //_____________________________________________________________________________ |
a99c3449 | 250 | void AliMUONRecoCheck::MakeReconstructedTracks(Bool_t refit) |
61fed964 | 251 | { |
252 | /// Make reconstructed tracks | |
103e6575 | 253 | if (!(fRecoTrackStore = AliMUONESDInterface::NewTrackStore())) return; |
61fed964 | 254 | |
b1fea02e | 255 | // loop over all reconstructed tracks and add them to the store (skip ghosts) |
103e6575 | 256 | Int_t nTracks = (Int_t) fESDEvent->GetNumberOfMuonTracks(); |
b1fea02e | 257 | for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) { |
258 | AliESDMuonTrack* esdTrack = fESDEvent->GetMuonTrack(iTrack); | |
a99c3449 | 259 | if (esdTrack->ContainTrackerData()) AliMUONESDInterface::Add(*esdTrack, *fRecoTrackStore, refit); |
b1fea02e | 260 | } |
61fed964 | 261 | |
262 | } | |
263 | ||
48217459 | 264 | //_____________________________________________________________________________ |
96ebe67e | 265 | void AliMUONRecoCheck::MakeTrackRefs() |
48217459 | 266 | { |
267 | /// Make reconstructible tracks | |
103e6575 | 268 | AliMUONVTrackStore *tmpTrackRefStore = AliMUONESDInterface::NewTrackStore(); |
269 | if (!tmpTrackRefStore) return; | |
48217459 | 270 | |
96ebe67e | 271 | Double_t x, y, z, pX, pY, pZ, bendingSlope, nonBendingSlope, inverseBendingMomentum; |
272 | TParticle* particle; | |
273 | TClonesArray* trackRefs; | |
274 | Int_t nTrackRef = fMCEventHandler->MCEvent()->GetNumberOfTracks(); | |
103e6575 | 275 | AliMUONVClusterStore* cStore = AliMUONESDInterface::NewClusterStore(); |
276 | if (!cStore) return; | |
277 | AliMUONVCluster* hit = cStore->CreateCluster(0,0,0); | |
b8dc484b | 278 | |
96ebe67e | 279 | // loop over simulated tracks |
280 | for (Int_t iTrackRef = 0; iTrackRef < nTrackRef; ++iTrackRef) { | |
281 | Int_t nHits = fMCEventHandler->GetParticleAndTR(iTrackRef, particle, trackRefs); | |
48217459 | 282 | |
96ebe67e | 283 | // skip empty trackRefs |
284 | if (nHits < 1) continue; | |
285 | ||
61fed964 | 286 | // get the particle charge for further calculation |
287 | TParticlePDG* ppdg = particle->GetPDG(); | |
46df197d | 288 | Int_t charge = ppdg != NULL ? (Int_t)(ppdg->Charge()/3.0) : 0; |
96ebe67e | 289 | |
61fed964 | 290 | AliMUONTrack track; |
48217459 | 291 | |
96ebe67e | 292 | // loop over simulated track hits |
293 | for (Int_t iHit = 0; iHit < nHits; ++iHit) { | |
294 | AliTrackReference* trackReference = static_cast<AliTrackReference*>(trackRefs->UncheckedAt(iHit)); | |
068e4c36 | 295 | |
61fed964 | 296 | // skip trackRefs not in MUON |
297 | if (trackReference->DetectorId() != AliTrackReference::kMUON) continue; | |
298 | ||
96ebe67e | 299 | // Get track parameters of current hit |
300 | x = trackReference->X(); | |
301 | y = trackReference->Y(); | |
302 | z = trackReference->Z(); | |
303 | pX = trackReference->Px(); | |
304 | pY = trackReference->Py(); | |
305 | pZ = trackReference->Pz(); | |
b8dc484b | 306 | |
96ebe67e | 307 | // check chamberId of current trackReference |
c59f70b9 | 308 | Int_t detElemId = trackReference->UserId(); |
309 | Int_t chamberId = detElemId / 100 - 1; | |
96ebe67e | 310 | if (chamberId < 0 || chamberId >= AliMUONConstants::NTrackingCh()) continue; |
48217459 | 311 | |
96ebe67e | 312 | // set hit parameters |
c59f70b9 | 313 | hit->SetUniqueID(AliMUONVCluster::BuildUniqueID(chamberId, detElemId, iHit)); |
103e6575 | 314 | hit->SetXYZ(x,y,z); |
315 | hit->SetErrXY(0.,0.); | |
b8dc484b | 316 | |
96ebe67e | 317 | // compute track parameters at hit |
7cdc832b | 318 | bendingSlope = 0; |
319 | nonBendingSlope = 0; | |
320 | inverseBendingMomentum = 0; | |
96ebe67e | 321 | if (TMath::Abs(pZ) > 0) { |
322 | bendingSlope = pY/pZ; | |
323 | nonBendingSlope = pX/pZ; | |
b8dc484b | 324 | } |
96ebe67e | 325 | Double_t pYZ = TMath::Sqrt(pY*pY+pZ*pZ); |
326 | if (pYZ >0) inverseBendingMomentum = 1/pYZ; | |
327 | inverseBendingMomentum *= charge; | |
328 | ||
329 | // set track parameters at hit | |
330 | AliMUONTrackParam trackParam; | |
331 | trackParam.SetNonBendingCoor(x); | |
332 | trackParam.SetBendingCoor(y); | |
333 | trackParam.SetZ(z); | |
334 | trackParam.SetBendingSlope(bendingSlope); | |
335 | trackParam.SetNonBendingSlope(nonBendingSlope); | |
336 | trackParam.SetInverseBendingMomentum(inverseBendingMomentum); | |
337 | ||
338 | // add track parameters at current hit to the track | |
103e6575 | 339 | track.AddTrackParamAtCluster(trackParam, *hit, kTRUE); |
96ebe67e | 340 | } |
341 | ||
61fed964 | 342 | // if none of the track hits was in MUON, goto the next track |
343 | if (track.GetNClusters() < 1) continue; | |
344 | ||
345 | // get track parameters at particle's vertex | |
346 | x = particle->Vx(); | |
347 | y = particle->Vy(); | |
348 | z = particle->Vz(); | |
349 | pX = particle->Px(); | |
350 | pY = particle->Py(); | |
351 | pZ = particle->Pz(); | |
352 | ||
353 | // compute rest of track parameters at particle's vertex | |
354 | bendingSlope = 0; | |
355 | nonBendingSlope = 0; | |
356 | inverseBendingMomentum = 0; | |
357 | if (TMath::Abs(pZ) > 0) { | |
358 | bendingSlope = pY/pZ; | |
359 | nonBendingSlope = pX/pZ; | |
360 | } | |
361 | Double_t pYZ = TMath::Sqrt(pY*pY+pZ*pZ); | |
362 | if (pYZ >0) inverseBendingMomentum = 1/pYZ; | |
363 | inverseBendingMomentum *= charge; | |
364 | ||
365 | // set track parameters at particle's vertex | |
366 | AliMUONTrackParam trackParamAtVertex; | |
367 | trackParamAtVertex.SetNonBendingCoor(x); | |
368 | trackParamAtVertex.SetBendingCoor(y); | |
369 | trackParamAtVertex.SetZ(z); | |
370 | trackParamAtVertex.SetBendingSlope(bendingSlope); | |
371 | trackParamAtVertex.SetNonBendingSlope(nonBendingSlope); | |
372 | trackParamAtVertex.SetInverseBendingMomentum(inverseBendingMomentum); | |
373 | ||
374 | // add track parameters at vertex | |
375 | track.SetTrackParamAtVertex(&trackParamAtVertex); | |
376 | ||
103e6575 | 377 | // store the track |
2e2d0c44 | 378 | track.SetUniqueID(iTrackRef); |
96ebe67e | 379 | tmpTrackRefStore->Add(track); |
b8dc484b | 380 | } |
b8dc484b | 381 | |
96ebe67e | 382 | CleanMuonTrackRef(tmpTrackRefStore); |
48217459 | 383 | |
103e6575 | 384 | delete hit; |
385 | delete cStore; | |
96ebe67e | 386 | delete tmpTrackRefStore; |
b8dc484b | 387 | } |
388 | ||
389 | //_____________________________________________________________________________ | |
96ebe67e | 390 | void AliMUONRecoCheck::CleanMuonTrackRef(const AliMUONVTrackStore *tmpTrackRefStore) |
b8dc484b | 391 | { |
48217459 | 392 | /// Re-calculate hits parameters because two AliTrackReferences are recorded for |
393 | /// each chamber (one when particle is entering + one when particle is leaving | |
394 | /// the sensitive volume) | |
103e6575 | 395 | if (!(fTrackRefStore = AliMUONESDInterface::NewTrackStore())) return; |
48217459 | 396 | |
96ebe67e | 397 | Double_t maxGasGap = 1.; // cm |
398 | Double_t x, y, z, pX, pY, pZ, x1, y1, z1, pX1, pY1, pZ1, z2; | |
399 | Double_t bendingSlope,nonBendingSlope,inverseBendingMomentum; | |
103e6575 | 400 | AliMUONVClusterStore* cStore = AliMUONESDInterface::NewClusterStore(); |
401 | if (!cStore) return; | |
402 | AliMUONVCluster* hit = cStore->CreateCluster(0,0,0); | |
48217459 | 403 | |
96ebe67e | 404 | // create iterator |
405 | TIter next(tmpTrackRefStore->CreateIterator()); | |
48217459 | 406 | |
96ebe67e | 407 | // loop over tmpTrackRef |
48217459 | 408 | AliMUONTrack* track; |
96ebe67e | 409 | while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) { |
410 | ||
411 | AliMUONTrack newTrack; | |
412 | ||
413 | // loop over tmpTrackRef's hits | |
414 | Int_t iHit1 = 0; | |
415 | Int_t nTrackHits = track->GetNClusters(); | |
416 | while (iHit1 < nTrackHits) { | |
417 | AliMUONTrackParam *trackParam1 = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->UncheckedAt(iHit1); | |
418 | ||
419 | // get track parameters at hit1 | |
420 | x1 = trackParam1->GetNonBendingCoor(); | |
421 | y1 = trackParam1->GetBendingCoor(); | |
422 | z1 = trackParam1->GetZ(); | |
423 | pX1 = trackParam1->Px(); | |
424 | pY1 = trackParam1->Py(); | |
425 | pZ1 = trackParam1->Pz(); | |
426 | ||
427 | // prepare new track parameters | |
428 | x = x1; | |
429 | y = y1; | |
430 | z = z1; | |
431 | pX = pX1; | |
432 | pY = pY1; | |
433 | pZ = pZ1; | |
434 | ||
435 | // loop over next tmpTrackRef's hits | |
436 | Int_t nCombinedHits = 1; | |
437 | for (Int_t iHit2 = iHit1+1; iHit2 < nTrackHits; iHit2++) { | |
438 | AliMUONTrackParam *trackParam2 = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->UncheckedAt(iHit2); | |
48217459 | 439 | |
96ebe67e | 440 | // get z position of hit2 |
441 | z2 = trackParam2->GetZ(); | |
442 | ||
443 | // complete new track parameters if hit2 is on the same detection element | |
444 | if ( TMath::Abs(z2-z1) < maxGasGap ) { | |
445 | x += trackParam2->GetNonBendingCoor(); | |
446 | y += trackParam2->GetBendingCoor(); | |
447 | z += z2; | |
448 | pX += trackParam2->Px(); | |
449 | pY += trackParam2->Py(); | |
450 | pZ += trackParam2->Pz(); | |
451 | nCombinedHits++; | |
48217459 | 452 | iHit1 = iHit2; |
453 | } | |
454 | ||
96ebe67e | 455 | } |
456 | ||
457 | // finalize new track parameters | |
458 | x /= (Double_t)nCombinedHits; | |
459 | y /= (Double_t)nCombinedHits; | |
460 | z /= (Double_t)nCombinedHits; | |
461 | pX /= (Double_t)nCombinedHits; | |
462 | pY /= (Double_t)nCombinedHits; | |
463 | pZ /= (Double_t)nCombinedHits; | |
464 | bendingSlope = 0; | |
465 | nonBendingSlope = 0; | |
466 | inverseBendingMomentum = 0; | |
467 | if (TMath::Abs(pZ) > 0) { | |
468 | bendingSlope = pY/pZ; | |
469 | nonBendingSlope = pX/pZ; | |
470 | } | |
471 | Double_t pYZ = TMath::Sqrt(pY*pY+pZ*pZ); | |
472 | if (pYZ >0) inverseBendingMomentum = 1/pYZ; | |
473 | inverseBendingMomentum *= trackParam1->GetCharge(); | |
b8dc484b | 474 | |
96ebe67e | 475 | // set hit parameters |
c59f70b9 | 476 | hit->SetUniqueID(trackParam1->GetClusterPtr()->GetUniqueID()); |
103e6575 | 477 | hit->SetXYZ(x,y,z); |
478 | hit->SetErrXY(0.,0.); | |
48217459 | 479 | |
96ebe67e | 480 | // set new track parameters at new hit |
481 | AliMUONTrackParam trackParam; | |
482 | trackParam.SetNonBendingCoor(x); | |
483 | trackParam.SetBendingCoor(y); | |
484 | trackParam.SetZ(z); | |
485 | trackParam.SetBendingSlope(bendingSlope); | |
486 | trackParam.SetNonBendingSlope(nonBendingSlope); | |
487 | trackParam.SetInverseBendingMomentum(inverseBendingMomentum); | |
488 | ||
489 | // add track parameters at current hit to the track | |
103e6575 | 490 | newTrack.AddTrackParamAtCluster(trackParam, *hit, kTRUE); |
b8dc484b | 491 | |
492 | iHit1++; | |
96ebe67e | 493 | } |
48217459 | 494 | |
2e2d0c44 | 495 | newTrack.SetUniqueID(track->GetUniqueID()); |
96ebe67e | 496 | newTrack.SetTrackParamAtVertex(track->GetTrackParamAtVertex()); |
497 | fTrackRefStore->Add(newTrack); | |
b8dc484b | 498 | |
96ebe67e | 499 | } |
b8dc484b | 500 | |
103e6575 | 501 | delete hit; |
502 | delete cStore; | |
b8dc484b | 503 | } |
504 | ||
505 | //_____________________________________________________________________________ | |
f202486b | 506 | void AliMUONRecoCheck::MakeReconstructibleTracks(UInt_t requestedStationMask, Bool_t request2ChInSameSt45) |
b8dc484b | 507 | { |
61fed964 | 508 | /// Isolate the reconstructible tracks |
103e6575 | 509 | if (!(fRecoTrackRefStore = AliMUONESDInterface::NewTrackStore())) return; |
48217459 | 510 | |
96ebe67e | 511 | // create iterator on trackRef |
512 | TIter next(fTrackRefStore->CreateIterator()); | |
b8dc484b | 513 | |
f202486b | 514 | // loop over trackRef and add reconstructible tracks to fRecoTrackRefStore |
48217459 | 515 | AliMUONTrack* track; |
96ebe67e | 516 | while ( ( track = static_cast<AliMUONTrack*>(next()) ) ) { |
f202486b | 517 | if (track->IsValid(requestedStationMask, request2ChInSameSt45)) fRecoTrackRefStore->Add(*track); |
518 | } | |
519 | ||
520 | } | |
521 | ||
522 | //_____________________________________________________________________________ | |
523 | AliMUONTrack* AliMUONRecoCheck::FindCompatibleTrack(AliMUONTrack &track, AliMUONVTrackStore &trackStore, | |
524 | Int_t &nMatchClusters, Bool_t useLabel, Double_t sigmaCut) | |
525 | { | |
526 | /// Return the track from the store matched with the given track (or 0x0) and the number of matched clusters. | |
527 | /// Matching is done by using the MC label of by comparing cluster/TrackRef positions according to the flag "useLabel". | |
528 | /// WARNING: Who match who matters since the matching algorithm uses the *fraction* of matched clusters of the given track | |
529 | ||
530 | AliMUONTrack *matchedTrack = 0x0; | |
531 | nMatchClusters = 0; | |
532 | ||
533 | if (useLabel) { // by using the MC label | |
96ebe67e | 534 | |
f202486b | 535 | // get the corresponding simulated track if any |
536 | Int_t label = track.GetMCLabel(); | |
537 | matchedTrack = (AliMUONTrack*) trackStore.FindObject(label); | |
48217459 | 538 | |
f202486b | 539 | // get the fraction of matched clusters |
540 | if (matchedTrack) { | |
541 | Int_t nClusters = track.GetNClusters(); | |
542 | for (Int_t iCl = 0; iCl < nClusters; iCl++) | |
543 | if (((AliMUONTrackParam*) track.GetTrackParamAtCluster()->UncheckedAt(iCl))->GetClusterPtr()->GetMCLabel() == label) | |
544 | nMatchClusters++; | |
545 | } | |
96ebe67e | 546 | |
f202486b | 547 | } else { // by comparing cluster/TrackRef positions |
48217459 | 548 | |
f202486b | 549 | // look for the corresponding simulated track if any |
550 | TIter next(trackStore.CreateIterator()); | |
551 | AliMUONTrack* track2; | |
552 | while ( ( track2 = static_cast<AliMUONTrack*>(next()) ) ) { | |
553 | ||
554 | // check compatibility | |
555 | Int_t n = 0; | |
556 | if (track.Match(*track2, sigmaCut, n)) { | |
557 | matchedTrack = track2; | |
558 | nMatchClusters = n; | |
559 | break; | |
560 | } | |
561 | ||
562 | } | |
48217459 | 563 | |
b8dc484b | 564 | } |
f202486b | 565 | |
566 | return matchedTrack; | |
567 | ||
b8dc484b | 568 | } |
569 |