]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrackLight.cxx
Update to fix the fact that AliRawReader::Create does not work correctly in online...
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackLight.cxx
index 1b6584a77f9442f16b529f9cdce7f82a97802a39..277cc2f178fbdc4c144feb3fda49646c2b651cca 100644 (file)
@@ -41,6 +41,7 @@
 #include "AliMUONConstants.h"
 #include "AliMUONVTrackStore.h"
 #include "AliMUONTrackExtrap.h"
+#include "AliMUONTrackParam.h"
 
 #include "AliESDMuonTrack.h"
 #include "AliRunLoader.h"
@@ -140,16 +141,20 @@ AliMUONTrackLight::~AliMUONTrackLight()
 
 void AliMUONTrackLight::FillFromAliMUONTrack(AliMUONTrack *trackReco,Double_t zvert){
   /// this method sets the muon reconstructed momentum according to the value given by AliMUONTrack
-  AliMUONTrackParam trPar(*((AliMUONTrackParam*) (trackReco->GetTrackParamAtCluster()->First())));
-  //  AliMUONTrackParam *trPar  = trackReco->GetTrackParamAtVertex();
-  AliMUONTrackExtrap::ExtrapToVertex(&trPar,0.,0.,0.,0.,0.);
+  AliMUONTrackParam trPar;
+  if (trackReco->GetTrackParamAtVertex()) trPar = *(trackReco->GetTrackParamAtVertex());
+  else {
+    trPar = *((AliMUONTrackParam*) trackReco->GetTrackParamAtCluster()->First());
+    AliMUONTrackExtrap::ExtrapToVertex(&trPar,0.,0.,0.,0.,0.);
+  }
   this->SetCharge(Int_t(TMath::Sign(1.,trPar.GetInverseBendingMomentum())));
   this->SetPxPyPz(trPar.Px(),trPar.Py(), trPar.Pz()); 
   this->SetTriggered(trackReco->GetMatchTrigger()); 
   
   Double_t xyz[3] = { trPar.GetNonBendingCoor(), 
                      trPar.GetBendingCoor(),
-                     zvert};
+                     trPar.GetZ()};
+  if (zvert!=-9999) xyz[2] = zvert;
   this->SetVertex(xyz); 
 }
 
