]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliModule.cxx
fixed missing return value check (resulting in crash when TreeK is not readable)
[u/mrichter/AliRoot.git] / STEER / AliModule.cxx
index 61fa6ae2e770c8b9e3bd95335f42a22c2e397ce7..a1a92d2fe797795d2241f299e0468c14ff416df0 100644 (file)
@@ -41,6 +41,7 @@
 #include <TDirectory.h>
 #include <TVirtualMC.h>
 #include <TGeoManager.h>
+#include <TString.h>
 
 #include "AliLog.h"
 #include "AliConfig.h"
@@ -50,7 +51,9 @@
 #include "AliRun.h"
 #include "AliTrackReference.h"
 #include "AliMC.h"
-#include "../RAW/AliRawDataHeader.h"
+#include "AliRawDataHeader.h"
+
+#include "AliDAQ.h"
 
 ClassImp(AliModule)
  
@@ -65,7 +68,6 @@ AliModule::AliModule():
   fActive(0),
   fHistograms(0),
   fNodes(0),
-  fDebug(0),
   fEnable(1),
   fTrackReferences(0),
   fMaxIterTrackRef(0),
@@ -89,7 +91,6 @@ AliModule::AliModule(const char* name,const char *title):
   fActive(0),
   fHistograms(new TList()),
   fNodes(new TList()),
-  fDebug(0),
   fEnable(1),
   fTrackReferences(new TClonesArray("AliTrackReference", 100)),
   fMaxIterTrackRef(0),
@@ -113,41 +114,13 @@ AliModule::AliModule(const char* name,const char *title):
 
   gAlice->AddModule(this);
 
-  SetMarkerColor(3);
+  //PH  SetMarkerColor(3);
   //
   // Clear space for tracking media and material indexes
 
   for(Int_t i=0;i<100;i++) (*fIdmate)[i]=(*fIdtmed)[i]=0;
 }
  
-//_______________________________________________________________________
-AliModule::AliModule(const AliModule &mod):
-  TNamed(mod),
-  TAttLine(mod),
-  TAttMarker(mod),
-  AliRndm(mod),
-  fEuclidMaterial(""),
-  fEuclidGeometry(""),
-  fIdtmed(0),
-  fIdmate(0),
-  fLoMedium(0),
-  fHiMedium(0),
-  fActive(0),
-  fHistograms(0),
-  fNodes(0),
-  fDebug(0),
-  fEnable(0),
-  fTrackReferences(0),
-  fMaxIterTrackRef(0),
-  fCurrentIterTrackRef(0),
-  fRunLoader(0)
-{
-  //
-  // Copy constructor
-  //
-  mod.Copy(*this);
-}
-
 //_______________________________________________________________________
 AliModule::~AliModule()
 {
@@ -184,15 +157,6 @@ AliModule::~AliModule()
 
 }
  
-//_______________________________________________________________________
-void AliModule::Copy(TObject & /* mod */) const
-{
-  //
-  // Copy *this onto mod, not implemented for AliModule
-  //
-  AliFatal("Not implemented!");
-}
-
 //_______________________________________________________________________
 void AliModule::Disable()
 {
@@ -246,8 +210,11 @@ void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a,
   // nwbuf       number of user words
   //
   Int_t kmat;
+  //Build the string uniquename as "DET_materialname"
   TString uniquename = GetName();
+  uniquename.Append("_");
   uniquename.Append(name);
+  //if geometry loaded from file only fill fIdmate, else create material too
   if(gAlice->IsRootGeometry()){
     TGeoMaterial *mat = gGeoManager->GetMaterial(uniquename.Data());
     kmat = mat->GetUniqueID();
@@ -257,7 +224,7 @@ void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a,
     (*fIdmate)[imat]=kmat;
   }
 }
-
+  
 //_______________________________________________________________________
 void AliModule::AliGetMaterial(Int_t imat, char* name, Float_t &a, 
                                Float_t &z, Float_t &dens, Float_t &radl,
@@ -282,6 +249,7 @@ void AliModule::AliGetMaterial(Int_t imat, char* name, Float_t &a,
   kmat=(*fIdmate)[imat];
   gMC->Gfmate(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
 }
+  
 
 //_______________________________________________________________________
 void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a,
@@ -308,8 +276,11 @@ void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a,
   // wmat        array of concentrations
   //
   Int_t kmat;
+  //Build the string uniquename as "DET_mixturename"
   TString uniquename = GetName();
+  uniquename.Append("_");
   uniquename.Append(name);
+  //if geometry loaded from file only fill fIdmate, else create mixture too
   if(gAlice->IsRootGeometry()){
     TGeoMaterial *mat = gGeoManager->GetMaterial(uniquename.Data());
     kmat = mat->GetUniqueID();
@@ -319,7 +290,7 @@ void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a,
     (*fIdmate)[imat]=kmat;
   }
 } 
-
 //_______________________________________________________________________
 void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat,
                           Int_t isvol, Int_t ifield, Float_t fieldm,
@@ -349,26 +320,22 @@ void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat,
   //        =  3       constant magnetic field along z
   //  
   Int_t kmed;
+  //Build the string uniquename as "DET_mediumname"
   TString uniquename = GetName();
+  uniquename.Append("_");
   uniquename.Append(name);
+  //if geometry loaded from file only fill fIdtmed, else create medium too
   if(gAlice->IsRootGeometry()){
-    TList *medialist = gGeoManager->GetListOfMedia();
-    TIter next(medialist);
-    TGeoMedium *med = 0;
-    while((med = (TGeoMedium*) next())){
-      if(!strcmp(uniquename.Data(),med->GetName())){
-       kmed = med->GetId();
-       (*fIdtmed)[numed]=kmed;
-       break;
-      }
-    }
+    TGeoMedium *med = gGeoManager->GetMedium(uniquename.Data());
+    kmed = med->GetId();
+    (*fIdtmed)[numed]=kmed;
   }else{
     gMC->Medium(kmed, uniquename.Data(), (*fIdmate)[nmat], isvol, ifield,
-                fieldm, tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); 
+                fieldm, tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf);
     (*fIdtmed)[numed]=kmed;
   }
 } 
