From c2af3a5e1397b67d5f57f988a0755572de34430b Mon Sep 17 00:00:00 2001
From: Norbert Herrmann <n.herrmann@physi.uni-heidelberg.de>
Date: Thu, 8 Apr 2021 13:56:12 +0200
Subject: [PATCH 1/5] fix inconsistencies introduced by last merge

---
 MQ/hitbuilder/startMQ_Mcbm2021.sh      | 4 ++--
 macro/beamtime/mcbm2021/calib_batch.sh | 2 +-
 macro/beamtime/mcbm2021/mTofPar.par    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
 mode change 100644 => 100755 macro/beamtime/mcbm2021/calib_batch.sh

diff --git a/MQ/hitbuilder/startMQ_Mcbm2021.sh b/MQ/hitbuilder/startMQ_Mcbm2021.sh
index 1ac20e665e..dba97ce798 100755
--- a/MQ/hitbuilder/startMQ_Mcbm2021.sh
+++ b/MQ/hitbuilder/startMQ_Mcbm2021.sh
@@ -38,7 +38,7 @@ _pultotmax=500
 _puldetref=16 # TSR=032
 
 #_tofftof=0.  
-_tofftof=-30. 
+_tofftof=-35. 
 
 if [[ $_reqmod -eq 1 ]]; then
   _iUnp=1
@@ -152,7 +152,7 @@ UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,t
 UNPACKER+=" --severity  INFO" 
 UNPACKER+=" --SelectComponents 1"
 #UNPACKER+=" --ReqBeam      20486" # diamond -> 0x00005006 v14a
-#UNPACKER+=" --ReqBeam      10246" # diamond -> 0x00002806 v21a 
+UNPACKER+=" --ReqBeam      10246" # diamond -> 0x00002806 v21a 
 if  [[ $_reqmod -lt 1 ]]; then
     UNPACKER+=" --ReqMode 0"
     case $_reqmod in
diff --git a/macro/beamtime/mcbm2021/calib_batch.sh b/macro/beamtime/mcbm2021/calib_batch.sh
old mode 100644
new mode 100755
index fd6e87fe73..9dc76d14d4
--- a/macro/beamtime/mcbm2021/calib_batch.sh
+++ b/macro/beamtime/mcbm2021/calib_batch.sh
@@ -78,7 +78,7 @@ source ./init_cal_all.sh ${RunIdMode} ${CalSet} ${Deadtime}
 
 cd  ${wdir}
 #echo execute: ./iter_calib.sh ${RunIdMode} ${CalSet} ${Sel2} ${Deadtime}
-#source ./iter_calib.sh ${RunIdMode} ${CalSet} ${Sel2} ${Deadtime}
+#source ./iter_calib.sh ${RunIdMode} ${CalSet} ${Sel2} ${Deadtime} 
 
 cd  ${wdir}
 echo execute: ./gen_hits.sh ${RunIdMode} ${CalSet} ${Sel2} ${Deadtime}
diff --git a/macro/beamtime/mcbm2021/mTofPar.par b/macro/beamtime/mcbm2021/mTofPar.par
index 98fb36b2fc..a64f628973 100644
--- a/macro/beamtime/mcbm2021/mTofPar.par
+++ b/macro/beamtime/mcbm2021/mTofPar.par
@@ -2,7 +2,7 @@
 //----------------------------------------------------------------------------
 NrOfGdpbs: Int_t 9
 GdpbIdArray: Int_t \
-0x5b7b 0x55c4 0x18c5 0x5f64 0x18e3 0x181c 0x1922 0x1925 0x1902
+0x5b7b 0x55c4 0x18c5 0x5f64 0x1889 0x181c 0x1922 0x1925 0x1902
 NrOfFeesPerGdpb: Int_t 30
 NrOfGet4PerFee:  Int_t 8
 NrOfChannelsPerGet4: Int_t 4
-- 
GitLab


From 8a20397b01c2e63153c8f744c8ac9b77942e5ffe Mon Sep 17 00:00:00 2001
From: Norbert Herrmann <n.herrmann@physi.uni-heidelberg.de>
Date: Sat, 10 Apr 2021 09:26:32 +0200
Subject: [PATCH 2/5] add DigiRate histograms

---
 macro/beamtime/mcbm2021/ana_trks.C            | 23 ++++++++++---------
 macro/beamtime/mcbm2021/gen_hits.sh           |  2 +-
 macro/beamtime/mcbm2021/init_cal_all.sh       |  6 ++---
 macro/beamtime/mcbm2021/iter_tracks.sh        |  2 +-
 macro/beamtime/mcbm2021/trk_cal_digi.sh       |  9 ++++----
 reco/detectors/tof/CbmTofEventClusterizer.cxx | 11 +++++++++
 reco/detectors/tof/CbmTofEventClusterizer.h   |  1 +
 reco/detectors/tof/CbmTofFindTracks.cxx       |  2 +-
 8 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/macro/beamtime/mcbm2021/ana_trks.C b/macro/beamtime/mcbm2021/ana_trks.C
index 4b82773a8e..16565aed72 100644
--- a/macro/beamtime/mcbm2021/ana_trks.C
+++ b/macro/beamtime/mcbm2021/ana_trks.C
@@ -163,8 +163,9 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString
   //tofFindTracks->SetTtTarg(0.055);  // target value Nov2019 (triple stack run 831)
   //tofFindTracks->SetTtTarg(0.048);  // target value Nov2019 (double stack run 714)
   //tofFindTracks->SetTtTarg(0.047);  // target value Mar2020, after T0 fix (full run 600)
-  //  0.044);  // target value Mar2020, after T0 fix (double stack run 714)
-  tofFindTracks->SetTtTarg(0.035);             // target value for inverse velocity, > 0.033 ns/cm!
+    tofFindTracks->SetTtTarg(0.058);  // target value Mar2021, after T0 fix (double stack run 1058)
+  //tofFindTracks->SetTtTarg(0.038);  // target value Mar2021, after T0 fix (double stack run 1051)
+  //tofFindTracks->SetTtTarg(0.035);             // target value for inverse velocity, > 0.033 ns/cm!
   tofFindTracks->SetCalParFileName(cTrkFile);  // Tracker parameter value file name
   tofFindTracks->SetBeamCounter(5, 0, 0);      // default beam counter
   tofFindTracks->SetR0Lim(20.);
@@ -236,15 +237,15 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString
       iMinNofHits   = 4;
       iNStations    = 9;
       iNReqStations = 5;
-      tofFindTracks->SetStation(0, 5, 0, 0);
-      tofFindTracks->SetStation(1, 0, 4, 1);
-      tofFindTracks->SetStation(2, 0, 3, 1);
-      tofFindTracks->SetStation(3, 0, 4, 0);
-      tofFindTracks->SetStation(4, 0, 3, 2);
-      tofFindTracks->SetStation(5, 9, 0, 0);
-      tofFindTracks->SetStation(6, 9, 1, 0);
-      tofFindTracks->SetStation(7, 9, 0, 1);
-      tofFindTracks->SetStation(8, 9, 1, 1);
+      tofFindTracks->SetStation(0, 0, 4, 1);
+      tofFindTracks->SetStation(1, 9, 0, 0);
+      tofFindTracks->SetStation(2, 9, 1, 0);
+      tofFindTracks->SetStation(3, 9, 0, 1);
+      tofFindTracks->SetStation(4, 9, 1, 1);
+      tofFindTracks->SetStation(5, 0, 3, 1);
+      tofFindTracks->SetStation(6, 0, 4, 0);
+      tofFindTracks->SetStation(7, 0, 3, 2);
+      tofFindTracks->SetStation(8, 5, 0, 0);
       break;
 
     case 2:
diff --git a/macro/beamtime/mcbm2021/gen_hits.sh b/macro/beamtime/mcbm2021/gen_hits.sh
index d2329381c2..be07761174 100755
--- a/macro/beamtime/mcbm2021/gen_hits.sh
+++ b/macro/beamtime/mcbm2021/gen_hits.sh
@@ -63,7 +63,7 @@ fi
 Nevt=$7
 if [[ ${Nevt} = "" ]]; then
     echo use all events
-    Nevt=-1
+    Nevt=500000
 fi
 
 echo gen_hits for $cRun with iDut=$iDut, iRef=$iRef, iSet=$iCalSet, iSel2=$iSel2, iBRef=$iBRef, Deadtime=$Deadtime, CalFile=$CalFile
diff --git a/macro/beamtime/mcbm2021/init_cal_all.sh b/macro/beamtime/mcbm2021/init_cal_all.sh
index 5338124cb4..2de32139df 100755
--- a/macro/beamtime/mcbm2021/init_cal_all.sh
+++ b/macro/beamtime/mcbm2021/init_cal_all.sh
@@ -56,9 +56,9 @@ cp .rootrc ${cRun}
 cd ${cRun}
 
 # Global variables, for for-loops
-iRestart=0   
-#iRestart=1  # use copied calibration file with walk corrections 
-#iRestart=33
+#iRestart=0   
+iRestart=1  # use copied calibration file with walk corrections 
+#iRestart=37
 iStep=0
 iStepLast=0
 iCalSel0=0
diff --git a/macro/beamtime/mcbm2021/iter_tracks.sh b/macro/beamtime/mcbm2021/iter_tracks.sh
index aad60160b0..a511c8ab02 100755
--- a/macro/beamtime/mcbm2021/iter_tracks.sh
+++ b/macro/beamtime/mcbm2021/iter_tracks.sh
@@ -123,7 +123,7 @@ fi
 
 # correction modes: 2 - TOff from Tt, 3 - Pull t, 4 - x, 5 - y, 6 - z, >10 - Pull t of individual stations 
 #for iCal in 3 2 10 11 12 13 14 15 4 5; do
-for iCal in 3 4 5; do
+for iCal in 2 3 4 5; do
 #for iCal in 3 2 4; do
 #for iCal in 3 2 ; do
 #for iCal in 2 ; do
diff --git a/macro/beamtime/mcbm2021/trk_cal_digi.sh b/macro/beamtime/mcbm2021/trk_cal_digi.sh
index 2e7e87c263..8efb9ebe22 100755
--- a/macro/beamtime/mcbm2021/trk_cal_digi.sh
+++ b/macro/beamtime/mcbm2021/trk_cal_digi.sh
@@ -108,7 +108,8 @@ if [[ $iShLev = "" ]]; then
   dDTRMSres=100000
   dL0DTRMSres=100000
 # get initial digi calibration 
-  cp -v  ./I*/${CalFile}  .
+# cp -v  ./I*/${CalFile}  .
+  cp -v ${CalFile}  IniTrk_${CalFile}
 # get latest tracker offsets
 # cp -v ../${cRun}_tofFindTracks.hst.root .
 else
@@ -159,7 +160,7 @@ while [[ $dDTres -gt 0 ]]; do
     cd $wdir/$cRun
     echo Current loop with Iter $iIter, CalAct $iCalAct and CalOpt $iCalOpt
     if [[ $iCalOpt = 1 ]] || [[ $iCalAct -gt 1 ]]; then 
-      root -b -q '../ana_digi_cal.C('$nEvt',93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") '
+      root -b -q '../ana_digi_cal_all.C('$nEvt',93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") '
       # update calibration parameter file, will only be active in next iteration 
       if [[ $iIter = -10 ]] && [[ $iCalOpt = 1 ]]; then  # exploratory option when iIter set to 0 
         echo Update Calibration file from ana_digi_cal
@@ -168,8 +169,8 @@ while [[ $dDTres -gt 0 ]]; do
         echo 20000 > TOffAvRMS.res
       else
         root -b -q '../ana_trks.C('$nEvt','$iSel','$iGenCor',"'$cRun'","'$cCalSet2'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$Deadtime',"'$CalIdMode'",1,1,'$iCalSet','$iCalAct')'
-      #root -l 'ana_trksi.C(-1,10,1,"385.50.5.0","000014500_020",20,1,1.90,7.60,50,"385.50.5.0",1,1)'
-  
+        #root -l 'ana_trksi.C(-1,10,1,"385.50.5.0","000014500_020",20,1,1.90,7.60,50,"385.50.5.0",1,1)'
+        #exit 0 # for debugging
         cp -v New_${CalFile} ${CalFile}  
       fi
       (( iIter   += 1 ))
