]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALTowerRecPoint.cxx
Added AliEMCALReconstructioner
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTowerRecPoint.cxx
index dfc28359772100fe3032b19cbbc8ba9befeda1da..83d8ad8991ffa99a69ef3e28749963078d0c920c 100644 (file)
 
 
 // --- ROOT system ---
-#include "TPad.h"
-#include "TH2.h"
 #include "TMath.h" 
-#include "TCanvas.h" 
 
 // --- Standard library ---
 
-#include <Riostream.h> 
-
 // --- AliRoot header files ---
 
- #include "AliGenerator.h"
+#include "AliGenerator.h"
 #include "AliEMCALGeometry.h"
 #include "AliEMCALTowerRecPoint.h"
-#include "AliRun.h"
 #include "AliEMCALGetter.h"
 
 ClassImp(AliEMCALTowerRecPoint)
@@ -53,7 +47,6 @@ AliEMCALTowerRecPoint::AliEMCALTowerRecPoint() : AliEMCALRecPoint()
   fEnergyList = 0 ;
   fTime = 0. ;
   fLocPos.SetX(0.)  ;      //Local position should be evaluated
-   
 }
 
 //____________________________________________________________________________
@@ -66,8 +59,7 @@ AliEMCALTowerRecPoint::AliEMCALTowerRecPoint(const char * opt) : AliEMCALRecPoin
   fCoreEnergy = 0 ; 
   fEnergyList = 0 ;
   fTime = -1. ;
-  fLocPos.SetX(1000000.)  ;      //Local position should be evaluated
-  
+  fLocPos.SetX(1000000.)  ;      //Local position should be evaluated  
 }
 
 //____________________________________________________________________________
@@ -129,17 +121,16 @@ Bool_t AliEMCALTowerRecPoint::AreNeighbours(AliEMCALDigit * digit1, AliEMCALDigi
   
   Bool_t aren = kFALSE ;
   
-  AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
-  AliEMCALGeometry * phosgeom =  (AliEMCALGeometry*)gime->EMCALGeometry();
+  AliEMCALGeometry * phosgeom =  (AliEMCALGetter::Instance())->EMCALGeometry();
 
-  Int_t relid1[4] ; 
+  Int_t relid1[3] ; 
   phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ; 
 
-  Int_t relid2[4] ; 
+  Int_t relid2[3] ; 
   phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ; 
   
-  Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;  
-  Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;  
+  Int_t rowdiff = TMath::Abs( relid1[1] - relid2[1] ) ;  
+  Int_t coldiff = TMath::Abs( relid1[2] - relid2[2] ) ;  
 
   if (( coldiff <= 1 )  && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0)) 
     aren = kTRUE ;
@@ -152,7 +143,7 @@ Int_t AliEMCALTowerRecPoint::Compare(const TObject * obj) const
 {
   // Compares two RecPoints according to their position in the EMCAL modules
 
-  Float_t delta = 1 ; //Width of "Sorting row". If you changibg this 
+  Float_t delta = 1 ; //Width of "Sorting row". If you change this 
                       //value (what is senseless) change as vell delta in
                       //AliEMCALTrackSegmentMakerv* and other RecPoints...
   Int_t rv ; 
@@ -190,7 +181,7 @@ Int_t AliEMCALTowerRecPoint::Compare(const TObject * obj) const
   return rv ; 
 }
 //______________________________________________________________________________
