From fb406905493099ed5041b9c8934f9a2a797a9f1c Mon Sep 17 00:00:00 2001
From: "P.-A. Loizeau" <p.-a.loizeau@gsi.de>
Date: Fri, 10 Dec 2021 14:06:37 +0100
Subject: [PATCH] Changes to add digi classes of all mCBM dets to non-root
 OnlineData library

---
 algo/data/CMakeLists.txt       | 18 ++++++++++++++++++
 core/data/much/CbmMuchDigi.cxx |  2 ++
 core/data/much/CbmMuchDigi.h   |  6 +++++-
 core/data/psd/CbmPsdDigi.cxx   |  3 ++-
 core/data/psd/CbmPsdDigi.h     |  6 +++++-
 core/data/rich/CbmRichDigi.cxx |  2 ++
 core/data/rich/CbmRichDigi.h   |  6 +++++-
 core/data/tof/CbmTofDigi.cxx   |  3 ++-
 core/data/tof/CbmTofDigi.h     | 10 +++++++---
 core/data/trd/CbmTrdDigi.cxx   | 10 ++++++++++
 core/data/trd/CbmTrdDigi.h     | 16 ++++++++++------
 11 files changed, 68 insertions(+), 14 deletions(-)

diff --git a/algo/data/CMakeLists.txt b/algo/data/CMakeLists.txt
index d2c94ed56b..ddff59ad68 100644
--- a/algo/data/CMakeLists.txt
+++ b/algo/data/CMakeLists.txt
@@ -5,6 +5,19 @@
 set(SRCS
   ${CMAKE_SOURCE_DIR}/core/data/sts/CbmStsDigi.cxx
   ${CMAKE_SOURCE_DIR}/core/data/sts/CbmStsAddress.cxx
+
+  ${CMAKE_SOURCE_DIR}/core/data/rich/CbmRichDigi.cxx
+
+  ${CMAKE_SOURCE_DIR}/core/data/much/CbmMuchDigi.cxx
+  ${CMAKE_SOURCE_DIR}/core/data/much/CbmMuchAddress.cxx
+
+  ${CMAKE_SOURCE_DIR}/core/data/trd/CbmTrdDigi.cxx
+
+  ${CMAKE_SOURCE_DIR}/core/data/tof/CbmTofDigi.cxx
+  ${CMAKE_SOURCE_DIR}/core/data/tof/CbmTofAddress.cxx
+
+  ${CMAKE_SOURCE_DIR}/core/data/psd/CbmPsdDigi.cxx
+  ${CMAKE_SOURCE_DIR}/core/data/psd/CbmPsdAddress.cxx
  )
 
 add_library(OnlineData SHARED ${SRCS})
@@ -13,6 +26,11 @@ target_include_directories(OnlineData
   PUBLIC ${CMAKE_SOURCE_DIR}/core/data
   PUBLIC ${CMAKE_SOURCE_DIR}/core/data/base
   PUBLIC ${CMAKE_SOURCE_DIR}/core/data/sts
+  PUBLIC ${CMAKE_SOURCE_DIR}/core/data/rich
+  PUBLIC ${CMAKE_SOURCE_DIR}/core/data/much
+  PUBLIC ${CMAKE_SOURCE_DIR}/core/data/trd
+  PUBLIC ${CMAKE_SOURCE_DIR}/core/data/tof
+  PUBLIC ${CMAKE_SOURCE_DIR}/core/data/psd
   PUBLIC ${CMAKE_SOURCE_DIR}/core/data/global
   PUBLIC ${CMAKE_SOURCE_DIR}/external/ipc/ipc/lib/fles_ipc
 )
diff --git a/core/data/much/CbmMuchDigi.cxx b/core/data/much/CbmMuchDigi.cxx
index 083c78975e..42adb42a20 100644
--- a/core/data/much/CbmMuchDigi.cxx
+++ b/core/data/much/CbmMuchDigi.cxx
@@ -58,4 +58,6 @@ void CbmMuchDigi::SetAdc(int32_t adc)
 void CbmMuchDigi::SetTime(uint64_t time) { fTime = time; }
 // -------------------------------------------------------------------------
 
+#ifndef NO_ROOT
 ClassImp(CbmMuchDigi)
+#endif
diff --git a/core/data/much/CbmMuchDigi.h b/core/data/much/CbmMuchDigi.h
index dabf02b971..06129d7631 100644
--- a/core/data/much/CbmMuchDigi.h
+++ b/core/data/much/CbmMuchDigi.h
@@ -23,7 +23,9 @@
 #include "CbmDefs.h"         // for kMuch
 #include "CbmMuchAddress.h"  // for CbmMuchAddress, kMuchModule
 
