From 99e20f74dba0dc232f090c7d2b5d9af5f161d7a1 Mon Sep 17 00:00:00 2001
From: Alexandru Bercuci <abercuci@niham.nipne.ro>
Date: Fri, 21 Jan 2022 09:53:12 +0200
Subject: [PATCH] add configuration options to the TrdModule to accomodate
 various pad-plane topologies and FEEs

---
 core/data/trd/CbmTrdCluster.h               |  2 +-
 core/detectors/trd/CbmTrdModuleAbstract.cxx |  2 +
 core/detectors/trd/CbmTrdModuleAbstract.h   | 42 +++++++++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/core/data/trd/CbmTrdCluster.h b/core/data/trd/CbmTrdCluster.h
index d7932433e6..cfe5d3030c 100644
--- a/core/data/trd/CbmTrdCluster.h
+++ b/core/data/trd/CbmTrdCluster.h
@@ -28,7 +28,7 @@ class CbmTrdCluster : public CbmCluster {
 public:
   enum eCbmTrdClusterDef
   {
-    kFasp = 5      ///< set type of FEE digis contained
+    kFasp = 5  ///< set type of FEE digis contained
       ,
     kProfileStart  ///< only for triangular if no T in first col
       ,
diff --git a/core/detectors/trd/CbmTrdModuleAbstract.cxx b/core/detectors/trd/CbmTrdModuleAbstract.cxx
index 52e2cd54cc..0230771725 100644
--- a/core/detectors/trd/CbmTrdModuleAbstract.cxx
+++ b/core/detectors/trd/CbmTrdModuleAbstract.cxx
@@ -7,6 +7,7 @@
 //_______________________________________________________________________________
 CbmTrdModuleAbstract::CbmTrdModuleAbstract()
   : TNamed()
+  , fModConfig(0)
   , fModAddress(0)
   , fLayerId(-1)
   , fRotation(0)
@@ -21,6 +22,7 @@ CbmTrdModuleAbstract::CbmTrdModuleAbstract()
 //_______________________________________________________________________________
 CbmTrdModuleAbstract::CbmTrdModuleAbstract(Int_t mod, Int_t ly, Int_t rot)
   : TNamed("CbmTrdModule", "Abstract TRD module implementation")
+  , fModConfig(0)
   , fModAddress(mod)
   , fLayerId(ly)
   , fRotation(rot)
diff --git a/core/detectors/trd/CbmTrdModuleAbstract.h b/core/detectors/trd/CbmTrdModuleAbstract.h
index ef47d2653c..a245142815 100644
--- a/core/detectors/trd/CbmTrdModuleAbstract.h
+++ b/core/detectors/trd/CbmTrdModuleAbstract.h
@@ -21,6 +21,12 @@ class CbmTrdParModGas;
   **/
 class CbmTrdModuleAbstract : public TNamed {
 public:
+  enum eCbmTrdModuleDef
+  {
+    kTrd2d = 0  ///< toggle pad-plane type of the chamber
+      ,
+    kFasp = 1  ///< toggle FEE type for the module
+  };
   /** \brief Default constructor.*/
   CbmTrdModuleAbstract();
   /** \brief Constructor with placement */
@@ -58,14 +64,50 @@ public:
    */
   virtual inline Int_t GetPadRowCol(Int_t address, Int_t& c) const;
   virtual const Char_t* GetPath() const { return fGeoPar ? fGeoPar->GetTitle() : ""; }
+  /** \brief Inquire the FEE read-out type of the module
+   * \return false for SPADIC and true for FASP
+   */
+  bool HasFaspFEE() const { return TESTBIT(fModConfig, eCbmTrdModuleDef::kFasp); }
+  /** \brief Inquire the pad-plane type of the chamber
+   * \return false for TRD-1D and true for TRD-2D
+   */
+  bool Has2dPadPlane() const { return TESTBIT(fModConfig, eCbmTrdModuleDef::kTrd2d); }
+
   virtual void LocalToMaster(Double_t in[3], Double_t out[3]);
+
   virtual void SetAsicPar(CbmTrdParSetAsic* p = nullptr) { fAsicPar = p; }
   virtual void SetChmbPar(const CbmTrdParModGas* p) { fChmbPar = p; }
   virtual void SetDigiPar(const CbmTrdParModDigi* p) { fDigiPar = p; }
   virtual void SetGainPar(const CbmTrdParModGain* p) { fGainPar = p; }
   virtual void SetGeoPar(const CbmTrdParModGeo* p) { fGeoPar = p; }
 
+  /** \brief Define the read-out FEE type of the module
+   * \param[in] set true for FASP and false [default] for SPADIC
+   */
+  void SetFEE(bool set = true)
+  {
+    set ? SETBIT(fModConfig, eCbmTrdModuleDef::kFasp) : CLRBIT(fModConfig, eCbmTrdModuleDef::kFasp);
+  }
+  /** \brief Define the pad-plane type of the chamber
+   * \param[in] set true for TRD-2D and false [default] for TRD-1D
+   */
+  void SetPadPlane(bool set = true)
+  {
+    set ? SETBIT(fModConfig, eCbmTrdModuleDef::kTrd2d) : CLRBIT(fModConfig, eCbmTrdModuleDef::kTrd2d);
+  }
+
 protected:
+  /** 8 bits bit map for module configuration
+   * [0] - chamber's pad-plane type; 0 rectangular pads, 1 triangular pads, \see SetRO
+   * [1] - chamber's FEE type; 0 SPADIC, 1 FASP, \see SetFEE
+   * [2] -  
+   * [3] -  
+   * [4] -  
+   * [5] -  
+   * [6] -  
+   * [7] -  
+   */
+  uint8_t fModConfig;
   // geometrical definitions imported from CbmTrdGeoHandler
   UShort_t fModAddress;  ///< unique identifier for current module
   Char_t fLayerId;       ///< layer identifier
-- 
GitLab