diff --git a/reco/detectors/tof/CbmTofEventClusterizer.cxx b/reco/detectors/tof/CbmTofEventClusterizer.cxx
index 65fb304247..498e07bb77 100644
--- a/reco/detectors/tof/CbmTofEventClusterizer.cxx
+++ b/reco/detectors/tof/CbmTofEventClusterizer.cxx
@@ -153,6 +153,7 @@ CbmTofEventClusterizer::CbmTofEventClusterizer(const char* name, Int_t verbose,
   , fhRpcDigiDTLD()
   , fhRpcDigiDTFD()
   , fhRpcDigiDTMul()
+  , fhRpcDigiRate()
   , fhRpcCluMul()
   , fhRpcCluRate()
   , fhRpcCluRate10s()
@@ -1175,6 +1176,7 @@ Bool_t CbmTofEventClusterizer::CreateHistos()
   fhRpcDigiDTLD.resize(iNbDet);
   fhRpcDigiDTFD.resize(iNbDet);
   fhRpcDigiDTMul.resize(iNbDet);
+  fhRpcDigiRate.resize(iNbDet);
   fhRpcCluMul.resize(iNbDet);
   fhRpcCluRate.resize(iNbDet);
   fhRpcCluRate10s.resize(iNbDet);
@@ -1266,6 +1268,10 @@ Bool_t CbmTofEventClusterizer::CreateHistos()
                                              iRpcId, iSmId, iSmType),
                                         fDigiBdfPar->GetNbChan(iSmType, iRpcId) * 2, 0,
                                         fDigiBdfPar->GetNbChan(iSmType, iRpcId) * 2, 20., 0.5, 20.5);
+    fhRpcDigiRate[iDetIndx] =
+      new TH1D(Form("cl_SmT%01d_sm%03d_rpc%03d_digirate", iSmType, iSmId, iRpcId),
+               Form("Digi rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)", iRpcId, iSmId, iSmType), 36000.,
+               0., 3600.);
 
     fhRpcCluMul[iDetIndx] =
       new TH1F(Form("cl_SmT%01d_sm%03d_rpc%03d_Mul", iSmType, iSmId, iRpcId),
@@ -4069,6 +4075,11 @@ Bool_t CbmTofEventClusterizer::BuildClusters()
         else
           break;
 
+        if (StartAnalysisTime > 0) {
+          Double_t dTimeAna = (pDigi->GetTime() - StartAnalysisTime) / 1.E9;
+          fhRpcDigiRate[iDetIndx]->Fill(dTimeAna, 1. / fhRpcDigiRate[iDetIndx]->GetBinWidth(1));
+        }
+
         size_t iDigiCh = pDigi->GetChannel() * 2 + pDigi->GetSide();
         if (iDigiCh < fvTimeLastDigi[iDetIndx].size()) {
           if (fvTimeLastDigi[iDetIndx][iDigiCh] > 0) {
diff --git a/reco/detectors/tof/CbmTofEventClusterizer.h b/reco/detectors/tof/CbmTofEventClusterizer.h
index a5dfd338e8..6e28173523 100644
--- a/reco/detectors/tof/CbmTofEventClusterizer.h
+++ b/reco/detectors/tof/CbmTofEventClusterizer.h
@@ -304,6 +304,7 @@ private:
   std::vector<TH2*> fhRpcDigiDTLD;                           //[nbDet]
   std::vector<TH2*> fhRpcDigiDTFD;                           //[nbDet]
   std::vector<TH2*> fhRpcDigiDTMul;                          //[nbDet]
+  std::vector<TH1*> fhRpcDigiRate;                            //[nbDet]
   std::vector<TH1*> fhRpcCluMul;                             //[nbDet]
   std::vector<TH1*> fhRpcCluRate;                            //[nbDet]
   std::vector<TH1*> fhRpcCluRate10s;                         //[nbDet]
diff --git a/reco/detectors/tof/CbmTofFindTracks.cxx b/reco/detectors/tof/CbmTofFindTracks.cxx
index 2e2cc4197b..daa187bdf6 100644
--- a/reco/detectors/tof/CbmTofFindTracks.cxx
+++ b/reco/detectors/tof/CbmTofFindTracks.cxx
@@ -1254,7 +1254,7 @@ void CbmTofFindTracks::CreateHistograms()
                          100, -DZ0MAX, DZ0MAX);
 
   fhTOff_Smt   = new TH2F(Form("hTOff_Smt"), Form("Tracklet TOff; RpcInd ; #DeltaTOff (ns)"), nSmt, 0, nSmt, 501,
-                        -fT0MAX * 20, fT0MAX * 20);
+                        -fT0MAX * 5, fT0MAX * 5);
   fhTOff_HMul2 = new TH2F(Form("hTOff_HMul2"), Form("Tracklet TOff(HMul2); RpcInd ; TOff (ns)"), nSmt, 0, nSmt, 500,
                           -fT0MAX, fT0MAX);
 
-- 
GitLab


From 5f876b95f10d3c02311d0cb830ee8d233557fa34 Mon Sep 17 00:00:00 2001
From: Norbert Herrmann <n.herrmann@physi.uni-heidelberg.de>
Date: Wed, 14 Apr 2021 10:17:54 +0200
Subject: [PATCH 3/5] modified treatment of T0 calibration

---
 reco/detectors/tof/CbmTofEventClusterizer.cxx | 102 ++++++++++++------
 1 file changed, 69 insertions(+), 33 deletions(-)

diff --git a/reco/detectors/tof/CbmTofEventClusterizer.cxx b/reco/detectors/tof/CbmTofEventClusterizer.cxx
index 498e07bb77..4cfb6c757a 100644
--- a/reco/detectors/tof/CbmTofEventClusterizer.cxx
+++ b/reco/detectors/tof/CbmTofEventClusterizer.cxx
@@ -1270,8 +1270,8 @@ Bool_t CbmTofEventClusterizer::CreateHistos()
                                         fDigiBdfPar->GetNbChan(iSmType, iRpcId) * 2, 20., 0.5, 20.5);
     fhRpcDigiRate[iDetIndx] =
       new TH1D(Form("cl_SmT%01d_sm%03d_rpc%03d_digirate", iSmType, iSmId, iRpcId),
-               Form("Digi rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)", iRpcId, iSmId, iSmType), 36000.,
-               0., 3600.);
+               Form("Digi rate of Rpc #%03d in Sm %03d of type %d; Time (s); Rate (Hz)", iRpcId, iSmId, iSmType),
+               36000., 0., 3600.);
 
     fhRpcCluMul[iDetIndx] =
       new TH1F(Form("cl_SmT%01d_sm%03d_rpc%03d_Mul", iSmType, iSmId, iRpcId),
@@ -1875,9 +1875,10 @@ Bool_t CbmTofEventClusterizer::FillHistos()
       }  // iHitInd loop end
 
       // do reference first
-      dTRef     = dDoubleMax;
-      fTRefHits = 0;
-
+      dTRef            = dDoubleMax;
+      fTRefHits        = 0;
+      Double_t dTRefAv = 0.;
+      std::vector<CbmTofHit*> pvBeamRef;
       for (Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) {
         pHit = (CbmTofHit*) fTofHitsColl->At(iHitInd);
         if (NULL == pHit) continue;
@@ -1902,16 +1903,32 @@ Bool_t CbmTofEventClusterizer::FillHistos()
           if (TotSum > fhRpcCluTot[iIndexDut]->GetYaxis()->GetXmax()) continue;  // ignore too large clusters
 
           fTRefHits = 1;
+          pvBeamRef.push_back(pHit);
           if (pHit->GetTime() < dTRef) {
             dTRef    = pHit->GetTime();
             pBeamRef = pHit;
           }
+          dTRefAv = (dTRefAv * iBeamRefMul + pHit->GetTime()) / (iBeamRefMul + 1);
           iBeamRefMul++;
         }
         else {  //additional reference type multiplicity
           if (fiBeamRefType == CbmTofAddress::GetSmType(iDetId)) iBeamAddRefMul++;
         }
       }
+      if (iBeamRefMul > 2) {
+        //LOG(info) << "BeamRefMul " << iBeamRefMul << ", pick hit with time closest to average " << dTRefAv << " from "
+        //          << pvBeamRef.size();
+        Double_t dTDist = dDoubleMax;
+        for (UInt_t i = 0; i < pvBeamRef.size(); i++) {
+          //LOG(info) << "i " << i << " " << pvBeamRef[i]->GetTime();
+          if (TMath::Abs(pvBeamRef[i]->GetTime() - dTRefAv) < dTDist) {
+            pBeamRef = pvBeamRef[i];
+            dTRef    = pBeamRef->GetTime();
+            dTDist   = TMath::Abs(dTRef - dTRefAv);
+          }
+        }
+      }
+
       LOG(debug) << "CbmTofEventClusterizer::FillHistos: BRefMul: " << iBeamRefMul << ", " << iBeamAddRefMul;
 
       if (iBeamRefMul == 0) return kFALSE;                  // don't fill histos without reference time
@@ -2542,17 +2559,17 @@ Bool_t CbmTofEventClusterizer::FillHistos()
 									 +TMath::Power(pHit->GetY()-dzscal*pTrig[iSel]->GetY(),2.))<fdCaldXdYMax
 									 * fhTRpcCluTOff[iIndexDut][iSel]->GetYaxis()->GetXmax())
 									 */
-                  fhTRpcCluTOff[iDetIndx][iSel]->Fill((Double_t) iCh,
-                                                      pHit->GetTime()
-                                                        - dTTrig[iSel]);  // -dTTcor[iSel] only valid for matches
-                  if (digiMatch->GetNofLinks() > 0)
+                  if (digiMatch->GetNofLinks() > 0) {
+                    fhTRpcCluTOff[iDetIndx][iSel]->Fill((Double_t) iCh,
+                                                        pHit->GetTime()
+                                                          - dTTrig[iSel]);  // -dTTcor[iSel] only valid for matches
                     fhTRpcCluTofOff[iDetIndx][iSel]->Fill((Double_t) iCh,
                                                           pHit->GetTime()
                                                             - dTTrig[iSel]);  // valid for beam experiments
-                  //  pHit->GetTime()-pBeamRef->GetTime());  // shift cluster time to beamcounter  time
-                  // pHit->GetTime()-pBeamRef->GetTime()-fdToDAv*pTrig[iSel]->GetR());// valid for beam experiments
+                    //  pHit->GetTime()-pBeamRef->GetTime());  // shift cluster time to beamcounter  time
+                    // pHit->GetTime()-pBeamRef->GetTime()-fdToDAv*pTrig[iSel]->GetR());// valid for beam experiments
+                  }
                 }
