]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSPpsdRecPoint.cxx
removed iostream
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPpsdRecPoint.cxx
index 3f75e65131aaf05930f8250309142e3312a7a3df..bc3ca8205afc11837652308b01dcbf953b66862e 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
+/* $Id$ */
 //_________________________________________________________________________
-// RecPoint in the PHOS PPSD: a list of AliPHOSDigit's
-//*-- Author : Yves Schutz  SUBATECH 
-//////////////////////////////////////////////////////////////////////////////
+//  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)
 
 // --- ROOT system ---
 
-// --- Standard library ---
+#include "TPad.h"
 
-#include <iostream.h>
+// --- Standard library ---
 
 // --- AliRoot header files ---
 
 #include "AliPHOSGeometry.h"
 #include "AliPHOSPpsdRecPoint.h"
+#include "AliPHOSCpvRecPoint.h"
 #include "AliRun.h"
+#include "AliPHOSGetter.h"
 
 ClassImp(AliPHOSPpsdRecPoint)
 
 //____________________________________________________________________________
 AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void)
 { 
+  // ctor
+
   fMulDigit = 0 ;  
-  AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;  
-  fDelta = geom->GetCrystalSize(0) ; 
   fLocPos.SetX(1000000.)  ;      //Local position should be evaluated
 }
 
 //____________________________________________________________________________
-AliPHOSPpsdRecPoint::~AliPHOSPpsdRecPoint(void) // dtor
-{ 
-  delete fDigitsList ; 
-}
-
-//____________________________________________________________________________
-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 
   
   
   if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists 
-    int * tempo = new ( int[fMaxDigit*=2] ) ; 
+    fMaxDigit*=2 ; 
+    int * tempo = new ( int[fMaxDigit] ) ; 
     Int_t index ; 
     
     for ( index = 0 ; index < fMulDigit ; index++ )
       tempo[index] = fDigitsList[index] ;
     
-    delete fDigitsList ; 
-    fDigitsList = tempo ;
+    delete []  fDigitsList ; 
+    fDigitsList =  new ( int[fMaxDigit] ) ;
+   
+    for ( index = 0 ; index < fMulDigit ; index++ )
+      fDigitsList[index] = tempo[index] ;
+    delete [] tempo ;
   }
-  
-  fDigitsList[fMulDigit++]  =  (int) &digit  ; 
+
+  fDigitsList[fMulDigit++]  =  digit.GetIndexInList() ; 
   fAmp += Energy ; 
+  EvalPHOSMod(&digit) ;
 }
 
-
-
-
 //____________________________________________________________________________
-Int_t AliPHOSPpsdRecPoint::Compare(TObject * obj)
+Int_t AliPHOSPpsdRecPoint::Compare(const TObject * obj) const
 {
+  // Compares according to the position
+  Float_t delta = 1 ; //width of the "Sorting row"
+
   Int_t rv ; 
   
-  AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ; 
+  if( (strcmp(obj->ClassName() , "AliPHOSPpsdRecPoint" )) == 0)  // PPSD Rec Point
+    {
+     AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ; 
+
+     Float_t x1 , z1 ;    //This rec point
+     Float_t x2 , z2 ;    //
+     
+     Int_t phosmod1 ;
+     Int_t phosmod2 ;
+     
+     Int_t up1 ;
+     Int_t up2 ; 
   
-  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(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) 
+     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 ;
+     GetLocalPosition(posloc) ;
+     x1 = posloc.X() ;
+     z1 = posloc.Z() ; 
+     phosmod1 = 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/delta) - (Int_t) TMath::Ceil(x2/delta) ;
+        
+        if (rowdif> 0) 
+          rv = 1 ;
+        else if(rowdif < 0) 
+          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
+    {
+      AliPHOSCpvRecPoint * clu  = (AliPHOSCpvRecPoint *) obj ;   
+      if(GetPHOSMod()  < clu->GetPHOSMod() ) 
        rv = -1 ;
       else 
-       rv = 1 ; 
+       rv = 1 ;
+      return rv ;
     }
 
-    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 ; 
 }
 
 //____________________________________________________________________________
-void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos){
-
-  if( fLocPos.X() < 1000000.) { //allready evaluated
-   LPos = fLocPos ;
-   return ;
-  }
+void AliPHOSPpsdRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits )
+{
+  // calculates all the characteristics of the RecPoint
+  AliPHOSRecPoint::EvalAll(logWeight,digits) ;
+  EvalLocalPosition(logWeight,digits) ;
+  EvalUp(digits) ;
+}
 
+//____________________________________________________________________________
+void AliPHOSPpsdRecPoint::EvalLocalPosition(Float_t logWeight,TClonesArray * digits )
+{
+  // Calculates the local position in the PHOS-PPSD-module coordinates
+  
   Int_t relid[4] ;
 
   Float_t x = 0. ;
   Float_t z = 0. ;
 
-  AliPHOSGeometry * PHOSGeom = (AliPHOSGeometry *) fGeom ;
+  AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
+  AliPHOSGeometry * phosgeom =  (AliPHOSGeometry*)gime->PHOSGeometry();
   
   AliPHOSDigit * digit ;
   Int_t iDigit;
 
-  for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit]
+  for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
+    digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) 
  
     Float_t xi ;
     Float_t zi ;
