]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSDigitizer.cxx
coverity fix
[u/mrichter/AliRoot.git] / ITS / AliITSDigitizer.cxx
index f7123febd44ec8916dad88658758f23b6ae706b4..a2b3dfb19561aaf96671ae19f9a2690e394b98e3 100644 (file)
 #include <TTree.h>
 #include <TBranch.h>
 
-#include <AliRun.h>
-#include <AliRunLoader.h>
-#include <AliLoader.h>
-#include <AliRunDigitizer.h>
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliLoader.h"
+#include "AliLog.h"
+#include "AliRunDigitizer.h"
 #include "AliITSDigitizer.h"
 #include "AliITSgeom.h"
+#include "AliITSgeomTGeo.h"
 #include "AliITSsimulation.h"
 
 ClassImp(AliITSDigitizer)
 
 //______________________________________________________________________
-AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
+AliITSDigitizer::AliITSDigitizer() : AliDigitizer(),
+fITS(0),
+fModActive(0),
+fInit(kFALSE),
+fRoif(-1),
+fRoiifile(0),
+fFlagFirstEv(kTRUE){
     // Default constructor. Assign fITS since it is never written out from
     // here. 
     // Inputs:
@@ -50,16 +58,18 @@ AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
     //      none.
     // Return:
     //      A blank AliITSDigitizer class.
+  fModActive = new Bool_t[AliITSgeomTGeo::GetNModules()];
+  for(Int_t i=0;i<AliITSgeomTGeo::GetNModules();i++) fModActive[i] = kTRUE;
 
-    fITS      = 0;
-    fModActive   = 0;
-    fRoif     = -1;
-    fRoiifile = 0;
-    fInit     = kFALSE;
-    fFlagFirstEv =kTRUE;
 }
 //______________________________________________________________________
-AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
+AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr),
+fITS(0),
+fModActive(0),
+fInit(kFALSE),
+fRoif(-1),
+fRoiifile(0),
+fFlagFirstEv(kTRUE){
     // Standard constructor. Assign fITS since it is never written out from
     // here. 
     // Inputs:
@@ -68,29 +78,10 @@ AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
     //      none.
     // Return:
     //      An AliItSDigitizer class.
-
-    fITS      = 0;
-    fModActive   = 0;
-    fRoif     = -1;
-    fRoiifile = 0;
-    fInit     = kFALSE;
-    fFlagFirstEv =kTRUE;
+  fModActive = new Bool_t[AliITSgeomTGeo::GetNModules()];
+  for(Int_t i=0;i<AliITSgeomTGeo::GetNModules();i++) fModActive[i] = kTRUE;
 }
 
-//______________________________________________________________________
-AliITSDigitizer::AliITSDigitizer(const AliITSDigitizer &/*rec*/):AliDigitizer(/*rec*/){
-    // Copy constructor. 
-
-  Error("Copy constructor","Copy constructor not allowed");
-  
-}
-//______________________________________________________________________
-AliITSDigitizer& AliITSDigitizer::operator=(const AliITSDigitizer& /*source*/){
-    // Assignment operator. This is a function which is not allowed to be
-    // done.
-    Error("operator=","Assignment operator not allowed\n");
-    return *this; 
-}
 
 //______________________________________________________________________
 AliITSDigitizer::~AliITSDigitizer(){
@@ -129,17 +120,13 @@ Bool_t AliITSDigitizer::Init(){
        fInit     = kFALSE;
        Warning("Init","ITS not found");
        return fInit;
-    } else if(fITS->GetITSgeom()){
-       //cout << "fRoif,fRoiifile="<<fRoif<<" "<<fRoiifile<<endl;
-       fModActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()];
-    } else{
+    } 
+    if(!fITS->GetITSgeom()){
        fRoiifile = 0;
        fInit     = kFALSE;
        Warning("Init","ITS geometry not found");
        return fInit;
     } // end if
-    // fModActive needs to be set to a default all kTRUE value
-    for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
     return fInit;
 }
 //______________________________________________________________________