+#ifndef NO_ROOT
 #include <Rtypes.h>      // for ClassDef
+#endif
 
 #include <boost/serialization/access.hpp>
 #include <boost/serialization/base_object.hpp>
@@ -121,6 +123,8 @@ private:
   bool fSaturationFlag =
     0;  //If adc value crosses the Maximum Adc value of actual electronics then SaturationFlag will be set.
 
-  ClassDef(CbmMuchDigi, 4);
+#ifndef NO_ROOT
+  ClassDefNV(CbmMuchDigi, 4);
+#endif
 };
 #endif
diff --git a/core/data/psd/CbmPsdDigi.cxx b/core/data/psd/CbmPsdDigi.cxx
index f4c72e2c51..c790ae4b5b 100644
--- a/core/data/psd/CbmPsdDigi.cxx
+++ b/core/data/psd/CbmPsdDigi.cxx
@@ -41,5 +41,6 @@ std::string CbmPsdDigi::ToString() const
   return string.Data();
 }
 
-
+#ifndef NO_ROOT
 ClassImp(CbmPsdDigi)
+#endif
diff --git a/core/data/psd/CbmPsdDigi.h b/core/data/psd/CbmPsdDigi.h
index 9e2b4519e4..403e65683b 100644
--- a/core/data/psd/CbmPsdDigi.h
+++ b/core/data/psd/CbmPsdDigi.h
@@ -22,7 +22,9 @@
 #include "CbmDefs.h"        // for ECbmModuleId::kPsd
 #include "CbmPsdAddress.h"  // for CbmPsdAddress
 
-#include <Rtypes.h>      // for THashConsistencyHolder, ClassDefNV
+#ifndef NO_ROOT
+#include <Rtypes.h>  // for ClassDefNV
+#endif
 
 #include <boost/serialization/access.hpp>
 #include <boost/serialization/base_object.hpp>
@@ -163,7 +165,9 @@ private:
     ar& fdEdep;
   }
 
+#ifndef NO_ROOT
   ClassDefNV(CbmPsdDigi, 5);
+#endif
 };
 
 #endif  // CBMPSDDIGI_H
diff --git a/core/data/rich/CbmRichDigi.cxx b/core/data/rich/CbmRichDigi.cxx
index 78cd2bdec1..590be77fb7 100644
--- a/core/data/rich/CbmRichDigi.cxx
+++ b/core/data/rich/CbmRichDigi.cxx
@@ -25,4 +25,6 @@ CbmRichDigi::~CbmRichDigi()
   // TODO Auto-generated destructor stub
 }
 
+#ifndef NO_ROOT
 ClassImp(CbmRichDigi)
+#endif
diff --git a/core/data/rich/CbmRichDigi.h b/core/data/rich/CbmRichDigi.h
index 42c0d429c4..cae69fe761 100644
--- a/core/data/rich/CbmRichDigi.h
+++ b/core/data/rich/CbmRichDigi.h
@@ -15,7 +15,9 @@
 
 #include "CbmDefs.h"  // for kRich
 
+#ifndef NO_ROOT
 #include <Rtypes.h>      // for ClassDef
+#endif
 
 #include <boost/serialization/access.hpp>
 #include <boost/serialization/base_object.hpp>
@@ -100,7 +102,7 @@ private:
   double fTime;
 
   /**
-	 * \brief Time-over-threshold, pulse width. 
+	 * \brief Time-over-threshold, pulse width.
    * This variable is only used in real data analysis, for the simulation it is set to 0.
 	 */
   double fToT;
@@ -115,7 +117,9 @@ private:
     ar& fToT;
   }
 
+#ifndef NO_ROOT
   ClassDefNV(CbmRichDigi, 3);
+#endif
 };
 
 #endif /* DATA_RICH_CBMRICHDIGI_H_ */
diff --git a/core/data/tof/CbmTofDigi.cxx b/core/data/tof/CbmTofDigi.cxx
index f310ab2b3d..3f31bcc036 100644
--- a/core/data/tof/CbmTofDigi.cxx
+++ b/core/data/tof/CbmTofDigi.cxx
@@ -51,5 +51,6 @@ void CbmTofDigi::SetAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_
   fuAddress = CbmTofAddress::GetUniqueAddress(Sm, Rpc, Channel, Side, SmType);
 }
 
