+//_____________________________________________________________________________
+void AliMUONRecoCheck::MakeTriggerableTracks()
+{
+ /// Make triggerable tracks
+ if (!(fRecoTriggerRefStore = AliMUONESDInterface::NewTriggerTrackStore()))
+ return;
+
+ Double_t x, y, z, slopeX, slopeY, pZ, xLoc, yLoc, zLoc;
+ TParticle* particle;
+ TClonesArray* trackRefs;
+ Int_t nTrackRef = fMCEventHandler->MCEvent()->GetNumberOfTracks();
+
+ // 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;
+
+ AliMUONTriggerTrack track;
+ AliMUONDigitStoreV2S digitStore;
+ Int_t hitsOnTrigger = 0;
+ Int_t currCh = -1;
+
+ // 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;
+
+ // check chamberId of current trackReference
+ Int_t detElemId = trackReference->UserId();
+ Int_t chamberId = detElemId / 100 - 1;
+ if (chamberId < AliMUONConstants::NTrackingCh() || chamberId >= AliMUONConstants::NCh() ) continue;
+
+ // Get track parameters of current hit
+ x = trackReference->X();
+ y = trackReference->Y();
+ z = trackReference->Z();
+
+ if ( InitTriggerResponse() ) {
+ fGeometryTransformer->Global2Local(detElemId, x, y, z, xLoc, yLoc, zLoc);
+
+ Int_t nboard = 0;
+ for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
+ {
+ const AliMpVSegmentation* seg
+ = AliMpSegmentation::Instance()
+ ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
+
+ AliMpPad pad = seg->PadByPosition(xLoc,yLoc,kFALSE);
+ Int_t ix = pad.GetIx();
+ Int_t iy = pad.GetIy();
+
+ if ( !pad.IsValid() ) continue;
+
+ if ( cath == AliMp::kCath0 ) nboard = pad.GetLocalBoardId(0);
+
+ AliMUONVDigit* digit = digitStore.Add(detElemId, nboard, pad.GetLocalBoardChannel(0),
+ cath, AliMUONVDigitStore::kDeny);
+ if (digit) {
+ digit->SetPadXY(ix,iy);
+ digit->SetCharge(1.);
+ }
+ }
+ }
+
+ if ( hitsOnTrigger == 0 ) {
+ pZ = trackReference->Pz();
+ slopeX = ( pZ == 0. ) ? 99999. : trackReference->Px() / pZ;
+ slopeY = ( pZ == 0. ) ? 99999. : trackReference->Py() / pZ;
+
+ track.SetX11(x);
+ track.SetY11(y);
+ track.SetZ11(z);
+ track.SetSlopeX(slopeX);
+ track.SetSlopeY(slopeY);
+ }
+
+ if ( currCh != chamberId ) {
+ hitsOnTrigger++;
+ currCh = chamberId;
+ }
+
+ } // loop on hits
+
+ if ( hitsOnTrigger < 3 ) continue;
+
+ // Check if the track passes the trigger algorithm
+ if ( InitTriggerResponse() ) {
+ AliMUONTriggerStoreV1 triggerStore;
+ fTriggerElectronics->Digits2Trigger(digitStore,triggerStore);
+
+ TIter next(triggerStore.CreateIterator());
+ AliMUONLocalTrigger* locTrg(0x0);
+
+ Int_t ptCutLevel = 0;
+
+ while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
+ {
+ if ( locTrg->IsTrigX() && locTrg->IsTrigY() )
+ {
+ ptCutLevel = TMath::Max(ptCutLevel, 1);
+ if ( locTrg->LoHpt() ) ptCutLevel = TMath::Max(ptCutLevel, 3);
+ else if ( locTrg->LoLpt() ) ptCutLevel = TMath::Max(ptCutLevel, 2);
+ } // board is fired
+ } // end of loop on Local Trigger
+ track.SetPtCutLevel(ptCutLevel);
+ }
+ track.SetUniqueID(iTrackRef);
+ fRecoTriggerRefStore->Add(track);
+ }
+}
+
+