]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliModule.cxx
Initialization of some data members (Alberto)
[u/mrichter/AliRoot.git] / STEER / AliModule.cxx
index 88f641f7bd5ee30e32890fb11e4731c9911ec9c8..bde9763d65b4df2cbdb1629760b5a669655a81c6 100644 (file)
@@ -40,6 +40,8 @@
 #include <TSystem.h>
 #include <TDirectory.h>
 #include <TVirtualMC.h>
+#include <TGeoManager.h>
+#include <TString.h>
 
 #include "AliLog.h"
 #include "AliConfig.h"
@@ -49,7 +51,9 @@
 #include "AliRun.h"
 #include "AliTrackReference.h"
 #include "AliMC.h"
-#include "../RAW/AliRawDataHeader.h"
+#include "AliRawDataHeader.h"
+
+#include "AliDAQ.h"
 
 ClassImp(AliModule)
  
@@ -242,8 +246,19 @@ void AliModule::AliMaterial(Int_t imat, const char* name, Float_t a,
   // nwbuf       number of user words
   //
   Int_t kmat;
-  gMC->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
-  (*fIdmate)[imat]=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();
+    (*fIdmate)[imat]=kmat;
+  }else{
+    gMC->Material(kmat, uniquename.Data(), a, z, dens, radl, absl, buf, nwbuf);
+    (*fIdmate)[imat]=kmat;
+  }
 }
   
 //_______________________________________________________________________
@@ -297,8 +312,19 @@ void AliModule::AliMixture(Int_t imat, const char *name, Float_t *a,
   // wmat        array of concentrations
   //
   Int_t kmat;
-  gMC->Mixture(kmat, name, a, z, dens, nlmat, wmat);
-  (*fIdmate)[imat]=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();
+    (*fIdmate)[imat]=kmat;
+  }else{
+    gMC->Mixture(kmat, uniquename.Data(), a, z, dens, nlmat, wmat);
+    (*fIdmate)[imat]=kmat;
+  }
 } 
  
 //_______________________________________________________________________
@@ -330,9 +356,20 @@ void AliModule::AliMedium(Int_t numed, const char *name, Int_t nmat,
   //        =  3       constant magnetic field along z
   //  
   Int_t kmed;
-  gMC->Medium(kmed,name, (*fIdmate)[nmat], isvol, ifield, fieldm,
-                        tmaxfd, stemax, deemax, epsil, stmin, ubuf, nbuf); 
-  (*fIdtmed)[numed]=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()){
+    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);
+    (*fIdtmed)[numed]=kmed;
+  }
 } 
  
 //_______________________________________________________________________
@@ -658,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);  
       }      
@@ -766,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);
 }
 
 
@@ -830,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);
@@ -853,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;