]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSPpsdRecPoint.cxx
position of the particle initiating the hit in PHOS
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPpsdRecPoint.cxx
index 31f6e377cd4eb90d6e3bdd012fbf29a838ea42d2..a1484cf4f3df298a6e7ff4655c34de1a9af0c1a3 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
-
 //_________________________________________________________________________
 //  A RecPoint (cluster) in the PPSD 
 //  A PPSD RecPoint ends up to be a single digit
+//  Why should I put meaningless comments
+//  just to satisfy
+//  the code checker                
 //                
 //*--  Yves Schutz (SUBATECH)
 
@@ -33,7 +34,9 @@
 
 #include "AliPHOSGeometry.h"
 #include "AliPHOSPpsdRecPoint.h"
+#include "AliPHOSCpvRecPoint.h"
 #include "AliRun.h"
+#include "AliPHOSIndexToObject.h"
 
 ClassImp(AliPHOSPpsdRecPoint)
 
@@ -49,7 +52,7 @@ AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void)
 }
 
 //____________________________________________________________________________
-void AliPHOSPpsdRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
+void AliPHOSPpsdRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
 {
   // adds a digit to the digits list
   // and accumulates the total amplitude and the multiplicity 
@@ -72,7 +75,7 @@ void AliPHOSPpsdRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
     delete [] tempo ;
   }
 
-  fDigitsList[fMulDigit++]  =  (int) &digit  ; 
+  fDigitsList[fMulDigit++]  =  digit.GetIndexInList() ; 
   fAmp += Energy ; 
 }
 
@@ -83,73 +86,86 @@ Int_t AliPHOSPpsdRecPoint::Compare(TObject * obj)
   
   Int_t rv ; 
   
-  AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ; 
-  
-  Float_t x1 , z1 ;
-  Float_t x2 , z2 ;
-  
-  Int_t phosmod1 ;
-  Int_t phosmod2 ;
-  
-  Int_t up1 ;
-  Int_t up2 ; 
-  
-  if(GetUp()) // upper layer
-    up1 = 0 ; 
-  else        // lower layer
-    up1 = 1 ;       
+  if( (strcmp(obj->ClassName() , "AliPHOSPpsdRecPoint" )) == 0)  // PPSD Rec Point
+    {
+     AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ; 
+
+     Float_t x1 , z1 ;
+     Float_t x2 , z2 ;
+     
+     Int_t phosmod1 ;
+     Int_t phosmod2 ;
+     
+     Int_t up1 ;
+     Int_t up2 ; 
   
-  if(clu->GetUp()) // upper layer
-    up2 = 0 ; 
-  else            // lower layer
-    up2 = 1 ;       
-
-  TVector3 posloc ;
-  this->GetLocalPosition(posloc) ;
-  x1 = posloc.X() ;
-  z1 = posloc.Z() ; 
-  phosmod1 = this->GetPHOSMod();  
-  clu->GetLocalPosition(posloc) ;
-  x2 = posloc.X() ;
-  z2 = posloc.Z() ; 
-  phosmod2 = clu->GetPHOSMod();
-
-  if(phosmod1 == phosmod2 ) {
-    if(up1 == up2 ){
-      Int_t rowdif = (Int_t)TMath::Ceil(x1/fDelta) - (Int_t) TMath::Ceil(x2/fDelta) ;
-
-      if (rowdif> 0) 
-       rv = -1 ;
+     if(GetUp()) // upper layer
+       up1 = 0 ; 
+     else        // lower layer
+       up1 = 1 ;       
+     
+     if(clu->GetUp()) // upper layer
+       up2 = 0 ; 
+     else            // lower layer
+       up2 = 1 ;       
+
+     TVector3 posloc ;
+     this->GetLocalPosition(posloc) ;
+     x1 = posloc.X() ;
+     z1 = posloc.Z() ; 
+     phosmod1 = this->GetPHOSMod();  
+     clu->GetLocalPosition(posloc) ;
+     x2 = posloc.X() ;
+     z2 = posloc.Z() ; 
+     phosmod2 = clu->GetPHOSMod();
+     
+     if(phosmod1 == phosmod2 ) {
+       
+       if(up1 == up2 ){
+        Int_t rowdif = (Int_t)TMath::Ceil(x1/fDelta) - (Int_t) TMath::Ceil(x2/fDelta) ;
+        
+        if (rowdif> 0) 
+          rv = -1 ;
       else if(rowdif < 0) 
        rv = 1 ;
-      else if(z1>z2) 
-       rv = -1 ;
-      else 
-       rv = 1 ; 
+        else if(z1>z2) 
+          rv = -1 ;
+        else 
+          rv = 1 ; 
+       }
+       
+       else {
+        
+        if(up1 < up2 ) // Upper level first (up = True or False, True > False)
+          rv = 1 ;   
+        else 
+          rv = - 1 ;
+       }
+       
+     } // if phosmod1 == phosmod2
+     
+     else {
+       
+       if(phosmod1 < phosmod2 ) 
+        rv = -1 ;
+       else 
+        rv = 1 ;
+       
+     }
+     
+     return rv ;      
     }
-
-    else {
-
-      if(up1 < up2 ) // Upper level first (up = True or False, True > False)
-       rv = 1 ;   
+  else
+    {
+      AliPHOSCpvRecPoint * clu  = (AliPHOSCpvRecPoint *) obj ;   
+      if(this->GetPHOSMod()  < clu->GetPHOSMod() ) 
+       rv = -1 ;
       else 
-       rv = - 1 ;
+       rv = 1 ;
+      return rv ;
     }
-    
-  } // if phosmod1 == phosmod2
-
-  else {
 
-    if(phosmod1 < phosmod2 ) 
-      rv = -1 ;
-    else 
-      rv = 1 ;
   
-}
-  
-  return rv ; 
 }
 
 //____________________________________________________________________________
@@ -157,6 +173,8 @@ void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos)
 {
   // Calculates the local position in the PHOS-PPSD-module corrdinates
   
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   if( fLocPos.X() < 1000000.) { //allready evaluated
    LPos = fLocPos ;
    return ;
@@ -173,7 +191,7 @@ void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos)
   Int_t iDigit;
 
   for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit]
