]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrackLight.cxx
removed warnings
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackLight.cxx
index 1b6584a77f9442f16b529f9cdce7f82a97802a39..1dd51a4d858ee5b7e42565cf660a058325a17bd4 100644 (file)
 #include "AliMUONTrack.h"
 #include "AliMUONConstants.h"
 #include "AliMUONVTrackStore.h"
-#include "AliMUONTrackExtrap.h"
+#include "AliMUONTrackParam.h"
 
 #include "AliESDMuonTrack.h"
-#include "AliRunLoader.h"
 #include "AliStack.h"
-#include "AliHeader.h"
+#include "AliLog.h"
 
 #include "TDatabasePDG.h"
 #include "TParticle.h"
 #include "TString.h"
 
+#include <cstdio>
+
 ClassImp(AliMUONTrackLight) 
 
 //===================================================================
@@ -126,8 +127,16 @@ AliMUONTrackLight::AliMUONTrackLight(AliESDMuonTrack* muonTrack)
     fWeight(1)
 { 
   /// constructor
-  //AliMUONTrackLight(); 
-  FillFromESD(muonTrack); 
+  fPgen.SetPxPyPzE(0.,0.,0.,0.); 
+  for (Int_t npar = 0; npar < fgkNParentsMax; npar++){
+    fParentPDGCode[npar] = -1; 
+    fParentPythiaLine[npar] = -1;
+  }
+  for (Int_t i = 0; i < 4; i++){
+    fQuarkPDGCode[i] = -1; 
+    fQuarkPythiaLine[i] = -1; 
+  }
+  FillFromESD(muonTrack);
 }
 
 //============================================
@@ -136,20 +145,58 @@ AliMUONTrackLight::~AliMUONTrackLight()
 /// Destructor
 } 
 
+//============================================
+AliMUONTrackLight& AliMUONTrackLight::operator=(const AliMUONTrackLight& muonCopy)
+{
+  // check assignment to self
+  if (this == &muonCopy) return *this;
+
+  // base class assignment
+  TObject::operator=(muonCopy);
+
+  // assignment operator
+  fPrec = muonCopy.fPrec; 
+  fIsTriggered = muonCopy.fIsTriggered;
+  fCharge = muonCopy.fCharge; 
+  fChi2 = muonCopy.fChi2; 
+  fCentr = muonCopy.fCentr;
+  fPgen = muonCopy.fPgen; 
+  fTrackPythiaLine = muonCopy.fTrackPythiaLine;
+  fTrackPDGCode = muonCopy.fTrackPDGCode;
+  fOscillation = muonCopy.fOscillation; 
+  fNParents = muonCopy.fNParents;
+  fWeight = muonCopy.fWeight;
+  
+  for (Int_t i=0; i<3; i++) fXYZ[i]=muonCopy.fXYZ[i]; 
+  for (Int_t npar = 0; npar < fgkNParentsMax; npar++){
+    fParentPDGCode[npar] = muonCopy.fParentPDGCode[npar]; 
+    fParentPythiaLine[npar] = muonCopy.fParentPythiaLine[npar];
+  }
+  for (Int_t i = 0; i < 4; i++){
+    fQuarkPDGCode[i] = muonCopy.fQuarkPDGCode[i]; 
+    fQuarkPythiaLine[i] = muonCopy.fQuarkPythiaLine[i]; 
+  }
+
+  return *this;
+}    
+
 //============================================
 
 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.);
-  this->SetCharge(Int_t(TMath::Sign(1.,trPar.GetInverseBendingMomentum())));
-  this->SetPxPyPz(trPar.Px(),trPar.Py(), trPar.Pz()); 
+  AliMUONTrackParam* trPar = trackReco->GetTrackParamAtVertex();
+  if (!trPar) {
+    AliError("The track must contain the parameters at vertex");
+    return;
+  }
+  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};
+  Double_t xyz[3] = { trPar->GetNonBendingCoor(), 
+                     trPar->GetBendingCoor(),
+                     trPar->GetZ()};
+  if (zvert!=-9999) xyz[2] = zvert;
   this->SetVertex(xyz); 
 }
 
@@ -186,114 +233,6 @@ void AliMUONTrackLight::SetPxPyPz(Double_t px, Double_t py, Double_t pz){
   fPrec.SetPxPyPzE(px,py,pz,energy);
 }
 
