From d754cdd813aa5196371d0f3893edc1be25f8ed93 Mon Sep 17 00:00:00 2001
From: Valentina <v.akishina@gsi.de>
Date: Mon, 28 Feb 2022 17:36:11 +0100
Subject: [PATCH] L1: check detector presence in the setup

---
 reco/L1/CbmL1.cxx          | 29 ++++++++++++++++++++++++++++-
 reco/L1/CbmL1.h            |  1 +
 reco/L1/CbmL1ReadEvent.cxx |  1 -
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx
index e4d11805e3..c1e8fdb281 100644
--- a/reco/L1/CbmL1.cxx
+++ b/reco/L1/CbmL1.cxx
@@ -109,6 +109,31 @@ CbmL1::~CbmL1()
   if (fInstance == this) fInstance = nullptr;
 }
 
+void CbmL1::CheckDetectorPresence()
+{
+  Bool_t IsMuch       = 0;
+  Bool_t IsTrd        = 0;
+  Bool_t IsTof        = 0;
+  Bool_t IsSts        = 0;
+  Bool_t IsMvd        = 0;
+  TObjArray* topNodes = gGeoManager->GetTopNode()->GetNodes();
+
+  for (Int_t iTopNode = 0; iTopNode < topNodes->GetEntriesFast(); iTopNode++) {
+    TGeoNode* topNode = static_cast<TGeoNode*>(topNodes->At(iTopNode));
+
+    if (TString(topNode->GetName()).Contains("much")) IsMuch = 1;
+    if (TString(topNode->GetName()).Contains("trd")) IsTrd = 1;
+    if (TString(topNode->GetName()).Contains("tof")) IsTof = 1;
+    if (TString(topNode->GetName()).Contains("sts")) IsSts = 1;
+    if (TString(topNode->GetName()).Contains("mvd")) IsMvd = 1;
+  }
+
+  fUseMUCH = (fUseMUCH && IsMuch);
+  fUseTRD  = fUseTRD && IsTrd;
+  fUseTOF  = fUseTOF && IsTof;
+  fUseMVD  = fUseMVD && IsMvd;
+}
+
 
 void CbmL1::SetParContainers()
 {
@@ -207,6 +232,8 @@ InitStatus CbmL1::Init()
     fUseTOF  = 0;
   }
 
+  CheckDetectorPresence();
+
 
   fStsPoints  = 0;
   fMvdPoints  = 0;
@@ -1441,7 +1468,7 @@ void CbmL1::Reconstruct(CbmEvent* event)
 
     if (fVerbose > 1) { cout << "L1 Track finder..." << endl; }
     algo->CATrackFinder();
-    // IdealTrackFinder();
+    //      IdealTrackFinder();
     fTrackingTime += algo->fCATime;
 
     if (fVerbose > 1) { cout << "L1 Track finder ok" << endl; }
diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h
index 75bb1aac03..20075dc300 100644
--- a/reco/L1/CbmL1.h
+++ b/reco/L1/CbmL1.h
@@ -125,6 +125,7 @@ public:
   static CbmL1* Instance() { return fInstance; }
 
   void SetParContainers();
+  void CheckDetectorPresence();
   virtual InitStatus ReInit();
   virtual InitStatus Init();
   void Exec(Option_t* option);
diff --git a/reco/L1/CbmL1ReadEvent.cxx b/reco/L1/CbmL1ReadEvent.cxx
index 7c1c04dc8a..837d47c7db 100644
--- a/reco/L1/CbmL1ReadEvent.cxx
+++ b/reco/L1/CbmL1ReadEvent.cxx
@@ -387,7 +387,6 @@ void CbmL1::ReadEvent(L1AlgoInputData* fData_, float& TsStart, float& TsLength,
                               ? (NMvdStations + NStsStations + NMuchStations + NTrdStations + iSt)
                               : MC.iStation;
             if (MC.iStation < 0) continue;
-            if (MC.z < 240) continue;
             assert(MC.iStation >= 0);
             int iTofSta = MC.iStation - (NMvdStations + NStsStations + NMuchStations + NTrdStations);
 
-- 
GitLab