@@ -152,7 +139,7 @@ void AliITSDigitizer::Exec(Option_t* opt){
     // Return:
     //      none.
 
-    char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+  char name[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
     const char *all;
     const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
                           strstr(opt,"SSD")};
@@ -171,7 +158,7 @@ void AliITSDigitizer::Exec(Option_t* opt){
        return;
     } // end if
 
-    sprintf(name,"%s",fITS->GetName());
+    snprintf(name,20,"%s",fITS->GetName());
 
     Int_t size   = fITS->GetITSgeom()->GetIndexMax();
     Int_t module,id,ifiles,mask;
@@ -198,6 +185,7 @@ void AliITSDigitizer::Exec(Option_t* opt){
     if ( outRL == 0x0)
      {
        Error("Exec","Can not get Output Run Loader");
+       delete [] fl;
        return;
      }
     outRL->GetEvent(event);
@@ -205,6 +193,7 @@ void AliITSDigitizer::Exec(Option_t* opt){
     if ( outgime == 0x0)
      {
        Error("Exec","Can not get Output ITS Loader");
+       delete [] fl;
        return;
      }
 
@@ -213,11 +202,13 @@ void AliITSDigitizer::Exec(Option_t* opt){
     
     // Digitize
     fITS->MakeBranchInTreeD(outgime->TreeD());
-    if(fRoif!=0) Info("AliITSDigitizer","Region of Interest digitization selected");
-    else Info("AliITSDigitizer","No Region of Interest selected. Digitizing everything");
-    //cout <<"fModActive="<<fModActive<<" fRoif="<<fRoif;
-    if(fModActive==0) fRoif = 0; // fModActive array must be define for RIO cuts.
-    //cout <<" fRoif="<<fRoif<<endl;
+    if(fRoif!=0) {
+      AliDebug(1,"Region of Interest digitization selected");
+    }
+    else {
+      AliDebug(1,"No Region of Interest selected. Digitizing everything");
+    }
+
 
     for(ifiles=0; ifiles<nfiles; ifiles++ )
      {
@@ -228,7 +219,7 @@ void AliITSDigitizer::Exec(Option_t* opt){
 
     for(module=0; module<size; module++ )
      {
-       if(fModActive && fRoif!=0) if(!fModActive[module]) continue;
+       if(fRoif!=0) if(!fModActive[module]) continue;
        id = fITS->GetITSgeom()->GetModuleType(module);
        if(!all && !det[id]) continue;
        sim      = (AliITSsimulation*)fITS->GetSimulationModel(id);
@@ -249,7 +240,7 @@ void AliITSDigitizer::Exec(Option_t* opt){
            TTree *treeS = ingime->TreeS();
            fITS->SetTreeAddress();
            
-           if( !(treeS && fITS->GetSDigits()) ) continue; 
+           if( !treeS  ) continue; 
            TBranch *brchSDigits = treeS->GetBranch( name );
            if( brchSDigits ) 
             {
@@ -257,6 +248,7 @@ void AliITSDigitizer::Exec(Option_t* opt){
             } else {
                 Error( "Exec", "branch ITS not found in TreeS, input file %d ",
                        ifiles );
+               delete [] fl;
                return;
             } // end if brchSDigits
             sdig->Clear();
@@ -329,7 +321,6 @@ void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){
 
     nm = fITS->GetITSgeom()->GetIndexMax();
     for(m=0;m<nm;m++){
-      //cout << " fModActive["<<m<<"]=";
       fModActive[m] = kFALSE; // Not active by default
       sdig->Clear();
       brchSDigits->GetEvent(m);
@@ -343,7 +334,7 @@ void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){
       //cout << fModActive[m];
       //cout << endl;
     } // end for m
-    Info("AliITSDigitizer","Digitization by Region of Interest selected");
+    AliDebug(1,"Digitization by Region of Interest selected");
     sdig->Clear();
     delete sdig;
     return;