-//============================================
-TParticle* AliMUONTrackLight::FindRefTrack(
-               AliMUONTrack* trackReco, AliMUONVTrackStore* trackRefArray,
-               AliStack* stack, Bool_t tempfix
-       )
-{
-  /// 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
-  ///           corresponding MC particle.
-  /// @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
-  Int_t compPart = 0;
-  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 
-    
-    if (iTrack==4) {
-      compPart++;
-      Int_t trackID = trackRef->GetTrackID();
-      this->SetTrackPythiaLine(trackID);
-      part = stack->Particle(trackID);
-      fTrackPDGCode = part->GetPdgCode();
-    }
-  }
-  if (compPart>1) {
-    AliFatal("More than one particle compatible with the reconstructed track.");
-  } 
-  return part;
-}
-
-//============================================
-Int_t AliMUONTrackLight::TrackCheck(Bool_t *compTrack){
-  /// Apply reconstruction requirements
-  /// Return number of validated conditions 
-  /// If all the tests are verified then TrackCheck = 4 (good track)
-  
-  Int_t iTrack = 0;
-  Int_t hitsInLastStations = 0;
-  
-  // apply reconstruction requirements
-  if (compTrack[0] || compTrack[1]) iTrack++; // at least one hit in st. 0
-  if (compTrack[2] || compTrack[3]) iTrack++; // at least one hit in st. 1
-  if (compTrack[4] || compTrack[5]) iTrack++; // at least one hit in st. 2
-  for (Int_t ch = 6; ch < AliMUONConstants::NTrackingCh(); ch++) {
-    if (compTrack[ch]) hitsInLastStations++; 
-  }
-  if (hitsInLastStations > 2) iTrack++; // at least 3 hits in st. 3 & 4
-  return iTrack;
-}
-
 //============================================
 void AliMUONTrackLight::FillMuonHistory(AliStack *stack, TParticle *part){
   /// scans the muon history to determine parents pdg code and pythia line
@@ -349,7 +288,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
@@ -412,7 +352,7 @@ Int_t AliMUONTrackLight::GetParentFlavour(Int_t idParent) const {
 }
 
 //====================================
-void AliMUONTrackLight::PrintInfo(Option_t* opt){
+void AliMUONTrackLight::PrintInfo(const Option_t* opt){
   /// prints information about the track: 
   /// - "H" muon's decay history
   /// - "K" muon kinematics
@@ -425,22 +365,22 @@ void AliMUONTrackLight::PrintInfo(Option_t* opt){
     TString pdg = "", line = "";
     for(int i = 3; i >= 0; i--){
       if(this->GetQuarkPythiaLine(i)>= 0){
-       sprintf(name, "%4d --> ", this->GetQuarkPythiaLine(i));
+       snprintf(name, 100, "%4d --> ", this->GetQuarkPythiaLine(i));
        line += name;
-       sprintf(name, "%4d --> ", this->GetQuarkPDGCode(i));
+       snprintf(name, 100, "%4d --> ", this->GetQuarkPDGCode(i));
        pdg += name;
       }
     }
     for(int i = 0; i < fNParents; i++){ 
       if(this->GetParentPythiaLine(i)>= 0){
-       sprintf(name, "%7d --> ", this->GetParentPythiaLine(i));
+       snprintf(name, 100, "%7d --> ", this->GetParentPythiaLine(i));
        line += name;
-       sprintf(name, "%7d --> ", this->GetParentPDGCode(i));
+       snprintf(name, 100, "%7d --> ", this->GetParentPDGCode(i));
        pdg += name;
       }
     }
-    sprintf(name, "%4d", this->GetTrackPythiaLine()); line += name;
-    sprintf(name, "%4d", this->GetTrackPDGCode()); pdg += name;
+    snprintf(name, 100, "%4d", this->GetTrackPythiaLine()); line += name;
+    snprintf(name, 100, "%4d", this->GetTrackPDGCode()); pdg += name;
 
     printf("\nmuon's decay history:\n");
     printf(" PDG: %s\n", pdg.Data());
@@ -477,7 +417,7 @@ Bool_t AliMUONTrackLight::IsParentPionOrKaon(Int_t idparent){
   else return kFALSE;
 }
 //====================================
-Bool_t AliMUONTrackLight::IsDiquark(Int_t pdg){
+Bool_t AliMUONTrackLight::IsDiquark(Int_t pdg) const{
   /// check if the provided pdg code corresponds to a diquark 
   pdg = TMath::Abs(pdg);
   if((pdg > 1000) && (pdg%100 < 10)) return kTRUE;