@@ -189,8 +194,7 @@ void AliMUONTrackLight::SetPxPyPz(Double_t px, Double_t py, Double_t pz){
 //============================================
 TParticle* AliMUONTrackLight::FindRefTrack(
                AliMUONTrack* trackReco, AliMUONVTrackStore* trackRefArray,
-               AliStack* stack, Bool_t tempfix
-       )
+               AliStack* stack)
 {
   /// Find the Monte Carlo (MC) particle that corresponds to a given reconstructed track.
   /// @param trackReco  This is the reconstructed track for which we want to find a
@@ -198,71 +202,39 @@ TParticle* AliMUONTrackLight::FindRefTrack(
   /// @param trackRefArray  The list of MC reference tracks as generated by
   ///           AliMUONRecoCheck::ReconstructedTracks for example.
   /// @param stack  The MC stack of simulated particles.
-  /// @param tempfix  This specifies if a temporary fix should be applied, where we only
-  ///           check if the first hit on chamber 1, the vertex momentum, the X-Y vertex
-  ///           coordinate and X-Y slope match between 'trackReco' and a MC reference
-  ///           track in 'trackRefArray'.
-  ///           This temporary fix is necessary while AliMUONTrack objects are no longer
-  ///           stored after reconstruction and the hit information is not completely
-  ///           stored in the ESD data.
   
   TParticle *part = 0; 
-  const Double_t kSigma2Cut = 16;  // 4 sigmas cut, kSigma2Cut = 4*4
+  const Double_t kSigmaCut = 4;  // 4 sigmas cut
   Int_t compPart = 0;
+  Bool_t compTrack;
+  
   TIter next(trackRefArray->CreateIterator());
   AliMUONTrack* trackRef;
   while ( (trackRef = static_cast<AliMUONTrack*>(next())) ) {
     // check if trackRef is compatible with trackReco:
-    //routine returns for each chamber a yes/no information if the
-    //hit of rec. track and hit of referenced track are compatible
-    Bool_t *compTrack = trackRef->CompatibleTrack(trackReco,kSigma2Cut);
-    Int_t iTrack = 0;
-    if (tempfix)
-    {
-      // All we can check with this temporary fix is that the first hit on chamber 1
-      // is the same and that the particles momentum, slope and vertex X and Y are
-      // compatible within resolution.
-      if (compTrack[0]) iTrack++;
-      AliMUONTrackParam* paramA = trackRef->GetTrackParamAtVertex();
-      AliMUONTrackParam* paramB = trackReco->GetTrackParamAtVertex();
-      if (paramA != NULL and paramB != NULL)
-      {
-        // Fetch the variances.
-        Double_t varX = paramA->GetCovariances()[0][0] + paramB->GetCovariances()[0][0];
-        Double_t varSlopeX = paramA->GetCovariances()[1][1] + paramB->GetCovariances()[1][1];
-        Double_t varY = paramA->GetCovariances()[2][2] + paramB->GetCovariances()[2][2];
-        Double_t varSlopeY = paramA->GetCovariances()[3][3] + paramB->GetCovariances()[3][3];
-        Double_t varInvP = paramA->GetCovariances()[4][4] + paramB->GetCovariances()[4][4];
-        // We might have to fill these variances with defaults.
-        if (varX == 0) varX = AliMUONConstants::DefaultNonBendingReso2();
-        if (varSlopeX == 0) varSlopeX = AliMUONConstants::DefaultNonBendingReso2();
-        if (varY == 0) varY = AliMUONConstants::DefaultBendingReso2();
-        if (varSlopeY == 0) varSlopeY = AliMUONConstants::DefaultBendingReso2();
-        if (varInvP == 0)
-        {
-               // Use ~10% resolution for momentum.
-               Double_t sigmaA = 0.1 * paramA->GetInverseBendingMomentum();
-               Double_t sigmaB = 0.1 * paramB->GetInverseBendingMomentum();
-               varInvP = sigmaA*sigmaA + sigmaB*sigmaB;
-        }
-        // Calculate the differences between parameters.
-        Double_t diffX = paramA->GetNonBendingCoor() - paramB->GetNonBendingCoor();
-        Double_t diffSlopeX = paramA->GetNonBendingSlope() - paramB->GetNonBendingSlope();
-        Double_t diffY = paramA->GetBendingCoor() - paramB->GetBendingCoor();
-        Double_t diffSlopeY = paramA->GetBendingSlope() - paramB->GetBendingSlope();
-        Double_t diffInvP = paramA->GetInverseBendingMomentum() - paramB->GetInverseBendingMomentum();
-        // Check that all the parameters are within kSigma2Cut limit.
-        if (diffX*diffX / varX < kSigma2Cut and diffY*diffY / varY < kSigma2Cut) iTrack++;
-        if (diffSlopeX*diffSlopeX / varSlopeX < kSigma2Cut and diffSlopeY*diffSlopeY / varSlopeY < kSigma2Cut) iTrack++;
-        if (diffInvP*diffInvP / varInvP < kSigma2Cut) iTrack++;
-      }
-    }
-    else
-      iTrack = this->TrackCheck(compTrack); //returns number of validated conditions 
+    compTrack = kFALSE;
     
-    if (iTrack==4) {
+    if (trackReco->GetNClusters() > 1) {
+      
+      // check cluster by cluster if trackReco contain info at each cluster
+      Bool_t compTrackArray[10];
+      trackRef->CompatibleTrack(trackReco,kSigmaCut,compTrackArray);
+      if (TrackCheck(compTrackArray) == 4) compTrack = kTRUE;
+      
+    } else {
+      
+      // otherwise check only parameters at the z position of the first trackRef
+      AliMUONTrackParam *refParam = (AliMUONTrackParam*) trackRef->GetTrackParamAtCluster()->First();
+      AliMUONTrackParam recoParam(*((AliMUONTrackParam*) trackReco->GetTrackParamAtCluster()->First()));
+      AliMUONTrackExtrap::ExtrapToZCov(&recoParam, refParam->GetZ());
+      Double_t chi2;
+      if (refParam->CompatibleTrackParam(recoParam, kSigmaCut, chi2)) compTrack = kTRUE;
+      
+    }
+      
+    if (compTrack) {
       compPart++;
-      Int_t trackID = trackRef->GetTrackID();
+      Int_t trackID = trackRef->GetUniqueID();
       this->SetTrackPythiaLine(trackID);
       part = stack->Particle(trackID);
       fTrackPDGCode = part->GetPdgCode();
@@ -349,7 +321,8 @@ void AliMUONTrackLight::FillMuonHistory(AliStack *stack, TParticle *part){
           this->GetParentFlavour(0), TMath::Abs(this->GetQuarkPDGCode(countP)))
         );
       
-      Int_t pdg = this->GetQuarkPDGCode(countP), line = this->GetQuarkPythiaLine(countP);
+      pdg = this->GetQuarkPDGCode(countP);
+      Int_t line = this->GetQuarkPythiaLine(countP);
       this->ResetQuarkInfo();
       while(TMath::Abs(pdg) != this->GetParentFlavour(0)){//pdg of q,g in Pythia listing following the wrong string end
                                                         //must coincide with the flavour of the last fragmented mother