]> 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 cc979aed776b249fb3db1010935a98c70f322294..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
+
+Revision 1.16.6.1  2002/06/10 15:28:58  hristov
+Merged with v3-08-02
+
+Revision 1.18  2002/04/12 12:13:23  cblume
+Add Jiris changes
+
+Revision 1.17  2002/03/28 14:59:07  cblume
+Coding conventions
+
+Revision 1.18  2002/04/12 12:13:23  cblume
+Add Jiris changes
+
+Revision 1.17  2002/03/28 14:59:07  cblume
+Coding conventions
+
+Revision 1.16  2002/02/12 11:42:08  cblume
+Remove fTree from destructor
+
 Revision 1.15  2002/02/11 14:27:54  cblume
 Geometry and hit structure update
 
@@ -78,7 +108,7 @@ Add new class AliTRDdigitsManager
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <iostream.h>
+#include <Riostream.h>
  
 #include <TROOT.h>
 #include <TTree.h>                                                              
@@ -113,6 +143,7 @@ AliTRDdigitsManager::AliTRDdigitsManager():TObject()
   fSDigits = 0;
 
   fFile    = NULL;
+  fFileCreated = kFALSE;
   fTree    = NULL;
   fDigits  = NULL;
   for (Int_t iDict = 0; iDict < kNDict; iDict++) {
@@ -139,7 +170,7 @@ AliTRDdigitsManager::~AliTRDdigitsManager()
   // AliTRDdigitsManager destructor
   //
 
-  if (fFile) {
+  if (fFile && fFileCreated) {
     fFile->Close();
     delete fFile;
     fFile = NULL;
@@ -189,11 +220,35 @@ 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());
+  }
+
 }
 
 //_____________________________________________________________________________
 void AliTRDdigitsManager::SetRaw()
 {
+  //
+  // Switch on the raw digits flag
+  //
 
   fIsRaw = kTRUE;
 
@@ -227,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 {
@@ -240,6 +296,21 @@ Bool_t AliTRDdigitsManager::Open(const Char_t *file)
 
 }
 
+//_____________________________________________________________________________
+void AliTRDdigitsManager::MakeTreeAndBranches(TFile *file, Int_t iEvent)
+{
+  //
+  // Creates tree for (s)digits in the specified file
+  //
+
+  fEvent = iEvent;
+  TDirectory *wd = gDirectory;
+  file->cd();
+  MakeBranch();
+  wd->cd();
+
+}
+
 //_____________________________________________________________________________
 Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file)
 {
@@ -424,7 +495,8 @@ Bool_t AliTRDdigitsManager::WriteDigits()
   }
 
   // Write the new tree to the output file
-  fTree->Write();
+  //fTree->Write();
+  fTree->AutoSave();  // Modification by Jiri
 
   return kTRUE;