-
               if (fvLastHits[iSmType][iSm][iRpc][iCh].size() > 1) {  // check for previous hits in memory time interval
                 std::list<CbmTofHit*>::iterator itL = fvLastHits[iSmType][iSm][iRpc][iCh].end();
                 itL--;
@@ -3369,7 +3386,8 @@ Bool_t CbmTofEventClusterizer::WriteHistos()
                 Double_t dTWidth = 0;
                 // don't shift time of reference counter on average
                 if (iCh == 0) {
-                  Double_t dW = 0.;
+                  Double_t dW  = 0.;
+                  TBeamRefMean = 0.;
                   for (Int_t iRefCh = 0; iRefCh < iNbCh; iRefCh++) {
                     Double_t dWCh = ((TH1*) htempTOff_px)->GetBinContent(iRefCh + 1);
                     if (0 < dWCh) {
@@ -3378,15 +3396,21 @@ Bool_t CbmTofEventClusterizer::WriteHistos()
                         TH1* hTy          = (TH1*) htempTOff->ProjectionY(Form("%s_py%d", htempTOff->GetName(), iRefCh),
                                                                  iRefCh + 1, iRefCh + 1);
                         Double_t dFMean   = hTy->GetBinCenter(hTy->GetMaximumBin());
-                        Double_t dFLim    = 0.5;  // CAUTION, fixed numeric value
+                        Double_t dFLim    = 1.;  // CAUTION, fixed numeric value
                         Double_t dBinSize = hTy->GetBinWidth(1);
                         dFLim             = TMath::Max(dFLim, 5. * dBinSize);
                         TFitResultPtr fRes = hTy->Fit("gaus", "SQM", "", dFMean - dFLim, dFMean + dFLim);
-                        LOG(debug) << "CalibC "
-                                   << Form(" TSRC %d%d%d%d gaus %8.2f %8.2f %8.2f ", iSmType, iSm, iRpc, iRefCh,
-                                           fRes->Parameter(0), fRes->Parameter(1), fRes->Parameter(2));
-                        TBeamRefMean += fRes->Parameter(1) * dWCh;  //overwrite mean
-                        dTWidth += fRes->Parameter(2) * dWCh;       //calculate width
+                        LOG(info) << "CalibC "
+                                  << Form(" TSRC %d%d%d%d gaus %8.2f %8.2f %8.2f ", iSmType, iSm, iRpc, iRefCh,
+                                          fRes->Parameter(0), fRes->Parameter(1), fRes->Parameter(2));
+                        if (fRes->Parameter(2) < 2.) {
+                          TBeamRefMean += fRes->Parameter(1) * dWCh;  // consider for mean
+                          dTWidth += fRes->Parameter(2) * dWCh;       //calculate width
+                        }
+                        else {
+                          TBeamRefMean += ((TProfile*) htempTOff_pfx)->GetBinContent(iRefCh + 1) * dWCh;
+                          dTWidth += ((TProfile*) htempTOff_pfx)->GetBinError(iRefCh + 1) * dWCh;
+                        }
                       }
                       else {
                         TBeamRefMean += ((TProfile*) htempTOff_pfx)->GetBinContent(iRefCh + 1) * dWCh;
@@ -3394,11 +3418,21 @@ Bool_t CbmTofEventClusterizer::WriteHistos()
                       }
                       TBeamRefMean += dWCh *  // enforce <offset>=0
                                       fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
-                    }
-                  }
+                    }  // dWCh > 0
+                  }    // iRefCh loop end
                   if (dW > 0.) {
                     TBeamRefMean /= dW;
                     dTWidth /= dW;
+                    // refit combined distribution
+                    TH1* hTy           = (TH1*) htempTOff->ProjectionY(Form("%s_py", htempTOff->GetName()));
+                    Double_t dFMean    = hTy->GetBinCenter(hTy->GetMaximumBin());
+                    Double_t dFLim     = 1.;  // CAUTION, fixed numeric value
+                    Double_t dBinSize  = hTy->GetBinWidth(1);
+                    dFLim              = TMath::Max(dFLim, 5. * dBinSize);
+                    TFitResultPtr fRes = hTy->Fit("gaus", "SQM", "", dFMean - dFLim, dFMean + dFLim);
+                    LOG(debug) << "<U> BeamRef Mean: " << fRes->Parameter(1) << ", " << TBeamRefMean
+                               << ", Width: " << fRes->Parameter(2) << ", " << dTWidth;
+                    TBeamRefMean = fRes->Parameter(1);
                     // TBD apply offset all other detectors since beam counter will not be shifted
                     LOG(info) << "<I> T0 shift all offsets by " << TBeamRefMean << ", AvWidth " << dTWidth;
                   }
@@ -3413,11 +3447,12 @@ Bool_t CbmTofEventClusterizer::WriteHistos()
                                      ((TProfile*) hAvTOff_pfx)->GetBinContent(iSm * iNbRpc + iRpc + 1), TBeamRefMean,
                                      fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
                                      fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] + TMean - TBeamRefMean);
-                //            TMean-=((TProfile *)hAvTOff_pfx)->GetBinContent(iSm*iNbRpc+iRpc+1);
+                // TMean-=((TProfile *)hAvTOff_pfx)->GetBinContent(iSm*iNbRpc+iRpc+1);
                 TMean -= TBeamRefMean;
               }  // beam counter end
               else {
-                TMean += TBeamRefMean;
+                // TMean += TBeamRefMean;  // destroys convergence
+                TMean -= TBeamRefMean;
               }
               if (htempTOff_px->GetBinContent(iCh + 1) > WalkNHmin) {
                 Double_t dOff0 = fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0];
@@ -3425,12 +3460,13 @@ Bool_t CbmTofEventClusterizer::WriteHistos()
                 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0] += -dTYOff + TMean;
                 fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1] += +dTYOff + TMean;
                 //if(iSmType==0 && iSm==4 && iRpc==2 && iCh==26)
-                LOG(debug) << Form("CalibB %d,%2d,%2d: TSRC %d%d%d%d, hits %6.0f, YM %6.3f"
-                                   ", dTY %6.3f, TM %8.3f, Off %8.3f,%8.3f -> %8.3f,%8.3f ",
-                                   fCalMode, fCalSel, fTRefMode, iSmType, iSm, iRpc, iCh,
-                                   htempTOff_px->GetBinContent(iCh + 1), YMean, dTYOff, TMean, dOff0, dOff1,
-                                   fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
-                                   fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
+                if (iCh == 1)
+                  LOG(info) << Form("CalibB %d,%2d,%2d: TSRC %d%d%d%d, hits %6.0f, YM %6.3f"
+                                    ", dTY %6.3f, TM %8.3f %8.3f, Off %8.3f,%8.3f -> %8.3f,%8.3f ",
+                                    fCalMode, fCalSel, fTRefMode, iSmType, iSm, iRpc, iCh,
+                                    htempTOff_px->GetBinContent(iCh + 1), YMean, dTYOff, TMean, TBeamRefMean, dOff0,
+                                    dOff1, fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][0],
+                                    fvCPTOff[iSmType][iSm * iNbRpc + iRpc][iCh][1]);
               }
               /*
 					 Double_t TotMean=((TProfile *)htempTot_pfx)->GetBinContent(iCh+1);
@@ -5213,10 +5249,10 @@ Bool_t CbmTofEventClusterizer::BuildHits()
                                          << L0.GetIndex();
                               Int_t iDigIndL = L0.GetIndex();
                               if (iDigIndL >= (Int_t) vDigiIndRef.size()) {
-                                if (iDetId != fiBeamRefAddr) {
-                                  LOG(warn) << Form("Invalid DigiRefInd for det 0x%08x", iDetId);
-                                  continue;
-                                }
+                                //if (iDetId != fiBeamRefAddr) {
+                                LOG(warn) << Form("Invalid DigiRefInd for det 0x%08x", iDetId);
+                                break;
+                                //}
                               }
                               if (vDigiIndRef.at(iDigIndL) >= (Int_t) fTofCalDigiVec->size()) {
                                 LOG(warn) << "Invalid CalDigiInd";
-- 
GitLab


From a21302b6eb369ac9adf3462bdc7d8ca9e186c49b Mon Sep 17 00:00:00 2001
From: Norbert Herrmann <n.herrmann@physi.uni-heidelberg.de>
Date: Wed, 14 Apr 2021 10:18:51 +0200
Subject: [PATCH 4/5] add option for digi rates

---
 macro/beamtime/pl_all_CluRateRatio.C | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/macro/beamtime/pl_all_CluRateRatio.C b/macro/beamtime/pl_all_CluRateRatio.C
index 925ea19a5d..4852362c69 100644
--- a/macro/beamtime/pl_all_CluRateRatio.C
+++ b/macro/beamtime/pl_all_CluRateRatio.C
@@ -50,6 +50,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0.,
   switch (iMode) {
     case 0: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSm, iRp); break;
     case 1: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate10s", iSmType, iSm, iRp); break;
+    case 2: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_digirate", iSmType, iSm, iRp); break;
   }
   h = (TH1*) gROOT->FindObjectAny(hname);
   if (h != NULL) {
@@ -101,6 +102,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0.,
     switch (iMode) {
       case 0: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSm, iRp); break;
       case 1: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate10s", iSmType, iSm, iRp); break;
+      case 2: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_digirate", iSmType, iSm, iRp); break;
     }
     h = (TH1*) gROOT->FindObjectAny(hname);
     if (h != NULL) {
@@ -145,6 +147,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0.,
     switch (iMode) {
       case 0: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSm, iRp); break;
       case 1: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate10s", iSmType, iSm, iRp); break;
+      case 2: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_digirate", iSmType, iSm, iRp); break;
     }
     h = (TH1*) gROOT->FindObjectAny(hname);
     if (h != NULL) {
@@ -188,6 +191,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0.,
       }
       if (iSt == 0) {
         hRat->SetMinimum(1.E-2);
+        hRat->SetMaximum(2.);
         hRat->Draw("L E");
         hRat->GetXaxis()->SetRangeUser(Tstart, Tend);
       }
@@ -198,7 +202,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0.,
       if (iCol == 5) iCol++;  // skip yellow
 
       //h->UseCurrentStyle();
-      gPad->SetLogy();
+      //gPad->SetLogy();
     }
     else {
       cout << "Histogram " << hname << " not existing. " << endl;
-- 
GitLab


From 6a26103268c8fa97ec749b68d30d181dfd717d81 Mon Sep 17 00:00:00 2001
From: Norbert Herrmann <n.herrmann@physi.uni-heidelberg.de>
Date: Sat, 17 Apr 2021 11:27:14 +0200
Subject: [PATCH 5/5] fix Tof v20a geometry

---
 macro/tof/geometry/Create_TOF_Geometry_v20a.C | 848 +++++++-----------
 reco/detectors/tof/CbmTofEventClusterizer.cxx |   8 +-
 2 files changed, 327 insertions(+), 529 deletions(-)

diff --git a/macro/tof/geometry/Create_TOF_Geometry_v20a.C b/macro/tof/geometry/Create_TOF_Geometry_v20a.C
index ddb17ab7fa..59543475d0 100644
--- a/macro/tof/geometry/Create_TOF_Geometry_v20a.C
+++ b/macro/tof/geometry/Create_TOF_Geometry_v20a.C
@@ -62,45 +62,34 @@ 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_v20a_1e" == geoVersion ? 800 :                     // SIS 100 electron
-     ("tof_v20a_1h" == geoVersion ? 800 :                  // SIS 100 hadron
-        ("tof_v20a_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
-                        ))))))));
+const Double_t TOF_Z_Corr = ("tof_v20a_1e" == geoVersion ? 800 :                        // SIS 100 electron
+                               ("tof_v20a_1h" == geoVersion ? 800 :                     // SIS 100 hadron
+                                  ("tof_v20a_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_v20a_1m" == geoVersion ? (762 - TOF_Z_Corr) :        // SIS 100 muon
-     ("tof_v20a_1e" == geoVersion ? (703 - TOF_Z_Corr) :     // SIS 100 electron
-        ("tof_v20a_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
-                        ))))))));
+const Double_t TOF_Z_Front = ("tof_v20a_1m" == geoVersion ? (762 - TOF_Z_Corr) :                    // SIS 100 muon
+                                ("tof_v20a_1e" == geoVersion ? (703 - TOF_Z_Corr) :                 // SIS 100 electron
+                                   ("tof_v20a_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
+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
+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
@@ -134,34 +123,18 @@ const Double_t Glass_Z[NumberOfDifferentCounterTypes] = {0.1, 0.1, 0.1, 0.1};
 
 const Double_t GasGap_X[NumberOfDifferentCounterTypes] = {32., 32., 30.0, 30.0};
 const Double_t GasGap_Y[NumberOfDifferentCounterTypes] = {26.9, 53., 20., 10.};
-const Double_t GasGap_Z[NumberOfDifferentCounterTypes] = {0.025,
-                                                          0.025,
-                                                          0.025,
-                                                          0.025};
+const Double_t GasGap_Z[NumberOfDifferentCounterTypes] = {0.025, 0.025, 0.025, 0.025};
 
 const Int_t NumberOfGaps[NumberOfDifferentCounterTypes] = {8, 8, 8, 8};
 //const Int_t NumberOfGaps[NumberOfDifferentCounterTypes] = {1,1,1,1}; //deb
-const Int_t NumberOfReadoutStrips[NumberOfDifferentCounterTypes] = {32,
-                                                                    32,
-                                                                    64,
-                                                                    64};
+const Int_t NumberOfReadoutStrips[NumberOfDifferentCounterTypes] = {32, 32, 32, 32};
 //const Int_t NumberOfReadoutStrips[NumberOfDifferentCounterTypes] = {1,1,1,1}; //deb
 
-const Double_t SingleStackStartPosition_Z[NumberOfDifferentCounterTypes] =
-  {-0.6, -0.6, -0.6, -0.6};
-
-const Double_t Electronics_X[NumberOfDifferentCounterTypes] = {34.0,
-                                                               34.0,
-                                                               32.0,
-                                                               32.};
-const Double_t Electronics_Y[NumberOfDifferentCounterTypes] = {5.0,
-                                                               5.0,
-                                                               0.5,
-                                                               0.5};
-const Double_t Electronics_Z[NumberOfDifferentCounterTypes] = {0.3,
-                                                               0.3,
-                                                               0.3,
-                                                               0.3};
+const Double_t SingleStackStartPosition_Z[NumberOfDifferentCounterTypes] = {-0.6, -0.6, -0.6, -0.6};
+
+const Double_t Electronics_X[NumberOfDifferentCounterTypes] = {34.0, 34.0, 32.0, 32.};
+const Double_t Electronics_Y[NumberOfDifferentCounterTypes] = {5.0, 5.0, 0.5, 0.5};
+const Double_t Electronics_Z[NumberOfDifferentCounterTypes] = {0.3, 0.3, 0.3, 0.3};
 
 const Int_t NofModuleTypes     = 7;
 const Int_t MaxNofModules      = 128;
@@ -177,14 +150,12 @@ const Int_t NMTm = 3;
 // x - horizontal, y vertical, z along beam
 // all number for the 6m position
 
-Double_t xPosModm[NMTm][NMm] = {
-  {0., 0., 0., 0.},             //x - coordinates of center of M1 modules
-  {129.5, -129.5, 0., 0.},      //x - coordinates of center of M2 modules
-  {146., -146., 146., -146.}};  //x - coordinates of center of M3 modules
-Double_t yPosModm[NMTm][NMm] = {
-  {-92.1, 92.1, 0., 0.},        //y - coordinates of center of M1 modules
-  {0., 0., 0., 0.},             //y - coordinates of center of M2 modules
-  {-92.1, -92.1, 92.1, 92.1}};  //y - coordinates of center of M3 modules
+Double_t xPosModm[NMTm][NMm] = {{0., 0., 0., 0.},             //x - coordinates of center of M1 modules
+                                {129.5, -129.5, 0., 0.},      //x - coordinates of center of M2 modules
+                                {146., -146., 146., -146.}};  //x - coordinates of center of M3 modules
+Double_t yPosModm[NMTm][NMm] = {{-92.1, 92.1, 0., 0.},        //y - coordinates of center of M1 modules
+                                {0., 0., 0., 0.},             //y - coordinates of center of M2 modules
+                                {-92.1, -92.1, 92.1, 92.1}};  //y - coordinates of center of M3 modules
 
 // original z- positions
 /*
@@ -194,15 +165,13 @@ Double_t zPosModm[NMTm][NMm] = {{608.32,608.32,0.,0.},       //z - coordinates o
 */
 // inverted M1/M2 positions
 
