]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSRecParticle.cxx
Coding conventions for PHOS
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecParticle.cxx
index 022ef40d22fe066079378646bcce84084ba39b64..78224515d148b1011588586dd441e979dab4414c 100644 (file)
@@ -141,7 +141,7 @@ const TParticle * AliPHOSRecParticle::GetPrimary() const
 } 
   
 //____________________________________________________________________________
-const Int_t AliPHOSRecParticle::GetPrimaryIndex() const  
+Int_t AliPHOSRecParticle::GetPrimaryIndex() const  
 {
   // Get the primary track index in TreeK which deposits the most energy
   // in Digits which forms EmcRecPoint, which produces TrackSegment,
@@ -151,7 +151,8 @@ const Int_t AliPHOSRecParticle::GetPrimaryIndex() const
   AliPHOSGetter * gime = AliPHOSGetter::Instance() ; 
   if (!gime) 
     AliError(Form("Getter not yet instantiated")) ; 
-  gime->Event(gime->EventNumber(), "DRTX") ; 
+  //PH  gime->Event(gime->EventNumber(), "DRTX") ; 
+  gime->Event(gime->EventNumber(), "DRT") ; 
   
   // Get TrackSegment corresponding to this RecParticle
   AliPHOSTrackSegment *ts          = gime->TrackSegment(fPHOSTrackSegment);
@@ -177,40 +178,67 @@ const Int_t AliPHOSRecParticle::GetPrimaryIndex() const
     }
   }
   digit = gime->Digit(digitList[bestDigitIndex]);
-
+  
   // Get the list of primary tracks producing this digit
   // and find which track has more track energy.
-  Int_t nPrimary = digit->GetNprimary();
-  TParticle *track = 0;
-  Double_t energyEM     = 0;
-  Double_t energyHadron = 0;
-  Int_t    trackEM      = -1;
-  Int_t    trackHadron  = -1;
-  for (Int_t iPrim=0; iPrim<nPrimary; iPrim++) {
-    Int_t iPrimary = digit->GetPrimary(iPrim+1);
-    if (iPrimary == -1 || TMath::Abs(iPrimary)>10000000)
-      continue ;  //PH 10000000 is the shift of the track 
-                  //PH indexes in the underlying event
-    track = gime->Primary(iPrimary);
-    Int_t pdgCode   = track->GetPdgCode();
-    Double_t energy = track->Energy();
-    if (pdgCode==22 || TMath::Abs(pdgCode)==11) {
-      if (energy > energyEM) {
-       energyEM = energy;
-       trackEM = iPrimary;
-      }
-    }
-    else {
-      if (energy > energyHadron) {
-       energyHadron = energy;
-       trackHadron = iPrimary;
+  //Int_t nPrimary = digit->GetNprimary();
+  //TParticle *track = 0;
+  //Double_t energyEM     = 0;
+  //Double_t energyHadron = 0;
+  //Int_t    trackEM      = -1;
+  //Int_t    trackHadron  = -1;
+  //for (Int_t iPrim=0; iPrim<nPrimary; iPrim++) {
+  //  Int_t iPrimary = digit->GetPrimary(iPrim+1);
+  //  if (iPrimary == -1 || TMath::Abs(iPrimary)>10000000)
+  //    continue ;  //PH 10000000 is the shift of the track 
+  //                //PH indexes in the underlying event
+  //  track = gime->Primary(iPrimary);
+  //  Int_t pdgCode   = track->GetPdgCode();
+  //  Double_t energy = track->Energy();
+  //  if (pdgCode==22 || TMath::Abs(pdgCode)==11) {
+  //    if (energy > energyEM) {
+  //   energyEM = energy;
+  //   trackEM = iPrimary;
+  //      }
+  //   }
+  //  else {
+  //     if (energy > energyHadron) {
+  //   energyHadron = energy;
+  //   trackHadron = iPrimary;
+       //    }
+  //  }
+  //}
+  // Preferences are given to electromagnetic tracks
+  //if (trackEM     != -1) return trackEM;     // track is gamma or e+-
+  //if (trackHadron != -1) return trackHadron; // track is hadron
+  //return -12345;                             // no track found :(
+
+
+  // Get the list of hits producing this digit,
+  // find which hit has deposited more energy 
+  // and find the primary track.
+
+  AliPHOSHit *hit = 0;
+  TClonesArray *hits = gime->Hits();
+  Double_t maxedep  =  0;
+  Int_t    maxtrack = -1;
+  Int_t    nHits    = hits ->GetEntries();
+  Int_t    id       = digit->GetId();
+
+  for (Int_t iHit=0; iHit<nHits; iHit++) {
+    hit = gime->Hit(iHit);
+    if(hit->GetId() == id){
+      Double_t edep  = hit->GetEnergy();
+      Int_t    track = hit->GetPrimary();
+      if(edep > maxedep){
+       maxedep  = edep;
+       maxtrack = track;
       }
     }
   }
-  // Preferences are given to electromagnetic tracks
-  if (trackEM     != -1) return trackEM;     // track is gamma or e+-
-  if (trackHadron != -1) return trackHadron; // track is hadron
-  return -12345;                             // no track found :(
+
+  if (maxtrack != -1) return maxtrack; // track is hadron
+  return -12345;                       // no track found :(
 }
 
 //____________________________________________________________________________
@@ -235,7 +263,7 @@ const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const
 }
 
 //____________________________________________________________________________
-void AliPHOSRecParticle::SetPID(Int_t type, Double_t weight)
+void AliPHOSRecParticle::SetPID(Int_t type, Float_t weight)
 {
   // Set the probability densities that this reconstructed particle
   // has a type of i: