diff --git a/macro/beamtime/hd2020/ana_trks.C b/macro/beamtime/hd2020/ana_trks.C
index e9499edd6a0bc808af9b26dc4390bc5a18d0560e..de66018ecc080dd381402a99f5428a6c83dcd67c 100644
--- a/macro/beamtime/hd2020/ana_trks.C
+++ b/macro/beamtime/hd2020/ana_trks.C
@@ -11,7 +11,7 @@ void ana_trks(Int_t nEvents        = 10000,
               TString cCalId       = "",
               Int_t iAnaCor        = 1,
               Bool_t bUseSigCalib  = kFALSE,
-              Int_t iCalSet        = 900920910,
+	          Int_t iCalSet        = 900920910,
               Int_t iCalOpt        = 1,
               Int_t iMc            = 0) {
   Int_t iVerbose = 1;
@@ -42,16 +42,16 @@ void ana_trks(Int_t nEvents        = 10000,
   TString cHstFile =
     paramDir
     + Form(
-      "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Ana.hst.root",
-      cFileId.Data(),
-      dDeadtime,
-      cSet.Data(),
-      iSel,
-      iSel2,
-      dScalFac,
-      dChi2Lim2,
-      iTrackingSetup,
-      cCalId.Data());
+        "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Ana.hst.root",
+        cFileId.Data(),
+        dDeadtime,
+        cSet.Data(),
+        iSel,
+        iSel2,
+        dScalFac,
+        dChi2Lim2,
+        iTrackingSetup,
+        cCalId.Data());
   TString cTrkFile = Form("%s_tofFindTracks.hst.root", cCalId.Data());
   TString cAnaFile = Form("%s_TrkAnaTestBeam.hst.root", cFileId.Data());
 
@@ -216,7 +216,7 @@ void ana_trks(Int_t nEvents        = 10000,
       //tofFindTracks->SetStation(8, 6, 1, 0);
       //tofFindTracks->SetStation(9, 6, 1, 1);
       break;
-
+      
     case 11:  // for calibration mode of full setup
       iMinNofHits   = 3;
       iNStations    = 6;
@@ -227,7 +227,7 @@ void ana_trks(Int_t nEvents        = 10000,
       tofFindTracks->SetStation(3, 9, 0, 1);
       tofFindTracks->SetStation(4, 6, 0, 0);
       tofFindTracks->SetStation(5, 6, 0, 1);
-      break;
+      break;      
 
     case 2:
       iMinNofHits   = 6;
@@ -618,7 +618,7 @@ void ana_trks(Int_t nEvents        = 10000,
   gInterpreter->ProcessLine("pl_all_Track2D(1)");
   gInterpreter->ProcessLine("pl_all_Track2D(2)");
   gInterpreter->ProcessLine("pl_all_Track2D(4)");
-
+  
   TString over_trk = "pl_over_trk(" + (TString)(Form("%d", iNStations)) + ")";
   gInterpreter->ProcessLine(over_trk);
 
diff --git a/macro/beamtime/hd2020/dis_digi.C b/macro/beamtime/hd2020/dis_digi.C
index d77c67cc67e0b126b46ba18e4481afe2fefcc787..c70f557b9c09dc59a251ba8b37b4af1df86b3c00 100644
--- a/macro/beamtime/hd2020/dis_digi.C
+++ b/macro/beamtime/hd2020/dis_digi.C
@@ -1,19 +1,7 @@
-void dis_digi(Int_t nEvents        = 100,
-              Int_t calMode        = 93,
-              Int_t calSel         = 1,
-              Int_t calSm          = 0,
-              Int_t RefSel         = 1,
-              TString cFileId      = "68.50.7.1",
-              Int_t iCalSet        = 10500,
-              Bool_t bOut          = 0,
-              Int_t iSel2          = 20,
-              Double_t dDeadtime   = 50,
-              Int_t iGenCor        = 1,
-              Int_t iTrackingSetup = 1,
-              Double_t dScalFac    = 5.,
-              Double_t dChi2Lim2   = 10.,
-              TString cCalId       = "XXX",
-              Bool_t bUseSigCalib  = kFALSE) {
+void dis_digi(Int_t nEvents = 100, Int_t calMode=93, Int_t calSel=1, Int_t calSm=0, Int_t RefSel=1, 
+TString cFileId="68.50.7.1", Int_t iCalSet=10500, Bool_t bOut=0, Int_t iSel2=20, Double_t dDeadtime=50, 
+Int_t iGenCor=1, Int_t iTrackingSetup=1, Double_t dScalFac=5., Double_t dChi2Lim2=10., TString cCalId="XXX", Bool_t bUseSigCalib=kFALSE) 
+{
   Int_t iVerbose = 1;
   //Specify log level (INFO, DEBUG, DEBUG1, ...)
   //TString logLevel = "FATAL";
@@ -26,370 +14,351 @@ void dis_digi(Int_t nEvents        = 100,
   FairLogger::GetLogger();
   gLogger->SetLogScreenLevel(logLevel);
   gLogger->SetLogVerbosityLevel("MEDIUM");
-
-  TString workDir = gSystem->Getenv("VMCWORKDIR");
+  
+  TString workDir    = gSystem->Getenv("VMCWORKDIR");
   /*
    TString workDir    = (TString)gInterpreter->ProcessLine(".! pwd");
    cout << "workdir = "<< workDir.Data() << endl;
    return;
   */
-  TString paramDir   = workDir + "/macro/beamtime/hd2020/";
-  TString ParFile    = paramDir + "data/" + cFileId + ".params.root";
-  TString InputFile  = paramDir + "data/" + cFileId + ".root";
-  TString OutputFile = paramDir + "data/disdigi_" + cFileId
-                       + Form("_%09d%03d", iCalSet, iSel2) + ".out.root";
-
-  TString cTrkFile = Form("%s_tofFindTracks.hst.root", cFileId.Data());
-
-  TList* parFileList = new TList();
-
-  TString FId = cFileId;
-  //TString TofGeo="v18o_cosmicHD";
-  TString TofGeo = "v20b_cosmicHD";  // for Buc2020 sandwiched
-  cout << "Geometry version " << TofGeo << endl;
-
-  TObjString* tofDigiFile = new TObjString(
-    workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par");  // TOF digi file
-  parFileList->Add(tofDigiFile);
-
-  //   TObjString tofDigiBdfFile = new TObjString( paramDir + "/tof." + FPar + "digibdf.par");
-  TObjString* tofDigiBdfFile =
-    new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digibdf.par");
-  parFileList->Add(tofDigiBdfFile);
-
-  TString geoDir  = gSystem->Getenv("VMCWORKDIR");
-  TString geoFile = geoDir + "/geometry/tof/geofile_tof_" + TofGeo + ".root";
-  TFile* fgeo     = new TFile(geoFile);
-  TGeoManager* geoMan = (TGeoManager*) fgeo->Get("FAIRGeom");
-  if (NULL == geoMan) {
-    cout << "<E> FAIRGeom not found in geoFile" << endl;
-    return;
-  }
-
-  if (0) {
-    TGeoVolume* master = geoMan->GetTopVolume();
-    master->SetVisContainers(1);
-    master->Draw("ogl");
-  }
+   TString paramDir   = workDir + "/macro/beamtime/hd2020/";
+   TString ParFile    = paramDir + "data/" + cFileId + ".params.root";
+   TString InputFile  = paramDir + "data/" + cFileId + ".root";
+   TString OutputFile = paramDir + "data/disdigi_"   + cFileId + Form("_%09d%03d",iCalSet,iSel2) + ".out.root";
+
+   TString cTrkFile=Form("%s_tofFindTracks.hst.root",cFileId.Data());
+
+   TList *parFileList = new TList();
+
+   TString FId=cFileId;
+   //TString TofGeo="v18o_cosmicHD";
+   TString TofGeo="v20b_cosmicHD"; // for Buc2020 sandwiched
+    cout << "Geometry version "<<TofGeo<<endl;
+
+   TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file
+   parFileList->Add(tofDigiFile);   
+
+   //   TObjString tofDigiBdfFile = new TObjString( paramDir + "/tof." + FPar + "digibdf.par");
+   TObjString *tofDigiBdfFile = new TObjString( workDir  + "/parameters/tof/tof_" + TofGeo +".digibdf.par");
+   parFileList->Add(tofDigiBdfFile);
+
+   TString geoDir  = gSystem->Getenv("VMCWORKDIR");
+   TString geoFile = geoDir + "/geometry/tof/geofile_tof_" + TofGeo + ".root";
+   TFile* fgeo = new TFile(geoFile);
+   TGeoManager *geoMan = (TGeoManager*) fgeo->Get("FAIRGeom");
+   if (NULL == geoMan){
+     cout << "<E> FAIRGeom not found in geoFile"<<endl;
+     return;
+   }
+   
+   if(0){
+   TGeoVolume* master=geoMan->GetTopVolume();
+   master->SetVisContainers(1); 
+   master->Draw("ogl"); 
+   }
 
   // -----   Reconstruction run   -------------------------------------------
-  FairRunAna* run = new FairRunAna();
+  FairRunAna *run= new FairRunAna();
   run->SetInputFile(InputFile.Data());
   //run->SetOutputFile(OutputFile);
-  run->SetUserOutputFileName(OutputFile.Data());
-  run->SetSink(new FairRootFileSink(run->GetUserOutputFileName()));
-
-  CbmTofEventClusterizer* tofClust =
-    new CbmTofEventClusterizer("TOF Event Clusterizer", iVerbose, bOut);
-
-  tofClust->SetCalMode(calMode);
-  tofClust->SetCalSel(calSel);
-  tofClust->SetCaldXdYMax(50.);  // geometrical matching window in cm
-  tofClust->SetCalCluMulMax(
-    4.);  // Max Counter Cluster Multiplicity for filling calib histos
-  tofClust->SetCalRpc(calSm);   // select detector for calibration update
-  tofClust->SetTRefId(RefSel);  // reference trigger for offset calculation
-  tofClust->SetTotMax(20.);     // Tot upper limit for walk corection
-  tofClust->SetTotMin(
-    0.01);  //(12000.);  // Tot lower limit for walk correction
-  tofClust->SetTotPreRange(
-    2.);  // effective lower Tot limit  in ns from peak position
-  tofClust->SetTotMean(2.);       // Tot calibration target value in ns
-  tofClust->SetMaxTimeDist(1.0);  // default cluster range in ns
-  //tofClust->SetMaxTimeDist(0.);       //Deb// default cluster range in ns
-  tofClust->SetDelTofMax(
-    60.);  // acceptance range for cluster correlation in cm (!)
-  tofClust->SetSel2MulMax(4);  // limit Multiplicity in 2nd selector
-  tofClust->SetChannelDeadtime(dDeadtime);  // artificial deadtime in ns
-  tofClust->SetEnableAvWalk(kTRUE);
-  tofClust->SetYFitMin(1.E4);
-  //tofClust->SetTimePeriod(6.25);       // ignore coarse time
-  //tofClust->SetCorMode(2);              // correct missing hits
-
-  Int_t calSelRead = calSel;
-  if (calSel < 0) calSelRead = 0;
-  TString cFname = Form("%s_set%09d_%02d_%01dtofClust.hst.root",
-                        cFileId.Data(),
-                        iCalSet,
-                        calMode,
-                        calSelRead);
-  tofClust->SetCalParFileName(cFname);
-  TString cOutFname =
-    Form("tofClust_%s_set%09d.hst.root", cFileId.Data(), iCalSet);
-  tofClust->SetOutHstFileName(cOutFname);
-
-  TString cAnaFile =
-    Form("%s_%09d%03d_tofAnaCosmic.hst.root", cFileId.Data(), iCalSet, iSel2);
-
-  switch (calMode) {
-    case -1:                      // initial calibration
-      tofClust->SetTotMax(256.);  // range in bin number
-      tofClust->SetTotPreRange(256.);
-      //tofClust->SetTotMin(1.);
-      tofClust->SetTRefDifMax(50000.);  // in ns
-      tofClust->PosYMaxScal(10000.);    // in % of length
-      tofClust->SetMaxTimeDist(0.);     // no cluster building
-      //tofClust->SetTimePeriod(0.);       // inspect coarse time
-      break;
-    case 0:                       // initial calibration
-      tofClust->SetTotMax(256.);  // range in bin number
-      tofClust->SetTotPreRange(256.);
-      //tofClust->SetTotMin(1.);
-      tofClust->SetTRefDifMax(50.);  // in ns
-      tofClust->PosYMaxScal(10.);    // in % of length
-      tofClust->SetMaxTimeDist(0.);  // no cluster building
-      //tofClust->SetTimePeriod(0.);       // inspect coarse time
-      break;
-    case 1:                       // save offsets, update walks, for diamonds
-      tofClust->SetTotMax(256.);  // range in bin number
-      tofClust->SetTotPreRange(256.);
-      tofClust->SetTRefDifMax(6.25);  // in ns
-      //tofClust->SetTimePeriod(6.25);       // inspect coarse time
-      tofClust->PosYMaxScal(10.);  // in % of length
-      break;
-    case 11:
-      tofClust->SetTRefDifMax(5.);  // in ns
-      tofClust->PosYMaxScal(3.0);   // in % of length
-      break;
-    case 21:
-      tofClust->SetTRefDifMax(2.5);  // in ns
-      tofClust->PosYMaxScal(2.0);    // in % of length
-      break;
-    case 31:
-      tofClust->SetTRefDifMax(2.);  // in ns
-      tofClust->PosYMaxScal(1.5);   // in % of length
-      break;
-    case 41:
-      tofClust->SetTRefDifMax(1.);  // in ns
-      tofClust->PosYMaxScal(0.8);   // in % of length
-      break;
-    case 51:
-      tofClust->SetTRefDifMax(0.7);  // in ns
-      tofClust->PosYMaxScal(0.7);    // in % of length
-      break;
-    case 61:
-      tofClust->SetTRefDifMax(0.5);  // in ns
-      tofClust->PosYMaxScal(0.7);    // in % of length
-      break;
-    case 71:
-      tofClust->SetTRefDifMax(0.4);  // in ns
-      tofClust->PosYMaxScal(0.6);    // in % of length
-      break;
-
-    case 2:                           // time difference calibration
-      tofClust->SetTRefDifMax(300.);  // in ns
-      tofClust->PosYMaxScal(1000.);   //in % of length
-      break;
-
-    case 3:                           // time offsets
-      tofClust->SetTRefDifMax(200.);  // in ns
-      tofClust->PosYMaxScal(100.);    //in % of length
-      tofClust->SetMaxTimeDist(0.);   // no cluster building
-      break;
-    case 12:
-    case 13:
-      tofClust->SetTRefDifMax(100.);  // in ns
-      tofClust->PosYMaxScal(50.);     //in % of length
-      break;
-    case 22:
-    case 23:
-      tofClust->SetTRefDifMax(50.);  // in ns
-      tofClust->PosYMaxScal(20.);    //in % of length
-      break;
-    case 32:
-    case 33:
-      tofClust->SetTRefDifMax(25.);  // in ns
-      tofClust->PosYMaxScal(10.);    //in % of length
-      break;
-    case 42:
-    case 43:
-      tofClust->SetTRefDifMax(12.);  // in ns
-      tofClust->PosYMaxScal(5.);     //in % of length
-      break;
-    case 52:
-    case 53:
-      tofClust->SetTRefDifMax(5.);  // in ns
-      tofClust->PosYMaxScal(3.);    //in % of length
-      break;
-    case 62:
-    case 63:
-      tofClust->SetTRefDifMax(3.);  // in ns
-      tofClust->PosYMaxScal(2.);    //in % of length
-      break;
-    case 72:
-    case 73:
-      tofClust->SetTRefDifMax(2.);  // in ns
-      tofClust->PosYMaxScal(1.5);   //in % of length
-      break;
-    case 82:
-    case 83:
-      tofClust->SetTRefDifMax(1.);  // in ns
-      tofClust->PosYMaxScal(1.0);   //in % of length
-      break;
-    case 92:
-    case 93:
-      tofClust->SetTRefDifMax(0.6);  // in ns
-      tofClust->PosYMaxScal(1.0);    //in % of length
-      break;
-
-    case 4:                         // velocity dependence (DelTOF)
-      tofClust->SetTRefDifMax(6.);  // in ns
-      tofClust->PosYMaxScal(1.5);   //in % of length
-      break;
-    case 14:
-      tofClust->SetTRefDifMax(5.);  // in ns
-      tofClust->PosYMaxScal(1.);    //in % of length
-      break;
-    case 24:
-      tofClust->SetTRefDifMax(3.);  // in ns
-      tofClust->PosYMaxScal(1.0);   //in % of length
-      break;
-    case 34:
-      tofClust->SetTRefDifMax(2.);  // in ns
-      tofClust->PosYMaxScal(1.0);   //in % of length
-      break;
-    case 44:
-      tofClust->SetTRefDifMax(1.);  // in ns
-      tofClust->PosYMaxScal(1.0);   //in % of length
-      break;
-    case 54:
-      tofClust->SetTRefDifMax(0.7);  // in ns
-      tofClust->PosYMaxScal(0.7);    //in % of length
-      break;
-    case 64:
-      tofClust->SetTRefDifMax(0.5);  // in ns
-      tofClust->PosYMaxScal(0.7);    //in % of length
-      break;
-    default:
-      cout << "<E> Calib mode not implemented! stop execution of script"
-           << endl;
-      return;
-  }
-  run->AddTask(tofClust);
-
-  Int_t iBRef    = iCalSet % 1000;
-  Int_t iSet     = (iCalSet - iBRef) / 1000;
-  Int_t iRSel    = 0;
-  Int_t iRSelTyp = 0;
-  Int_t iRSelSm  = 0;
-  Int_t iRSelRpc = 0;
-  iRSel          = iBRef;  // use diamond
-  if (iSel2 == 0) {
-    // iSel2=iBRef;
-  } else {
-    if (iSel2 < 0) iSel2 = -iSel2;
-  }
-
-  Int_t iRSelin = iRSel;
-  iRSelRpc      = iRSel % 10;
-  iRSelTyp      = (iRSel - iRSelRpc) / 10;
-  iRSelSm       = iRSelTyp % 10;
-  iRSelTyp      = (iRSelTyp - iRSelSm) / 10;
-
-  tofClust->SetBeamRefId(iRSelTyp);  // define Beam reference counter
-  tofClust->SetBeamRefSm(iRSelSm);
-  tofClust->SetBeamRefDet(iRSelRpc);
-  tofClust->SetBeamAddRefMul(-1);
-  tofClust->SetBeamRefMulMax(3);
-
-  Int_t iSel2in  = iSel2;
-  Int_t iSel2Rpc = iSel2 % 10;
-  iSel2          = (iSel2 - iSel2Rpc) / 10;
-  Int_t iSel2Sm  = iSel2 % 10;
-  iSel2          = (iSel2 - iSel2Sm) / 10;
-  if (iSel2 > 0) {
-    tofClust->SetSel2Id(iSel2);
-    tofClust->SetSel2Sm(iSel2Sm);
-    tofClust->SetSel2Rpc(iSel2Rpc);
-  }
-
-  Int_t iRef    = iSet % 1000;
-  Int_t iDut    = (iSet - iRef) / 1000;
-  Int_t iDutRpc = iDut % 10;
-  iDut          = (iDut - iDutRpc) / 10;
-  Int_t iDutSm  = iDut % 10;
-  iDut          = (iDut - iDutSm) / 10;
-
-  tofClust->SetDutId(iDut);
-  tofClust->SetDutSm(iDutSm);
-  tofClust->SetDutRpc(iDutRpc);
-
-  Int_t iRefRpc = iRef % 10;
-  iRef          = (iRef - iRefRpc) / 10;
-  Int_t iRefSm  = iRef % 10;
-  iRef          = (iRef - iRefSm) / 10;
-
-  tofClust->SetSelId(iRef);
-  tofClust->SetSelSm(iRefSm);
-  tofClust->SetSelRpc(iRefRpc);
-
-  cout << "Run with iRSel = " << iRSel << ", iSel2 = " << iSel2in << endl;
-
-  // =========================================================================
-  // ===                       Tracking                                    ===
-  // =========================================================================
-  CbmStsDigitize* stsDigitize = new CbmStsDigitize();  //necessary for kalman !!
-  CbmKF* kalman               = new CbmKF();
-
-  CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN();
-  tofTrackFinder->SetMaxTofTimeDifference(5.);  // in ns/cm
-  tofTrackFinder->SetTxLIM(1.6);                // max slope dx/dz
-  tofTrackFinder->SetTyLIM(1.6);                // max dev from mean slope dy/dz
-  tofTrackFinder->SetTyMean(0.);                // mean slope dy/dz
-  tofTrackFinder->SetMaxTofTimeDifference(1.);  // in ns/cm
-
-  CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211);
-  TFitter* MyFit                    = new TFitter(1);  // initialize Minuit
-  tofTrackFinder->SetFitter(tofTrackFitter);
-  CbmTofFindTracks* tofFindTracks = new CbmTofFindTracks("TOF Track Finder");
-  tofFindTracks->UseFinder(tofTrackFinder);
-  tofFindTracks->UseFitter(tofTrackFitter);
-  tofFindTracks->SetCorMode(iGenCor);  // valid options: 0,1,2,3,4,5,6, 10 - 19
-  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->SetBeamCounter(9,0,1);
-  //tofFindTracks->SetBeamCounter(1,1,1);
-
-  tofFindTracks->SetT0MAX(dScalFac);  // in ns
-  tofFindTracks->SetSIGT(0.08);       // default in ns
-  tofFindTracks->SetSIGX(0.3);        // default in cm
-  tofFindTracks->SetSIGY(0.6);        // default in cm
-  tofFindTracks->SetSIGZ(0.1);        // default in cm
-  tofFindTracks->SetUseSigCalib(
-    bUseSigCalib);  // ignore resolutions in CalPar file
-  tofTrackFinder->SetSIGLIM(dChi2Lim2
-                            * 2.);  // matching window in multiples of chi2
-  tofTrackFinder->SetChiMaxAccept(dChi2Lim2);  // max tracklet chi2
-
-  Int_t iMinNofHits   = -1;
-  Int_t iNStations    = 0;
-  Int_t iNReqStations = 3;
-
-  switch (iTrackingSetup) {
-    case 0:  // bypass mode
-      iMinNofHits = -1;
-      iNStations  = 1;
-      tofFindTracks->SetStation(0, 9, 0, 0);  // Diamond
-      break;
-    case 1:  // for calibration mode of full setup
-      iMinNofHits   = 3;
-      iNStations    = 10;
-      iNReqStations = 4;
-      //     tofFindTracks->SetStation(0, 9, 0, 0);
-      tofFindTracks->SetStation(0, 9, 1, 0);
-      tofFindTracks->SetStation(1, 9, 2, 0);
-      tofFindTracks->SetStation(2, 9, 0, 0);
-      tofFindTracks->SetStation(3, 9, 1, 1);
-      tofFindTracks->SetStation(4, 9, 2, 1);
-      tofFindTracks->SetStation(5, 9, 0, 1);
-      tofFindTracks->SetStation(6, 6, 0, 0);
-      tofFindTracks->SetStation(7, 6, 0, 1);
-      tofFindTracks->SetStation(8, 6, 1, 0);
-      tofFindTracks->SetStation(9, 6, 1, 1);
-      /*
+   run->SetUserOutputFileName(OutputFile.Data());
+   run->SetSink(new FairRootFileSink(run->GetUserOutputFileName()));
+
+   CbmTofEventClusterizer* tofClust = new CbmTofEventClusterizer("TOF Event Clusterizer",iVerbose, bOut);
+
+   tofClust->SetCalMode(calMode);
+   tofClust->SetCalSel(calSel);
+   tofClust->SetCaldXdYMax(50.);         // geometrical matching window in cm 
+   tofClust->SetCalCluMulMax(4.);        // Max Counter Cluster Multiplicity for filling calib histos  
+   tofClust->SetCalRpc(calSm);           // select detector for calibration update  
+   tofClust->SetTRefId(RefSel);          // reference trigger for offset calculation 
+   tofClust->SetTotMax(20.);             // Tot upper limit for walk corection
+   tofClust->SetTotMin(0.01);            //(12000.);  // Tot lower limit for walk correction
+   tofClust->SetTotPreRange(2.);         // effective lower Tot limit  in ns from peak position
+   tofClust->SetTotMean(2.);             // Tot calibration target value in ns 
+   tofClust->SetMaxTimeDist(1.0);        // default cluster range in ns 
+   //tofClust->SetMaxTimeDist(0.);       //Deb// default cluster range in ns 
+   tofClust->SetDelTofMax(60.);          // acceptance range for cluster correlation in cm (!)  
+   tofClust->SetSel2MulMax(4);           // limit Multiplicity in 2nd selector
+   tofClust->SetChannelDeadtime(dDeadtime);    // artificial deadtime in ns 
+   tofClust->SetEnableAvWalk(kTRUE);
+   tofClust->SetYFitMin(1.E4);
+   //tofClust->SetTimePeriod(6.25);       // ignore coarse time 
+   //tofClust->SetCorMode(2);              // correct missing hits
+
+   Int_t calSelRead = calSel;
+   if (calSel<0) calSelRead=0;
+   TString cFname=Form("%s_set%09d_%02d_%01dtofClust.hst.root",cFileId.Data(),iCalSet,calMode,calSelRead);
+   tofClust->SetCalParFileName(cFname);
+   TString cOutFname=Form("tofClust_%s_set%09d.hst.root",cFileId.Data(),iCalSet);
+   tofClust->SetOutHstFileName(cOutFname);
+
+   TString cAnaFile=Form("%s_%09d%03d_tofAnaCosmic.hst.root",cFileId.Data(),iCalSet,iSel2);
+      
+   switch (calMode) {
+   case -1:                                    // initial calibration 
+     tofClust->SetTotMax(256.);         // range in bin number 
+     tofClust->SetTotPreRange(256.);
+     //tofClust->SetTotMin(1.);
+     tofClust->SetTRefDifMax(50000.);   // in ns 
+     tofClust->PosYMaxScal(10000.);     // in % of length 
+     tofClust->SetMaxTimeDist(0.);      // no cluster building  
+     //tofClust->SetTimePeriod(0.);       // inspect coarse time 
+     break;
+    case 0:                                    // initial calibration 
+     tofClust->SetTotMax(256.);         // range in bin number 
+     tofClust->SetTotPreRange(256.);
+     //tofClust->SetTotMin(1.);
+     tofClust->SetTRefDifMax(50.);   // in ns 
+     tofClust->PosYMaxScal(10.);     // in % of length 
+     tofClust->SetMaxTimeDist(0.);      // no cluster building  
+     //tofClust->SetTimePeriod(0.);       // inspect coarse time 
+     break;
+   case 1:                                      // save offsets, update walks, for diamonds 
+     tofClust->SetTotMax(256.);           // range in bin number 
+     tofClust->SetTotPreRange(256.);
+     tofClust->SetTRefDifMax(6.25);       // in ns 
+     //tofClust->SetTimePeriod(6.25);       // inspect coarse time 
+     tofClust->PosYMaxScal(10.);       // in % of length 
+     break;
+   case 11:
+     tofClust->SetTRefDifMax(5.);       // in ns 
+     tofClust->PosYMaxScal(3.0);        // in % of length 
+     break;   
+   case 21:
+     tofClust->SetTRefDifMax(2.5);      // in ns 
+     tofClust->PosYMaxScal(2.0);        // in % of length 
+     break;
+   case 31:
+     tofClust->SetTRefDifMax(2.);    // in ns 
+     tofClust->PosYMaxScal(1.5);        // in % of length 
+     break;
+   case 41:
+     tofClust->SetTRefDifMax(1.);    // in ns 
+     tofClust->PosYMaxScal(0.8);        // in % of length 
+     break;   
+   case 51:
+     tofClust->SetTRefDifMax(0.7);     // in ns 
+     tofClust->PosYMaxScal(0.7);        // in % of length 
+     break;
+   case 61:
+     tofClust->SetTRefDifMax(0.5);      // in ns 
+     tofClust->PosYMaxScal(0.7);        // in % of length 
+     break;   
+   case 71:
+     tofClust->SetTRefDifMax(0.4);     // in ns 
+     tofClust->PosYMaxScal(0.6);        // in % of length 
+     break;
+
+   case 2:                                    // time difference calibration
+     tofClust->SetTRefDifMax(300.);     // in ns 
+     tofClust->PosYMaxScal(1000.);      //in % of length
+     break;
+
+   case 3:                                    // time offsets 
+     tofClust->SetTRefDifMax(200.);     // in ns 
+     tofClust->PosYMaxScal(100.);       //in % of length
+     tofClust->SetMaxTimeDist(0.);      // no cluster building  
+     break;
+   case 12:
+   case 13:
+     tofClust->SetTRefDifMax(100.);   // in ns 
+     tofClust->PosYMaxScal(50.);        //in % of length
+     break;
+   case 22:
+   case 23:
+     tofClust->SetTRefDifMax(50.);    // in ns 
+     tofClust->PosYMaxScal(20.);         //in % of length
+     break;
+   case 32:
+   case 33:
+     tofClust->SetTRefDifMax(25.);    // in ns 
+     tofClust->PosYMaxScal(10.);         //in % of length
+     break;
+   case 42:
+   case 43:
+     tofClust->SetTRefDifMax(12.);   // in ns 
+     tofClust->PosYMaxScal(5.);        //in % of length
+     break;
+   case 52:
+   case 53:
+     tofClust->SetTRefDifMax(5.);   // in ns 
+     tofClust->PosYMaxScal(3.);        //in % of length
+     break;
+   case 62:
+   case 63:
+     tofClust->SetTRefDifMax(3.);   // in ns 
+     tofClust->PosYMaxScal(2.);        //in % of length
+     break;
+   case 72:
+   case 73:
+     tofClust->SetTRefDifMax(2.);    // in ns 
+     tofClust->PosYMaxScal(1.5);        //in % of length
+     break;
+   case 82:
+   case 83:
+     tofClust->SetTRefDifMax(1.);    // in ns 
+     tofClust->PosYMaxScal(1.0);        //in % of length   
+     break;
+   case 92:
+   case 93:
+     tofClust->SetTRefDifMax(0.6);    // in ns 
+     tofClust->PosYMaxScal(1.0);        //in % of length   
+     break;
+
+   case 4:                                      // velocity dependence (DelTOF)
+     tofClust->SetTRefDifMax(6.);    // in ns 
+     tofClust->PosYMaxScal(1.5);        //in % of length
+     break;
+   case 14:
+     tofClust->SetTRefDifMax(5.);   // in ns 
+     tofClust->PosYMaxScal(1.);        //in % of length
+     break;
+   case 24:
+     tofClust->SetTRefDifMax(3.);   // in ns 
+     tofClust->PosYMaxScal(1.0);        //in % of length
+     break;
+   case 34:
+     tofClust->SetTRefDifMax(2.);   // in ns 
+     tofClust->PosYMaxScal(1.0);        //in % of length
+     break;
+   case 44:
+     tofClust->SetTRefDifMax(1.);   // in ns 
+     tofClust->PosYMaxScal(1.0);        //in % of length
+     break;
+   case 54:
+     tofClust->SetTRefDifMax(0.7);     // in ns 
+     tofClust->PosYMaxScal(0.7);        //in % of length
+     break;
+   case 64:
+     tofClust->SetTRefDifMax(0.5);     // in ns 
+     tofClust->PosYMaxScal(0.7);        //in % of length
+     break;
+   default:
+     cout << "<E> Calib mode not implemented! stop execution of script"<<endl;
+     return;
+   } 
+   run->AddTask(tofClust);
+
+   Int_t iBRef=iCalSet%1000;
+   Int_t iSet = (iCalSet - iBRef)/1000;
+   Int_t iRSel=0;
+   Int_t iRSelTyp=0;
+   Int_t iRSelSm=0;
+   Int_t iRSelRpc=0;
+   iRSel=iBRef;     // use diamond
+   if(iSel2==0){
+     // iSel2=iBRef;
+   }else{
+     if(iSel2<0) iSel2=-iSel2;
+   }   
+
+   Int_t iRSelin=iRSel;
+   iRSelRpc=iRSel%10;
+   iRSelTyp = (iRSel-iRSelRpc)/10;
+   iRSelSm=iRSelTyp%10;
+   iRSelTyp = (iRSelTyp-iRSelSm)/10;
+
+   tofClust->SetBeamRefId(iRSelTyp);    // define Beam reference counter 
+   tofClust->SetBeamRefSm(iRSelSm);
+   tofClust->SetBeamRefDet(iRSelRpc);
+   tofClust->SetBeamAddRefMul(-1);
+   tofClust->SetBeamRefMulMax(3);
+
+   Int_t iSel2in=iSel2;
+   Int_t iSel2Rpc= iSel2%10;
+   iSel2=(iSel2-iSel2Rpc)/10;
+   Int_t iSel2Sm=iSel2%10;
+   iSel2=(iSel2-iSel2Sm)/10;
+   if(iSel2 > 0) {
+     tofClust->SetSel2Id(iSel2); 
+     tofClust->SetSel2Sm(iSel2Sm); 
+     tofClust->SetSel2Rpc(iSel2Rpc);
+   }
+
+   Int_t iRef = iSet %1000;
+   Int_t iDut = (iSet - iRef)/1000;
+   Int_t iDutRpc = iDut%10;
+   iDut = (iDut - iDutRpc)/10;
+   Int_t iDutSm = iDut%10;
+   iDut = (iDut - iDutSm)/10;
+
+   tofClust->SetDutId(iDut);
+   tofClust->SetDutSm(iDutSm);
+   tofClust->SetDutRpc(iDutRpc);
+
+   Int_t iRefRpc = iRef%10;
+   iRef = (iRef - iRefRpc)/10;
+   Int_t iRefSm = iRef%10;
+   iRef = (iRef - iRefSm)/10;
+
+   tofClust->SetSelId(iRef);
+   tofClust->SetSelSm(iRefSm);
+   tofClust->SetSelRpc(iRefRpc);
+
+   cout << "Run with iRSel = "<<iRSel<<", iSel2 = "<<iSel2in<<endl;
+   
+   // =========================================================================
+   // ===                       Tracking                                    ===
+   // =========================================================================
+   CbmStsDigitize* stsDigitize = new CbmStsDigitize(); //necessary for kalman !!
+   CbmKF* kalman = new CbmKF();
+
+   CbmTofTrackFinder* tofTrackFinder= new CbmTofTrackFinderNN();
+   tofTrackFinder->SetMaxTofTimeDifference(5.);    // in ns/cm 
+   tofTrackFinder->SetTxLIM(1.6);                 // max slope dx/dz
+   tofTrackFinder->SetTyLIM(1.6);                 // max dev from mean slope dy/dz
+   tofTrackFinder->SetTyMean(0.);                 // mean slope dy/dz
+   tofTrackFinder->SetMaxTofTimeDifference(1.);   // in ns/cm
+ 
+   CbmTofTrackFitter* tofTrackFitter= new CbmTofTrackFitterKF(0,211);
+   TFitter *MyFit = new TFitter(1);                // initialize Minuit
+   tofTrackFinder->SetFitter(tofTrackFitter);
+   CbmTofFindTracks* tofFindTracks  = new CbmTofFindTracks("TOF Track Finder");
+   tofFindTracks->UseFinder(tofTrackFinder);
+   tofFindTracks->UseFitter(tofTrackFitter);
+   tofFindTracks->SetCorMode(iGenCor);           // valid options: 0,1,2,3,4,5,6, 10 - 19
+   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->SetBeamCounter(9,0,1);
+   //tofFindTracks->SetBeamCounter(1,1,1);
+  
+   tofFindTracks->SetT0MAX(dScalFac);            // in ns
+   tofFindTracks->SetSIGT(0.08);                 // default in ns
+   tofFindTracks->SetSIGX(0.3);                  // default in cm
+   tofFindTracks->SetSIGY(0.6);                  // default in cm 
+   tofFindTracks->SetSIGZ(0.1);                  // default in cm 
+   tofFindTracks->SetUseSigCalib(bUseSigCalib);        // ignore resolutions in CalPar file
+   tofTrackFinder->SetSIGLIM(dChi2Lim2*2.);      // matching window in multiples of chi2
+   tofTrackFinder->SetChiMaxAccept(dChi2Lim2);   // max tracklet chi2
+
+   Int_t iMinNofHits=-1;
+   Int_t iNStations=0;
+   Int_t iNReqStations=3;
+
+   switch (iTrackingSetup){
+   case 0:            // bypass mode
+     iMinNofHits=-1;   
+     iNStations=1;        
+     tofFindTracks->SetStation(0, 9, 0, 0);       // Diamond 
+     break;
+   case 1:                                           // for calibration mode of full setup
+     iMinNofHits=3;
+     iNStations=10;
+     iNReqStations=4;
+     //     tofFindTracks->SetStation(0, 9, 0, 0);         
+     tofFindTracks->SetStation(0, 9, 1, 0);
+     tofFindTracks->SetStation(1, 9, 2, 0);         
+     tofFindTracks->SetStation(2, 9, 0, 0);         
+     tofFindTracks->SetStation(3, 9, 1, 1);         
+     tofFindTracks->SetStation(4, 9, 2, 1);
+     tofFindTracks->SetStation(5, 9, 0, 1);     
+     tofFindTracks->SetStation(6, 6, 0, 0);         
+     tofFindTracks->SetStation(7, 6, 0, 1);
+     tofFindTracks->SetStation(8, 6, 1, 0);
+     tofFindTracks->SetStation(9, 6, 1, 1);
+     /*
      tofFindTracks->SetStation(8, 8, 0, 0);       
      tofFindTracks->SetStation(9, 8, 0, 1);       
      tofFindTracks->SetStation(10, 8, 0, 2);       
@@ -399,223 +368,209 @@ void dis_digi(Int_t nEvents        = 100,
      tofFindTracks->SetStation(14, 8, 0, 6);       
      tofFindTracks->SetStation(15, 8, 0, 7);       
      */
-      break;
-
-    case 11:  // for debugging
-      iMinNofHits   = 3;
-      iNStations    = 5;
-      iNReqStations = 5;
-      //     tofFindTracks->SetStation(0, 9, 0, 0);
-      tofFindTracks->SetStation(0, 9, 1, 0);
-      tofFindTracks->SetStation(1, 9, 2, 0);
-      tofFindTracks->SetStation(2, 9, 2, 1);
-      tofFindTracks->SetStation(3, 9, 0, 1);
-      tofFindTracks->SetStation(4, 1, 0, 1);
-      break;
-
-    case 2:
-      iMinNofHits   = 6;
-      iNStations    = 7;
-      iNReqStations = 7;
-      tofFindTracks->SetStation(0, 9, 1, 0);
-      tofFindTracks->SetStation(1, 9, 2, 0);
-      tofFindTracks->SetStation(2, 9, 1, 1);
-      tofFindTracks->SetStation(3, 9, 2, 1);
-      tofFindTracks->SetStation(4, 9, 0, 0);
-      tofFindTracks->SetStation(5, 9, 0, 1);
-      tofFindTracks->SetStation(6, 1, 0, 1);
-      //     tofFindTracks->SetStation(6, iDut, iDutSm, iDutRpc);
-      break;
-
-    case 21:
-      iMinNofHits   = 5;
-      iNStations    = 6;
-      iNReqStations = 6;
-      tofFindTracks->SetStation(0, 9, 1, 0);
-      tofFindTracks->SetStation(1, 9, 2, 0);
-      tofFindTracks->SetStation(2, 9, 1, 1);
-      tofFindTracks->SetStation(3, 9, 2, 1);
-      //tofFindTracks->SetStation(4, 9, 0, 0);
-      tofFindTracks->SetStation(4, 9, 0, 1);
-      tofFindTracks->SetStation(5, 1, 0, 1);
-      //     tofFindTracks->SetStation(6, iDut, iDutSm, iDutRpc);
-      break;
-
-    case 3:
-      iMinNofHits   = 4;
-      iNStations    = 5;
-      iNReqStations = 5;
-      tofFindTracks->SetStation(0, 9, 1, 1);
-      tofFindTracks->SetStation(1, 9, 2, 1);
-      tofFindTracks->SetStation(2, 9, 1, 0);
-      tofFindTracks->SetStation(3, 9, 2, 0);
-      tofFindTracks->SetStation(4, 9, 0, 1);
-      break;
-
-    case 4: iMinNofHits = 5; break;
-
-    case 5:  // for calibration of 2-stack and add-on counters (STAR2, CERN)
-      iMinNofHits   = 5;
-      iNStations    = 7;
-      iNReqStations = 7;
-      //     tofFindTracks->SetStation(0, 9, 0, 0);
-      tofFindTracks->SetStation(0, 9, 1, 0);
-      tofFindTracks->SetStation(1, 9, 2, 0);
-      tofFindTracks->SetStation(2, 9, 1, 1);
-      tofFindTracks->SetStation(3, 9, 2, 1);
-      tofFindTracks->SetStation(4, 9, 0, 1);
-      tofFindTracks->SetStation(5, 6, 0, 0);
-      tofFindTracks->SetStation(6, 6, 0, 1);
-      break;
-
-    default:
-      cout << "Tracking setup " << iTrackingSetup << " not implemented "
-           << endl;
-      return;
-      ;
-  }
-  tofFindTracks->SetMinNofHits(iMinNofHits);
-  tofFindTracks->SetNStations(iNStations);
-  tofFindTracks->SetNReqStations(iNReqStations);
-  tofFindTracks->PrintSetup();
-  run->AddTask(tofFindTracks);
-
-  // =========================================================================
-  // ===                       Analysis                                    ===
-  // =========================================================================
-
-  CbmTofAnaTestbeam* tofAnaTestbeam =
-    new CbmTofAnaTestbeam("TOF TestBeam Analysis", iVerbose);
-
-  //CbmTofAnaTestbeam defaults
-  tofAnaTestbeam->SetReqTrg(0);  // 0 - no selection
-  tofAnaTestbeam->SetDXMean(0.);
-  tofAnaTestbeam->SetDYMean(0.);
-  tofAnaTestbeam->SetDTMean(0.);  // in ps
-  tofAnaTestbeam->SetDXWidth(0.4);
-  tofAnaTestbeam->SetDYWidth(0.4);
-  tofAnaTestbeam->SetDTWidth(80.);  // in ps
-  tofAnaTestbeam->SetCalParFileName(cAnaFile);
-  tofAnaTestbeam->SetPosY4Sel(
-    0.5);  // Y Position selection in fraction of strip length
-  tofAnaTestbeam->SetDTDia(0.);        // Time difference to additional diamond
-  tofAnaTestbeam->SetCorMode(RefSel);  // 1 - DTD4, 2 - X4
-  tofAnaTestbeam->SetMul0Max(30);      // Max Multiplicity in dut
-  tofAnaTestbeam->SetMul4Max(30);      // Max Multiplicity in Ref - RPC
-  tofAnaTestbeam->SetMulDMax(10);      // Max Multiplicity in Diamond
-  tofAnaTestbeam->SetHitDistMin(30.);  // initialization
-  tofAnaTestbeam->SetEnableMatchPosScaling(kFALSE);
-
-  tofAnaTestbeam->SetPosYS2Sel(
-    0.5);  // Y Position selection in fraction of strip length
-  tofAnaTestbeam->SetChS2Sel(0.);     // Center of channel selection window
-  tofAnaTestbeam->SetDChS2Sel(100.);  // Width  of channel selection window
-  tofAnaTestbeam->SetTShift(0.);      // Shift DTD4 to 0
-  tofAnaTestbeam->SetSel2TOff(0.);    // Shift Sel2 time peak to 0
-  tofAnaTestbeam->SetTOffD4(13.);     // Shift DTD4 to physical value
-
-  if (iSel2 > 0) {
-    tofAnaTestbeam->SetMrpcSel2(
-      iSel2);  // initialization of second selector Mrpc Type
-    tofAnaTestbeam->SetMrpcSel2Sm(
-      iSel2Sm);  // initialization of second selector Mrpc SmId
-    tofAnaTestbeam->SetMrpcSel2Rpc(
-      iSel2Rpc);  // initialization of second selector Mrpc RpcId
-  }
-
-  tofAnaTestbeam->SetDut(iDut);            // Device under test
-  tofAnaTestbeam->SetDutSm(iDutSm);        // Device under test
-  tofAnaTestbeam->SetDutRpc(iDutRpc);      // Device under test
-  tofAnaTestbeam->SetMrpcRef(iRef);        // Reference RPC
-  tofAnaTestbeam->SetMrpcRefSm(iRefSm);    // Reference RPC
-  tofAnaTestbeam->SetMrpcRefRpc(iRefRpc);  // Reference RPC
-
-  tofAnaTestbeam->SetChi2Lim(10.);  // initialization of Chi2 selection limit
-
-  if (0) switch (iSet) {
-      case 0:   // upper part of setup: P2 - P5
-      case 3:   // upper part of setup: P2 - P5
-      case 34:  // upper part of setup: P2 - P5
-      case 400300:
-        switch (iRSel) {
-          case 4:
-            tofAnaTestbeam->SetTShift(0.);    // Shift DTD4 to 0
-            tofAnaTestbeam->SetTOffD4(16.);   // Shift DTD4 to physical value
-            tofAnaTestbeam->SetSel2TOff(0.);  // Shift Sel2 time peak to 0
-            break;
-
-          case 5:
-            tofAnaTestbeam->SetTShift(-3.);   // Shift DTD4 to 0
-            tofAnaTestbeam->SetTOffD4(16.);   // Shift DTD4 to physical value
-            tofAnaTestbeam->SetSel2TOff(0.);  // Shift Sel2 time peak to 0
-            break;
-
-          case 9:
-            tofAnaTestbeam->SetChi2Lim(
-              100.);  // initialization of Chi2 selection limit
-            tofAnaTestbeam->SetMulDMax(
-              3);  // Max Multiplicity in BeamRef // Diamond
-            tofAnaTestbeam->SetTShift(0.1);    // Shift DTD4 to 0
-            tofAnaTestbeam->SetTOffD4(16.);    // Shift DTD4 to physical value
-            tofAnaTestbeam->SetSel2TOff(0.5);  // Shift Sel2 time peak to 0
-            break;
-
-          default:;
-        }
-
-      default:
-        cout << "<E> detector setup " << iSet << " unknown, stop!" << endl;
-        return;
-        ;
-    }  // end of different subsets
-
-  //run->AddTask(tofAnaTestbeam);
-  // =========================================================================
-  /*
+     break;
+
+   case 11:                                           // for debugging
+     iMinNofHits=3;
+     iNStations=5;
+     iNReqStations=5;
+     //     tofFindTracks->SetStation(0, 9, 0, 0);         
+     tofFindTracks->SetStation(0, 9, 1, 0);
+     tofFindTracks->SetStation(1, 9, 2, 0);         
+     tofFindTracks->SetStation(2, 9, 2, 1);
+     tofFindTracks->SetStation(3, 9, 0, 1);     
+     tofFindTracks->SetStation(4, 1, 0, 1);
+     break;
+     
+   case 2:
+     iMinNofHits=6;
+     iNStations=7;
+     iNReqStations=7;
+     tofFindTracks->SetStation(0, 9, 1, 0);
+     tofFindTracks->SetStation(1, 9, 2, 0);         
+     tofFindTracks->SetStation(2, 9, 1, 1);         
+     tofFindTracks->SetStation(3, 9, 2, 1);  
+     tofFindTracks->SetStation(4, 9, 0, 0);         
+     tofFindTracks->SetStation(5, 9, 0, 1);
+     tofFindTracks->SetStation(6, 1, 0, 1);
+     //     tofFindTracks->SetStation(6, iDut, iDutSm, iDutRpc);
+     break;
+     
+   case 21:
+     iMinNofHits=5;
+     iNStations=6;
+     iNReqStations=6;
+     tofFindTracks->SetStation(0, 9, 1, 0);
+     tofFindTracks->SetStation(1, 9, 2, 0);         
+     tofFindTracks->SetStation(2, 9, 1, 1);         
+     tofFindTracks->SetStation(3, 9, 2, 1);  
+     //tofFindTracks->SetStation(4, 9, 0, 0);         
+     tofFindTracks->SetStation(4, 9, 0, 1);
+     tofFindTracks->SetStation(5, 1, 0, 1);
+     //     tofFindTracks->SetStation(6, iDut, iDutSm, iDutRpc);
+     break;
+     
+   case 3:
+     iMinNofHits=4;
+     iNStations=5;
+     iNReqStations=5; 
+     tofFindTracks->SetStation(0, 9, 1, 1);         
+     tofFindTracks->SetStation(1, 9, 2, 1);  
+     tofFindTracks->SetStation(2, 9, 1, 0);
+     tofFindTracks->SetStation(3, 9, 2, 0);
+     tofFindTracks->SetStation(4, 9, 0, 1);  
+     break;
+
+   case 4:
+     iMinNofHits=5;
+
+     break;
+
+   case 5:     // for calibration of 2-stack and add-on counters (STAR2, CERN)
+     iMinNofHits=5;
+     iNStations=7;
+     iNReqStations=7;
+     //     tofFindTracks->SetStation(0, 9, 0, 0);         
+     tofFindTracks->SetStation(0, 9, 1, 0);
+     tofFindTracks->SetStation(1, 9, 2, 0);         
+     tofFindTracks->SetStation(2, 9, 1, 1);         
+     tofFindTracks->SetStation(3, 9, 2, 1);
+     tofFindTracks->SetStation(4, 9, 0, 1);         
+     tofFindTracks->SetStation(5, 6, 0, 0);         
+     tofFindTracks->SetStation(6, 6, 0, 1);
+     break;
+     
+   default:
+     cout << "Tracking setup "<<iTrackingSetup<<" not implemented "<<endl;
+     return;
+     ;
+   }
+   tofFindTracks->SetMinNofHits(iMinNofHits);
+   tofFindTracks->SetNStations(iNStations);
+   tofFindTracks->SetNReqStations(iNReqStations);
+   tofFindTracks->PrintSetup();
+   run->AddTask(tofFindTracks);
+
+   // =========================================================================
+   // ===                       Analysis                                    ===
+   // =========================================================================
+
+   CbmTofAnaTestbeam* tofAnaTestbeam = new CbmTofAnaTestbeam("TOF TestBeam Analysis",iVerbose);
+
+   //CbmTofAnaTestbeam defaults  
+   tofAnaTestbeam->SetReqTrg(0);   // 0 - no selection
+   tofAnaTestbeam->SetDXMean(0.);
+   tofAnaTestbeam->SetDYMean(0.);
+   tofAnaTestbeam->SetDTMean(0.);  // in ps
+   tofAnaTestbeam->SetDXWidth(0.4);
+   tofAnaTestbeam->SetDYWidth(0.4);
+   tofAnaTestbeam->SetDTWidth(80.); // in ps
+   tofAnaTestbeam->SetCalParFileName(cAnaFile);
+   tofAnaTestbeam->SetPosY4Sel(0.5); // Y Position selection in fraction of strip length
+   tofAnaTestbeam->SetDTDia(0.);   // Time difference to additional diamond
+   tofAnaTestbeam->SetCorMode(RefSel); // 1 - DTD4, 2 - X4 
+   tofAnaTestbeam->SetMul0Max(30);      // Max Multiplicity in dut 
+   tofAnaTestbeam->SetMul4Max(30);      // Max Multiplicity in Ref - RPC 
+   tofAnaTestbeam->SetMulDMax(10);      // Max Multiplicity in Diamond    
+   tofAnaTestbeam->SetHitDistMin(30.);  // initialization
+   tofAnaTestbeam->SetEnableMatchPosScaling(kFALSE);
+
+   tofAnaTestbeam->SetPosYS2Sel(0.5);   // Y Position selection in fraction of strip length
+   tofAnaTestbeam->SetChS2Sel(0.);      // Center of channel selection window
+   tofAnaTestbeam->SetDChS2Sel(100.);   // Width  of channel selection window
+   tofAnaTestbeam->SetTShift(0.);       // Shift DTD4 to 0
+   tofAnaTestbeam->SetSel2TOff(0.);     // Shift Sel2 time peak to 0 
+   tofAnaTestbeam->SetTOffD4(13.);   // Shift DTD4 to physical value
+
+   if(iSel2 > 0) {
+     tofAnaTestbeam->SetMrpcSel2(iSel2);           // initialization of second selector Mrpc Type 
+     tofAnaTestbeam->SetMrpcSel2Sm(iSel2Sm);       // initialization of second selector Mrpc SmId
+     tofAnaTestbeam->SetMrpcSel2Rpc(iSel2Rpc);     // initialization of second selector Mrpc RpcId
+   }
+
+   tofAnaTestbeam->SetDut(iDut);              // Device under test   
+   tofAnaTestbeam->SetDutSm(iDutSm);          // Device under test   
+   tofAnaTestbeam->SetDutRpc(iDutRpc);        // Device under test   
+   tofAnaTestbeam->SetMrpcRef(iRef);          // Reference RPC     
+   tofAnaTestbeam->SetMrpcRefSm(iRefSm);      // Reference RPC     
+   tofAnaTestbeam->SetMrpcRefRpc(iRefRpc);    // Reference RPC     
+
+   tofAnaTestbeam->SetChi2Lim(10.);           // initialization of Chi2 selection limit  
+
+   if(0)
+   switch (iSet) {
+   case 0:                                 // upper part of setup: P2 - P5
+   case 3:                                 // upper part of setup: P2 - P5
+   case 34:                                // upper part of setup: P2 - P5
+   case 400300:
+     switch (iRSel){
+         case 4:
+	   tofAnaTestbeam->SetTShift(0.);   // Shift DTD4 to 0
+	   tofAnaTestbeam->SetTOffD4(16.);   // Shift DTD4 to physical value
+	   tofAnaTestbeam->SetSel2TOff(0.);     // Shift Sel2 time peak to 0
+	   break;
+	   
+         case 5:
+	   tofAnaTestbeam->SetTShift(-3.);     // Shift DTD4 to 0
+	   tofAnaTestbeam->SetTOffD4(16.);   // Shift DTD4 to physical value
+	   tofAnaTestbeam->SetSel2TOff(0.);     // Shift Sel2 time peak to 0
+	   break;
+
+         case 9:
+	   tofAnaTestbeam->SetChi2Lim(100.);   // initialization of Chi2 selection limit  
+	   tofAnaTestbeam->SetMulDMax(3);      // Max Multiplicity in BeamRef // Diamond    
+	   tofAnaTestbeam->SetTShift(0.1);   // Shift DTD4 to 0
+	   tofAnaTestbeam->SetTOffD4(16.);   // Shift DTD4 to physical value
+	   tofAnaTestbeam->SetSel2TOff(0.5);     // Shift Sel2 time peak to 0
+	   break;
+
+         default:
+	   ;
+     }
+
+     default:
+	   cout<<"<E> detector setup "<<iSet<<" unknown, stop!"<<endl;
+	   return;
+	 ;
+   }  // end of different subsets
+
+   //run->AddTask(tofAnaTestbeam);
+   // =========================================================================
+   /*
    CbmTofOnlineDisplay* display = new CbmTofOnlineDisplay();
    display->SetUpdateInterval(1000);
    run->AddTask(display);   
    */
   // -----  Parameter database   --------------------------------------------
-
-  FairRuntimeDb* rtdb       = run->GetRuntimeDb();
-  Bool_t kParameterMerged   = kTRUE;
-  FairParRootFileIo* parIo2 = new FairParRootFileIo(kParameterMerged);
-  parIo2->open(ParFile.Data(), "UPDATE");
-  parIo2->print();
-  rtdb->setFirstInput(parIo2);
-
-  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
-  parIo1->open(parFileList, "in");
-  parIo1->print();
-  rtdb->setSecondInput(parIo1);
-  rtdb->print();
-  rtdb->printParamContexts();
-
-  //  FairParRootFileIo* parInput1 = new FairParRootFileIo();
-  //  parInput1->open(ParFile.Data());
-  //  rtdb->setFirstInput(parInput1);
-
-  FairEventManager* fMan = new FairEventManager();
-
-  CbmEvDisTracks* Tracks = new CbmEvDisTracks(
-    "Tof Tracks",
-    1,
-    kFALSE,
-    kTRUE);  //name, verbosity, RnrChildren points, RnrChildren track
-             //  CbmEvDisTracks *Tracks =  new CbmEvDisTracks("Tof Tracks",1);
+ 
+   FairRuntimeDb* rtdb = run->GetRuntimeDb();
+   Bool_t kParameterMerged = kTRUE;
+   FairParRootFileIo* parIo2 = new FairParRootFileIo(kParameterMerged);
+   parIo2->open(ParFile.Data(), "UPDATE");
+   parIo2->print();
+   rtdb->setFirstInput(parIo2);
+  
+   FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
+   parIo1->open(parFileList, "in");
+   parIo1->print();
+   rtdb->setSecondInput(parIo1);
+   rtdb->print();
+   rtdb->printParamContexts();
+
+   //  FairParRootFileIo* parInput1 = new FairParRootFileIo();
+   //  parInput1->open(ParFile.Data());
+   //  rtdb->setFirstInput(parInput1);
+
+   FairEventManager *fMan= new FairEventManager();
+ 
+  CbmEvDisTracks *Tracks =  new CbmEvDisTracks("Tof Tracks",1,kFALSE,kTRUE); //name, verbosity, RnrChildren points, RnrChildren track
+   //  CbmEvDisTracks *Tracks =  new CbmEvDisTracks("Tof Tracks",1);
   fMan->AddTask(Tracks);
-  CbmPixelHitSetDraw* TofUHits =
-    new CbmPixelHitSetDraw("TofUHit", kRed, kOpenCross);
+  CbmPixelHitSetDraw *TofUHits = new CbmPixelHitSetDraw ("TofUHit", kRed, kOpenCross );
   fMan->AddTask(TofUHits);
-  CbmPointSetArrayDraw* TofHits = new CbmPointSetArrayDraw(
-    "TofHit",
-    1,
-    1,
-    4,
-    kTRUE);  //name, colorMode, markerMode, verbosity, RnrChildren
-  //  CbmPixelHitSetDraw *TofHits = new CbmPixelHitSetDraw ("TofHit", kRed, kOpenCircle, 4);// kFullSquare);
-  fMan->AddTask(TofHits);
+   CbmPointSetArrayDraw *TofHits = new CbmPointSetArrayDraw ("TofHit", 1, 1, 4, kTRUE); //name, colorMode, markerMode, verbosity, RnrChildren
+   //  CbmPixelHitSetDraw *TofHits = new CbmPixelHitSetDraw ("TofHit", kRed, kOpenCircle, 4);// kFullSquare);
+  fMan->AddTask(TofHits); 
 
 
   TGeoVolume* top = gGeoManager->GetTopVolume();
@@ -623,9 +578,9 @@ void dis_digi(Int_t nEvents        = 100,
   gGeoManager->SetVisLevel(5);
   TObjArray* allvolumes = gGeoManager->GetListOfVolumes();
   //cout<<"GeoVolumes  "  << gGeoManager->GetListOfVolumes()->GetEntries()<<endl;
-  for (Int_t i = 0; i < allvolumes->GetEntries(); i++) {
-    TGeoVolume* vol = (TGeoVolume*) allvolumes->At(i);
-    TString name    = vol->GetName();
+  for(Int_t i=0; i<allvolumes->GetEntries(); i++){
+    TGeoVolume* vol     = (TGeoVolume*)allvolumes->At(i);
+    TString name = vol->GetName();
     //    cout << " GeoVolume "<<i<<" Name: "<< name << endl;
     vol->SetTransparency(90);
     /* switch (char *) not allowed any more in root 6 :(
@@ -650,31 +605,32 @@ void dis_digi(Int_t nEvents        = 100,
     */
   }
   //  gGeoManager->SetVisLevel(3);
-  //  top->SetTransparency(80);
+  //  top->SetTransparency(80); 
   //  top->Draw("ogl");
 
-  //  fMan->Init(1,4,10000);
-  fMan->Init(1, 5);
-
-  cout << "customize TEveManager gEve " << gEve << endl;
-  gEve->GetDefaultGLViewer()->SetClearColor(kYellow - 10);
-  TGLViewer* v       = gEve->GetDefaultGLViewer();
-  TGLAnnotation* ann = new TGLAnnotation(v, cFileId, 0.01, 0.98);
-  ann->SetTextSize(0.03);  // % of window diagonal
+  //  fMan->Init(1,4,10000);                     
+  fMan->Init(1,5); 
+                    
+  cout << "customize TEveManager gEve "<< gEve << endl;
+  gEve->GetDefaultGLViewer()->SetClearColor(kYellow-10);
+  TGLViewer* v = gEve->GetDefaultGLViewer();
+  TGLAnnotation* ann = new TGLAnnotation(v,cFileId,0.01,0.98);
+  ann->SetTextSize(0.03);// % of window diagonal
   ann->SetTextColor(4);
 
   //  gEve->TEveProjectionAxes()->SetDrawOrigin(kTRUE);
 
-  {  // from readCurrentCamera(const char* fname)
-    TGLCamera& c      = gEve->GetDefaultGLViewer()->CurrentCamera();
-    const char* fname = "Cam.sav";
-    TFile* f          = TFile::Open(fname, "READ");
-    if (!f) return;
-    if (f->GetKey(c.ClassName())) {
-      f->GetKey(c.ClassName())->Read(&c);
-      c.IncTimeStamp();
-      gEve->GetDefaultGLViewer()->RequestDraw();
-    }
+  {   // from readCurrentCamera(const char* fname)
+  TGLCamera& c = gEve->GetDefaultGLViewer()->CurrentCamera();
+  const char* fname="Cam.sav";
+  TFile* f = TFile::Open(fname, "READ");
+  if (!f) 
+    return;
+  if (f->GetKey(c.ClassName())) {
+    f->GetKey(c.ClassName())->Read(&c);
+    c.IncTimeStamp();
+    gEve->GetDefaultGLViewer()->RequestDraw();
+  }
   }
 
   // -----   Intialise and run   --------------------------------------------
@@ -682,7 +638,7 @@ void dis_digi(Int_t nEvents        = 100,
   //  cout << "Starting run" << endl;
   //  run->Run(0, nEvents);
   // ------------------------------------------------------------------------
-  // default display
+  // default display 
   /*
   TString Display_Status = "pl_over_Mat04D4best.C";
   TString Display_Funct = "pl_over_Mat04D4best()";  
diff --git a/macro/beamtime/hd2020/pl_all_3D.C b/macro/beamtime/hd2020/pl_all_3D.C
index 6a94e7f91bacc8593fef98baee7269abf3f1b152..9582590d67d502633894b06877dc29a1528b6cb6 100644
--- a/macro/beamtime/hd2020/pl_all_3D.C
+++ b/macro/beamtime/hd2020/pl_all_3D.C
@@ -1,69 +1,65 @@
-void pl_all_3D(Int_t iOpt = 0, Int_t iSel = 0, Int_t iNSt = 2) {
+void pl_all_3D(Int_t iOpt=0, Int_t iSel=0, Int_t iNSt=2)
+{
   //  TCanvas *can = new TCanvas("can22","can22");
-  //  can->Divide(2,2);
+  //  can->Divide(2,2); 
   //  TCanvas *can = new TCanvas("can","can",48,55,700,900);
-  TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900);
-  can->Divide(4, 3, 0.01, 0.01);
-  //  can->Divide(2,2,0,0);
-  Float_t lsize = 0.07;
+  TCanvas *can = new TCanvas("can","can",48,56,900,900);
+  can->Divide(4,3,0.01,0.01); 
+  //  can->Divide(2,2,0,0); 
+  Float_t lsize=0.07;
 
-  gPad->SetFillColor(0);
-  gStyle->SetPalette(1);
-  gStyle->SetLabelSize(lsize);
+ gPad->SetFillColor(0);
+ gStyle->SetPalette(1);
+ gStyle->SetLabelSize(lsize);
 
-  //gStyle->SetOptStat(kTRUE);
-  //gROOT->cd();
-  //gROOT->SetDirLevel(2);
+ //gStyle->SetOptStat(kTRUE);
+ //gROOT->cd();
+ //gROOT->SetDirLevel(2);
 
-  TH3* h;
-  TH2* h2;
-  const Int_t iType[6]   = {9, 6, 7, 5, 6, 8};
-  const Int_t iSmNum[6]  = {3, 2, 1, 1, 1, 1};
-  const Int_t iRpcNum[6] = {2, 2, 1, 1, 2, 8};
-  TString cOpt;
+ TH3 *h;
+ TH2 *h2;
+ const Int_t   iType[6]={9,6,7,5,6,8};
+ const Int_t  iSmNum[6]={3,2,1,1,1,1};
+ const Int_t iRpcNum[6]={2,2,1,1,2,8};
+ TString cOpt; 
 
-  Int_t iCanv = 0;
-  // if (h!=NULL) h->Delete();
+ Int_t iCanv=0;
+ // if (h!=NULL) h->Delete();
 
-  for (Int_t iSt = 0; iSt < iNSt; iSt++) {
-    for (Int_t iSm = 0; iSm < iSmNum[iSt]; iSm++) {
-      for (Int_t iRp = 0; iRp < iRpcNum[iSt]; iRp++) {
-        can->cd(iCanv + 1);
-        iCanv++;
-        gROOT->cd();
-        TString hname = Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2",
-                             iType[iSt],
-                             iSm,
-                             iRp,
-                             iSel);
-        h             = (TH3*) gROOT->FindObjectAny(hname);
-        if (h != NULL) {
-          switch (iOpt) {
-            case 0:
-              cOpt = "yx";
-              h->Project3D(cOpt)->Draw("colz");
-              break;
+ for(Int_t iSt=0; iSt<iNSt; iSt++){
+  for(Int_t iSm=0; iSm<iSmNum[iSt];iSm++){
+    for(Int_t iRp=0; iRp<iRpcNum[iSt];iRp++){
+      can->cd(iCanv+1); iCanv++;
+      gROOT->cd();
+      TString hname=Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2",iType[iSt],iSm,iRp,iSel);
+      h=(TH3 *)gROOT->FindObjectAny(hname);
+      if (h!=NULL) {
+		switch(iOpt){
+		  case 0: 
+			cOpt="yx";
+			h->Project3D(cOpt)->Draw("colz");
+			break;
 
-            case 1:
-              cOpt = "yx";
-              h->Project3D(cOpt)->Draw("colz");
-              gPad->SetLogz();
-              break;
+		  case 1:
+			cOpt="yx";
+			h->Project3D(cOpt)->Draw("colz");
+		    gPad->SetLogz();
+			break;
 
-            case 2:
-              cOpt = "pfyx";
-              h2   = (TH2*) h->Project3DProfile("yx");
-              h2->SetMinimum(-0.2);
-              h2->SetMaximum(0.2);
-              h2->Draw("colz");
-              break;
-            default:;
-          }
-        } else {
-          cout << "Histogram " << hname << " not existing. " << endl;
-        }
-      }
+		  case 2: 
+			cOpt="pfyx";
+			h2 = (TH2 *)h->Project3DProfile("yx");
+			h2->SetMinimum(-0.2);
+			h2->SetMaximum(0.2);
+			h2->Draw("colz");
+			break;
+		  default:
+			;
+		}
+      }else{cout<<"Histogram "<<hname<<" not existing. "<<endl;}
     }
   }
-  can->SaveAs(Form("pl_all_%s.pdf", cOpt.Data()));
-}
+ }
+ can->SaveAs(Form("pl_all_%s.pdf",cOpt.Data()));
+
+} 
diff --git a/macro/beamtime/hd2020/pl_all_Track2D.C b/macro/beamtime/hd2020/pl_all_Track2D.C
index 382bc4ed578e69fa27531edeeb6455becd270e63..668b37b101b8cc23e208050a265f647bf0ad0c54 100644
--- a/macro/beamtime/hd2020/pl_all_Track2D.C
+++ b/macro/beamtime/hd2020/pl_all_Track2D.C
@@ -1,122 +1,136 @@
-void pl_all_Track2D(Int_t iOpt = 1, Int_t iNSt = 2) {
+void pl_all_Track2D(Int_t iOpt=1, Int_t iNSt=2)
+{
   //  TCanvas *can = new TCanvas("can22","can22");
-  //  can->Divide(2,2);
+  //  can->Divide(2,2); 
   //  TCanvas *can = new TCanvas("can","can",48,55,700,900);
-  TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900);
-  can->Divide(5, 6, 0.01, 0.01);
-  //  can->Divide(2,2,0,0);
-  Float_t lsize = 0.07;
+  TCanvas *can = new TCanvas("can","can",48,56,900,900);
+  can->Divide(5,6,0.01,0.01); 
+  //  can->Divide(2,2,0,0); 
+  Float_t lsize=0.07;
 
-  gPad->SetFillColor(0);
-  gStyle->SetPalette(1);
-  gStyle->SetLabelSize(lsize);
+ gPad->SetFillColor(0);
+ gStyle->SetPalette(1);
+ gStyle->SetLabelSize(lsize);
 
-  //gStyle->SetOptStat(kTRUE);
-  //gROOT->cd();
-  //gROOT->SetDirLevel(2);
+ //gStyle->SetOptStat(kTRUE);
+ //gROOT->cd();
+ //gROOT->SetDirLevel(2);
 
-  TH2* h;
-  TH2* h2;
-  const Int_t iType[6]   = {0, 9, 5, 5, 7, 8};
-  const Int_t iSmNum[6]  = {5, 1, 1, 1, 1, 1};
-  const Int_t iRpcNum[6] = {5, 1, 1, 1, 1, 8};
-  TString cOpt;
+ TH2 *h;
+ TH2 *h2;
+ const Int_t  iType[6]={0,9,5,5,7,8};
+ const Int_t  iSmNum[6]={5,1,1,1,1,1};
+ const Int_t iRpcNum[6]={5,1,1,1,1,8};
+ TString cOpt; 
 
-  switch (iOpt) {
-    case 0: cOpt = "Size"; break;
-    case 1: cOpt = "Pos"; break;
-    case 2: cOpt = "TOff"; break;
-    case 3: cOpt = "Tot"; break;
-    case 4: cOpt = "Walk"; break;
-    case 5: cOpt = "Walk"; break;
-    case 6: cOpt = "Mul"; break;
-    case 7: cOpt = "Trms"; break;
-    case 8: cOpt = "DelPos"; break;
-    case 9: cOpt = "DelTOff"; break;
-    case 10: cOpt = "DelMatPos"; break;
-    case 11: cOpt = "DelMatTOff"; break;
-    default:;
-  }
+ switch(iOpt){
+ case 0: 
+   cOpt="Size";
+   break;
+ case 1:
+   cOpt="Pos";
+   break;
+ case 2:
+   cOpt="TOff";
+   break;
+ case 3:
+   cOpt="Tot";
+   break;
+ case 4:
+   cOpt="Walk";
+   break;
+ case 5:
+   cOpt="Walk";
+   break;
+ case 6:
+   cOpt="Mul";
+   break;
+ case 7:
+   cOpt="Trms";
+   break;
+ case 8:
+   cOpt="DelPos";
+   break;
+ case 9:
+   cOpt="DelTOff";
+   break;
+ case 10:
+   cOpt="DelMatPos";
+   break;
+ case 11:
+   cOpt="DelMatTOff";
+   break;
+ default:
+   ;
+ }
 
-  Int_t iDet       = 0;
-  Double_t dAvMean = 0.;
-  Double_t dAvRMS  = 0.;
-  Int_t iCanv      = 0;
+ Int_t iDet=0;
+ Double_t dAvMean=0.;
+ Double_t dAvRMS=0.;
+ Int_t iCanv=0;
 
-  for (Int_t iSt = 0; iSt < iNSt; iSt++) {
-    // cout << "plot station "<<iSt<<" with "<< iSmNum[iSt] <<" modules of "<<iRpcNum[iSt]<<" Rpcs each"<<endl;
-    for (Int_t iSm = 0; iSm < iSmNum[iSt]; iSm++) {
-      //cout << "plot module at station "<<iSt<<" with "<< iSmNum[iSt] <<" modules of "<<iRpcNum[iSt]<<" Rpcs each"<<endl;
-      for (Int_t iRp = 0; iRp < iRpcNum[iSt]; iRp++) {
-        //cout << "plot rpc at station "<<iSt<<" with "<< iSmNum[iSt] <<" modules of "<<iRpcNum[iSt]<<" Rpcs each"<<endl;
-        can->cd(iCanv + 1);
-        iCanv++;
-        gROOT->cd();
-        TString hname = "";
-        Int_t iCol    = 1;
-        switch (iOpt) {
-          case 4:
-            for (Int_t iSide = 0; iSide < 2; iSide++)
-              for (Int_t iCh = 0; iCh < 32; iCh++) {
-                hname = Form("cal_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%d_%s",
-                             iType[iSt],
-                             iSm,
-                             iRp,
-                             iCh,
-                             iSide,
-                             cOpt.Data());
-                h     = (TH2*) gROOT->FindObjectAny(hname);
-                if (h != NULL) {
-                  TProfile* hProf =
-                    h->ProfileX(Form("%s_pfx%d%d", hname.Data(), iCh, iSide));
-                  hProf->SetLineColor(iCol);
-                  hProf->SetLineStyle(1);
-                  hProf->SetMarkerColor(iCol);
-                  hProf->SetMarkerStyle(24 + iSide);
-                  iCol++;
-                  if (iCh == 0) iCol = 1;
-                  if (iCh == 0 && iSide == 0) {
-                    hProf->SetMaximum(0.4);
-                    hProf->SetMinimum(-0.4);
-                    hProf->GetXaxis()->SetRangeUser(0., 10.);
-                    hProf->Draw("LP");
-                  } else {
-                    hProf->Draw("LPsame");
-                  }
-                }
-              }
-            break;
-          default:
-            hname = Form("cal_SmT%01d_sm%03d_rpc%03d_%s",
-                         iType[iSt],
-                         iSm,
-                         iRp,
-                         cOpt.Data());
-            h     = (TH2*) gROOT->FindObjectAny(hname);
-            if (h != NULL) {
-              if (iOpt == 2 || iOpt == 2) { gPad->SetLogz(); }
-              h->Draw("colz");
-              h->ProfileX()->Draw("same");
-              iDet++;
-              dAvMean += h->ProfileX()->GetMean(2);
-              dAvRMS += h->ProfileX()->GetRMS(2);
-              cout << "TrackQA " << cOpt.Data() << " for TSR " << iType[iSt]
-                   << iSm << iRp << ": Off " << h->ProfileX()->GetMean(2)
-                   << ", RMS " << h->ProfileX()->GetRMS(2) << endl;
-            }
-        }
-      }
-    }
+ for(Int_t iSt=0; iSt<iNSt; iSt++){
+   // cout << "plot station "<<iSt<<" with "<< iSmNum[iSt] <<" modules of "<<iRpcNum[iSt]<<" Rpcs each"<<endl;
+  for(Int_t iSm=0; iSm<iSmNum[iSt];iSm++){
+    //cout << "plot module at station "<<iSt<<" with "<< iSmNum[iSt] <<" modules of "<<iRpcNum[iSt]<<" Rpcs each"<<endl;
+    for(Int_t iRp=0; iRp<iRpcNum[iSt];iRp++){
+      //cout << "plot rpc at station "<<iSt<<" with "<< iSmNum[iSt] <<" modules of "<<iRpcNum[iSt]<<" Rpcs each"<<endl;
+      can->cd(iCanv+1); iCanv++;
+      gROOT->cd();
+      TString hname="";
+      Int_t iCol=1;
+      switch(iOpt) {
+		case 4:
+		  for (Int_t iSide=0; iSide<2; iSide++)
+		    for (Int_t iCh=0; iCh<32; iCh++) {
+			  hname=Form("cal_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%d_%s",iType[iSt],iSm,iRp,iCh,iSide,cOpt.Data());
+              h=(TH2 *)gROOT->FindObjectAny(hname);
+              if (h!=NULL) {
+                TProfile *hProf=h->ProfileX(Form("%s_pfx%d%d",hname.Data(),iCh,iSide));
+                hProf->SetLineColor(iCol);
+                hProf->SetLineStyle(1);
+                hProf->SetMarkerColor(iCol);
+                hProf->SetMarkerStyle(24+iSide);
+                iCol++;
+                if(iCh==0) iCol=1;
+                if(iCh==0 && iSide==0) {
+				  hProf->SetMaximum(0.4);
+				  hProf->SetMinimum(-0.4);
+				  hProf->GetXaxis()->SetRangeUser(0.,10.);
+				  hProf->Draw("LP");
+			    } else {
+				  hProf->Draw("LPsame");
+			    }
+			  }
+              
+		    }
+		  break;
+		default:
+            hname=Form("cal_SmT%01d_sm%03d_rpc%03d_%s",iType[iSt],iSm,iRp,cOpt.Data());
+            h=(TH2 *)gROOT->FindObjectAny(hname);
+            if (h!=NULL) {
+				if (iOpt == 2 || iOpt==2 ) {
+					gPad->SetLogz();
+				}
+				h->Draw("colz");
+				h->ProfileX()->Draw("same");
+				iDet++;
+				dAvMean += h->ProfileX()->GetMean(2);
+				dAvRMS  += h->ProfileX()->GetRMS(2);
+				cout << "TrackQA " << cOpt.Data() <<" for TSR " << iType[iSt] << iSm << iRp << ": Off "<< h->ProfileX()->GetMean(2) 
+				<< ", RMS "<< h->ProfileX()->GetRMS(2) << endl;
+			}
+		}	  
+	}
   }
-  dAvMean /= (Double_t) iDet;
-  dAvRMS /= (Double_t) iDet;
-  cout << "TrackQA " << cOpt.Data() << ": AvOff " << dAvMean << ", AvRMS "
-       << dAvRMS << endl;
-  dAvMean = TMath::Abs(dAvMean);
-  gROOT->ProcessLine(
-    Form(".! echo %d > %sAvOff.res", (Int_t)(dAvMean * 1.E4), cOpt.Data()));
-  gROOT->ProcessLine(
-    Form(".! echo %d > %sAvRMS.res", (Int_t)(dAvRMS * 1.E4), cOpt.Data()));
+ }
+ dAvMean /= (Double_t)iDet;
+ dAvRMS  /= (Double_t)iDet;
+ cout << "TrackQA " << cOpt.Data() <<": AvOff "<< dAvMean << ", AvRMS "<< dAvRMS << endl;
+ dAvMean=TMath::Abs(dAvMean);
+ gROOT->ProcessLine(Form(".! echo %d > %sAvOff.res", (Int_t)(dAvMean*1.E4),cOpt.Data()));
+ gROOT->ProcessLine(Form(".! echo %d > %sAvRMS.res", (Int_t)(dAvRMS*1.E4),cOpt.Data()));
+
+ can->SaveAs(Form("pl_all_Track_%s.pdf",cOpt.Data()));
 
-  can->SaveAs(Form("pl_all_Track_%s.pdf", cOpt.Data()));
-}
+} 
diff --git a/macro/beamtime/mcbm2018/ana_digi_cal.C b/macro/beamtime/mcbm2018/ana_digi_cal.C
index f792256dacc3216b876cf1f3b6b12b7df83e3257..eb9b70872e86db3cbb2cd07e2e56700ef9efacde 100644
--- a/macro/beamtime/mcbm2018/ana_digi_cal.C
+++ b/macro/beamtime/mcbm2018/ana_digi_cal.C
@@ -46,7 +46,7 @@ void ana_digi_cal(Int_t nEvents      = 10000000,
   TString FId    = cFileId;
   TString TofGeo = "v18m_mcbm";
   cout << "Geometry version " << TofGeo << endl;
-  /*
+/*
   TObjString* tofDigiFile = new TObjString(
     workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par");  // TOF digi file
   parFileList->Add(tofDigiFile);
diff --git a/macro/beamtime/mcbm2018/ana_trks.C b/macro/beamtime/mcbm2018/ana_trks.C
index 42d387348df7ac9b0699a4ec3e4a24d4f3e92c83..3fea1fc9adf651d7afea7fd8c69f27ac679d125b 100644
--- a/macro/beamtime/mcbm2018/ana_trks.C
+++ b/macro/beamtime/mcbm2018/ana_trks.C
@@ -66,7 +66,7 @@ void ana_trks(Int_t nEvents        = 10000,
   gSystem->Exec(shcmd.Data());
 
   TList* parFileList = new TList();
-  Int_t iGeo         = 0;  //iMc;
+  Int_t iGeo = 0;  //iMc;
   if (iGeo == 0) {
     TString TofGeo = "v18m_mcbm";  //default
 
@@ -178,12 +178,12 @@ void ana_trks(Int_t nEvents        = 10000,
       tofTrackFinder->SetTxLIM(0.15);   // max slope dx/dz
       tofTrackFinder->SetTyLIM(0.18);   // max dev from mean slope dy/dz
       break;
-    case 2:  // for triple stack 012 counter evaluation
-      tofTrackFinder->SetTxMean(0.0);    // mean slope dx/dz
-      tofTrackFinder->SetTyMean(-0.03);  // mean slope dy/dz
-      tofTrackFinder->SetTxLIM(0.06);    // max slope dx/dz
-      tofTrackFinder->SetTyLIM(0.03);    // max dev from mean slope dy/dz
-      break;
+    case 2:                             // for triple stack 012 counter evaluation
+      tofTrackFinder->SetTxMean(0.0);  // mean slope dx/dz
+      tofTrackFinder->SetTyMean(-0.03);   // mean slope dy/dz
+      tofTrackFinder->SetTxLIM(0.06);  // max slope dx/dz
+      tofTrackFinder->SetTyLIM(0.03);  // max dev from mean slope dy/dz
+      break;      
   }
 
   CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211);
@@ -197,15 +197,14 @@ void ana_trks(Int_t nEvents        = 10000,
   tofFindTracks->SetCorMode(iGenCor);  // valid options: 0,1,2,3,4,5,6, 10 - 19
   //tofFindTracks->SetTtTarg(0.041);     // Mar19, Run 159
   //tofFindTracks->SetTtTarg(0.0605);  // target value for Mar2020 triple stack -> betapeak ~ 0.95
-  tofFindTracks->SetTtTarg(
-    0.062);  // target value for Mar2020 triple stack -> betapeak ~ 0.95
+  tofFindTracks->SetTtTarg(0.062);   // target value for Mar2020 triple stack -> betapeak ~ 0.95
   //tofFindTracks->SetTtTarg(0.058);   // target value for Mar2020 double stack
   //tofFindTracks->SetTtTarg(0.051);   // target value Nov2019
   //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(0.);             // for calibration
+  tofFindTracks->SetR0Lim(0.); // for calibration
   tofFindTracks->SetStationMaxHMul(
     30);  // Max Hit Multiplicity in any used station
 
@@ -213,13 +212,12 @@ void ana_trks(Int_t nEvents        = 10000,
   tofFindTracks->SetSIGT(0.08);       // default in ns
   tofFindTracks->SetSIGX(0.45);       // local-y default in cm
   tofFindTracks->SetSIGY(0.3);        // local-x default in cm
-  tofFindTracks->SetSIGZ(10.05);      // default in cm
+  tofFindTracks->SetSIGZ(10.05);       // default in cm
   tofFindTracks->SetUseSigCalib(
     bUseSigCalib);  // ignore resolutions in CalPar file
   tofTrackFinder->SetSIGLIM(dChi2Lim2
                             * 2.);  // matching window in multiples of chi2
-  tofTrackFinder->SetSIGLIMMOD(
-    1.5);  // search window modifier for last hit (DUT)
+  tofTrackFinder->SetSIGLIMMOD(1.5);   // search window modifier for last hit (DUT)
   tofTrackFinder->SetChiMaxAccept(dChi2Lim2);  // max tracklet chi2
 
   Int_t iMinNofHits   = -1;
@@ -350,8 +348,8 @@ void ana_trks(Int_t nEvents        = 10000,
       tofFindTracks->SetStation(2, 0, 0, 2);
       tofFindTracks->SetStation(3, 0, 1, 2);
       break;
-
-    case 14:  // for eval 012
+      
+    case 14:    // for eval 012
       iMinNofHits   = 3;
       iNStations    = 4;
       iNReqStations = 4;
@@ -360,8 +358,8 @@ void ana_trks(Int_t nEvents        = 10000,
       tofFindTracks->SetStation(1, 0, 0, 2);
       tofFindTracks->SetStation(2, 0, 1, 2);
       break;
-
-    case 24:  // for geometry tuning 012
+      
+    case 24:    // for geometry tuning 012
       iMinNofHits   = 3;
       iNStations    = 3;
       iNReqStations = 3;
diff --git a/macro/beamtime/mcbm2020/ana_digi_cal.C b/macro/beamtime/mcbm2020/ana_digi_cal.C
index 7599670f916122901040daa3d6525e94e0cc1de7..1219f114844a1d72f2ada448fa1db60f55aaa8fd 100644
--- a/macro/beamtime/mcbm2020/ana_digi_cal.C
+++ b/macro/beamtime/mcbm2020/ana_digi_cal.C
@@ -45,14 +45,14 @@ void ana_digi_cal(Int_t nEvents      = 10000000,
 
   TList* parFileList = new TList();
 
-  TString FId = cFileId;
+  TString FId    = cFileId;
   TString cRun(FId(0, 3));
-  Int_t iRun     = cRun.Atoi();
+  Int_t iRun = cRun.Atoi();
   TString TofGeo = "";
   if (iRun < 690)
     TofGeo = "v20a_mcbm";
   else
-    TofGeo = "v20b_mcbm";
+    TofGeo = "v20f_mcbm";
   cout << "Geometry version " << TofGeo << endl;
 
   //   TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file
@@ -98,7 +98,7 @@ void ana_digi_cal(Int_t nEvents      = 10000000,
   tofClust->SetTRefId(RefSel);  // reference trigger for offset calculation
   tofClust->SetTotMax(20.);     // Tot upper limit for walk corection
   tofClust->SetTotMin(
-    0.01);  //(12000.);  // Tot lower limit for walk correction
+    0.);  //(12000.);  // Tot lower limit for walk correction
   tofClust->SetTotPreRange(
     5.);  // effective lower Tot limit  in ns from peak position
   tofClust->SetTotMean(5.);       // Tot calibration target value in ns
diff --git a/macro/beamtime/mcbm2020/ana_digi_cal_all.C b/macro/beamtime/mcbm2020/ana_digi_cal_all.C
index b05009550666965955a3e923f6fb24e2105888a2..79c4cdb0ed62fa00dc7948f9dd9030f51467caca 100644
--- a/macro/beamtime/mcbm2020/ana_digi_cal_all.C
+++ b/macro/beamtime/mcbm2020/ana_digi_cal_all.C
@@ -45,14 +45,14 @@ void ana_digi_cal_all(Int_t nEvents      = 10000000,
 
   TList* parFileList = new TList();
 
-  TString FId = cFileId;
+  TString FId    = cFileId;
   TString cRun(FId(0, 3));
-  Int_t iRun     = cRun.Atoi();
+  Int_t iRun = cRun.Atoi();
   TString TofGeo = "";
   if (iRun < 690)
     TofGeo = "v20a_mcbm";
   else
-    TofGeo = "v20b_mcbm";
+    TofGeo = "v20f_mcbm";
   cout << "Geometry version " << TofGeo << endl;
 
   //   TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file
@@ -98,7 +98,7 @@ void ana_digi_cal_all(Int_t nEvents      = 10000000,
   tofClust->SetTRefId(RefSel);  // reference trigger for offset calculation
   tofClust->SetTotMax(20.);     // Tot upper limit for walk corection
   tofClust->SetTotMin(
-    0.01);  //(12000.);  // Tot lower limit for walk correction
+    0.);  //(12000.);  // Tot lower limit for walk correction
   tofClust->SetTotPreRange(
     5.);  // effective lower Tot limit  in ns from peak position
   tofClust->SetTotMean(5.);       // Tot calibration target value in ns
diff --git a/macro/beamtime/mcbm2020/ana_digi_cali.C b/macro/beamtime/mcbm2020/ana_digi_cali.C
index 7fca643c22993e1ab50d7708d083eb67f59a9f81..b3db3a279219579c30e229dd674d8a99f8bbe4c9 100644
--- a/macro/beamtime/mcbm2020/ana_digi_cali.C
+++ b/macro/beamtime/mcbm2020/ana_digi_cali.C
@@ -46,7 +46,7 @@ void ana_digi_cali(Int_t nEvents      = 10000000,
   TList* parFileList = new TList();
 
   TString FId    = cFileId;
-  TString TofGeo = "v20b_mcbm";
+  TString TofGeo = "v20f_mcbm";
   cout << "Geometry version " << TofGeo << endl;
 
   //   TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file
@@ -92,7 +92,7 @@ void ana_digi_cali(Int_t nEvents      = 10000000,
   tofClust->SetTRefId(RefSel);  // reference trigger for offset calculation
   tofClust->SetTotMax(20.);     // Tot upper limit for walk corection
   tofClust->SetTotMin(
-    0.01);  //(12000.);  // Tot lower limit for walk correction
+    0.);  //(12000.);  // Tot lower limit for walk correction
   tofClust->SetTotPreRange(
     5.);  // effective lower Tot limit  in ns from peak position
   tofClust->SetTotMean(5.);       // Tot calibration target value in ns
diff --git a/macro/beamtime/mcbm2020/ana_trks.C b/macro/beamtime/mcbm2020/ana_trks.C
index 57810219c5f23fd7c1850399b2c4583a0f058070..b753f165d361bbfc42b1adde03f2d48e22cd9845 100644
--- a/macro/beamtime/mcbm2020/ana_trks.C
+++ b/macro/beamtime/mcbm2020/ana_trks.C
@@ -698,6 +698,7 @@ void ana_trks(Int_t nEvents        = 10000,
   gROOT->LoadMacro("pl_Eff_DTLH.C");
   gROOT->LoadMacro("pl_Eff_TIS.C");
   gROOT->LoadMacro("pl_Dut_Res.C");
+  gROOT->LoadMacro("pl_Dut_Vel.C");
 
   TString SaveToHstFile = "save_hst(\"" + cHstFile + "\")";
   gInterpreter->ProcessLine(SaveToHstFile);
diff --git a/macro/beamtime/mcbm2020/ana_trksi.C b/macro/beamtime/mcbm2020/ana_trksi.C
index fa413a2e76d86948cc52f015b4eb79724b4249f3..00bca0062ccf03fce1de8b13e769411f4800bacc 100644
--- a/macro/beamtime/mcbm2020/ana_trksi.C
+++ b/macro/beamtime/mcbm2020/ana_trksi.C
@@ -268,7 +268,7 @@ void ana_trksi(Int_t nEvents        = 10000,
 
     case 2:
       iMinNofHits   = 3;
-      iNStations    = 28;
+      iNStations    = 27;
       iNReqStations = 4;
       tofFindTracks->SetStation(0, 0, 2, 2);
       tofFindTracks->SetStation(1, 0, 0, 2);
@@ -297,7 +297,7 @@ void ana_trksi(Int_t nEvents        = 10000,
       tofFindTracks->SetStation(24, 0, 3, 4);
       tofFindTracks->SetStation(25, 9, 0, 0);
       tofFindTracks->SetStation(26, 9, 0, 1);
-      tofFindTracks->SetStation(27, 5, 0, 0);
+      //tofFindTracks->SetStation(27, 5, 0, 0);
       break;
 
     case 3:
@@ -460,7 +460,7 @@ void ana_trksi(Int_t nEvents        = 10000,
   tofAnaTestbeam->SetHitDistMin(30.);   // initialization
   tofAnaTestbeam->SetEnableMatchPosScaling(kTRUE);
   tofAnaTestbeam->SetSpillDuration(3.);
-  tofAnaTestbeam->SetSpillTime(0.);
+  tofAnaTestbeam->SetStartSpillTime(-100.);
   if (iMc == 1) {
     tofAnaTestbeam->SetSpillDuration(0.);
     tofAnaTestbeam->SetSpillBreak(0.);
diff --git a/macro/beamtime/mcbm2020/dis_digi.C b/macro/beamtime/mcbm2020/dis_digi.C
index 78a81ea032450257fadf075dbd43f739407cc9ba..81054c61396a7f355008f167b9e07540a80a6afb 100644
--- a/macro/beamtime/mcbm2020/dis_digi.C
+++ b/macro/beamtime/mcbm2020/dis_digi.C
@@ -15,14 +15,14 @@ void dis_digi(Int_t nEvents        = 100,
               TString cCalId       = "XXX",
               Bool_t bUseSigCalib  = kFALSE,
               Int_t iCalOpt        = 1) {
-
+  
   Int_t iVerbose = 1;
   if (cCalId == "") cCalId = cFileId;
   TString FId = cFileId;
   TString cRun(FId(0, 3));
   Int_t iRun = cRun.Atoi();
   cout << "dis_digi for Run " << iRun << endl;
-
+  
   //Specify log level (INFO, DEBUG, DEBUG1, ...)
   //TString logLevel = "FATAL";
   //TString logLevel = "ERROR";
@@ -56,22 +56,22 @@ void dis_digi(Int_t nEvents        = 100,
 
   TString shcmd = "rm -v " + ParFile;
   gSystem->Exec(shcmd.Data());
-
+  
   Int_t iGeo = 0;  //iMc;
   if (iGeo == 0) {
     TString TofGeo = "";
     if (iRun < 690)
       TofGeo = "v20a_mcbm";
     else
-      TofGeo = "v20b_mcbm";
+      TofGeo = "v20f_mcbm";
     cout << "Geometry version " << TofGeo << endl;
-    /*  
+/*  
     TObjString* tofDigiFile = new TObjString(
       workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par");  // TOF digi file
     parFileList->Add(tofDigiFile);
 */
-    TObjString* tofDigiBdfFile = new TObjString(workDir + "/parameters/tof/tof_"
-                                                + TofGeo + ".digibdf.par");
+    TObjString* tofDigiBdfFile =
+      new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digibdf.par");
     parFileList->Add(tofDigiBdfFile);
 
     TString geoDir  = gSystem->Getenv("VMCWORKDIR");
@@ -89,7 +89,7 @@ void dis_digi(Int_t nEvents        = 100,
       master->Draw("ogl");
     }
   }
-
+  
   // Local steering variables
   Int_t iBRef    = iCalSet % 1000;
   Int_t iSet     = (iCalSet - iBRef) / 1000;
@@ -329,153 +329,154 @@ void dis_digi(Int_t nEvents        = 100,
   // =========================================================================
 
   CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN();
-  tofTrackFinder->SetMaxTofTimeDifference(0.4);  // in ns/cm
-  Int_t TrackerPar = 0;
-  switch (TrackerPar) {
-    case 0:                           // for full mTof setup
-      tofTrackFinder->SetTxLIM(0.3);  // max slope dx/dz
-      tofTrackFinder->SetTyLIM(0.3);  // max dev from mean slope dy/dz
-      tofTrackFinder->SetTxMean(0.);  // mean slope dy/dz
-      tofTrackFinder->SetTyMean(0.);  // mean slope dy/dz
-      break;
-    case 1:                             // for double stack test counters
-      tofTrackFinder->SetTxMean(0.21);  // mean slope dy/dz
-      tofTrackFinder->SetTyMean(0.18);  // mean slope dy/dz
-      tofTrackFinder->SetTxLIM(0.15);   // max slope dx/dz
-      tofTrackFinder->SetTyLIM(0.18);   // max dev from mean slope dy/dz
-      break;
-  }
-
-  CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211);
-  TFitter* MyFit                    = new TFitter(1);  // initialize Minuit
-  tofTrackFinder->SetFitter(tofTrackFitter);
-  CbmTofFindTracks* tofFindTracks = new CbmTofFindTracks("TOF Track Finder");
-  tofFindTracks->UseFinder(tofTrackFinder);
-  tofFindTracks->UseFitter(tofTrackFitter);
-  tofFindTracks->SetCalOpt(
-    iCalOpt);  // 1 - update offsets, 2 - update walk, 0 - bypass
-  tofFindTracks->SetCorMode(iGenCor);  // valid options: 0,1,2,3,4,5,6, 10 - 19
-  tofFindTracks->SetTtTarg(
-    0.057);  // target value for inverse velocity, > 0.033 ns/cm!
-  //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(100.);
-
-  tofFindTracks->SetStationMaxHMul(
-    30);  // Max Hit Multiplicity in any used station
-
-  tofFindTracks->SetT0MAX(dScalFac);  // in ns
-  tofFindTracks->SetSIGT(0.08);       // default in ns
-  tofFindTracks->SetSIGX(0.3);        // default in cm
-  tofFindTracks->SetSIGY(0.6);        // default in cm
-  tofFindTracks->SetSIGZ(0.05);       // default in cm
-  tofFindTracks->SetUseSigCalib(
-    bUseSigCalib);  // ignore resolutions in CalPar file
-  tofTrackFinder->SetSIGLIM(dChi2Lim2
-                            * 2.);  // matching window in multiples of chi2
-  tofTrackFinder->SetChiMaxAccept(dChi2Lim2);  // max tracklet chi2
-
-
-  Int_t iMinNofHits   = -1;
-  Int_t iNStations    = 0;
-  Int_t iNReqStations = 3;
-
-  switch (iTrackingSetup) {
-    case 0:  // bypass mode
-      iMinNofHits = -1;
-      iNStations  = 1;
-      tofFindTracks->SetStation(0, 5, 0, 0);  // Diamond
-      break;
-
-    case 1:  // for calibration mode of full setup
-    {
-      Double_t dTsig = dScalFac * 0.03;
-      tofFindTracks->SetSIGT(dTsig);  // allow for variable deviations in ns
+    tofTrackFinder->SetMaxTofTimeDifference(0.4);  // in ns/cm
+    Int_t TrackerPar = 0;
+    switch (TrackerPar) {
+      case 0:                           // for full mTof setup
+        tofTrackFinder->SetTxLIM(0.3);  // max slope dx/dz
+        tofTrackFinder->SetTyLIM(0.3);  // max dev from mean slope dy/dz
+        tofTrackFinder->SetTxMean(0.);  // mean slope dy/dz
+        tofTrackFinder->SetTyMean(0.);  // mean slope dy/dz
+        break;
+      case 1:                             // for double stack test counters
+        tofTrackFinder->SetTxMean(0.21);  // mean slope dy/dz
+        tofTrackFinder->SetTyMean(0.18);  // mean slope dy/dz
+        tofTrackFinder->SetTxLIM(0.15);   // max slope dx/dz
+        tofTrackFinder->SetTyLIM(0.18);   // max dev from mean slope dy/dz
+        break;
     }
-      iMinNofHits   = 3;
-      iNStations    = 28;
-      iNReqStations = 4;
-      tofFindTracks->SetStation(0, 5, 0, 0);
-      tofFindTracks->SetStation(1, 0, 2, 2);
-      tofFindTracks->SetStation(2, 0, 1, 2);
-      tofFindTracks->SetStation(3, 0, 0, 2);
-      tofFindTracks->SetStation(4, 0, 2, 1);
-      tofFindTracks->SetStation(5, 0, 1, 1);
-      tofFindTracks->SetStation(6, 0, 0, 1);
-      tofFindTracks->SetStation(7, 0, 2, 3);
-      tofFindTracks->SetStation(8, 0, 1, 3);
-      tofFindTracks->SetStation(9, 0, 0, 3);
-      tofFindTracks->SetStation(10, 0, 2, 0);
-      tofFindTracks->SetStation(11, 0, 1, 0);
-      tofFindTracks->SetStation(12, 0, 0, 0);
-      tofFindTracks->SetStation(13, 0, 2, 4);
-      tofFindTracks->SetStation(14, 0, 1, 4);
-      tofFindTracks->SetStation(15, 0, 0, 4);
-      tofFindTracks->SetStation(16, 0, 4, 0);
-      tofFindTracks->SetStation(17, 0, 3, 0);
-      tofFindTracks->SetStation(18, 0, 4, 1);
-      tofFindTracks->SetStation(19, 0, 3, 1);
-      tofFindTracks->SetStation(20, 0, 4, 2);
-      tofFindTracks->SetStation(21, 0, 3, 2);
-      tofFindTracks->SetStation(22, 0, 4, 3);
-      tofFindTracks->SetStation(23, 0, 3, 3);
-      tofFindTracks->SetStation(24, 0, 4, 4);
-      tofFindTracks->SetStation(25, 0, 3, 4);
-      tofFindTracks->SetStation(26, 9, 0, 0);
-      tofFindTracks->SetStation(27, 9, 0, 1);
-      //tofFindTracks->SetStation(28, 6, 0, 0);
-      //tofFindTracks->SetStation(29, 6, 0, 1);
-      break;
 
-    case 2:
-      iMinNofHits   = 3;
-      iNStations    = 14;
-      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, 0);
-      tofFindTracks->SetStation(5, 0, 4, 2);
-      tofFindTracks->SetStation(6, 0, 3, 2);
-      tofFindTracks->SetStation(7, 0, 4, 3);
-      tofFindTracks->SetStation(8, 0, 3, 3);
-      tofFindTracks->SetStation(9, 0, 4, 4);
-      tofFindTracks->SetStation(10, 0, 3, 4);
-      tofFindTracks->SetStation(11, 9, 0, 0);
-      tofFindTracks->SetStation(12, 9, 0, 1);
-      tofFindTracks->SetStation(13, 7, 0, 0);
-      break;
-
-    case 3:
-      iMinNofHits   = 3;
-      iNStations    = 16;
-      iNReqStations = 4;
-
-      tofFindTracks->SetStation(0, 0, 2, 2);
-      tofFindTracks->SetStation(1, 0, 1, 2);
-      tofFindTracks->SetStation(2, 0, 0, 2);
-
-      tofFindTracks->SetStation(3, 0, 2, 1);
-      tofFindTracks->SetStation(4, 0, 1, 1);
-      tofFindTracks->SetStation(5, 0, 0, 1);
-
-      tofFindTracks->SetStation(6, 0, 2, 3);
-      tofFindTracks->SetStation(7, 0, 1, 3);
-      tofFindTracks->SetStation(8, 0, 0, 3);
-
-      tofFindTracks->SetStation(9, 0, 2, 0);
-      tofFindTracks->SetStation(10, 0, 1, 0);
-      tofFindTracks->SetStation(11, 0, 0, 0);
-
-      tofFindTracks->SetStation(12, 0, 2, 4);
-      tofFindTracks->SetStation(13, 0, 1, 4);
-      tofFindTracks->SetStation(14, 0, 0, 4);
-
-      tofFindTracks->SetStation(15, 5, 0, 0);
-      /*
+    CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211);
+    TFitter* MyFit                    = new TFitter(1);  // initialize Minuit
+    tofTrackFinder->SetFitter(tofTrackFitter);
+    CbmTofFindTracks* tofFindTracks = new CbmTofFindTracks("TOF Track Finder");
+    tofFindTracks->UseFinder(tofTrackFinder);
+    tofFindTracks->UseFitter(tofTrackFitter);
+    tofFindTracks->SetCalOpt(
+      iCalOpt);  // 1 - update offsets, 2 - update walk, 0 - bypass
+    tofFindTracks->SetCorMode(
+      iGenCor);  // valid options: 0,1,2,3,4,5,6, 10 - 19
+    tofFindTracks->SetTtTarg(
+      0.057);  // target value for inverse velocity, > 0.033 ns/cm!
+    //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(100.);
+
+    tofFindTracks->SetStationMaxHMul(
+      30);  // Max Hit Multiplicity in any used station
+
+    tofFindTracks->SetT0MAX(dScalFac);  // in ns
+    tofFindTracks->SetSIGT(0.08);       // default in ns
+    tofFindTracks->SetSIGX(0.3);        // default in cm
+    tofFindTracks->SetSIGY(0.6);        // default in cm
+    tofFindTracks->SetSIGZ(0.05);       // default in cm
+    tofFindTracks->SetUseSigCalib(
+      bUseSigCalib);  // ignore resolutions in CalPar file
+    tofTrackFinder->SetSIGLIM(dChi2Lim2
+                              * 2.);  // matching window in multiples of chi2
+    tofTrackFinder->SetChiMaxAccept(dChi2Lim2);  // max tracklet chi2
+
+
+    Int_t iMinNofHits   = -1;
+    Int_t iNStations    = 0;
+    Int_t iNReqStations = 3;
+
+    switch (iTrackingSetup) {
+      case 0:  // bypass mode
+        iMinNofHits = -1;
+        iNStations  = 1;
+        tofFindTracks->SetStation(0, 5, 0, 0);  // Diamond
+        break;
+
+      case 1:  // for calibration mode of full setup
+      {
+        Double_t dTsig = dScalFac * 0.03;
+        tofFindTracks->SetSIGT(dTsig);  // allow for variable deviations in ns
+      }
+        iMinNofHits   = 3;
+        iNStations    = 28;
+        iNReqStations = 4;
+        tofFindTracks->SetStation(0, 5, 0, 0);
+        tofFindTracks->SetStation(1, 0, 2, 2);
+        tofFindTracks->SetStation(2, 0, 1, 2);
+        tofFindTracks->SetStation(3, 0, 0, 2);
+        tofFindTracks->SetStation(4, 0, 2, 1);
+        tofFindTracks->SetStation(5, 0, 1, 1);
+        tofFindTracks->SetStation(6, 0, 0, 1);
+        tofFindTracks->SetStation(7, 0, 2, 3);
+        tofFindTracks->SetStation(8, 0, 1, 3);
+        tofFindTracks->SetStation(9, 0, 0, 3);
+        tofFindTracks->SetStation(10, 0, 2, 0);
+        tofFindTracks->SetStation(11, 0, 1, 0);
+        tofFindTracks->SetStation(12, 0, 0, 0);
+        tofFindTracks->SetStation(13, 0, 2, 4);
+        tofFindTracks->SetStation(14, 0, 1, 4);
+        tofFindTracks->SetStation(15, 0, 0, 4);
+        tofFindTracks->SetStation(16, 0, 4, 0);
+        tofFindTracks->SetStation(17, 0, 3, 0);
+        tofFindTracks->SetStation(18, 0, 4, 1);
+        tofFindTracks->SetStation(19, 0, 3, 1);
+        tofFindTracks->SetStation(20, 0, 4, 2);
+        tofFindTracks->SetStation(21, 0, 3, 2);
+        tofFindTracks->SetStation(22, 0, 4, 3);
+        tofFindTracks->SetStation(23, 0, 3, 3);
+        tofFindTracks->SetStation(24, 0, 4, 4);
+        tofFindTracks->SetStation(25, 0, 3, 4);
+        tofFindTracks->SetStation(26, 9, 0, 0);
+        tofFindTracks->SetStation(27, 9, 0, 1);
+        //tofFindTracks->SetStation(28, 6, 0, 0);
+        //tofFindTracks->SetStation(29, 6, 0, 1);
+        break;
+
+      case 2:
+        iMinNofHits   = 3;
+        iNStations    = 14;
+        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, 0);
+        tofFindTracks->SetStation(5, 0, 4, 2);
+        tofFindTracks->SetStation(6, 0, 3, 2);
+        tofFindTracks->SetStation(7, 0, 4, 3);
+        tofFindTracks->SetStation(8, 0, 3, 3);
+        tofFindTracks->SetStation(9, 0, 4, 4);
+        tofFindTracks->SetStation(10, 0, 3, 4);
+        tofFindTracks->SetStation(11, 9, 0, 0);
+        tofFindTracks->SetStation(12, 9, 0, 1);
+        tofFindTracks->SetStation(13, 7, 0, 0);
+        break;
+
+      case 3:
+        iMinNofHits   = 3;
+        iNStations    = 16;
+        iNReqStations = 4;
+        
+		tofFindTracks->SetStation(0, 0, 2, 2);
+		tofFindTracks->SetStation(1, 0, 1, 2);
+		tofFindTracks->SetStation(2, 0, 0, 2);
+
+		tofFindTracks->SetStation(3, 0, 2, 1);
+		tofFindTracks->SetStation(4, 0, 1, 1);
+		tofFindTracks->SetStation(5, 0, 0, 1);
+
+		tofFindTracks->SetStation(6, 0, 2, 3);
+		tofFindTracks->SetStation(7, 0, 1, 3);
+		tofFindTracks->SetStation(8, 0, 0, 3);
+
+		tofFindTracks->SetStation(9,  0, 2, 0);
+		tofFindTracks->SetStation(10, 0, 1, 0);
+		tofFindTracks->SetStation(11, 0, 0, 0);
+
+		tofFindTracks->SetStation(12, 0, 2, 4);
+		tofFindTracks->SetStation(13, 0, 1, 4);
+		tofFindTracks->SetStation(14, 0, 0, 4);
+
+		tofFindTracks->SetStation(15, 5, 0, 0);
+        /*
      tofFindTracks->SetStation(16, 0, 3, 2);         
      tofFindTracks->SetStation(17, 0, 4, 2);  
      tofFindTracks->SetStation(18, 0, 3, 1);         
@@ -487,87 +488,87 @@ void dis_digi(Int_t nEvents        = 100,
      tofFindTracks->SetStation(24, 0, 3, 4);         
      tofFindTracks->SetStation(25, 0, 4, 4); 
      */
-      break;
-
-    case 4:
-      iMinNofHits   = 3;
-      iNStations    = 4;
-      iNReqStations = 4;
-      tofFindTracks->SetStation(0, 5, 0, 0);
-      tofFindTracks->SetStation(1, 0, 4, 1);
-      tofFindTracks->SetStation(2, 0, 3, 1);
-      tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc);
-      break;
-
-    case 5:  // for calibration of 2-stack and add-on counters (STAR2, BUC)
-      iMinNofHits   = 3;
-      iNStations    = 5;
-      iNReqStations = 4;
-      tofFindTracks->SetStation(0, 5, 0, 0);
-      tofFindTracks->SetStation(1, 0, 4, 1);
-      tofFindTracks->SetStation(2, 0, 3, 1);
-      tofFindTracks->SetStation(3, 9, 0, 0);
-      tofFindTracks->SetStation(4, 9, 0, 1);
-      break;
+        break;
+
+      case 4:
+        iMinNofHits   = 3;
+        iNStations    = 4;
+        iNReqStations = 4;
+        tofFindTracks->SetStation(0, 5, 0, 0);
+        tofFindTracks->SetStation(1, 0, 4, 1);
+        tofFindTracks->SetStation(2, 0, 3, 1);
+        tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc);
+        break;
+
+      case 5:  // for calibration of 2-stack and add-on counters (STAR2, BUC)
+        iMinNofHits   = 3;
+        iNStations    = 5;
+        iNReqStations = 4;
+        tofFindTracks->SetStation(0, 5, 0, 0);
+        tofFindTracks->SetStation(1, 0, 4, 1);
+        tofFindTracks->SetStation(2, 0, 3, 1);
+        tofFindTracks->SetStation(3, 9, 0, 0);
+        tofFindTracks->SetStation(4, 9, 0, 1);
+        break;
+
+      case 6:
+        iMinNofHits   = 3;
+        iNStations    = 4;
+        iNReqStations = 4;
+        tofFindTracks->SetStation(0, 5, 0, 0);
+        tofFindTracks->SetStation(1, 0, 4, 1);
+        tofFindTracks->SetStation(2, 0, 3, 1);
+        tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc);
+        //    tofFindTracks->SetStation(3, 9, 0, 0);
+        //    tofFindTracks->SetStation(3, 9, 0, 1);
+        //    tofFindTracks->SetStation(3, 7, 0, 0);
+        break;
+
+      case 7:  // for calibration of 2-stack and add-on counters (BUC)
+        iMinNofHits   = 4;
+        iNStations    = 5;
+        iNReqStations = 5;
+        tofFindTracks->SetStation(0, 5, 0, 0);
+        tofFindTracks->SetStation(1, 0, 4, 3);
+        tofFindTracks->SetStation(2, 0, 3, 3);
+        tofFindTracks->SetStation(3, 6, 0, 0);
+        tofFindTracks->SetStation(4, 6, 0, 1);
+        break;
+
+      case 8:  // evaluation of add-on counters (BUC)
+        iMinNofHits   = 3;
+        iNStations    = 4;
+        iNReqStations = 4;
+        tofFindTracks->SetStation(0, 5, 0, 0);
+        tofFindTracks->SetStation(1, 0, 4, 3);
+        tofFindTracks->SetStation(2, 0, 3, 3);
+        tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc);
+        break;
+
+      case 10:
+        iMinNofHits   = 3;
+        iNStations    = 4;
+        iNReqStations = 4;
+        tofFindTracks->SetStation(0, 5, 0, 0);
+        tofFindTracks->SetStation(1, 0, 1, 2);
+        tofFindTracks->SetStation(2, 0, 0, 2);
+        tofFindTracks->SetStation(3, 0, 2, 2);
 
-    case 6:
-      iMinNofHits   = 3;
-      iNStations    = 4;
-      iNReqStations = 4;
-      tofFindTracks->SetStation(0, 5, 0, 0);
-      tofFindTracks->SetStation(1, 0, 4, 1);
-      tofFindTracks->SetStation(2, 0, 3, 1);
-      tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc);
-      //    tofFindTracks->SetStation(3, 9, 0, 0);
-      //    tofFindTracks->SetStation(3, 9, 0, 1);
-      //    tofFindTracks->SetStation(3, 7, 0, 0);
-      break;
-
-    case 7:  // for calibration of 2-stack and add-on counters (BUC)
-      iMinNofHits   = 4;
-      iNStations    = 5;
-      iNReqStations = 5;
-      tofFindTracks->SetStation(0, 5, 0, 0);
-      tofFindTracks->SetStation(1, 0, 4, 3);
-      tofFindTracks->SetStation(2, 0, 3, 3);
-      tofFindTracks->SetStation(3, 6, 0, 0);
-      tofFindTracks->SetStation(4, 6, 0, 1);
-      break;
-
-    case 8:  // evaluation of add-on counters (BUC)
-      iMinNofHits   = 3;
-      iNStations    = 4;
-      iNReqStations = 4;
-      tofFindTracks->SetStation(0, 5, 0, 0);
-      tofFindTracks->SetStation(1, 0, 4, 3);
-      tofFindTracks->SetStation(2, 0, 3, 3);
-      tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc);
-      break;
-
-    case 10:
-      iMinNofHits   = 3;
-      iNStations    = 4;
-      iNReqStations = 4;
-      tofFindTracks->SetStation(0, 5, 0, 0);
-      tofFindTracks->SetStation(1, 0, 1, 2);
-      tofFindTracks->SetStation(2, 0, 0, 2);
-      tofFindTracks->SetStation(3, 0, 2, 2);
-
-    default:
-      cout << "Tracking setup " << iTrackingSetup << " not implemented "
-           << endl;
-      return;
-      ;
-  }
-  tofFindTracks->SetMinNofHits(iMinNofHits);
-  tofFindTracks->SetNStations(iNStations);
-  tofFindTracks->SetNReqStations(iNReqStations);
-  tofFindTracks->PrintSetup();
-  run->AddTask(tofFindTracks);
-
-  // =========================================================================
-  // ===                       Analysis                                    ===
-  // =========================================================================
+      default:
+        cout << "Tracking setup " << iTrackingSetup << " not implemented "
+             << endl;
+        return;
+        ;
+    }
+    tofFindTracks->SetMinNofHits(iMinNofHits);
+    tofFindTracks->SetNStations(iNStations);
+    tofFindTracks->SetNReqStations(iNReqStations);
+    tofFindTracks->PrintSetup();
+    run->AddTask(tofFindTracks);
+
+    // =========================================================================
+    // ===                       Analysis                                    ===
+    // =========================================================================
 
   CbmTofAnaTestbeam* tofAnaTestbeam =
     new CbmTofAnaTestbeam("TOF TestBeam Analysis", iVerbose);
diff --git a/macro/beamtime/mcbm2020/dis_trks.C b/macro/beamtime/mcbm2020/dis_trks.C
index 789a07a96228ab7b451f2361642b6b0bd048231b..76c9a2f128a8319a04d2a7c9feedd8ec8c034180 100644
--- a/macro/beamtime/mcbm2020/dis_trks.C
+++ b/macro/beamtime/mcbm2020/dis_trks.C
@@ -48,16 +48,16 @@ void dis_trks(Int_t nEvents        = 10,
   TString cHstFile =
     paramDir
     + Form(
-      "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Dis.hst.root",
-      cFileId.Data(),
-      dDeadtime,
-      cSet.Data(),
-      iSel,
-      iSel2,
-      dScalFac,
-      dChi2Lim2,
-      iTrackingSetup,
-      cCalId.Data());
+        "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Dis.hst.root",
+        cFileId.Data(),
+        dDeadtime,
+        cSet.Data(),
+        iSel,
+        iSel2,
+        dScalFac,
+        dChi2Lim2,
+        iTrackingSetup,
+        cCalId.Data());
   TString cTrkFile = Form("%s_tofFindTracks.hst.root", cCalId.Data());
   TString cAnaFile = Form("%s_TrkAnaTestBeam.hst.root", cCalId.Data());
 
@@ -74,7 +74,7 @@ void dis_trks(Int_t nEvents        = 10,
     if (iRun < 690)
       TofGeo = "v20a_mcbm";
     else
-      TofGeo = "v20b_mcbm";
+      TofGeo = "v20f_mcbm";
     cout << "Geometry version " << TofGeo << endl;
 
     // -----   Load the geometry setup   -------------------------------------
@@ -101,8 +101,8 @@ void dis_trks(Int_t nEvents        = 10,
     //TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file
     //parFileList->Add(tofDigiFile);
 
-    TObjString* tofDigiBdfFile = new TObjString(workDir + "/parameters/tof/tof_"
-                                                + TofGeo + ".digibdf.par");
+    TObjString* tofDigiBdfFile =
+      new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digibdf.par");
     parFileList->Add(tofDigiBdfFile);
 
     // -----   Reconstruction run   -------------------------------------------
@@ -293,28 +293,28 @@ void dis_trks(Int_t nEvents        = 10,
         iMinNofHits   = 3;
         iNStations    = 16;
         iNReqStations = 4;
+        
+		tofFindTracks->SetStation(0, 0, 2, 2);
+		tofFindTracks->SetStation(1, 0, 1, 2);
+		tofFindTracks->SetStation(2, 0, 0, 2);
 
-        tofFindTracks->SetStation(0, 0, 2, 2);
-        tofFindTracks->SetStation(1, 0, 1, 2);
-        tofFindTracks->SetStation(2, 0, 0, 2);
-
-        tofFindTracks->SetStation(3, 0, 2, 1);
-        tofFindTracks->SetStation(4, 0, 1, 1);
-        tofFindTracks->SetStation(5, 0, 0, 1);
+		tofFindTracks->SetStation(3, 0, 2, 1);
+		tofFindTracks->SetStation(4, 0, 1, 1);
+		tofFindTracks->SetStation(5, 0, 0, 1);
 
-        tofFindTracks->SetStation(6, 0, 2, 3);
-        tofFindTracks->SetStation(7, 0, 1, 3);
-        tofFindTracks->SetStation(8, 0, 0, 3);
+		tofFindTracks->SetStation(6, 0, 2, 3);
+		tofFindTracks->SetStation(7, 0, 1, 3);
+		tofFindTracks->SetStation(8, 0, 0, 3);
 
-        tofFindTracks->SetStation(9, 0, 2, 0);
-        tofFindTracks->SetStation(10, 0, 1, 0);
-        tofFindTracks->SetStation(11, 0, 0, 0);
+		tofFindTracks->SetStation(9,  0, 2, 0);
+		tofFindTracks->SetStation(10, 0, 1, 0);
+		tofFindTracks->SetStation(11, 0, 0, 0);
 
-        tofFindTracks->SetStation(12, 0, 2, 4);
-        tofFindTracks->SetStation(13, 0, 1, 4);
-        tofFindTracks->SetStation(14, 0, 0, 4);
+		tofFindTracks->SetStation(12, 0, 2, 4);
+		tofFindTracks->SetStation(13, 0, 1, 4);
+		tofFindTracks->SetStation(14, 0, 0, 4);
 
-        tofFindTracks->SetStation(15, 5, 0, 0);
+		tofFindTracks->SetStation(15, 5, 0, 0);
         /*
      tofFindTracks->SetStation(16, 0, 3, 2);         
      tofFindTracks->SetStation(17, 0, 4, 2);  
diff --git a/macro/beamtime/mcbm2020/gen_digi.sh b/macro/beamtime/mcbm2020/gen_digi.sh
index ef35f88b69ed7839b20f0af20d6d47894ac0bdf6..de025f82f5e3fbc78e69904653405711861cf2cc 100755
--- a/macro/beamtime/mcbm2020/gen_digi.sh
+++ b/macro/beamtime/mcbm2020/gen_digi.sh
@@ -60,6 +60,12 @@ else
     CalFile=${CalIdMode}_set${CalIdSet}_93_1tofClust.hst.root    
 fi
 
+Nevt=$7
+if [[ ${Nevt} = "" ]]; then
+    echo use all events
+    Nevt=-1
+fi
+
 echo gen_digi for $cRun with iDut=$iDut, iRef=$iRef, iSet=$iCalSet, iSel2=$iSel2, iBRef=$iBRef, Deadtime=$Deadtime, CalFile=$CalFile
 
 if [ -e /lustre/cbm ]; then
@@ -78,7 +84,7 @@ cp    ../.rootrc .
 cp    ../rootlogon.C .
 cp -v ../${CalFile}  .
 #root -b -q '../ana_digi_cal.C(100000,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") '
-root -b -q '../ana_digi_cal.C(-1,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'") '
 #root -b -q '../ana_digi_cos.C(-1,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") '
 #root -b -q '../ana_digi_star.C(-1,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") '
 
diff --git a/macro/beamtime/mcbm2020/init_cal_all.sh b/macro/beamtime/mcbm2020/init_cal_all.sh
index a7bebd05e55afd637d4350e161d28c730730ab09..a43948b01cd66532eca9c4cee5ff79fb7668830d 100755
--- a/macro/beamtime/mcbm2020/init_cal_all.sh
+++ b/macro/beamtime/mcbm2020/init_cal_all.sh
@@ -57,7 +57,7 @@ cd ${cRun}
 
 # Global variables, for for-loops
 iRestart=0
-#iRestart=25
+#iRestart=29
 iStep=0
 iStepLast=0
 iCalSel0=0
diff --git a/macro/beamtime/mcbm2020/iter_tracks.sh b/macro/beamtime/mcbm2020/iter_tracks.sh
index 3a37e3a5c0e2cdd200cda595462697d4c193e62d..e8ca6abaa707cc5aa070d6346cebb99fb5cde01a 100755
--- a/macro/beamtime/mcbm2020/iter_tracks.sh
+++ b/macro/beamtime/mcbm2020/iter_tracks.sh
@@ -81,7 +81,7 @@ cp ../.rootrc .
 cp ../rootlogon.C .
 
 # clean directory for start from scratch
-# rm -v ${cRun}_tofFindTracks.hst.root
+rm -v ${cRun}_tofFindTracks.hst.root
 rm -v TCalib.res
 
 if [[ $iter > 0 ]]; then
diff --git a/macro/beamtime/mcbm2020/trk_cal_digi.sh b/macro/beamtime/mcbm2020/trk_cal_digi.sh
index ffe80098845e22f87f8b7bdbdc087a98bb4e3267..6f22c3bafbd390fbe43feb17aafffbce398ab556 100755
--- a/macro/beamtime/mcbm2020/trk_cal_digi.sh
+++ b/macro/beamtime/mcbm2020/trk_cal_digi.sh
@@ -85,13 +85,14 @@ echo trk_cal_digi for $cRun with iDut=$iDut, iRef=$iRef, iSet=$iCalSet, iSel2=$i
 
 if [[ $iShLev = "" ]]; then 
   iShLev=0
-  nEvt=200000
+  nEvt=20000
   dDTres=100000
   dDTRMSres=100000
+  dL0DTRMSres=100000
+else
+ (( iShLev += 1 ))  
 fi 
 
-echo execute trk_cal_digi at shell level $iShLev
-
 if [ -e /lustre/cbm ]; then
 source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh 
 wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020
@@ -109,7 +110,7 @@ cd    $cRun
 cp    ../.rootrc .
 cp    ../rootlogon.C .
 
-echo Execute in `pwd` at $iShLev: ./trk_cal_digi.sh $1 $2 $3 $4 $5 $6 $7 $8
+echo Execute in `pwd` at shell level $iShLev: ./trk_cal_digi.sh $1 $2 $3 $4 $5 $6 $7 $8
 
 # get initial digi calibration 
 #cp -v  ./I*/${CalFile}  .
@@ -127,7 +128,7 @@ fRange1=2.
 fRange2=4.0
 TRange2Limit=3. 
 
-iSel=901041
+iSel=900041
 iGenCor=3
 cCalSet2=${cCalSet}_$cSel2
 
@@ -139,8 +140,9 @@ case $iCalOpt in
   (( nEvtMax *= 10 ))
   ;;
 esac
-
-while [[ $dDTres > 0 ]]; do
+  
+iIter=0
+while [[ $dDTres -gt 0 ]]; do
   nEvt=`echo "scale=0;$nEvt * 1./1." | bc`
   #nEvt=`echo "scale=0;$nEvt * 1.1/1." | bc`
   if [ $nEvt -gt $nEvtMax ]; then
@@ -154,11 +156,11 @@ while [[ $dDTres > 0 ]]; do
   fi
   
   iCalAct=$iCalOpt
-  iIter=0
-  echo Enter while loop with CalAct $iCalAct in dir `pwd`
+  echo Enter while loop with Iter $iIter, CalAct $iCalAct in dir `pwd`
+
   while [[ $iCalAct -gt 0 ]]; do  
     cd $wdir/$cRun
-    echo Current loop with CalAct $iCalAct and CalOpt $iCalOpt
+    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'") '
       # update calibration parameter file, will only be active in next iteration 
@@ -173,26 +175,26 @@ while [[ $dDTres > 0 ]]; do
   
         cp -v New_${CalFile} ${CalFile}  
       fi
+      (( iIter   += 1 ))
     else 
       cd $wdir
       # store current status 
       dLDTres=$dDTres
       dLDTRMSres=$dDTRMSres
       iLCalOpt=$iCalOpt
-      echo Store limits $dLDTres, $dLDTRMSres
-      (( iShLev += 1 ))
-      echo exec in `pwd` at level $iShLev: trk_cal_digi $1 $2 $3 $4 $5 1 $7
+      echo Store $iIter limits $dLDTres, $dLDTRMSres
+      echo exec in `pwd` at iter $iIter, level $iShLev: trk_cal_digi $1 $2 $3 $4 $5 1 $7
       trk_cal_digi $1 $2 $3 $4 $5 1 $7
-      (( iShLev -= 1 ))
       # restore old status
+      dL0DTRMSres=$dDTRMSres
+      dLDTRMSres=50000  # prepare for next round 
       dDTres=$dLDTres
       dDTRMSres=$dLDTRMSres
       iCalOpt=$iLCalOpt
-      echo exec1done, resume old CalOpt $iCalOpt with status $dDTres, $dDTRMSres
+      echo exec1done at $iIter, $iShLev resume old CalOpt $iCalOpt with limits $dDTres, $dDTRMSres, $dL0DTRMSres
     fi
     (( iCalAct -= 1 ))
-    (( iIter   += 1 ))
-    echo Continue while loop with CalAct $iCalAct and CalOpt $iCalOpt
+    echo Continue while loop with Iter $iIter, ShLev $iShLev, CalAct $iCalAct and CalOpt $iCalOpt
   done
   
   cd $wdir/$cRun
@@ -202,13 +204,18 @@ while [[ $dDTres > 0 ]]; do
   if [[ $Tres = 0 ]]; then
     Tres=1
   fi
+  
+  if [[ $dDTRMSres -eq 50000 ]]; then 
+    TRMSres=1000
+  fi
+  
   dTdif=`echo "$dDTres - $Tres" | bc`
   compare_result=`echo "$Tres < $dDTres" | bc`
 
   dTRMSdif=`echo "$dDTRMSres - $TRMSres" | bc`
   compare_RMS=`echo "$TRMSres < $dDTRMSres" | bc`
 
-  echo at iter=$iter got TOff = $Tres, compare to $dDTres, dTdif = $dTdif, result = $compare_result, TRMS = $TRMSres, old $dDTRMSres, dif = $dTRMSdif, result = $compare_RMS 
+  echo At iter=$iter, ShLev=$iShLev got TOff = $Tres, compare to $dDTres, dTdif = $dTdif, result = $compare_result, TRMS = $TRMSres, old $dDTRMSres, dif = $dTRMSdif, result = $compare_RMS 
 
   ((compare_result += $compare_RMS))
   echo CMPR result_summary: $compare_result 
@@ -223,25 +230,28 @@ while [[ $dDTres > 0 ]]; do
     fi
     dDTres=$Tres
     dDTRMSres=$TRMSres
-    echo Store new res values $dDTres, $dDTRMSres
+    echo Stored $iIter, $iShLev new res values $dDTres, $dDTRMSres
     (( dDTRMSres -= 1 ))  # next attempt should be at least 1ps better for continuation
     cp -v New_${CalFile} ${CalFile}  
     cp -v New_${CalFile} ${CalFile}_$iter  
   else
+    echo Next iteration $TRMSres -gt $dL0DTRMSres ?
+    if [[ $TRMSres -gt $dL0DTRMSres ]]; then
+      exit 0 
+    fi
     dDTres=0
   fi
   (( iter += 1 ))
 done
 
+(( iShLev -= 1 ))
 cd $wdir/$cRun
+echo Finishing with ShLev $iShLev, Iter = $iIter 
 # generate full statistics digi file 
-if [[ $iShLev = 0 ]]; then 
-  root -b -q '../ana_digi_cal.C(-1,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") '
-fi
-
-cd $wdir
-
-if [[ $iShLev = 0 ]]; then 
+if [[ $iShLev -eq 0 ]]; then
+#  root -b -q '../ana_digi_cal.C(-1,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") '
+  root -b -q '../ana_digi_cal.C(1000000,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") '
+  cd $wdir
   mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/TrkCalDigi_${cRun}_${iCalSet}_${iSel2}_${CalIdMode}.out
 fi
 
diff --git a/macro/beamtime/pl_Dut_Vel.C b/macro/beamtime/pl_Dut_Vel.C
index 68770955294531dbd09a9e772bde5b734eeef6d4..78d20bd9e9705203158ab4c40b8d4c642d0654f1 100644
--- a/macro/beamtime/pl_Dut_Vel.C
+++ b/macro/beamtime/pl_Dut_Vel.C
@@ -1,5 +1,5 @@
 void pl_Dut_Vel(const char* cDut = "900",
-                Double_t dEffMin  =0.,
+                Double_t dEffMin  =0.7,
                 Double_t Tstart  = 0.,
                 Double_t Tend    = 50.,
                 TString sysinfo  = "") {
diff --git a/macro/beamtime/pl_XY_trk.C b/macro/beamtime/pl_XY_trk.C
index 65e1687678e8c1b8e57a4ace222b997dc3c04460..15c848a20961d9e7c29c220bf3d345cab77554c5 100644
--- a/macro/beamtime/pl_XY_trk.C
+++ b/macro/beamtime/pl_XY_trk.C
@@ -37,13 +37,13 @@ void pl_XY_trk(Int_t NSt = 4, Double_t MinEff = 0.5, Double_t dThr = 0.1) {
       h2acc->Reset();
       Int_t Nbins   = h2->GetNbinsX() * h2->GetNbinsY();
       Double_t dMax = dThr * h2->GetMaximum();
-      for (Int_t i = 0; i < (Int_t) h2->GetNbinsX(); i++)
-        for (Int_t j = 0; j < (Int_t) h2->GetNbinsY(); j++) {
-          h2->GetBinContent(i + 1, j + 1) < dMax
-            ? h2acc->SetBinContent(i + 1, j + 1, 0.)
-            : h2acc->SetBinContent(i + 1, j + 1, 1.);
-          //cout << "Bin "<<i<<","<<j<<": "<< h2->GetBinContent(i+1,j+1) <<" filled with "<<h2acc->GetBinContent(i+1,j+1)<<endl;
-        }
+      for (Int_t i = 0; i < (Int_t)h2->GetNbinsX(); i++) 
+      for (Int_t j = 0; j < (Int_t)h2->GetNbinsY(); j++) 
+      {
+        h2->GetBinContent(i+1, j+1) < dMax ? h2acc->SetBinContent(i+1, j+1, 0.)
+                                           : h2acc->SetBinContent(i+1, j+1, 1.);
+        //cout << "Bin "<<i<<","<<j<<": "<< h2->GetBinContent(i+1,j+1) <<" filled with "<<h2acc->GetBinContent(i+1,j+1)<<endl;
+	  }
       TH2D* h2aall = (TH2D*) h2->Clone(Form("ALL_acc%d", iSt));
       h2aall->Multiply(h2aall, h2acc, 1., 1., "B");
       Nall = h2aall->Integral();
diff --git a/macro/beamtime/pl_over_trk.C b/macro/beamtime/pl_over_trk.C
index 60d6af2f9595311b05e956281bce6e0efc53168b..e9af558ef74448094bd9994840299212775fa531 100644
--- a/macro/beamtime/pl_over_trk.C
+++ b/macro/beamtime/pl_over_trk.C
@@ -203,14 +203,18 @@ void pl_over_trk(Int_t NSt = 4) {
     cout << hname << " not found" << endl;
   }
   */
-  hname = Form("hCalR0");
+  hname = Form("hCalDX0");
   h1    = (TH1*) gROOT->FindObjectAny(hname);
   if (h1 != NULL) {
     h1->Draw("");
     gPad->SetLogy();
+    hname = Form("hCalDY0");
+    TH1 *h1y = (TH1*) gROOT->FindObjectAny(hname);
+    h1y->SetLineColor(2);
+    h1y->Draw("same");
   } else {
     cout << hname << " not found" << endl;
-  }
+  }  
 
   can->cd(14);
   gROOT->cd();
diff --git a/macro/beamtime/pl_pull_trk.C b/macro/beamtime/pl_pull_trk.C
index efdaf052da76469b0a01a6cf5406f189899984f7..7f7283c6f3cc00943043d548670972b409ef81a4 100644
--- a/macro/beamtime/pl_pull_trk.C
+++ b/macro/beamtime/pl_pull_trk.C
@@ -1,7 +1,4 @@
-void pl_pull_trk(Int_t NSt   = 8,
-                 Int_t iVar  = 0,
-                 Int_t iFit  = 0,
-                 Int_t iDrop = -1) {
+void pl_pull_trk(Int_t NSt = 8, Int_t iVar = 0, Int_t iFit = 0, Int_t iDrop=-1) {
   //  TCanvas *can = new TCanvas("can22","can22");
   //  can->Divide(2,2);
   TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800);
@@ -34,8 +31,8 @@ void pl_pull_trk(Int_t NSt   = 8,
   Double_t vSigErr[MSt];
   Double_t vResErr[MSt];
   // if (h!=NULL) h->Delete();
-  Int_t iCan   = 1;
-  Int_t iIndSt = 0;
+  Int_t iCan = 1;
+  Int_t iIndSt=0;
   TString var;
   Double_t Nall;
 
@@ -57,18 +54,18 @@ void pl_pull_trk(Int_t NSt   = 8,
       gPad->SetLogy();
       gPad->SetGridx();
       if (iFit > 0) {
-        Double_t dFMean   = h1->GetMean();
-        Double_t dFLim    = 3.0 * h1->GetRMS();
+        Double_t dFMean = h1->GetMean();
+        Double_t dFLim  = 3.0 * h1->GetRMS();
         Double_t dBinSize = h1->GetBinWidth(1);
-        dFLim             = TMath::Max(dFLim, 5. * dBinSize);
+        dFLim=TMath::Max(dFLim,5.*dBinSize);
         TFitResultPtr fRes =
           h1->Fit("gaus", "S", "", dFMean - dFLim, dFMean + dFLim);
         //cout << " fRes = "<< fRes <<endl;
-        if (-1 == fRes) return;
-        if (iDrop == iSt) {  // drop station from deconvolution
-          continue;
-        }
-        cout << "Add " << iSt << " as station index " << iIndSt << endl;
+        if (-1 == fRes) continue;
+        if ( iDrop == iSt ) { // drop station from deconvolution
+		  continue;
+		}
+		cout << "Add " << iSt << " as station index " << iIndSt << endl;
         vSt[iIndSt]      = iSt;
         vMean[iIndSt]    = fRes->Parameter(1);
         vSig[iIndSt]     = fRes->Parameter(2);
diff --git a/macro/beamtime/pl_vert_trk.C b/macro/beamtime/pl_vert_trk.C
index b37f3d610310017d7a097c65c16386284ba57540..9975cab8da19cc62682cf80d8ce80e6d97f6158c 100644
--- a/macro/beamtime/pl_vert_trk.C
+++ b/macro/beamtime/pl_vert_trk.C
@@ -1,4 +1,4 @@
-void pl_vert_trk() {
+void pl_vert_trk(Double_t dFitWidth=0.) {
   //  TCanvas *can = new TCanvas("can22","can22");
   //  can->Divide(2,2);
   TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800);
@@ -29,64 +29,55 @@ void pl_vert_trk() {
 
   can->cd(2);
   gROOT->cd();
-  Double_t MeanX0    = 0.;
-  Double_t SigX0     = 0.;
-  Double_t MeanX0Err = 0.;
-  Double_t SigX0Err  = 0.;
-  h1                 = (TH1*) h2->ProjectionX();
+  Double_t MeanX0=0.;
+  Double_t SigX0=0.;
+  Double_t MeanX0Err=0.;
+  Double_t SigX0Err=0.;
+  h1    = (TH1*) h2->ProjectionX();
   if (h1 != NULL) {
     Double_t dFMean = h1->GetMean();
-    Double_t dFLim  = 3.0 * h1->GetRMS();
-    dFMean          = h1->GetBinCenter(h1->GetMaximumBin());
-    dFLim           = 15.;
+    Double_t dFLim  = 2.0 * h1->GetRMS();
+    dFMean=h1->GetBinCenter( h1-> GetMaximumBin() ); 
+    if(dFitWidth > 0.) dFLim=dFitWidth;
     TFitResultPtr fRes =
-      h1->Fit("gaus", "S", "", dFMean - dFLim, dFMean + dFLim);
+        h1->Fit("gaus", "QS", "", dFMean - dFLim, dFMean + dFLim);
     //cout << " fRes = "<< fRes <<endl;
     if (-1 != fRes) {
       MeanX0    = fRes->Parameter(1);
       SigX0     = fRes->Parameter(2);
-      MeanX0Err = 0.;
+      MeanX0Err   = 0.;
       MeanX0Err = fRes->ParError(1);
       SigX0Err  = fRes->ParError(2);
-    }
+	}
   }
 
-  Double_t MeanY0    = 0.;
-  Double_t SigY0     = 0.;
-  Double_t MeanY0Err = 0.;
-  Double_t SigY0Err  = 0.;
-  h1                 = (TH1*) h2->ProjectionY();
+  Double_t MeanY0=0.;
+  Double_t SigY0=0.;
+  Double_t MeanY0Err=0.;
+  Double_t SigY0Err=0.;
+  h1    = (TH1*) h2->ProjectionY();
   if (h1 != NULL) {
     Double_t dFMean = h1->GetMean();
-    Double_t dFLim  = 3.0 * h1->GetRMS();
-    dFMean          = h1->GetBinCenter(h1->GetMaximumBin());
-    dFLim           = 15.;
+    Double_t dFLim  = 2.0 * h1->GetRMS();
+    dFMean=h1->GetBinCenter( h1-> GetMaximumBin() ); 
+    if(dFitWidth > 0.) dFLim=dFitWidth;
     TFitResultPtr fRes =
-      h1->Fit("gaus", "S", "same", dFMean - dFLim, dFMean + dFLim);
-    h1->SetLineColor(7);
+        h1->Fit("gaus", "QS", "same", dFMean - dFLim, dFMean + dFLim);
+        h1->SetLineColor(7);
     //cout << " fRes = "<< fRes <<endl;
     if (-1 != fRes) {
       MeanY0    = fRes->Parameter(1);
       SigY0     = fRes->Parameter(2);
-      MeanY0Err = 0.;
+      MeanY0Err   = 0.;
       MeanY0Err = fRes->ParError(1);
       SigY0Err  = fRes->ParError(2);
-    }
+	}
   }
-
-
-  cout << Form("TrkXY0_0: MeanX %6.2f (%5.2f), SigX %6.2f (%5.2f) ",
-               MeanX0,
-               MeanX0Err,
-               SigX0,
-               SigX0Err)
-       << Form(" MeanY %6.2f (%5.2f), SigY %6.2f (%5.2f) ",
-               MeanY0,
-               MeanY0Err,
-               SigY0,
-               SigY0Err)
-       << endl;
-
+  
+  
+  cout << Form("TrkXY0_0: MeanX %6.2f (%5.2f), SigX %6.2f (%5.2f) ",MeanX0, MeanX0Err, SigX0, SigX0Err)
+       << Form(" MeanY %6.2f (%5.2f), SigY %6.2f (%5.2f) ",MeanY0, MeanY0Err, SigY0, SigY0Err) << endl; 
+   
   can->cd(3);
   gROOT->cd();
   hname = Form("hTrklXY0_1");
@@ -94,62 +85,54 @@ void pl_vert_trk() {
   if (h2 != NULL) {
     h2->Draw("colz");
     gPad->SetLogz();
-    Double_t MeanX1    = 0.;
-    Double_t SigX1     = 0.;
-    Double_t MeanX1Err = 0.;
-    Double_t SigX1Err  = 0.;
-    h1                 = (TH1*) h2->ProjectionX();
-    if (h1 != NULL) {
+    Double_t MeanX1=0.;
+	Double_t SigX1=0.;
+	Double_t MeanX1Err=0.;
+	Double_t SigX1Err=0.;
+	h1    = (TH1*) h2->ProjectionX();
+	if (h1 != NULL) {
       Double_t dFMean = h1->GetMean();
-      Double_t dFLim  = 3.0 * h1->GetRMS();
-      dFMean          = h1->GetBinCenter(h1->GetMaximumBin());
-      dFLim           = 15.;
+      Double_t dFLim  = 2.0 * h1->GetRMS();
+      dFMean=h1->GetBinCenter( h1-> GetMaximumBin() ); 
+      if(dFitWidth > 0.) dFLim=dFitWidth;
       TFitResultPtr fRes =
-        h1->Fit("gaus", "S", "", dFMean - dFLim, dFMean + dFLim);
+        h1->Fit("gaus", "QS", "", dFMean - dFLim, dFMean + dFLim);
       //cout << " fRes = "<< fRes <<endl;
       if (-1 != fRes) {
-        MeanX1    = fRes->Parameter(1);
-        SigX1     = fRes->Parameter(2);
-        MeanX1Err = 0.;
-        MeanX1Err = fRes->ParError(1);
-        SigX1Err  = fRes->ParError(2);
-      }
-
-      Double_t MeanY1    = 0.;
-      Double_t SigY1     = 0.;
-      Double_t MeanY1Err = 0.;
-      Double_t SigY1Err  = 0.;
-      h1                 = (TH1*) h2->ProjectionY();
-      if (h1 != NULL) {
-        Double_t dFMean = h1->GetMean();
-        Double_t dFLim  = 3.0 * h1->GetRMS();
-        dFMean          = h1->GetBinCenter(h1->GetMaximumBin());
-        dFLim           = 15.;
-        TFitResultPtr fRes =
-          h1->Fit("gaus", "S", "same", dFMean - dFLim, dFMean + dFLim);
+		MeanX1    = fRes->Parameter(1);
+		SigX1     = fRes->Parameter(2);
+		MeanX1Err   = 0.;
+		MeanX1Err = fRes->ParError(1);
+		SigX1Err  = fRes->ParError(2);
+	  }
+	
+	  Double_t MeanY1=0.;
+	  Double_t SigY1=0.;
+	  Double_t MeanY1Err=0.;
+	  Double_t SigY1Err=0.;
+	  h1    = (TH1*) h2->ProjectionY();
+	  if (h1 != NULL) {
+		Double_t dFMean = h1->GetMean();
+		Double_t dFLim  = 2.0 * h1->GetRMS();
+		dFMean=h1->GetBinCenter( h1-> GetMaximumBin() ); 
+        if(dFitWidth > 0.) dFLim=dFitWidth;
+		TFitResultPtr fRes =
+          h1->Fit("gaus", "QS", "same", dFMean - dFLim, dFMean + dFLim);
         h1->SetLineColor(7);
         //cout << " fRes = "<< fRes <<endl;
         if (-1 != fRes) {
-          MeanY1    = fRes->Parameter(1);
-          SigY1     = fRes->Parameter(2);
-          MeanY1Err = 0.;
-          MeanY1Err = fRes->ParError(1);
-          SigY1Err  = fRes->ParError(2);
-        }
-      }
-
-      cout << Form("TrkXY0_1: MeanX %6.2f (%5.2f), SigX %6.2f (%5.2f) ",
-                   MeanX1,
-                   MeanX1Err,
-                   SigX1,
-                   SigX1Err)
-           << Form(" MeanY %6.2f (%5.2f), SigY %6.2f (%5.2f) ",
-                   MeanY1,
-                   MeanY1Err,
-                   SigY1,
-                   SigY1Err)
-           << endl;
-    }
+		  MeanY1    = fRes->Parameter(1);
+		  SigY1     = fRes->Parameter(2);
+		  MeanY1Err   = 0.;
+		  MeanY1Err = fRes->ParError(1);
+		  SigY1Err  = fRes->ParError(2);
+	    }
+	  }
+  
+	  cout << Form("TrkXY0_1: MeanX %6.2f (%5.2f), SigX %6.2f (%5.2f) ",MeanX1, MeanX1Err, SigX1, SigX1Err)
+           << Form(" MeanY %6.2f (%5.2f), SigY %6.2f (%5.2f) ",MeanY1, MeanY1Err, SigY1, SigY1Err) << endl; 
+     
+	}
 
   } else {
     cout << hname << " not found" << endl;
@@ -176,6 +159,60 @@ void pl_vert_trk() {
   } else {
     cout << hname << " not found" << endl;
   }
+  
+  can->cd(10);
+  if (h2 != NULL) {
+    h2->Draw("colz");
+    gPad->SetLogz();
+    Double_t MeanX1=0.;
+	Double_t SigX1=0.;
+	Double_t MeanX1Err=0.;
+	Double_t SigX1Err=0.;
+	h1    = (TH1*) h2->ProjectionX();
+	if (h1 != NULL) {
+      Double_t dFMean = h1->GetMean();
+      Double_t dFLim  = 2.0 * h1->GetRMS();
+      dFMean=h1->GetBinCenter( h1-> GetMaximumBin() ); 
+      if(dFitWidth > 0.) dFLim=dFitWidth;
+      TFitResultPtr fRes =
+        h1->Fit("gaus", "QS", "", dFMean - dFLim, dFMean + dFLim);
+      //cout << " fRes = "<< fRes <<endl;
+      if (-1 != fRes) {
+		MeanX1    = fRes->Parameter(1);
+		SigX1     = fRes->Parameter(2);
+		MeanX1Err   = 0.;
+		MeanX1Err = fRes->ParError(1);
+		SigX1Err  = fRes->ParError(2);
+	  }
+	
+	  Double_t MeanY1=0.;
+	  Double_t SigY1=0.;
+	  Double_t MeanY1Err=0.;
+	  Double_t SigY1Err=0.;
+	  h1    = (TH1*) h2->ProjectionY();
+	  if (h1 != NULL) {
+		Double_t dFMean = h1->GetMean();
+		Double_t dFLim  = 2.0 * h1->GetRMS();
+		dFMean=h1->GetBinCenter( h1-> GetMaximumBin() ); 
+        if(dFitWidth > 0.) dFLim=dFitWidth;
+		TFitResultPtr fRes =
+          h1->Fit("gaus", "QS", "same", dFMean - dFLim, dFMean + dFLim);
+        h1->SetLineColor(7);
+        //cout << " fRes = "<< fRes <<endl;
+        if (-1 != fRes) {
+		  MeanY1    = fRes->Parameter(1);
+		  SigY1     = fRes->Parameter(2);
+		  MeanY1Err   = 0.;
+		  MeanY1Err = fRes->ParError(1);
+		  SigY1Err  = fRes->ParError(2);
+	    }
+	  }
+  
+	  cout << Form("VTX0: MeanX %6.2f (%5.2f), SigX %6.2f (%5.2f) ",MeanX1, MeanX1Err, SigX1, SigX1Err)
+           << Form(" MeanY %6.2f (%5.2f), SigY %6.2f (%5.2f) ",MeanY1, MeanY1Err, SigY1, SigY1Err) << endl; 
+    }     
+  }
+
 
   can->cd(6);
   gROOT->cd();
@@ -221,4 +258,5 @@ void pl_vert_trk() {
     cout << hname << " not found" << endl;
   }
   can->SaveAs(Form("pl_vtx.pdf"));
+
 }
diff --git a/macro/mcbm/geometry/tof/Create_TOF_Geometry_v20f_mcbm.C b/macro/mcbm/geometry/tof/Create_TOF_Geometry_v20f_mcbm.C
index e9336a8d66a081307d336e349e134dc62ebf1a65..64a14cc67c57779c7eee5d9730859d39cf20d889 100644
--- a/macro/mcbm/geometry/tof/Create_TOF_Geometry_v20f_mcbm.C
+++ b/macro/mcbm/geometry/tof/Create_TOF_Geometry_v20f_mcbm.C
@@ -140,9 +140,9 @@ const Int_t NCounterInModule[NofModuleTypes] = {5, 5, 3, 5, 5, 1, 2, 1, 8, 2};
 
 // Placement of the counter inside the module
 const Float_t CounterXStartPosition[NofModuleTypes] =
-  {-60., -66.0, -56.0, -60.0, -60.0, 0.0, 0., 0., -7., 0.};
+  {-60.1, -66.0, -56.0, -60.0, -60.0, 0.0, 0., 0., -7., 0.};
 const Float_t CounterXDistance[NofModuleTypes] =
-  {30.0, 32.0, 51.0, 30.0, 30.0, 0.0, 0., 0., 2., -1.};
+  {29.3, 32.0, 51.0, 30.0, 30.0, 0.0, 0., 0., 2., -1.};
 const Float_t CounterYStartPosition[NofModuleTypes] =
   {0.0, 0.0, 0.0, 0.0, 0.0, 0., 0., -4., -1.3, 0.};
 const Float_t CounterYDistance[NofModuleTypes] =
@@ -326,15 +326,18 @@ void Create_TOF_Geometry_v20f_mcbm() {
     new TGeoTranslation("", TOF_X_Front_Stand, 0., 0.);
   TGeoTranslation* stand_trans =
     new TGeoTranslation("", 0., 0., TOF_Z_Front_Stand);    
+  TGeoCombiTrans* stand_combi_trans =
+    new TGeoCombiTrans(*stand_trans, *tof_rotation);  
+    
   // Nov 2019 run
   // TGeoTranslation*  stand_trans   = new TGeoTranslation("", 12., 0., TOF_Z_Front_Stand);
   // TGeoTranslation*  stand_trans   = new TGeoTranslation("",  0., 0., TOF_Z_Front_Stand);
   TGeoRotation* stand_rot = new TGeoRotation();
   stand_rot->RotateY(0.55);
+  //stand_rot->RotateY(1.0);
   TGeoCombiTrans* stand_combi_trans_local =
     new TGeoCombiTrans(*stand_trans_local, *stand_rot);
-  TGeoCombiTrans* stand_combi_trans =
-    new TGeoCombiTrans(*stand_trans, *tof_rotation);    
+    
   //tof->AddNode(tofstand, 1, stand_combi_trans);
   tof->AddNode(tofstand, 1, stand_combi_trans_local);
   //tof->AddNode(tofstand, 1);