]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSsDigitize.cxx
Fixes for Coverity warnings (M. van Leeuwen)
[u/mrichter/AliRoot.git] / ITS / AliITSsDigitize.cxx
index 481d2e12e39926d65f203820a84168150fb61a54..282b6aa618ca3afae878f2fb87c6a6adc84aec7d 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
  
-/*
-$Log$
-Revision 1.2.4.1  2002/06/10 17:51:15  hristov
-Merged with v3-08-02
+/* $Id$ */
 
-Revision 1.2  2002/05/19 18:17:03  hristov
-Changes needed by ICC/IFC compiler (Intel)
-
-Revision 1.1  2002/03/28 16:25:26  nilsen
-New TTask method for creating SDigits from Hits.
-
-*/
-
-#include <iostream.h>
+#include <Riostream.h>
  
 #include <TROOT.h>
 #include <TFile.h>
@@ -40,10 +29,20 @@ New TTask method for creating SDigits from Hits.
 #include "AliITS.h"
 #include "AliITSsDigitize.h"
 #include "AliITSgeom.h"
+
+/////////////////////////////////////////////////////////
+//                                                     //
+//                                                     //
+//                                                     //
+///////////////////////////////////////////////////////// 
 ClassImp(AliITSsDigitize)
 //______________________________________________________________________
-AliITSsDigitize::AliITSsDigitize(){
+AliITSsDigitize::AliITSsDigitize():
+fInit(kFALSE),
+fEnt(0),
+fEnt0(0),
+fITS(0),
+fRunLoader(0x0){
     // Default constructor.
     // Inputs:
     //  none.
@@ -52,14 +51,15 @@ AliITSsDigitize::AliITSsDigitize(){
     // Return:
     //    A zero-ed constructed AliITSsDigitize class.
  
-    fFilename = "";
-    fFile     = 0;
-    fITS      = 0;
     fDet[0] = fDet[1] = fDet[2] = kTRUE;
-    fInit     = kFALSE;
 }
 //______________________________________________________________________
-AliITSsDigitize::AliITSsDigitize(const char* filename){
+AliITSsDigitize::AliITSsDigitize(const char* filename):
+fInit(),
+fEnt(0),
+fEnt0(0),
+fITS(0),
+fRunLoader(0x0){
     // Standard constructor.
     // Inputs:
     //  const char* filename    filename containing the digits to be
@@ -72,24 +72,15 @@ AliITSsDigitize::AliITSsDigitize(const char* filename){
     // Return:
     //    A standardly constructed AliITSsDigitize class.
  
-    fFilename = filename;
-    if(filename){
-        fFile = (TFile*)gROOT->GetListOfFiles()->FindObject(fFilename.Data());
-        if(fFile) fFile->Close();
-        fFile = new TFile(fFilename.Data(),"UPDATE");
-        //
-        if(gAlice) {
-          delete gAlice;
-          gAlice = 0;
-        }
-        gAlice = (AliRun*)fFile->Get("gAlice");
-        if(!gAlice) {
-            cout << "gAlice not found on file. Aborting." << endl;
-            fInit = kFALSE;
-            return;
-        } // end if !gAlice
-    } // end if !filename.
+    if(gAlice) 
+     {
+      delete gAlice;
+      gAlice = 0;
+     }
+    fRunLoader = AliRunLoader::Open(filename);
+    fRunLoader->LoadgAlice();
+    fRunLoader->LoadHeader();
+    
  
     Init();
 }
@@ -103,8 +94,7 @@ AliITSsDigitize::~AliITSsDigitize(){
     // Return:
     //    A destroyed AliITSsDigitize class.
  
-    if(fFile) fFile->Close();
-    fFile     = 0;
+    if(fRunLoader) delete fRunLoader;
     fITS      = 0;
  
 }
@@ -117,8 +107,8 @@ Bool_t AliITSsDigitize::Init(){
     //   none.
     // Return:
     //    kTRUE if no errors initilizing this class occurse else kFALSE
-    Int_t nparticles;
+    //Int_t nparticles;
+   
     fITS = (AliITS*) gAlice->GetDetector("ITS");
     if(!fITS){
         cout << "ITS not found aborting. fITS=" << fITS << endl;
@@ -134,23 +124,25 @@ Bool_t AliITSsDigitize::Init(){
  
     fDet[0] = fDet[1] = fDet[2] = kTRUE;
     fEnt0 = 0;
-    fEnt  = gAlice->GetEventsPerRun(); 
+    fEnt  = AliRunLoader::Instance()->GetNumberOfEvents(); 
  
-    if(!gAlice->TreeS()){
+    AliLoader* loader = fRunLoader->GetLoader("ITSLoader");
+    
+    if(!loader->TreeS()){
         cout << "Having to create the SDigits Tree." << endl;
-        gAlice->MakeTree("S");
+        loader->MakeTree("S");
     } // end if !gAlice->TreeS()
     //make branch
     fITS->MakeBranch("S");
     fITS->SetTreeAddress();
-    nparticles = gAlice->GetEvent(fEnt0);
+    
+    fRunLoader->GetEvent(fEnt0);
     // finished init.
     fInit = InitSDig();
     return fInit;
 }
 //______________________________________________________________________
-Bool_t AliITSsDigitize::InitSDig(){
+Bool_t AliITSsDigitize::InitSDig() const {
     // Sets up SDigitization part of AliITSDetType..
     // Inputs:
     //      none.
@@ -172,9 +164,14 @@ void AliITSsDigitize::Exec(const Option_t *opt){
     // Return:
     //      none.
     Option_t *lopt;
-//    Int_t nparticles,evnt;
-    if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS")||opt==0){
+    Bool_t condition =kFALSE;
+    if(opt){
+      if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS"))condition =kTRUE;
+    }
+    else{
+      condition = kTRUE;
+    } 
+    if(condition){
         fDet[0] = fDet[1] = fDet[2] = kTRUE;
         lopt = "All";
     }else{
@@ -191,5 +188,5 @@ void AliITSsDigitize::Exec(const Option_t *opt){
         return;
     } // end if !fInit
 
-    fITS->HitsToSDigits(gAlice->GetHeader()->GetEvent(),0,-1," ",lopt," ");
+    fITS->HitsToSDigits(fRunLoader->GetHeader()->GetEvent(),0,-1," ",lopt," ");
 }