-void AliEMCALTowerRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const
+void AliEMCALTowerRecPoint::ExecuteEvent(Int_t /*event*/, Int_t, Int_t) const
 {
   
   // Execute action corresponding to one event
@@ -200,10 +191,8 @@ void AliEMCALTowerRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const
   //  and switched off when the mouse button is released.
   
     
-  // AliEMCALGetter * gime =  AliEMCALGetter::GetInstance() ; 
-//   if(!gime) return ;
-//   AliEMCALGeometry * emcalgeom =  (AliEMCALGeometry*)gime->EMCALGeometry();
-  
+  //    AliEMCALGeometry * phosgeom =  (AliEMCALGetter::Instance())->EMCALGeometry();
+
 //   static TGraph *  digitgraph = 0 ;
   
 //   if (!gPad->IsEditable()) return;
@@ -218,7 +207,7 @@ void AliEMCALTowerRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const
 //   case kButton1Down: {
 //     AliEMCALDigit * digit ;
 //     Int_t iDigit;
-//     Int_t relid[4] ;
+//     Int_t relid[3] ;
     
 //     const Int_t kMulDigit = AliEMCALTowerRecPoint::GetDigitsMultiplicity() ; 
 //     Float_t * xi = new Float_t[kMulDigit] ; 
@@ -309,60 +298,48 @@ void  AliEMCALTowerRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * dig
 
   AliEMCALDigit * digit ;
  
-  AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
-  AliEMCALGeometry * emcalgeom =  (AliEMCALGeometry*)gime->EMCALGeometry();
+  AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
   
 
  // Calculates the center of gravity in the local EMCAL-module coordinates 
   
   Int_t iDigit;
-  Int_t relid[4] ;
 
-  if (!fTheta || !fPhi ) {
-    for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-      digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
-      
-      Float_t thetai ;
-      Float_t phii ;
-      emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-      emcalgeom->PosInAlice(relid, thetai, phii);
-      Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
-      fTheta = fTheta + thetai * w ;
-      fPhi   += (phii * w );
-      wtot  += w ;
-    }
+  if (!fTheta || !fPhi ) 
+    EvalGlobalPosition(logWeight, digits) ;
+  
+  const Float_t kDeg2Rad = TMath::DegToRad() ; 
     
-    if (wtot > 0 ) {
-      fTheta /= wtot ;
-      fPhi   /= wtot ;
-    } else {
-      fTheta = -1. ;
-      fPhi   = -1. ; 
-    }
-       
-  }
+  Float_t cyl_radius = 0 ;  
 
-  const Float_t kDeg2Rad = TMath::Pi() / static_cast<Double_t>(180) ; 
+  if (IsInECA()) 
+    cyl_radius = emcalgeom->GetIP2ECASection() ;
+  else 
+    Fatal("EvalDispersion", "Unexpected tower section!") ; 
   
-  Float_t cyl_radius = emcalgeom->GetIPDistance()+emcalgeom->GetAirGap() ;
-  Float_t x =  cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
-  Float_t y =  cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ; 
-  Float_t z =  cyl_radius * TMath::Tan(fTheta * kDeg2Rad ) ; 
+  Float_t x =  fLocPos.X() ; 
+  Float_t y =  fLocPos.Y() ; 
+  Float_t z =  fLocPos.Z() ; 
   
+  if (gDebug == 2) 
+    printf("EvalDispersion: x,y,z = %f,%f,%f", x, y, z) ;
+
 // Calculates the dispersion in coordinates 
   wtot = 0.;
   for(iDigit=0; iDigit < fMulDigit; iDigit++) {
     digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit])  ;
     Float_t thetai = 0. ;
     Float_t phii = 0.;
-    emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-    emcalgeom->PosInAlice(relid, thetai, phii);
+    emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
     Float_t xi =  cyl_radius * TMath::Cos(phii * kDeg2Rad ) ;
     Float_t yi =  cyl_radius * TMath::Sin(phii * kDeg2Rad ) ; 
-    Float_t zi =  cyl_radius * TMath::Tan(thetai * kDeg2Rad ) ; 
+    Float_t zi =  cyl_radius / TMath::Tan(thetai * kDeg2Rad ) ; 
+
+    if (gDebug == 2) 
+      printf("EvalDispersion: id = %d, xi,yi,zi = %f,%f,%f", digit->GetId(), xi, yi, zi) ;
 
     Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
-    d += w*((xi-x)*(xi-x) + (yi-y)*(yi-y)+ (zi-z)*(zi-z) ) ; 
+    d += w * ( (xi-x)*(xi-x) + (zi-z)*(zi-z) ) ; 
     wtot+=w ;
   }
   
@@ -385,12 +362,9 @@ void AliEMCALTowerRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * dig
   Float_t coreRadius = 10. ;
 
   AliEMCALDigit * digit ;
-  Int_t relid[4] ;
   Float_t wtot = 0. ;
 
-  AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
-  AliEMCALGeometry * emcalgeom =  (AliEMCALGeometry*)gime->EMCALGeometry();
-    
+  AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();    
   Int_t iDigit;
 
   if (!fTheta || !fPhi ) {
@@ -399,8 +373,7 @@ void AliEMCALTowerRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * dig
       
       Float_t thetai ;
       Float_t phii ;
-      emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-      emcalgeom->PosInAlice(relid, thetai, phii);
+      emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
       Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
       fTheta = fTheta + thetai * w ;
       fPhi   += (phii * w );
@@ -415,21 +388,19 @@ void AliEMCALTowerRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * dig
       fPhi   = -1 ; 
     }
   }
