]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveDet/AliEveEMCALData.cxx
Coverity
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveEMCALData.cxx
index 6f1dbff72e876d1a4f3a366b32d576a33ee4dd11..580deb0510dfc923edafac5e2e856054ec96ff56 100644 (file)
@@ -1,30 +1,26 @@
-//*********************************************************************
-// - AliEVE implementation -
+//
 // Fill containers for visualisation of EMCAL data structures
-//    - read and store MC Hits
-//    - read and store digits from esds or runloader
+//    - read and store MC Hits    - read and store digits from esds or runloader
 //    - read and store clusters from esds or runloader 
 //
 // Author: Magali Estienne (magali.estienne@cern.ch)
 // June 30 2008
-//*********************************************************************
+//
+
+//#include <Riostream.h>
+//#include <vector>
 
-#include <TObject.h>
-#include <TEveUtil.h>
 #include <TTree.h>
 #include <TBranch.h>
 #include <TObjArray.h>
 #include <TRefArray.h>
 #include <TClonesArray.h>
-#include <TEvePointSet.h>
+#include <TMath.h>
+#include <TLorentzVector.h>
 
-#include "AliRun.h"
 #include "AliRunLoader.h"
 #include "AliEMCALLoader.h"
-#include "AliESDEvent.h"
 #include "AliESDVertex.h"
-#include "AliEMCAL.h"
-#include "AliEMCALGeometry.h"
 #include "AliEMCALHit.h"
 #include "AliEMCALDigit.h"
 
 #include "AliESDCaloCluster.h"
 
 #include "AliEveEMCALData.h"
-#include "AliEveEMCALSModule.h"
 #include "AliEveEMCALSModuleData.h"
 
+class Riostream;
+class TObject;
+class TEveUtil;
+class TEvePointSet;
+class AliRun;
+class AliESDEvent;
+class AliEMCAL;
+class AliEMCALGeometry;
+class AliEveEMCALSModule;
+
+
 ClassImp(AliEveEMCALData)
 
 //______________________________________________________________________________
@@ -124,12 +130,6 @@ AliEveEMCALData::~AliEveEMCALData()
   delete fPoint;
 }
 
-//______________________________________________________________________________
-void AliEveEMCALData::Reset()
-{
-
-}
-
 //______________________________________________________________________________
 AliEveEMCALData::AliEveEMCALData(const AliEveEMCALData &edata) :
   TObject(edata),
