From e262c966c4720b71878bd2d81e992114acee61af Mon Sep 17 00:00:00 2001
From: Alexandru Bercuci <abercuci@niham.nipne.ro>
Date: Thu, 4 Nov 2021 13:32:20 +0200
Subject: [PATCH] add radiator identification based on geo file

---
 core/detectors/trd/CbmTrdGeoHandler.cxx | 14 ++++++++++++++
 core/detectors/trd/CbmTrdGeoHandler.h   |  7 ++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/core/detectors/trd/CbmTrdGeoHandler.cxx b/core/detectors/trd/CbmTrdGeoHandler.cxx
index cff3dcf2e5..e7e24345bc 100644
--- a/core/detectors/trd/CbmTrdGeoHandler.cxx
+++ b/core/detectors/trd/CbmTrdGeoHandler.cxx
@@ -39,6 +39,7 @@ CbmTrdGeoHandler::CbmTrdGeoHandler()
   , fLayerId(0)
   , fModuleId(0)
   , fModuleType(0)
+  , fRadiatorType(-1)
   , fRotation(0)
   , fStation(0)
   , fLayer(0)
@@ -159,6 +160,12 @@ Int_t CbmTrdGeoHandler::GetModuleType(const TString& path)
   return fModuleType;
 }
 
+Int_t CbmTrdGeoHandler::GetRadiatorType(const TString& path)
+{
+  if (fGeoPathHash != path.Hash()) { NavigateTo(path); }
+  return fRadiatorType;
+}
+
 Int_t CbmTrdGeoHandler::GetStation(const TString& path)
 {
   if (fGeoPathHash != path.Hash()) { NavigateTo(path); }
@@ -221,6 +228,13 @@ void CbmTrdGeoHandler::NavigateTo(const TString& path)
       // In TGeoManager numbering starts with 1, so we have to subtract 1.
       fModuleCopy = ((modulecopyNr / 1000000) % 100);  // from module copy number
       fRotation   = ((modulecopyNr / 100000) % 10);    // from module copy number
+      fRadiatorType = -1;
+      for (int i = 0; i < modulenode->GetNdaughters(); i++) {
+        TString nDaughter(modulenode->GetDaughter(i)->GetName());
+        if (!nDaughter.BeginsWith("radiator") && !nDaughter.BeginsWith("Radiator")) continue;
+        fRadiatorType = 0;
+        // TODO define radiator (+ entrance window) types according to the naming convention 
+      }
     }
     else  // 2013 and earlier
     {
diff --git a/core/detectors/trd/CbmTrdGeoHandler.h b/core/detectors/trd/CbmTrdGeoHandler.h
index 5271dbf52d..2201065db8 100644
--- a/core/detectors/trd/CbmTrdGeoHandler.h
+++ b/core/detectors/trd/CbmTrdGeoHandler.h
@@ -82,6 +82,10 @@ public:
   Double_t GetY(const TString& path);
   Double_t GetZ(const TString& path);
   Int_t GetModuleType(const TString& path);
+  /** \brief Navigate to node and return the radiator type build in the geometry based on the naming convention.
+   * @return radiator type ID or -1 if the radiator is not installed
+   */
+  Int_t GetRadiatorType(const TString& path);
 
   // for backward compatibility
   Int_t GetStation(const TString& path);
@@ -101,6 +105,7 @@ private:
   Int_t fLayerId;              //!
   Int_t fModuleId;             //!
   Int_t fModuleType;           //!
+  Int_t fRadiatorType;         //! radiator + chamber entrance window type 
   Int_t fRotation;             //! rotation angle 0,1,2,3
 
   // for backward compatibility
@@ -111,7 +116,7 @@ private:
   CbmTrdGeoHandler(const CbmTrdGeoHandler&);
   CbmTrdGeoHandler operator=(const CbmTrdGeoHandler&);
 
-  ClassDef(CbmTrdGeoHandler, 4)
+  ClassDef(CbmTrdGeoHandler, 5)
 };
 
 #endif  //CBMTRDGEOHANDLER_H
-- 
GitLab