]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSEmcRecPoint.cxx
AliHLTTPCSpacePointData:
[u/mrichter/AliRoot.git] / PHOS / AliPHOSEmcRecPoint.cxx
index 5c7dd85eb10d353adef126538bc909f902134f96..5dcb9051b14af0ce681fdb5af83e3c161215b2a5 100644 (file)
 
 /* $Id$ */
 
+/* History of cvs commits:
+ *
+ * $Log$
+ */
+
 //_________________________________________________________________________
 //  RecPoint implementation for PHOS-EMC 
 //  An EmcRecPoint is a cluster of digits   
@@ -23,7 +28,6 @@
 
 
 // --- ROOT system ---
-#include "TPad.h"
 #include "TH2.h"
 #include "TMath.h" 
 #include "TCanvas.h" 
 // --- Standard library ---
 
 // --- AliRoot header files ---
-
+#include "AliLog.h"
+#include "AliPHOSLoader.h"
 #include "AliGenerator.h"
 #include "AliPHOSGeometry.h"
+#include "AliPHOSDigit.h"
 #include "AliPHOSEmcRecPoint.h"
-#include "AliRun.h"
-#include "AliPHOSGetter.h"
-
 ClassImp(AliPHOSEmcRecPoint)
 
 //____________________________________________________________________________
@@ -109,8 +113,8 @@ void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
 
   if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists 
     fMaxDigit*=2 ; 
-    Int_t * tempo = new ( Int_t[fMaxDigit] ) 
-    Float_t * tempoE =  new ( Float_t[fMaxDigit] ) ;
+    Int_t * tempo = new Int_t[fMaxDigit]
+    Float_t * tempoE =  new Float_t[fMaxDigit];
 
     Int_t index ;     
     for ( index = 0 ; index < fMulDigit ; index++ ){
@@ -119,10 +123,10 @@ void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
     }
     
     delete [] fDigitsList ; 
-    fDigitsList =  new ( Int_t[fMaxDigit] ) ;
+    fDigitsList =  new Int_t[fMaxDigit];
  
     delete [] fEnergyList ;
-    fEnergyList =  new ( Float_t[fMaxDigit] ) ;
+    fEnergyList =  new Float_t[fMaxDigit];
 
     for ( index = 0 ; index < fMulDigit ; index++ ){
       fDigitsList[index] = tempo[index] ;
@@ -148,7 +152,7 @@ Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * d
   
   Bool_t aren = kFALSE ;
   
-  AliPHOSGeometry * phosgeom =  AliPHOSLoader::GetPHOSGeometry();
+  AliPHOSGeometry * phosgeom =  AliPHOSGeometry::GetInstance() ;
 
   Int_t relid1[4] ; 
   phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ; 
@@ -169,8 +173,8 @@ Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * d
 Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
 {
   // Compares two RecPoints according to their position in the PHOS modules
-
-  Float_t delta = 1 ; //Width of "Sorting row". If you changibg this 
+  
+  const Float_t delta = 1 ; //Width of "Sorting row". If you changibg this 
                       //value (what is senseless) change as vell delta in
                       //AliPHOSTrackSegmentMakerv* and other RecPoints...
   Int_t rv ; 
@@ -208,7 +212,7 @@ Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
   return rv ; 
 }
 //______________________________________________________________________________
-void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) const
+void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) /*const*/
 {
   
   // Execute action corresponding to one event
@@ -218,7 +222,7 @@ void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) const
   //  and switched off when the mouse button is released.
   
   
-  AliPHOSGeometry * phosgeom =  AliPHOSLoader::GetPHOSGeometry();
+  AliPHOSGeometry * phosgeom =  AliPHOSGeometry::GetInstance();
   
   static TGraph *  digitgraph = 0 ;
   
@@ -229,16 +233,16 @@ void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) const
 
   
   //try to get run loader from default event folder
-  AliRunLoader* rn = AliRunLoader::GetRunLoader(AliConfig::fgkDefaultEventFolderName);
+  AliRunLoader* rn = AliRunLoader::GetRunLoader(AliConfig::GetDefaultEventFolderName());
   if (rn == 0x0) 
     {
-      Error("ExecuteEvent","Can not find Run Loader in Default Event Folder");
+      AliError(Form("Cannot find Run Loader in Default Event Folder"));
       return;
     }
   AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(rn->GetLoader("PHOSLoader"));
   if (gime == 0x0) 
     {
-      Error("ExecuteEvent","Can not find PHOS Loader from Run Loader");
+      AliError(Form("Cannot find PHOS Loader from Run Loader"));
       return;
     }
   
@@ -344,7 +348,7 @@ void  AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits
 
   AliPHOSDigit * digit ;
  
-  AliPHOSGeometry * phosgeom =  AliPHOSLoader::GetPHOSGeometry();
+  AliPHOSGeometry * phosgeom =  AliPHOSGeometry::GetInstance();
 
  // Calculates the center of gravity in the local PHOS-module coordinates 
   
@@ -403,7 +407,7 @@ void AliPHOSEmcRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits
 
   AliPHOSDigit * digit ;
 
-  AliPHOSGeometry * phosgeom =  AliPHOSLoader::GetPHOSGeometry();
+  AliPHOSGeometry * phosgeom =  AliPHOSGeometry::GetInstance();
 
   Int_t iDigit;
 
@@ -453,7 +457,7 @@ void  AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
 
   AliPHOSDigit * digit ;
 