-
-  const Float_t kDeg2Rad = TMath::Pi() / static_cast<Double_t>(180) ; 
-
-  Float_t cyl_radius = emcalgeom->GetIPDistance()+emcalgeom->GetAirGap() ;
+  
+  const Float_t kDeg2Rad = TMath::DegToRad() ; 
+  
+  Float_t cyl_radius = emcalgeom->GetIP2ECASection();
   Float_t x =  cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
   Float_t y =  cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ; 
   Float_t z =  cyl_radius * TMath::Tan(fTheta * kDeg2Rad ) ; 
 
   for(iDigit=0; iDigit < fMulDigit; iDigit++) {
     digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
-    Int_t relid[4] ;
     Float_t thetai = 0. ;
     Float_t phii = 0. ;
-    emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-    emcalgeom->PosInAlice(relid, thetai, phii);
+    emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
     
     Float_t xi =  cyl_radius * TMath::Cos(phii * kDeg2Rad ) ;
     Float_t yi =  cyl_radius * TMath::Sin(phii * kDeg2Rad ) ; 
@@ -439,7 +410,7 @@ void AliEMCALTowerRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * dig
     if(distance < coreRadius)
       fCoreEnergy += fEnergyList[iDigit] ;
   }
-
+  
 }
 
 //____________________________________________________________________________
@@ -456,24 +427,26 @@ void  AliEMCALTowerRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digi
 
   AliEMCALDigit * digit ;
 
-  AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
-  AliEMCALGeometry * emcalgeom =  (AliEMCALGeometry*)gime->EMCALGeometry();
+  AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
 
   Int_t iDigit;
-  const Float_t kDeg2Rad = TMath::Pi() / static_cast<Double_t>(180) ; 
+  const Float_t kDeg2Rad = TMath::DegToRad() ; 
   
-  Float_t cyl_radius = emcalgeom->GetIPDistance()+emcalgeom->GetAirGap() ;
+   Float_t cyl_radius = 0 ;  
+  
+  if (IsInECA()) 
+    cyl_radius = emcalgeom->GetIP2ECASection() ;
+  else 
+    Fatal("EvalDispersion", "Unexpected tower section!") ; 
 
   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
     digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit])  ;
-    Int_t relid[4] ;
     Float_t thetai = 0. ;
     Float_t phii = 0. ; 
-    emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-    emcalgeom->PosInAlice(relid, thetai, phii);
+    emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
     Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
     Float_t xi =  cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
-    Float_t zi =  cyl_radius * TMath::Tan(fTheta * kDeg2Rad ) ; 
+    Float_t zi =  cyl_radius / TMath::Tan(fTheta * kDeg2Rad ) ; 
     dxx  += w * xi * xi ;
     x    += w * xi ;
     dzz  += w * zi * zi ;
@@ -495,8 +468,7 @@ void  AliEMCALTowerRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digi
     //   //Apply correction due to non-perpendicular incidence
 //   Double_t CosX ;
 //   Double_t CosZ ;
-//   AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
-//   AliEMCALGeometry * emcalgeom =  (AliEMCALGeometry*)gime->EMCALGeometry();
+//   AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
   //   Double_t DistanceToIP= (Double_t ) emcalgeom->GetIPDistance() ;
   
 //   CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
@@ -541,12 +513,10 @@ void AliEMCALTowerRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray *
   // Calculates the center of gravity in the local EMCAL-module coordinates 
   Float_t wtot = 0. ;
  
-  Int_t relid[4] ;
+  //  Int_t relid[3] ;
   
   AliEMCALDigit * digit ;
-
-  AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
-  AliEMCALGeometry * emcalgeom  =  static_cast<AliEMCALGeometry*>(gime->EMCALGeometry());
+  AliEMCALGeometry * emcalgeom  =  (AliEMCALGetter::Instance())->EMCALGeometry();
   Int_t iDigit;
 
   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
@@ -554,8 +524,7 @@ void AliEMCALTowerRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray *
 
     Float_t thetai ;
     Float_t phii ;
-    emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-    emcalgeom->PosInAlice(relid, thetai, phii);
+    emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
     Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
     fTheta = fTheta + thetai * w ;
     fPhi   += (phii * w );
@@ -570,10 +539,26 @@ void AliEMCALTowerRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray *
     fPhi   = -1.; 
   }
   
-  fLocPos.SetX(0.)  ;
-  fLocPos.SetY(0.) ;
-  fLocPos.SetZ(0.)  ;
 
