- // debug facility
-
- AliMUONTrack *track;
- AliMUONHitForRec *hitForRec;
- TClonesArray * hitForRecAtHit = 0;
- Float_t xRec,yRec,zRec;
-
- Int_t nTrackRef = fMuonTrackRef->GetEntriesFast();
-
- printf(" ******************************* \n");
- printf(" nb of tracks %d \n",nTrackRef);
-
- for (Int_t index = 0; index < nTrackRef; index++) {
- track = (AliMUONTrack*)fMuonTrackRef->At(index);
- hitForRecAtHit = track->GetHitForRecAtHit();
- Int_t nTrackHits = hitForRecAtHit->GetEntriesFast();
- printf(" track number %d \n",index);
- for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
- hitForRec = (AliMUONHitForRec*) hitForRecAtHit->At(iHit);
- xRec = hitForRec->GetNonBendingCoor();
- yRec = hitForRec->GetBendingCoor();
- zRec = hitForRec->GetZ();
- printf(" x,y,z: %f , %f , %f \n",xRec,yRec,zRec);
+ /// Make reconstructible tracks
+ AliMUONVTrackStore *tmpTrackRefStore = AliMUONESDInterface::NewTrackStore();
+ if (!tmpTrackRefStore) return;
+
+ Double_t x, y, z, pX, pY, pZ, bendingSlope, nonBendingSlope, inverseBendingMomentum;
+ TParticle* particle;
+ TClonesArray* trackRefs;
+ Int_t nTrackRef = fMCEventHandler->MCEvent()->GetNumberOfTracks();
+ AliMUONVClusterStore* cStore = AliMUONESDInterface::NewClusterStore();
+ if (!cStore) return;
+ AliMUONVCluster* hit = cStore->CreateCluster(0,0,0);
+
+ // loop over simulated tracks
+ for (Int_t iTrackRef = 0; iTrackRef < nTrackRef; ++iTrackRef) {
+ Int_t nHits = fMCEventHandler->GetParticleAndTR(iTrackRef, particle, trackRefs);
+
+ // skip empty trackRefs
+ if (nHits < 1) continue;
+
+ // get the particle charge for further calculation
+ TParticlePDG* ppdg = particle->GetPDG();
+ Int_t charge = ppdg != NULL ? (Int_t)(ppdg->Charge()/3.0) : 0;
+
+ AliMUONTrack track;
+
+ // loop over simulated track hits
+ for (Int_t iHit = 0; iHit < nHits; ++iHit) {
+ AliTrackReference* trackReference = static_cast<AliTrackReference*>(trackRefs->UncheckedAt(iHit));
+
+ // skip trackRefs not in MUON
+ if (trackReference->DetectorId() != AliTrackReference::kMUON) continue;
+
+ // Get track parameters of current hit
+ x = trackReference->X();
+ y = trackReference->Y();
+ z = trackReference->Z();
+ pX = trackReference->Px();
+ pY = trackReference->Py();
+ pZ = trackReference->Pz();
+
+ // check chamberId of current trackReference
+ Int_t detElemId = trackReference->UserId();
+ Int_t chamberId = detElemId / 100 - 1;
+ if (chamberId < 0 || chamberId >= AliMUONConstants::NTrackingCh()) continue;
+
+ // set hit parameters
+ hit->SetUniqueID(AliMUONVCluster::BuildUniqueID(chamberId, detElemId, iHit));
+ hit->SetXYZ(x,y,z);
+ hit->SetErrXY(0.,0.);
+
+ // compute track parameters at hit
+ bendingSlope = 0;
+ nonBendingSlope = 0;
+ inverseBendingMomentum = 0;
+ if (TMath::Abs(pZ) > 0) {
+ bendingSlope = pY/pZ;
+ nonBendingSlope = pX/pZ;
+ }
+ Double_t pYZ = TMath::Sqrt(pY*pY+pZ*pZ);
+ if (pYZ >0) inverseBendingMomentum = 1/pYZ;
+ inverseBendingMomentum *= charge;
+
+ // set track parameters at hit
+ AliMUONTrackParam trackParam;
+ trackParam.SetNonBendingCoor(x);
+ trackParam.SetBendingCoor(y);
+ trackParam.SetZ(z);
+ trackParam.SetBendingSlope(bendingSlope);
+ trackParam.SetNonBendingSlope(nonBendingSlope);
+ trackParam.SetInverseBendingMomentum(inverseBendingMomentum);
+
+ // add track parameters at current hit to the track
+ track.AddTrackParamAtCluster(trackParam, *hit, kTRUE);
+ }
+
+ // if none of the track hits was in MUON, goto the next track
+ if (track.GetNClusters() < 1) continue;
+
+ // get track parameters at particle's vertex
+ x = particle->Vx();
+ y = particle->Vy();
+ z = particle->Vz();
+ pX = particle->Px();
+ pY = particle->Py();
+ pZ = particle->Pz();
+
+ // compute rest of track parameters at particle's vertex
+ bendingSlope = 0;
+ nonBendingSlope = 0;
+ inverseBendingMomentum = 0;
+ if (TMath::Abs(pZ) > 0) {
+ bendingSlope = pY/pZ;
+ nonBendingSlope = pX/pZ;