]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliModule.cxx
Cell numbering fixed for V0A
[u/mrichter/AliRoot.git] / STEER / AliModule.cxx
index 80c255dd9fae4c39656c7cfcb663a33089de4d9e..bde9763d65b4df2cbdb1629760b5a669655a81c6 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),
@@ -135,7 +136,6 @@ AliModule::AliModule(const AliModule &mod):
   fActive(0),
   fHistograms(0),
   fNodes(0),
-  fDebug(0),
   fEnable(0),
   fTrackReferences(0),
   fMaxIterTrackRef(0),
@@ -246,9 +246,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();
@@ -258,7 +260,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,
@@ -283,6 +285,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,
@@ -309,9 +312,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();
@@ -321,7 +326,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,
@@ -351,27 +356,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,
@@ -695,13 +695,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);  
       }      
@@ -803,16 +804,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);
 }
 
 
@@ -867,17 +868,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);
@@ -890,7 +881,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;
 
@@ -906,11 +897,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;
-}