]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliJetGrid.cxx
Adding includes for EMCAL_Utils and OADB PATH (A. Shabetai)
[u/mrichter/AliRoot.git] / JETAN / AliJetGrid.cxx
index b9e7c6c9f5db99f2637b34295c43c85349a71af3..a0b18b0284acb572278e3a356378cd7aee27fb36 100644 (file)
 //  > grid->SetMatrixIndexes();
 //  > grid->SetIndexIJ();
 //
-//  Author : magali.estienne@ires.in2p3.fr
+//  Author : magali.estienne@subatech.in2p3.fr
 //=========================================================================
 
 // Standard headers 
 #include <Riostream.h>
 // Root headers
+#include <TMath.h>
 #include <TMatrixD.h>
 #include <TArrayD.h>
 #include <TArrayI.h>
 
 ClassImp(AliJetGrid)
 
-
 //__________________________________________________________
 AliJetGrid::AliJetGrid():
-    fGrid(0),
-    fNphi(0),        
-    fNeta(0),      
-    fPhi(0),       
-    fEta(0),       
-    fIndex(0),     
-    fIndexI(0),    
-    fIndexJ(0),    
-    fPhiMin(0),    
-    fPhiMax(0),    
-    fEtaMin(0),    
-    fEtaMax(0),    
-    fEtaBinInTPCAcc(0),   
-    fPhiBinInTPCAcc(0),   
-    fEtaBinInEMCalAcc(0), 
-    fPhiBinInEMCalAcc(0), 
-    fNbinEta(0),
-    fNbinPhi(0),
-    fMaxPhi(0),
-    fMinPhi(0),
-    fMaxEta(0),
-    fMinEta(0),
-    fDebug(1)
- {
+  fGrid(0),
+  fNphi(0),        
+  fNeta(0),      
+  fPhi(0),       
+  fEta(0),       
+  fIndex(0),     
+  fIndexI(0),    
+  fIndexJ(0),    
+  fPhiMin(0),    
+  fPhiMax(0),    
+  fEtaMin(0),    
+  fEtaMax(0),    
+  fEtaBinInTPCAcc(0),   
+  fPhiBinInTPCAcc(0),   
+  fEtaBinInEMCalAcc(0), 
+  fPhiBinInEMCalAcc(0), 
+  fNbinEta(0),
+  fNbinPhi(0),
+  fMaxPhi(0),
+  fMinPhi(0),
+  fMaxEta(0),
+  fMinEta(0),
+  fDebug(1)
+{
   // Default constructor
 }
 
 //__________________________________________________________
 AliJetGrid::AliJetGrid(Int_t nphi,Int_t neta,Double_t phiMin,Double_t phiMax,Double_t etaMin,Double_t etaMax):
-    fGrid(0),
-    fNphi(nphi),        
-    fNeta(neta),      
-    fPhi(0),       
-    fEta(0),       
-    fIndex(0),     
-    fIndexI(0),    
-    fIndexJ(0),    
-    fPhiMin(0),    
-    fPhiMax(0),    
-    fEtaMin(0),    
-    fEtaMax(0),    
-    fEtaBinInTPCAcc(0),   
-    fPhiBinInTPCAcc(0),   
-    fEtaBinInEMCalAcc(0), 
-    fPhiBinInEMCalAcc(0), 
-    fNbinEta(0),
-    fNbinPhi(0),
-    fMaxPhi(phiMax),
-    fMinPhi(phiMin),
-    fMaxEta(etaMax),
-    fMinEta(etaMin),
-    fDebug(1)
- {
+  fGrid(0),
+  fNphi(nphi),        
+  fNeta(neta),      
+  fPhi(0),       
+  fEta(0),       
+  fIndex(0),     
+  fIndexI(0),    
+  fIndexJ(0),    
+  fPhiMin(0),    
+  fPhiMax(0),    
+  fEtaMin(0),    
+  fEtaMax(0),    
+  fEtaBinInTPCAcc(0),   
+  fPhiBinInTPCAcc(0),   
+  fEtaBinInEMCalAcc(0), 
+  fPhiBinInEMCalAcc(0), 
+  fNbinEta(0),
+  fNbinPhi(0),
+  fMaxPhi(phiMax),
+  fMinPhi(phiMin),
+  fMaxEta(etaMax),
+  fMinEta(etaMin),
+  fDebug(1)
+{
   // Standard constructor
   fPhi    = new TArrayD(fNphi+1);
   fEta    = new TArrayD(fNeta+1);
   fIndexI = new TArrayI((fNeta+1)*(fNphi+1)+1);
   fIndexJ = new TArrayI((fNeta+1)*(fNphi+1)+1);
   
-  for(Int_t i=0; i<fNphi+1; i++) (*fPhi)[i] = (phiMax-phiMin)/fNphi*i+phiMin;
-  for(Int_t i=0; i<fNeta+1; i++) (*fEta)[i] = (etaMax-etaMin)/fNeta*i+etaMin;
+  for(Int_t i=0; i<fNphi+1; i++) {
+         if(fNphi!=0) (*fPhi)[i] = (phiMax-phiMin)/fNphi*i+phiMin;
+         else (*fPhi)[i] = phiMin+(phiMax-phiMin)/2;
+  }
+  for(Int_t i=0; i<fNeta+1; i++) {
+         if(fNeta!=0) (*fEta)[i] = (etaMax-etaMin)/fNeta*i+etaMin;
+         else (*fEta)[i] = etaMin+(etaMax-etaMin)/2;
+  }
   
   if(fDebug > 3){
       for(Int_t i=0; i<(fNphi+1); i++)  cout << (*fPhi)[i] << endl;
@@ -119,26 +125,35 @@ AliJetGrid::AliJetGrid(Int_t nphi,Int_t neta,Double_t phiMin,Double_t phiMax,Dou
 }
 
 //__________________________________________________________
-AliJetGrid::AliJetGrid(const AliJetGrid& grid):TNamed(grid) {
+AliJetGrid::AliJetGrid(const AliJetGrid& grid) : 
+  TNamed(grid),
+  fGrid(grid.fGrid),
+  fNphi(grid.fNphi),        
+  fNeta(grid.fNeta),      
+  fPhi(0),       
+  fEta(0),       
+  fIndex(0),     
+  fIndexI(grid.fIndexI),    
+  fIndexJ(grid.fIndexJ),    
+  fPhiMin(grid.fPhiMin),    
+  fPhiMax(grid.fPhiMax),    
+  fEtaMin(grid.fEtaMin),    
+  fEtaMax(grid.fEtaMax),    
+  fEtaBinInTPCAcc(grid.fEtaBinInTPCAcc),   
+  fPhiBinInTPCAcc(grid.fPhiBinInTPCAcc),   
+  fEtaBinInEMCalAcc(grid.fEtaBinInEMCalAcc), 
+  fPhiBinInEMCalAcc(grid.fPhiBinInEMCalAcc), 
+  fNbinEta(grid.fNbinEta),
+  fNbinPhi(grid.fNbinPhi),
+  fMaxPhi(grid.fMaxPhi),
+  fMinPhi(grid.fMinPhi),
+  fMaxEta(grid.fMaxEta),
+  fMinEta(grid.fMinEta),
+  fDebug(grid.fDebug) 
+{
 
   // Copy constructor
 
-  fNphi = grid.fNphi;
-  fNeta = grid.fNeta;
-  fPhiMin = grid.fPhiMin;
-  fPhiMax = grid.fPhiMax;
-  fEtaMin = grid.fEtaMin;
-  fEtaMax = grid.fEtaMax;
-  fEtaBinInTPCAcc = grid.fEtaBinInTPCAcc;
-  fPhiBinInTPCAcc = grid.fPhiBinInTPCAcc;
-  fEtaBinInEMCalAcc = grid.fEtaBinInEMCalAcc;
-  fPhiBinInEMCalAcc = grid.fPhiBinInEMCalAcc;
-  fNbinPhi = grid.fNbinPhi;
-  fMaxPhi = grid.fMaxPhi;
-  fMinPhi = grid.fMinPhi;
-  fMaxEta = grid.fMaxEta;
-  fMinEta = grid.fMinEta;
-
   fPhi = new TArrayD(fNphi+1);
   for(Int_t i=0; i<fNphi+1; i++) (*fPhi)[i] = grid.fPhi->At(i);
   fEta = new TArrayD(fNeta+1);
@@ -150,6 +165,45 @@ AliJetGrid::AliJetGrid(const AliJetGrid& grid):TNamed(grid) {
   }
 }
 
+
+AliJetGrid& AliJetGrid::operator=(const AliJetGrid& other)
+{
+  // Assignment
+  fGrid = other.fGrid;
+  fNphi = other.fNphi;        
+  fNeta = other.fNeta;      
+  fPhi    = 0;       
+  fEta    = 0;       
+  fIndex  = 0;     
+  fIndexI = other.fIndexI;    
+  fIndexJ = other.fIndexJ;    
+  fPhiMin = other.fPhiMin;    
+  fPhiMax = other.fPhiMax;    
+  fEtaMin = other.fEtaMin;    
+  fEtaMax = other.fEtaMax;    
+  fEtaBinInTPCAcc   = other.fEtaBinInTPCAcc;   
+  fPhiBinInTPCAcc   = other.fPhiBinInTPCAcc;   
+  fEtaBinInEMCalAcc = other.fEtaBinInEMCalAcc; 
+  fPhiBinInEMCalAcc = other.fPhiBinInEMCalAcc; 
+  fNbinEta = other.fNbinEta;
+  fNbinPhi = other.fNbinPhi;
+  fMaxPhi  = other.fMaxPhi;
+  fMinPhi  = other.fMinPhi;
+  fMaxEta  = other.fMaxEta;
+  fMinEta  = other.fMinEta;
+  fDebug   = other.fDebug;
+  fPhi = new TArrayD(fNphi+1);
+  for(Int_t i=0; i<fNphi+1; i++) (*fPhi)[i] = other.fPhi->At(i);
+  fEta = new TArrayD(fNeta+1);
+  for(Int_t i=0; i<fNeta+1; i++) (*fEta)[i] = other.fEta->At(i);
+  
+  fIndex = new TMatrixD(fNphi+1,fNeta+1);
+  for(Int_t i=0; i<fNphi+1; i++) {
+    for(Int_t j=0; j<fNeta+1; j++) (*fIndex)(i,j)=(*other.fIndex)(i,j);
+  }
+  return *this;
+}
+
 //__________________________________________________________
 AliJetGrid::~AliJetGrid() {
 
@@ -163,7 +217,8 @@ AliJetGrid::~AliJetGrid() {
 
 //__________________________________________________________
 void AliJetGrid::InitParams(Double_t phiMinCal,Double_t phiMaxCal,Double_t etaMinCal,Double_t etaMaxCal) 
-{ // To set initial parameters
+{ 
+// To set initial parameters
 
   fPhiMin = phiMinCal; // rad
   fPhiMax = phiMaxCal; // rad
@@ -199,7 +254,8 @@ void AliJetGrid::InitParams(Double_t phiMinCal,Double_t phiMaxCal,Double_t etaMi
 
 //__________________________________________________________
 TArrayD* AliJetGrid::GetArrayEta() 
-{ // Returns an array with the eta points
+{ 
+// Returns an array with the eta points
 
   return fEta;
 
@@ -207,7 +263,8 @@ TArrayD* AliJetGrid::GetArrayEta()
 
 //__________________________________________________________
 TArrayD* AliJetGrid::GetArrayPhi() 
-{ // Returns an array with the phi points
+{ 
+// Returns an array with the phi points
 
   return fPhi;
 
@@ -215,7 +272,8 @@ TArrayD* AliJetGrid::GetArrayPhi()
 
 //__________________________________________________________
 TMatrixD* AliJetGrid::GetIndexObject()
-{ // Returns a pointer to the matrix
+{ 
+// Returns a pointer to the matrix
 
   return fIndex;
 
@@ -223,8 +281,9 @@ TMatrixD* AliJetGrid::GetIndexObject()
 
 //__________________________________________________________
 void AliJetGrid::GetAccParam(Int_t &nphi, Int_t &neta, Float_t &minphi, Float_t &maxphi, 
-                               Float_t &mineta, Float_t &maxeta)
-{ // Returns EMCAL acceptance initially setted
+                               Float_t &mineta, Float_t &maxeta) const
+{ 
+// Returns EMCAL acceptance initially setted
 
   nphi = fNphi;
   neta = fNeta;
@@ -236,8 +295,9 @@ void AliJetGrid::GetAccParam(Int_t &nphi, Int_t &neta, Float_t &minphi, Float_t
 
 //__________________________________________________________
 void AliJetGrid::GetBinParam(Int_t &phibintpc, Int_t &etabintpc, 
-                               Int_t &phibinemc, Int_t &etabinemc, Int_t &nbinphi)
-{ // Returns number of bins in TPC and EMCAL geometry
+                               Int_t &phibinemc, Int_t &etabinemc, Int_t &nbinphi) const
+{ 
+// Returns number of bins in TPC and EMCAL geometry
 
   etabintpc = fEtaBinInTPCAcc;
   phibintpc = fPhiBinInTPCAcc;
@@ -248,9 +308,10 @@ void AliJetGrid::GetBinParam(Int_t &phibintpc, Int_t &etabintpc,
 
 //__________________________________________________________
 Int_t AliJetGrid::GetIndexFromEtaPhi(Double_t phi,Double_t eta) const 
-{ // Tells the index value of a corresponding (eta,phi) real position
-  // Loop over all entries -> takes time. 
-  // Used one time at the begining to fill the grids
+{ 
+// Tells the index value of a corresponding (eta,phi) real position
+// Loop over all entries -> takes time.
+// Used one time at the begining to fill the grids
 
   /*   this is how bins are numbered
    
@@ -402,7 +463,8 @@ Int_t AliJetGrid::GetIndexFromEtaPhi(Double_t phi,Double_t eta) const
 
 //__________________________________________________________
 void AliJetGrid::GetEtaPhiFromIndex(Int_t index, Float_t &eta, Float_t &phi)
-{ // Get (eta,phi) position for a given index BUT loop over all entries (takes time)
+{ 
+// Get (eta,phi) position for a given index BUT loop over all entries (takes time)
 
   for(Int_t j=0; j<fNphi+1; j++) {
     for(Int_t i=0; i<fNeta+1; i++) {
@@ -449,7 +511,8 @@ void AliJetGrid::GetEtaPhiFromIndex(Int_t index, Float_t &eta, Float_t &phi)
 
 //__________________________________________________________
 Int_t AliJetGrid::GetIndex(Double_t phi, Double_t eta) 
-{ // Get index value for a (eta,phi) position - Direct value
+{ 
+// Get index value for a (eta,phi) position - Direct value
 
   Int_t ieta = GetIndexJFromEta(eta);
   Int_t iphi = GetIndexIFromPhi(phi);
@@ -466,8 +529,9 @@ Int_t AliJetGrid::GetIndex(Double_t phi, Double_t eta)
 
 //__________________________________________________________
 Int_t AliJetGrid::GetIndexJFromEta(Double_t eta)
-{ // Get eta id 
-  // Eta discretized
+{ 
+// Get eta id
+// Eta discretized
 
   Int_t idEta =0;
   Double_t temp = (eta+fMaxEta)/(fMaxEta-fMinEta)*fNeta;
@@ -485,8 +549,9 @@ Int_t AliJetGrid::GetIndexJFromEta(Double_t eta)
 }
 //__________________________________________________________
 Int_t AliJetGrid::GetIndexIFromPhi(Double_t phi)
-{ // Get phi id
-  // Phi discretized
+{ 
+// Get phi id
+// Phi discretized
 
   Int_t idPhi = 0;
   Double_t temp = 0.;
@@ -510,8 +575,9 @@ Int_t AliJetGrid::GetIndexIFromPhi(Double_t phi)
 
 //__________________________________________________________
 void AliJetGrid::SetMatrixIndex(Int_t i,Double_t par) 
-{ // Allows to set parameters using only one index (if fGrid==0) !!
-  // Not used !
+{ 
+// Allows to set parameters using only one index (if fGrid==0) !!
+// Not used !
 
   Int_t iphi = (Int_t)i/fNeta;
   Int_t ieta = i-iphi*fNeta;
@@ -522,7 +588,8 @@ void AliJetGrid::SetMatrixIndex(Int_t i,Double_t par)
 
 //__________________________________________________________
 void AliJetGrid::SetMatrixIndexes() 
-{ // Fill the final matrix object with the corresponding index in eta/phi
+{ 
+// Fill the final matrix object with the corresponding index in eta/phi
 
   for(Int_t i=0; i<fNphi+1; i++){
     for(Int_t j=0; j<fNeta+1; j++){
@@ -541,7 +608,8 @@ void AliJetGrid::SetMatrixIndexes()
 
 //__________________________________________________________
 void AliJetGrid::SetIndexIJ()
-{ // 
+{ 
+// Set the grid index
 
   for(Int_t i=0; i<fNphi+1; i++){
     for(Int_t j=0; j<fNeta+1; j++){
@@ -561,15 +629,17 @@ void AliJetGrid::SetIndexIJ()
 }
 
 //__________________________________________________________
-void AliJetGrid::GetIJFromIndex(Int_t index, Int_t i, Int_t j)
-{ // returns i position id of eta and j position id of phi for a given grid index
+void AliJetGrid::GetIJFromIndex(Int_t index, Int_t& i, Int_t& j) const
+{ 
+// Returns i position id of eta and j position id of phi for a given grid index
   i = (*fIndexI)[index];
   j = (*fIndexJ)[index];
 }
 
 //__________________________________________________________
 void AliJetGrid::GetEtaPhiFromIndex2(Int_t index, Float_t &phi, Float_t &eta)
-{ // returns eta, phi values for a given grid index
+{ 
+// Returns eta, phi values for a given grid index
 
   phi = fPhi->At((*fIndexI)[index]);
   eta = fEta->At((*fIndexJ)[index]);
@@ -577,7 +647,8 @@ void AliJetGrid::GetEtaPhiFromIndex2(Int_t index, Float_t &phi, Float_t &eta)
 
 //__________________________________________________________
 Int_t AliJetGrid::GetNEntries()
-{ // Returns the number of entries of the grid
+{ 
+// Returns the number of entries of the grid
 
   if(fDebug>20){
     cout << "fMaxPhi : " << fMaxPhi << endl;
@@ -592,7 +663,8 @@ Int_t AliJetGrid::GetNEntries()
 
 //__________________________________________________________
 Int_t AliJetGrid::GetNEntries2()
-{ // Returns the number of entries of the grid
+{ 
+// Returns the number of entries of the grid
 
   Int_t indexNum = GetIndex(fMaxPhi-1.,fMaxEta-0.5);
     if(fDebug>20) cout << "indexNum : " << indexNum << endl;