]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliDetector.cxx
Issue AliError instead of AliFatal in case of inconsistent number of tracks
[u/mrichter/AliRoot.git] / STEER / AliDetector.cxx
index 3731b6196fa14842c69007c73a3402e6b71e9616..71d748b5b2ddc3ef9a386fbd734dfcf045e9f5cc 100644 (file)
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <assert.h>
-
 #include <TBrowser.h>
-#include <TFile.h>
-#include <TFolder.h>
-#include <TROOT.h>
 #include <TTree.h>
-#include <Riostream.h>
 
+#include "AliLog.h"
 #include "AliConfig.h"
 #include "AliDetector.h"
 #include "AliHit.h"
 #include "AliMC.h"
 
 
-// Static variables for the hit iterator routines
-static Int_t sMaxIterHit=0;
-static Int_t sCurIterHit=0;
-
-
 ClassImp(AliDetector)
  
 //_______________________________________________________________________
 AliDetector::AliDetector():
+  AliModule(),
   fTimeGate(200.e-9),
   fIshunt(0),
   fNhits(0),
   fNdigits(0),
   fBufferSize(1600),
+  fMaxIterHit(0),
+  fCurIterHit(0),
   fHits(0),
   fDigits(0),
   fPoints(0),
@@ -83,6 +76,8 @@ AliDetector::AliDetector(const AliDetector &det):
   fNhits(0),
   fNdigits(0),
   fBufferSize(1600),
+  fMaxIterHit(0),
+  fCurIterHit(0),
   fHits(0),
   fDigits(0),
   fPoints(0),
@@ -99,6 +94,8 @@ AliDetector::AliDetector(const char* name,const char *title):
   fNhits(0),
   fNdigits(0),
   fBufferSize(1600),
+  fMaxIterHit(0),
+  fCurIterHit(0),
   fHits(0),
   fDigits(0),
   fPoints(0),
@@ -143,12 +140,11 @@ AliDetector::~AliDetector()
 }
 
 //_______________________________________________________________________
-void AliDetector::Publish(const char */*dir*/, void */*address*/, const char */*name*/)
+void AliDetector::Publish(const char */*dir*/, void */*address*/, const char */*name*/) const
 {
 //
 // Register pointer to detector objects. 
 // 
-//  TFolder *topFolder = (TFolder *)gROOT->FindObjectAny("/Folders");
   MayNotUse("Publish");
 }
 
@@ -171,17 +167,17 @@ TBranch* AliDetector::MakeBranchInTree(TTree *tree, const char* name,
 // 
 //
 //
-// if (GetDebug()>1)
if(GetDebug()) Info("MakeBranch","Making Branch %s",name);
+    
AliDebug(2,Form("Making Branch %s",name));
  if (tree == 0x0) 
   {
-   Error("MakeBranch","Making Branch %s Tree is NULL",name);
+   AliError(Form("Making Branch %s Tree is NULL",name));
    return 0x0;
   }
  TBranch *branch = tree->GetBranch(name);
  if (branch) 
   {  
-    if(GetDebug()) Info("MakeBranch","Branch %s is already in tree.",name);
+    AliDebug(2,Form("Branch %s is already in tree.",name));
     return branch;
   }
     
@@ -191,9 +187,9 @@ TBranch* AliDetector::MakeBranchInTree(TTree *tree, const char* name,
   } 
  else 
   {
-    branch = tree->Branch(name,address,size);
+    branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
   }
if(GetDebug()) Info("MakeBranch","Branch %s returning branch %#x",name,branch);
AliDebug(2,Form("Branch %s returning branch %#x",name,branch));
  return branch;
 }
 
@@ -222,7 +218,7 @@ void AliDetector::Copy(TObject &) const
   //
   // Copy *this onto det -- not implemented
   //
-  Fatal("Copy","Not implemented\n");
+  AliFatal("Not implemented");
 }
 
 //_______________________________________________________________________
@@ -248,9 +244,9 @@ AliHit* AliDetector::FirstHit(Int_t track)
     TreeH()->GetEvent(track); //skowron
   }
   //