-
+#ifndef NO_ROOT
 ClassImp(CbmTofDigi)
+#endif
diff --git a/core/data/tof/CbmTofDigi.h b/core/data/tof/CbmTofDigi.h
index c412c7cee0..99febb4a8c 100644
--- a/core/data/tof/CbmTofDigi.h
+++ b/core/data/tof/CbmTofDigi.h
@@ -17,9 +17,9 @@
  ** Calibrated Time [ps]:          32 bits double
  ** Calibrated Tot  [ps]:          32 bits double
  **
- ** In triggered setup, the time is relative to the trigger time, which 
- ** is measured with a resolution of a few ns corresponding to the TDC 
- ** system clock cycle. 
+ ** In triggered setup, the time is relative to the trigger time, which
+ ** is measured with a resolution of a few ns corresponding to the TDC
+ ** system clock cycle.
  ** In free-streaming setups, the time is relative to the last epoch.
  **/
 
@@ -29,7 +29,9 @@
 #include "CbmDefs.h"        // for kTof
 #include "CbmTofAddress.h"  // for CbmTofAddress
 
+#ifndef NO_ROOT
 #include <Rtypes.h>      // for ClassDef
+#endif
 
 #include <boost/serialization/access.hpp>
 #include <boost/serialization/base_object.hpp>
@@ -168,6 +170,8 @@ private:
     ar& fdTot;
   }
 
+#ifndef NO_ROOT
   ClassDefNV(CbmTofDigi, 3);
+#endif
 };
 #endif  // CBMTOFDIGI_H
diff --git a/core/data/trd/CbmTrdDigi.cxx b/core/data/trd/CbmTrdDigi.cxx
index aadc37ae19..736797eb11 100644
--- a/core/data/trd/CbmTrdDigi.cxx
+++ b/core/data/trd/CbmTrdDigi.cxx
@@ -15,6 +15,14 @@
 
 #include <cmath>
 
+#ifdef NO_ROOT
+// Coming from Rtypes.h in ROOT mode
+#define BIT(n) (1ULL << (n))
+#define SETBIT(n, i) ((n) |= BIT(i))
+#define CLRBIT(n, i) ((n) &= ~BIT(i))
+#define TESTBIT(n, i) ((Bool_t)(((n) &BIT(i)) != 0))
+#endif
+
 using std::endl;
 using std::string;
 using std::stringstream;
@@ -308,4 +316,6 @@ string CbmTrdDigi::ToString() const
   return ss.str();
 }
 
+#ifndef NO_ROOT
 ClassImp(CbmTrdDigi)
+#endif
diff --git a/core/data/trd/CbmTrdDigi.h b/core/data/trd/CbmTrdDigi.h
index a0a06f7747..2dee01c61e 100644
--- a/core/data/trd/CbmTrdDigi.h
+++ b/core/data/trd/CbmTrdDigi.h
@@ -7,7 +7,9 @@
 
 #include "CbmDefs.h"  // for kTrd
 
-#include <Rtypes.h>      // for ClassDef
+#ifndef NO_ROOT
+#include <Rtypes.h>  // for CLRBIT, SETBIT, TESTBIT, ClassDef
+#endif
 
 #include <boost/serialization/access.hpp>
 #include <boost/serialization/base_object.hpp>
@@ -81,14 +83,14 @@ public:
 
   /**
    * @brief Copy Construct a new Cbm Trd Digi
-   * 
+   *
    */
   CbmTrdDigi(const CbmTrdDigi&);
 
   /**
    * @brief Assignment operator
-   * 
-   * @return CbmTrdDigi& 
+   *
+   * @return CbmTrdDigi&
   */
   CbmTrdDigi& operator=(const CbmTrdDigi&) = default;
 
@@ -265,13 +267,13 @@ protected:
 
   /**
    * @brief clock length in ns for acquisition
-   * 
+   *
    */
   static const double fgClk[static_cast<size_t>(eCbmTrdAsicType::kNTypes) + 1];
 
   /**
   * @brief Nr. of digits stored for ASIC
-  * 
+  *
   */
   static const float fgPrecission[static_cast<size_t>(eCbmTrdAsicType::kNTypes) + 1];
 
@@ -295,7 +297,9 @@ private:
     ar& fTime;
   }
 
+#ifndef NO_ROOT
   ClassDefNV(CbmTrdDigi, 4);  // Production ready TRD digit
+#endif
 };
 
 #endif
-- 
GitLab