From 03d1b8863ad83a80bbe7724f41e4c40f06d3ea3a Mon Sep 17 00:00:00 2001
From: Norbert Herrmann <n.herrmann@physi.uni-heidelberg.de>
Date: Sun, 28 Nov 2021 14:16:40 +0100
Subject: [PATCH] provide tof v21a geometry

Apply clang-format. uncomment TofSimpClusterizer constructor
---
 core/detectors/tof/CbmTofDigiBdfPar.cxx       |    4 +-
 core/detectors/tof/CbmTofGeoHandler.cxx       |    9 +-
 macro/beamtime/mcbm2021/ana_trks_eval.C       |    5 +
 macro/beamtime/mcbm2021/eval_tracks.sh        |    4 +-
 macro/beamtime/pl_Eff_TIR.C                   |    2 +-
 macro/beamtime/pl_over_trk.C                  |  464 +++---
 macro/beamtime/pl_pull_trk.C                  |  326 ++--
 macro/run/run_reco.C                          |    2 +-
 macro/tof/geometry/Create_TOF_Geometry_v21a.C | 1092 +++++++++++++
 .../Create_TOF_Geometry_v21a_cosmicHD.C       | 1365 +++++++++++++++++
 .../tof/geometry/ModulePosition_10m_v21a.dat  |  232 +++
 macro/tof/geometry/ModuleType0_v21a.dat       |    6 +
 macro/tof/geometry/ModuleType10_v21a.dat      |   31 +
 macro/tof/geometry/ModuleType11_v21a.dat      |   25 +
 macro/tof/geometry/ModuleType12_v21a.dat      |   28 +
 macro/tof/geometry/ModuleType13_v21a.dat      |   19 +
 macro/tof/geometry/ModuleType14_v21a.dat      |   25 +
 macro/tof/geometry/ModuleType1_v21a.dat       |    6 +
 macro/tof/geometry/ModuleType2_v21a.dat       |    6 +
 macro/tof/geometry/ModuleType3_v21a.dat       |    6 +
 macro/tof/geometry/ModuleType4_v21a.dat       |    6 +
 macro/tof/geometry/ModuleType5_v21a.dat       |   31 +
 macro/tof/geometry/ModuleType6_v21a.dat       |   25 +
 macro/tof/geometry/ModuleType7_v21a.dat       |   28 +
 macro/tof/geometry/ModuleType8_v21a.dat       |   19 +
 macro/tof/geometry/ModuleType9_v21a.dat       |   26 +
 macro/tof/geometry/create_geopar_allsetups.sh |   30 +-
 macro/tof/geometry/create_parameters.sh       |    5 +-
 28 files changed, 3404 insertions(+), 423 deletions(-)
 create mode 100644 macro/tof/geometry/Create_TOF_Geometry_v21a.C
 create mode 100644 macro/tof/geometry/Create_TOF_Geometry_v21a_cosmicHD.C
 create mode 100644 macro/tof/geometry/ModulePosition_10m_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType0_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType10_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType11_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType12_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType13_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType14_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType1_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType2_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType3_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType4_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType5_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType6_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType7_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType8_v21a.dat
 create mode 100644 macro/tof/geometry/ModuleType9_v21a.dat

diff --git a/core/detectors/tof/CbmTofDigiBdfPar.cxx b/core/detectors/tof/CbmTofDigiBdfPar.cxx
index daf6191ef6..5d884a377a 100644
--- a/core/detectors/tof/CbmTofDigiBdfPar.cxx
+++ b/core/detectors/tof/CbmTofDigiBdfPar.cxx
@@ -193,7 +193,7 @@ Bool_t CbmTofDigiBdfPar::getParams(FairParamList* l)
                    << " not found in the text file. "
                    << "This is normal for geometries < 14a but may indicate file "
                       "corruption "
-                   << " for newer geometries. Values are set to default 0.0 cm/ps.";
+                   << " for newer geometries. Values are set to default 0.0 cm/ns.";
       for (Int_t iRpc = 0; iRpc < fiNbRpc[iSmType]; iRpc++)
         fdSigVel[iSmType].SetAt(0.0, iRpc);
       //return kFALSE;
@@ -728,7 +728,7 @@ void CbmTofDigiBdfPar::printParams()
     sRpcNb += Form("%3d ", GetNbRpc(iSmType));
     sGapsNb[iSmType]     = Form("  Nb of Gaps in SM type    %3d:|->  ", iSmType);
     sGapsSz[iSmType]     = Form("  Gap Size(mm) in SM type  %3d:|-> ", iSmType);
-    sSigVel[iSmType]     = Form("  SigVel(cm/ps) in SM type %3d:|-> ", iSmType);
+    sSigVel[iSmType]     = Form("  SigVel(cm/ns) in SM type %3d:|-> ", iSmType);
     sChNb[iSmType]       = Form("  Nb of Chan in SM type    %3d:|->  ", iSmType);
     sChType[iSmType]     = Form("  Chan Type in SM type     %3d:|->  ", iSmType);
     sChOrient[iSmType]   = Form("  Chan Orientation in SM type  %3d:|->  ", iSmType);
diff --git a/core/detectors/tof/CbmTofGeoHandler.cxx b/core/detectors/tof/CbmTofGeoHandler.cxx
index 3719cf301f..42fb871eae 100644
--- a/core/detectors/tof/CbmTofGeoHandler.cxx
+++ b/core/detectors/tof/CbmTofGeoHandler.cxx
@@ -211,7 +211,9 @@ Int_t CbmTofGeoHandler::GetUniqueDetectorId()
     else {
       Volname = CurrentVolOffName(4);
     }
-    smtype = Volname[7] - '0';
+    //smtype = Volname[7] - '0';
+    TString csmtype = Volname(7, Volname.Length());
+    smtype          = csmtype.Atoi();
     CurrentVolOffID(4, smodule);
     CurrentVolOffID(2, counter);
     CurrentVolOffID(1, gap);
@@ -222,6 +224,7 @@ Int_t CbmTofGeoHandler::GetUniqueDetectorId()
     cell--;
   }
 
+  LOG(debug1) << "GetUniqueDetectorId: ";
   LOG(debug1) << " Volname: " << Volname << ", " << CurrentVolOffName(3) << ", " << CurrentVolOffName(2) << ", "
               << CurrentVolOffName(1) << ", " << CurrentVolOffName(0);
 
@@ -279,7 +282,9 @@ Int_t CbmTofGeoHandler::GetUniqueCounterId()
     else {
       Volname = CurrentVolOffName(4);
     }
-    smtype = Volname[7] - '0';
+    //smtype = Volname[7] - '0';
+    TString csmtype = Volname(7, Volname.Length());
+    smtype          = csmtype.Atoi();
     CurrentVolOffID(4, smodule);
     CurrentVolOffID(2, counter);
     CurrentVolOffID(1, gap);
