]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSLoader.cxx
Coverity fix.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSLoader.cxx
index 57cce58e1d9652673e9c43071dfb1c6ec4fcd7ed..0a90d24fc56fe633314badd75fbb7f04ad9d7d1e 100644 (file)
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.18  2006/08/28 10:01:56  kharlov
+ * Effective C++ warnings fixed (Timur Pocheptsov)
+ *
+ * Revision 1.17  2006/08/25 16:00:53  kharlov
+ * Compliance with Effective C++AliPHOSHit.cxx
+ *
+ * Revision 1.16  2006/08/01 12:15:04  cvetan
+ * Adding a constructor from TFolder. Needed by AliReconstruction plugin scheme
+ *
  * Revision 1.15  2005/07/12 20:07:35  hristov
  * Changes needed to run simulation and reconstrruction in the same AliRoot session
  *
 //     ................
 //  please->GetEvent(event) ;    // reads new event from galice.root
 //                  
-//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
-//*--         Completely redesigned by Dmitri Peressounko March 2001  
+//-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
+//--         Completely redesigned by Dmitri Peressounko March 2001  
 //
-//*-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
-//*--         systematic usage of TFolders without changing the interface        
+//-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
+//--         systematic usage of TFolders without changing the interface        
 //////////////////////////////////////////////////////////////////////////////
 
 
@@ -63,8 +72,6 @@
 #include "AliPHOSLoader.h"
 #include "AliPHOS.h"
 #include "AliPHOSHit.h"
-#include "AliPHOSCalibrationDB.h"
-#include "AliPHOSGetter.h"
 
 ClassImp(AliPHOSLoader)
 
@@ -82,22 +89,28 @@ const TString AliPHOSLoader::fgkCpvRecPointsBranchName("PHOSCpvRP");//Name for b
 const TString AliPHOSLoader::fgkTrackSegmentsBranchName("PHOSTS");//Name for branch with TrackSegments
 const TString AliPHOSLoader::fgkRecParticlesBranchName("PHOSRP");//Name for branch with Reconstructed Particles
 //____________________________________________________________________________ 
-AliPHOSLoader::AliPHOSLoader()
- {
-  fDebug = 0;
- }
+AliPHOSLoader::AliPHOSLoader() : fBranchTitle(), fDebug(0), fTmpHits(0x0)
+{
+  //def ctor
+  fTmpHits =  new TClonesArray("AliPHOSHit",1000);
+}
 //____________________________________________________________________________ 
-AliPHOSLoader::AliPHOSLoader(const Char_t *detname,const Char_t *eventfoldername):
-      AliLoader(detname,eventfoldername)
+AliPHOSLoader::AliPHOSLoader(const Char_t *detname,const Char_t *eventfoldername) :
+      AliLoader(detname, eventfoldername),
+      fBranchTitle(), fDebug(0), fTmpHits(0x0)
 {
-  fDebug=0;
+  //ctor
 }
 //____________________________________________________________________________ 
 AliPHOSLoader::AliPHOSLoader(const Char_t *detname,TFolder *topfolder):
-      AliLoader(detname,topfolder)
+  AliLoader(detname,topfolder),
+  fBranchTitle(), fDebug(0), fTmpHits(0x0)
+
 {
-  fDebug=0;
+  //ctor
+  fTmpHits =  new TClonesArray("AliPHOSHit",1000);
 }
+
 //____________________________________________________________________________ 
 
 AliPHOSLoader::~AliPHOSLoader()
@@ -111,10 +124,6 @@ AliPHOSLoader::~AliPHOSLoader()
   Clean(fgkTracksName);
   Clean(fgkRecParticlesName);
   CleanFolders() ;
-  // set to 0x0 the objgetter in AliGetter ... weird isn it !
-  AliPHOSGetter * gime = AliPHOSGetter::Instance() ; // (AliLoader::GetRunLoader()->GetFileName()).Data()) ; 
-  if (gime) 
-    gime->Reset() ;
 }
 
 //____________________________________________________________________________ 
