From 2720b5ea1e4e929242b157db118c5510406997d8 Mon Sep 17 00:00:00 2001
From: Valentina <v.akishina@gsi.de>
Date: Wed, 17 Nov 2021 13:18:48 +0100
Subject: [PATCH] L1: corrections for mCBM setup

---
 reco/L1/CbmL1.cxx                  | 18 ++++++++++++-----
 reco/L1/CbmL1ReadEvent.cxx         | 32 ++++++++++++++++++++++--------
 reco/L1/L1Algo/L1CATrackFinder.cxx |  8 ++++----
 3 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx
index ac53fb5752..6491893064 100644
--- a/reco/L1/CbmL1.cxx
+++ b/reco/L1/CbmL1.cxx
@@ -398,8 +398,10 @@ InitStatus CbmL1::Init()
       }
     }
     NTrdStations = layerCounter;
+    NTrdStations = NTrdStations - 1;
   }
 
+
   // count ToF parameters
 
   // if (fUseTOF) {
@@ -429,7 +431,7 @@ InitStatus CbmL1::Init()
   // }
 
   // TODO: Read N TOF stations from geometry
-  if (fUseTOF) NTOFStation = 3;  //fTofDigiBdfPar->GetNbTrackingStations();
+  if (fUseTOF) NTOFStation = 4;  //fTofDigiBdfPar->GetNbTrackingStations();
 
   CbmStsSetup* stsSetup = CbmStsSetup::Instance();
   if (!stsSetup->IsInit()) { stsSetup->Init(nullptr); }
@@ -607,7 +609,12 @@ InitStatus CbmL1::Init()
 
       //      Int_t nrModules = fTrdDigiPar->GetNrOfModules();
 
-      int ModuleId = fTrdDigiPar->GetModuleId(num);
+      int skip = 0;
+      if (num == 0) skip = 0;
+      if (num == 1) skip = 2;
+      if (num == 2) skip = 3;
+
+      int ModuleId = fTrdDigiPar->GetModuleId(skip);
 
       CbmTrdParModDigi* module = (CbmTrdParModDigi*) fTrdDigiPar->GetModulePar(ModuleId);
 
@@ -635,9 +642,10 @@ InitStatus CbmL1::Init()
 
       geo.push_back(4);
 
-      if (ist == (NMvdStations + NStsStations + NTrdStations + NMuchStations + 0)) geo.push_back(247);
-      if (ist == (NMvdStations + NStsStations + NTrdStations + NMuchStations + 1)) geo.push_back(264);
-      if (ist == (NMvdStations + NStsStations + NTrdStations + NMuchStations + 2)) geo.push_back(280);
+      if (ist == (NMvdStations + NStsStations + NTrdStations + NMuchStations + 0)) geo.push_back(251);
+      if (ist == (NMvdStations + NStsStations + NTrdStations + NMuchStations + 1)) geo.push_back(270);
+      if (ist == (NMvdStations + NStsStations + NTrdStations + NMuchStations + 2)) geo.push_back(293);
+      if (ist == (NMvdStations + NStsStations + NTrdStations + NMuchStations + 3)) geo.push_back(310);
 
       geo.push_back(10);  /// TODO: add Tof width dz
       geo.push_back(0);
diff --git a/reco/L1/CbmL1ReadEvent.cxx b/reco/L1/CbmL1ReadEvent.cxx
index c6433a5e75..e5ad92f54d 100644
--- a/reco/L1/CbmL1ReadEvent.cxx
+++ b/reco/L1/CbmL1ReadEvent.cxx
@@ -242,6 +242,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
             for (Int_t iSt = 0; iSt < NTrdStations; iSt++) {
               if (MC.z > sta[iSt].z[0] - 4.0) { MC.iStation = NMvdStations + NStsStations + NMuchStations + iSt; }
             }
+            if (MC.iStation < 0) continue;
             assert(MC.iStation >= 0);
             Double_t dtrck          = dFEI(iFile, iEvent, MC.ID);
             DFEI2I::iterator trk_it = dFEI2vMCTracks.find(dtrck);
@@ -321,7 +322,7 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
             MC.iStation    = -1;
             L1Station* sta = algo->vStations + NMvdStations + NStsStations + NMuchStations + NTrdStations;
             for (Int_t iSt = 0; iSt < NTOFStation; iSt++)
-              MC.iStation = (MC.z > sta[iSt].z[0] - 1.5)
+              MC.iStation = (MC.z > sta[iSt].z[0] - 6)
                               ? (NMvdStations + NStsStations + NMuchStations + NTrdStations + iSt)
                               : MC.iStation;
 