-Double_t zPosModm[NMTm][NMm] = {
-  {632.22, 632.22, 0., 0.},           //z - coordinates of center of M1 modules
-  {608.22, 608.22, 0., 0.},           //z - coordinates of center of M2 modules
-  {656.12, 656.12, 656.12, 656.12}};  //z - coordinates of center of M3 modules
+Double_t zPosModm[NMTm][NMm] = {{632.22, 632.22, 0., 0.},           //z - coordinates of center of M1 modules
+                                {608.22, 608.22, 0., 0.},           //z - coordinates of center of M2 modules
+                                {656.12, 656.12, 656.12, 656.12}};  //z - coordinates of center of M3 modules
 
-Double_t FlipModm[NMTm][NMm] = {
-  {0., 180., 0., 0.},  //M1 rotation angle with respect to normal of surface
-  {0., 180., 0., 0.},  //M2 rotation angle
-  {0., 0., 0., 0.}};   //M3 rotation angle
+Double_t FlipModm[NMTm][NMm] = {{0., 180., 0., 0.},  //M1 rotation angle with respect to normal of surface
+                                {0., 180., 0., 0.},  //M2 rotation angle
+                                {0., 0., 0., 0.}};   //M3 rotation angle
 
 /*
 Double_t xPosModm[NMTm][NMm] = {{0.,0.,0.,0.},            //M1 coordinates
@@ -243,18 +212,15 @@ const Double_t CounterDypos2[NMTm] = { 8.,9.,8.};
 */
 
 //*************************************************************
-const Double_t xPosCounter1[32] = {
-  43.5,  14.5,  -14.5, -43.5, 43.5,  14.5,  -14.5, -43.5, 43.5,  14.5, -14.5,
-  -43.5, 43.5,  14.5,  -14.5, -43.5, 43.5,  14.5,  -14.5, -43.5, 43.5, 14.5,
-  -14.5, -43.5, 43.5,  14.5,  -14.5, -43.5, 43.5,  14.5,  -14.5, -43.5};
-const Double_t yPosCounter1[32] = {
-  -54.6, -54.6, -54.6, -54.6, -36.4, -36.4, -36.4, -36.4, -18.2, -18.2, -18.2,
-  -18.2, 0.,    0.,    0.,    0.,    18.2,  18.2,  18.2,  18.2,  36.4,  36.4,
-  36.4,  36.4,  50.5,  50.5,  50.5,  50.5,  59.6,  59.6,  59.6,  59.6};
-const Double_t zPosCounter1[32] = {
-  -3.01, -7.55, -3.01, -7.55, 6.07,  1.53,  6.07,  1.53,  -3.01, -7.55, -3.01,
-  -7.55, 6.07,  1.53,  6.07,  1.53,  -3.01, -7.55, -3.01, -7.55, 6.07,  1.53,
-  6.07,  1.53,  -3.01, -7.55, -3.01, -7.55, 6.07,  1.53,  6.07,  1.53};
+const Double_t xPosCounter1[32] = {43.5,  14.5,  -14.5, -43.5, 43.5,  14.5,  -14.5, -43.5, 43.5,  14.5, -14.5,
+                                   -43.5, 43.5,  14.5,  -14.5, -43.5, 43.5,  14.5,  -14.5, -43.5, 43.5, 14.5,
+                                   -14.5, -43.5, 43.5,  14.5,  -14.5, -43.5, 43.5,  14.5,  -14.5, -43.5};
+const Double_t yPosCounter1[32] = {-54.6, -54.6, -54.6, -54.6, -36.4, -36.4, -36.4, -36.4, -18.2, -18.2, -18.2,
+                                   -18.2, 0.,    0.,    0.,    0.,    18.2,  18.2,  18.2,  18.2,  36.4,  36.4,
+                                   36.4,  36.4,  50.5,  50.5,  50.5,  50.5,  59.6,  59.6,  59.6,  59.6};
+const Double_t zPosCounter1[32] = {-3.01, -7.55, -3.01, -7.55, 6.07,  1.53,  6.07,  1.53,  -3.01, -7.55, -3.01,
+                                   -7.55, 6.07,  1.53,  6.07,  1.53,  -3.01, -7.55, -3.01, -7.55, 6.07,  1.53,
+                                   6.07,  1.53,  -3.01, -7.55, -3.01, -7.55, 6.07,  1.53,  6.07,  1.53};
 /*
 const Double_t xPosCounter2[27] = {87.,58.,29.,0.,-29.,-58.,-87.,-58.,-87.,87.,58.,29.,0.,-29.,-58.,-87.,-58.,-87.,
 87.,58.,29.,0.,-29.,-58.,-87.,-58.,-87.};
@@ -264,94 +230,64 @@ const Double_t zPosCounter2[27] = {-7.55,-3.01,-7.55,-3.01,-7.55,-3.01,-7.55,6.0
 -3.01,-7.55,6.07,1.53,-7.55,-3.01,-7.55,-3.01,-7.55,-3.01,-7.55,6.07,1.53};
 */
 // rearranged: first all large, than the small counters
-const Double_t xPosCounter2[27] = {87.,  58.,  29.,  0.,   -29., 87.,  58.,
-                                   29.,  0.,   -29., 87.,  58.,  29.,  0.,
-                                   -29., -58., -87., -58., -87., -58., -87.,
-                                   -58., -87., -58., -87., -58., -87.};
-const Double_t yPosCounter2[27] = {-19., -19., -19., -19.,  -19.,  0.,   0.,
-                                   0.,   0.,   0.,   19.,   19.,   19.,  19.,
-                                   19.,  -24., -24., -14.4, -14.4, -4.8, -4.8,
-                                   4.8,  4.8,  14.4, 14.4,  24.,   24.};
-const Double_t zPosCounter2[27] = {
-  -7.55, -3.01, -7.55, -3.01, -7.55, 1.53,  6.07,  1.53,  6.07,
-  1.53,  -7.55, -3.01, -7.55, -3.01, -7.55, -3.01, -7.55, 6.07,
-  1.53,  -3.01, -7.55, 6.07,  1.53,  -3.01, -7.55, 6.07,  1.53};
-
-const Double_t xPosCounter3[42] = {
-  72.5,  43.5,  14.5,  -14.5, -43.5, -72.5, 72.5,  43.5,  14.5, -14.5, -43.5,
-  -72.5, 72.5,  43.5,  14.5,  -14.5, -43.5, -72.5, 72.5,  43.5, 14.5,  -14.5,
-  -43.5, -72.5, 72.5,  43.5,  14.5,  -14.5, -43.5, -72.5, 72.5, 43.5,  14.5,
-  -14.5, -43.5, -72.5, 72.5,  43.5,  14.5,  -14.5, -43.5, -72.5};
-const Double_t yPosCounter3[42] = {
-  -54.6, -54.6, -54.6, -54.6, -54.6, -54.6, -34.6, -34.6, -34.6, -34.6, -34.6,
-  -34.6, -18.2, -18.2, -18.2, -18.2, -18.2, -18.2, 0.,    0.,    0.,    0.,
-  0.,    0.,    18.2,  18.2,  18.2,  18.2,  18.2,  18.2,  34.6,  34.6,  34.6,
-  34.6,  34.6,  34.6,  54.6,  54.6,  54.6,  54.6,  54.6,  54.6};
-const Double_t zPosCounter3[42] = {
-  -7.55, -3.01, -7.55, -3.01, -7.55, -3.01, 1.53,  6.07,  1.53, 6.07, 1.53,
-  6.07,  -7.55, -3.01, -7.55, -3.01, -7.55, -3.01, 1.53,  6.07, 1.53, 6.07,
-  1.53,  6.07,  -7.55, -3.01, -7.55, -3.01, -7.55, -3.01, 1.53, 6.07, 1.53,
-  6.07,  1.53,  6.07,  -7.55, -3.01, -7.55, -3.01, -7.55, -3.01};
+const Double_t xPosCounter2[27] = {87.,  58.,  29.,  0.,   -29., 87.,  58.,  29.,  0.,   -29., 87.,  58.,  29., 0.,
+                                   -29., -58., -87., -58., -87., -58., -87., -58., -87., -58., -87., -58., -87.};
+const Double_t yPosCounter2[27] = {-19., -19., -19., -19.,  -19.,  0.,   0.,   0.,  0.,  0.,   19.,  19., 19., 19.,
+                                   19.,  -24., -24., -14.4, -14.4, -4.8, -4.8, 4.8, 4.8, 14.4, 14.4, 24., 24.};
+const Double_t zPosCounter2[27] = {-7.55, -3.01, -7.55, -3.01, -7.55, 1.53,  6.07,  1.53,  6.07,
+                                   1.53,  -7.55, -3.01, -7.55, -3.01, -7.55, -3.01, -7.55, 6.07,
+                                   1.53,  -3.01, -7.55, 6.07,  1.53,  -3.01, -7.55, 6.07,  1.53};
+
+const Double_t xPosCounter3[42] = {72.5,  43.5,  14.5,  -14.5, -43.5, -72.5, 72.5,  43.5,  14.5, -14.5, -43.5,
+                                   -72.5, 72.5,  43.5,  14.5,  -14.5, -43.5, -72.5, 72.5,  43.5, 14.5,  -14.5,
+                                   -43.5, -72.5, 72.5,  43.5,  14.5,  -14.5, -43.5, -72.5, 72.5, 43.5,  14.5,
+                                   -14.5, -43.5, -72.5, 72.5,  43.5,  14.5,  -14.5, -43.5, -72.5};
+const Double_t yPosCounter3[42] = {-54.6, -54.6, -54.6, -54.6, -54.6, -54.6, -34.6, -34.6, -34.6, -34.6, -34.6,
+                                   -34.6, -18.2, -18.2, -18.2, -18.2, -18.2, -18.2, 0.,    0.,    0.,    0.,
+                                   0.,    0.,    18.2,  18.2,  18.2,  18.2,  18.2,  18.2,  34.6,  34.6,  34.6,
+                                   34.6,  34.6,  34.6,  54.6,  54.6,  54.6,  54.6,  54.6,  54.6};
+const Double_t zPosCounter3[42] = {-7.55, -3.01, -7.55, -3.01, -7.55, -3.01, 1.53,  6.07,  1.53, 6.07, 1.53,
+                                   6.07,  -7.55, -3.01, -7.55, -3.01, -7.55, -3.01, 1.53,  6.07, 1.53, 6.07,
+                                   1.53,  6.07,  -7.55, -3.01, -7.55, -3.01, -7.55, -3.01, 1.53, 6.07, 1.53,
+                                   6.07,  1.53,  6.07,  -7.55, -3.01, -7.55, -3.01, -7.55, -3.01};
 
 //  trebuie recalculat pt a da centrul detectorului, nu coltul lui
 const Int_t NCounter1Y[NMTm]        = {6, 3, 7};
 const Double_t CounterXstart1[NMTm] = {
-  -43.5,
-  87.,
-  72.5};  // position of left most counter in x - direction (for un-rotated modules)
-const Double_t CounterYstart1[NMTm] = {
-  -54.6,
-  -19.,
-  -54.6};  // position of lowest counter in y direction (for un-rotated modules)
-const Double_t CounterDyoff1[NMTm][2] = {
-  {-4.54, 4.54},  // staggering in z direction due to row number
-  {4.54, -4.54},
-  {4.54, -4.54}};
-const Double_t CounterDzoff1[NMTm][2] = {
-  {4.54, -4.54},  // staggering in z direction due to column number
-  {4.54, -4.54},
-  {4.54, -4.54}};
-const Double_t CounterDxpos1[NMTm] = {
-  29.,
-  29.,
-  29.};  // distance of counters in x - direction
-const Double_t CounterDypos1[NMTm] = {
-  18.2,
-  19.,
-  18.2};  // distance of counters in y - direction
-
-const Int_t NCounter2Y[NMTm] = {
-  2,
-  6,
-  0};  //number of counters of 100 mm strip length in a column within each module type
+  -43.5, 87., 72.5};  // position of left most counter in x - direction (for un-rotated modules)
+const Double_t CounterYstart1[NMTm]   = {-54.6, -19.,
+                                       -54.6};  // position of lowest counter in y direction (for un-rotated modules)
+const Double_t CounterDyoff1[NMTm][2] = {{-4.54, 4.54},  // staggering in z direction due to row number
+                                         {4.54, -4.54},
+                                         {4.54, -4.54}};
+const Double_t CounterDzoff1[NMTm][2] = {{4.54, -4.54},  // staggering in z direction due to column number
+                                         {4.54, -4.54},
+                                         {4.54, -4.54}};
+const Double_t CounterDxpos1[NMTm]    = {29., 29., 29.};    // distance of counters in x - direction
+const Double_t CounterDypos1[NMTm]    = {18.2, 19., 18.2};  // distance of counters in y - direction
+
+const Int_t NCounter2Y[NMTm] = {2, 6,
+                                0};  //number of counters of 100 mm strip length in a column within each module type
 
 const Double_t CounterXstart2[NMTm]   = {-43.5, -58., 0.};
 const Double_t CounterYstart2[NMTm]   = {50.5, -24., 0.};
