]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDdigitsManager.cxx
Protection against division by 0 in Binaries().
[u/mrichter/AliRoot.git] / TRD / AliTRDdigitsManager.cxx
index ab1d5f27c925f38afcfb4d22638cb1dda36881e3..ab7a04e5879171012f13e4a51073546cad2e1b46 100644 (file)
 
 /*
 $Log$
+Revision 1.21  2003/02/04 17:26:00  cblume
+Include a reset of the digits arrays in order to process several events
+
+Revision 1.20  2002/10/22 15:53:08  alibrary
+Introducing Riostream.h
+
+Revision 1.19  2002/10/14 14:57:43  hristov
+Merging the VirtualMC branch to the main development branch (HEAD)
+
 Revision 1.16.6.2  2002/07/24 10:09:30  alibrary
 Updating VirtualMC
 
@@ -99,7 +108,7 @@ Add new class AliTRDdigitsManager
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <iostream.h>
+#include <Riostream.h>
  
 #include <TROOT.h>
 #include <TTree.h>                                                              
@@ -134,6 +143,7 @@ AliTRDdigitsManager::AliTRDdigitsManager():TObject()
   fSDigits = 0;
 
   fFile    = NULL;
+  fFileCreated = kFALSE;
   fTree    = NULL;
   fDigits  = NULL;
   for (Int_t iDict = 0; iDict < kNDict; iDict++) {
@@ -160,7 +170,7 @@ AliTRDdigitsManager::~AliTRDdigitsManager()
   // AliTRDdigitsManager destructor
   //
 
-  if (fFile) {
+  if (fFile && fFileCreated) {
     fFile->Close();
     delete fFile;
     fFile = NULL;
@@ -210,6 +220,27 @@ void AliTRDdigitsManager::CreateArrays()
                                                ,AliTRDgeometry::Ndet());
   }
 
+}
+//_____________________________________________________________________________
+void AliTRDdigitsManager::ResetArrays()
+{
+  //
+  // Reset the data arrays
+  //
+
+  if (fDigits) {
+    delete fDigits;
+  }
+  fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet());
+
+  for (Int_t iDict = 0; iDict < kNDict; iDict++) {
+    if (fDictionary[iDict]) {  
+      delete fDictionary[iDict];
+    }
+    fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI"
+                                               ,AliTRDgeometry::Ndet());
+  }
+
 }
 
 //_____________________________________________________________________________
@@ -251,6 +282,7 @@ Bool_t AliTRDdigitsManager::Open(const Char_t *file)
       printf("Open the AliROOT-file %s.\n",file);
     }
     fFile = new TFile(file,"UPDATE");
+    fFileCreated = kTRUE;
     if (!fFile) return kFALSE;
   }
   else {