@@ -678,7 +679,16 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
 
       th.id = tmpHits.size();
 
-      th.iStation = NMvdStations + mh->GetPlaneId() + NStsStations + NMuchStations;
+      int sta = mh->GetPlaneId();
+
+      if (sta > 1) sta = sta - 1;
+
+      th.iStation = NMvdStations + sta + NStsStations + NMuchStations;
+
+      // if (mh->GetPlaneId()==0) continue;
+      // if (mh->GetPlaneId()==1) continue;
+      // if (mh->GetPlaneId()==2) continue;
+      // if (mh->GetPlaneId()==3) continue;
 
 
       th.time = mh->GetTime();
@@ -778,12 +788,16 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
 
       int sttof = -1;
 
-      if (fTofDigiBdfPar->GetTrackingStation(mh) == 0) sttof = 0;
-      if (fTofDigiBdfPar->GetTrackingStation(mh) == 1) sttof = 0;
-      if (fTofDigiBdfPar->GetTrackingStation(mh) == 2) sttof = 1;
-      if (fTofDigiBdfPar->GetTrackingStation(mh) == 3) sttof = 1;
-      if (fTofDigiBdfPar->GetTrackingStation(mh) == 4) sttof = 2;
-      if (fTofDigiBdfPar->GetTrackingStation(mh) == 5) sttof = 2;
+      sttof = fTofDigiBdfPar->GetTrackingStation(mh);
+
+      // if (fTofDigiBdfPar->GetTrackingStation(mh) == 0) sttof = 0;
+      // if (fTofDigiBdfPar->GetTrackingStation(mh) == 1) sttof = 0;
+      // if (fTofDigiBdfPar->GetTrackingStation(mh) == 2) sttof = 1;
+      // if (fTofDigiBdfPar->GetTrackingStation(mh) == 3) sttof = 1;
+      // if (fTofDigiBdfPar->GetTrackingStation(mh) == 4) sttof = 2;
+      // if (fTofDigiBdfPar->GetTrackingStation(mh) == 5) sttof = 2;
+
+      if ((th.x > 20) && (th.z > 270) && (fTofDigiBdfPar->GetTrackingStation(mh) == 1)) sttof = 2;
 
       th.iStation = sttof + NMvdStations + NStsStations + NMuchStations + NTrdStations;
 
@@ -811,6 +825,8 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
       th.y = pos.Y();
       th.z = pos.Z();
 
+      if (th.z > 400) continue;
+
       L1Station& st = algo->vStations[th.iStation];
       th.u_front    = th.x * st.frontInfo.cos_phi[0] + th.y * st.frontInfo.sin_phi[0];
       th.u_back     = th.x * st.backInfo.cos_phi[0] + th.y * st.backInfo.sin_phi[0];
diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx
index 354a68d922..df8c15fdef 100644
--- a/reco/L1/L1Algo/L1CATrackFinder.cxx
+++ b/reco/L1/L1Algo/L1CATrackFinder.cxx
@@ -476,7 +476,7 @@ inline void L1Algo::f20(
 
       const fscal dY = ym[i1_4] - y[i1_4];
 
-      if (dY * dY > dy_est2 && dY < 0) continue;
+      if (dY * dY > dy_est2) continue;
 
       // check x-boundaries
       fvec x, C00;
@@ -680,7 +680,7 @@ inline void L1Algo::f30(  // input
       if (fTrackingMode != kMcbm) fit.L1AddMaterial(T2, fRadThick[istam].GetRadThick(T2.x, T2.y), T2.qp, 1);
 
       if (fTrackingMode == kGlobal || fTrackingMode == kMcbm)
-        fit.L1AddThickMaterial(T2, fRadThick[istam].GetRadThick(T2.x, T2.y), T2.qp, 1, stam.materialInfo.thick, 1);
+        fit.L1AddThickMaterial(T2, fRadThick[istam].GetRadThick(T2.x, T2.y), MaxInvMom, 1, stam.materialInfo.thick, 1);
 #else
       fit.L1AddMaterial(T2, stam.materialInfo, T2.qp, 1);
 #endif
@@ -2696,8 +2696,8 @@ inline void L1Algo::CAFindTrack(int ista, L1Branch& best_tr, unsigned char& best
       Cty += new_trip.GetCty();
 
       if (fTrackingMode == kGlobal || fTrackingMode == kMcbm) {
-        if (dty > 6 * Cty) continue;
-        if (dtx > 7 * Ctx) continue;
+        if (dty > 3 * Cty) continue;
+        if (dtx > 3 * Ctx) continue;
       }
 
 
-- 
GitLab