-const Double_t CounterDyoff2[NMTm][2] = {{-4.54, 4.54},
-                                         {-4.54, 4.54},
-                                         {0., 0.}};
-const Double_t CounterDzoff2[NMTm][2] = {{4.54, -4.54},
-                                         {4.54, -4.54},
-                                         {0., 0.}};
+const Double_t CounterDyoff2[NMTm][2] = {{-4.54, 4.54}, {-4.54, 4.54}, {0., 0.}};
+const Double_t CounterDzoff2[NMTm][2] = {{4.54, -4.54}, {4.54, -4.54}, {0., 0.}};
 const Double_t CounterDxpos2[NMTm]    = {29., 29., 29.};
 const Double_t CounterDypos2[NMTm]    = {9.1, 9.6, 0.};
 
 // Aluminum box for all module types
 //m,s,b,m1,m2,m3
-const Double_t Module_Size_X[NofModuleTypes] =
-  {180.2, 180.2, 180.2, 180.2, 127.0, 214.0, 185.0};
-const Double_t Module_Size_Y[NofModuleTypes] =
-  {49., 49., 49., 74., 141.7, 70.5, 141.7};
+const Double_t Module_Size_X[NofModuleTypes] = {180.2, 180.2, 180.2, 180.2, 127.0, 214.0, 185.0};
+const Double_t Module_Size_Y[NofModuleTypes] = {49., 49., 49., 74., 141.7, 70.5, 141.7};
 const Double_t Module_Over_Y[NofModuleTypes] = {11.5, 11.5, 11., 4.5, 4.5, 5.1};
-const Double_t Module_Size_Z[NofModuleTypes] =
-  {10., 10., 10., 10., 23.9, 23.9, 23.9};
-const Double_t Module_Thick_Alu_X_left  = 1.;
-const Double_t Module_Thick_Alu_X_right = 0.1;
-const Double_t Module_Thick_Alu_Y       = 0.1;
-const Double_t Module_Thick_Alu_Z       = 0.1;
+const Double_t Module_Size_Z[NofModuleTypes] = {10., 10., 10., 10., 23.9, 23.9, 23.9};
+const Double_t Module_Thick_Alu_X_left       = 1.;
+const Double_t Module_Thick_Alu_X_right      = 0.1;
+const Double_t Module_Thick_Alu_Y            = 0.1;
+const Double_t Module_Thick_Alu_Z            = 0.1;
 
-const Double_t shift_gas_box =
-  (Module_Thick_Alu_X_right - Module_Thick_Alu_X_left) / 2;
+const Double_t shift_gas_box = (Module_Thick_Alu_X_right - Module_Thick_Alu_X_left) / 2;
 
 // Distance to the center of the TOF wall [cm];
 // for 0m
@@ -371,9 +307,7 @@ const Double_t InnerWall_Z_PositionShift = 400.;    // -600.;  // inner wall pla
 const Double_t Wall_Z_PositionShift      = -25.; // -998.;  // outer wall placed at 1000
 */
 
-const Double_t Wall_Z_Position = TOF_Z_Front + 0.5 * Module_Size_Z[0]
-                                 + 3.5 * Module_Size_Z[1]
-                                 + 4.5 * Module_Size_Z[2];
+const Double_t Wall_Z_Position = TOF_Z_Front + 0.5 * Module_Size_Z[0] + 3.5 * Module_Size_Z[1] + 4.5 * Module_Size_Z[2];
 //const Double_t Wall_Z_Position = TOF_Z_Front + 98.5;  // corresponds to center of front module in the inner tower
 //const Double_t Wall_Z_Position = 1050;  // corresponds to center of front module in the inner tower
 //
@@ -387,17 +321,13 @@ const Double_t Wall_Z_Position = TOF_Z_Front + 0.5 * Module_Size_Z[0]
 
 //Type of Counter for module
 const Int_t CounterTypeInModule[NofModuleTypes] = {0, 0, 0, 1, 23, 23, 23};
-const Int_t NCounterInModule[NofModuleTypes] = {5, 5, 5, 5, 2408, 1512, 4200};
+const Int_t NCounterInModule[NofModuleTypes]    = {5, 5, 5, 5, 2408, 1512, 4200};
 
 // Placement of the counter inside the module
-const Double_t CounterXStartPosition[NofModuleTypes] =
-  {-60.0, -67.02, -67.02, -67.02, -60.0, -60.0, -16.0};
-const Double_t CounterXDistance[NofModuleTypes] =
-  {30.0, 30.351, 30.351, 30.351, 30.0, 30.0, 30.0};
-const Double_t CounterZDistance[NofModuleTypes] =
-  {2.5, 0.0, 0.0, 0.0, 2.5, 2.5, 2.5};
-const Double_t CounterRotationAngle[NofModuleTypes] =
-  {0., 8.7, 8.7, 8.7, 0., 0., 0.};
+const Double_t CounterXStartPosition[NofModuleTypes] = {-60.0, -67.02, -67.02, -67.02, -60.0, -60.0, -16.0};
+const Double_t CounterXDistance[NofModuleTypes]      = {30.0, 30.351, 30.351, 30.351, 30.0, 30.0, 30.0};
+const Double_t CounterZDistance[NofModuleTypes]      = {2.5, 0.0, 0.0, 0.0, 2.5, 2.5, 2.5};
+const Double_t CounterRotationAngle[NofModuleTypes]  = {0., 8.7, 8.7, 8.7, 0., 0., 0.};
 
 // Pole (support structure)
 const Int_t MaxNumberOfPoles = 200;
@@ -442,10 +372,8 @@ const Double_t Inner_Module_First_Y_Position            = 16.;
 const Double_t Inner_Module_Last_Y_Position             = 480.;
 const Double_t Inner_Module_X_Offset                    = 2.;
 const Int_t Inner_Module_NTypes                         = 3;
-const Double_t Inner_Module_Types[Inner_Module_NTypes]  = {4., 3., 0.};
-const Double_t Inner_Module_Number[Inner_Module_NTypes] = {2.,
-                                                           2.,
-                                                           6.};  //V13_3a
+const Double_t Inner_Module_Types[Inner_Module_NTypes]  = {4., 5., 6.};
+const Double_t Inner_Module_Number[Inner_Module_NTypes] = {2., 2., 4.};  //V13_3a
 //const Double_t Inner_Module_Number[Inner_Module_NTypes] = {0.,0.,0.}; //debugging
 
 const Double_t InnerSide_Module_X_Offset                    = 51.;
@@ -454,15 +382,13 @@ const Double_t InnerSide_Module_Types[Inner_Module_NTypes]  = {5.};
 const Double_t InnerSide_Module_Number[Inner_Module_NTypes] = {2.};  //v13_3a
 //const Double_t InnerSide_Module_Number[Inner_Module_NTypes] = {0.};  //debug
 
-const Double_t Outer_Module_First_Y_Position = 0.;
-const Double_t Outer_Module_Last_Y_Position  = 480.;
-const Double_t Outer_Module_X_Offset         = 3.;
-const Int_t Outer_Module_Col                 = 4;
-const Int_t Outer_Module_NTypes              = 2;
-const Double_t Outer_Module_Types[Outer_Module_NTypes][Outer_Module_Col] =
-  {1., 1., 1., 1., 2., 2., 2., 2.};
-const Double_t Outer_Module_Number[Outer_Module_NTypes][Outer_Module_Col] =
-  {9., 9., 2., 0., 0., 0., 3., 4.};  //V13_3a
+const Double_t Outer_Module_First_Y_Position                              = 0.;
+const Double_t Outer_Module_Last_Y_Position                               = 480.;
+const Double_t Outer_Module_X_Offset                                      = 3.;
+const Int_t Outer_Module_Col                                              = 4;
+const Int_t Outer_Module_NTypes                                           = 2;
+const Double_t Outer_Module_Types[Outer_Module_NTypes][Outer_Module_Col]  = {1., 1., 1., 1., 2., 2., 2., 2.};
+const Double_t Outer_Module_Number[Outer_Module_NTypes][Outer_Module_Col] = {9., 9., 2., 0., 0., 0., 3., 4.};  //V13_3a
 //const Double_t Outer_Module_Number[Outer_Module_NTypes][Outer_Module_Col] = {1.,1.,0.,0.,  0.,0.,0.,0.};//debug
 
 // some global variables
@@ -497,7 +423,8 @@ void position_tof_modules_m(Int_t, Int_t);
 void dump_info_file();
 void read_module_positions();
 