@@ -173,7 +173,7 @@ AliEveEMCALData& AliEveEMCALData::operator=(const AliEveEMCALData &edata)
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::SetTree(TTree* tree)
+void AliEveEMCALData::SetTree(TTree* const tree)
 {
   //
   // Set digit-tree to be used for digit retrieval. 
@@ -185,7 +185,7 @@ void AliEveEMCALData::SetTree(TTree* tree)
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::SetESD(AliESDEvent* esd)
+void AliEveEMCALData::SetESD(AliESDEvent* const esd)
 {
   //
   // Set esd
@@ -195,7 +195,7 @@ void AliEveEMCALData::SetESD(AliESDEvent* esd)
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::SetNode(TGeoNode* node)
+void AliEveEMCALData::SetNode(TGeoNode* const node)
 {
   //
   // Set node
@@ -205,7 +205,7 @@ void AliEveEMCALData::SetNode(TGeoNode* node)
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::InitEMCALGeom(AliRunLoader* rl)
+void AliEveEMCALData::InitEMCALGeom(AliRunLoader* const rl)
 {
   //
   // Set data members for EMCAL geometry
@@ -299,7 +299,7 @@ void AliEveEMCALData::DeleteSuperModules()
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::LoadHits(TTree* t)
+void AliEveEMCALData::LoadHits(TTree* const t)
 {
   //
   // Get hit information from RunLoader
@@ -350,40 +350,50 @@ void AliEveEMCALData::LoadHits(TTree* t)
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::LoadHitsFromEMCALLoader(AliEMCALLoader* emcl)
+void AliEveEMCALData::LoadHitsFromEMCALLoader(AliEMCALLoader* const emcl)
 {
   //
   // Get hit information from EMCAL Loader
   //
 
-  AliEMCALHit* hit;
+       AliEMCALHit* hit;
   
-  //Fill array of hits                                                                        
-  TClonesArray *hits = (TClonesArray*)emcl->Hits();
-
-  //Get hits from the list                                                                    
-  for(Int_t ihit = 0; ihit< hits->GetEntries();ihit++){
-
-    hit = static_cast<AliEMCALHit *>(hits->At(ihit)) ;
+       //Fill array of hits                                                                        
+       TClonesArray *hits = 0;//(TClonesArray*)emcl->Hits();
+       TTree *treeH = emcl->TreeH();   
+       if (treeH) {
+               Int_t nTrack = treeH->GetEntries();  // TreeH has array of hits for every primary
+               TBranch * branchH = treeH->GetBranch("EMCAL");
+               //if(fHits)fHits->Clear();
+               branchH->SetAddress(&hits);
+               for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
+                       branchH->GetEntry(iTrack);
+                       
+                       //Get hits from the list                                                                    
+                       for(Int_t ihit = 0; ihit< hits->GetEntries();ihit++){
+
+                               hit = static_cast<AliEMCALHit *>(hits->At(ihit)) ;
     
-    if(hit != 0){
-      if(fDebug>1) cout << "Hit info " << hit->GetId() << " " << hit->GetEnergy() << endl;
-
-      Int_t id = hit->GetId();
-      // These are local coordinates
-      Double_t xl = 0.; Double_t yl = 0.; Double_t zl = 0.;
-      // Get global coordinates
-      Double_t x = hit->X();
-      Double_t y = hit->Y();
-      Double_t z = hit->Z();
-      Double_t amp = hit->GetEnergy();
-      Int_t iSupMod = 0;
-      // Get SM Id
-      GetGeomInfo(id,iSupMod,xl,yl,zl);
-      fSM[iSupMod]->RegisterHit(id,iSupMod,amp,x,y,z);
-    }
-  }
-  
+                               if(hit != 0){
+                                       if(fDebug>1) cout << "Hit info " << hit->GetId() << " " << hit->GetEnergy() << endl;
+
+                                       Int_t id = hit->GetId();
+                                       // These are local coordinates
+                                       Double_t xl = 0.; Double_t yl = 0.; Double_t zl = 0.;
+                                       // Get global coordinates
+                                       Double_t x = hit->X();
+                                       Double_t y = hit->Y();
+                                       Double_t z = hit->Z();
+                                       Double_t amp = hit->GetEnergy();
+                                       Int_t iSupMod = 0;
+                                       // Get SM Id
+                                       GetGeomInfo(id,iSupMod,xl,yl,zl);
+                                       fSM[iSupMod]->RegisterHit(id,iSupMod,amp,x,y,z);
+                               }//hit exists
+                       }//hit loop
+                       if(hits)hits->Clear();
+               }// track loop
+       }//treeH exists
 }
 
 //______________________________________________________________________________
@@ -402,7 +412,7 @@ void AliEveEMCALData::LoadDigits(TTree *t)
   AliEMCALDigit * dig;
 
   //  Double_t amp   = -1 ;
-  Double_t ampInt   = -1 ;
+  Double_t ampFlo   = -1 ;
   Int_t id      = -1 ;
   Int_t iSupMod =  0 ;
   Double_t x, y, z;
@@ -414,9 +424,9 @@ void AliEveEMCALData::LoadDigits(TTree *t)
       if(dig != 0) {
        id   = dig->GetId() ; //cell (digit) label
        // adc
-       ampInt  = dig->GetAmp(); //amplitude in cell (digit)
+       ampFlo  = dig->GetAmplitude(); //amplitude in cell (digit)
        // GeV
-       //      amp = ampInt*0.0153; // To be modified with correct OCDB conversion     
+       //      amp = ampFlo*0.0153; // To be modified with correct OCDB conversion     
 
        GetGeomInfo(id,iSupMod,x,y,z);
 
@@ -425,7 +435,7 @@ void AliEveEMCALData::LoadDigits(TTree *t)
 // //  fSM[iSupMod]->SaveDigit(dig);
 // //  if(iSupMod<fNsmfull) fSMfull[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
 // //  if(iSupMod>fNsmfull) fSMhalf[iSupMod-10]->RegisterDigit(id,iSupMod,amp,x,y,z);
-       fSM[iSupMod]->RegisterDigit(id,iSupMod,ampInt,x,y,z);
+       fSM[iSupMod]->RegisterDigit(id,iSupMod,ampFlo,x,y,z);
 //     fSM[iSupMod]->SaveDigit(dig);
 //     if(iSupMod<fNsmfull) fSMfull[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
 //     if(iSupMod>fNsmfull) fSMhalf[iSupMod-10]->RegisterDigit(id,iSupMod,amp,x,y,z);
@@ -439,7 +449,7 @@ void AliEveEMCALData::LoadDigits(TTree *t)
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::LoadDigitsFromEMCALLoader(AliEMCALLoader* emcl)
+void AliEveEMCALData::LoadDigitsFromEMCALLoader(AliEMCALLoader* const emcl)
 {
 
   //
@@ -454,7 +464,7 @@ void AliEveEMCALData::LoadDigitsFromEMCALLoader(AliEMCALLoader* emcl)
   //Get digits from the list  
   
   //  Double_t amp   = -1 ;
-  Double_t ampInt   = -1 ;
+  Double_t ampFlo   = -1 ;
   Int_t id      = -1 ;
   Int_t iSupMod =  0 ;
   Double_t x, y, z;
@@ -464,19 +474,19 @@ void AliEveEMCALData::LoadDigitsFromEMCALLoader(AliEMCALLoader* emcl)
      dig = static_cast<AliEMCALDigit *>(digits->At(idig)) ;
 
      if(dig != 0){
-       if(fDebug>1) cout << "Digit info " << dig->GetId() << " " << dig->GetAmp() << endl;
+       if(fDebug>1) cout << "Digit info " << dig->GetId() << " " << dig->GetAmplitude() << endl;
        id   = dig->GetId() ; //cell (digit) label
        // adc
-       ampInt  = dig->GetAmp(); //amplitude in cell (digit)
+       ampFlo  = dig->GetAmplitude(); //amplitude in cell (digit)
        // GeV
-       //       amp = ampInt*0.0153.; // To be modified with correct OCDB conversion
+       //       amp = ampFlo*0.0153.; // To be modified with correct OCDB conversion
 
        GetGeomInfo(id,iSupMod,x,y,z);
        
        //       // GeV
        //       fSM[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
        // adc
-       fSM[iSupMod]->RegisterDigit(id,iSupMod,ampInt,x,y,z);
+       fSM[iSupMod]->RegisterDigit(id,iSupMod,ampFlo,x,y,z);
      }
       else {
        cout << "Digit object empty" << endl;
@@ -503,9 +513,9 @@ void AliEveEMCALData::LoadDigitsFromESD()
     {
       Int_t id   = cells.GetCellNumber(icell);
       // adc
-      Double_t ampInt  = cells.GetAmplitude(icell);
+      Double_t ampFlo  = cells.GetAmplitude(icell);
       // GeV
-      //      Double_t amp = ampInt*0.0153; // To be modified with correct OCDB conversion
+      //      Double_t amp = ampFlo*0.0153; // To be modified with correct OCDB conversion
 
       GetGeomInfo(id,iSupMod,x,y,z);
 
@@ -514,15 +524,15 @@ void AliEveEMCALData::LoadDigitsFromESD()
 //       if(iSupMod<fNsmfull) fSMfull[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
 //       if(iSupMod>fNsmfull) fSMhalf[iSupMod-10]->RegisterDigit(id,iSupMod,amp,x,y,z);
       // adc
-      fSM[iSupMod]->RegisterDigit(id,iSupMod,ampInt,x,y,z);
-      if(iSupMod<fNsmfull) fSMfull[iSupMod]->RegisterDigit(id,iSupMod,ampInt,x,y,z);
-      if(iSupMod>fNsmfull) fSMhalf[iSupMod-10]->RegisterDigit(id,iSupMod,ampInt,x,y,z);
+      fSM[iSupMod]->RegisterDigit(id,iSupMod,ampFlo,x,y,z);
+      if(iSupMod<fNsmfull) fSMfull[iSupMod]->RegisterDigit(id,iSupMod,ampFlo,x,y,z);
+      if(iSupMod>fNsmfull) fSMhalf[iSupMod-10]->RegisterDigit(id,iSupMod,ampFlo,x,y,z);
 
     } // end loop cells
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::LoadRecPoints(TTree* t)
+void AliEveEMCALData::LoadRecPoints(TTree* const t)
 {
   //
   // Get rec point information from RunLoader
@@ -548,14 +558,14 @@ void AliEveEMCALData::LoadRecPoints(TTree* t)
        // GeV
        Double_t amp = (Double_t)rp->GetEnergy();
        // adc
-       Double_t ampInt = amp/0.0153; // To be modified with correct OCDB conversion
+       Double_t ampFlo = amp/0.0153; // To be modified with correct OCDB conversion
        TVector3 lpos;
        rp->GetLocalPosition(lpos);
 
 //     // GeV
 //     fSM[iSupMod]->RegisterCluster(iSupMod,amp,lpos[0],lpos[1],lpos[2]);
         // adc
-       fSM[iSupMod]->RegisterCluster(iSupMod,ampInt,lpos[0],lpos[1],lpos[2]);
+       fSM[iSupMod]->RegisterCluster(iSupMod,ampFlo,lpos[0],lpos[1],lpos[2]);
       }
     }
   }
@@ -563,7 +573,7 @@ void AliEveEMCALData::LoadRecPoints(TTree* t)
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::LoadRecPointsFromEMCALLoader(AliEMCALLoader* emcl)
+void AliEveEMCALData::LoadRecPointsFromEMCALLoader(AliEMCALLoader* const emcl)
 {
   //
   // Get rec point information from EMCAL Loader
@@ -590,14 +600,14 @@ void AliEveEMCALData::LoadRecPointsFromEMCALLoader(AliEMCALLoader* emcl)
        if(fDebug>1) cout << "RecPoint info " << rp->GetAbsId() << " " << rp->GetEnergy() << endl;
        Int_t iSupMod = rp->GetSuperModuleNumber();
        Double_t amp = (Double_t)rp->GetEnergy();
-       Double_t ampInt = amp/0.0153; // To be modified with correct OCDB conversion
+       Double_t ampFlo = amp/0.0153; // To be modified with correct OCDB conversion
        TVector3 lpos;
        rp->GetLocalPosition(lpos);
        
 //        // GeV
 //        fSM[iSupMod]->RegisterCluster(iSupMod,amp,lpos[0],lpos[1],lpos[2]);
        // adc
-       fSM[iSupMod]->RegisterCluster(iSupMod,ampInt,lpos[0],lpos[1],lpos[2]);
+       fSM[iSupMod]->RegisterCluster(iSupMod,ampFlo,lpos[0],lpos[1],lpos[2]);
     }
   }
   
@@ -621,8 +631,8 @@ void AliEveEMCALData::LoadRecPointsFromESD()
   
   // Get reconstructed vertex position
   AliESDVertex* primVertex =(AliESDVertex*) fESD->GetVertex();
-  Double_t vertex_position[3] ; 
-  primVertex->GetXYZ(vertex_position) ; 
+  Double_t vertexPosition[3] ; 
+  primVertex->GetXYZ(vertexPosition) ; 
 
   //Get the CaloClusters
   //select EMCAL clusters only 
@@ -642,13 +652,13 @@ void AliEveEMCALData::LoadRecPointsFromESD()
       // adc
       //      Int_t   eneInt = (Int_t)energy*500+0.5;
       Double_t eneInt = energy/0.0153; // To be modified with correct OCDB conversion
-      Double_t disp   = clus->GetClusterDisp() ;
+      Double_t disp   = clus->GetDispersion() ;
       
       clus->GetPosition(pos) ; // Global position
       TVector3 vpos(pos[0],pos[1],pos[2]) ;
       TLorentzVector p4 ;
       TVector3 p3;
-      clus->GetMomentum(p4,vertex_position);
+      clus->GetMomentum(p4,vertexPosition);
       p3.SetXYZ(p4[0],p4[1],p4[2]);
       Double_t eta = p3.Eta();
       Double_t phi = ( (p3.Phi()) < 0) ? (p3.Phi()) + 2. * TMath::Pi() : (p3.Phi());
@@ -707,7 +717,7 @@ AliEveEMCALSModuleData* AliEveEMCALData::GetSModuleData(Int_t sm)
 }
 
 //______________________________________________________________________________
-void AliEveEMCALData::LoadRaw()
+void AliEveEMCALData::LoadRaw() const
 {
   //
   // Get raw information