+    digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) )
  
     Float_t xi ;
     Float_t zi ;
@@ -197,11 +215,16 @@ void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos)
 //____________________________________________________________________________
 Bool_t AliPHOSPpsdRecPoint::GetUp() 
 {
+  // Are we in the uper PPSD module ?
+
   Int_t relid[4] ;
   
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
   
-  AliPHOSDigit *digit = (AliPHOSDigit *)fDigitsList[0] ; 
+  
+  AliPHOSDigit *digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[0]) ) ; 
   
   phosgeom->AbsToRelNumbering(digit->GetId(),relid);
   Bool_t up ;
@@ -256,18 +279,22 @@ void AliPHOSPpsdRecPoint::Print(Option_t * option)
   Float_t zi ;
   Int_t relid[4] ; 
 
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit];
-    phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-    phosgeom->RelPosInModule(relid, xi, zi);
-    cout << " Id = " << digit->GetId() ;  
-    cout << "  Phos mod = " << relid[0] ;  
-    cout << "  PPSD mod = " << relid[1] ;  
-    cout << "  x = " << xi ;  
-    cout << "  z = " << zi ;  
-    cout << "   Energy = " << digit->GetAmp() << endl ;
+    digit = please->GimeDigit( fDigitsList[iDigit] ) ; 
+    if (digit) {
+      phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
+      phosgeom->RelPosInModule(relid, xi, zi);
+      cout << " Id = " << digit->GetId() ;  
+      cout << "  Phos mod = " << relid[0] ;  
+      cout << "  PPSD mod = " << relid[1] ;  
+      cout << "  x = " << xi ;  
+      cout << "  z = " << zi ;  
+      cout << "   Energy = " << digit->GetAmp() << endl ;
+    }
   }
   cout << "       Multiplicity    = " << fMulDigit  << endl ;
+  cout << "       Stored at position " << fIndexInList << endl ; 
 }