-void Create_TOF_Geometry_v16e() {
+void Create_TOF_Geometry_v20a()
+{
   // Load the necessary FairRoot libraries
   //  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
   //  basiclibs();
@@ -506,12 +433,9 @@ void Create_TOF_Geometry_v16e() {
   //  gSystem->Load("libBase");
 
   // Printout what we are generating
-  std::cout << "Generating geometry " << geoVersion << " at " << TOF_Z_Front
-            << " cm from target." << std::endl
-            << "Inner wall need to be shifted by " << InnerWall_Z_PositionShift
-            << std::endl
-            << "Outer wall need to be shifted by " << Wall_Z_PositionShift
-            << std::endl;
+  std::cout << "Generating geometry " << geoVersion << " at " << TOF_Z_Front << " cm from target." << std::endl
+            << "Inner wall need to be shifted by " << InnerWall_Z_PositionShift << std::endl
+            << "Outer wall need to be shifted by " << Wall_Z_PositionShift << std::endl;
 
   // read input Data
   read_module_positions();
@@ -537,8 +461,7 @@ void Create_TOF_Geometry_v16e() {
   TGeoVolume* tof           = new TGeoVolumeAssembly(geoVersion);
   top->AddNode(tof, 1, toftrans);
 
-  for (Int_t counterType = 0; counterType < NumberOfDifferentCounterTypes;
-       counterType++) {
+  for (Int_t counterType = 0; counterType < NumberOfDifferentCounterTypes; counterType++) {
     gCounter[counterType] = create_new_counter(counterType);
   }
 
@@ -598,11 +521,11 @@ void Create_TOF_Geometry_v16e() {
   //  top->Raytrace();
 
   // Printout what we are generating
-  std::cout << "Done generating geometry " << geoVersion << " at "
-            << TOF_Z_Front << " cm from target." << std::endl;
+  std::cout << "Done generating geometry " << geoVersion << " at " << TOF_Z_Front << " cm from target." << std::endl;
 }
 
-void read_module_positions() {
+void read_module_positions()
+{
   //TFile * fPosInput = new TFile( "TOF_10M.dat", "READ");
   ifstream inFile;
   inFile.open("TOF_10M.dat");
@@ -658,9 +581,8 @@ void read_module_positions() {
     xPosMod[iModType][iMod] = (Double_t) iX / 10.;
     yPosMod[iModType][iMod] = (Double_t) iY / 10.;
     zPosMod[iModType][iMod] = (Double_t) iZ / 10. + Wall_Z_PositionShift;
-    if (cPos == 'l') {
-      FlipMod[iModType][iMod] = 1.;
-    } else {
+    if (cPos == 'l') { FlipMod[iModType][iMod] = 1.; }
+    else {
       FlipMod[iModType][iMod] = 0.;
     }
     //  if (iModType==1 && iMod==1) return;
@@ -669,11 +591,11 @@ void read_module_positions() {
       <<yPosMod[iModType][iMod]<<", z "<<zPosMod[iModType][iMod]<<endl;
   */
   }
-  cout << "Data reading finished for " << NModules[0] << " modules of type 0, "
-       << NModules[1] << " of type 1, " << NModules[2] << " of type 2  "
-       << endl;
+  cout << "Data reading finished for " << NModules[0] << " modules of type 0, " << NModules[1] << " of type 1, "
+       << NModules[2] << " of type 2  " << endl;
 }
-void create_materials_from_media_file() {
+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();
@@ -705,7 +627,8 @@ void create_materials_from_media_file() {
   geoBuild->createMedium(carbon);
 }
 
-TGeoVolume* create_counter(Int_t modType) {
+TGeoVolume* create_counter(Int_t modType)
+{
 
   //glass
   Double_t gdx = Glass_X[modType];
@@ -740,26 +663,22 @@ TGeoVolume* create_counter(Int_t modType) {
   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
+  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);
+  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.);
+  TGeoTranslation* gas_gap_trans = new TGeoTranslation("", 0., 0., (gdz + ggdz) / 2.);
 
 
   // Single subdivided active gas gap
@@ -789,12 +708,10 @@ TGeoVolume* create_counter(Int_t modType) {
   TGeoVolume* multi_stack = new TGeoVolumeAssembly("multi_stack");
   Int_t l                 = 0;
   for (l = 0; l < ngaps; l++) {
-    TGeoTranslation* single_stack_trans =
-      new TGeoTranslation("", 0., 0., startzpos + l * dzpos);
+    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);
+  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
@@ -815,7 +732,8 @@ TGeoVolume* create_counter(Int_t modType) {
   return counter;
 }
 
-TGeoVolume* create_new_counter(Int_t modType) {
+TGeoVolume* create_new_counter(Int_t modType)
+{
 
   //glass
   Double_t gdx = Glass_X[modType];
@@ -843,16 +761,12 @@ TGeoVolume* create_new_counter(Int_t modType) {
   Double_t cdx = TMath::Max(gdx, ggdx);
   cdx          = TMath::Max(cdx, dxe) + 0.2;
   Double_t cdy = TMath::Max(gdy, ggdy) + 2 * dye + 0.2;
-  Double_t cdz = ngaps * ggdz + (ngaps + 1) * gdz
-                 + 0.2;  // ngaps * (gdz+ggdz) + gdz + 0.2; // ok
+  Double_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
-  Double_t dzpos = gdz + ggdz;
-  Double_t startzposglas =
-    -ngaps * (gdz + ggdz)
-    / 2.;  // -cdz/2.+0.1+gdz/2.; // ok  // (-cdz+gdz)/2.; // not ok
-  Double_t startzposgas =
-    startzposglas + gdz / 2. + ggdz / 2.;  // -cdz/2.+0.1+gdz   +ggdz/2.;  // ok
+  Double_t dzpos         = gdz + ggdz;
+  Double_t startzposglas = -ngaps * (gdz + ggdz) / 2.;  // -cdz/2.+0.1+gdz/2.; // ok  // (-cdz+gdz)/2.; // not ok
+  Double_t startzposgas  = startzposglas + gdz / 2. + ggdz / 2.;  // -cdz/2.+0.1+gdz   +ggdz/2.;  // ok
 
 
   // needed materials
@@ -864,18 +778,15 @@ TGeoVolume* create_new_counter(Int_t modType) {
 
   // define counter volume
   TGeoBBox* counter_box = new TGeoBBox("", cdx / 2., cdy / 2., cdz / 2.);
-  TGeoVolume* counter =
-    new TGeoVolume("counter", counter_box, noActiveGasVolMed);
+  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
+  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);
@@ -886,15 +797,13 @@ TGeoVolume* create_new_counter(Int_t modType) {
   // place 8 gas gaps and 9 glas plates in the counter
   for (Int_t igap = 0; igap <= ngaps; igap++) {
     // place (ngaps+1) glass plates
-    Double_t zpos_glas = startzposglas + igap * dzpos;
-    TGeoTranslation* glass_plate_trans =
-      new TGeoTranslation("", 0., 0., zpos_glas);
+    Double_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) {
-      Double_t zpos_gas = startzposgas + igap * dzpos;
-      TGeoTranslation* gas_gap_trans =
-        new TGeoTranslation("", 0., 0., zpos_gas);
+      Double_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;
@@ -916,7 +825,8 @@ TGeoVolume* create_new_counter(Int_t modType) {
   return counter;
 }
 
-TGeoVolume* create_tof_module(Int_t modType) {
+TGeoVolume* create_tof_module(Int_t modType)
+{
   Int_t cType          = CounterTypeInModule[modType];
   Double_t dx          = Module_Size_X[modType];
   Double_t dy          = Module_Size_Y[modType];
@@ -945,41 +855,34 @@ TGeoVolume* create_tof_module(Int_t modType) {
   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);
+  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.);
+  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)
     Double_t zpos;
-    if (0 == modType) {
-      zpos = dzoff *= -1;
-    } else {
+    if (0 == modType) { zpos = dzoff *= -1; }
+    else {
       zpos = 0.;
     }
-    TGeoTranslation* counter_trans =
-      new TGeoTranslation("", startxpos + j * dxpos, 0.0, zpos);
+    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);
+    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) {
-  if (modType > 3)
-    return create_new_tof_module_m(modType);  // Bucharest modules
+TGeoVolume* create_new_tof_module(Int_t modType)
+{
+  if (modType > 3) return create_new_tof_module_m(modType);  // Bucharest modules
 
   Int_t cType          = CounterTypeInModule[modType];
   Double_t dx          = Module_Size_X[modType];
@@ -1005,33 +908,25 @@ TGeoVolume* create_new_tof_module(Int_t modType) {
   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);
+  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.);
+  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 < NCounterInModule[modType]; j++) {  //loop over counters (modules)
     Double_t zpos;
-    if (0 == modType || 3 == modType || 4 == modType || 5 == modType) {
-      zpos = dzoff *= -1;
-    } else {
+    if (0 == modType || 3 == modType || 4 == modType || 5 == modType) { zpos = dzoff *= -1; }
+    else {
       zpos = 0.;
     }
-    TGeoTranslation* counter_trans =
-      new TGeoTranslation("", startxpos + j * dxpos, 0.0, zpos);
+    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);
+    TGeoCombiTrans* counter_combi_trans = new TGeoCombiTrans(*counter_trans, *counter_rot);
     gas_box_vol->AddNode(gCounter[cType], j, counter_combi_trans);
   }
 
@@ -1039,7 +934,8 @@ TGeoVolume* create_new_tof_module(Int_t modType) {
 }
 
 
-TGeoVolume* create_new_tof_module_m(Int_t modType) {
+TGeoVolume* create_new_tof_module_m(Int_t modType)
+{
   Int_t cType2 = CounterTypeInModule[modType] % 10;
   Int_t cType1 = (CounterTypeInModule[modType] - cType2) / 10;
 
@@ -1049,9 +945,8 @@ TGeoVolume* create_new_tof_module_m(Int_t modType) {
   Int_t jm         = modType - 4;
   const Int_t iNum = iNum1 + iNum2;
 
-  cout << " module_m: " << modType << ", " << jm << ": " << iNum1
-       << " counters type " << cType1 << ", " << iNum2 << " type " << cType2
-       << endl;
+  cout << " module_m: " << modType << ", " << jm << ": " << iNum1 << " counters type " << cType1 << ", " << iNum2
+       << " type " << cType2 << endl;
 
   Double_t dx          = Module_Size_X[modType];
   Double_t dy          = Module_Size_Y[modType];
@@ -1076,16 +971,12 @@ TGeoVolume* create_new_tof_module_m(Int_t modType) {
   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);
+  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.);
+  TGeoTranslation* gas_box_trans = new TGeoTranslation("", shift_gas_box, 0., 0.);
   module->AddNode(gas_box_vol, 0, gas_box_trans);
   Double_t xpos;
   Double_t ypos;
@@ -1121,14 +1012,13 @@ TGeoVolume* create_new_tof_module_m(Int_t modType) {
         break;
     }
 
-    cout << "Place counter " << j << " " << ii << ", iX " << iX << ", iY " << iY
-         << " at " << xpos << ", " << ypos << ", " << zpos << endl;
+    cout << "Place counter " << j << " " << ii << ", iX " << iX << ", iY " << iY << " at " << xpos << ", " << ypos
+         << ", " << zpos << endl;
 
     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);
+    TGeoCombiTrans* counter_combi_trans = new TGeoCombiTrans(*counter_trans, *counter_rot);
     gas_box_vol->AddNode(gCounter[cType1], j, counter_combi_trans);
     ii++;
   }
@@ -1138,8 +1028,7 @@ TGeoVolume* create_new_tof_module_m(Int_t modType) {
     Int_t iY  = j % NCounter2Y[jm];
     Int_t iX2 = iX % 2;
     Int_t iY2 = iY % 2;
-    cout << "Put counter type 2 j=" << j << ", jm: " << jm << ", iX " << iX
-         << ", iY " << iY << ", iX2 " << iX2 << endl;
+    cout << "Put counter type 2 j=" << j << ", jm: " << jm << ", iX " << iX << ", iY " << iY << ", iX2 " << iX2 << endl;
     /*
     Double_t xpos = CounterXstart2[jm] + iX*CounterDxpos2[jm];
     Double_t ypos = CounterYstart2[jm] + iY*CounterDypos2[jm];
@@ -1165,13 +1054,12 @@ TGeoVolume* create_new_tof_module_m(Int_t modType) {
     }
 
 
-    cout << "Place counter " << j << ", iX " << iX << ", iY " << iY << " at "
-         << xpos << ", " << ypos << ", " << zpos << endl;
+    cout << "Place counter " << j << ", iX " << iX << ", iY " << iY << " at " << xpos << ", " << ypos << ", " << zpos
+         << endl;
     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);
+    TGeoCombiTrans* counter_combi_trans = new TGeoCombiTrans(*counter_trans, *counter_rot);
     gas_box_vol->AddNode(gCounter[cType2], j + iNum1, counter_combi_trans);
     ii++;
   }
@@ -1180,7 +1068,8 @@ TGeoVolume* create_new_tof_module_m(Int_t modType) {
 }
 
 
-TGeoVolume* create_tof_pole() {
+TGeoVolume* create_tof_pole()
+{
   // needed materials
   TGeoMedium* boxVolMed = gGeoMan->GetMedium(PoleVolumeMedium);
   TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium);
@@ -1192,10 +1081,9 @@ TGeoVolume* create_tof_pole() {
   Double_t width_aluy = Pole_Thick_Y;
   Double_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);
+  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.);
@@ -1206,32 +1094,28 @@ TGeoVolume* create_tof_pole() {
   Double_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
+  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);
+    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;
+  }
+  else
+    cout << "Skipping pole_air_vol, no thickness: " << air_dx << " " << air_dy << " " << air_dz << endl;
 
   return pole;
 }
 
-TGeoVolume* create_tof_poleshort() {
+TGeoVolume* create_tof_poleshort()
+{
   // needed materials
   TGeoMedium* boxVolMed = gGeoMan->GetMedium(PoleVolumeMedium);
   TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium);
@@ -1243,10 +1127,9 @@ TGeoVolume* create_tof_poleshort() {
   Double_t width_aluy = Pole_Thick_Y;
   Double_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);
+  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.);
@@ -1256,33 +1139,29 @@ TGeoVolume* create_tof_poleshort() {
   Double_t air_dy = dy / 2. - width_aluy;
   Double_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
+  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);
+    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;
+  }
+  else
+    cout << "Skipping pole_air_vol, no thickness: " << air_dx << " " << air_dy << " " << air_dz << endl;
 
   return pole;
 }
 
 
-TGeoVolume* create_tof_bar(Double_t dx, Double_t dy, Double_t dz) {
+TGeoVolume* create_tof_bar(Double_t dx, Double_t dy, Double_t dz)
+{
   // needed materials
   TGeoMedium* boxVolMed = gGeoMan->GetMedium(PoleVolumeMedium);
   TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium);
@@ -1299,8 +1178,7 @@ TGeoVolume* create_tof_bar(Double_t dx, Double_t dy, Double_t dz) {
   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);
+  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
@@ -1310,7 +1188,8 @@ TGeoVolume* create_tof_bar(Double_t dx, Double_t dy, Double_t dz) {
   return bar;
 }
 
-void position_tof_poles(Int_t modType) {
+void position_tof_poles(Int_t modType)
+{
 
   TGeoTranslation* pole_trans = NULL;
 
@@ -1324,27 +1203,25 @@ void position_tof_poles(Int_t modType) {
       pole_trans = new TGeoTranslation("", xPos, 0., zPos);
       gGeoMan->GetVolume(geoVersion)->AddNode(gPole, numPoles, pole_trans);
       numPoles++;
-    } else {  // position 2 short poles
+    }
+    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);
+      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);
+      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) {
+void position_tof_bars(Int_t modType)
+{
 
   TGeoTranslation* bar_trans = NULL;
 
@@ -1377,22 +1254,17 @@ void position_tof_bars(Int_t modType) {
   // 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
-  int j   = i + 1;
-  gBar[j] = create_tof_bar(
-    Frame_Size_X, Frame_YLen, Frame_Size_Y);  // Outer frame big bar along Y
+  i                = NumberOfBars;
+  gBar[i]          = create_tof_bar(Frame_XLen, Frame_Size_Y, Frame_Size_Y);  // Outer frame big bar along X
+  int j            = i + 1;
+  gBar[j]          = create_tof_bar(Frame_Size_X, Frame_YLen, Frame_Size_Y);  // Outer frame big bar along Y
   Double_t numBarY = 0;
   numBars          = 0;
 
   for (Double_t dZ = -1.; dZ < 2.; dZ += 2.) {
     Double_t zPos = Frame_Pos_Z - dZ * Bar_Size_Z / 2.;
     //    Double_t yPos = Pole_Size_Y/2.+1.5*Bar_Size_Y;
-    Double_t yPos =
-      Frame_YLen / 2.
-      + Frame_Size_Y
-          / 2;  // Make outer frame independent of the inner poles!!!!
+    Double_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);
@@ -1417,7 +1289,8 @@ void position_tof_bars(Int_t modType) {
   }
 }
 
-void position_inner_tof_modules(Int_t modNType) {
+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;
@@ -1443,43 +1316,34 @@ void position_inner_tof_modules(Int_t modNType) {
     Int_t modNum  = 0;
     for (Int_t i = 0; i < Inner_Module_Number[j]; i++) {
       ii++;
-      cout << "Inner ii " << ii << " Last " << Last_Size_Y << "," << Last_Over_Y
-           << endl;
-      Double_t DeltaY = Module_Size_Y[modType] + Last_Size_Y
-                        - 2. * (Module_Over_Y[modType] + Last_Over_Y);
+      cout << "Inner ii " << ii << " Last " << Last_Size_Y << "," << Last_Over_Y << endl;
+      Double_t DeltaY = Module_Size_Y[modType] + Last_Size_Y - 2. * (Module_Over_Y[modType] + Last_Over_Y);
       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;
+      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(geoVersion)
-        ->AddNode(gModules[modType], modNum, module_trans);
+      gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_trans);
       modNum++;
       module_trans = new TGeoTranslation("", xPos, -yPos, zPos);
-      gGeoMan->GetVolume(geoVersion)
-        ->AddNode(gModules[modType], modNum, module_trans);
+      gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_trans);
       modNum++;
       if (ii > 0) {
-        module_trans = new TGeoTranslation(
-          "", xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]);
-        gGeoMan->GetVolume(geoVersion)
-          ->AddNode(gModules[modType], modNum, module_trans);
+        module_trans = new TGeoTranslation("", xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]);
+        gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_trans);
         modNum++;
-        module_trans = new TGeoTranslation(
-          "", xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]);
-        gGeoMan->GetVolume(geoVersion)
-          ->AddNode(gModules[modType], modNum, module_trans);
+        module_trans = new TGeoTranslation("", xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]);
+        gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_trans);
         modNum++;
       }
     }
   }
 }
 
-void position_tof_modules_m(Int_t ModType1, Int_t ModType2) {
+void position_tof_modules_m(Int_t ModType1, Int_t ModType2)
+{
 
   TGeoTranslation* module_trans = NULL;
   TGeoRotation* module_rot0     = new TGeoRotation();
@@ -1505,23 +1369,22 @@ void position_tof_modules_m(Int_t ModType1, Int_t ModType2) {
       Double_t xPos = xPosModm[jm][i];
       Double_t yPos = yPosModm[jm][i];
       Double_t zPos = zPosModm[jm][i] + InnerWall_Z_PositionShift;
-      cout << "Place Mod Type " << j << " at x " << xPos << ", y " << yPos
-           << ", z " << zPos << ", Flip " << FlipModm[jm][i] << endl;
+      cout << "Place Mod " << i << " of Type " << j << " at x " << xPos << ", y " << yPos << ", z " << zPos << ", Flip "
+           << FlipModm[jm][i] << endl;
 
       module_trans = new TGeoTranslation("", xPos, yPos, zPos);
-      if (FlipModm[jm][i] == 180.) {
-        module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot1);
-      } else {
+      if (FlipModm[jm][i] == 180.) { module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot1); }
+      else {
         module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot0);
       }
-      gGeoMan->GetVolume(geoVersion)
-        ->AddNode(gModules[modType], modNum, module_combi_trans);
+      gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_combi_trans);
       modNum++;
     }
   }
 }
 
-void position_tof_modules(Int_t NModTypes) {
+void position_tof_modules(Int_t NModTypes)
+{
   TGeoTranslation* module_trans = NULL;
   TGeoRotation* module_rot0     = new TGeoRotation();
   module_rot0->RotateZ(0.);
@@ -1553,22 +1416,19 @@ void position_tof_modules(Int_t NModTypes) {
       //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 (FlipMod[j][i] == 1) {
-        module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot1);
-      } else {
+      if (FlipMod[j][i] == 1) { module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot1); }
+      else {
         module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot0);
       }
-      gGeoMan->GetVolume(geoVersion)
-        ->AddNode(gModules[modType], modNum, module_combi_trans);
+      gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_combi_trans);
       modNum++;
 
       // add structural material
 
       Bool_t BPexist = kFALSE;
       Double_t SignX;
-      if (xPosMod[j][i] != 0.) {
-        SignX = xPos / TMath::Abs(xPos);
-      } else {
+      if (xPosMod[j][i] != 0.) { SignX = xPos / TMath::Abs(xPos); }
+      else {
         SignX = 1.;
       }
 
@@ -1585,9 +1445,8 @@ void position_tof_modules(Int_t NModTypes) {
         //	cout <<"Add zLayer "<<NLayer<<" at z="<<zPos<<" from ModType "<<j<<", Module "<<i<<endl;
         NLayer++;
       }
-      if (iLz % 2) {
-        SignZ = 1;
-      } else {
+      if (iLz % 2) { SignZ = 1; }
+      else {
         SignZ = -1;
       }
       switch (iLz) {  // fix inconsistencies with above
@@ -1598,8 +1457,7 @@ void position_tof_modules(Int_t NModTypes) {
           break;
       }
 
-      Double_t zPosPole =
-        zPos + (Module_Size_Z[j] / 2. + Pole_Size_Z / 2.) * SignZ;
+      Double_t zPosPole = zPos + (Module_Size_Z[j] / 2. + Pole_Size_Z / 2.) * SignZ;
       Double_t xPosPole = xPos + (Module_Size_X[j] / 2.) * SignX;
 
       Int_t iCx = -1;
@@ -1622,8 +1480,7 @@ void position_tof_modules(Int_t NModTypes) {
       }
 
       for (Int_t iP = 0; iP < NumberOfPoles; iP++) {
-        if (TMath::Abs(zPosPole - Pole_ZPos[iP]) < Pole_Size_Z
-            && TMath::Abs(xPosPole - Pole_XPos[iP]) < Pole_Size_X) {
+        if (TMath::Abs(zPosPole - Pole_ZPos[iP]) < Pole_Size_Z && TMath::Abs(xPosPole - Pole_XPos[iP]) < Pole_Size_X) {
           BPexist = kTRUE;
           break;
         }
@@ -1656,8 +1513,7 @@ void position_tof_modules(Int_t NModTypes) {
       }
     }  // for i
   }    // for j
-  cout << " Total number of modules: " << modNum << ", poles: " << NumberOfPoles
-       << endl;
+  cout << " Total number of modules: " << modNum << ", poles: " << NumberOfPoles << endl;
 
   //  Pole related bars
   Double_t BZMin = 10000.;
@@ -1672,8 +1528,7 @@ void position_tof_modules(Int_t NModTypes) {
   Frame_Pos_Z = (BZMax + BZMin) / 2.;
   Bar_Pos_Z   = (BZMax + BZMin) / 2.;
 
-  cout << "Place " << NCol << " bars of z-length " << Bar_Size_Z
-       << " at z = " << Bar_Pos_Z << endl;
+  cout << "Place " << NCol << " bars of z-length " << Bar_Size_Z << " at z = " << Bar_Pos_Z << endl;
 
   Int_t iC;
   Bool_t bBarExist = kFALSE;
@@ -1681,63 +1536,40 @@ void position_tof_modules(Int_t NModTypes) {
     // Check if creating a bar for this pole would not collide with an existing bar
     bBarExist = kFALSE;
     for (Int_t iBar = 0; iBar < NumberOfBars; iBar++) {
-      if ((TMath::Abs(xPosCol[iC] - Bar_XPos[iBar])
-           < Bar_Size_X))  // Original bar
+      if ((TMath::Abs(xPosCol[iC] - Bar_XPos[iBar]) < Bar_Size_X))  // Original bar
       {
-        cout << Form(
-          "Rejected bar for col %03d at X= %7.2f due to bar %03d at X= %7.2f",
-          iC,
-          xPosCol[iC],
-          iBar,
-          Bar_XPos[iBar])
-             << endl;
-
-        cout << Form(" ==> Replaced bar %03d at X= %7.2f by a bar at ",
-                     iBar,
-                     Bar_XPos[iBar]);
-        Bar_XPos[iBar] = (xPosCol[iC] + Bar_XPos[iBar])
-                         / 2.0;  // take mean of the 2 positions!!
-        cout << Form(" X= %7.2f (middle of colliding X positions)",
+        cout << Form("Rejected bar for col %03d at X= %7.2f due to bar %03d at X= %7.2f", iC, xPosCol[iC], iBar,
                      Bar_XPos[iBar])
              << endl;
 
+        cout << Form(" ==> Replaced bar %03d at X= %7.2f by a bar at ", iBar, Bar_XPos[iBar]);
+        Bar_XPos[iBar] = (xPosCol[iC] + Bar_XPos[iBar]) / 2.0;  // take mean of the 2 positions!!
+        cout << Form(" X= %7.2f (middle of colliding X positions)", Bar_XPos[iBar]) << endl;
+
         bBarExist = kTRUE;
         break;
       }
 
-      if ((TMath::Abs(xPosCol[iC] + Bar_XPos[iBar])
-           < Bar_Size_X))  // Mirrored bar VS original
+      if ((TMath::Abs(xPosCol[iC] + Bar_XPos[iBar]) < Bar_Size_X))  // Mirrored bar VS original
       {
-        cout << Form(
-          "Rejected bar for col %03d at X= %7.2f due to bar %03d at X= %7.2f",
-          iC,
-          xPosCol[iC],
-          iBar,
-          Bar_XPos[iBar])
-             << endl;
-
-        cout << Form(" ==> Replaced bar %03d at X= %7.2f by a bar at ",
-                     iBar,
-                     Bar_XPos[iBar]);
-        Bar_XPos[iBar] = (Bar_XPos[iBar] - xPosCol[iC])
-                         / 2.0;  // take mean of the 2 positions!!
-        cout << Form(" X= %7.2f (middle of colliding X positions)",
+        cout << Form("Rejected bar for col %03d at X= %7.2f due to bar %03d at X= %7.2f", iC, xPosCol[iC], iBar,
                      Bar_XPos[iBar])
              << endl;
 
+        cout << Form(" ==> Replaced bar %03d at X= %7.2f by a bar at ", iBar, Bar_XPos[iBar]);
+        Bar_XPos[iBar] = (Bar_XPos[iBar] - xPosCol[iC]) / 2.0;  // take mean of the 2 positions!!
+        cout << Form(" X= %7.2f (middle of colliding X positions)", Bar_XPos[iBar]) << endl;
+
         bBarExist = kTRUE;
         break;
       }
     }  //  for (Int_t iP=0; iP<NumberOfPoles; iP++)
 
     if (!bBarExist) {
-      gBar[NumberOfBars] = create_tof_bar(Bar_Size_X, Bar_Size_Y, Bar_Size_Z);
-      Bar_ZPos[NumberOfBars] =
-        Bar_Pos_Z;  //PosPole+Bar_Size_Z/2.-Pole_Size_Z/2.;
+      gBar[NumberOfBars]     = create_tof_bar(Bar_Size_X, Bar_Size_Y, Bar_Size_Z);
+      Bar_ZPos[NumberOfBars] = Bar_Pos_Z;  //PosPole+Bar_Size_Z/2.-Pole_Size_Z/2.;
       Bar_XPos[NumberOfBars] = xPosCol[iC];
-      cout << Form("Placed bar %03d at X= %7.2f and Z = %7.2f ",
-                   NumberOfBars,
-                   Bar_XPos[NumberOfBars],
+      cout << Form("Placed bar %03d at X= %7.2f and Z = %7.2f ", NumberOfBars, Bar_XPos[NumberOfBars],
                    Bar_ZPos[NumberOfBars])
            << endl;
       NumberOfBars++;
@@ -1746,7 +1578,8 @@ void position_tof_modules(Int_t NModTypes) {
 }
 
 
-void position_side_tof_modules(Int_t modNType) {
+void position_side_tof_modules(Int_t modNType)
+{
   TGeoTranslation* module_trans = NULL;
   TGeoRotation* module_rot      = new TGeoRotation();
   module_rot->RotateZ(180.);
@@ -1760,67 +1593,51 @@ void position_side_tof_modules(Int_t modNType) {
     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;
-      Double_t DeltaY = Module_Size_Y[modType] + Last_Size_Y
-                        - 2. * (Module_Over_Y[modType] + Last_Over_Y);
+      cout << "InnerSide ii " << ii << " Last " << Last_Size_Y << "," << Last_Over_Y << endl;
+      Double_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];
       Double_t xPos = InnerSide_Module_X_Offset;
       Double_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;
+      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(geoVersion)
-        ->AddNode(gModules[modType], modNum, module_trans);
+      gGeoMan->GetVolume(geoVersion)->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(geoVersion)
-        ->AddNode(gModules[modType], modNum, module_combi_trans);
+      gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_combi_trans);
       modNum++;
 
       if (ii > 1) {
         module_trans = new TGeoTranslation("", xPos, -yPos, zPos);
-        gGeoMan->GetVolume(geoVersion)
-          ->AddNode(gModules[modType], modNum, module_trans);
+        gGeoMan->GetVolume(geoVersion)->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(geoVersion)
-          ->AddNode(gModules[modType], modNum, module_combi_trans);
+        gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_combi_trans);
         modNum++;
 
-        module_trans = new TGeoTranslation(
-          "", xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]);
-        gGeoMan->GetVolume(geoVersion)
-          ->AddNode(gModules[modType], modNum, module_trans);
+        module_trans = new TGeoTranslation("", xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]);
+        gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_trans);
         modNum++;
 
-        module_trans = new TGeoTranslation(
-          "", -xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]);
+        module_trans       = new TGeoTranslation("", -xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]);
         module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
-        gGeoMan->GetVolume(geoVersion)
-          ->AddNode(gModules[modType], modNum, module_combi_trans);
+        gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_combi_trans);
         modNum++;
 
-        module_trans = new TGeoTranslation(
-          "", xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]);
-        gGeoMan->GetVolume(geoVersion)
-          ->AddNode(gModules[modType], modNum, module_trans);
+        module_trans = new TGeoTranslation("", xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]);
+        gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_trans);
         modNum++;
 
-        module_trans = new TGeoTranslation(
-          "", -xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]);
+        module_trans       = new TGeoTranslation("", -xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]);
         module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
-        gGeoMan->GetVolume(geoVersion)
-          ->AddNode(gModules[modType], modNum, module_combi_trans);
+        gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum, module_combi_trans);
         modNum++;
       }
     }
@@ -1870,15 +1687,13 @@ void position_outer_tof_modules(Int_t nCol)  //modType, Int_t col1, Int_t col2)
       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_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++;
 
-      cout << Form("Placed Outer module bar %03d at X= %7.2f and Z = %7.2f ",
-                   NumberOfBars,
-                   Bar_XPos[NumberOfBars],
+      cout << Form("Placed Outer module bar %03d at X= %7.2f and Z = %7.2f ", NumberOfBars, Bar_XPos[NumberOfBars],
                    Bar_ZPos[NumberOfBars])
            << endl;
     }
@@ -1887,69 +1702,52 @@ void position_outer_tof_modules(Int_t nCol)  //modType, Int_t col1, Int_t col2)
       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;
+      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;
-        Double_t DeltaY = Module_Size_Y[modType] + Last_Size_Y
-                          - 2. * (Module_Over_Y[modType] + Last_Over_Y);
+        cout << "Outer ii " << ii << " Last " << Last_Size_Y << "," << Last_Over_Y << endl;
+        Double_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 << "(#"
+        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;
+             << " at Y = " << yPos << " Ysize = " << Module_Size_Y[modType] << " DeltaY = " << DeltaY << endl;
 
         module_trans = new TGeoTranslation("", xPos, yPos, zPos);
-        gGeoMan->GetVolume(geoVersion)
-          ->AddNode(gModules[modType], modNum[modType], module_trans);
+        gGeoMan->GetVolume(geoVersion)->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(geoVersion)
-          ->AddNode(gModules[modType], modNum[modType], module_combi_trans);
+        gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum[modType], module_combi_trans);
         modNum[modType]++;
 
         if (ii > 1) {
           module_trans = new TGeoTranslation("", xPos, -yPos, zPos);
-          gGeoMan->GetVolume(geoVersion)
-            ->AddNode(gModules[modType], modNum[modType], module_trans);
+          gGeoMan->GetVolume(geoVersion)->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(geoVersion)
-            ->AddNode(gModules[modType], modNum[modType], module_combi_trans);
+          gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum[modType], module_combi_trans);
           modNum[modType]++;
 
           // second layer
-          module_trans =
-            new TGeoTranslation("", xPos, yPos - DeltaY / 2., zPos + DzPos);
-          gGeoMan->GetVolume(geoVersion)
-            ->AddNode(gModules[modType], modNum[modType], module_trans);
+          module_trans = new TGeoTranslation("", xPos, yPos - DeltaY / 2., zPos + DzPos);
+          gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum[modType], module_trans);
           modNum[modType]++;
-          module_trans =
-            new TGeoTranslation("", -xPos, yPos - DeltaY / 2., zPos + DzPos);
+          module_trans       = new TGeoTranslation("", -xPos, yPos - DeltaY / 2., zPos + DzPos);
           module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
-          gGeoMan->GetVolume(geoVersion)
-            ->AddNode(gModules[modType], modNum[modType], module_combi_trans);
+          gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum[modType], module_combi_trans);
           modNum[modType]++;
 
-          module_trans =
-            new TGeoTranslation("", xPos, -(yPos - DeltaY / 2.), zPos + DzPos);
-          gGeoMan->GetVolume(geoVersion)
-            ->AddNode(gModules[modType], modNum[modType], module_trans);
+          module_trans = new TGeoTranslation("", xPos, -(yPos - DeltaY / 2.), zPos + DzPos);
+          gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum[modType], module_trans);
           modNum[modType]++;
-          module_trans =
-            new TGeoTranslation("", -xPos, -(yPos - DeltaY / 2.), zPos + DzPos);
+          module_trans       = new TGeoTranslation("", -xPos, -(yPos - DeltaY / 2.), zPos + DzPos);
           module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot);
-          gGeoMan->GetVolume(geoVersion)
-            ->AddNode(gModules[modType], modNum[modType], module_combi_trans);
+          gGeoMan->GetVolume(geoVersion)->AddNode(gModules[modType], modNum[modType], module_combi_trans);
           modNum[modType]++;
         }
       }
@@ -1958,7 +1756,8 @@ void position_outer_tof_modules(Int_t nCol)  //modType, Int_t col1, Int_t col2)
 }
 
 
-void dump_info_file() {
+void dump_info_file()
+{
   TDatime datetime;  // used to get timestamp
 
   printf("writing info file: %s\n", FileNameInfo.Data());
@@ -1983,8 +1782,7 @@ void dump_info_file() {
   if (TOF_Z_Front == 1020) fprintf(ifile, "SIS 300 muon\n");
   fprintf(ifile, "\n");
 
-  const Double_t TOF_Z_Back =
-    Wall_Z_Position + 1.5 * Module_Size_Z[0];  // back of TOF wall
+  const Double_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
@@ -1994,9 +1792,7 @@ void dump_info_file() {
 
   // 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, "%7.2f cm   center of staggered, front RPC cell at x=0\n", Wall_Z_Position);
   fprintf(ifile, "\n");
 
   fclose(ifile);
diff --git a/reco/detectors/tof/CbmTofEventClusterizer.cxx b/reco/detectors/tof/CbmTofEventClusterizer.cxx
index 4cfb6c757a..24df970c3c 100644
--- a/reco/detectors/tof/CbmTofEventClusterizer.cxx
+++ b/reco/detectors/tof/CbmTofEventClusterizer.cxx
@@ -966,9 +966,11 @@ Bool_t CbmTofEventClusterizer::LoadGeometry()
       Int_t iUCellId = CbmTofAddress::GetUniqueAddress(iSmId, iRpcId, ++iCell, 0, iSmType);
       fChannelInfo   = fDigiPar->GetCell(iUCellId);
       if (NULL == fChannelInfo) break;
-      LOG(debug3) << " Cell " << iCell << Form(" 0x%08x ", iUCellId) << Form(", fCh 0x%p ", fChannelInfo)
-                  << ", x: " << fChannelInfo->GetX() << ", y: " << fChannelInfo->GetY()
-                  << ", z: " << fChannelInfo->GetZ();
+      LOG(debug3) << " Cell " << iCell << Form(" 0x%08x ", iUCellId) << Form(", fCh %p ", fChannelInfo) << ", TSRC "
+                  << iSmType << iSmId << iRpcId << iCell << ", x: " << fChannelInfo->GetX()
+                  << ", y: " << fChannelInfo->GetY() << ", z: " << fChannelInfo->GetZ()
+                  << ", dy: " << fChannelInfo->GetSizey();
+      if (iCell > 100) { LOG(fatal) << "Too many cells " << fDigiPar->GetNrOfModules(); }
     }
   }
 
-- 
GitLab