]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSDigit.cxx
#include "AliHeader.h" needed
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigit.cxx
index c137b5896e74c1e2193692eaffb9b0d2cb167351..83ac5d132dbc5665e9cebe8f8da0e72b84f7baf9 100644 (file)
@@ -20,8 +20,6 @@
 //              energy
 //              3 identifiers for the primary particle(s) at the origine of the digit
 //  The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell
-//  It would be nice to replace the 3 identifiers by an array, but, because digits are kept in a TClonesQArray,
-//   it is not possible to stream such an array... (beyond my understqnding!)
 //
 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH)
 
@@ -95,7 +93,7 @@ AliPHOSDigit::~AliPHOSDigit()
 }
 
 //____________________________________________________________________________
-Int_t AliPHOSDigit::Compare(TObject * obj)
+Int_t AliPHOSDigit::Compare(const TObject * obj) const
 {
   // Compares two digits with respect to its Id
   // to sort according increasing Id
@@ -129,7 +127,15 @@ Int_t AliPHOSDigit::GetPrimary(Int_t index) const
   return rv ; 
   
 }
-
+//____________________________________________________________________________
+void AliPHOSDigit::ShiftPrimary(Int_t shift)
+{
+  //shifts primary number to BIG offset, to separate primary in different TreeK
+  Int_t index  ;
+  for(index = 0; index <fNprimary; index ++ ){
+    fPrimary[index] = fPrimary[index]+ shift * 10000000   ;
+  } 
+}
 //____________________________________________________________________________
 Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const 
 {
@@ -150,22 +156,25 @@ AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit)
   fAmp += digit.fAmp ;
   
   Int_t max1 = fNprimary ; 
-  Int_t max2 = digit.fNprimary ; 
-  
-  if ( fNprimary + digit.fNprimary < fNMaxPrimary ) {
-    fNprimary += digit.fNprimary ; 
   
-    Int_t index ; 
-    for (index = 0 ; index < max2 ; index++)
-      fPrimary[index+max1] = (digit.fPrimary)[index] ; 
+  Int_t index ; 
+  for (index = 0 ; index < digit.fNprimary ; index++){
+    Bool_t deja = kTRUE ;
+    Int_t old ;
+    for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
+      if(fPrimary[old] == (digit.fPrimary)[index])
+       deja = kFALSE;
+    }
+    if(deja){
+      fPrimary[fNprimary] = (digit.fPrimary)[index] ; 
+      fNprimary++ ;
+      if(fNprimary>fNMaxPrimary) {
+       cout << "AliPHOSDigit >> Increase NMaxPrimary "<< endl ;
+       return *this ;
+      }
+    }
   }
-  else{
-    cout << "AliPHOSDigit >> Increase NMaxPrimary"<< endl ;
-    Int_t index ; 
-    for (index = max1; index < fNMaxPrimary ; index++)
-      fPrimary[index] = (digit.fPrimary)[index-max1] ; 
-    fNprimary = fNMaxPrimary ;
-  }  
+  
   return *this ;
 }