@@ -128,7 +137,7 @@ void AliPHOSLoader::CleanFolders()
 Int_t AliPHOSLoader::SetEvent()
 {
 //Cleans loaded stuff and and sets Files and Directories
-// do not post any data to folder/tasks
+// do not post any data to folder
 
 
  Int_t retval = AliLoader::SetEvent();
@@ -178,27 +187,16 @@ Int_t AliPHOSLoader::GetEvent()
   return 0;
 }
 
-//____________________________________________________________________________ 
-const AliPHOS * AliPHOSLoader::PHOS() 
-{
-  // returns the PHOS object 
-  AliPHOS * phos = dynamic_cast<AliPHOS*>(GetModulesFolder()->FindObject(fDetectorName));
-  if ( phos == 0x0) 
-    if (fDebug)
-      cout << "WARNING: AliPHOSLoader::PHOS -> PHOS module not found in Folders" << endl ; 
-  return phos ; 
-}  
-
-//____________________________________________________________________________ 
-const AliPHOSGeometry * AliPHOSLoader::PHOSGeometry() 
-{
-  // Return PHOS geometry
-  AliPHOSGeometry * rv = 0 ; 
-  if (PHOS() )
-    rv =  PHOS()->GetGeometry();
-  return rv ; 
-} 
-
+// //____________________________________________________________________________ 
+// const AliPHOS * AliPHOSLoader::PHOS() 
+// {
+//   // returns the PHOS object 
+//   AliPHOS * phos = dynamic_cast<AliPHOS*>(GetModulesFolder()->FindObject(fDetectorName));
+//   if ( phos == 0x0) 
+//     if (fDebug)
+//       cout << "WARNING: AliPHOSLoader::PHOS -> PHOS module not found in Folders" << endl ; 
+//   return phos ; 
+// }  
 
 //____________________________________________________________________________ 
 Int_t AliPHOSLoader::LoadHits(Option_t* opt)
@@ -399,58 +397,47 @@ Int_t AliPHOSLoader::ReadHits()
 // Reads data from TreeH and stores it in TClonesArray that sits in DetectorDataFolder
 //
   TObject** hitref = HitsRef();
-  if(hitref == 0x0)
-   {
-     MakeHitsArray();
-     hitref = HitsRef();
-   }
+  if(hitref == 0x0) {
+    MakeHitsArray();
+    hitref = HitsRef();
+  }
 
-  TClonesArray* hits = dynamic_cast<TClonesArray*>(*hitref);
+  TClonesArray* hits = static_cast<TClonesArray*>(*hitref);
 
   TTree* treeh = TreeH();
   
-  if(treeh == 0)
-   {
+  if(treeh == 0) {
     AliError("Cannot read TreeH from folder");
     return 1;
   }
   
   TBranch * hitsbranch = treeh->GetBranch(fDetectorName);
-  if (hitsbranch == 0) 
-   {
+  if (hitsbranch == 0) {
     AliError("Cannot find branch PHOS"); 
     return 1;
   }
 
   AliDebug(1, "Reading Hits");
   
-  if (hitsbranch->GetEntries() > 1)
-   {
-    TClonesArray * tempo =  new TClonesArray("AliPHOSHit",1000);
+  if (hitsbranch->GetEntries() > 1) {
 
-    hitsbranch->SetAddress(&tempo);
+    hitsbranch->SetAddress(&fTmpHits);
     Int_t index = 0 ; 
-    Int_t i = 0 ;
-    for (i = 0 ; i < hitsbranch->GetEntries(); i++) 
-     {
+    for (Int_t i = 0 ; i < hitsbranch->GetEntries(); i++) {
       hitsbranch->GetEntry(i) ;
-      Int_t j = 0 ;
-      for ( j = 0 ; j < tempo->GetEntries() ; j++) 
-       {
-         AliPHOSHit* hit = (AliPHOSHit*)tempo->At(j); 
-         new((*hits)[index]) AliPHOSHit( *hit ) ;
-         index++ ; 
-       }
-     }
-    tempo->Delete();
-    delete tempo;
-   }
-  else 
-   {
+      for (Int_t j = 0 ; j < fTmpHits->GetEntriesFast() ; j++) {
+       AliPHOSHit* hit = (AliPHOSHit*)fTmpHits->At(j); 
+       new((*hits)[index]) AliPHOSHit( *hit ) ;
+       index++ ; 
+      }
+    }
+    fTmpHits->Clear();
+  }
+  else {
     hitsbranch->SetAddress(hitref);
     hitsbranch->GetEntry(0) ;
-   }
-
+  }
+  
   return 0;
 }
 //____________________________________________________________________________ 
@@ -484,7 +471,7 @@ Int_t AliPHOSLoader::ReadSDigits()
     return 0;
   }
     