diff --git a/macro/beamtime/mcbm2021/ana_trks_eval.C b/macro/beamtime/mcbm2021/ana_trks_eval.C
index b0697a2339..b8e78e2089 100644
--- a/macro/beamtime/mcbm2021/ana_trks_eval.C
+++ b/macro/beamtime/mcbm2021/ana_trks_eval.C
@@ -600,6 +600,11 @@ void ana_trks_eval(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TSt
                       tofAnaTestbeam->SetTShift(6.5);    // Shift DTD4 to 0
                       tofAnaTestbeam->SetSel2TOff(0.6);  // Shift Sel2 time peak to 0
                       break;
+                    case 1051:
+                    case 1058:
+                      tofAnaTestbeam->SetTShift(-3.);   // Shift DTD4 to 0
+                      tofAnaTestbeam->SetSel2TOff(0.);  // Shift Sel2 time peak to 0
+                      break;
                     case 717:
                     default:  // 714
                       //tofAnaTestbeam->SetSel2TOff(-1.3);  // Shift Sel2 time peak to 0
diff --git a/macro/beamtime/mcbm2021/eval_tracks.sh b/macro/beamtime/mcbm2021/eval_tracks.sh
index 548dbd217b..36e40e3660 100755
--- a/macro/beamtime/mcbm2021/eval_tracks.sh
+++ b/macro/beamtime/mcbm2021/eval_tracks.sh
@@ -53,7 +53,7 @@ if [[ ${cCalRef} = "" ]]; then
 fi
 
 dDTres=10000000
-nEvt=1000000
+nEvt=2000000
 
 cSel2=$iSel2;
 if [[ $iSel2 < 100 ]]; then
@@ -84,7 +84,9 @@ fRange2=2.5
 
 #frange1 limits DT spectrum range 
 fRange1=0.9
+#dDeadtime=00
 dDeadtime=50
+
 #./gen_digi.sh 600.100.5.0 30040500 500 50    600.100.5.0  30040500
 #./gen_digi.sh $cRun $iCalSet $iSel2 $Deadtime $CalIdMode CalIdSet
 
diff --git a/macro/beamtime/pl_Eff_TIR.C b/macro/beamtime/pl_Eff_TIR.C
index eaf52528a2..ef2410a25f 100644
--- a/macro/beamtime/pl_Eff_TIR.C
+++ b/macro/beamtime/pl_Eff_TIR.C
@@ -8,7 +8,7 @@ void pl_Eff_TIR(Int_t iDut = 900, Double_t dEffMin = 0., Double_t dEffMax = 1.,
   gROOT->LoadMacro("pl_Datime.C");
   //  TCanvas *can = new TCanvas("can22","can22");
   //  can->Divide(2,2);
-  TCanvas* can = new TCanvas("can", "can", 48, 55, 450, 600);
+  TCanvas* can = new TCanvas("can", "can", 48, 55, 700, 600);
   can->Divide(1, 3);
 
   gPad->SetFillColor(0);
diff --git a/macro/beamtime/pl_over_trk.C b/macro/beamtime/pl_over_trk.C
index 2acd4c2416..d94e4afb55 100644
--- a/macro/beamtime/pl_over_trk.C
+++ b/macro/beamtime/pl_over_trk.C
@@ -2,219 +2,217 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Norbert Herrmann [committer] */
 
-void pl_over_trk(Int_t NSt = 4)
-{
-  //  TCanvas *can = new TCanvas("can22","can22");
-  //  can->Divide(2,2);
-  TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800);
-  can->Divide(4, 4);
+//  TCanvas *can = new TCanvas("can22","can22");
+//  can->Divide(2,2);
+TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800);
+can->Divide(4, 4);
 
-  gPad->SetFillColor(0);
-  gStyle->SetPalette(1);
-  gStyle->SetOptStat(kTRUE);
+gPad->SetFillColor(0);
+gStyle->SetPalette(1);
+gStyle->SetOptStat(kTRUE);
 
-  gROOT->cd();
-  gROOT->SetDirLevel(1);
+gROOT->cd();
+gROOT->SetDirLevel(1);
 
-  TH1* h;
-  TH1* h1;
-  TH2* h2;
-  TH1* hAll;
-  // if (h!=NULL) h->Delete();
-  TString hname = "";
-  Int_t iCol    = 1;
+TH1* h;
+TH1* h1;
+TH2* h2;
+TH1* hAll;
+// if (h!=NULL) h->Delete();
+TString hname = "";
+Int_t iCol    = 1;
 
-  can->cd(1);
-  gROOT->cd();
-  hname = Form("hTrklMulNhits");
-  h2    = (TH2*) gROOT->FindObjectAny(hname);
-  if (h2 != NULL) {
-    h2->Draw("colz");
-    gPad->SetLogz();
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
+can->cd(1);
+gROOT->cd();
+hname = Form("hTrklMulNhits");
+h2    = (TH2*) gROOT->FindObjectAny(hname);
+if (h2 != NULL) {
+  h2->Draw("colz");
+  gPad->SetLogz();
+}
+else {
+  cout << hname << " not found" << endl;
+}
 
-  can->cd(2);
-  gROOT->cd();
-  hname = Form("hTrklHMul");
-  h2    = (TH2*) gROOT->FindObjectAny(hname);
-  if (h2 != NULL) {
-    h2->Draw("colz");
-    gPad->SetLogz();
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
+can->cd(2);
+gROOT->cd();
+hname = Form("hTrklHMul");
+h2    = (TH2*) gROOT->FindObjectAny(hname);
+if (h2 != NULL) {
+  h2->Draw("colz");
+  gPad->SetLogz();
+}
+else {
+  cout << hname << " not found" << endl;
+}
 
-  can->cd(3);
-  gROOT->cd();
-  hname = Form("hTrklChi2");
-  h2    = (TH2*) gROOT->FindObjectAny(hname);
-  if (h2 != NULL) {
-    h2->Draw("colz");
-    gPad->SetLogz();
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
+can->cd(3);
+gROOT->cd();
+hname = Form("hTrklChi2");
+h2    = (TH2*) gROOT->FindObjectAny(hname);
+if (h2 != NULL) {
+  h2->Draw("colz");
+  gPad->SetLogz();
+}
+else {
+  cout << hname << " not found" << endl;
+}
 
-  can->cd(4);
-  gROOT->cd();
-  hname = Form("hTrklMulMaxMax-1");
-  h2    = (TH2*) gROOT->FindObjectAny(hname);
-  if (h2 != NULL) {
-    h2->Draw("colz");
-    gPad->SetLogz();
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
+can->cd(4);
+gROOT->cd();
+hname = Form("hTrklMulMaxMax-1");
+h2    = (TH2*) gROOT->FindObjectAny(hname);
+if (h2 != NULL) {
+  h2->Draw("colz");
+  gPad->SetLogz();
+}
+else {
+  cout << hname << " not found" << endl;
+}
 
-  can->cd(5);
-  gROOT->cd();
-  iCol = 1;
-  for (Int_t iSt = 0; iSt < NSt; iSt++) {
-    hname = Form("hPullX_Station_%d", iSt);
-    h1    = (TH1*) gROOT->FindObjectAny(hname);
-    if (h1 != NULL) {
-      if (iSt == 0) {
-        h1->Draw("");
-        h1->SetMinimum(0.5);
-        gPad->SetLogy();
-      }
-      else {
-        h1->Draw("same");
-      }
-      if (iCol == 5 || iCol == 10) iCol++;
-      h1->SetLineColor(iCol++);
+can->cd(5);
+gROOT->cd();
+iCol = 1;
+for (Int_t iSt = 0; iSt < NSt; iSt++) {
+  hname = Form("hPullX_Station_%d", iSt);
+  h1    = (TH1*) gROOT->FindObjectAny(hname);
+  if (h1 != NULL) {
+    if (iSt == 0) {
+      h1->Draw("");
+      h1->SetMinimum(0.5);
+      gPad->SetLogy();
     }
     else {
-      cout << hname << " not found" << endl;
+      h1->Draw("same");
     }
+    if (iCol == 5 || iCol == 10) iCol++;
+    h1->SetLineColor(iCol++);
   }
-
-  can->cd(6);
-  gROOT->cd();
-  iCol = 1;
-  for (Int_t iSt = 0; iSt < NSt; iSt++) {
-    hname = Form("hPullY_Station_%d", iSt);
-    h1    = (TH1*) gROOT->FindObjectAny(hname);
-    if (h1 != NULL) {
-      if (iSt == 0) {
-        h1->Draw("");
-        h1->SetMinimum(0.5);
-        gPad->SetLogy();
-      }
-      else {
-        h1->Draw("same");
-      }
-      if (iCol == 5 || iCol == 10) iCol++;
-      h1->SetLineColor(iCol++);
-    }
-    else {
-      cout << hname << " not found" << endl;
-    }
+  else {
+    cout << hname << " not found" << endl;
   }
+}
 
-  can->cd(7);
-  gROOT->cd();
-  iCol = 1;
-  for (Int_t iSt = 0; iSt < NSt; iSt++) {
-    hname = Form("hPullZ_Station_%d", iSt);
-    h1    = (TH1*) gROOT->FindObjectAny(hname);
-    if (h1 != NULL) {
-      if (iSt == 0) {
-        h1->Draw("");
-        h1->SetMinimum(0.5);
-        gPad->SetLogy();
-      }
-      else {
-        h1->Draw("same");
-      }
-      if (iCol == 5 || iCol == 10) iCol++;
-      h1->SetLineColor(iCol++);
+can->cd(6);
+gROOT->cd();
+iCol = 1;
+for (Int_t iSt = 0; iSt < NSt; iSt++) {
+  hname = Form("hPullY_Station_%d", iSt);
+  h1    = (TH1*) gROOT->FindObjectAny(hname);
+  if (h1 != NULL) {
+    if (iSt == 0) {
+      h1->Draw("");
+      h1->SetMinimum(0.5);
+      gPad->SetLogy();
     }
     else {
-      cout << hname << " not found" << endl;
+      h1->Draw("same");
     }
+    if (iCol == 5 || iCol == 10) iCol++;
+    h1->SetLineColor(iCol++);
   }
+  else {
+    cout << hname << " not found" << endl;
+  }
+}
 
-  can->cd(8);
-  gROOT->cd();
-  iCol = 1;
-  for (Int_t iSt = 0; iSt < NSt; iSt++) {
-    hname = Form("hPullT_Station_%d", iSt);
-    h1    = (TH1*) gROOT->FindObjectAny(hname);
-    if (h1 != NULL) {
-      if (iSt == 0) {
-        h1->Draw("");
-        h1->SetMinimum(0.5);
-        gPad->SetLogy();
-      }
-      else {
-        h1->Draw("same");
-      }
-      if (iCol == 5 || iCol == 10) iCol++;
-      h1->SetLineColor(iCol++);
+can->cd(7);
+gROOT->cd();
+iCol = 1;
+for (Int_t iSt = 0; iSt < NSt; iSt++) {
+  hname = Form("hPullZ_Station_%d", iSt);
+  h1    = (TH1*) gROOT->FindObjectAny(hname);
+  if (h1 != NULL) {
+    if (iSt == 0) {
+      h1->Draw("");
+      h1->SetMinimum(0.5);
+      gPad->SetLogy();
     }
     else {
-      cout << hname << " not found" << endl;
+      h1->Draw("same");
     }
-  }
-
-  can->cd(9);
-  gROOT->cd();
-  hname = Form("hTrklXY0_0");
-  h2    = (TH2*) gROOT->FindObjectAny(hname);
-  if (h2 != NULL) {
-    h2->Draw("colz");
-    gPad->SetLogz();
+    if (iCol == 5 || iCol == 10) iCol++;
+    h1->SetLineColor(iCol++);
   }
   else {
     cout << hname << " not found" << endl;
   }
+}
 
-  can->cd(10);
-  gROOT->cd();
-  hname = Form("hTrklXY0_1");
-  h2    = (TH2*) gROOT->FindObjectAny(hname);
-  if (h2 != NULL) {
-    h2->Draw("colz");
-    gPad->SetLogz();
+can->cd(8);
+gROOT->cd();
+iCol = 1;
+for (Int_t iSt = 0; iSt < NSt; iSt++) {
+  hname = Form("hPullT_Station_%d", iSt);
+  h1    = (TH1*) gROOT->FindObjectAny(hname);
+  if (h1 != NULL) {
+    if (iSt == 0) {
+      h1->Draw("");
+      h1->SetMinimum(0.5);
+      gPad->SetLogy();
+    }
+    else {
+      h1->Draw("same");
+    }
+    if (iCol == 5 || iCol == 10) iCol++;
+    h1->SetLineColor(iCol++);
   }
   else {
     cout << hname << " not found" << endl;
   }
+}
 
-  can->cd(11);
-  gROOT->cd();
-  hname = Form("hTrklTxHMul");
-  h2    = (TH2*) gROOT->FindObjectAny(hname);
-  if (h2 != NULL) {
-    h2->Draw("colz");
-    gPad->SetLogz();
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
+can->cd(9);
+gROOT->cd();
+hname = Form("hTrklXY0_0");
+h2    = (TH2*) gROOT->FindObjectAny(hname);
+if (h2 != NULL) {
+  h2->Draw("colz");
+  gPad->SetLogz();
+}
+else {
+  cout << hname << " not found" << endl;
+}
 
-  can->cd(12);
-  gROOT->cd();
-  hname = Form("hTrklTyHMul");
-  h2    = (TH2*) gROOT->FindObjectAny(hname);
-  if (h2 != NULL) {
-    h2->Draw("colz");
-    gPad->SetLogz();
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
+can->cd(10);
+gROOT->cd();
+hname = Form("hTrklXY0_1");
+h2    = (TH2*) gROOT->FindObjectAny(hname);
+if (h2 != NULL) {
+  h2->Draw("colz");
+  gPad->SetLogz();
+}
+else {
+  cout << hname << " not found" << endl;
+}
+
+can->cd(11);
+gROOT->cd();
+hname = Form("hTrklTxHMul");
+h2    = (TH2*) gROOT->FindObjectAny(hname);
+if (h2 != NULL) {
+  h2->Draw("colz");
+  gPad->SetLogz();
+}
+else {
+  cout << hname << " not found" << endl;
+}
 
-  can->cd(13);
-  gROOT->cd();
-  /*************
+can->cd(12);
+gROOT->cd();
+hname = Form("hTrklTyHMul");
+h2    = (TH2*) gROOT->FindObjectAny(hname);
+if (h2 != NULL) {
+  h2->Draw("colz");
+  gPad->SetLogz();
+}
+else {
+  cout << hname << " not found" << endl;
+}
+
+can->cd(13);
+gROOT->cd();
+/*************
   hname = Form("hTrklTtHMul");
   h2    = (TH2*) gROOT->FindObjectAny(hname);
   if (h2 != NULL) {
@@ -224,63 +222,63 @@ void pl_over_trk(Int_t NSt = 4)
     cout << hname << " not found" << endl;
   }
   */
-  hname = Form("hCalDX0");
-  h1    = (TH1*) gROOT->FindObjectAny(hname);
-  if (h1 != NULL) {
-    hname    = Form("hCalDY0");
-    TH1* h1y = (TH1*) gROOT->FindObjectAny(hname);
+hname = Form("hCalDX0");
+h1    = (TH1*) gROOT->FindObjectAny(hname);
+if (h1 != NULL) {
+  hname    = Form("hCalDY0");
+  TH1* h1y = (TH1*) gROOT->FindObjectAny(hname);
 
-    Double_t dYmax = TMath::Max(h1->GetMaximum(), h1y->GetMaximum());
-    dYmax *= 1.1;
-    h1->SetMaximum(dYmax);
+  Double_t dYmax = TMath::Max(h1->GetMaximum(), h1y->GetMaximum());
+  dYmax *= 1.1;
+  h1->SetMaximum(dYmax);
 
-    h1->Draw("");
-    gPad->SetLogy();
+  h1->Draw("");
+  gPad->SetLogy();
 
-    h1y->SetLineColor(2);
-    h1y->Draw("same");
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
+  h1y->SetLineColor(2);
+  h1y->Draw("same");
+}
+else {
+  cout << hname << " not found" << endl;
+}
 
-  can->cd(14);
-  gROOT->cd();
-  hname = Form("hAllHitsStation");
-  h1    = (TH1*) gROOT->FindObjectAny(hname);
-  if (h1 != NULL) {
-    h1->Draw("");
-    h1->SetMinimum(0.1 * h1->GetMaximum());
-    gPad->SetLogy();
-    hAll = (TH1*) h1->Clone();
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
-  hname = Form("hUsedHitsStation");
-  h1    = (TH1*) gROOT->FindObjectAny(hname);
-  if (h1 != NULL) {
-    h1->Draw("same");
-    h1->SetLineColor(2);
-    TH1* hEff = (TH1*) h1->Clone();
-    hEff->Divide(h1, hAll, 1., 1., "B");
+can->cd(14);
+gROOT->cd();
+hname = Form("hAllHitsStation");
+h1    = (TH1*) gROOT->FindObjectAny(hname);
+if (h1 != NULL) {
+  h1->Draw("");
+  h1->SetMinimum(0.1 * h1->GetMaximum());
+  gPad->SetLogy();
+  hAll = (TH1*) h1->Clone();
+}
+else {
+  cout << hname << " not found" << endl;
+}
+hname = Form("hUsedHitsStation");
+h1    = (TH1*) gROOT->FindObjectAny(hname);
+if (h1 != NULL) {
+  h1->Draw("same");
+  h1->SetLineColor(2);
+  TH1* hEff = (TH1*) h1->Clone();
+  hEff->Divide(h1, hAll, 1., 1., "B");
 
-    can->cd(15);
-    hEff->Draw();
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
-  can->cd(16);
-  gROOT->cd();
-  hname = Form("hTrklVelHMul");
-  h2    = (TH2*) gROOT->FindObjectAny(hname);
-  if (h2 != NULL) {
-    h2->Draw("colz");
-    gPad->SetLogz();
-  }
-  else {
-    cout << hname << " not found" << endl;
-  }
-  can->SaveAs("pl_over_trk.pdf");
+  can->cd(15);
+  hEff->Draw();
+}
+else {
+  cout << hname << " not found" << endl;
+}
+can->cd(16);
+gROOT->cd();
+hname = Form("hTrklVelHMul");
+h2    = (TH2*) gROOT->FindObjectAny(hname);
+if (h2 != NULL) {
+  h2->Draw("colz");
+  gPad->SetLogz();
+}
+else {
+  cout << hname << " not found" << endl;
+}
+can->SaveAs("pl_over_trk.pdf");
 }
diff --git a/macro/beamtime/pl_pull_trk.C b/macro/beamtime/pl_pull_trk.C
index 6f3f4e326f..99ed8836cf 100644
--- a/macro/beamtime/pl_pull_trk.C
+++ b/macro/beamtime/pl_pull_trk.C
@@ -2,185 +2,183 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Norbert Herrmann [committer] */
 
-void pl_pull_trk(Int_t NSt = 8, Int_t iVar = 0, Int_t iFit = 0, Int_t iDrop = -1)
-{
-  //  TCanvas *can = new TCanvas("can22","can22");
-  //  can->Divide(2,2);
-  TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800);
-  switch (NSt) {
-    case 7: can->Divide(3, 4); break;
-    case 6:
-    case 5:
-    case 4: can->Divide(3, 3); break;
-    case 9: can->Divide(3, 4); break;
-    case 18: can->Divide(4, 5); break;
-    default: can->Divide(4, 4); ;
-  }
-  gPad->SetFillColor(0);
-  gStyle->SetPalette(1);
-  gStyle->SetOptStat(kTRUE);
-  gStyle->SetOptFit(kTRUE);
+//  TCanvas *can = new TCanvas("can22","can22");
+//  can->Divide(2,2);
+TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800);
+switch (NSt) {
+  case 7: can->Divide(3, 4); break;
+  case 6:
+  case 5:
+  case 4: can->Divide(3, 3); break;
+  case 9: can->Divide(3, 4); break;
+  case 18: can->Divide(4, 5); break;
+  default: can->Divide(4, 4); ;
+}
+gPad->SetFillColor(0);
+gStyle->SetPalette(1);
+gStyle->SetOptStat(kTRUE);
+gStyle->SetOptFit(kTRUE);
 
-  gROOT->cd();
-  gROOT->SetDirLevel(1);
+gROOT->cd();
+gROOT->SetDirLevel(1);
 
-  TH1* h;
-  TH1* h1;
-  TH2* h2;
+TH1* h;
+TH1* h1;
+TH2* h2;
 
-  const Int_t MSt = 30;
-  Double_t vSt[MSt];
-  Double_t vMean[MSt];
-  Double_t vSig[MSt];
-  Double_t vRes[MSt];
-  Double_t vStErr[MSt];
-  Double_t vMeanErr[MSt];
-  Double_t vSigErr[MSt];
-  Double_t vResErr[MSt];
-  // if (h!=NULL) h->Delete();
-  Int_t iCan   = 1;
-  Int_t iIndSt = 0;
-  TString var;
-  Double_t Nall;
+const Int_t MSt = 30;
+Double_t vSt[MSt];
+Double_t vMean[MSt];
+Double_t vSig[MSt];
+Double_t vRes[MSt];
+Double_t vStErr[MSt];
+Double_t vMeanErr[MSt];
+Double_t vSigErr[MSt];
+Double_t vResErr[MSt];
+// if (h!=NULL) h->Delete();
+Int_t iCan   = 1;
+Int_t iIndSt = 0;
+TString var;
+Double_t Nall;
 
-  switch (iVar) {
-    case 0: var = "X"; break;
-    case 1: var = "Y"; break;
-    case 2: var = "Z"; break;
-    case 3: var = "T"; break;
-    case 4: var = "TB"; break;
-  }
-  for (Int_t iSt = 0; iSt < NSt; iSt++) {
-    can->cd(iCan++);
-    gROOT->cd();
-    TString hname = Form("hPull%s_Station_%d", var.Data(), iSt);
-    h1            = (TH1*) gROOT->FindObjectAny(hname);
-    if (h1 != NULL) {
-      h1->Draw("");
-      Nall = h1->GetEntries();
-      gPad->SetLogy();
-      gPad->SetGridx();
-      if (iFit > 0) {
-        //Double_t dFMean   = h1->GetMean();
-        Double_t dFMean    = h1->GetBinCenter(h1->GetMaximumBin());
-        Double_t dFLim     = 2.0 * h1->GetRMS();
-        Double_t dBinSize  = h1->GetBinWidth(1);
-        dFLim              = TMath::Max(dFLim, 5. * dBinSize);
-        TFitResultPtr fRes = h1->Fit("gaus", "SQM", "", dFMean - dFLim, dFMean + dFLim);
-        //cout << " fRes = "<< fRes <<endl;
-        if (-1 == fRes) continue;
-        if (iDrop == iSt) {  // drop station from deconvolution
-          continue;
-        }
-        cout << "Add " << iSt << " as station index " << iIndSt << endl;
-        vSt[iIndSt]      = iSt;
-        vMean[iIndSt]    = fRes->Parameter(1);
-        vSig[iIndSt]     = fRes->Parameter(2);
-        vStErr[iIndSt]   = 0.;
-        vMeanErr[iIndSt] = fRes->ParError(1);
-        vSigErr[iIndSt]  = fRes->ParError(2);
-        //vSig[iIndSt]=TMath::Max(20.,vSig[iSt]);
-        iIndSt++;
+switch (iVar) {
+  case 0: var = "X"; break;
+  case 1: var = "Y"; break;
+  case 2: var = "Z"; break;
+  case 3: var = "T"; break;
+  case 4: var = "TB"; break;
+}
+for (Int_t iSt = 0; iSt < NSt; iSt++) {
+  can->cd(iCan++);
+  gROOT->cd();
+  TString hname = Form("hPull%s_Station_%d", var.Data(), iSt);
+  h1            = (TH1*) gROOT->FindObjectAny(hname);
+  if (h1 != NULL) {
+    h1->Draw("");
+    Nall = h1->GetEntries();
+    gPad->SetLogy();
+    gPad->SetGridx();
+    if (iFit > 0) {
+      //Double_t dFMean   = h1->GetMean();
+      Double_t dFMean    = h1->GetBinCenter(h1->GetMaximumBin());
+      Double_t dFLim     = 2.0 * h1->GetRMS();
+      Double_t dBinSize  = h1->GetBinWidth(1);
+      dFLim              = TMath::Max(dFLim, 5. * dBinSize);
+      TFitResultPtr fRes = h1->Fit("gaus", "SQM", "", dFMean - dFLim, dFMean + dFLim);
+      //cout << " fRes = "<< fRes <<endl;
+      if (-1 == fRes) continue;
+      if (iDrop == iSt) {  // drop station from deconvolution
+        continue;
       }
-    }
-    else {
-      cout << hname << " not found" << endl;
+      cout << "Add " << iSt << " as station index " << iIndSt << endl;
+      vSt[iIndSt]      = iSt;
+      vMean[iIndSt]    = fRes->Parameter(1);
+      vSig[iIndSt]     = fRes->Parameter(2);
+      vStErr[iIndSt]   = 0.;
+      vMeanErr[iIndSt] = fRes->ParError(1);
+      vSigErr[iIndSt]  = fRes->ParError(2);
+      //vSig[iIndSt]=TMath::Max(20.,vSig[iSt]);
+      iIndSt++;
     }
   }
-  if (0 == iFit) return;
-  cout << "Process " << iIndSt << " fit values " << endl;
-  can->cd(iCan++);
-  Double_t dLMargin   = 0.35;
-  Double_t dTitOffset = 1.8;
-  gPad->SetLeftMargin(dLMargin);
-  TGraphErrors* grm = new TGraphErrors(iIndSt, vSt, vMean, vStErr, vMeanErr);
-  grm->SetTitle("Mean");
-  grm->GetXaxis()->SetTitle("Station number");
-  switch (iVar) {
-    case 0:
-    case 1:
-    case 2: grm->GetYaxis()->SetTitle("mean deviation (cm)"); break;
-    default: grm->GetYaxis()->SetTitle("mean deviation (ns)");
+  else {
+    cout << hname << " not found" << endl;
   }
-  grm->GetYaxis()->SetTitleOffset(dTitOffset);
-  grm->GetXaxis()->SetLimits(-0.5, NSt - 0.5);
-  grm->SetMarkerStyle(24);
-  grm->Draw("APLE");
+}
+if (0 == iFit) return;
+cout << "Process " << iIndSt << " fit values " << endl;
+can->cd(iCan++);
+Double_t dLMargin   = 0.35;
+Double_t dTitOffset = 1.8;
+gPad->SetLeftMargin(dLMargin);
+TGraphErrors* grm = new TGraphErrors(iIndSt, vSt, vMean, vStErr, vMeanErr);
+grm->SetTitle("Mean");
+grm->GetXaxis()->SetTitle("Station number");
+switch (iVar) {
+  case 0:
+  case 1:
+  case 2: grm->GetYaxis()->SetTitle("mean deviation (cm)"); break;
+  default: grm->GetYaxis()->SetTitle("mean deviation (ns)");
+}
+grm->GetYaxis()->SetTitleOffset(dTitOffset);
+grm->GetXaxis()->SetLimits(-0.5, NSt - 0.5);
+grm->SetMarkerStyle(24);
+grm->Draw("APLE");
 
-  can->cd(iCan++);
-  gPad->SetLeftMargin(dLMargin);
-  TGraphErrors* grs = new TGraphErrors(iIndSt, vSt, vSig, vStErr, vSigErr);
-  grs->SetTitle("Gaussian width");
-  grs->GetXaxis()->SetTitle("Station number");
-  switch (iVar) {
-    case 0:
-    case 1:
-    case 2: grs->GetYaxis()->SetTitle("Gaussian sigma (cm)"); break;
-    default: grs->GetYaxis()->SetTitle("Gaussian sigma (ns)");
-  }
-  grs->GetYaxis()->SetTitleOffset(dTitOffset);
-  grs->GetXaxis()->SetLimits(-0.5, NSt - 0.5);
-  grs->SetMarkerStyle(24);
-  grs->Draw("APLE");
+can->cd(iCan++);
+gPad->SetLeftMargin(dLMargin);
+TGraphErrors* grs = new TGraphErrors(iIndSt, vSt, vSig, vStErr, vSigErr);
+grs->SetTitle("Gaussian width");
+grs->GetXaxis()->SetTitle("Station number");
+switch (iVar) {
+  case 0:
+  case 1:
+  case 2: grs->GetYaxis()->SetTitle("Gaussian sigma (cm)"); break;
+  default: grs->GetYaxis()->SetTitle("Gaussian sigma (ns)");
+}
+grs->GetYaxis()->SetTitleOffset(dTitOffset);
+grs->GetXaxis()->SetLimits(-0.5, NSt - 0.5);
+grs->SetMarkerStyle(24);
+grs->Draw("APLE");
 
-  can->cd(iCan++);
-  gPad->SetLeftMargin(dLMargin);
-  Double_t val = (iIndSt - 1) * (iIndSt - 1);
-  TMatrixD a(iIndSt, iIndSt);
-  for (Int_t i = 0; i < iIndSt; i++)
-    for (Int_t j = 0; j < iIndSt; j++) {
-      if (i == j) { a[i][j] = 1; }
-      else {
-        a[i][j] = 1. / val;
-      }
+can->cd(iCan++);
+gPad->SetLeftMargin(dLMargin);
+Double_t val = (iIndSt - 1) * (iIndSt - 1);
+TMatrixD a(iIndSt, iIndSt);
+for (Int_t i = 0; i < iIndSt; i++)
+  for (Int_t j = 0; j < iIndSt; j++) {
+    if (i == j) { a[i][j] = 1; }
+    else {
+      a[i][j] = 1. / val;
     }
-  a.Draw("colz");
-  a.Print();
+  }
+a.Draw("colz");
+a.Print();
 
-  // can->cd(iCan++);
-  TMatrixD ainv = a;
-  ainv.Invert();
-  ainv.Draw("colz");
-  ainv.Print();
-  TMatrixD aSig(iIndSt, 1);
-  for (Int_t i = 0; i < iIndSt; i++)
-    aSig[i][0] = vSig[i] * vSig[i];
+// can->cd(iCan++);
+TMatrixD ainv = a;
+ainv.Invert();
+ainv.Draw("colz");
+ainv.Print();
+TMatrixD aSig(iIndSt, 1);
+for (Int_t i = 0; i < iIndSt; i++)
+  aSig[i][0] = vSig[i] * vSig[i];
 
-  cout << "Measured gaussian widths: " << endl;
-  aSig.Print();
-  TMatrixD xRes = ainv * aSig;
-  cout << "Resolution of counters: " << endl;
-  xRes.Print();
+cout << "Measured gaussian widths: " << endl;
+aSig.Print();
+TMatrixD xRes = ainv * aSig;
+cout << "Resolution of counters: " << endl;
+xRes.Print();
 
-  //can->cd(iCan++);
-  for (Int_t i = 0; i < iIndSt; i++) {
-    vRes[i]    = TMath::Sqrt(TMath::Abs(xRes[i][0]));
-    vResErr[i] = vSigErr[i];
-  }
-  TGraphErrors* grr = new TGraphErrors(iIndSt, vSt, vRes, vStErr, vResErr);
-  grr->SetTitle("Final resolution");
-  grr->GetXaxis()->SetTitle("Station number");
-  switch (iVar) {
-    case 0:
-    case 1:
-    case 2: grr->GetYaxis()->SetTitle("resolution (cm)"); break;
-    default: grr->GetYaxis()->SetTitle("resolution (ns)");
-  }
-  grr->GetYaxis()->SetTitleOffset(dTitOffset);
-  grr->GetXaxis()->SetLimits(-0.5, NSt - 0.5);
-  //grr->GetXaxis()->SetRangeUser(-0.5,NSt-0.5);
-  grr->SetMarkerStyle(24);
-  grr->Draw("APLE");
+//can->cd(iCan++);
+for (Int_t i = 0; i < iIndSt; i++) {
+  vRes[i]    = TMath::Sqrt(TMath::Abs(xRes[i][0]));
+  vResErr[i] = vSigErr[i];
+}
+TGraphErrors* grr = new TGraphErrors(iIndSt, vSt, vRes, vStErr, vResErr);
+grr->SetTitle("Final resolution");
+grr->GetXaxis()->SetTitle("Station number");
+switch (iVar) {
+  case 0:
+  case 1:
+  case 2: grr->GetYaxis()->SetTitle("resolution (cm)"); break;
+  default: grr->GetYaxis()->SetTitle("resolution (ns)");
+}
+grr->GetYaxis()->SetTitleOffset(dTitOffset);
+grr->GetXaxis()->SetLimits(-0.5, NSt - 0.5);
+//grr->GetXaxis()->SetRangeUser(-0.5,NSt-0.5);
+grr->SetMarkerStyle(24);
+grr->Draw("APLE");
 
-  for (Int_t i = 0; i < iIndSt; i++)
-    cout << Form("GMean %6.3f +/- %6.5f, GSig: %6.3f +/- %6.5f => ResC %d: %6.3f ", vMean[i], vMeanErr[i], vSig[i],
-                 vSigErr[i], i, vRes[i])
-         << endl;
+for (Int_t i = 0; i < iIndSt; i++)
+  cout << Form("GMean %6.3f +/- %6.5f, GSig: %6.3f +/- %6.5f => ResC %d: %6.3f ", vMean[i], vMeanErr[i], vSig[i],
+               vSigErr[i], i, vRes[i])
+       << endl;
 
-  cout << "Res-summary " << iVar << ": Nall, sigs = " << Nall;
-  for (Int_t i = 0; i < iIndSt; i++)
-    cout << Form(", %7.4f", vRes[i]);
-  cout << endl;
+cout << "Res-summary " << iVar << ": Nall, sigs = " << Nall;
+for (Int_t i = 0; i < iIndSt; i++)
+  cout << Form(", %7.4f", vRes[i]);
+cout << endl;
 
-  can->SaveAs(Form("pl_pull_trk_%s%02d.pdf", var.Data(), NSt));
+can->SaveAs(Form("pl_pull_trk_%s%02d.pdf", var.Data(), NSt));
 }
diff --git a/macro/run/run_reco.C b/macro/run/run_reco.C
index fc2d5d1420..7259d550b9 100644
--- a/macro/run/run_reco.C
+++ b/macro/run/run_reco.C
@@ -342,7 +342,7 @@ void run_reco(TString input = "", Int_t nTimeSlices = -1, Int_t firstTimeSlice =
 
   // -----   Local reconstruction in TOF   ----------------------------------
   if (useTof) {
-    CbmTofSimpClusterizer* tofCluster = new CbmTofSimpClusterizer("TofSimpClusterizer", 0);
+    CbmTofSimpClusterizer* tofCluster = new CbmTofSimpClusterizer("TOF Simple Clusterizer", 0);
     tofCluster->SetOutputBranchPersistent("TofHit", kTRUE);
     tofCluster->SetOutputBranchPersistent("TofDigiMatch", kTRUE);
     run->AddTask(tofCluster);
diff --git a/macro/tof/geometry/Create_TOF_Geometry_v21a.C b/macro/tof/geometry/Create_TOF_Geometry_v21a.C
new file mode 100644
index 0000000000..34f78ad729
--- /dev/null
+++ b/macro/tof/geometry/Create_TOF_Geometry_v21a.C
@@ -0,0 +1,1092 @@
+/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Norbert Herrmann [committer] */
+
+///
+/// \file Create_TOF_Geometry_v21a.C
+/// \brief Generates TOF geometry in Root format.
+///
+
+// Changelog
+// 2021-11-15 - ID - update design of  inner wall (current design, 300 counters, 2 MRPC types)
+// 2020-02-23 - ID - implementation of Bucharest wall (current design), possibility to choose between simple, single stack and double stack MRPCs
+// 2017-10-18 - PAL- Fix the overlaps in the support structure => v17c
+// 2016-07-18 - DE - patch double free or corruption with poleshort: same TGeoVolume name was used in pole
+// 2015-11-09 - PAL- Change naming convention to follow the more meaningfull one used in trd: YYv_ss
+//                   with YY = year, v = version (a, b, ...) and ss = setup (1h for SIS100 hadron, ...)
+//                   => Prepare tof_v16a_1h to tof_v16a_3m
+// 2015-11-09 - PAL- Modify to easily prepare tof_v14_0a to tof_v14_0e on model of 13_5a to 13_5e
+// 2014-06-30 - NH - prepare tof_v14_0  geometry - SIS 300 hadron  : TOF_Z_Front =  880 cm //Bucharest
+// 2014-06-27 - NH - prepare tof_v13_6b geometry - SIS 300 hadron  : TOF_Z_Front =  880 cm //external input
+// 2013-10-16 - DE - prepare tof_v13_5a geometry - SIS 100 hadron  : TOF_Z_Front =  450 cm
+// 2013-10-16 - DE - prepare tof_v13_5b geometry - SIS 100 electron: TOF_Z_Front =  600 cm
+// 2013-10-16 - DE - prepare tof_v13_5c geometry - SIS 100 muon    : TOF_Z_Front =  650 cm
+// 2013-10-16 - DE - prepare tof_v13_5d geometry - SIS 300 electron: TOF_Z_Front =  880 cm
+// 2013-10-16 - DE - prepare tof_v13_5e geometry - SIS 300 muon    : TOF_Z_Front = 1020 cm
+// 2013-10-16 - DE - patch pole_alu bug - skip 0 thickness air volume in pole
+// 2013-09-04 - DE - prepare tof_v13_4a geometry - SIS 100 hadron  : TOF_Z_Front =  450 cm
+// 2013-09-04 - DE - prepare tof_v13_4b geometry - SIS 100 electron: TOF_Z_Front =  600 cm
+// 2013-09-04 - DE - prepare tof_v13_4c geometry - SIS 100 muon    : TOF_Z_Front =  650 cm
+// 2013-09-04 - DE - prepare tof_v13_4d geometry - SIS 300 electron: TOF_Z_Front =  880 cm
+// 2013-09-04 - DE - prepare tof_v13_4e geometry - SIS 300 muon    : TOF_Z_Front = 1020 cm
+// 2013-09-04 - DE - dump z-positions to .geo.info file
+// 2013-09-04 - DE - define front z-position of TOF wall (TOF_Z_Front)
+// 2013-09-04 - DE - fix arrangement of glass plates in RPC cells
+
+// in root all sizes are given in cm
+// read positions of modules from dat - file
+
+#include "TFile.h"
+#include "TGeoCompositeShape.h"
+#include "TGeoManager.h"
+#include "TGeoMaterial.h"
+#include "TGeoMatrix.h"
+#include "TGeoMedium.h"
+#include "TGeoPgon.h"
+#include "TGeoVolume.h"
+#include "TList.h"
+#include "TROOT.h"
+#include "TString.h"
+#include "TSystem.h"
+
+#include <iostream>
+#include <sstream>
+
+const Bool_t IncludeSupports = true;  // false;   // true, if support structure is included in geometry
+
+// Name of geometry version and output file
+const TString geoVersion = "tof_v21a_1h";  // SIS 100 hadron, 4.5 m
+//const TString geoVersion = "tof_v21a_1e";   // SIS 100 electron
+//const TString geoVersion = "tof_v21a_1m";   // SIS 100 mon
+const TString FileNameSim  = geoVersion + ".geo.root";
+const TString FileNameGeo  = geoVersion + "_geo.root";
+const TString FileNameInfo = geoVersion + ".geo.info";
+
+const Double_t TOF_Z_Corr = ("tof_v21a_1e" == geoVersion ? 800 :                        // SIS 100 electron
+                               ("tof_v21a_1h" == geoVersion ? 800 :                     // SIS 100 hadron
+                                  ("tof_v21a_1m" == geoVersion ? 859 :                  // SIS 100 muon
+                                     ("tof_v16e_1h" == geoVersion ? 546.485 :           // SIS 100 hadron
+                                        ("tof_v16e_1e" == geoVersion ? 696.485 :        // SIS 100 electron
+                                           ("tof_v16e_1m" == geoVersion ? 776.485 :     // SIS 100 muon
+                                              ("tof_v16e_3e" == geoVersion ? 976.485 :  // SIS 300 electron
+                                                 ("tof_v16e_3m" == geoVersion ? 0 :     // SIS 300 muon
+                                                    600  // Set default to SIS 100 electron
+                                                  ))))))));
+
+
+// TOF_Z_Front corresponds to front cover of outer super module towers
+const Double_t TOF_Z_Front = ("tof_v21a_1m" == geoVersion ? (762 - TOF_Z_Corr) :                    // SIS 100 muon
+                                ("tof_v21a_1e" == geoVersion ? (703 - TOF_Z_Corr) :                 // SIS 100 electron
+                                   ("tof_v21a_1h" == geoVersion ? (703 - TOF_Z_Corr) :              // SIS 100 hadron
+                                      ("tof_v16e_1h" == geoVersion ? (450 - TOF_Z_Corr) :           // SIS 100 hadron
+                                         ("tof_v16e_1e" == geoVersion ? (600 - TOF_Z_Corr) :        // SIS 100 electron
+                                            ("tof_v16e_1m" == geoVersion ? (680 - TOF_Z_Corr) :     // SIS 100 muon
+                                               ("tof_v16e_3e" == geoVersion ? (880 - TOF_Z_Corr) :  // SIS 300 electron
+                                                  ("tof_v16e_3m" == geoVersion ? (1020 - TOF_Z_Corr) :  // SIS 300 muon
+                                                     600  // Set default to SIS 100 electron
+                                                   ))))))));
+
+// Shift of the TOF inner wall relative to default position [cm];
+const Double_t InnerWall_Z_PositionShift = TOF_Z_Front - 475;  // in cm, Inner wall Offset 0 for wall at 6m
+// Shift of the TOF outer wall relative to default position [cm];
+const Double_t Wall_Z_PositionShift = InnerWall_Z_PositionShift - 405;  // in cm, Outer wall Offset -5cm for wall at 10m
+// for 0 m
+/*
+const Double_t  = -600.;  // inner wall placed at 600
+const Double_t       = -998.;  // outer wall placed at 1000
+*/
+// for 6m
+/*
+const Double_t InnerWall_Z_PositionShift = 0.;    // -600.;  // inner wall placed at 600
+const Double_t Wall_Z_PositionShift      = -425.; // -998.;  // outer wall placed at 1000
+*/
+/*
+// for 10 m
+const Double_t InnerWall_Z_PositionShift = 400.;    // -600.;  // inner wall placed at 600
+const Double_t Wall_Z_PositionShift      = -25.; // -998.;  // outer wall placed at 1000
+*/
+
+// Names of the different used materials which are used to build the modules
+// The materials are defined in the global media.geo file
+const TString KeepingVolumeMedium = "air";
+const TString BoxVolumeMedium     = "aluminium";
+const TString PoleVolumeMedium    = "tof_pole_aluminium";
+const TString NoActivGasMedium    = "RPCgas_noact";
+const TString ActivGasMedium      = "RPCgas";
+const TString GlasMedium          = "RPCglass";
+const TString ElectronicsMedium   = "carbon";
+
+const Int_t NumberOfDifferentCounterTypes = 6;
+
+const Float_t PCB_X[NumberOfDifferentCounterTypes] = {32., 32., 32., 30., 30., 30.};
+const Float_t PCB_Y[NumberOfDifferentCounterTypes] = {
+  52., 26.9, 26.9, 20., 10., 6,
+};
+const Float_t PCB_Z[NumberOfDifferentCounterTypes] = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1};
+
+const Float_t Glass_X[NumberOfDifferentCounterTypes] = {32., 32., 32., 30., 30., 30.};
+const Float_t Glass_Y[NumberOfDifferentCounterTypes] = {
+  52., 26.9, 26.9, 20., 10., 6,
+};
+const Float_t Glass_Z[NumberOfDifferentCounterTypes] = {0.028, 0.028, 0.07, 0.07, 0.07, 0.07};
+
+const Float_t GasGap_X[NumberOfDifferentCounterTypes] = {32., 32., 32., 30., 30., 30.};
+const Float_t GasGap_Y[NumberOfDifferentCounterTypes] = {
+  52., 26.9, 26.9, 20., 10., 6,
+};
+const Float_t GasGap_Z[NumberOfDifferentCounterTypes] = {0.023, 0.023, 0.025, 0.02, 0.02, 0.02};
+
+const Int_t NumberOfGaps[NumberOfDifferentCounterTypes]          = {10, 10, 8, 10, 10, 10};
+const Int_t NumberOfReadoutStrips[NumberOfDifferentCounterTypes] = {32, 32, 32, 32, 32, 32};
+
+const Float_t Electronics_X[NumberOfDifferentCounterTypes] = {34.0, 34.0, 34.0, 32.0, 32.0, 32.0};
+const Float_t Electronics_Y[NumberOfDifferentCounterTypes] = {5.0, 5.0, 5.0, 0.5, 0.5, 0.5};
+const Float_t Electronics_Z[NumberOfDifferentCounterTypes] = {0.3, 0.3, 0.3, 0.3, 0.3, 0.3};
+
+const Int_t NofModuleTypes = 15;
+const Int_t MaxNofCounters = 60;
+const Int_t MaxNofModules  = 230;
+
+const Int_t NCounterInModule[NofModuleTypes]     = {5, 5, 5, 5, 5, 30, 24, 27, 18, 24, 30, 24, 27, 18, 24};
+const Int_t NModulesOfModuleType[NofModuleTypes] = {62, 32, 8, 100, 16, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1};
+Int_t iMod[NofModuleTypes]                       = {0};
+//Int_t ActNofModuleTypes    = 2;
+Int_t NModules[NofModuleTypes] = {0};
+
+Float_t xPosCou[NofModuleTypes][MaxNofCounters];
+Float_t yPosCou[NofModuleTypes][MaxNofCounters];
+Float_t zPosCou[NofModuleTypes][MaxNofCounters];
+Int_t CouType[NofModuleTypes][MaxNofCounters];
+
+Float_t xPosMod[MaxNofModules];
+Float_t yPosMod[MaxNofModules];
+Float_t zPosMod[MaxNofModules];
+Int_t ModType[MaxNofModules] = {MaxNofModules * -1};
+//Float_t FlipMod[NofModuleTypes][MaxNofModules];
+
+const Float_t Module_Size_X[NofModuleTypes] = {180.2, 180.2, 180.2, 180.2, 180.2, 210.5, 124.4, 98.3,
+                                               69.3,  124.4, 210.5, 124.4, 98.3,  69.3,  124.4};
+const Float_t Module_Size_Y[NofModuleTypes] = {74.,   49.,   49.,  49.,   49.,   73.8,  130.0, 128.7,
+                                               128.7, 130.0, 73.8, 130.0, 128.7, 128.7, 130.0};
+const Float_t Module_Size_Z[NofModuleTypes] = {11.2, 11.2, 11.2, 11.2, 11.2, 19.6, 19.6, 19.6,
+                                               19.6, 19.6, 19.6, 19.6, 19.6, 19.6, 19.6};
+
+// Placement of the counter inside the module
+const Float_t CounterRotationAngle[NofModuleTypes] = {10., 10., 0., 10., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
+
+const Float_t Module_Thick_Alu_X_left  = 1.;
+const Float_t Module_Thick_Alu_X_right = 0.1;
+const Float_t Module_Thick_Alu_Y       = 0.1;
+const Float_t Module_Thick_Alu_Z_front = 0.1;
+const Float_t Module_Thick_Alu_Z_back  = 1.;
+
+const Float_t shift_gas_box_x = (Module_Thick_Alu_X_right - Module_Thick_Alu_X_left) / 2;
+const Float_t shift_gas_box_z = (Module_Thick_Alu_Z_back - Module_Thick_Alu_Z_front) / 2;
+
+const Float_t Wall_Z_Position =
+  TOF_Z_Front + 1000. - 884.;  // if you want to know where this numbers come from ask Ingo
+
+// Pole (support structure)
+const Int_t MaxNumberOfPoles = 200;
+Float_t Pole_ZPos[MaxNumberOfPoles];
+Float_t Pole_XPos[MaxNumberOfPoles];
+Float_t Pole_Col[MaxNumberOfPoles];
+Int_t NumberOfPoles = 0;
+
+const Float_t Pole_Size_X      = 8.;
+const Float_t Pole_Size_Y      = 1000.;
+const Float_t PoleShort_Size_Y = 370.;
+const Float_t Pole_Size_Z      = 2.;
+const Float_t Pole_Thick_X     = 0.4;
+const Float_t Pole_Thick_Y     = 0.4;
+const Float_t Pole_Thick_Z     = 0.4;
+const Float_t XLimInner        = 180.;
+
+
+// Bars & frame (support structure)
+const Float_t Frame_Size_X = 20.;
+const Float_t Frame_Size_Y = 20.;
+Float_t Bar_Size_Z         = 176.;
+const Float_t Frame_XLen   = 1400;
+const Float_t Frame_YLen   = Pole_Size_Y + 2. * Frame_Size_Y;
+Float_t Frame_Pos_Z        = TOF_Z_Front + 88.;
+const Float_t Bar_Size_X   = 30;
+const Float_t Bar_Size_Y   = 20.;
+Float_t Bar_Pos_Z;
+
+const Int_t MaxNumberOfBars = 200;
+Float_t Bar_ZPos[MaxNumberOfBars];
+Float_t Bar_XPos[MaxNumberOfBars];
+Int_t NumberOfBars = 0;
+
+const Float_t ChamberOverlap = 40;
+const Float_t DxColl         = 158.0;  //Module_Size_X-ChamberOverlap;
+//const Float_t Pole_Offset=Module_Size_X/2.+Pole_Size_X/2.;
+const Float_t Pole_Offset = 90.0 + Pole_Size_X / 2.;
+
+// some global variables
+TGeoManager* gGeoMan = NULL;           // Pointer to TGeoManager instance
+TGeoVolume* gModules[NofModuleTypes];  // Global storage for module types
+TGeoVolume* gCounter[NumberOfDifferentCounterTypes];
+TGeoVolume* gPole;
+TGeoVolume* gPoleShort;
+TGeoVolume* gBar[MaxNumberOfBars];
+
+Float_t Last_Size_Y = 0.;
+Float_t Last_Over_Y = 0.;
+
+// Forward declarations
+
+void create_materials_from_media_file();
+TGeoVolume* create_counter_simple(Int_t);
+TGeoVolume* create_counter_doublestack(Int_t);
+TGeoVolume* create_counter_singlestack(Int_t);
+TGeoVolume* create_tof_module(Int_t);
+TGeoVolume* create_tof_module_m(Int_t);
+TGeoVolume* create_new_tof_module(Int_t);
+TGeoVolume* create_new_tof_module_m(Int_t);
+TGeoVolume* create_tof_pole();
+TGeoVolume* create_tof_poleshort();
+TGeoVolume* create_tof_bar();
+void position_tof_poles(Int_t);
+void position_tof_bars(Int_t);
+void position_inner_tof_modules(Int_t);
+void position_side_tof_modules(Int_t);
+void position_outer_tof_modules(Int_t);
+void position_tof_modules();
+void position_tof_modules_m(Int_t, Int_t);
+void dump_info_file();
+void read_module_positions();
+void read_counter_positions();
+
+void Create_TOF_Geometry_v21a()
+{
+  // Load the necessary FairRoot libraries
+  //  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
+  //  basiclibs();
+  //  gSystem->Load("libGeoBase");
+  //  gSystem->Load("libParBase");
+  //  gSystem->Load("libBase");
+
+  // Printout what we are generating
+  std::cout << "Generating geometry " << geoVersion << " at " << TOF_Z_Front << " cm from target." << std::endl;
+
+  // read input Data
+  read_counter_positions();
+  read_module_positions();
+  // Load needed material definition from media.geo file
+  create_materials_from_media_file();
+
+  // Get the GeoManager for later usage
+  gGeoMan = (TGeoManager*) gROOT->FindObject("FAIRGeom");
+  gGeoMan->SetVisLevel(7);  // 2 = super modules
+  gGeoMan->SetVisOption(1);
+
+  // Create the top volume
+  /*
+  TGeoBBox* topbox= new TGeoBBox("", 1000., 1000., 1000.);
+  TGeoVolume* top = new TGeoVolume("top", topbox, gGeoMan->GetMedium("air"));
+  gGeoMan->SetTopVolume(top);
+  */
+
+  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
+  gGeoMan->SetTopVolume(top);
+
+  TGeoTranslation* toftrans = new TGeoTranslation(0., 0., TOF_Z_Corr);
+  TGeoVolume* tof           = new TGeoVolumeAssembly(geoVersion);
+  top->AddNode(tof, 1, toftrans);
+
+  for (Int_t counterType = 0; counterType < NumberOfDifferentCounterTypes; counterType++) {
+    //gCounter[counterType] = create_counter_simple(counterType);
+    gCounter[counterType] = create_counter_doublestack(counterType);
+    //gCounter[counterType] = create_counter_singlestack(counterType);
+  }
+
+  for (Int_t moduleType = 0; moduleType < NofModuleTypes; moduleType++) {
+    gModules[moduleType] = create_new_tof_module(moduleType);
+    gModules[moduleType]->SetVisContainers(1);
+  }
+
+  gPole      = create_tof_pole();
+  gPoleShort = create_tof_poleshort();
+
+  position_tof_modules();
+
+  if (IncludeSupports) {
+    position_tof_poles(0);
+    position_tof_bars(0);
+  }
+
+  gGeoMan->CloseGeometry();
+  gGeoMan->CheckOverlaps(0.00001);
+  gGeoMan->CheckOverlaps(0.00001, "s");
+  gGeoMan->PrintOverlaps();
+  gGeoMan->GetListOfOverlaps()->Print();
+  gGeoMan->Test();
+
+  top->SetVisContainers(1);
+  gGeoMan->SetVisLevel(5);
+  top->Draw("ogl");
+  //top->Draw();
+  //gModules[0]->Draw("ogl");
+  //  gModules[0]->Draw("");
+  gModules[0]->SetVisContainers(1);
+  //  gModules[1]->Draw("");
+  gModules[1]->SetVisContainers(1);
+  //gModules[5]->Draw("");
+  //  top->Raytrace();
+
+  tof->Export(FileNameSim);  // an alternative way of writing the tof volume
+  TFile* outfile = new TFile(FileNameSim, "UPDATE");
+  toftrans->Write();
+  outfile->Close();
+
+  outfile = new TFile(FileNameGeo, "RECREATE");
+  gGeoMan->Write();
+  outfile->Close();
+
+  dump_info_file();
+
+  // Printout what we are generating
+  std::cout << "Done generating geometry " << geoVersion << " at " << TOF_Z_Front << " cm from target." << std::endl;
+}
+
+void read_counter_positions()
+{
+  //TFile * fPosInput = new TFile( "TOF_10M.dat", "READ");
+  for (Int_t modtype = 0; modtype < NofModuleTypes; modtype++) {
+    TString moduleTypeName = Form("ModuleType%d_v21a.dat", modtype);
+    cout << "load parameters from file " << moduleTypeName << endl;
+    ifstream inFile;
+    inFile.open(moduleTypeName);
+    if (!inFile.is_open()) {
+      cout << "<E> cannot open input file " << endl;
+      return;
+    }
+
+    cout << "------------------------------" << endl;
+    cout << "Reading content of " << moduleTypeName << endl;
+    std::string strdummy;
+    std::getline(inFile, strdummy);
+    //cout<<strdummy<<endl;
+    Int_t iNum;
+    Int_t ictype;
+    Float_t iX;
+    Float_t iY;
+    Float_t iZ;
+    Int_t iCou = 0;
+    while (std::getline(inFile, strdummy)) {
+      //  std::getline(inFile,strdummy);
+      //cout<<strdummy<<endl;
+      stringstream ss;
+      ss << strdummy;
+      ss >> iNum >> ictype >> iX >> iY >> iZ;
+      ss << strdummy;
+      //cout<<iCou<< "    "<<iNum<<"    "<<ictype<<"   "<<iX<<"    "<<iY<<"    "<<iZ<<endl;
+      CouType[modtype][iCou] = ictype;
+      xPosCou[modtype][iCou] = iX;
+      yPosCou[modtype][iCou] = iY;
+      zPosCou[modtype][iCou] = iZ;
+      iCou++;
+    }
+  }
+}
+
+
+void read_module_positions()
+{
+  //TFile * fPosInput = new TFile( "TOF_10M.dat", "READ");
+  ifstream inFile;
+  inFile.open("ModulePosition_10m_v21a.dat");
+  if (!inFile.is_open()) {
+    cout << "<E> cannot open input file " << endl;
+    return;
+  }
+
+  cout << "------------------------------" << endl;
+  cout << "Reading content of ModulePosition_10m_v21a.dat" << endl;
+  std::string strdummy;
+  std::getline(inFile, strdummy);
+  //cout<<strdummy<<endl;
+  Int_t iNum;
+  Int_t iModT;
+  Float_t iX;
+  Float_t iY;
+  Float_t iZ;
+  //Int_t iModType=0;
+  Int_t iMod = 0;
+  //while( !inFile.eof()  )
+  //for(Int_t iL=0; iL<2; iL++)
+  while (std::getline(inFile, strdummy)) {
+    //  std::getline(inFile,strdummy);
+    //cout<<strdummy<<endl;
+    stringstream ss;
+    ss << strdummy;
+    ss >> iNum >> iModT >> iX >> iY >> iZ;
+    ss << strdummy;
+    //  ss>>iNum>>iX>>iY>>iZ>>cType[0]>>cType[1];
+    //cout<<iNum<<"   "<<iModT<<"   "<<iX<<"   "<<iY<<"   "<<iZ<<endl;
+
+    //cout<<" ModType "<<iModType<<endl;
+    //cout<<" ModType "<<iModType<<", # "<<iMod<<endl;
+    ModType[iMod] = iModT;
+    NModules[iModT]++;
+    if (NModules[iModT] > NModulesOfModuleType[iModT]) {
+      cout << "Too many modules of Type " << iModT << endl;
+      break;
+    }
+    xPosMod[iMod] = iX;
+    yPosMod[iMod] = iY;
+    zPosMod[iMod] = iZ;
+    iMod++;
+    /*
+  if(cPos=='l'){
+    FlipMod[iModType][iMod]=1.;
+  }else{
+    FlipMod[iModType][iMod]=0.;
+  }
+  //  if (iModType==1 && iMod==1) return;
+ 
+    cout<<" ModType "<<iModType<<", Mod "<<iMod<<", x "<<xPosMod[iModType][iMod]<<", y "
+      <<yPosMod[iModType][iMod]<<", z "<<zPosMod[iModType][iMod]<<endl;
+  */
+    if (iMod > MaxNofModules) {
+      cout << "Too many modules found in input file, max is " << MaxNofModules << endl;
+      break;
+    }
+  }
+  //cout <<"Data reading finished for "<< endl;
+}
+
+
+void create_materials_from_media_file()
+{
+  // Use the FairRoot geometry interface to load the media which are already defined
+  FairGeoLoader* geoLoad    = new FairGeoLoader("TGeo", "FairGeoLoader");
+  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
+  TString geoPath           = gSystem->Getenv("VMCWORKDIR");
+  TString geoFile           = geoPath + "/geometry/media.geo";
+  geoFace->setMediaFile(geoFile);
+  geoFace->readMedia();
+
+  // Read the required media and create them in the GeoManager
+  FairGeoMedia* geoMedia   = geoFace->getMedia();
+  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
+
+  FairGeoMedium* air                = geoMedia->getMedium("air");
+  FairGeoMedium* aluminium          = geoMedia->getMedium("aluminium");
+  FairGeoMedium* tof_pole_aluminium = geoMedia->getMedium("tof_pole_aluminium");
+  FairGeoMedium* RPCgas             = geoMedia->getMedium("RPCgas");
+  FairGeoMedium* RPCgas_noact       = geoMedia->getMedium("RPCgas_noact");
+  FairGeoMedium* RPCglass           = geoMedia->getMedium("RPCglass");
+  FairGeoMedium* carbon             = geoMedia->getMedium("carbon");
+
+  // include check if all media are found
+
+  geoBuild->createMedium(air);
+  geoBuild->createMedium(aluminium);
+  geoBuild->createMedium(tof_pole_aluminium);
+  geoBuild->createMedium(RPCgas);
+  geoBuild->createMedium(RPCgas_noact);
+  geoBuild->createMedium(RPCglass);
+  geoBuild->createMedium(carbon);
+}
+
+
+TGeoVolume* create_counter_simple(Int_t countType)
+{
+  TGeoMedium* activeGasVolMed   = gGeoMan->GetMedium(ActivGasMedium);
+  TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
+  //TGeoMedium* glassPlateVolMed   = gGeoMan->GetMedium(GlasMedium);
+  //gas gap
+  Int_t nstrips = NumberOfReadoutStrips[countType];
+
+  Float_t ggdx = GasGap_X[countType];
+  Float_t ggdy = GasGap_Y[countType];
+  //Float_t ggdz=GasGap_Z[countType];
+  Float_t ggdz = 1.;
+  Float_t gsdx = ggdx / float(nstrips);
+
+
+  TGeoBBox* counter_box = new TGeoBBox("", (ggdx + 0.2) / 2., (ggdy + 0.2) / 2., (ggdz + 0.2) / 2.);
+  TGeoVolume* counter   = new TGeoVolume("counter", counter_box, noActiveGasVolMed);
+  counter->SetLineColor(kCyan);  // set line color for the counter
+  counter->SetTransparency(70);  // set transparency for the TOF
+  // Single gas gap
+  TGeoBBox* gas_gap       = new TGeoBBox("", ggdx / 2., ggdy / 2., ggdz / 2.);
+  TGeoVolume* gas_gap_vol = new TGeoVolume("Gap", gas_gap, activeGasVolMed);
+  gas_gap_vol->Divide("Cell", 1, nstrips, -ggdx / 2., 0);
+  gas_gap_vol->SetLineColor(kRed);   // set line color for the gas gap
+  gas_gap_vol->SetTransparency(70);  // set transparency for the TOF
+  TGeoTranslation* gas_gap_trans = new TGeoTranslation("", 0., 0., 0.);
+
+  counter->AddNode(gas_gap_vol, 0, gas_gap_trans);
+
+  return counter;
+}
+
+TGeoVolume* create_counter_doublestack(Int_t countType)
+{
+  //glass
+  Float_t pdx = PCB_X[countType];
+  Float_t pdy = PCB_Y[countType];
+  Float_t pdz = PCB_Z[countType];
+
+  //glass
+  Float_t gdx = Glass_X[countType];
+  Float_t gdy = Glass_Y[countType];
+  Float_t gdz = Glass_Z[countType];
+
+  //gas gap
+  Int_t nstrips = NumberOfReadoutStrips[countType];
+  Int_t ngaps   = NumberOfGaps[countType];
+
+
+  Float_t ggdx = GasGap_X[countType];
+  Float_t ggdy = GasGap_Y[countType];
+  Float_t ggdz = GasGap_Z[countType];
+  Float_t gsdx = ggdx / float(nstrips);
+
+  //single stack
+  //Float_t dzpos=gdz+ggdz;
+  // Float_t startzpos=SingleStackStartPosition_Z[modType];
+
+  // electronics
+  //pcb dimensions
+  Float_t dxe  = Electronics_X[countType];
+  Float_t dye  = Electronics_Y[countType];
+  Float_t dze  = Electronics_Z[countType];
+  Float_t yele = (gdy + 0.1) / 2. + dye / 2.;
+
+  // needed materials
+  TGeoMedium* glassPlateVolMed  = gGeoMan->GetMedium(GlasMedium);
+  TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
+  TGeoMedium* activeGasVolMed   = gGeoMan->GetMedium(ActivGasMedium);
+  TGeoMedium* electronicsVolMed = gGeoMan->GetMedium(ElectronicsMedium);
+
+  // Single PCB
+  TGeoBBox* pcb       = new TGeoBBox("", pdx / 2., pdy / 2., pdz / 2.);
+  TGeoVolume* pcb_vol = new TGeoVolume("tof_pcb", pcb, electronicsVolMed);
+  pcb_vol->SetLineColor(kGreen);  // set line color for the pcb
+  pcb_vol->SetTransparency(20);   // set transparency for the TOF
+  TGeoTranslation* pcb_trans0 = new TGeoTranslation("", 0., 0., 0.);
+
+  // Single glass plate
+  TGeoBBox* glass_plate       = new TGeoBBox("", gdx / 2., gdy / 2., gdz / 2.);
+  TGeoVolume* glass_plate_vol = new TGeoVolume("tof_glass", glass_plate, glassPlateVolMed);
+  glass_plate_vol->SetLineColor(kMagenta);  // set line color for the glass plate
+  glass_plate_vol->SetTransparency(20);     // set transparency for the TOF
+  //TGeoTranslation* glass_plate_trans = new TGeoTranslation("", 0., 0., 0.);
+
+  // Single gas gap
+  TGeoBBox* gas_gap       = new TGeoBBox("", ggdx / 2., ggdy / 2., ggdz / 2.);
+  TGeoVolume* gas_gap_vol = new TGeoVolume("Gap", gas_gap, activeGasVolMed);
+  gas_gap_vol->Divide("Cell", 1, nstrips, -ggdx / 2., 0);
+  gas_gap_vol->SetLineColor(kRed);   // set line color for the gas gap
+  gas_gap_vol->SetTransparency(70);  // set transparency for the TOF
+  //TGeoTranslation* gas_gap_trans = new TGeoTranslation("", 0., 0., (gdz+ggdz)/2.);
+
+  TGeoVolume* counter = new TGeoVolumeAssembly("counter");
+  counter->AddNode(pcb_vol, 0, pcb_trans0);
+  Int_t l = 0;
+  for (l = 0; l < ngaps + 1; l++) {
+    if (l % 2 == 0) {
+      if (l == 0) {
+        TGeoTranslation* glass_plate_trans = new TGeoTranslation("", 0., 0., 0.5 * (pdz + gdz));
+        counter->AddNode(glass_plate_vol, l, glass_plate_trans);
+        TGeoTranslation* glass_plate_trans1 = new TGeoTranslation("", 0., 0., -0.5 * (pdz + gdz));
+        counter->AddNode(glass_plate_vol, l + ngaps + 1, glass_plate_trans1);
+      }
+      else {
+        TGeoTranslation* glass_plate_trans =
+          new TGeoTranslation("", 0., 0., 0.5 * (pdz + gdz) + l * (0.5 * (ggdz + gdz)));
+        counter->AddNode(glass_plate_vol, l, glass_plate_trans);
+        TGeoTranslation* glass_plate_trans1 =
+          new TGeoTranslation("", 0., 0., -0.5 * (pdz + gdz) - l * (0.5 * (ggdz + gdz)));
+        counter->AddNode(glass_plate_vol, l + ngaps + 1, glass_plate_trans1);
+      }
+    }
+    else {
+      TGeoTranslation* gas_gap_trans = new TGeoTranslation("", 0., 0., 0.5 * (pdz + gdz) + l * (0.5 * (ggdz + gdz)));
+      counter->AddNode(gas_gap_vol, l, gas_gap_trans);
+      TGeoTranslation* gas_gap_trans1 = new TGeoTranslation("", 0., 0., -0.5 * (pdz + gdz) - l * (0.5 * (ggdz + gdz)));
+      counter->AddNode(gas_gap_vol, l + ngaps + 1, gas_gap_trans1);
+    }
+  }
+  TGeoTranslation* pcb_trans1 = new TGeoTranslation("", 0., 0., (pdz + gdz) + (l - 1) * (0.5 * (ggdz + gdz)));
+  counter->AddNode(pcb_vol, l + ngaps + 1, pcb_trans1);
+  TGeoTranslation* pcb_trans2 = new TGeoTranslation("", 0., 0., -(pdz + gdz) - (l - 1) * (0.5 * (ggdz + gdz)));
+  counter->AddNode(pcb_vol, l + ngaps + 1, pcb_trans2);
+
+
+  TGeoBBox* epcb       = new TGeoBBox("", dxe / 2., dye / 2., dze / 2.);
+  TGeoVolume* epcb_vol = new TGeoVolume("epcb", epcb, electronicsVolMed);
+  epcb_vol->SetLineColor(kCyan);  // set line color for the electronic
+  epcb_vol->SetTransparency(10);  // set transparency for the TOF
+  for (Int_t l = 0; l < 2; l++) {
+    yele *= -1.;
+    TGeoTranslation* epcb_trans = new TGeoTranslation("", 0., yele, 0.);
+    counter->AddNode(epcb_vol, l, epcb_trans);
+  }
+
+  return counter;
+}
+
+TGeoVolume* create_counter_singlestack(Int_t modType)
+{
+
+  //glass
+  Float_t gdx = Glass_X[modType];
+  Float_t gdy = Glass_Y[modType];
+  Float_t gdz = Glass_Z[modType];
+
+  //gas gap
+  Int_t nstrips = NumberOfReadoutStrips[modType];
+  Int_t ngaps   = NumberOfGaps[modType];
+
+
+  Float_t ggdx = GasGap_X[modType];
+  Float_t ggdy = GasGap_Y[modType];
+  Float_t ggdz = GasGap_Z[modType];
+  Float_t gsdx = ggdx / (Float_t)(nstrips);
+
+  // electronics
+  //pcb dimensions
+  Float_t dxe  = Electronics_X[modType];
+  Float_t dye  = Electronics_Y[modType];
+  Float_t dze  = Electronics_Z[modType];
+  Float_t yele = gdy / 2. + dye / 2.;
+
+  // counter size (calculate from glas, gap and electronics sizes)
+  Float_t cdx = TMath::Max(gdx, ggdx);
+  cdx         = TMath::Max(cdx, dxe) + 0.2;
+  Float_t cdy = TMath::Max(gdy, ggdy) + 2 * dye + 0.2;
+  Float_t cdz = ngaps * ggdz + (ngaps + 1) * gdz + 0.2;  // ngaps * (gdz+ggdz) + gdz + 0.2; // ok
+
+  //calculate thickness and first position in counter of single stack
+  Float_t dzpos         = gdz + ggdz;
+  Float_t startzposglas = -ngaps * (gdz + ggdz) / 2.;  // -cdz/2.+0.1+gdz/2.; // ok  // (-cdz+gdz)/2.; // not ok
+  Float_t startzposgas  = startzposglas + gdz / 2. + ggdz / 2.;  // -cdz/2.+0.1+gdz   +ggdz/2.;  // ok
+
+
+  // needed materials
+  TGeoMedium* glassPlateVolMed  = gGeoMan->GetMedium(GlasMedium);
+  TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
+  TGeoMedium* activeGasVolMed   = gGeoMan->GetMedium(ActivGasMedium);
+  TGeoMedium* electronicsVolMed = gGeoMan->GetMedium(ElectronicsMedium);
+
+
+  // define counter volume
+  TGeoBBox* counter_box = new TGeoBBox("", cdx / 2., cdy / 2., cdz / 2.);
+  TGeoVolume* counter   = new TGeoVolume("counter", counter_box, noActiveGasVolMed);
+  counter->SetLineColor(kCyan);  // set line color for the counter
+  counter->SetTransparency(70);  // set transparency for the TOF
+
+  // define single glass plate volume
+  TGeoBBox* glass_plate       = new TGeoBBox("", gdx / 2., gdy / 2., gdz / 2.);
+  TGeoVolume* glass_plate_vol = new TGeoVolume("tof_glass", glass_plate, glassPlateVolMed);
+  glass_plate_vol->SetLineColor(kMagenta);  // set line color for the glass plate
+  glass_plate_vol->SetTransparency(20);     // set transparency for the TOF
+  // define single gas gap volume
+  TGeoBBox* gas_gap       = new TGeoBBox("", ggdx / 2., ggdy / 2., ggdz / 2.);
+  TGeoVolume* gas_gap_vol = new TGeoVolume("Gap", gas_gap, activeGasVolMed);
+  gas_gap_vol->Divide("Cell", 1, nstrips, -ggdx / 2., 0);
+  gas_gap_vol->SetLineColor(kRed);   // set line color for the gas gap
+  gas_gap_vol->SetTransparency(99);  // set transparency for the TOF
+
+  // place 8 gas gaps and 9 glas plates in the counter
+  for (Int_t igap = 0; igap <= ngaps; igap++) {
+    // place (ngaps+1) glass plates
+    Float_t zpos_glas                  = startzposglas + igap * dzpos;
+    TGeoTranslation* glass_plate_trans = new TGeoTranslation("", 0., 0., zpos_glas);
+    counter->AddNode(glass_plate_vol, igap, glass_plate_trans);
+    // place ngaps gas gaps
+    if (igap < ngaps) {
+      Float_t zpos_gas               = startzposgas + igap * dzpos;
+      TGeoTranslation* gas_gap_trans = new TGeoTranslation("", 0., 0., zpos_gas);
+      counter->AddNode(gas_gap_vol, igap, gas_gap_trans);
+    }
+    //    cout <<"Zpos(Glas): "<< zpos_glas << endl;
+    //    cout <<"Zpos(Gas): "<< zpos_gas << endl;
+  }
+
+  // create and place the electronics above and below the glas stack
+  TGeoBBox* pcb       = new TGeoBBox("", dxe / 2., dye / 2., dze / 2.);
+  TGeoVolume* pcb_vol = new TGeoVolume("pcb", pcb, electronicsVolMed);
+  pcb_vol->SetLineColor(kYellow);  // kCyan); // set line color for electronics
+  pcb_vol->SetTransparency(10);    // set transparency for the TOF
+  for (Int_t l = 0; l < 2; l++) {
+    yele *= -1.;
+    TGeoTranslation* pcb_trans = new TGeoTranslation("", 0., yele, 0.);
+    counter->AddNode(pcb_vol, l, pcb_trans);
+  }
+
+
+  return counter;
+}
+
+TGeoVolume* create_new_tof_module(Int_t modType)
+{
+
+  Float_t dx          = Module_Size_X[modType];
+  Float_t dy          = Module_Size_Y[modType];
+  Float_t dz          = Module_Size_Z[modType];
+  Float_t width_aluxl = Module_Thick_Alu_X_left;
+  Float_t width_aluxr = Module_Thick_Alu_X_right;
+  Float_t width_aluy  = Module_Thick_Alu_Y;
+  Float_t width_aluzf = Module_Thick_Alu_Z_front;
+  Float_t width_aluzb = Module_Thick_Alu_Z_back;
+  Float_t rotangle    = CounterRotationAngle[modType];
+
+  TGeoMedium* boxVolMed         = gGeoMan->GetMedium(BoxVolumeMedium);
+  TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
+
+  TString moduleName = Form("module_%d", modType);
+
+  TGeoBBox* module_box = new TGeoBBox("", dx / 2., dy / 2., dz / 2.);
+  TGeoVolume* module   = new TGeoVolume(moduleName, module_box, boxVolMed);
+  module->SetLineColor(kGreen);  // set line color for the alu box
+  module->SetTransparency(20);   // set transparency for the TOF
+
+  if (modType < 5) {
+    TGeoBBox* gas_box       = new TGeoBBox("", (dx - (width_aluxl + width_aluxr)) / 2., (dy - 2 * width_aluy) / 2.,
+                                     (dz - 2 * width_aluzf) / 2.);
+    TGeoVolume* gas_box_vol = new TGeoVolume("gas_box", gas_box, noActiveGasVolMed);
+    gas_box_vol->SetLineColor(kBlue);  // set line color for the alu box
+    gas_box_vol->SetTransparency(50);  // set transparency for the TOF
+    TGeoTranslation* gas_box_trans = new TGeoTranslation("", shift_gas_box_x, 0., 0.);
+    module->AddNode(gas_box_vol, 0, gas_box_trans);
+
+    for (Int_t j = 0; j < NCounterInModule[modType]; j++) {  //loop over counters (modules)
+      cout << j << "  " << modType << "  xPos " << xPosCou[modType][j] << "  yPos " << yPosCou[modType][j] << "  zPos "
+           << zPosCou[modType][j] << endl;
+      TGeoTranslation* counter_trans =
+        new TGeoTranslation("", xPosCou[modType][j], yPosCou[modType][j], zPosCou[modType][j]);
+      TGeoRotation* counter_rot = new TGeoRotation();
+      counter_rot->RotateY(rotangle);
+      TGeoCombiTrans* counter_combi_trans = new TGeoCombiTrans(*counter_trans, *counter_rot);
+      gas_box_vol->AddNode(gCounter[CouType[modType][j]], j, counter_combi_trans);
+    }
+    cout << "-------------------------------" << endl;
+  }
+  else {
+    TGeoBBox* gas_box       = new TGeoBBox("", (dx - 2 * width_aluxr) / 2., (dy - 2 * width_aluy) / 2.,
+                                     (dz + (width_aluzf - width_aluzb)) / 2.);
+    TGeoVolume* gas_box_vol = new TGeoVolume("gas_box", gas_box, noActiveGasVolMed);
+    gas_box_vol->SetLineColor(kBlue);  // set line color for the alu box
+    gas_box_vol->SetTransparency(50);  // set transparency for the TOF
+    TGeoTranslation* gas_box_trans = new TGeoTranslation("", 0., 0., -shift_gas_box_z);
+    module->AddNode(gas_box_vol, 0, gas_box_trans);
+
+    for (Int_t j = 0; j < NCounterInModule[modType]; j++) {  //loop over counters (modules)
+      cout << j << "  " << modType << "  xPos " << xPosCou[modType][j] << "  yPos " << yPosCou[modType][j] << "  zPos "
+           << zPosCou[modType][j] << endl;
+      TGeoTranslation* counter_trans =
+        new TGeoTranslation("", xPosCou[modType][j], yPosCou[modType][j], zPosCou[modType][j]);
+      TGeoRotation* counter_rot = new TGeoRotation();
+      counter_rot->RotateY(rotangle);
+      TGeoCombiTrans* counter_combi_trans = new TGeoCombiTrans(*counter_trans, *counter_rot);
+      gas_box_vol->AddNode(gCounter[CouType[modType][j]], j, counter_combi_trans);
+    }
+    cout << "-------------------------------" << endl;
+  }
+  return module;
+}
+
+TGeoVolume* create_tof_pole()
+{
+  // needed materials
+  TGeoMedium* boxVolMed = gGeoMan->GetMedium(PoleVolumeMedium);
+  TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium);
+
+  Float_t dx         = Pole_Size_X;
+  Float_t dy         = Pole_Size_Y;
+  Float_t dz         = Pole_Size_Z;
+  Float_t width_alux = Pole_Thick_X;
+  Float_t width_aluy = Pole_Thick_Y;
+  Float_t width_aluz = Pole_Thick_Z;
+
+  TGeoVolume* pole         = new TGeoVolumeAssembly("Pole");
+  TGeoBBox* pole_alu_box   = new TGeoBBox("", dx / 2., dy / 2., dz / 2.);
+  TGeoVolume* pole_alu_vol = new TGeoVolume("pole_alu", pole_alu_box, boxVolMed);
+  pole_alu_vol->SetLineColor(kGreen);  // set line color for the alu box
+  //  pole_alu_vol->SetTransparency(20); // set transparency for the TOF
+  TGeoTranslation* pole_alu_trans = new TGeoTranslation("", 0., 0., 0.);
+  pole->AddNode(pole_alu_vol, 0, pole_alu_trans);
+
+  Float_t air_dx = dx / 2. - width_alux;
+  Float_t air_dy = dy / 2. - width_aluy;
+  Float_t air_dz = dz / 2. - width_aluz;
+
+  //  cout << "My pole." << endl;
+  if (air_dx <= 0.) cout << "ERROR - No air volume in pole X, size: " << air_dx << endl;
+  if (air_dy <= 0.) cout << "ERROR - No air volume in pole Y, size: " << air_dy << endl;
+  if (air_dz <= 0.) cout << "ERROR - No air volume in pole Z, size: " << air_dz << endl;
+
+  if ((air_dx > 0.) && (air_dy > 0.) && (air_dz > 0.))  // crate air volume only, if larger than zero
+  {
+    TGeoBBox* pole_air_box = new TGeoBBox("", air_dx, air_dy, air_dz);
+    //  TGeoBBox* pole_air_box = new TGeoBBox("", dx/2.-width_alux, dy/2.-width_aluy, dz/2.-width_aluz);
+    TGeoVolume* pole_air_vol = new TGeoVolume("pole_air", pole_air_box, airVolMed);
+    pole_air_vol->SetLineColor(kYellow);  // set line color for the alu box
+    pole_air_vol->SetTransparency(70);    // set transparency for the TOF
+    TGeoTranslation* pole_air_trans = new TGeoTranslation("", 0., 0., 0.);
+    pole_alu_vol->AddNode(pole_air_vol, 0, pole_air_trans);
+  }
+  else
+    cout << "Skipping pole_air_vol, no thickness: " << air_dx << " " << air_dy << " " << air_dz << endl;
+
+  return pole;
+}
+
+TGeoVolume* create_tof_poleshort()
+{
+  // needed materials
+  TGeoMedium* boxVolMed = gGeoMan->GetMedium(PoleVolumeMedium);
+  TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium);
+
+  Float_t dx         = Pole_Size_X;
+  Float_t dy         = PoleShort_Size_Y;
+  Float_t dz         = Pole_Size_Z;
+  Float_t width_alux = Pole_Thick_X;
+  Float_t width_aluy = Pole_Thick_Y;
+  Float_t width_aluz = Pole_Thick_Z;
+
+  TGeoVolume* pole         = new TGeoVolumeAssembly("PoleShort");
+  TGeoBBox* pole_alu_box   = new TGeoBBox("", dx / 2., dy / 2., dz / 2.);
+  TGeoVolume* pole_alu_vol = new TGeoVolume("poleshort_alu", pole_alu_box, boxVolMed);
+  pole_alu_vol->SetLineColor(kGreen);  // set line color for the alu box
+  //  pole_alu_vol->SetTransparency(20); // set transparency for the TOF
+  TGeoTranslation* pole_alu_trans = new TGeoTranslation("", 0., 0., 0.);
+  pole->AddNode(pole_alu_vol, 0, pole_alu_trans);
+
+  Float_t air_dx = dx / 2. - width_alux;
+  Float_t air_dy = dy / 2. - width_aluy;
+  Float_t air_dz = dz / 2. - width_aluz;
+  //  cout << "My pole." << endl;
+  if (air_dx <= 0.) cout << "ERROR - No air volume in pole X, size: " << air_dx << endl;
+  if (air_dy <= 0.) cout << "ERROR - No air volume in pole Y, size: " << air_dy << endl;
+  if (air_dz <= 0.) cout << "ERROR - No air volume in pole Z, size: " << air_dz << endl;
+
+  if ((air_dx > 0.) && (air_dy > 0.) && (air_dz > 0.))  // crate air volume only, if larger than zero
+  {
+    TGeoBBox* pole_air_box = new TGeoBBox("", air_dx, air_dy, air_dz);
+    //  TGeoBBox* pole_air_box = new TGeoBBox("", dx/2.-width_alux, dy/2.-width_aluy, dz/2.-width_aluz);
+    TGeoVolume* pole_air_vol = new TGeoVolume("poleshort_air", pole_air_box, airVolMed);
+    pole_air_vol->SetLineColor(kYellow);  // set line color for the alu box
+    pole_air_vol->SetTransparency(70);    // set transparency for the TOF
+    TGeoTranslation* pole_air_trans = new TGeoTranslation("", 0., 0., 0.);
+    pole_alu_vol->AddNode(pole_air_vol, 0, pole_air_trans);
+  }
+  else
+    cout << "Skipping pole_air_vol, no thickness: " << air_dx << " " << air_dy << " " << air_dz << endl;
+
+  return pole;
+}
+
+
+TGeoVolume* create_tof_bar(Float_t dx, Float_t dy, Float_t dz)
+{
+  // needed materials
+  TGeoMedium* boxVolMed = gGeoMan->GetMedium(PoleVolumeMedium);
+  TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium);
+
+  Float_t width_alux = Pole_Thick_X;
+  Float_t width_aluy = Pole_Thick_Y;
+  Float_t width_aluz = Pole_Thick_Z;
+
+  TGeoVolume* bar         = new TGeoVolumeAssembly("Bar");
+  TGeoBBox* bar_alu_box   = new TGeoBBox("", dx / 2., dy / 2., dz / 2.);
+  TGeoVolume* bar_alu_vol = new TGeoVolume("bar_alu", bar_alu_box, boxVolMed);
+  bar_alu_vol->SetLineColor(kGreen);  // set line color for the alu box
+  //  bar_alu_vol->SetTransparency(20); // set transparency for the TOF
+  TGeoTranslation* bar_alu_trans = new TGeoTranslation("", 0., 0., 0.);
+  bar->AddNode(bar_alu_vol, 0, bar_alu_trans);
+
+  TGeoBBox* bar_air_box   = new TGeoBBox("", dx / 2. - width_alux, dy / 2. - width_aluy, dz / 2. - width_aluz);
+  TGeoVolume* bar_air_vol = new TGeoVolume("bar_air", bar_air_box, airVolMed);
+  bar_air_vol->SetLineColor(kYellow);  // set line color for the alu box
+  bar_air_vol->SetTransparency(70);    // set transparency for the TOF
+  TGeoTranslation* bar_air_trans = new TGeoTranslation("", 0., 0., 0.);
+  bar_alu_vol->AddNode(bar_air_vol, 0, bar_air_trans);
+
+  return bar;
+}
+
+void position_tof_poles(Int_t modType)
+{
+  cout << "Position " << NumberOfPoles << " TOF poles" << endl;
+  TGeoTranslation* pole_trans = NULL;
+
+  Int_t numPoles      = 0;
+  Int_t numPolesShort = 0;
+  for (Int_t i = 0; i < NumberOfPoles; i++) {
+
+    Float_t xPos = Pole_XPos[i];
+    Float_t zPos = Pole_ZPos[i];
+    if (TMath::Abs(xPos) > XLimInner) {
+      pole_trans = new TGeoTranslation("", xPos, 0., zPos);
+      gGeoMan->GetVolume(geoVersion)->AddNode(gPole, numPoles, pole_trans);
+      numPoles++;
+    }
+    else {  // position 2 short poles
+
+      // upper short poles
+      pole_trans = new TGeoTranslation("", xPos, Pole_Size_Y / 2. - PoleShort_Size_Y / 2., zPos);
+      gGeoMan->GetVolume(geoVersion)->AddNode(gPoleShort, numPolesShort, pole_trans);
+      numPolesShort++;
+
+      // lower short poles
+      pole_trans = new TGeoTranslation("", xPos, PoleShort_Size_Y / 2. - Pole_Size_Y / 2., zPos);
+      gGeoMan->GetVolume(geoVersion)->AddNode(gPoleShort, numPolesShort, pole_trans);
+      numPolesShort++;
+    }
+    cout << " Position Pole " << numPoles << " at z=" << Pole_ZPos[i] << ", x " << Pole_XPos[i] << endl;
+  }
+}
+
+void position_tof_bars(Int_t modType)
+{
+
+  TGeoTranslation* bar_trans = NULL;
+
+  Int_t numBars = 0;
+  Int_t i, j;
+  for (i = 0; i < NumberOfBars; i++) {
+
+    Float_t xPos = Bar_XPos[i];
+    Float_t zPos = Bar_ZPos[i];
+    Float_t yPos = Pole_Size_Y / 2. + Bar_Size_Y / 2.;
+
+    bar_trans = new TGeoTranslation("", xPos, yPos, zPos);
+    gGeoMan->GetVolume(geoVersion)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+
+    bar_trans = new TGeoTranslation("", xPos, -yPos, zPos);
+    gGeoMan->GetVolume(geoVersion)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+
+    bar_trans = new TGeoTranslation("", -xPos, yPos, zPos);
+    gGeoMan->GetVolume(geoVersion)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+
+    bar_trans = new TGeoTranslation("", -xPos, -yPos, zPos);
+    gGeoMan->GetVolume(geoVersion)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+  }
+  cout << " Position Bar " << numBars << " at z=" << Bar_ZPos[i] << endl;
+
+  // outer horizontal and vertical frame bars
+
+  NumberOfBars++;
+  i               = NumberOfBars;
+  gBar[i]         = create_tof_bar(Frame_XLen, Frame_Size_Y, Frame_Size_Y);  // Outer frame big bar along X
+  j               = i + 1;
+  gBar[j]         = create_tof_bar(Frame_Size_X, Frame_YLen, Frame_Size_Y);  // Outer frame big bar along Y
+  Float_t numBarY = 0;
+  numBars         = 0;
+
+  for (Float_t dZ = -1.; dZ < 2.; dZ += 2.) {
+    Float_t zPos = Frame_Pos_Z - dZ * (Bar_Size_Z / 2. - 10.);
+    Float_t yPos = Frame_YLen / 2. + Frame_Size_Y / 2;  // Make outer frame independent of the inner poles!!!!
+
+    // Outer Frame Top bar
+    bar_trans = new TGeoTranslation("", 0., yPos, zPos);
+    gGeoMan->GetVolume(geoVersion)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+
+    // Outer Frame Bottom bar
+    bar_trans = new TGeoTranslation("", 0., -yPos, zPos);
+    gGeoMan->GetVolume(geoVersion)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+
+    // Outer Frame Right bar
+    Float_t xPos = Frame_XLen / 2 - Frame_Size_Y / 2.;
+    bar_trans    = new TGeoTranslation("", xPos, 0., zPos);
+    gGeoMan->GetVolume(geoVersion)->AddNode(gBar[j], numBarY, bar_trans);
+    numBarY++;
+
+    // Outer Frame Left bar
+    bar_trans = new TGeoTranslation("", -xPos, 0., zPos);
+    gGeoMan->GetVolume(geoVersion)->AddNode(gBar[j], numBarY, bar_trans);
+    numBarY++;
+  }
+}
+
+void position_tof_modules()
+{
+  TGeoTranslation* module_trans = NULL;
+  TGeoRotation* module_rot0     = new TGeoRotation();
+  module_rot0->RotateZ(0.);
+  TGeoRotation* module_rot1 = new TGeoRotation();
+  module_rot1->RotateZ(180.);
+  TGeoCombiTrans* module_combi_trans = NULL;
+
+  //  if(modType != 0) continue; // debugging
+  for (int iModT = 0; iModT < NofModuleTypes; iModT++)
+    for (Int_t i = 0; i < MaxNofModules; i++) {
+      if (ModType[i] != iModT) continue;  // process ModTypes in order
+      // for(Int_t i=0; i<5; i++) {
+      //if(i != 0) continue; // debugging
+      Float_t xPos = xPosMod[i];
+      Float_t yPos = yPosMod[i];
+      Float_t zPos = zPosMod[i] - 884.0 + TOF_Z_Front;
+      //cout<<"Place Mod Type "<<j<<" at x "<<xPos<<", y "<<yPos<<", z "<<zPos<<", Flip "<<FlipMod[j][i]<<endl;
+
+      module_trans = new TGeoTranslation("", xPos, yPos, zPos);
+      if (ModType[i] < 5 && xPosMod[i] < 0.0) { module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot1); }
+      else {
+        module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot0);
+      }
+      cout << "AddModule " << i << "   ModType  " << ModType[i] << "  iMod:  " << iMod[ModType[i]] << endl;
+      gGeoMan->GetVolume(geoVersion)->AddNode(gModules[ModType[i]], iMod[ModType[i]], module_combi_trans);
+      iMod[ModType[i]]++;
+
+      if (iMod[ModType[i]] > NModulesOfModuleType[ModType[i]]) {
+        cout << "Inconsistent number of modules " << endl;
+        break;
+      }
+    }
+}
+
+void dump_info_file()
+{
+  TDatime datetime;  // used to get timestamp
+
+  printf("writing info file: %s\n", FileNameInfo.Data());
+
+  FILE* ifile;
+  ifile = fopen(FileNameInfo.Data(), "w");
+
+  if (ifile == NULL) {
+    printf("error opening %s\n", FileNameInfo.Data());
+    exit(1);
+  }
+
+  fprintf(ifile, "#\n##   %s information file\n#\n\n", geoVersion.Data());
+
+  fprintf(ifile, "# created %d\n\n", datetime.GetDate());
+
+  fprintf(ifile, "# TOF setup\n");
+  if (TOF_Z_Front == 450) fprintf(ifile, "SIS 100 hadron setup\n");
+  if (TOF_Z_Front == 600) fprintf(ifile, "SIS 100 electron\n");
+  if (TOF_Z_Front == 650) fprintf(ifile, "SIS 100 muon\n");
+  if (TOF_Z_Front == 880) fprintf(ifile, "SIS 300 electron\n");
+  if (TOF_Z_Front == 1020) fprintf(ifile, "SIS 300 muon\n");
+  fprintf(ifile, "\n");
+
+  const Float_t TOF_Z_Back = TOF_Z_Front + 176.5;  // back of TOF wall
+
+  fprintf(ifile, "# envelope\n");
+  // Show extension of TRD
+  fprintf(ifile, "%7.2f cm   start of TOF (z)\n", TOF_Z_Front - 10.);
+  fprintf(ifile, "%7.2f cm   end   of TOF (z)\n", TOF_Z_Back + 10.);
+  fprintf(ifile, "\n");
+
+  // Layer thickness
+  fprintf(ifile, "# central tower position\n");
+  fprintf(ifile, "%7.2f cm   center of staggered, front RPC cell at x=0\n", Wall_Z_Position);
+  fprintf(ifile, "\n");
+
+  fclose(ifile);
+}
diff --git a/macro/tof/geometry/Create_TOF_Geometry_v21a_cosmicHD.C b/macro/tof/geometry/Create_TOF_Geometry_v21a_cosmicHD.C
new file mode 100644
index 0000000000..4190406a17
--- /dev/null
+++ b/macro/tof/geometry/Create_TOF_Geometry_v21a_cosmicHD.C
@@ -0,0 +1,1365 @@
+/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Norbert Herrmann [committer] */
+
+///
+/// \file derived from Create_TOF_Geometry_v18m_mCbm.C
+/// \brief Generates TOF geometry in Root format.
+///
+
+// Changelog
+//
+
+// in root all sizes are given in cm
+
+#include "TFile.h"
+#include "TGeoCompositeShape.h"
+#include "TGeoManager.h"
+#include "TGeoMaterial.h"
+#include "TGeoMatrix.h"
+#include "TGeoMedium.h"
+#include "TGeoPgon.h"
+#include "TGeoVolume.h"
+#include "TList.h"
+#include "TMath.h"
+#include "TROOT.h"
+#include "TString.h"
+#include "TSystem.h"
+
+#include <iostream>
+
+// Name of geometry version and output file
+const TString geoVersion      = "tof_v21a";  // do not change
+const TString geoVersionStand = geoVersion + "Stand";
+
+//
+const TString fileTag      = "tof_v21a";
+const TString FileNameSim  = fileTag + "_cosmicHD.root";
+const TString FileNameGeo  = fileTag + "_cosmicHD.geo.root";
+const TString FileNameInfo = fileTag + "_cosmicHD.info";
+
+// TOF_Z_Front corresponds to front cover of outer super module towers
+const Float_t TOF_Z_Front_Stand = 30;  // = z=298 mCBM@SIS18
+const Float_t TOF_Z_Front       = 30;
+//const Float_t TOF_Z_Front =  130;  // = z=225 mCBM@SIS18
+//const Float_t TOF_Z_Front =  250;  // SIS 100 hadron
+//const Float_t TOF_Z_Front =  450;  // SIS 100 hadron
+//const Float_t TOF_Z_Front =  600;  // SIS 100 electron
+//const Float_t TOF_Z_Front =  650;  // SIS 100 muon
+//const Float_t TOF_Z_Front =  880;  // SIS 300 electron
+//const Float_t TOF_Z_Front = 1020;  // SIS 300 muon
+//
+//const Float_t TOF_Z_Front = 951.5;   // Wall_Z_Position = 1050 cm
+
+
+// Names of the different used materials which are used to build the modules
+// The materials are defined in the global media.geo file
+const TString KeepingVolumeMedium = "air";
+const TString BoxVolumeMedium     = "aluminium";
+const TString NoActivGasMedium    = "RPCgas_noact";
+const TString ActivGasMedium      = "RPCgas";
+const TString GlasMedium          = "RPCglass";
+const TString ElectronicsMedium   = "carbon";
+
+// Counters:
+// 0 MRPC3a
+// 1 MRPC3b
+// 2
+// 3
+// 4 Diamond
+//
+// 6 Buc 2019
+// 7 CERN 20gap
+// 8 Ceramic Pad
+const Int_t NumberOfDifferentCounterTypes            = 9;
+const Float_t Glass_X[NumberOfDifferentCounterTypes] = {32., 52., 32., 32., 0.2, 32., 28.8, 20., 2.4};
+const Float_t Glass_Y[NumberOfDifferentCounterTypes] = {26.9, 53., 20., 10., 0.2, 10., 6., 20., 2.4};
+const Float_t Glass_Z[NumberOfDifferentCounterTypes] = {0.1, 0.1, 0.1, 0.1, 0.01, 0.1, 0.1, 0.1, 0.1};
+
+const Float_t GasGap_X[NumberOfDifferentCounterTypes] = {32., 52., 32., 32., 0.2, 32., 28.8, 20., 2.4};
+const Float_t GasGap_Y[NumberOfDifferentCounterTypes] = {26.9, 53., 20., 10., 0.2, 10., 6., 20., 2.4};
+const Float_t GasGap_Z[NumberOfDifferentCounterTypes] = {0.025, 0.025, 0.025, 0.025, 0.01, 0.02, 0.02, 0.02, 0.025};
+
+const Int_t NumberOfGaps[NumberOfDifferentCounterTypes] = {8, 8, 8, 8, 1, 8, 10, 20, 4};
+//const Int_t NumberOfGaps[NumberOfDifferentCounterTypes] = {1,1,1,1}; //deb
+const Int_t NumberOfReadoutStrips[NumberOfDifferentCounterTypes] = {32, 32, 32, 32, 80, 32, 32, 20, 1};
+//const Int_t NumberOfReadoutStrips[NumberOfDifferentCounterTypes] = {1,1,1,1}; //deb
+
+const Float_t SingleStackStartPosition_Z[NumberOfDifferentCounterTypes] = {-0.6, -0.6, -0.6, -0.6, -0.1,
+                                                                           -0.6, -0.6, -0.6, -1.};
+
+const Float_t Electronics_X[NumberOfDifferentCounterTypes] = {34.0, 53.0, 32.0, 32., 0.3, 0.1, 28.8, 20., 0.1};
+const Float_t Electronics_Y[NumberOfDifferentCounterTypes] = {5.0, 5.0, 1.0, 1., 0.1, 0.1, 1.0, 1.0, 0.1};
+const Float_t Electronics_Z[NumberOfDifferentCounterTypes] = {0.3, 0.3, 0.3, 0.3, 0.1, 0.1, 0.1, 0.1, 0.1};
+
+const Int_t NofModuleTypes = 10;
+// 0 mCBM module
+// 1 STAR module
+// 5 Diamond
+// 6 Buc
+// 7 CERN 20 gap
+// 8 Ceramic
+// 9 Star2
+// Aluminum box for all module types
+const Float_t Module_Size_X[NofModuleTypes] = {180., 102.15, 180., 180., 180., 5., 40., 30., 22.5, 100.};
+const Float_t Module_Size_Y[NofModuleTypes] = {49., 48.3, 74., 28., 18., 5., 12., 30., 11., 49.};
+const Float_t Module_Over_Y[NofModuleTypes] = {11.5, 11., 11., 4.5, 4.5, 0., 0., 0., 0., 0.};
+const Float_t Module_Size_Z[NofModuleTypes] = {11., 11.1, 13., 11., 11., 1., 12., 6., 6.2, 11.2};
+const Float_t Module_Thick_Alu_X_left       = 0.1;
+const Float_t Module_Thick_Alu_X_right      = 1.0;
+const Float_t Module_Thick_Alu_Y            = 0.1;
+const Float_t Module_Thick_Alu_Z            = 0.1;
+
+// Distance to the center of the TOF wall [cm];
+const Float_t Wall_Z_Position = 400.;
+const Float_t MeanTheta       = 0.;
+
+//Type of Counter for module
+const Int_t CounterTypeInModule[NofModuleTypes] = {0, 0, 1, 2, 3, 4, 6, 7, 8, 0};
+const Int_t NCounterInModule[NofModuleTypes]    = {5, 3, 3, 5, 5, 1, 2, 1, 8, 2};
+
+// Placement of the counter inside the module
+const Float_t CounterXStartPosition[NofModuleTypes] = {-60., -27.74, -56.0, -60.0, -60.0, 0.0, 0., 0., -7., 0.};
+const Float_t CounterXDistance[NofModuleTypes]      = {30., 30.5, 51.0, 30.0, 30.0, 0.0, 0., 0., 2., 0.};
+const Float_t CounterYStartPosition[NofModuleTypes] = {0.0, 0.0, 0.0, 0.0, 0.0, 0., 0., -4., -1.3, 0.};
+const Float_t CounterYDistance[NofModuleTypes]      = {0.0, 0.0, 0.0, 0.0, 0.0, 0., 0., 8., 0., 0.};
+const Float_t CounterZDistance[NofModuleTypes]      = {-2.5, 0.0, 0.0, 2.5, 2.5, 0., 6., 0., 0.1, 4.};
+const Float_t CounterZStartPosition[NofModuleTypes] = {0.0, 0.0, 0.0, 0.0, 0.0, 0., -3., 0., 0.0, -2.};
+const Float_t CounterRotationAngle[NofModuleTypes]  = {0., 10.0, 7.0, 0., 0., 0., 0., 0., 0., 0.};
+
+// Pole (support structure)
+const Int_t MaxNumberOfPoles = 20;
+Float_t Pole_ZPos[MaxNumberOfPoles];
+Float_t Pole_Col[MaxNumberOfPoles];
+Int_t NumberOfPoles = 0;
+
+const Float_t Pole_Size_X  = 20.;
+const Float_t Pole_Size_Y  = 300.;
+const Float_t Pole_Size_Z  = 10.;
+const Float_t Pole_Thick_X = 5.;
+const Float_t Pole_Thick_Y = 5.;
+const Float_t Pole_Thick_Z = 5.;
+
+// Bars (support structure)
+const Float_t Bar_Size_X = 20.;
+const Float_t Bar_Size_Y = 20.;
+Float_t Bar_Size_Z       = 100.;
+
+const Int_t MaxNumberOfBars = 20;
+Float_t Bar_ZPos[MaxNumberOfBars];
+Float_t Bar_XPos[MaxNumberOfBars];
+Int_t NumberOfBars = 0;
+
+const Float_t ChamberOverlap = 40;
+const Float_t DxColl         = 158.0;  //Module_Size_X-ChamberOverlap;
+//const Float_t Pole_Offset=Module_Size_X/2.+Pole_Size_X/2.;
+const Float_t Pole_Offset = 90.0 + Pole_Size_X / 2.;
+
+// Position for module placement
+const Float_t Inner_Module_First_Y_Position = 16.;
+const Float_t Inner_Module_Last_Y_Position  = 480.;
+const Float_t Inner_Module_X_Offset         = 0.;  // centered position in x/y
+//const Float_t Inner_Module_X_Offset=18; // shift by 16 cm in x
+const Int_t Inner_Module_NTypes                       = 3;
+const Float_t Inner_Module_Types[Inner_Module_NTypes] = {4., 3., 0.};
+//const Float_t Inner_Module_Number[Inner_Module_NTypes] = {2.,2.,6.}; //V13_3a
+const Float_t Inner_Module_Number[Inner_Module_NTypes] = {2., 2., 1.};  //V13_3a
+//const Float_t Inner_Module_Number[Inner_Module_NTypes] = {0.,0.,0.}; //debugging
+
+const Float_t InnerSide_Module_X_Offset                    = 51.;
+const Float_t InnerSide_Module_NTypes                      = 1;
+const Float_t InnerSide_Module_Types[Inner_Module_NTypes]  = {5.};
+const Float_t InnerSide_Module_Number[Inner_Module_NTypes] = {2.};  //v13_3a
+//const Float_t InnerSide_Module_Number[Inner_Module_NTypes] = {0.};  //debug
+
+const Float_t Outer_Module_First_Y_Position                              = 0.;
+const Float_t Outer_Module_Last_Y_Position                               = 480.;
+const Float_t Outer_Module_X_Offset                                      = 3.;
+const Int_t Outer_Module_Col                                             = 4;
+const Int_t Outer_Module_NTypes                                          = 2;
+const Float_t Outer_Module_Types[Outer_Module_NTypes][Outer_Module_Col]  = {1., 1., 1., 1., 2., 2., 2., 2.};
+const Float_t Outer_Module_Number[Outer_Module_NTypes][Outer_Module_Col] = {9., 9., 2., 0., 0., 0., 3., 4.};  //V13_3a
+//const Float_t Outer_Module_Number[Outer_Module_NTypes][Outer_Module_Col] = {1.,1.,0.,0.,  0.,0.,0.,0.};//debug
+
+const Float_t Star2_First_Z_Position       = TOF_Z_Front + 0.;
+const Float_t Star2_Delta_Z_Position[3]    = {0., 53.5, 35.};
+const Float_t Star2_First_Y_Position       = 0.;  //
+const Float_t Star2_Delta_Y_Position       = 0.;  //
+const Float_t Star2_rotate_Z               = 0.;
+const Int_t Star2_NTypes                   = 1;
+const Float_t Star2_Types[Star2_NTypes]    = {9.};
+const Float_t Star2_Number[Star2_NTypes]   = {2.};  //debugging, V16b
+const Float_t Star2_X_Offset[Star2_NTypes] = {0.};  //{62.};
+
+const Float_t Buc_First_Z_Position     = TOF_Z_Front + 48.4;
+const Float_t Buc_Delta_Z_Position     = 0.;
+const Float_t Buc_First_Y_Position     = 0.;  //
+const Float_t Buc_Delta_Y_Position     = 0.;  //
+const Float_t Buc_rotate_Z             = 180.;
+const Float_t Buc_rotate_X             = 180.;
+const Int_t Buc_NTypes                 = 1;
+const Float_t Buc_Types[Buc_NTypes]    = {6.};
+const Float_t Buc_Number[Buc_NTypes]   = {1.};  //debugging, V16b
+const Float_t Buc_X_Offset[Buc_NTypes] = {1.};
+
+const Int_t Cer_NTypes                   = 3;
+const Float_t Cer_Z_Position[Cer_NTypes] = {(float) (TOF_Z_Front + 13.2), (float) (TOF_Z_Front + 15.),
+                                            (float) (TOF_Z_Front + 15.)};
+const Float_t Cer_X_Position[Cer_NTypes] = {0., 0., 0.};
+const Float_t Cer_Y_Position[Cer_NTypes] = {-1., 0., 0.};
+const Float_t Cer_rotate_Z[Cer_NTypes]   = {0., 0., 0.};
+const Float_t Cer_Types[Cer_NTypes]      = {5., 8., 8.};
+const Float_t Cer_Number[Cer_NTypes]     = {1., 1., 1.};  //V16b
+
+const Float_t CERN_Z_Position          = TOF_Z_Front + 35.;  // 20 gap
+const Float_t CERN_First_Y_Position    = 0.;
+const Float_t CERN_X_Offset            = 3.2;  //65.5;
+const Float_t CERN_rotate_Z            = -90.;
+const Int_t CERN_NTypes                = 1;
+const Float_t CERN_Types[CERN_NTypes]  = {7.};  // this is the SmType!
+const Float_t CERN_Number[CERN_NTypes] = {1.};  // evtl. double for split signals
+
+const Float_t Star_First_Z_Position       = TOF_Z_Front - 12.;
+const Float_t Star_Delta_Z_Position       = 0;   //20.;
+const Float_t Star_First_Y_Position       = 0.;  //
+const Float_t Star_Delta_Y_Position       = 0.;  //
+const Float_t Star_rotate_Y               = 0;   //-6.8;
+const Float_t Star_rotate_Z               = 0.;
+const Int_t Star_NTypes                   = 1;
+const Float_t Star_Types[Star2_NTypes]    = {1.};
+const Float_t Star_Number[Star2_NTypes]   = {1.};
+const Float_t Star_X_Offset[Star2_NTypes] = {-5.};
+
+// some global variables
+TGeoManager* gGeoMan = NULL;           // Pointer to TGeoManager instance
+TGeoVolume* gModules[NofModuleTypes];  // Global storage for module types
+TGeoVolume* gCounter[NumberOfDifferentCounterTypes];
+TGeoVolume* gPole;
+TGeoVolume* gBar[MaxNumberOfBars];
+
+const Float_t Dia_Z_Position         = -0.5 - TOF_Z_Front_Stand;
+const Float_t Dia_First_Y_Position   = 0.;
+const Float_t Dia_X_Offset           = 0.;
+const Float_t Dia_rotate_Z           = 0.;
+const Int_t Dia_NTypes               = 1;
+const Float_t Dia_Types[Dia_NTypes]  = {5.};
+const Float_t Dia_Number[Dia_NTypes] = {1.};
+
+Float_t Last_Size_Y = 0.;
+Float_t Last_Over_Y = 0.;
+
+// Forward declarations
+void create_materials_from_media_file();
+TGeoVolume* create_counter(Int_t);
+TGeoVolume* create_new_counter(Int_t);
+TGeoVolume* create_tof_module(Int_t);
+TGeoVolume* create_new_tof_module(Int_t);
+TGeoVolume* create_tof_pole();
+TGeoVolume* create_tof_bar();
+void position_tof_poles(Int_t);
+void position_tof_bars(Int_t);
+void position_inner_tof_modules(Int_t);
+void position_side_tof_modules(Int_t);
+void position_outer_tof_modules(Int_t);
+void position_Dia(Int_t);
+void position_Star2(Int_t);
+void position_Star(Int_t);
+void position_Buc(Int_t);
+void position_cer_modules(Int_t);
+void position_CERN(Int_t);
+void dump_info_file();
+
+
+void Create_TOF_Geometry_v21a_cosmicHD()
+{
+  // Load the necessary FairRoot libraries
+  //  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
+  //  basiclibs();
+  //  gSystem->Load("libGeoBase");
+  //  gSystem->Load("libParBase");
+  //  gSystem->Load("libBase");
+
+  // Load needed material definition from media.geo file
+  create_materials_from_media_file();
+
+  // Get the GeoManager for later usage
+  gGeoMan = (TGeoManager*) gROOT->FindObject("FAIRGeom");
+  gGeoMan->SetVisLevel(5);  // 2 = super modules
+  gGeoMan->SetVisOption(0);
+
+  // Create the top volume
+  /*
+  TGeoBBox* topbox= new TGeoBBox("", 1000., 1000., 1000.);
+  TGeoVolume* top = new TGeoVolume("top", topbox, gGeoMan->GetMedium("air"));
+  gGeoMan->SetTopVolume(top);
+  */
+
+  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
+  gGeoMan->SetTopVolume(top);
+
+  TGeoRotation* tof_rotation = new TGeoRotation();
+  tof_rotation->RotateY(0.);  // angle with respect to beam axis
+                              //tof_rotation->RotateZ(   0 );   // electronics on  9 o'clock position = +x
+  //  tof_rotation->RotateZ(   0 );   // electronics on  9 o'clock position = +x
+  //  tof_rotation->RotateZ(  90 );   // electronics on 12 o'clock position (top)
+  //  tof_rotation->RotateZ( 180 );   // electronics on  3 o'clock position = -x
+  //  tof_rotation->RotateZ( 270 );   // electronics on  6 o'clock position (bottom)
+
+  TGeoVolume* tof = new TGeoVolumeAssembly(geoVersion);
+  top->AddNode(tof, 1, tof_rotation);
+
+  TGeoVolume* tofstand         = new TGeoVolumeAssembly(geoVersionStand);
+  TGeoTranslation* stand_trans = new TGeoTranslation("", 0., 0., TOF_Z_Front_Stand);
+  TGeoRotation* stand_rot      = new TGeoRotation();
+  stand_rot->RotateY(0.);
+  TGeoCombiTrans* stand_combi_trans = new TGeoCombiTrans(*stand_trans, *stand_rot);
+  tof->AddNode(tofstand, 1, stand_combi_trans);
+
+  for (Int_t counterType = 0; counterType < NumberOfDifferentCounterTypes; counterType++) {
+    gCounter[counterType] = create_new_counter(counterType);
+  }
+
+  for (Int_t moduleType = 0; moduleType < NofModuleTypes; moduleType++) {
+    gModules[moduleType] = create_new_tof_module(moduleType);
+    gModules[moduleType]->SetVisContainers(1);
+  }
+
+  // no pole
+  //  gPole = create_tof_pole();
+
+  //  position_side_tof_modules(1);  // keep order !!
+  //  position_inner_tof_modules(2);
+  //  position_inner_tof_modules(3);
+  //  position_Dia(1);
+  position_Star2(1);
+  //position_cer_modules(3);
+  // position_CERN(1);
+  // position_Buc(1);
+  // position_Star(1);
+
+  cout << "Outer Types " << Outer_Module_Types[0][0] << ", " << Outer_Module_Types[1][0]
+       << ", col=1:  " << Outer_Module_Types[0][1] << ", " << Outer_Module_Types[1][1] << endl;
+  cout << "Outer Number " << Outer_Module_Number[0][0] << ", " << Outer_Module_Number[1][0]
+       << ", col=1:  " << Outer_Module_Number[0][1] << ", " << Outer_Module_Number[1][1] << endl;
+  //  position_outer_tof_modules(4);
+  // position_tof_poles(0);
+  // position_tof_bars(0);
+
+  gGeoMan->CloseGeometry();
+  gGeoMan->CheckOverlaps(0.001);
+  gGeoMan->PrintOverlaps();
+  gGeoMan->Test();
+
+  TFile* outfile1 = new TFile(FileNameSim, "RECREATE");
+  top->Write();
+  //gGeoMan->Write();
+  outfile1->Close();
+
+  TFile* outfile2 = new TFile(FileNameGeo, "RECREATE");
+  gGeoMan->Write();
+  outfile2->Close();
+
+  dump_info_file();
+
+  top->SetVisContainers(1);
+  gGeoMan->SetVisLevel(5);
+  top->Draw("ogl");
+  //top->Draw();
+  //gModules[0]->Draw("ogl");
+  //  gModules[0]->Draw("");
+  gModules[0]->SetVisContainers(1);
+  //  gModules[1]->Draw("");
+  gModules[1]->SetVisContainers(1);
+  //gModules[5]->Draw("");
+  //  top->Raytrace();
+}
+
+void create_materials_from_media_file()
+{
+  // Use the FairRoot geometry interface to load the media which are already defined
+  FairGeoLoader* geoLoad    = new FairGeoLoader("TGeo", "FairGeoLoader");
+  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
+  TString geoPath           = gSystem->Getenv("VMCWORKDIR");
+  TString geoFile           = geoPath + "/geometry/media.geo";
+  geoFace->setMediaFile(geoFile);
+  geoFace->readMedia();
+
+  // Read the required media and create them in the GeoManager
+  FairGeoMedia* geoMedia   = geoFace->getMedia();
+  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
+
+  FairGeoMedium* air          = geoMedia->getMedium("air");
+  FairGeoMedium* aluminium    = geoMedia->getMedium("aluminium");
+  FairGeoMedium* RPCgas       = geoMedia->getMedium("RPCgas");
+  FairGeoMedium* RPCgas_noact = geoMedia->getMedium("RPCgas_noact");
+  FairGeoMedium* RPCglass     = geoMedia->getMedium("RPCglass");
+  FairGeoMedium* carbon       = geoMedia->getMedium("carbon");
+
+  // include check if all media are found
+
+  geoBuild->createMedium(air);
+  geoBuild->createMedium(aluminium);
+  geoBuild->createMedium(RPCgas);
+  geoBuild->createMedium(RPCgas_noact);
+  geoBuild->createMedium(RPCglass);
+  geoBuild->createMedium(carbon);
+}
+
+TGeoVolume* create_counter(Int_t modType)
+{
+
+  //glass
+  Float_t gdx = Glass_X[modType];
+  Float_t gdy = Glass_Y[modType];
+  Float_t gdz = Glass_Z[modType];
+
+  //gas gap
+  Int_t nstrips = NumberOfReadoutStrips[modType];
+  Int_t ngaps   = NumberOfGaps[modType];
+
+
+  Float_t ggdx = GasGap_X[modType];
+  Float_t ggdy = GasGap_Y[modType];
+  Float_t ggdz = GasGap_Z[modType];
+  Float_t gsdx = ggdx / float(nstrips);
+
+  //single stack
+  Float_t dzpos     = gdz + ggdz;
+  Float_t startzpos = SingleStackStartPosition_Z[modType];
+
+  // electronics
+  //pcb dimensions
+  Float_t dxe  = Electronics_X[modType];
+  Float_t dye  = Electronics_Y[modType];
+  Float_t dze  = Electronics_Z[modType];
+  Float_t yele = (gdy + 0.1) / 2. + dye / 2.;
+
+  // needed materials
+  TGeoMedium* glassPlateVolMed  = gGeoMan->GetMedium(GlasMedium);
+  TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
+  TGeoMedium* activeGasVolMed   = gGeoMan->GetMedium(ActivGasMedium);
+  TGeoMedium* electronicsVolMed = gGeoMan->GetMedium(ElectronicsMedium);
+
+  // Single glass plate
+  TGeoBBox* glass_plate       = new TGeoBBox("", gdx / 2., gdy / 2., gdz / 2.);
+  TGeoVolume* glass_plate_vol = new TGeoVolume("tof_glass", glass_plate, glassPlateVolMed);
+  glass_plate_vol->SetLineColor(kMagenta);  // set line color for the glass plate
+  glass_plate_vol->SetTransparency(20);     // set transparency for the TOF
+  TGeoTranslation* glass_plate_trans = new TGeoTranslation("", 0., 0., 0.);
+
+  // Single gas gap
+  TGeoBBox* gas_gap = new TGeoBBox("", ggdx / 2., ggdy / 2., ggdz / 2.);
+  //TGeoVolume* gas_gap_vol =
+  //new TGeoVolume("tof_gas_gap", gas_gap, noActiveGasVolMed);
+  TGeoVolume* gas_gap_vol = new TGeoVolume("tof_gas_active", gas_gap, activeGasVolMed);
+  gas_gap_vol->Divide("Strip", 1, nstrips, -ggdx / 2., 0);
+
+  gas_gap_vol->SetLineColor(kRed);   // set line color for the gas gap
+  gas_gap_vol->SetTransparency(70);  // set transparency for the TOF
+  TGeoTranslation* gas_gap_trans = new TGeoTranslation("", 0., 0., (gdz + ggdz) / 2.);
+
+
+  // Single subdivided active gas gap
+  /*
+    TGeoBBox* gas_active = new TGeoBBox("", gsdx/2., ggdy/2., ggdz/2.);
+    TGeoVolume* gas_active_vol = 
+    new TGeoVolume("tof_gas_active", gas_active, activeGasVolMed);
+  gas_active_vol->SetLineColor(kBlack); // set line color for the gas gap
+  gas_active_vol->SetTransparency(70); // set transparency for the TOF
+  */
+
+  // Add glass plate, inactive gas gap and active gas gaps to a single stack
+  TGeoVolume* single_stack = new TGeoVolumeAssembly("single_stack");
+  single_stack->AddNode(glass_plate_vol, 0, glass_plate_trans);
+  single_stack->AddNode(gas_gap_vol, 0, gas_gap_trans);
+
+  /*
+  for (Int_t l=0; l<nstrips; l++){
+    TGeoTranslation* gas_active_trans 
+      = new TGeoTranslation("", -ggdx/2+(l+0.5)*gsdx, 0., 0.);
+    gas_gap_vol->AddNode(gas_active_vol, l, gas_active_trans);
+    //    single_stack->AddNode(gas_active_vol, l, gas_active_trans);
+  }
+  */
+
+  // Add 8 single stacks + one glass plate at the e09.750nd to a multi stack
+  TGeoVolume* multi_stack = new TGeoVolumeAssembly("multi_stack");
+  Int_t l;
+  for (l = 0; l < ngaps; l++) {
+    TGeoTranslation* single_stack_trans = new TGeoTranslation("", 0., 0., startzpos + l * dzpos);
+    multi_stack->AddNode(single_stack, l, single_stack_trans);
+  }
+  TGeoTranslation* single_glass_back_trans = new TGeoTranslation("", 0., 0., startzpos + ngaps * dzpos);
+  multi_stack->AddNode(glass_plate_vol, l, single_glass_back_trans);
+
+  // Add electronics above and below the glass stack to build a complete counter
+  TGeoVolume* counter                = new TGeoVolumeAssembly("counter");
+  TGeoTranslation* multi_stack_trans = new TGeoTranslation("", 0., 0., 0.);
+  counter->AddNode(multi_stack, l, multi_stack_trans);
+
+  TGeoBBox* pcb       = new TGeoBBox("", dxe / 2., dye / 2., dze / 2.);
+  TGeoVolume* pcb_vol = new TGeoVolume("pcb", pcb, electronicsVolMed);
+  pcb_vol->SetLineColor(kCyan);  // set line color for the gas gap
+  pcb_vol->SetTransparency(10);  // set transparency for the TOF
+  for (Int_t l = 0; l < 2; l++) {
+    yele *= -1.;
+    TGeoTranslation* pcb_trans = new TGeoTranslation("", 0., yele, 0.);
+    counter->AddNode(pcb_vol, l, pcb_trans);
+  }
+
+  return counter;
+}
+
+TGeoVolume* create_new_counter(Int_t modType)
+{
+
+  //glass
+  Float_t gdx = Glass_X[modType];
+  Float_t gdy = Glass_Y[modType];
+  Float_t gdz = Glass_Z[modType];
+
+  //gas gap
+  Int_t nstrips = NumberOfReadoutStrips[modType];
+  Int_t ngaps   = NumberOfGaps[modType];
+
+
+  Float_t ggdx = GasGap_X[modType];
+  Float_t ggdy = GasGap_Y[modType];
+  Float_t ggdz = GasGap_Z[modType];
+  Float_t gsdx = ggdx / (Float_t)(nstrips);
+
+  // electronics
+  //pcb dimensions
+  Float_t dxe  = Electronics_X[modType];
+  Float_t dye  = Electronics_Y[modType];
+  Float_t dze  = Electronics_Z[modType];
+  Float_t yele = gdy / 2. + dye / 2.;
+
+  // counter size (calculate from glas, gap and electronics sizes)
+  Float_t cdx = TMath::Max(gdx, ggdx);
+  cdx         = TMath::Max(cdx, dxe) + 0.2;
+  Float_t cdy = TMath::Max(gdy, ggdy) + 2 * dye + 0.2;
+  Float_t cdz = ngaps * ggdz + (ngaps + 1) * gdz + 0.2;  // ngaps * (gdz+ggdz) + gdz + 0.2; // ok
+
+  //calculate thickness and first position in counter of single stack
+  Float_t dzpos         = gdz + ggdz;
+  Float_t startzposglas = -ngaps * (gdz + ggdz) / 2.;  // -cdz/2.+0.1+gdz/2.; // ok  // (-cdz+gdz)/2.; // not ok
+  Float_t startzposgas  = startzposglas + gdz / 2. + ggdz / 2.;  // -cdz/2.+0.1+gdz   +ggdz/2.;  // ok
+
+
+  // needed materials
+  TGeoMedium* glassPlateVolMed  = gGeoMan->GetMedium(GlasMedium);
+  TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
+  TGeoMedium* activeGasVolMed   = gGeoMan->GetMedium(ActivGasMedium);
+  TGeoMedium* electronicsVolMed = gGeoMan->GetMedium(ElectronicsMedium);
+
+
+  // define counter volume
+  TGeoBBox* counter_box = new TGeoBBox("", cdx / 2., cdy / 2., cdz / 2.);
+  TGeoVolume* counter   = new TGeoVolume("counter", counter_box, noActiveGasVolMed);
+  counter->SetLineColor(kCyan);  // set line color for the counter
+  counter->SetTransparency(70);  // set transparency for the TOF
+
+  // define single glass plate volume
+  TGeoBBox* glass_plate       = new TGeoBBox("", gdx / 2., gdy / 2., gdz / 2.);
+  TGeoVolume* glass_plate_vol = new TGeoVolume("tof_glass", glass_plate, glassPlateVolMed);
+  glass_plate_vol->SetLineColor(kMagenta);  // set line color for the glass plate
+  glass_plate_vol->SetTransparency(20);     // set transparency for the TOF
+  // define single gas gap volume
+  TGeoBBox* gas_gap       = new TGeoBBox("", ggdx / 2., ggdy / 2., ggdz / 2.);
+  TGeoVolume* gas_gap_vol = new TGeoVolume("Gap", gas_gap, activeGasVolMed);
+  gas_gap_vol->Divide("Cell", 1, nstrips, -ggdx / 2., 0);
+  gas_gap_vol->SetLineColor(kRed);   // set line color for the gas gap
+  gas_gap_vol->SetTransparency(99);  // set transparency for the TOF
+
+  // place 8 gas gaps and 9 glas plates in the counter
+  for (Int_t igap = 0; igap <= ngaps; igap++) {
+    // place (ngaps+1) glass plates
+    Float_t zpos_glas                  = startzposglas + igap * dzpos;
+    TGeoTranslation* glass_plate_trans = new TGeoTranslation("", 0., 0., zpos_glas);
+    counter->AddNode(glass_plate_vol, igap, glass_plate_trans);
+    // place ngaps gas gaps
+    if (igap < ngaps) {
+      Float_t zpos_gas               = startzposgas + igap * dzpos;
+      TGeoTranslation* gas_gap_trans = new TGeoTranslation("", 0., 0., zpos_gas);
+      counter->AddNode(gas_gap_vol, igap, gas_gap_trans);
+    }
+    //    cout <<"Zpos(Glas): "<< zpos_glas << endl;
+    //    cout <<"Zpos(Gas): "<< zpos_gas << endl;
+  }
+
+  // create and place the electronics above and below the glas stack
+  TGeoBBox* pcb       = new TGeoBBox("", dxe / 2., dye / 2., dze / 2.);
+  TGeoVolume* pcb_vol = new TGeoVolume("pcb", pcb, electronicsVolMed);
+  pcb_vol->SetLineColor(kYellow);  // kCyan); // set line color for electronics
+  pcb_vol->SetTransparency(10);    // set transparency for the TOF
+  for (Int_t l = 0; l < 2; l++) {
+    yele *= -1.;
+    TGeoTranslation* pcb_trans = new TGeoTranslation("", 0., yele, 0.);
+    counter->AddNode(pcb_vol, l, pcb_trans);
+  }
+
+
+  return counter;
+}
+
+TGeoVolume* create_tof_module(Int_t modType)
+{
+  Int_t cType         = CounterTypeInModule[modType];
+  Float_t dx          = Module_Size_X[modType];
+  Float_t dy          = Module_Size_Y[modType];
+  Float_t dz          = Module_Size_Z[modType];
+  Float_t width_aluxl = Module_Thick_Alu_X_left;
+  Float_t width_aluxr = Module_Thick_Alu_X_right;
+  Float_t width_aluy  = Module_Thick_Alu_Y;
+  Float_t width_aluz  = Module_Thick_Alu_Z;
+
+  Float_t shift_gas_box = (Module_Thick_Alu_X_right - Module_Thick_Alu_X_left) / 2;
+
+  Float_t dxpos     = CounterXDistance[modType];
+  Float_t startxpos = CounterXStartPosition[modType];
+  Float_t dzoff     = CounterZDistance[modType];
+  Float_t rotangle  = CounterRotationAngle[modType];
+
+  TGeoMedium* boxVolMed         = gGeoMan->GetMedium(BoxVolumeMedium);
+  TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
+
+  TString moduleName = Form("module_%d", modType);
+  TGeoVolume* module = new TGeoVolumeAssembly(moduleName);
+
+  TGeoBBox* alu_box       = new TGeoBBox("", dx / 2., dy / 2., dz / 2.);
+  TGeoVolume* alu_box_vol = new TGeoVolume("alu_box", alu_box, boxVolMed);
+  alu_box_vol->SetLineColor(kGreen);  // set line color for the alu box
+  alu_box_vol->SetTransparency(20);   // set transparency for the TOF
+  TGeoTranslation* alu_box_trans = new TGeoTranslation("", 0., 0., 0.);
+  module->AddNode(alu_box_vol, 0, alu_box_trans);
+
+  TGeoBBox* gas_box =
+    new TGeoBBox("", (dx - (width_aluxl + width_aluxr)) / 2., (dy - 2 * width_aluy) / 2., (dz - 2 * width_aluz) / 2.);
+  TGeoVolume* gas_box_vol = new TGeoVolume("gas_box", gas_box, noActiveGasVolMed);
+  gas_box_vol->SetLineColor(kYellow);  // set line color for the gas box
+  gas_box_vol->SetTransparency(70);    // set transparency for the TOF
+  TGeoTranslation* gas_box_trans = new TGeoTranslation("", shift_gas_box, 0., 0.);
+  alu_box_vol->AddNode(gas_box_vol, 0, gas_box_trans);
+
+  for (Int_t j = 0; j < 5; j++) {  //loop over counters (modules)
+    Float_t zpos;
+    if (0 == modType) { zpos = dzoff *= -1; }
+    else {
+      zpos = 0.;
+    }
+    //cout << "counter z position " << zpos << endl;
+    TGeoTranslation* counter_trans = new TGeoTranslation("", startxpos + j * dxpos, 0.0, zpos);
+
+    TGeoRotation* counter_rot = new TGeoRotation();
+    counter_rot->RotateY(rotangle);
+    TGeoCombiTrans* counter_combi_trans = new TGeoCombiTrans(*counter_trans, *counter_rot);
+    gas_box_vol->AddNode(gCounter[cType], j, counter_combi_trans);
+  }
+
+  return module;
+}
+
+TGeoVolume* create_new_tof_module(Int_t modType)
+{
+  Int_t cType         = CounterTypeInModule[modType];
+  Float_t dx          = Module_Size_X[modType];
+  Float_t dy          = Module_Size_Y[modType];
+  Float_t dz          = Module_Size_Z[modType];
+  Float_t width_aluxl = Module_Thick_Alu_X_left;
+  Float_t width_aluxr = Module_Thick_Alu_X_right;
+  Float_t width_aluy  = Module_Thick_Alu_Y;
+  Float_t width_aluz  = Module_Thick_Alu_Z;
+
+  Float_t shift_gas_box = (Module_Thick_Alu_X_right - Module_Thick_Alu_X_left) / 2;
+
+  Float_t dxpos     = CounterXDistance[modType];
+  Float_t startxpos = CounterXStartPosition[modType];
+  Float_t dypos     = CounterYDistance[modType];
+  Float_t startypos = CounterYStartPosition[modType];
+  Float_t dzoff     = CounterZDistance[modType];
+  Float_t rotangle  = CounterRotationAngle[modType];
+
+  TGeoMedium* boxVolMed         = gGeoMan->GetMedium(BoxVolumeMedium);
+  TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
+
+  TString moduleName = Form("module_%d", modType);
+
+  TGeoBBox* module_box = new TGeoBBox("", dx / 2., dy / 2., dz / 2.);
+  TGeoVolume* module   = new TGeoVolume(moduleName, module_box, boxVolMed);
+  module->SetLineColor(kGreen);  // set line color for the alu box
+  module->SetTransparency(20);   // set transparency for the TOF
+
+  TGeoBBox* gas_box =
+    new TGeoBBox("", (dx - (width_aluxl + width_aluxr)) / 2., (dy - 2 * width_aluy) / 2., (dz - 2 * width_aluz) / 2.);
+  TGeoVolume* gas_box_vol = new TGeoVolume("gas_box", gas_box, noActiveGasVolMed);
+  gas_box_vol->SetLineColor(kBlue);  // set line color for the alu box
+  gas_box_vol->SetTransparency(50);  // set transparency for the TOF
+  TGeoTranslation* gas_box_trans = new TGeoTranslation("", shift_gas_box, 0., 0.);
+  module->AddNode(gas_box_vol, 0, gas_box_trans);
+
+  for (Int_t j = 0; j < NCounterInModule[modType]; j++) {  //loop over counters (modules)
+                                                           //for (Int_t j=0; j< 1; j++){ //loop over counters (modules)
+    Float_t xpos, ypos, zpos;
+    if (0 == modType || 3 == modType || 4 == modType || 5 == modType) { zpos = dzoff *= -1; }
+    else {
+      zpos = CounterZStartPosition[modType] + j * dzoff;
+    }
+    //cout << "counter z position " << zpos << endl;
+    xpos = startxpos + j * dxpos;
+    ypos = startypos + j * dypos;
+
+    TGeoTranslation* counter_trans = new TGeoTranslation("", xpos, ypos, zpos);
+
+    TGeoRotation* counter_rot = new TGeoRotation();
+    counter_rot->RotateY(rotangle);
+    TGeoCombiTrans* counter_combi_trans = new TGeoCombiTrans(*counter_trans, *counter_rot);
+    gas_box_vol->AddNode(gCounter[cType], j, counter_combi_trans);
+  }
+
+  return module;
+}
+
+
+TGeoVolume* create_tof_pole()
+{
+  // needed materials
+  TGeoMedium* boxVolMed = gGeoMan->GetMedium(BoxVolumeMedium);
+  TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium);
+
+  Float_t dx         = Pole_Size_X;
+  Float_t dy         = Pole_Size_Y;
+  Float_t dz         = Pole_Size_Z;
+  Float_t width_alux = Pole_Thick_X;
+  Float_t width_aluy = Pole_Thick_Y;
+  Float_t width_aluz = Pole_Thick_Z;
+
+  TGeoVolume* pole         = new TGeoVolumeAssembly("Pole");
+  TGeoBBox* pole_alu_box   = new TGeoBBox("", dx / 2., dy / 2., dz / 2.);
+  TGeoVolume* pole_alu_vol = new TGeoVolume("pole_alu", pole_alu_box, boxVolMed);
+  pole_alu_vol->SetLineColor(kGreen);  // set line color for the alu box
+  pole_alu_vol->SetTransparency(20);   // set transparency for the TOF
+  TGeoTranslation* pole_alu_trans = new TGeoTranslation("", 0., 0., 0.);
+  pole->AddNode(pole_alu_vol, 0, pole_alu_trans);
+
+  Float_t air_dx = dx / 2. - width_alux;
+  Float_t air_dy = dy / 2. - width_aluy;
+  Float_t air_dz = dz / 2. - width_aluz;
+
+  //  cout << "My pole." << endl;
+  if (air_dx <= 0.) cout << "ERROR - No air volume in pole X, size: " << air_dx << endl;
+  if (air_dy <= 0.) cout << "ERROR - No air volume in pole Y, size: " << air_dy << endl;
+  if (air_dz <= 0.) cout << "ERROR - No air volume in pole Z, size: " << air_dz << endl;
+
+  if ((air_dx > 0.) && (air_dy > 0.) && (air_dz > 0.))  // crate air volume only, if larger than zero
+  {
+    TGeoBBox* pole_air_box = new TGeoBBox("", air_dx, air_dy, air_dz);
+    //  TGeoBBox* pole_air_box = new TGeoBBox("", dx/2.-width_alux, dy/2.-width_aluy, dz/2.-width_aluz);
+    TGeoVolume* pole_air_vol = new TGeoVolume("pole_air", pole_air_box, airVolMed);
+    pole_air_vol->SetLineColor(kYellow);  // set line color for the alu box
+    pole_air_vol->SetTransparency(70);    // set transparency for the TOF
+    TGeoTranslation* pole_air_trans = new TGeoTranslation("", 0., 0., 0.);
+    pole_alu_vol->AddNode(pole_air_vol, 0, pole_air_trans);
+  }
+  else
+    cout << "Skipping pole_air_vol, no thickness: " << air_dx << " " << air_dy << " " << air_dz << endl;
+
+  return pole;
+}
+
+TGeoVolume* create_tof_bar(Float_t dx, Float_t dy, Float_t dz)
+{
+  // needed materials
+  TGeoMedium* boxVolMed = gGeoMan->GetMedium(BoxVolumeMedium);
+  TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium);
+
+  Float_t width_alux = Pole_Thick_X;
+  Float_t width_aluy = Pole_Thick_Y;
+  Float_t width_aluz = Pole_Thick_Z;
+
+  TGeoVolume* bar         = new TGeoVolumeAssembly("Bar");
+  TGeoBBox* bar_alu_box   = new TGeoBBox("", dx / 2., dy / 2., dz / 2.);
+  TGeoVolume* bar_alu_vol = new TGeoVolume("bar_alu", bar_alu_box, boxVolMed);
+  bar_alu_vol->SetLineColor(kGreen);  // set line color for the alu box
+  bar_alu_vol->SetTransparency(20);   // set transparency for the TOF
+  TGeoTranslation* bar_alu_trans = new TGeoTranslation("", 0., 0., 0.);
+  bar->AddNode(bar_alu_vol, 0, bar_alu_trans);
+
+  TGeoBBox* bar_air_box   = new TGeoBBox("", dx / 2. - width_alux, dy / 2. - width_aluy, dz / 2. - width_aluz);
+  TGeoVolume* bar_air_vol = new TGeoVolume("bar_air", bar_air_box, airVolMed);
+  bar_air_vol->SetLineColor(kYellow);  // set line color for the alu box
+  bar_air_vol->SetTransparency(70);    // set transparency for the TOF
+  TGeoTranslation* bar_air_trans = new TGeoTranslation("", 0., 0., 0.);
+  bar_alu_vol->AddNode(bar_air_vol, 0, bar_air_trans);
+
+  return bar;
+}
+
+void position_tof_poles(Int_t modType)
+{
+
+  TGeoTranslation* pole_trans = NULL;
+
+  Int_t numPoles = 0;
+  for (Int_t i = 0; i < NumberOfPoles; i++) {
+    if (i < 2) {
+      pole_trans = new TGeoTranslation("", -Pole_Offset + 2.0, 0., Pole_ZPos[i]);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gPole, numPoles, pole_trans);
+      numPoles++;
+    }
+    else {
+      Float_t xPos = Pole_Offset + Pole_Size_X / 2. + Pole_Col[i] * DxColl;
+      Float_t zPos = Pole_ZPos[i];
+      pole_trans   = new TGeoTranslation("", xPos, 0., zPos);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gPole, numPoles, pole_trans);
+      numPoles++;
+
+      pole_trans = new TGeoTranslation("", -xPos, 0., zPos);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gPole, numPoles, pole_trans);
+      numPoles++;
+    }
+    cout << " Position Pole " << numPoles << " at z=" << Pole_ZPos[i] << endl;
+  }
+}
+
+void position_tof_bars(Int_t modType)
+{
+
+  TGeoTranslation* bar_trans = NULL;
+
+  Int_t numBars = 0;
+  Int_t i;
+  Float_t xPos;
+  Float_t yPos;
+  Float_t zPos;
+
+  for (i = 0; i < NumberOfBars; i++) {
+
+    xPos = Bar_XPos[i];
+    zPos = Bar_ZPos[i];
+    yPos = Pole_Size_Y / 2. + Bar_Size_Y / 2.;
+
+    bar_trans = new TGeoTranslation("", xPos, yPos, zPos);
+    gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+
+    bar_trans = new TGeoTranslation("", xPos, -yPos, zPos);
+    gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+
+    bar_trans = new TGeoTranslation("", -xPos, yPos, zPos);
+    gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+
+    bar_trans = new TGeoTranslation("", -xPos, -yPos, zPos);
+    gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans);
+    numBars++;
+  }
+  cout << " Position Bar " << numBars << " at z=" << Bar_ZPos[i] << endl;
+
+  // horizontal frame bars
+  i = NumberOfBars;
+  NumberOfBars++;
+  // no bar
+  //   gBar[i]=create_tof_bar(2.*xPos+Pole_Size_X,Bar_Size_Y,Bar_Size_Y);
+
+  zPos      = Pole_ZPos[0] + Pole_Size_Z / 2.;
+  bar_trans = new TGeoTranslation("", 0., yPos, zPos);
+  gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans);
+  numBars++;
+
+  bar_trans = new TGeoTranslation("", 0., -yPos, zPos);
+  gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans);
+  numBars++;
+}
+
+void position_inner_tof_modules(Int_t modNType)
+{
+  TGeoTranslation* module_trans = NULL;
+
+  //  Int_t numModules=(Int_t)( (Inner_Module_Last_Y_Position-Inner_Module_First_Y_Position)/Module_Size_Y[modType])+1;
+  Float_t yPos = Inner_Module_First_Y_Position;
+  Int_t ii     = 0;
+  Float_t xPos = Inner_Module_X_Offset;
+  Float_t zPos = Wall_Z_Position;
+
+  Pole_ZPos[NumberOfPoles] = zPos;
+  Pole_Col[NumberOfPoles]  = 0;
+  NumberOfPoles++;
+
+  Float_t DzPos = 0.;
+  for (Int_t j = 0; j < modNType; j++) {
+    if (Module_Size_Z[j] > DzPos) { DzPos = Module_Size_Z[j]; }
+  }
+  Pole_ZPos[NumberOfPoles] = zPos + DzPos;
+  Pole_Col[NumberOfPoles]  = 0;
+  NumberOfPoles++;
+
+  // for (Int_t j=0; j<modNType; j++){
+  // for (Int_t j=1; j<modNType; j++){
+  Int_t modType;
+  Int_t modNum;
+  for (Int_t j = 2; j < modNType; j++) {  // place only M4 type modules (modNType == 2)
+                                          //DEDE
+    modType = Inner_Module_Types[j];
+    modNum  = 0;
+    //  for(Int_t i=0; i<Inner_Module_Number[j]; i++) {
+    //  for(Int_t i=0; i<1; i++) { // place 1x2 modules in the top and same in the bottom
+    for (Int_t i = 0; i < 2; i++) {  // place 2x2 modules in the top and same in the bottom
+      ii++;
+      cout << "Inner ii " << ii << " Last " << Last_Size_Y << ", " << Last_Over_Y << endl;
+      Float_t DeltaY = Module_Size_Y[modType] + Last_Size_Y - 2. * (Module_Over_Y[modType] + Last_Over_Y);
+      //    DeltaY = 1.5;
+      cout << "DeltaY " << DeltaY << endl;
+      yPos += DeltaY;
+      Last_Size_Y = Module_Size_Y[modType];
+      Last_Over_Y = Module_Over_Y[modType];
+      cout << "Position Inner Module " << i << " of " << Inner_Module_Number[j] << " Type " << modType
+           << " at Y = " << yPos << " Ysize = " << Module_Size_Y[modType] << " DeltaY = " << DeltaY << endl;
+
+      ///    module_trans = new TGeoTranslation("", xPos, yPos, zPos);
+      ///    gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+      ///    modNum++;
+      ///    module_trans = new TGeoTranslation("", xPos, -yPos, zPos);
+      ///    gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+      ///    modNum++;
+      //    //    if (ii>0) {
+      //    if (ii>1) {
+      //      module_trans
+      //	= new TGeoTranslation("", xPos, yPos-DeltaY/2, zPos+Module_Size_Z[modType]);
+      //      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+      //    modNum++;
+      //      module_trans
+      //	= new TGeoTranslation("", xPos, -(yPos-DeltaY/2), zPos+Module_Size_Z[modType]);
+      //      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+      //    modNum++;
+      //    }
+    }
+  }
+  // module_trans = new TGeoTranslation("", xPos, -49-3, zPos);
+
+  // Mar2019 setup
+  const Int_t NModules           = 5;
+  xPos                           = 0.;
+  yPos                           = 0.;
+  zPos                           = TOF_Z_Front;
+  const Double_t ModDx[NModules] = {0., 0., 1.5, 49.8, 49.8};
+  //const Double_t ModDx[NModules]= { 1.5,    0., -1.5, 49.8, 55.8};
+  const Double_t ModDy[NModules]     = {0., 0., 0., 0., 0.};
+  const Double_t ModDz[NModules]     = {0., 16.5, 34., 0., 16.5};
+  const Double_t ModAng[NModules]    = {-90., -90., -90., -90., -90.0};
+  TGeoRotation* module_rot           = NULL;
+  TGeoCombiTrans* module_combi_trans = NULL;
+
+  for (Int_t iMod = 0; iMod < NModules; iMod++) {
+    module_trans = new TGeoTranslation("", xPos + ModDx[iMod], yPos + ModDy[iMod], zPos + ModDz[iMod]);
+    module_rot   = new TGeoRotation();
+    module_rot->RotateZ(ModAng[iMod]);
+    module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+    gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+    modNum++;
+  }
+
+
+  /*
+ module_trans = new TGeoTranslation("", xPos, 0, zPos+16.5);
+ gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+ modNum++;
+ 
+ // module_trans = new TGeoTranslation("", xPos, 49+3, zPos);
+ module_trans = new TGeoTranslation("", xPos, 0, zPos+16.5+17.5);
+ gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+ modNum++;
+
+ // module_trans = new TGeoTranslation("", xPos,-26, zPos+Module_Size_Z[modType]);
+ module_trans = new TGeoTranslation("", xPos, -49.8, zPos);
+ gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+ modNum++;
+
+ // module_trans = new TGeoTranslation("", xPos, 26, zPos+Module_Size_Z[modType]);
+ module_trans = new TGeoTranslation("", xPos, -49.8, zPos+16.5);
+ gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+ modNum++;
+ */
+}
+
+
+void position_Dia(Int_t modNType)
+{
+  TGeoTranslation* module_trans = NULL;
+  TGeoRotation* module_rot      = new TGeoRotation();
+  module_rot->RotateZ(Dia_rotate_Z);
+  TGeoCombiTrans* module_combi_trans = NULL;
+
+  //  Int_t numModules=(Int_t)( (Inner_Module_Last_Y_Position-Inner_Module_First_Y_Position)/Module_Size_Y[modType])+1;
+  Float_t yPos = Dia_First_Y_Position;
+  Int_t ii     = 0;
+  Float_t xPos = Dia_X_Offset;
+  Float_t zPos = Dia_Z_Position;
+
+  Int_t modNum = 0;
+  for (Int_t j = 0; j < modNType; j++) {
+    Int_t modType = Dia_Types[j];
+    for (Int_t i = 0; i < Dia_Number[j]; i++) {
+      ii++;
+      module_trans       = new TGeoTranslation("", xPos, yPos, zPos);
+      module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+      modNum++;
+    }
+  }
+}
+
+void position_Star2(Int_t modNType)
+{
+  TGeoTranslation* module_trans = NULL;
+  TGeoRotation* module_rot      = new TGeoRotation();
+  module_rot->RotateZ(Star2_rotate_Z);
+  TGeoCombiTrans* module_combi_trans = NULL;
+
+  Float_t yPos = Star2_First_Y_Position;
+  Float_t zPos = Star2_First_Z_Position;
+  Int_t ii     = 0;
+
+  Int_t modNum = 0;
+  for (Int_t j = 0; j < modNType; j++) {
+    Int_t modType = Star2_Types[j];
+    Float_t xPos  = Star2_X_Offset[j];
+    for (Int_t i = 0; i < Star2_Number[j]; i++) {
+      ii++;
+      module_trans       = new TGeoTranslation("", xPos, yPos, zPos);
+      module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+      modNum++;
+      yPos += Star2_Delta_Y_Position;
+      zPos += Star2_Delta_Z_Position[modNum];
+    }
+  }
+}
+
+void position_Buc(Int_t modNType)
+{
+  TGeoTranslation* module_trans = NULL;
+  TGeoRotation* module_rot      = new TGeoRotation("Buc2018", Buc_rotate_Z, Buc_rotate_X, 0.);
+  //TGeoRotation* module_rot = new TGeoRotation();
+  // module_rot->RotateZ(Buc_rotate_Z);
+  // module_rot->RotateX(Buc_rotate_X);
+  TGeoCombiTrans* module_combi_trans = NULL;
+
+  Float_t yPos = Buc_First_Y_Position;
+  Float_t zPos = Buc_First_Z_Position;
+  Int_t ii     = 0;
+
+  Int_t modNum = 0;
+  for (Int_t j = 0; j < modNType; j++) {
+    Int_t modType = Buc_Types[j];
+    Float_t xPos  = Buc_X_Offset[j];
+    for (Int_t i = 0; i < Buc_Number[j]; i++) {
+      ii++;
+      module_trans       = new TGeoTranslation("", xPos, yPos, zPos);
+      module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+      modNum++;
+      yPos += Buc_Delta_Y_Position;
+      zPos += Buc_Delta_Z_Position;
+    }
+  }
+}
+
+void position_cer_modules(Int_t modNType)
+{
+  Int_t ii     = 0;
+  Int_t modNum = 0;
+  for (Int_t j = 1; j < modNType; j++) {
+    Int_t modType                 = Cer_Types[j];
+    Float_t xPos                  = Cer_X_Position[j];
+    Float_t yPos                  = Cer_Y_Position[j];
+    Float_t zPos                  = Cer_Z_Position[j];
+    TGeoTranslation* module_trans = NULL;
+    TGeoRotation* module_rot      = new TGeoRotation(Form("Cer%d", j), Cer_rotate_Z[j], -MeanTheta, 0.);
+    // module_rot->RotateZ(Cer_rotate_Z[j]);
+    TGeoCombiTrans* module_combi_trans = NULL;
+
+    for (Int_t i = 0; i < Cer_Number[j]; i++) {
+      ii++;
+      cout << "Position Ceramic Module " << i << " of " << Cer_Number[j] << " Type " << modType << " at X = " << xPos
+           << ", Y = " << yPos << ", Z = " << zPos << endl;
+      // Front staggered module (Top if pair), top
+      module_trans       = new TGeoTranslation("", xPos, yPos, zPos);
+      module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+      //    modNum++;
+    }
+  }
+}
+
+void position_CERN(Int_t modNType)
+{
+  TGeoTranslation* module_trans = NULL;
+  TGeoRotation* module_rot      = new TGeoRotation();
+  module_rot->RotateZ(CERN_rotate_Z);
+  TGeoCombiTrans* module_combi_trans = NULL;
+
+  //  Int_t numModules=(Int_t)( (Inner_Module_Last_Y_Position-Inner_Module_First_Y_Position)/Module_Size_Y[modType])+1;
+  Float_t yPos = CERN_First_Y_Position;
+  Int_t ii     = 0;
+  Float_t xPos = CERN_X_Offset;
+  Float_t zPos = CERN_Z_Position;
+
+  for (Int_t j = 0; j < modNType; j++) {
+    Int_t modType = CERN_Types[j];
+    Int_t modNum  = 0;
+    for (Int_t i = 0; i < CERN_Number[j]; i++) {
+      ii++;
+      module_trans       = new TGeoTranslation("", xPos, yPos, zPos);
+      module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+      modNum++;
+    }
+  }
+}
+
+void position_Star(Int_t modNType)
+{
+  TGeoTranslation* module_trans = NULL;
+  // TGeoRotation* module_rot = new TGeoRotation("Star",Star_rotate_Z,Star_rotate_Y,0.);
+  TGeoRotation* module_rot = new TGeoRotation("Star");
+  module_rot->RotateY(Star_rotate_Y);
+  // module_rot->RotateZ(Star_rotate_Z);
+  TGeoCombiTrans* module_combi_trans = NULL;
+
+  Float_t yPos = Star_First_Y_Position;
+  Float_t zPos = Star_First_Z_Position;
+  Int_t ii     = 0;
+
+  Int_t modNum = 0;
+  for (Int_t j = 0; j < modNType; j++) {
+    Int_t modType = Star_Types[j];
+    Float_t xPos  = Star_X_Offset[j];
+    for (Int_t i = 0; i < Star_Number[j]; i++) {
+      ii++;
+      module_trans       = new TGeoTranslation("", xPos, yPos, zPos);
+      module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+      modNum++;
+      yPos += Star_Delta_Y_Position;
+      zPos += Star_Delta_Z_Position;
+    }
+  }
+}
+
+void position_side_tof_modules(Int_t modNType)
+{
+  TGeoTranslation* module_trans = NULL;
+  TGeoRotation* module_rot      = new TGeoRotation();
+  module_rot->RotateZ(180.);
+  TGeoCombiTrans* module_combi_trans = NULL;
+
+  //  Int_t numModules=(Int_t)( (Inner_Module_Last_Y_Position-Inner_Module_First_Y_Position)/Module_Size_Y[modType])+1;
+  Float_t yPos = 0.;  //Inner_Module_First_Y_Position;
+  Int_t ii     = 0;
+  for (Int_t j = 0; j < modNType; j++) {
+    Int_t modType = InnerSide_Module_Types[j];
+    Int_t modNum  = 0;
+    for (Int_t i = 0; i < InnerSide_Module_Number[j]; i++) {
+      ii++;
+      cout << "InnerSide ii " << ii << " Last " << Last_Size_Y << "," << Last_Over_Y << endl;
+      Float_t DeltaY = Module_Size_Y[modType] + Last_Size_Y - 2. * (Module_Over_Y[modType] + Last_Over_Y);
+      if (ii > 1) { yPos += DeltaY; }
+      Last_Size_Y  = Module_Size_Y[modType];
+      Last_Over_Y  = Module_Over_Y[modType];
+      Float_t xPos = InnerSide_Module_X_Offset;
+      Float_t zPos = Wall_Z_Position;
+      cout << "Position InnerSide Module " << i << " of " << InnerSide_Module_Number[j] << " Type " << modType
+           << " at Y = " << yPos << " Ysize = " << Module_Size_Y[modType] << " DeltaY = " << DeltaY << endl;
+
+      module_trans = new TGeoTranslation("", xPos, yPos, zPos);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+      modNum++;
+
+      module_trans       = new TGeoTranslation("", -xPos, yPos, zPos);
+      module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+      gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+      modNum++;
+
+      if (ii > 1) {
+        module_trans = new TGeoTranslation("", xPos, -yPos, zPos);
+        gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+        modNum++;
+
+        module_trans       = new TGeoTranslation("", -xPos, -yPos, zPos);
+        module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+        gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+        modNum++;
+
+        module_trans = new TGeoTranslation("", xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]);
+        gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+        modNum++;
+
+        module_trans       = new TGeoTranslation("", -xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]);
+        module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+        gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+        modNum++;
+
+        module_trans = new TGeoTranslation("", xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]);
+        gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans);
+        modNum++;
+
+        module_trans       = new TGeoTranslation("", -xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]);
+        module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+        gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_combi_trans);
+        modNum++;
+      }
+    }
+  }
+}
+
+void position_outer_tof_modules(Int_t nCol)  //modType, Int_t col1, Int_t col2)
+{
+  TGeoTranslation* module_trans = NULL;
+  TGeoRotation* module_rot      = new TGeoRotation();
+  module_rot->RotateZ(180.);
+  TGeoCombiTrans* module_combi_trans = NULL;
+
+  //  Int_t numModules=(Int_t)( (Outer_Module_Last_Y_Position-Outer_Module_First_Y_Position)/Module_Size_Y[modType])+1;
+
+  Int_t modNum[NofModuleTypes];
+  for (Int_t k = 0; k < NofModuleTypes; k++) {
+    modNum[k] = 0;
+  }
+
+  Float_t zPos = Wall_Z_Position;
+  for (Int_t j = 0; j < nCol; j++) {
+    Float_t xPos  = Outer_Module_X_Offset + ((j + 1) * DxColl);
+    Last_Size_Y   = 0.;
+    Last_Over_Y   = 0.;
+    Float_t yPos  = 0.;
+    Int_t ii      = 0;
+    Float_t DzPos = 0.;
+    for (Int_t k = 0; k < Outer_Module_NTypes; k++) {
+      Int_t modType = Outer_Module_Types[k][j];
+      if (Module_Size_Z[modType] > DzPos) {
+        if (Outer_Module_Number[k][j] > 0) { DzPos = Module_Size_Z[modType]; }
+      }
+    }
+
+    zPos -= 2. * DzPos;  //((j+1)*2*Module_Size_Z[modType]);
+
+    Pole_ZPos[NumberOfPoles] = zPos;
+    Pole_Col[NumberOfPoles]  = j + 1;
+    NumberOfPoles++;
+    Pole_ZPos[NumberOfPoles] = zPos + DzPos;
+    Pole_Col[NumberOfPoles]  = j + 1;
+    NumberOfPoles++;
+    //if (j+1==nCol) {
+    if (1) {
+      Pole_ZPos[NumberOfPoles] = Pole_ZPos[0];
+      Pole_Col[NumberOfPoles]  = j + 1;
+      NumberOfPoles++;
+
+      Bar_Size_Z             = Pole_ZPos[0] - zPos;
+      gBar[NumberOfBars]     = create_tof_bar(Bar_Size_X, Bar_Size_Y, Bar_Size_Z);
+      Bar_ZPos[NumberOfBars] = zPos + Bar_Size_Z / 2. - Pole_Size_Z / 2.;
+      Bar_XPos[NumberOfBars] = xPos + Pole_Offset;
+      NumberOfBars++;
+    }
+
+    for (Int_t k = 0; k < Outer_Module_NTypes; k++) {
+      Int_t modType    = Outer_Module_Types[k][j];
+      Int_t numModules = Outer_Module_Number[k][j];
+
+      cout << " Outer: position " << numModules << " of type " << modType << " in col " << j << " at z = " << zPos
+           << ", DzPos = " << DzPos << endl;
+      for (Int_t i = 0; i < numModules; i++) {
+        ii++;
+        cout << "Outer ii " << ii << " Last " << Last_Size_Y << "," << Last_Over_Y << endl;
+        Float_t DeltaY = Module_Size_Y[modType] + Last_Size_Y - 2. * (Module_Over_Y[modType] + Last_Over_Y);
+        if (ii > 1) { yPos += DeltaY; }
+        Last_Size_Y = Module_Size_Y[modType];
+        Last_Over_Y = Module_Over_Y[modType];
+        cout << "Position Outer Module " << i << " of " << Outer_Module_Number[k][j] << " Type " << modType << "(#"
+             << modNum[modType] << ") "
+             << " at Y = " << yPos << " Ysize = " << Module_Size_Y[modType] << " DeltaY = " << DeltaY << endl;
+
+        module_trans = new TGeoTranslation("", xPos, yPos, zPos);
+        gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum[modType], module_trans);
+        modNum[modType]++;
+
+        module_trans       = new TGeoTranslation("", -xPos, yPos, zPos);
+        module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+        gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum[modType], module_combi_trans);
+        modNum[modType]++;
+
+        if (ii > 1) {
+          module_trans = new TGeoTranslation("", xPos, -yPos, zPos);
+          gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum[modType], module_trans);
+          modNum[modType]++;
+          module_trans       = new TGeoTranslation("", -xPos, -yPos, zPos);
+          module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+          gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum[modType], module_combi_trans);
+          modNum[modType]++;
+
+          // second layer
+          module_trans = new TGeoTranslation("", xPos, yPos - DeltaY / 2., zPos + DzPos);
+          gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum[modType], module_trans);
+          modNum[modType]++;
+          module_trans       = new TGeoTranslation("", -xPos, yPos - DeltaY / 2., zPos + DzPos);
+          module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+          gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum[modType], module_combi_trans);
+          modNum[modType]++;
+
+          module_trans = new TGeoTranslation("", xPos, -(yPos - DeltaY / 2.), zPos + DzPos);
+          gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum[modType], module_trans);
+          modNum[modType]++;
+          module_trans       = new TGeoTranslation("", -xPos, -(yPos - DeltaY / 2.), zPos + DzPos);
+          module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
+          gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum[modType], module_combi_trans);
+          modNum[modType]++;
+        }
+      }
+    }
+  }
+}
+
+
+void dump_info_file()
+{
+  TDatime datetime;  // used to get timestamp
+
+  printf("writing info file: %s\n", FileNameInfo.Data());
+
+  FILE* ifile;
+  ifile = fopen(FileNameInfo.Data(), "w");
+
+  if (ifile == NULL) {
+    printf("error opening %s\n", FileNameInfo.Data());
+    exit(1);
+  }
+
+  fprintf(ifile, "#\n##   %s information file\n#\n\n", geoVersion.Data());
+
+  fprintf(ifile, "# created %d\n\n", datetime.GetDate());
+
+  fprintf(ifile, "# TOF setup\n");
+  if (TOF_Z_Front == 450) fprintf(ifile, "SIS 100 hadron setup\n");
+  if (TOF_Z_Front == 600) fprintf(ifile, "SIS 100 electron\n");
+  if (TOF_Z_Front == 650) fprintf(ifile, "SIS 100 muon\n");
+  if (TOF_Z_Front == 880) fprintf(ifile, "SIS 300 electron\n");
+  if (TOF_Z_Front == 1020) fprintf(ifile, "SIS 300 muon\n");
+  fprintf(ifile, "\n");
+
+  const Float_t TOF_Z_Back = Wall_Z_Position + 1.5 * Module_Size_Z[0];  // back of TOF wall
+
+  fprintf(ifile, "# envelope\n");
+  // Show extension of TRD
+  fprintf(ifile, "%7.2f cm   start of TOF (z)\n", TOF_Z_Front);
+  fprintf(ifile, "%7.2f cm   end   of TOF (z)\n", TOF_Z_Back);
+  fprintf(ifile, "\n");
+
+  // Layer thickness
+  fprintf(ifile, "# central tower position\n");
+  fprintf(ifile, "%7.2f cm   center of staggered, front RPC cell at x=0\n", Wall_Z_Position);
+  fprintf(ifile, "\n");
+
+  fclose(ifile);
+}
diff --git a/macro/tof/geometry/ModulePosition_10m_v21a.dat b/macro/tof/geometry/ModulePosition_10m_v21a.dat
new file mode 100644
index 0000000000..dfceb17f3f
--- /dev/null
+++ b/macro/tof/geometry/ModulePosition_10m_v21a.dat
@@ -0,0 +1,232 @@
+#	ModType	X	Y	Z
+1	0	-539.9	400.5	903.4
+2	0	-539.9	345.3	889.9
+3	0	-539.9	299.9	903.4
+4	0	-539.9	246.1	889.9
+5	0	-539.9	199.3	903.4
+6	0	-539.9	147.0	889.9
+7	0	-539.9	98.8	903.4
+8	0	-539.9	50.0	916.9
+9	0	-539.9	0.0	930.4
+10	0	-539.9	-50.0	916.9
+11	0	-539.9	-98.8	903.4
+12	0	-539.9	-147.0	889.9
+13	0	-539.9	-199.3	903.4
+14	0	-539.9	-246.1	889.9
+15	0	-539.9	-299.9	903.4
+16	0	-539.9	-345.3	889.9
+17	0	-539.9	-400.5	903.4
+18	0	-407.9	412.8	930.4
+19	0	-407.9	357.3	916.9
+20	0	-407.9	312.0	930.4
+21	0	-407.9	257.8	916.9
+22	0	-407.9	211.0	930.4
+23	0	-407.9	158.5	916.9
+24	0	-407.9	110.5	930.4
+25	3	-408.2	75.0	944.7
+26	3	-423.2	51.0	957.7
+27	3	-408.2	25.0	944.7
+28	3	-423.2	0.0	957.7
+29	3	-408.2	-25.0	944.7
+30	3	-423.2	-51.0	957.7
+31	3	-408.2	-75.0	944.7
+32	0	-407.9	-110.5	930.4
+33	0	-407.9	-158.5	916.9
+34	0	-407.9	-211.0	930.4
+35	0	-407.9	-257.8	916.9
+36	0	-407.9	-312.0	930.4
+37	0	-407.9	-357.3	916.9
+38	0	-407.9	-412.8	930.4
+39	1	-276.7	419.5	944.7
+40	1	-286.7	400.2	957.7
+41	1	-276.7	369.5	944.7
+42	1	-286.7	349.2	957.7
+43	3	-276.7	319.5	944.7
+44	3	-286.7	298.2	957.7
+45	3	-276.7	269.5	944.7
+46	3	-286.7	247.7	957.7
+47	3	-276.7	219.5	944.7
+48	3	-286.7	197.2	957.7
+49	3	-276.7	165.9	944.7
+50	3	-286.7	146.7	957.7
+51	3	-276.7	125.0	971.2
+52	3	-286.7	102.0	984.2
+53	3	-276.7	75.0	971.2
+54	3	-286.7	51.0	984.2
+55	3	-276.7	25.0	971.2
+56	3	-286.7	0.0	984.2
+57	3	-276.7	-25.0	971.2
+58	3	-286.7	-51.0	984.2
+59	3	-276.7	-75.0	971.2
+60	3	-286.7	-102.0	984.2
+61	3	-276.7	-125.0	971.2
+62	3	-286.7	-146.7	957.7
+63	3	-276.7	-165.9	944.7
+64	3	-286.7	-197.2	957.7
+65	3	-276.7	-219.5	944.7
+66	3	-286.7	-247.7	957.7
+67	3	-276.7	-269.5	944.7
+68	3	-286.7	-298.2	957.7
+69	3	-276.7	-319.5	944.7
+70	1	-286.7	-349.2	957.7
+71	1	-276.7	-369.5	944.7
+72	1	-286.7	-400.2	957.7
+73	1	-276.7	-419.5	944.7
+74	1	-141.7	425.0	971.2
+75	1	-146.7	405.8	984.2
+76	1	-141.7	375.0	971.2
+77	1	-146.7	354.8	984.2
+78	3	-141.7	325.0	971.2
+79	3	-146.7	303.8	984.2
+80	3	-141.7	275.0	971.2
+81	3	-146.7	253.3	984.2
+82	3	-141.7	225.0	971.2
+83	3	-146.7	202.8	984.2
+84	3	-141.7	175.0	971.2
+85	3	-146.7	152.3	984.2
+86	3	-146.7	-152.3	984.2
+87	3	-141.7	-175.0	971.2
+88	3	-146.7	-202.8	984.2
+89	3	-141.7	-225.0	971.2
+90	3	-146.7	-253.3	984.2
+91	3	-141.7	-275.0	971.2
+92	3	-146.7	-303.8	984.2
+93	3	-141.7	-325.0	971.2
+94	1	-146.7	-354.8	984.2
+95	1	-141.7	-375.0	971.2
+96	1	-146.7	-405.8	984.2
+97	1	-141.7	-425.0	971.2
+98	2	0	425.5	1000.0
+99	2	0	405.3	1013.0
+100	2	0	375.5	1000.0
+101	2	0	354.7	1013.0
+102	4	0	325.5	1000.0
+103	4	0	304.1	1013.0
+104	4	0	275.5	1000.0
+105	4	0	253.5	1013.0
+106	4	0	225.5	1000.0
+107	4	0	202.9	1013.0
+108	4	0	175.5	1000.0
+109	4	0	152.3	1013.0
+110	4	0	-152.3	1013.0
+111	4	0	-175.5	1000.0
+112	4	0	-202.9	1013.0
+113	4	0	-225.5	1000.0
+114	4	0	-253.5	1013.0
+115	4	0	-275.5	1000.0
+116	4	0	-304.1	1013.0
+117	4	0	-325.5	1000.0
+118	2	0	-354.7	1013.0
+119	2	0	-375.5	1000.0
+120	2	0	-405.3	1013.0
+121	2	0	-425.5	1000.0
+122	1	141.7	425.0	971.2
+123	1	146.7	405.8	984.2
+124	1	141.7	375.0	971.2
+125	1	146.7	354.8	984.2
+126	3	141.7	325.0	971.2
+127	3	146.7	303.8	984.2
+128	3	141.7	275.0	971.2
+129	3	146.7	253.3	984.2
+130	3	141.7	225.0	971.2
+131	3	146.7	202.8	984.2
+132	3	141.7	175.0	971.2
+133	3	146.7	152.3	984.2
+134	3	146.7	-152.3	984.2
+135	3	141.7	-175.0	971.2
+136	3	146.7	-202.8	984.2
+137	3	141.7	-225.0	971.2
+138	3	146.7	-253.3	984.2
+139	3	141.7	-275.0	971.2
+140	3	146.7	-303.8	984.2
+141	3	141.7	-325.0	971.2
+142	1	146.7	-354.8	984.2
+143	1	141.7	-375.0	971.2
+144	1	146.7	-405.8	984.2
+145	1	141.7	-425.0	971.2
+146	1	276.7	419.5	944.7
+147	1	286.7	400.2	957.7
+148	1	276.7	369.5	944.7
+149	1	286.7	349.2	957.7
+150	3	276.7	319.5	944.7
+151	3	286.7	298.2	957.7
+152	3	276.7	269.5	944.7
+153	3	286.7	247.7	957.7
+154	3	276.7	219.5	944.7
+155	3	286.7	197.2	957.7
+156	3	276.7	165.9	944.7
+157	3	286.7	146.7	957.7
+158	3	276.7	125.0	971.2
+159	3	286.7	102.0	984.2
+160	3	276.7	75.0	971.2
+161	3	286.7	51.0	984.2
+162	3	276.7	25.0	971.2
+163	3	286.7	0.0	984.2
+164	3	276.7	-25.0	971.2
+165	3	286.7	-51.0	984.2
+166	3	276.7	-75.0	971.2
+167	3	286.7	-102.0	984.2
+168	3	276.7	-125.0	971.2
+169	3	286.7	-146.7	957.7
+170	3	276.7	-165.9	944.7
+171	3	286.7	-197.2	957.7
+172	3	276.7	-219.5	944.7
+173	3	286.7	-247.7	957.7
+174	3	276.7	-269.5	944.7
+175	3	286.7	-298.2	957.7
+176	3	276.7	-319.5	944.7
+177	1	286.7	-349.2	957.7
+178	1	276.7	-369.5	944.7
+179	1	286.7	-400.2	957.7
+180	1	276.7	-419.5	944.7
+181	0	407.9	412.8	930.4
+182	0	407.9	357.3	916.9
+183	0	407.9	312.0	930.4
+184	0	407.9	257.8	916.9
+185	0	407.9	211.0	930.4
+186	0	407.9	158.5	916.9
+187	0	407.9	110.5	930.4
+188	3	408.2	75.0	944.7
+189	3	423.2	51.0	957.7
+190	3	408.2	25.0	944.7
+191	3	423.2	0.0	957.7
+192	3	408.2	-25.0	944.7
+193	3	423.2	-51.0	957.7
+194	3	408.2	-75.0	944.7
+195	0	407.9	-110.5	930.4
+196	0	407.9	-158.5	916.9
+197	0	407.9	-211.0	930.4
+198	0	407.9	-257.8	916.9
+199	0	407.9	-312.0	930.4
+200	0	407.9	-357.3	916.9
+201	0	407.9	-412.8	930.4
+202	0	539.9	400.5	903.4
+203	0	539.9	345.3	889.9
+204	0	539.9	299.9	903.4
+205	0	539.9	246.1	889.9
+206	0	539.9	199.3	903.4
+207	0	539.9	147.0	889.9
+208	0	539.9	98.8	903.4
+209	0	539.9	50.0	916.9
+210	0	539.9	0.0	930.4
+211	0	539.9	-50.0	916.9
+212	0	539.9	-98.8	903.4
+213	0	539.9	-147.0	889.9
+214	0	539.9	-199.3	903.4
+215	0	539.9	-246.1	889.9
+216	0	539.9	-299.9	903.4
+217	0	539.9	-345.3	889.9
+218	0	539.9	-400.5	903.4
+219	5	-129.05	0.0	1011
+220	6	-172.15	89.6	1050.4
+221	7	-71.7	89.4	1030.7
+222	8	0.0	89.4	1050.4
+223	7	71.7	89.4	1030.7
+224	9	172.15	89.6	1050.4
+225	10	129.05	0.0	1011
+226	11	172.15	-89.6	1050.4
+227	12	71.7	-89.6	1030.7
+228	13	0.0	-89.4	1050.4
+229	12	-172.15	-89.6	1030.7
+230	14	-172.15	-89.6	1050.4
+
diff --git a/macro/tof/geometry/ModuleType0_v21a.dat b/macro/tof/geometry/ModuleType0_v21a.dat
new file mode 100644
index 0000000000..c45afcc97f
--- /dev/null
+++ b/macro/tof/geometry/ModuleType0_v21a.dat
@@ -0,0 +1,6 @@
+#     CT        X            Y        Z
+1	0	-67.0	     0.0      0.0
+2	0	-36.5	0.0  0.0
+3	0	-6.0	0.0  0.0
+4	0	24.5	0.   	0.0
+5	0	55.0	0.0	0.0
diff --git a/macro/tof/geometry/ModuleType10_v21a.dat b/macro/tof/geometry/ModuleType10_v21a.dat
new file mode 100644
index 0000000000..b613ba1b36
--- /dev/null
+++ b/macro/tof/geometry/ModuleType10_v21a.dat
@@ -0,0 +1,31 @@
+#     CT        X            Y        Z
+1   4		-86.15	     25.0      1.8
+2   4		-86.15	     15.0      -5.4
+3   4		-86.15	     5.0       1.8
+4   4		-86.15	     -5.0	-5.4
+5   4		-86.15	     -15.0	1.8
+6   4		-86.15	     -25.0	-5.4
+7   4		-57.35	     25.0	5.4
+8   4		-57.35	     15.0	-1.8
+9   4		-57.35	     5.0	5.4
+10   4		-57.35	     -5.0	-1.8
+11   4		-57.35	     -15.0	5.4
+12   4		-57.35	     -25.0	-1.8
+13   4		-28.55	     25.0      1.8
+14   4		-28.55	     15.0      -5.4
+15   4		-28.55	     5.0       1.8
+16   4		-28.55	     -5.0	-5.4
+17   4		-28.55	     -15.0	1.8
+18   4		-28.55	     -25.0	-5.4
+19   3		0.05	     20.0      -1.8
+20   3		0.05	     0.0       5.4
+21   3		0.05	     -20.0     -1.8
+22   3		28.85	     20.0     -5.4 
+23   3		28.85	     0.0      1.8
+24   3		28.85	     -20.0     -5.4
+25   3		57.35	     20.0      -1.8
+26   3		57.35	     0.0       5.4
+27   3		57.35	     -20.0     -1.8
+28   3		86.15	     20.0     -5.4 
+29   3		86.15	     0.0      1.8
+30   3		86.15	     -20.0     -5.4
diff --git a/macro/tof/geometry/ModuleType11_v21a.dat b/macro/tof/geometry/ModuleType11_v21a.dat
new file mode 100644
index 0000000000..2b8eacd611
--- /dev/null
+++ b/macro/tof/geometry/ModuleType11_v21a.dat
@@ -0,0 +1,25 @@
+#	CT	    X		  Y	  Z
+1	3	    -43.05	  49.6	  5.4
+2	3	    -43.05	  29.6	  -1.8
+3	3	    -43.05	  9.9	  	  5.4
+4	3	    -43.05	  -10.1	  -1.8
+5	3	    -43.05	  -29.6	  5.4
+6	3	    -43.05	  -49.6	  -1.8
+7	3	    -14.25	  49.6	  1.8
+8	3	    -14.25	  29.6	  -5.4
+9	3	    -14.25	  9.9	  	  1.8
+10	3	    -14.25	  -10.1	  -5.4
+11	3	    -14.25	  -29.6	  1.8
+12	3	    -14.25	  -49.6	  -5.4
+13	3	    14.25	  49.6	  5.4
+14	3	    14.25	  29.6	  -1.8
+15	3	    14.25	  9.9	  	  5.4
+16	3	    14.25	  -10.1	  -1.8
+17	3	    14.25	  -29.6	  5.4
+18	3	    14.25	  -49.6	  -1.8
+19	3	    43.05	  49.6	  1.8
+20	3	    43.05	  29.6	  -5.4
+21	3	    43.05	  9.9	  	  1.8
+22	3	    43.05	  -10.1	  -5.4
+23	3	    43.05	  -29.6	  1.8
+24	3	    43.05	  -49.6	  -5.4
diff --git a/macro/tof/geometry/ModuleType12_v21a.dat b/macro/tof/geometry/ModuleType12_v21a.dat
new file mode 100644
index 0000000000..15f2c93658
--- /dev/null
+++ b/macro/tof/geometry/ModuleType12_v21a.dat
@@ -0,0 +1,28 @@
+#	CT  	    X	           Y	       	   Z
+1	4	    -28.8	   54.4		   -5.4
+2	4	    -28.8	   44.5		   1.8
+3	4	    -28.8	   34.5		   -5.4
+4	4	    -28.8	   24.8		   1.8
+5	4	    -28.8	   14.8		   -5.4
+6	4	    -28.8	   5.1		   1.8
+7	3	    -28.8	   -9.9		   -5.4
+8	3	    -28.8	   -29.4		   1.8
+9	3	    -28.8	   -49.4		   -5.4
+10	4	    0.0	   54.4		   -1.8
+11	4	    0.0	   44.5		   5.4
+12	4	    0.0	   34.5		   -1.8
+13	4	    0.0	   24.8		   5.4
+14	4	    0.0	   14.8		  -1.8
+15	4	    0.0	   5.1		   5.4
+16	3	    0.0	   -9.9		   -1.8
+17	3	    0.0	   -29.4		   5.4
+18	3	    0.0	   -49.4		   -1.8
+19	4	    28.8	   54.4		   -5.4
+20	4	    28.8	   44.5		   1.8
+21	4	    28.8	   34.5		   -5.4
+22	4	    28.8	   24.8		   1.8
+23	4	    28.8	   14.8		   -5.4
+24	4	    28.8	   5.1		   1.8
+25	3	    28.8	   -9.9		   -5.4
+26	3	    28.8	   -29.4		   1.8
+27	3	    28.8	   -49.4		   -5.4
diff --git a/macro/tof/geometry/ModuleType13_v21a.dat b/macro/tof/geometry/ModuleType13_v21a.dat
new file mode 100644
index 0000000000..59b0638a61
--- /dev/null
+++ b/macro/tof/geometry/ModuleType13_v21a.dat
@@ -0,0 +1,19 @@
+#	CT  	    X	           Y	       	   Z
+1	4	    -14.4	   54.4		   -5.4
+2	4	    -14.4	   44.5		   1.8
+3	4	    -14.4	   34.5		   -5.4
+4	4	    -14.4	   24.8		   1.8
+5	4	    -14.4	   14.8		   -5.4
+6	4	    -14.4	   5.1		   1.8
+7	3	    -14.4	   -9.9		   -5.4
+8	3	    -14.4	   -29.4		   1.8
+9	3	    -14.4	   -49.4		   -5.4
+10	4	    14.4	   54.4		   -1.8
+11	4	    14.4	   44.5		   5.4
+12	4	    14.4	   34.5		   -1.8
+13	4	    14.4	   24.8		   5.4
+14	4	    14.4	   14.8		  -1.8
+15	4	    14.4	   5.1		   5.4
+16	3	    14.4	   -9.9		   -1.8
+17	3	    14.4	   -29.4		   5.4
+18	3	    14.4	   -49.4		   -1.8
diff --git a/macro/tof/geometry/ModuleType14_v21a.dat b/macro/tof/geometry/ModuleType14_v21a.dat
new file mode 100644
index 0000000000..a84e6995e3
--- /dev/null
+++ b/macro/tof/geometry/ModuleType14_v21a.dat
@@ -0,0 +1,25 @@
+#	CT	    X		  Y	  Z
+1	3	    -43.05	  49.6	  1.8
+2	3	    -43.05	  29.6	  -5.4
+3	3	    -43.05	  9.9	  	  1.8
+4	3	    -43.05	  -10.1	  -5.4
+5	3	    -43.05	  -29.6	  1.8
+6	3	    -43.05	  -49.6	  -5.4
+7	3	    -14.25	  49.6	  5.4
+8	3	    -14.25	  29.6	  -1.8
+9	3	    -14.25	  9.9		  5.4
+10	3	    -14.25	  -10.1	  -1.8
+11	3	    -14.25	  -29.6	  5.4
+12	3	    -14.25	  -49.6	  -1.8
+13	3	    14.25	  49.6	  1.8
+14	3	    14.25	  29.6	  -5.4
+15	3	    14.25	  9.9	  	  1.8
+16	3	    14.25	  -10.1	  -5.4
+17	3	    14.25	  -29.6	  1.8
+18	3	    14.25	  -49.6	  -5.4
+19	3	    43.05	  49.6	  5.4
+20	3	    43.05	  29.6	  -1.8
+21	3	    43.05	  9.9	  	  5.4
+22	3	    43.05	  -10.1	  -1.8
+23	3	    43.05	  -29.6	  5.4
+24	3	    43.05	  -49.6	  -1.8
diff --git a/macro/tof/geometry/ModuleType1_v21a.dat b/macro/tof/geometry/ModuleType1_v21a.dat
new file mode 100644
index 0000000000..0a9ecea32c
--- /dev/null
+++ b/macro/tof/geometry/ModuleType1_v21a.dat
@@ -0,0 +1,6 @@
+#     CT        X            Y        Z
+1	1	-67.0	     0.0      0.0
+2	1	-36.5	0.0  0.0
+3	1	-6.0	0.0  0.0
+4	1	24.5	0.   	0.0
+5	1	55.0	0.0	0.0
diff --git a/macro/tof/geometry/ModuleType2_v21a.dat b/macro/tof/geometry/ModuleType2_v21a.dat
new file mode 100644
index 0000000000..2ae281d4dd
--- /dev/null
+++ b/macro/tof/geometry/ModuleType2_v21a.dat
@@ -0,0 +1,6 @@
+#     CT        X            Y        Z
+1	1	-60	     0.0      2.5
+2	1	-30	0.0  -2.5
+3	1	0.0	0.0  2.5
+4	1	30	0.   	-2.5
+5	1	60	0.0	2.5
diff --git a/macro/tof/geometry/ModuleType3_v21a.dat b/macro/tof/geometry/ModuleType3_v21a.dat
new file mode 100644
index 0000000000..c104dba3f3
--- /dev/null
+++ b/macro/tof/geometry/ModuleType3_v21a.dat
@@ -0,0 +1,6 @@
+#     CT        X            Y        Z
+1	2	-67.0	     0.0      0.0
+2	2	-36.5	0.0  0.0
+3	2	-6.0	0.0  0.0
+4	2	24.5	0.   	0.0
+5	2	55.0	0.0	0.0
diff --git a/macro/tof/geometry/ModuleType4_v21a.dat b/macro/tof/geometry/ModuleType4_v21a.dat
new file mode 100644
index 0000000000..3d800db013
--- /dev/null
+++ b/macro/tof/geometry/ModuleType4_v21a.dat
@@ -0,0 +1,6 @@
+#     CT        X            Y        Z
+1	2	-60	     0.0      2.5
+2	2	-30	0.0  -2.5
+3	2	0.0	0.0  2.5
+4	2	30	0.   	-2.5
+5	2	60	0.0	2.5
diff --git a/macro/tof/geometry/ModuleType5_v21a.dat b/macro/tof/geometry/ModuleType5_v21a.dat
new file mode 100644
index 0000000000..f0b90564b8
--- /dev/null
+++ b/macro/tof/geometry/ModuleType5_v21a.dat
@@ -0,0 +1,31 @@
+#     CT        X            Y        Z
+1     3		-86.15	     20.0     -5.4 
+2     3		-86.15	     0.0      1.8
+3     3		-86.15	     -20.0     -5.4 
+4     3		-57.35	     20.0      -1.8
+5     3		-57.35	     0.0       5.4
+6     3		-57.35	     -20.0     -1.8
+7     3		-28.85	     20.0     -5.4 
+8     3		-28.85	     0.0      1.8
+9     3		-28.85	     -20.0     -5.4 
+10   3		-0.05	     20.0      -1.8
+11   3		-0.05	     0.0       5.4
+12   3		-0.05	     -20.0     -1.8
+13   4		28.55	     25.0      1.8
+14   4		28.55	     15.0      -5.4
+15   4		28.55	     5.0       1.8
+16   4		28.55	     -5.0	-5.4
+17   4		28.55	     -15.0	1.8
+18   4		28.55	     -25.0	-5.4
+19   4		57.35	     25.0	5.4
+20   4		57.35	     15.0	-1.8
+21   4		57.35	     5.0	5.4
+22   4		57.35	     -5.0	-1.8
+23   4		57.35	     -15.0	5.4
+24   4		57.35	     -25.0	-1.8
+25   4		86.15	     25.0      1.8
+26   4		86.15	     15.0      -5.4
+27   4		86.15	     5.0       1.8
+28   4		86.15	     -5.0	-5.4
+29   4		86.15	     -15.0	1.8
+30   4		86.15	     -25.0	-5.4
diff --git a/macro/tof/geometry/ModuleType6_v21a.dat b/macro/tof/geometry/ModuleType6_v21a.dat
new file mode 100644
index 0000000000..3c044652b1
--- /dev/null
+++ b/macro/tof/geometry/ModuleType6_v21a.dat
@@ -0,0 +1,25 @@
+#	CT	    X		  Y	  Z
+1	3	    -43.05	  49.6	  -5.4
+2	3	    -43.05	  29.6	  1.8
+3	3	    -43.05	  10.1	  -5.4
+4	3	    -43.05	  -9.9	  1.8
+5	3	    -43.05	  -29.6	  -5.4
+6	3	    -43.05	  -49.6	  1.8
+7	3	    -14.25	  49.6	  -1.8
+8	3	    -14.25	  29.6	  5.4
+9	3	    -14.25	  10.1	  -1.8
+10	3	    -14.25	  -9.9	  5.4
+11	3	    -14.25	  -29.6	  -1.8
+12	3	    -14.25	  -49.6	  5.4
+13	3	    14.25	  49.6	  -5.4
+14	3	    14.25	  29.6	  1.8
+15	3	    14.25	  10.1	  -5.4
+16	3	    14.25	  -9.9	  1.8
+17	3	    14.25	  -29.6	  -5.4
+18	3	    14.25	  -49.6	  1.8
+19	3	    43.05	  49.6	  -1.8
+20	3	    43.05	  29.6	  5.4
+21	3	    43.05	  10.1	  -1.8
+22	3	    43.05	  -9.9	  5.4
+23	3	    43.05	  -29.6	  -1.8
+24	3	    43.05	  -49.6	  5.4
diff --git a/macro/tof/geometry/ModuleType7_v21a.dat b/macro/tof/geometry/ModuleType7_v21a.dat
new file mode 100644
index 0000000000..2e0e5c46dc
--- /dev/null
+++ b/macro/tof/geometry/ModuleType7_v21a.dat
@@ -0,0 +1,28 @@
+#	CT  	    X	           Y	       	   Z
+1	3	    -28.8	   49.4		   -5.4
+2	3	    -28.8	   29.4		   1.8
+3	3	    -28.8	   9.9		   -5.4
+4	4	    -28.8	   -5.1		   1.8
+5	4	    -28.8	   -14.8		   -5.4
+6	4	    -28.8	   -24.8		   1.8
+7	4	    -28.8	   -34.5		   -5.4
+8	4	    -28.8	   -44.5		   1.8
+9	4	    -28.8	   -54.4		   -5.4
+10	3	    0.0	   49.4		   -1.8
+11	3	    0.0	   29.4		   5.4
+12	3	    0.0	   9.9		   -1.8
+13	4	    0.0	   -5.1		   5.4
+14	4	    0.0	   -14.8		  -1.8 
+15	4	    0.0	   -24.8		   5.4
+16	4	    0.0	   -34.5		   -1.8
+17	4	    0.0	   -44.5		   5.4
+18	4	    0.0	   -54.4		   -1.8
+19	3	    28.8	   49.4		   -5.4
+20	3	    28.8	   29.4		   1.8
+21	3	    28.8	   9.9		   -5.4
+22	4	    28.8	   -5.1		   1.8
+23	4	    28.8	   -14.8		   -5.4
+24	4	    28.8	   -24.8		   1.8
+25	4	    28.8	   -34.5		   -5.4
+26	4	    28.8	   -44.5		   1.8
+27	4	    28.8	   -54.4		   -5.4
diff --git a/macro/tof/geometry/ModuleType8_v21a.dat b/macro/tof/geometry/ModuleType8_v21a.dat
new file mode 100644
index 0000000000..8c56f4df14
--- /dev/null
+++ b/macro/tof/geometry/ModuleType8_v21a.dat
@@ -0,0 +1,19 @@
+#	CT  	    X	           Y	       	   Z
+1	3	    -14.4	   49.4		   -5.4
+2	3	    -14.4	   29.4		   1.8
+3	3	    -14.4	   9.9		   -5.4
+4	4	    -14.4	   -5.1		   1.8
+5	4	    -14.4	   -14.8		   -5.4
+6	4	    -14.4	   -24.8		   1.8
+7	4	    -14.4	   -34.5		   -5.4
+8	4	    -14.4	   -44.5		   1.8
+9	4	    -14.4	   -54.4		   -5.4
+10	3	    14.4	   49.4		   -1.8
+11	3	    14.4	   29.4		   5.4
+12	3	    14.4	   9.9		   -1.8
+13	4	    14.4	   -5.1		   5.4
+14	4	    14.4	   -14.8		  -1.8 
+15	4	    14.4	   -24.8		   5.4
+16	4	    14.4	   -34.5		   -1.8
+17	4	    14.4	   -44.5		   5.4
+18	4	    14.4	   -54.4		   -1.8
diff --git a/macro/tof/geometry/ModuleType9_v21a.dat b/macro/tof/geometry/ModuleType9_v21a.dat
new file mode 100644
index 0000000000..6a5f1cd5e0
--- /dev/null
+++ b/macro/tof/geometry/ModuleType9_v21a.dat
@@ -0,0 +1,26 @@
+#	CT	    X		  Y	  Z
+1	3	    -43.05	  49.6	  -1.8
+2	3	    -43.05	  29.6	  5.4
+3	3	    -43.05	  10.1	  -1.8
+4	3	    -43.05	  -9.9	  5.4
+5	3	    -43.05	  -29.6	  -1.8
+6	3	    -43.05	  -49.6	  5.4
+7	3	    -14.25	  49.6	  -5.4
+8	3	    -14.25	  29.6	  1.8
+9	3	    -14.25	  10.1	  -5.4
+10	3	    -14.25	  -9.9	  1.8
+11	3	    -14.25	  -29.6	  -5.4
+12	3	    -14.25	  -49.6	  1.8
+13	3	    14.25	  49.6	  -1.8
+14	3	    14.25	  29.6	  5.4
+15	3	    14.25	  10.1	  -1.8
+16	3	    14.25	  -9.9	  5.4
+17	3	    14.25	  -29.6	  -1.8
+18	3	    14.25	  -49.6	  5.4
+19	3	    43.05	  49.6	  -5.4
+20	3	    43.05	  29.6	  1.8
+21	3	    43.05	  10.1	  -5.4
+22	3	    43.05	  -9.9	  1.8
+23	3	    43.05	  -29.6	  -5.4
+24	3	    43.05	  -49.6	  1.8
+
diff --git a/macro/tof/geometry/create_geopar_allsetups.sh b/macro/tof/geometry/create_geopar_allsetups.sh
index e8a87de9e4..3757d1e71b 100755
--- a/macro/tof/geometry/create_geopar_allsetups.sh
+++ b/macro/tof/geometry/create_geopar_allsetups.sh
@@ -25,14 +25,14 @@ sed -i.tmp 's|//const TString geoVersion = "tof_'${VGEO}'_1m";|const TString geo
 root -l -q Create_TOF_Geometry_${VGEO}.C
 
 # Generate the 3e geo file
