The changes to perform the trigger chamber efficiency determination from ESD
[u/mrichter/AliRoot.git] / MUON / AliMUONVTrackReconstructor.cxx
index 7c44f936b6975d403024135dafd0f07745befd2f..1bccc72cc19104d33a85a1b3cef3f3d62410c359 100644 (file)
@@ -756,164 +756,8 @@ void AliMUONVTrackReconstructor::ValidateTracksWithTrigger(AliMUONVTrackStore& t
   /// Try to match track from tracking system with trigger track
   AliCodeTimerAuto("");
 
-  const Double_t kDeltaZ = TMath::Abs(AliMUONConstants::DefaultChamberZ(12) - AliMUONConstants::DefaultChamberZ(10));
-
-  //static const Double_t kDistSigma[3]={1,1,0.02}; // sigma of distributions (trigger-track) X,Y,slopeY
-  // sigma of distributions (trigger-track) X,Y,slopeY
-  const Double_t kDistSigma[3]={AliMUONConstants::TriggerNonBendingReso(),
-                               AliMUONConstants::TriggerBendingReso(),
-                               1.414 * AliMUONConstants::TriggerBendingReso()/kDeltaZ};
-
-  const Double_t kTrigNonBendReso = AliMUONConstants::TriggerNonBendingReso();
-  const Double_t kTrigBendReso = AliMUONConstants::TriggerBendingReso();
-  const Double_t kTrigSlopeBendReso = 1.414 * AliMUONConstants::TriggerBendingReso()/kDeltaZ;
-  const Double_t kTrigCovSlopeBend = - kTrigBendReso * kTrigBendReso / kDeltaZ;
-
-  // Covariance matrix 3x3 (X,Y,slopeY) for trigger tracks
-  TMatrixD trigCov(3,3);
-  trigCov.Zero();
-  trigCov(0,0) = kTrigNonBendReso * kTrigNonBendReso;
-  trigCov(1,1) = kTrigBendReso * kTrigBendReso;
-  trigCov(2,2) = kTrigSlopeBendReso * kTrigSlopeBendReso;
-  trigCov(1,2) = trigCov(2,1) = kTrigCovSlopeBend;
-
-  Int_t matchTrigger;
-  Int_t loTrgNum(-1);
-  Double_t distTriggerTrack[3], sigma2[3];
-  Double_t xTrack, yTrack, ySlopeTrack, chi2MatchTrigger, minChi2MatchTrigger, chi2;
-
-  TIter itTrack(trackStore.CreateIterator());
-  AliMUONTrack* track;
-
-  const Float_t kZFilterOut = AliMUONConstants::MuonFilterZEnd();
-  const Float_t kFilterThickness = TMath::Abs(kZFilterOut-AliMUONConstants::MuonFilterZBeg()); // cm
-  const Int_t kFirstTrigCh = AliMUONConstants::NTrackingCh();
-  
-  while ( ( track = static_cast<AliMUONTrack*>(itTrack()) ) )
-  {
-    matchTrigger = 0;
-    chi2MatchTrigger = 0.;
-    loTrgNum = -1;
-    Int_t doubleMatch=-1; // Check if track matches 2 trigger tracks
-    Double_t doubleChi2 = -1.;
-    
-    AliMUONTrackParam trackParam(*((AliMUONTrackParam*) (track->GetTrackParamAtCluster()->Last())));
-
-    AliMUONTrackExtrap::ExtrapToZCov(&trackParam, kZFilterOut); // Extrap to muon filter end
-    AliMUONTrackExtrap::AddMCSEffect(&trackParam, kFilterThickness, AliMUONConstants::MuonFilterX0()); // Add MCS effects
-    AliMUONTrackExtrap::ExtrapToZCov(&trackParam, AliMUONConstants::DefaultChamberZ(kFirstTrigCh)); // extrap to 1st trigger chamber
-
-    const TMatrixD& kParamCov = trackParam.GetCovariances();
-    
-    xTrack = trackParam.GetNonBendingCoor();
-    yTrack = trackParam.GetBendingCoor();
-    ySlopeTrack = trackParam.GetBendingSlope();
-
-    // Covariance matrix 3x3 (X,Y,slopeY) for tracker tracks
-    TMatrixD trackCov(3,3);
-    trackCov.Zero();
-    trackCov(0,0) = kParamCov(0,0);
-    trackCov(1,1) = kParamCov(2,2);
-    trackCov(2,2) = kParamCov(3,3);
-    trackCov(1,2) = kParamCov(2,3);
-    trackCov(2,1) = kParamCov(3,2);
-
-    TMatrixD sumCov(trackCov,TMatrixD::kPlus,trigCov);
-
-    Bool_t isCovOK = kTRUE;
-
-    if (sumCov.Determinant() != 0) {
-      sumCov.Invert();
-    } else {
-      AliWarning(" Determinant = 0");
-      isCovOK = kFALSE;
-      sigma2[0] = kParamCov(0,0);
-      sigma2[1] = kParamCov(2,2);
-      sigma2[2] = kParamCov(3,3);
-      for (Int_t iVar = 0; iVar < 3; iVar++) sigma2[iVar] += kDistSigma[iVar] * kDistSigma[iVar];
-    }
-
-    minChi2MatchTrigger = 999.;
-
-    AliMUONTriggerTrack *triggerTrack;
-    TIter itTriggerTrack(triggerTrackStore.CreateIterator());
-    while ( ( triggerTrack = static_cast<AliMUONTriggerTrack*>(itTriggerTrack() ) ) )
-    {
-      distTriggerTrack[0] = triggerTrack->GetX11()-xTrack;
-      distTriggerTrack[1] = triggerTrack->GetY11()-yTrack;
-      distTriggerTrack[2] = TMath::Tan(triggerTrack->GetThetay())-ySlopeTrack;
-
-      if(isCovOK){
-       TMatrixD paramDiff(3,1);
-       for(Int_t iVar = 0; iVar < 3; iVar++)
-         paramDiff(iVar,0) = distTriggerTrack[iVar];
-       
-       TMatrixD tmp(sumCov,TMatrixD::kMult,paramDiff);
-       TMatrixD chi2M(paramDiff,TMatrixD::kTransposeMult,tmp);
-       chi2 = chi2M(0,0);
-      }
-      else {
-       chi2 = 0.;
-       for (Int_t iVar = 0; iVar < 3; iVar++) chi2 += distTriggerTrack[iVar]*distTriggerTrack[iVar]/sigma2[iVar];
-      }
-
-      chi2 /= 3.; // Normalized Chi2: 3 degrees of freedom (X,Y,slopeY)
-      if (chi2 < AliMUONReconstructor::GetRecoParam()->GetMaxNormChi2MatchTrigger()) 
-      {
-        Bool_t isDoubleTrack = (TMath::Abs(chi2 - minChi2MatchTrigger)<1.);
-        if (chi2 < minChi2MatchTrigger && chi2 < AliMUONReconstructor::GetRecoParam()->GetMaxNormChi2MatchTrigger()) 
-        {
-          if(isDoubleTrack)
-          {
-            doubleMatch = loTrgNum;
-            doubleChi2 = chi2MatchTrigger;
-          }
-          minChi2MatchTrigger = chi2;
-          chi2MatchTrigger = chi2;
-          loTrgNum = triggerTrack->GetLoTrgNum();
-          AliMUONLocalTrigger* locTrg = triggerStore.FindLocal(loTrgNum);
-          matchTrigger=1;
-          if(locTrg->LoLpt()>0)matchTrigger=2;
-          if(locTrg->LoHpt()>0)matchTrigger=3;
-        }
-        else if(isDoubleTrack) 
-        {
-          doubleMatch = triggerTrack->GetLoTrgNum();
-          doubleChi2 = chi2;
-        }
-      }
-    }
-    if(doubleMatch>=0)
-    { // If two trigger tracks match, select the one passing more trigger cuts
-      AliDebug(1, Form("Two candidates found: %i and %i",loTrgNum,doubleMatch));
-      AliMUONLocalTrigger* locTrg1 = triggerStore.FindLocal(doubleMatch);
-      if((locTrg1->LoLpt()>0 && matchTrigger<2) || (locTrg1->LoHpt() && matchTrigger<3))
-      {
-        if(locTrg1->LoHpt()>0)matchTrigger=3;
-        else matchTrigger=2;
-        loTrgNum = doubleMatch;
-        chi2MatchTrigger=doubleChi2;
-      }
-    }
-    
-    track->SetMatchTrigger(matchTrigger);
-    track->SetLoTrgNum(loTrgNum);
-    track->SetChi2MatchTrigger(chi2MatchTrigger);
-    
-    AliMUONLocalTrigger* locTrg = static_cast<AliMUONLocalTrigger*>(triggerStore.FindLocal(loTrgNum));
-    
-    if (locTrg)
-    {    
-      track->SetLocalTrigger(locTrg->LoCircuit(),
-                             locTrg->LoStripX(),
-                             locTrg->LoStripY(),
-                             locTrg->LoDev(),
-                             locTrg->LoLpt(),
-                             locTrg->LoHpt());
-    }    
-  }  
-  
-  trackHitPattern.GetHitPattern(trackStore,triggerStore);
+  trackHitPattern.ExecuteValidation(trackStore, triggerTrackStore, triggerStore);
+  trackHitPattern.UpdateQA();
 }
 
   //__________________________________________________________________________