-  branch->SetAddress(SDigitsRef());
+  branch->SetAddress(sdref);
   branch->GetEntry(0);
   return 0;
 }
@@ -600,13 +587,17 @@ Int_t AliPHOSLoader::ReadRecPoints()
    }
 
   Int_t ii ; 
-  Int_t maxemc = emca->GetEntries() ; 
-  for ( ii= 0 ; ii < maxemc ; ii++ ) 
-    EmcRecPoints()->Add(emca->At(ii)) ;
-  Int_t maxcpv = cpva->GetEntries() ;
-  for ( ii= 0 ; ii < maxcpv ; ii++ )
-    CpvRecPoints()->Add(cpva->At(ii)) ; 
+  if (emca != 0) {
+    Int_t maxemc = emca->GetEntries() ; 
+    for ( ii= 0 ; ii < maxemc ; ii++ ) 
+      EmcRecPoints()->Add(emca->At(ii)) ;
+  }
+
+  if (cpva != 0) {
+    Int_t maxcpv = cpva->GetEntries() ;
+    for ( ii= 0 ; ii < maxcpv ; ii++ )
+      CpvRecPoints()->Add(cpva->At(ii)) ; 
+  }
 
   return retval;
 }
@@ -634,6 +625,8 @@ Int_t AliPHOSLoader::ReadTracks()
    }
   
   TBranch * branch = treeT->GetBranch(fgkTrackSegmentsBranchName);
+//   AliInfo(Form("Branch named %s is opened: 0x%z",
+//               fgkTrackSegmentsBranchName.Data(),branch));
   if (branch == 0) 
    {//easy, maybe just a new tree
     AliError(Form("Cannot find branch named %s",
@@ -687,17 +680,6 @@ Int_t AliPHOSLoader::ReadRecParticles()
 }
 
 
-AliPHOSGeometry* AliPHOSLoader::GetPHOSGeometry()
-{
-  //returns PHOS geometry from gAlice 
-  //static Method used by some classes where it is not convienient to pass eventfoldername
-  if (gAlice == 0x0)
-    return 0x0;
-  AliPHOS* phos=dynamic_cast<AliPHOS*>(gAlice->GetDetector("PHOS"));
-  if (phos == 0x0)
-    return 0x0;
-  return phos->GetGeometry();
-}
 /***************************************************************************************/
 
 AliPHOSLoader* AliPHOSLoader::GetPHOSLoader(const  char* eventfoldername)
@@ -852,34 +834,6 @@ void AliPHOSLoader::CleanRecParticles()
  }
 //____________________________________________________________________________ 
 
-void AliPHOSLoader::ReadCalibrationDB(const char * database,const char * filename)
-{
-  // Read calibration data base from file
-  if(fcdb && (strcmp(database,fcdb->GetTitle())==0))
-    return ;
-
-  TFile * file = gROOT->GetFile(filename) ;
-  if(!file)
-    file = TFile::Open(filename);
-  if(!file){
-    AliError(Form("Cannot open file %s", filename)) ;
-    return ;
-  }
-  if(fcdb)
-    fcdb->Delete() ;
-  fcdb = dynamic_cast<AliPHOSCalibrationDB *>(file->Get("AliPHOSCalibrationDB")) ;
-  if(!fcdb)
-    AliError(Form("No database %s in file %s", database, filename)) ;
-}
-//____________________________________________________________________________ 
-
-// AliPHOSSDigitizer*  AliPHOSLoader::PHOSSDigitizer() 
-// { 
-// //return PHOS SDigitizer
-//  return  dynamic_cast<AliPHOSSDigitizer*>(SDigitizer()) ;
-// }
-
-//____________________________________________________________________________ 
 void AliPHOSLoader::MakeHitsArray()
 {
   // Add Hits array to the data folder