-  AliPHOSGeometry * phosgeom =  AliPHOSLoader::GetPHOSGeometry();
+  AliPHOSGeometry * phosgeom =  AliPHOSGeometry::GetInstance();
 
   Int_t iDigit;
 
@@ -525,7 +529,7 @@ void  AliPHOSEmcRecPoint::EvalMoments(Float_t logWeight,TClonesArray * digits)
 
   AliPHOSDigit * digit ;
 
-  AliPHOSGeometry * phosgeom =  AliPHOSLoader::GetPHOSGeometry();
+  AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
 
   Int_t iDigit;
 
@@ -638,14 +642,13 @@ void  AliPHOSEmcRecPoint::EvalMoments(Float_t logWeight,TClonesArray * digits)
 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
 {
   // Evaluates all shower parameters
-
   EvalLocalPosition(logWeight, digits) ;
   EvalElipsAxis(logWeight, digits) ;
   EvalMoments(logWeight, digits) ;
   EvalDispersion(logWeight, digits) ;
   EvalCoreEnergy(logWeight, digits);
   EvalTime(digits) ;
-  AliPHOSRecPoint::EvalAll(logWeight,digits) ;
+  AliPHOSRecPoint::EvalAll(digits) ;
 }
 //____________________________________________________________________________
 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
@@ -660,7 +663,7 @@ void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * dig
   
   AliPHOSDigit * digit ;
 
-  AliPHOSGeometry * phosgeom =  AliPHOSLoader::GetPHOSGeometry();
+  AliPHOSGeometry * phosgeom =  AliPHOSGeometry::GetInstance() ;
 
   Int_t iDigit;
 
@@ -677,7 +680,6 @@ void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * dig
     wtot += w ;
 
   }
-
   x /= wtot ;
   z /= wtot ;
 
@@ -686,8 +688,12 @@ void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * dig
   Float_t parb = 6.52 ; 
 
   Float_t xo,yo,zo ; //Coordinates of the origin
-  gAlice->Generator()->GetOrigin(xo,yo,zo) ;
-
+  //We should check all 3 possibilities to avoid seg.v.
+  if(gAlice && gAlice->GetMCApp() && gAlice->Generator())
+    gAlice->Generator()->GetOrigin(xo,yo,zo) ;
+  else{
+    xo=yo=zo=0.;
+  }
   Float_t phi = phosgeom->GetPHOSAngle(relid[0]) ;
 
   //Transform to the local ref.frame
@@ -728,7 +734,7 @@ Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
 }
 
 //____________________________________________________________________________
-Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(const Float_t H) const
+Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(Float_t H) const
 {
   // Calculates the multiplicity of digits with energy larger than H*energy 
   
@@ -765,6 +771,9 @@ Int_t  AliPHOSEmcRecPoint::GetNumberOfLocalMax( AliPHOSDigit **  maxAt, Float_t
       digit = maxAt[iDigit] ;
           
       for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {       
+       if(iDigit == iDigitN)
+         continue ;
+       
        digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ; 
        
        if ( AreNeighbours(digit, digitN) ) {
@@ -815,8 +824,8 @@ void AliPHOSEmcRecPoint::EvalTime(TClonesArray * digits)
 void AliPHOSEmcRecPoint::Purify(Float_t threshold){
   //Removes digits below threshold
 
-  Int_t * tempo = new ( Int_t[fMaxDigit] ) 
-  Float_t * tempoE =  new ( Float_t[fMaxDigit] ) ;
+  Int_t * tempo = new Int_t[fMaxDigit]
+  Float_t * tempoE =  new Float_t[fMaxDigit];
 
   Int_t mult = 0 ;
   for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
@@ -830,8 +839,8 @@ void AliPHOSEmcRecPoint::Purify(Float_t threshold){
   fMulDigit = mult ;
   delete [] fDigitsList ;
   delete [] fEnergyList ;
-  fDigitsList = new (Int_t[fMulDigit]) ;
-  fEnergyList = new ( Float_t[fMulDigit]) ;
+  fDigitsList = new Int_t[fMulDigit];
+  fEnergyList = new Float_t[fMulDigit];
 
   fAmp = 0.; //Recalculate total energy
   for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
@@ -852,17 +861,17 @@ void AliPHOSEmcRecPoint::Print(Option_t *) const
   TString message ; 
   message  = "AliPHOSEmcRecPoint:\n" ;
   message +=  " digits # = " ; 
-  Info("Print", message.Data()) ; 
+  AliInfo(Form(message.Data())) ; 
 
   Int_t iDigit;
   for(iDigit=0; iDigit<fMulDigit; iDigit++)
     printf(" %d ", fDigitsList[iDigit] ) ;  
   
-  Info("Print", " Energies = ") ;
+  printf(" Energies = ") ;
   for(iDigit=0; iDigit<fMulDigit; iDigit++) 
     printf(" %f ", fEnergyList[iDigit] ) ;
   printf("\n") ; 
-   Info("Print", " Primaries  ") ;
+   printf(" Primaries  ") ;
   for(iDigit = 0;iDigit < fMulTrack; iDigit++)
     printf(" %d ", fTracksList[iDigit]) ;
   printf("\n") ;       
@@ -871,7 +880,7 @@ void AliPHOSEmcRecPoint::Print(Option_t *) const
   message += "       Number of primaries %d" ; 
   message += "       Stored at position %d" ; 
  
-  Info("Print", message.Data(), fMulDigit, fAmp, fMulTrack,GetIndexInList() ) ;  
+  printf(message.Data(), fMulDigit, fAmp, fMulTrack,GetIndexInList() ) ;  
 }