-sed -i.tmp 's|const TString geoVersion = "tof_'${VGEO}'_1m";|//const TString geoVersion = "tof_'${VGEO}'_1m";|' Create_TOF_Geometry_${VGEO}.C
-sed -i.tmp 's|//const TString geoVersion = "tof_'${VGEO}'_3e";|const TString geoVersion = "tof_'${VGEO}'_3e";|' Create_TOF_Geometry_${VGEO}.C
-root -l -q Create_TOF_Geometry_${VGEO}.C
+#sed -i.tmp 's|const TString geoVersion = "tof_'${VGEO}'_1m";|//const TString geoVersion = "tof_'${VGEO}'_1m";|' Create_TOF_Geometry_${VGEO}.C
+#sed -i.tmp 's|//const TString geoVersion = "tof_'${VGEO}'_3e";|const TString geoVersion = "tof_'${VGEO}'_3e";|' Create_TOF_Geometry_${VGEO}.C
+#root -l -q Create_TOF_Geometry_${VGEO}.C
 
 # Generate the 3m geo file
-sed -i.tmp 's|const TString geoVersion = "tof_'${VGEO}'_3e";|//const TString geoVersion = "tof_'${VGEO}'_3e";|' Create_TOF_Geometry_${VGEO}.C
-sed -i.tmp 's|//const TString geoVersion = "tof_'${VGEO}'_3m";|const TString geoVersion = "tof_'${VGEO}'_3m";|' Create_TOF_Geometry_${VGEO}.C
-root -l -q Create_TOF_Geometry_${VGEO}.C
+#sed -i.tmp 's|const TString geoVersion = "tof_'${VGEO}'_3e";|//const TString geoVersion = "tof_'${VGEO}'_3e";|' Create_TOF_Geometry_${VGEO}.C
+#sed -i.tmp 's|//const TString geoVersion = "tof_'${VGEO}'_3m";|const TString geoVersion = "tof_'${VGEO}'_3m";|' Create_TOF_Geometry_${VGEO}.C
+#root -l -q Create_TOF_Geometry_${VGEO}.C
 
 # Restore the macro file to 1h
 mv Create_TOF_Geometry_${VGEO}.C.bak Create_TOF_Geometry_${VGEO}.C