-    PHOSGeom->AbsToRelNumbering(digit->GetId(), relid) ;
-    PHOSGeom->RelPosInModule(relid, xi, zi);
+    phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
+    phosgeom->RelPosInModule(relid, xi, zi);
     x += xi ;
     z += zi ;
   }
 
-  x   /= fMulDigit ;
-  z   /= fMulDigit ;
+  x /= fMulDigit ;
+  z /= fMulDigit ;
 
   fLocPos.SetX(x)  ;
   fLocPos.SetY(0.) ;
   fLocPos.SetZ(z)  ;
 
-  LPos = fLocPos ;
 }
 
 //____________________________________________________________________________
-Bool_t AliPHOSPpsdRecPoint::GetUp() 
+void AliPHOSPpsdRecPoint::EvalUp(TClonesArray * digits)
 {
+  // Are we in the uper PPSD module ?
+
   Int_t relid[4] ;
   
-  AliPHOSGeometry * PHOSGeom = (AliPHOSGeometry *) fGeom ;
+  AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
+  AliPHOSGeometry * phosgeom =  (AliPHOSGeometry*)gime->PHOSGeometry();
   
-  AliPHOSDigit *digit = (AliPHOSDigit *)fDigitsList[0] ; 
   
-  PHOSGeom->AbsToRelNumbering(digit->GetId(),relid);
-  Bool_t up ;
+  AliPHOSDigit *digit = (AliPHOSDigit *) digits->At(fDigitsList[0]) ; 
+  
+  phosgeom->AbsToRelNumbering(digit->GetId(),relid);
 
   if((Int_t)TMath::Ceil((Float_t)relid[1]/
-                       (PHOSGeom->GetNumberOfModulesPhi()*PHOSGeom->GetNumberOfModulesZ())-0.0001 ) > 1) 
-    up = kFALSE ;
+                       (phosgeom->GetNumberOfModulesPhi()*phosgeom->GetNumberOfModulesZ())-0.0001 ) > 1) 
+    fUp = kFALSE ;
   else  
-    up = kTRUE ;
+    fUp = kTRUE ;
   
-  return up ;
 }
-
-//____________________________________________________________________________
-void AliPHOSPpsdRecPoint::Print(Option_t * option) 
+//______________________________________________________________________________
+void AliPHOSPpsdRecPoint::Paint(Option_t *)
 {
-  cout << "AliPHOSPpsdRecPoint: " << endl ;
+  //*-*-*-*-*-*-*-*-*-*-*Paint this ALiRecPoint as a TMarker  with its current attributes*-*-*-*-*-*-*
+  //*-*                  =============================================
+
+  TVector3 pos(0.,0.,0.) ;
+  GetLocalPosition(pos) ;
+  Coord_t x = pos.X() ;
+  Coord_t y = pos.Z() ;
+  Color_t markercolor = 1 ;
+  Size_t  markersize  = 1. ;
+  Style_t markerstyle = 2 ;
+  if (GetUp()) 
+    markerstyle = 3 ;
   
-  AliPHOSDigit * digit ; 
-  Int_t iDigit;
-
-  for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit];
-    cout << "     digit Id          = " << digit->GetId()  
-         << "     digit Energy      = " << digit->GetAmp() << endl ;
+  if (!gPad->IsBatch()) {
+    gVirtualX->SetMarkerColor(markercolor);
+    gVirtualX->SetMarkerSize (markersize);
+    gVirtualX->SetMarkerStyle(markerstyle);
   }
-  cout << "       Multiplicity    = " << fMulDigit  << endl ;
+  gPad->SetAttMarkerPS(markercolor,markerstyle,markersize);
+  gPad->PaintPolyMarker(1,&x,&y,"");
+  
+  
 }
 
-
-// //____________________________________________________________________________
-// AliPHOSPpsdRecPoint& AliPHOSPpsdRecPoint::operator = (AliPHOSPpsdRecPoint Clu)
-// {
-//  int* DL = Clu.GetDigitsList() ; 
+//____________________________________________________________________________
+void AliPHOSPpsdRecPoint::Print(Option_t * option) 
+{
+  // Print the digits information 
   
-//   if(fDigitsList) 
-//     delete fDigitsList ;
-
-//   AliPHOSDigit * digit ;
-//   Int_t iDigit;
-
-//   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-//     digit = (AliPHOSDigit *) DL[iDigit];
-//     AddDigit(*digit) ;
-//   }
-
-//   fDelta = Clu.GetDelta() ; 
-//   delete DL ; 
-
-//   fAmp       = Clu.GetEnergy() ;
-//   fGeom      = Clu.GetGeom() ;
-//   TVector3 LocPos;
-//   Clu.GetLocalPosition(LocPos) ;
-//   fLocPos    = LocPos;
-//   fMulDigit  = Clu.GetMultiplicity() ;
-//   fMaxDigit  = Clu.GetMaximumMultiplicity() ;
-//   fPHOSMod   = Clu.GetPHOSMod() ;
+  Info("Print","AliPHOSPpsdRecPoint: " ) ;
   
+  Int_t iDigit; 
+  Info("Print"," Digit{s} # ") ; 
+  for(iDigit=0; iDigit<fMulDigit; iDigit++) 
+    Info("Print", "%d", fDigitsList[iDigit]) ;  
+  Info("Print","       Multiplicity    = %d", fMulDigit  ) ;
+  Info("Print","       Stored at position %d", fIndexInList ) ; 
+}
+
 
-//   return *this ;
-// }