-  sMaxIterHit=fHits->GetEntriesFast();
-  sCurIterHit=0;
-  if(sMaxIterHit) return dynamic_cast<AliHit*>(fHits->UncheckedAt(0));
+  fMaxIterHit=fHits->GetEntriesFast();
+  fCurIterHit=0;
+  if(fMaxIterHit) return dynamic_cast<AliHit*>(fHits->UncheckedAt(0));
   else            return 0;
 }
 
@@ -260,13 +256,13 @@ AliHit* AliDetector::NextHit()
   //
   // Return the next hit for the current track
   //
-  if(sMaxIterHit) {
-    if(++sCurIterHit<sMaxIterHit) 
-      return dynamic_cast<AliHit*>(fHits->UncheckedAt(sCurIterHit));
+  if(fMaxIterHit) {
+    if(++fCurIterHit<fMaxIterHit) 
+      return dynamic_cast<AliHit*>(fHits->UncheckedAt(fCurIterHit));
     else        
       return 0;
   } else {
-    printf("* AliDetector::NextHit * Hit Iterator called without calling FistHit before\n");
+    AliWarning("Hit Iterator called without calling FistHit before");
     return 0;
   }
 }
@@ -279,7 +275,7 @@ void AliDetector::LoadPoints(Int_t)
   //
   if (fHits == 0) 
    {
-    Error("LoadPoints","fHits == 0. Name is %s",GetName());
+    AliError(Form("fHits == 0. Name is %s",GetName()));
     return;
    }
   //
@@ -311,7 +307,10 @@ void AliDetector::LoadPoints(Int_t)
   for (Int_t hit=0;hit<nhits;hit++) {
     ahit = dynamic_cast<AliHit*>(fHits->UncheckedAt(hit));
     trk=ahit->GetTrack();
-    assert(trk<=tracks);
+    if(trk>tracks) {
+      AliError(Form("Found track number %d, max track %d",trk, tracks));
+      continue;
+    }
     if(ntrk[trk]==limi[trk])
      {
       //
@@ -360,7 +359,7 @@ void AliDetector::MakeBranch(Option_t *option)
   // Create a new branch for this detector in its treeH
   //
 
-  if(GetDebug()) Info("MakeBranch"," for %s",GetName());
+  AliDebug(2,Form(" for %s",GetName()));
   const char *cH = strstr(option,"H");
 
   if (fHits && TreeH() && cH) 
@@ -417,12 +416,12 @@ void AliDetector::SetTreeAddress()
     branch = tree->GetBranch(GetName());
     if (branch) 
      {
-       if(GetDebug()) Info("SetTreeAddress","(%s) Setting for Hits",GetName());
+       AliDebug(2,Form("(%s) Setting for Hits",GetName()));
        branch->SetAddress(&fHits);
      }
     else
      { //can be invoked before branch creation
-       if(GetDebug()) Warning("SetTreeAddress","(%s) Failed for Hits. Can not find branch in tree.",GetName());
+       AliDebug(2,Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
      }
   }
   
@@ -449,7 +448,7 @@ void AliDetector::MakeTree(Option_t *option)
     AliLoader* loader = GetLoader();
     if (loader == 0x0)
      {
-       Error("MakeTree","Can not get loader for %s",GetName());
+       AliError(Form("Can not get loader for %s",GetName()));
        return;
      }
     loader->MakeTree(option); //delegate this job to getter
@@ -461,23 +460,21 @@ AliLoader* AliDetector::MakeLoader(const char* topfoldername)
 //builds standard getter (AliLoader type)
 //if detector wants to use castomized getter, it must overload this method
 
- if (GetDebug())
-   Info("MakeLoader",
-        "Creating standard getter for detector %s. Top folder is %s.",
-         GetName(),topfoldername);
+ AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
+         GetName(),topfoldername));
      
  fLoader = new AliLoader(GetName(),topfoldername);
  return fLoader;
 }
 
 //_______________________________________________________________________
-TTree* AliDetector::TreeH()
+TTree* AliDetector::TreeH() const
 {
 //Get the hits container from the folder
   if (GetLoader() == 0x0) 
     {
     //sunstitude this with make getter when we can obtain the event folder name 
-     Error("TreeH","Can not get the getter");
+     AliError("Can not get the getter");
      return 0x0;
     }