@@ -44,19 +44,17 @@ cp tof_${VGEO}_*.geo.root ../../../geometry/tof/
 root -l -q 'make_geofile.C("tof_'${VGEO}'_1h")'
 root -l -q 'make_geofile.C("tof_'${VGEO}'_1e")'
 root -l -q 'make_geofile.C("tof_'${VGEO}'_1m")'
-root -l -q 'make_geofile.C("tof_'${VGEO}'_3e")'
-root -l -q 'make_geofile.C("tof_'${VGEO}'_3m")'
+#root -l -q 'make_geofile.C("tof_'${VGEO}'_3e")'
+#root -l -q 'make_geofile.C("tof_'${VGEO}'_3m")'
 
 # Generate the digi parameter files
-root -l -q 'create_digipar.C("tof_'${VGEO}'_1h")'
-root -l -q 'create_digipar.C("tof_'${VGEO}'_1e")'
-root -l -q 'create_digipar.C("tof_'${VGEO}'_1m")'
-root -l -q 'create_digipar.C("tof_'${VGEO}'_3e")'
-root -l -q 'create_digipar.C("tof_'${VGEO}'_3m")'
+#root -l -q 'create_digipar.C("tof_'${VGEO}'_1m")'
+#root -l -q 'create_digipar.C("tof_'${VGEO}'_3e")'
+#root -l -q 'create_digipar.C("tof_'${VGEO}'_3m")'
 