-
 //_______________________________________________________________________
 void AliModule::AliMatrix(Int_t &nmat, Float_t theta1, Float_t phi1,
                           Float_t theta2, Float_t phi2, Float_t theta3,
@@ -684,6 +651,14 @@ void AliModule::ReadEuclidMedia(const char* filnam)
   AliWarning("reading error or premature end of file");
 } 
 
+//_______________________________________________________________________
+void AliModule::AddAlignableVolumes() const
+{
+  // 
+  if (IsActive())
+    AliWarning(Form(" %s still has to implement the AddAlignableVolumes method!",GetName()));
+}
+
 //_______________________________________________________________________
 void AliModule::RemapTrackReferencesIDs(Int_t *map)
 {
@@ -692,13 +667,14 @@ void AliModule::RemapTrackReferencesIDs(Int_t *map)
   // Called at finish primary
   //
   if (!fTrackReferences) return;
-  for (Int_t i=0;i<fTrackReferences->GetEntries();i++){
+  Int_t nEntries = fTrackReferences->GetEntries();
+  
+  for (Int_t i=0;i<nEntries;i++){
     AliTrackReference * ref = dynamic_cast<AliTrackReference*>(fTrackReferences->UncheckedAt(i));
     if (ref) {
       Int_t newID = map[ref->GetTrack()];
       if (newID>=0) ref->SetTrack(newID);
       else {
-        //ref->SetTrack(-1);
         ref->SetBit(kNotDeleted,kFALSE);
         fTrackReferences->RemoveAt(i);  
       }      
@@ -800,16 +776,16 @@ void AliModule::SetTreeAddress()
 }
 
 //_____________________________________________________________________________
-void  AliModule::AddTrackReference(Int_t label){
+AliTrackReference*  AliModule::AddTrackReference(Int_t label){
   //
   // add a trackrefernce to the list
   if (!fTrackReferences) {
     AliError("Container trackrefernce not active");
-    return;
+    return 0;
   }
   Int_t nref = fTrackReferences->GetEntriesFast();
   TClonesArray &lref = *fTrackReferences;
-  new(lref[nref]) AliTrackReference(label);
+  return new(lref[nref]) AliTrackReference(label);
 }
 
 
@@ -864,17 +840,7 @@ void AliModule::Digits2Raw()
 
   AliWarning(Form("Dummy version called for %s", GetName()));
 
-  const Int_t kNDetectors = 17;
-  const char* kDetectors[kNDetectors] = {"TPC", "ITSSPD", "ITSSDD", "ITSSSD", "TRD", "TOF", "PHOS", "RICH", "EMCAL", "MUON", "MUTR", "ZDC", "PMD", "START", "VZERO", "CRT", "FMD"};
-  const Int_t kDetectorDDLs[kNDetectors] = {216, 20, 12, 16, 18, 72, 20, 20, 22, 20, 2, 1, 6, 1, 1, 1, 3};
-  Int_t nDDLs = 1;
-  Int_t ddlOffset = 0;
-  for (Int_t i = 0; i < kNDetectors; i++) {
-    if (strcmp(GetName(), kDetectors[i]) == 0) {
-      nDDLs = kDetectorDDLs[i];
-      ddlOffset = 0x100 * i;
-    }
-  }
+  Int_t nDDLs = AliDAQ::NumberOfDdls(GetName());
 
   if (!GetLoader()) return;
   fstream digitsFile(GetLoader()->GetDigitsFileName(), ios::in);
@@ -887,7 +853,7 @@ void AliModule::Digits2Raw()
 
   for (Int_t iDDL = 0; iDDL < nDDLs; iDDL++) {
     char fileName[20];
-    sprintf(fileName, "%s_%d.ddl", GetName(), iDDL + ddlOffset);
+    strcpy(fileName,AliDAQ::DdlFileName(GetName(),iDDL));
     fstream rawFile(fileName, ios::out);
     if (!rawFile) return;
 
@@ -903,11 +869,3 @@ void AliModule::Digits2Raw()
   digitsFile.close();
   delete[] buffer;
 }
-
-
-//_____________________________________________________________________________
-Int_t AliModule::GetDebug() const
-{
-  AliWarning("Don't use this method any more, use AliDebug instead");
-  return 0;
-}