+  const Float_t kDeg2Rad = TMath::DegToRad() ; 
+  
+  Float_t cyl_radius = 0 ;  
+
+  if (IsInECA()) 
+    cyl_radius = emcalgeom->GetIP2ECASection() ;
+  else 
+    Fatal("EvalGlobalPosition", "Unexpected tower section!") ; 
+  
+  Float_t x =  cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
+  Float_t y =  cyl_radius * TMath::Sin(fPhi * kDeg2Rad ) ; 
+  Float_t z =  cyl_radius / TMath::Tan(fTheta * kDeg2Rad ) ; 
+  
+  fLocPos.SetX(x)  ;
+  fLocPos.SetY(y) ;
+  fLocPos.SetZ(z)  ;
+    
+  if (gDebug==2)
+    printf("EvalGlobalPosition: x,y,z = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ; 
   fLocPosM = 0 ;
 }
 
@@ -619,13 +604,11 @@ Int_t  AliEMCALTowerRecPoint::GetNumberOfLocalMax(AliEMCALDigit **  maxAt, Float
   AliEMCALDigit * digit ;
   AliEMCALDigit * digitN ;
   
-
   Int_t iDigitN ;
   Int_t iDigit ;
 
   for(iDigit = 0; iDigit < fMulDigit; iDigit++)
     maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit])  ;
-
   
   for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {   
     if(maxAt[iDigit]) {
@@ -677,31 +660,57 @@ void AliEMCALTowerRecPoint::EvalTime(TClonesArray * digits){
   
 }
 //____________________________________________________________________________
-void AliEMCALTowerRecPoint::Print(Option_t * option
+void AliEMCALTowerRecPoint::Print(Option_t *) 
 {
   // Print the list of digits belonging to the cluster
   
-  cout << "AliEMCALTowerRecPoint: " << endl ;
+  printf("\n") ; 
 
   Int_t iDigit;
-  cout << " digits # = " ;
-  for(iDigit=0; iDigit<fMulDigit; iDigit++)
-    cout << fDigitsList[iDigit] << "  " ;  
-  cout << endl ;
-  
-  cout << " Energies = " ;
-  for(iDigit=0; iDigit<fMulDigit; iDigit++) 
-    cout  << fEnergyList[iDigit] << "  ";
-  cout << endl ;
-  
-  cout << " Primaries  " ;
-  for(iDigit = 0;iDigit < fMulTrack; iDigit++)
-    cout << fTracksList[iDigit] << " " << endl ;
-       
-  cout << "       Multiplicity    = " << fMulDigit  << endl ;
-  cout << "       Cluster Energy  = " << fAmp << endl ;
-  cout << "       Number of primaries " << fMulTrack << endl ;
-  cout << "       Stored at position " << GetIndexInList() << endl ; 
+  printf("digits # = ");
+  for(iDigit=0; iDigit<fMulDigit; iDigit++) {
+     printf("%i ", fDigitsList[iDigit]); 
+  } 
+  
+  printf("\nEnergies = ");
+  for(iDigit=0; iDigit<fMulDigit; iDigit++) { 
+    printf("%f ", fEnergyList[iDigit]); 
+  }
+  
+   printf("\nPrimaries  ");
+   for(iDigit = 0;iDigit < fMulTrack; iDigit++) {
+     printf("%i ", fTracksList[iDigit]);
+   }
+   printf("\n       Multiplicity    = %i", fMulDigit);
+   printf("\n       Cluster Energy  = %f", fAmp);
+   printf("\n       Number of primaries %i", fMulTrack);
+   printf("\n       Stored at position: %i", GetIndexInList()); 
 }
  
+//____________________________________________________________________________
+const TVector3 AliEMCALTowerRecPoint::XYZInAlice(Float_t r, Float_t theta, Float_t phi) const 
+{
+  // spherical coordinates of recpoint in Alice reference frame
+
+  if (gDebug == 2) 
+    printf("XYZInAlice: r = %f, theta = %f, phi = %f", r, theta, phi) ; 
+
+  if (theta == 9999. || phi == 9999. || r == 9999.) {
+    TVector3  globalpos;  
+    GetGlobalPosition(globalpos);
+    phi   =  globalpos.X() * TMath::DegToRad() ; 
+    r     =  globalpos.Y() ; 
+    theta =  globalpos.Z() * TMath::DegToRad() ; 
+  }
+  else {
+    theta *= TMath::DegToRad() ; 
+    phi   *= TMath::DegToRad() ; 
+  }
+  
+  Float_t y = r * TMath::Cos(phi) ; 
+  Float_t x = r * TMath::Sin(phi) * TMath::Sin(theta) ; 
+  Float_t z = r * TMath::Sin(phi) * TMath::Cos(theta) ; 
+  
+  TVector3 vec(z, x, y) ; 
+  return vec ; 
+}