]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliDetector.cxx
Possibility to define the magnetic field in the reconstruction (Yu.Belikov)
[u/mrichter/AliRoot.git] / STEER / AliDetector.cxx
index 08355af3b8d9804cca9fa1e36a2caf3a8bd782f8..acadffe55629aef445ed8b5313c87dd1aa70d995 100644 (file)
 
 /*
 $Log$
+Revision 1.11  2001/01/26 19:58:46  hristov
+Major upgrade of AliRoot code
+
+Revision 1.10  2001/01/17 10:50:50  hristov
+Corrections to destructors
+
+Revision 1.9  2000/12/12 18:19:06  alibrary
+Introduce consistency check when loading points
+
+Revision 1.8  2000/11/30 07:12:48  alibrary
+Introducing new Rndm and QA classes
+
+Revision 1.7  2000/10/02 21:28:14  fca
+Removal of useless dependecies via forward declarations
+
+Revision 1.6  2000/07/12 08:56:25  fca
+Coding convention correction and warning removal
+
+Revision 1.5  1999/09/29 09:24:29  fca
+Introduction of the Copyright and cvs Log
+
 */
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -34,14 +55,17 @@ $Log$
 //End_Html
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
+
+#include <assert.h>
+
+#include <TTree.h>
+#include <TBrowser.h>
+#include <TFile.h>
+
 #include "AliDetector.h"
 #include "AliRun.h"
 #include "AliHit.h"
 #include "AliPoints.h"
-#include <TClass.h>
-#include <TNode.h>
-#include <TRandom.h>
-
 // Static variables for the hit iterator routines
 static Int_t sMaxIterHit=0;
 static Int_t sCurIterHit=0;
@@ -61,6 +85,7 @@ AliDetector::AliDetector()
   fDigits     = 0;
   fTimeGate   = 200.e-9;
   fBufferSize = 16000;
+  fDigitsFile = 0;
 }
  
 //_____________________________________________________________________________
@@ -80,6 +105,7 @@ AliDetector::AliDetector(const char* name,const char *title):AliModule(name,titl
   fNdigits    = 0;
   fPoints     = 0;
   fBufferSize = 16000;
+  fDigitsFile = 0;
 }
  
 //_____________________________________________________________________________
@@ -92,9 +118,18 @@ AliDetector::~AliDetector()
   fNdigits    = 0;
   //
   // Delete space point structure
-  if (fPoints) fPoints->Delete();
-  delete fPoints;
-  fPoints     = 0;
+  if (fPoints) {
+    fPoints->Delete();
+    delete fPoints;
+    fPoints     = 0;
+  }
+  // Delete digits structure
+  if (fDigits) {
+    fDigits->Delete();
+    delete fDigits;
+    fDigits     = 0;
+  }
+  if (fDigitsFile) delete [] fDigitsFile;
 }
  
 //_____________________________________________________________________________
@@ -116,6 +151,15 @@ void AliDetector::Browse(TBrowser *b)
   }
 }
 
+//_____________________________________________________________________________
+void AliDetector::Copy(AliDetector &det) const
+{
+  //
+  // Copy *this onto det -- not implemented
+  //
+  Fatal("Copy","Not implemented~\n");
+}
+
 //_____________________________________________________________________________
 void AliDetector::FinishRun()
 {
@@ -194,6 +238,7 @@ void AliDetector::LoadPoints(Int_t)
   for (Int_t hit=0;hit<nhits;hit++) {
     ahit = (AliHit*)fHits->UncheckedAt(hit);
     trk=ahit->GetTrack();
+    assert(trk<=tracks);
     if(ntrk[trk]==limi[trk]) {
       //
       // Initialise a new track
@@ -207,9 +252,9 @@ void AliDetector::LoadPoints(Int_t)
     } else {
       fp = coor[trk];
     }
-    fp[3*ntrk[trk]  ] = ahit->fX;
-    fp[3*ntrk[trk]+1] = ahit->fY;
-    fp[3*ntrk[trk]+2] = ahit->fZ;
+    fp[3*ntrk[trk]  ] = ahit->X();
+    fp[3*ntrk[trk]+1] = ahit->Y();
+    fp[3*ntrk[trk]+2] = ahit->Z();
     ntrk[trk]++;
   }
   //
@@ -232,22 +277,32 @@ void AliDetector::LoadPoints(Int_t)
 }
 
 //_____________________________________________________________________________
-void AliDetector::MakeBranch(Option_t *option)
+void AliDetector::MakeBranch(Option_t *option, char *file)
 {
   //
   // Create a new branch in the current Root Tree
   // The branch of fHits is automatically split
   //
   char branchname[10];
   sprintf(branchname,"%s",GetName());
   //
   // Get the pointer to the header
-  char *H = strstr(option,"H");
+  const char *cH = strstr(option,"H");
   //
-  if (fHits   && gAlice->TreeH() && H) {
-    gAlice->TreeH()->Branch(branchname,&fHits, fBufferSize);
-    printf("* AliDetector::MakeBranch * Making Branch %s for hits\n",branchname);
+  if (fHits && gAlice->TreeH() && cH) {
+    gAlice->MakeBranchInTree(gAlice->TreeH(), 
+                             branchname, &fHits, fBufferSize, file) ;
   }    
+  
+  const char *cD = strstr(option,"D");
+
+  if (cD) {
+    if (file) {
+       fDigitsFile = new char[strlen (file)];
+       strcpy(fDigitsFile,file);
+    }
+  }
 }
 
 //_____________________________________________________________________________
@@ -308,39 +363,4 @@ void AliDetector::SetTreeAddress()
   }
 }
 
-//_____________________________________________________________________________
-void AliDetector::Streamer(TBuffer &R__b)
-{
-  //
-  // Stream an object of class Detector.
-  //
-  if (R__b.IsReading()) {
-    Version_t R__v = R__b.ReadVersion(); if (R__v) { }
-    TNamed::Streamer(R__b);
-    TAttLine::Streamer(R__b);
-    TAttMarker::Streamer(R__b);
-    AliModule::Streamer(R__b);
-    R__b >> fTimeGate;
-    R__b >> fIshunt;
-    //R__b >> fNhits;
-    //
-    // Stream the pointers but not the TClonesArrays
-    R__b >> fHits; // diff
-    R__b >> fDigits; // diff
-    
-  } else {
-    R__b.WriteVersion(AliDetector::IsA());
-    TNamed::Streamer(R__b);
-    TAttLine::Streamer(R__b);
-    TAttMarker::Streamer(R__b);
-    AliModule::Streamer(R__b);
-    R__b << fTimeGate;
-    R__b << fIshunt;
-    //R__b << fNhits;
-    //
-    // Stream the pointers but not the TClonesArrays
-    R__b << fHits; // diff
-    R__b << fDigits; // diff
-  }
-}