-cp tof_${VGEO}_*.digi.par ../../../parameters/tof/
+#cp tof_${VGEO}_*.digi.par ../../../parameters/tof/
 
 # cleanup extra files
-rm auaumbias.tof_${VGEO}_*.mc.root auaumbias.tof_${VGEO}_*.params.root test.esd.tof_${VGEO}_*.root gphysi.dat
-rm tof_${VGEO}_*.geo.root tof_${VGEO}_*_geo.root tof_${VGEO}_*.geo.info geofile_tof_${VGEO}_*.root tof_${VGEO}_*.digi.par
+#rm auaumbias.tof_${VGEO}_*.mc.root auaumbias.tof_${VGEO}_*.params.root test.esd.tof_${VGEO}_*.root gphysi.dat
+#rm tof_${VGEO}_*.geo.root tof_${VGEO}_*_geo.root tof_${VGEO}_*.geo.info geofile_tof_${VGEO}_*.root tof_${VGEO}_*.digi.par
 rm Create_TOF_Geometry_${VGEO}.C.tmp
diff --git a/macro/tof/geometry/create_parameters.sh b/macro/tof/geometry/create_parameters.sh
index 9992da0967..ac92ac380f 100755
--- a/macro/tof/geometry/create_parameters.sh
+++ b/macro/tof/geometry/create_parameters.sh
@@ -30,9 +30,8 @@ root -b -q ''${workdir}'/make_geofile_noBfield.C("tof_'${cVersion}'")'
 
 cp -v ${workdir}/geofile_tof_${cVersion}.root ${VMCWORKDIR}/geometry/tof/
 
-root -b -q ''${workdir}'/create_digipar.C("tof_'${cVersion}'")'
-
-mv -v ${workdir}/tof_${cVersion}.digi.par ${VMCWORKDIR}/parameters/tof/
+#root -b -q ''${workdir}'/create_digipar.C("tof_'${cVersion}'")'
+#mv -v ${workdir}/tof_${cVersion}.digi.par ${VMCWORKDIR}/parameters/tof/
 
 rm -v ${workdir}/auaumbias.tof_${cVersion}.mc.root
 #rm -v ${workdir}/auaumbias.tof_${cVersion}.params.root
-- 
GitLab