From 573d6f314f1782db84b5033ac4d27884237df290 Mon Sep 17 00:00:00 2001 From: Guillaume Pronost Date: Fri, 10 Apr 2026 12:14:41 +0900 Subject: [PATCH] Final github commit --- .gitignore | 8 +- .../DataModel-lite/Constants/Mass.hpp | 0 .../DataModel-lite/Constants/Suffix.hpp | 0 .../DataModel-lite/Constants/Units.hpp | 0 .../DataModel-lite/Constants/mPMTs.hpp | 0 .../DataModel-lite/Enums/DetectorID.hpp | 0 .../DataModel-lite/Enums/PMTType.hpp | 0 .../DataModel-lite/HKDarkNoise.cpp | 0 .../DataModel-lite/HKDarkNoise.hpp | 53 ++- DataManager/DataModel-lite/HKDarkNoiseV1.cpp | 35 ++ .../DataModel-lite/HKDarkNoiseV1.hpp | 63 +++- .../DataModel-lite/HKGeometry.cpp | 0 .../DataModel-lite/HKGeometry.hpp | 0 .../DataModel-lite/HKGeometryPMT.cpp | 0 .../DataModel-lite/HKGeometryPMT.hpp | 34 +- .../DataModel-lite/HKGeometryPMTV1.cpp | 2 + .../DataModel-lite/HKGeometryPMTV1.hpp | 19 +- .../DataModel-lite/HKGeometryV1.cpp | 0 .../DataModel-lite/HKGeometryV1.hpp | 0 .../DataModel-lite/HKHit.cpp | 0 .../DataModel-lite/HKHit.hpp | 0 .../DataModel-lite/HKHitV1.cpp | 0 .../DataModel-lite/HKHitV1.hpp | 0 .../DataModel-lite/HKObject.cpp | 0 .../DataModel-lite/HKObject.hpp | 0 .../DataModel-lite/LinkDef.h | 0 {leaf => DataManager}/GNUmakefile | 18 +- {leaf => DataManager}/HKManager.cpp | 0 {leaf => DataManager}/HKManager.hpp | 0 LEAF/GNUmakefile | 91 +++++ {leaf => LEAF}/LEAF.cpp | 0 {leaf => LEAF}/LEAF.hpp | 24 +- LEAF/LEAFConfig.cpp | 126 +++++++ LEAF/LEAFConfig.hpp | 76 ++++ {leaf => LEAF}/LEAFSrcFitter.cpp | 101 +++-- {leaf => LEAF}/LEAFSrcInputs.cpp | 0 {leaf => LEAF}/LEAFSrcLikelihoods.cpp | 0 {leaf => LEAF}/LEAFUtilities.cpp | 0 {leaf => LEAF}/LEAFUtilities.hpp | 0 LEAF/LinkDef.h | 8 + {leaf => LEAF}/SplineUtilities.cpp | 0 {leaf => LEAF}/SplineUtilities.hpp | 0 example/GNUmakefile | 7 +- example/env.sh | 2 +- leaf/DataModel-lite/HKDarkNoiseV1.cpp | 25 -- leaf/DataModel-lite/HKGeometryPMT copy.hpp | 351 ------------------ leaf/LEAFConfig.hpp | 200 ---------- leaf/LinkDef.h | 3 - 48 files changed, 539 insertions(+), 707 deletions(-) rename {leaf => DataManager}/DataModel-lite/Constants/Mass.hpp (100%) rename {leaf => DataManager}/DataModel-lite/Constants/Suffix.hpp (100%) rename {leaf => DataManager}/DataModel-lite/Constants/Units.hpp (100%) rename {leaf => DataManager}/DataModel-lite/Constants/mPMTs.hpp (100%) rename {leaf => DataManager}/DataModel-lite/Enums/DetectorID.hpp (100%) rename {leaf => DataManager}/DataModel-lite/Enums/PMTType.hpp (100%) rename {leaf => DataManager}/DataModel-lite/HKDarkNoise.cpp (100%) rename {leaf => DataManager}/DataModel-lite/HKDarkNoise.hpp (65%) create mode 100644 DataManager/DataModel-lite/HKDarkNoiseV1.cpp rename {leaf => DataManager}/DataModel-lite/HKDarkNoiseV1.hpp (58%) rename {leaf => DataManager}/DataModel-lite/HKGeometry.cpp (100%) rename {leaf => DataManager}/DataModel-lite/HKGeometry.hpp (100%) rename {leaf => DataManager}/DataModel-lite/HKGeometryPMT.cpp (100%) rename {leaf => DataManager}/DataModel-lite/HKGeometryPMT.hpp (93%) rename {leaf => DataManager}/DataModel-lite/HKGeometryPMTV1.cpp (92%) rename {leaf => DataManager}/DataModel-lite/HKGeometryPMTV1.hpp (90%) rename {leaf => DataManager}/DataModel-lite/HKGeometryV1.cpp (100%) rename {leaf => DataManager}/DataModel-lite/HKGeometryV1.hpp (100%) rename {leaf => DataManager}/DataModel-lite/HKHit.cpp (100%) rename {leaf => DataManager}/DataModel-lite/HKHit.hpp (100%) rename {leaf => DataManager}/DataModel-lite/HKHitV1.cpp (100%) rename {leaf => DataManager}/DataModel-lite/HKHitV1.hpp (100%) rename {leaf => DataManager}/DataModel-lite/HKObject.cpp (100%) rename {leaf => DataManager}/DataModel-lite/HKObject.hpp (100%) rename {leaf => DataManager}/DataModel-lite/LinkDef.h (100%) rename {leaf => DataManager}/GNUmakefile (90%) rename {leaf => DataManager}/HKManager.cpp (100%) rename {leaf => DataManager}/HKManager.hpp (100%) create mode 100755 LEAF/GNUmakefile rename {leaf => LEAF}/LEAF.cpp (100%) rename {leaf => LEAF}/LEAF.hpp (88%) create mode 100644 LEAF/LEAFConfig.cpp create mode 100644 LEAF/LEAFConfig.hpp rename {leaf => LEAF}/LEAFSrcFitter.cpp (93%) rename {leaf => LEAF}/LEAFSrcInputs.cpp (100%) rename {leaf => LEAF}/LEAFSrcLikelihoods.cpp (100%) rename {leaf => LEAF}/LEAFUtilities.cpp (100%) rename {leaf => LEAF}/LEAFUtilities.hpp (100%) create mode 100644 LEAF/LinkDef.h rename {leaf => LEAF}/SplineUtilities.cpp (100%) rename {leaf => LEAF}/SplineUtilities.hpp (100%) delete mode 100644 leaf/DataModel-lite/HKDarkNoiseV1.cpp delete mode 100644 leaf/DataModel-lite/HKGeometryPMT copy.hpp delete mode 100644 leaf/LEAFConfig.hpp delete mode 100644 leaf/LinkDef.h diff --git a/.gitignore b/.gitignore index 08756f9..5d89fce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ .vscode +build-*/ +install-*/ +__pycache__/ + *.o *.swp *.log @@ -7,9 +11,7 @@ example/analysis example/analysis_fullrec example/data example/*.root -leaf/DataModelRootDict* -leaf/HKAstroAnalysis.* -leaf/DataModel +DataManager/DataModelRootDict* lib/* job.sh Config.sh \ No newline at end of file diff --git a/leaf/DataModel-lite/Constants/Mass.hpp b/DataManager/DataModel-lite/Constants/Mass.hpp similarity index 100% rename from leaf/DataModel-lite/Constants/Mass.hpp rename to DataManager/DataModel-lite/Constants/Mass.hpp diff --git a/leaf/DataModel-lite/Constants/Suffix.hpp b/DataManager/DataModel-lite/Constants/Suffix.hpp similarity index 100% rename from leaf/DataModel-lite/Constants/Suffix.hpp rename to DataManager/DataModel-lite/Constants/Suffix.hpp diff --git a/leaf/DataModel-lite/Constants/Units.hpp b/DataManager/DataModel-lite/Constants/Units.hpp similarity index 100% rename from leaf/DataModel-lite/Constants/Units.hpp rename to DataManager/DataModel-lite/Constants/Units.hpp diff --git a/leaf/DataModel-lite/Constants/mPMTs.hpp b/DataManager/DataModel-lite/Constants/mPMTs.hpp similarity index 100% rename from leaf/DataModel-lite/Constants/mPMTs.hpp rename to DataManager/DataModel-lite/Constants/mPMTs.hpp diff --git a/leaf/DataModel-lite/Enums/DetectorID.hpp b/DataManager/DataModel-lite/Enums/DetectorID.hpp similarity index 100% rename from leaf/DataModel-lite/Enums/DetectorID.hpp rename to DataManager/DataModel-lite/Enums/DetectorID.hpp diff --git a/leaf/DataModel-lite/Enums/PMTType.hpp b/DataManager/DataModel-lite/Enums/PMTType.hpp similarity index 100% rename from leaf/DataModel-lite/Enums/PMTType.hpp rename to DataManager/DataModel-lite/Enums/PMTType.hpp diff --git a/leaf/DataModel-lite/HKDarkNoise.cpp b/DataManager/DataModel-lite/HKDarkNoise.cpp similarity index 100% rename from leaf/DataModel-lite/HKDarkNoise.cpp rename to DataManager/DataModel-lite/HKDarkNoise.cpp diff --git a/leaf/DataModel-lite/HKDarkNoise.hpp b/DataManager/DataModel-lite/HKDarkNoise.hpp similarity index 65% rename from leaf/DataModel-lite/HKDarkNoise.hpp rename to DataManager/DataModel-lite/HKDarkNoise.hpp index 03e8cbd..2b4ba01 100644 --- a/leaf/DataModel-lite/HKDarkNoise.hpp +++ b/DataManager/DataModel-lite/HKDarkNoise.hpp @@ -10,8 +10,8 @@ #include #include -#include "HKObject.hpp" #include "Enums/PMTType.hpp" +#include "HKObject.hpp" /************************************************ * HKDarkNoise class definition @@ -27,7 +27,7 @@ class HKDarkNoise : public HKObject { */ HKDarkNoise(HKDarkNoise* in); - virtual ~HKDarkNoise() = 0; //!< Destructor + virtual ~HKDarkNoise() = 0; //!< Destructor virtual void Reset() = 0; //!< Reset function, called after each event virtual unsigned int GetVersion() const = 0; //!< Return the class version number @@ -41,44 +41,63 @@ class HKDarkNoise : public HKObject { // v1 functions - //! Return average total number of dark noise hit in 1ns for a given PMT type + //! Initialize dark noise vector for a given PMT type + /*! + \param in PMTType. PMT type (ID, OD, mPMT) + \param number int. Number of PMTs + */ + virtual bool Initialize(PMTType in, int number) { return false; } + + //! Return average total number of dark noise hit in 1ns for a given PMT type //! Note: the value is ~ N_PMT * darknoise_per_PMT * 1e-9 /*! \param in PMTType. PMT type (ID, OD, mPMT) */ - virtual double GetAverageTotalDarkNoisePerNS(PMTType in) const { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0.0); + virtual double GetAverageTotalDarkNoisePerNS(PMTType in) const { + return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0.0); } - - //! Set average total number of dark noise hit in 1ns for a given PMT type + + //! Set average total number of dark noise hit in 1ns for a given PMT type //! Note: the value is ~ N_PMT * darknoise_per_PMT * 1e-9 /*! \param in PMTType. PMT type (ID, OD, mPMT) \param noise double. Average total dark noise hit */ - virtual bool SetAverageTotalDarkNoisePerNS(PMTType in, double noise) { - return false; - } + virtual bool SetAverageTotalDarkNoisePerNS(PMTType in, double noise) { return false; } //! Return dark noise rate for a given PMT in Hz /*! \param in PMTType. PMT type (ID, OD, mPMT) - \param num int. Channel number + \param num int. Channel number */ - virtual double GetDarkNoiseHz(PMTType in, int num) const { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0.0); + virtual double GetDarkNoiseHz(PMTType in, int num) const { + return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0.0); } - + //! Set dark noise value for a given PMT type in Hz /*! \param in PMTType. PMT type (ID, OD, mPMT) - \param num int. Channel number + \param num int. Channel number \param noise double. Dark noise value in Hz */ - virtual bool SetDarkNoiseHz(PMTType in, int num, double noise) { - return false; + virtual bool SetDarkNoiseHz(PMTType in, int num, double noise) { return false; } + + //! Return dark noise vector for a given PMT type + /*! + \param in PMTType. PMT type (ID, OD, mPMT) + \return std::vector. Dark noise values in Hz + */ + virtual const std::vector GetDarkNoiseVectorHz(PMTType in) const { + return HKFormatError::ThrowErrorVersion>(__PRETTY_FUNCTION__, std::vector()); } + //! Set dark noise vector for a given PMT type + /*! + \param in PMTType. PMT type (ID, OD, mPMT) + \param noise std::vector. Dark noise values in Hz + */ + virtual bool SetDarkNoiseVectorHz(PMTType in, const std::vector& noise) { return false; } + ClassDef(HKDarkNoise, 1); //!< ROOT Class definition }; diff --git a/DataManager/DataModel-lite/HKDarkNoiseV1.cpp b/DataManager/DataModel-lite/HKDarkNoiseV1.cpp new file mode 100644 index 0000000..4580e13 --- /dev/null +++ b/DataManager/DataModel-lite/HKDarkNoiseV1.cpp @@ -0,0 +1,35 @@ +#include "HKDarkNoiseV1.hpp" + +HKDarkNoiseV1::HKDarkNoiseV1() { + m_avg_dark_noise[static_cast(PMTType::kID)] = 0.0; + m_avg_dark_noise[static_cast(PMTType::kOD)] = 0.0; + m_avg_dark_noise[static_cast(PMTType::kmPMT)] = 0.0; + + this->Reset(); +} + +HKDarkNoiseV1::HKDarkNoiseV1(HKDarkNoise* in) { + // Load variable here: + + // v1 copies + m_avg_dark_noise[static_cast(PMTType::kID)] = in->GetAverageTotalDarkNoisePerNS(PMTType::kID); + m_avg_dark_noise[static_cast(PMTType::kOD)] = in->GetAverageTotalDarkNoisePerNS(PMTType::kOD); + m_avg_dark_noise[static_cast(PMTType::kmPMT)] = in->GetAverageTotalDarkNoisePerNS(PMTType::kmPMT); + + m_dark_noise[static_cast(PMTType::kID)] = in->GetDarkNoiseVectorHz(PMTType::kID); + m_dark_noise[static_cast(PMTType::kOD)] = in->GetDarkNoiseVectorHz(PMTType::kOD); + m_dark_noise[static_cast(PMTType::kmPMT)] = in->GetDarkNoiseVectorHz(PMTType::kmPMT); +} + +HKDarkNoiseV1::~HKDarkNoiseV1() { + this->Reset(); +} + +void HKDarkNoiseV1::Reset() { + // Initialize variable here: + // Note, reset is called for every new event, so variables needing to be initialized + // once for a full file should be defined in the creator + + // v1 resets + // m_a = 0; +} diff --git a/leaf/DataModel-lite/HKDarkNoiseV1.hpp b/DataManager/DataModel-lite/HKDarkNoiseV1.hpp similarity index 58% rename from leaf/DataModel-lite/HKDarkNoiseV1.hpp rename to DataManager/DataModel-lite/HKDarkNoiseV1.hpp index 1cecd66..40f8c3f 100644 --- a/leaf/DataModel-lite/HKDarkNoiseV1.hpp +++ b/DataManager/DataModel-lite/HKDarkNoiseV1.hpp @@ -25,7 +25,7 @@ class HKDarkNoiseV1 : public HKDarkNoise { HKDarkNoiseV1(HKDarkNoise* in); ~HKDarkNoiseV1() override; //!< Destructor - void Reset() override; //!< Reset function, called after each event. Use it to initialize variable + void Reset() override; //!< Reset function, called after each event. Use it to initialize variable static constexpr unsigned int GetVersionStatic() { return 1; @@ -37,42 +37,73 @@ class HKDarkNoiseV1 : public HKDarkNoise { // v1 functions - //! Return average total number of dark noise hit in 1ns for a given PMT type + //! Initialize dark noise vector for a given PMT type + /*! + \param in PMTType. PMT type (ID, OD, mPMT) + \param number int. Number of PMTs + */ + bool Initialize(PMTType in, int number) override { + m_dark_noise[static_cast(in)].resize(number, 0.0); + return true; + } + + //! Return average total number of dark noise hit in 1ns for a given PMT type //! Note: the value is ~ N_PMT * darknoise_per_PMT * 1e-9 /*! \param in PMTType. PMT type (ID, OD, mPMT) */ - double GetAverageTotalDarkNoisePerNS(PMTType in) const override { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0.0); + double GetAverageTotalDarkNoisePerNS(PMTType in) const override { + return m_avg_dark_noise[static_cast(in)]; } - - //! Set average total number of dark noise hit in 1ns for a given PMT type + + //! Set average total number of dark noise hit in 1ns for a given PMT type //! Note: the value is ~ N_PMT * darknoise_per_PMT * 1e-9 /*! \param in PMTType. PMT type (ID, OD, mPMT) \param noise double. Average total dark noise hit */ bool SetAverageTotalDarkNoisePerNS(PMTType in, double noise) override { - return false; + m_avg_dark_noise[static_cast(in)] = noise; + return true; } //! Return dark noise value for a given PMT in Hz /*! \param in PMTType. PMT type (ID, OD, mPMT) - \param num int. Channel number + \param num int. Channel number */ - double GetDarkNoiseHz(PMTType in, int num) const override { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0.0); + double GetDarkNoiseHz(PMTType in, int num) const override { + return m_dark_noise[static_cast(in)][num]; } - + //! Set dark noise value for a given PMT type in Hz /*! \param in PMTType. PMT type (ID, OD, mPMT) - \param num int. Channel number + \param num int. Channel number \param noise double. Dark noise value in Hz */ bool SetDarkNoiseHz(PMTType in, int num, double noise) override { - return false; + m_dark_noise[static_cast(in)][num] = noise; + return true; + } + + //! Return dark noise vector for a given PMT type + /*! + \param in PMTType. PMT type (ID, OD, mPMT) + \return std::vector. Dark noise values in Hz + */ + const std::vector GetDarkNoiseVectorHz(PMTType in) const override { + return m_dark_noise[static_cast(in)]; + } + + //! Set dark noise vector for a given PMT type + /*! + \param in PMTType. PMT type (ID, OD, mPMT) + \param noise std::vector. Dark noise values in Hz + */ + bool SetDarkNoiseVectorHz(PMTType in, const std::vector& noise) override { + m_dark_noise[static_cast(in)] = noise; + return true; } // define function here: @@ -82,8 +113,10 @@ class HKDarkNoiseV1 : public HKDarkNoise { private: // v1 data members - std::array(PMTType::kNumPMTTypes)> m_avg_dark_noise; // Average dark noise for each PMT type (ID, OD, mPMT) - std::array, static_cast(PMTType::kNumPMTTypes)> m_dark_noise; // Dark noise for each PMT (ID, OD, mPMT). + std::array(PMTType::kNumPMTTypes)> + m_avg_dark_noise; // Average dark noise for each PMT type (ID, OD, mPMT) + std::array, static_cast(PMTType::kNumPMTTypes)> + m_dark_noise; // Dark noise for each PMT (ID, OD, mPMT). ClassDefOverride(HKDarkNoiseV1, 1); //!< ROOT Class definition }; diff --git a/leaf/DataModel-lite/HKGeometry.cpp b/DataManager/DataModel-lite/HKGeometry.cpp similarity index 100% rename from leaf/DataModel-lite/HKGeometry.cpp rename to DataManager/DataModel-lite/HKGeometry.cpp diff --git a/leaf/DataModel-lite/HKGeometry.hpp b/DataManager/DataModel-lite/HKGeometry.hpp similarity index 100% rename from leaf/DataModel-lite/HKGeometry.hpp rename to DataManager/DataModel-lite/HKGeometry.hpp diff --git a/leaf/DataModel-lite/HKGeometryPMT.cpp b/DataManager/DataModel-lite/HKGeometryPMT.cpp similarity index 100% rename from leaf/DataModel-lite/HKGeometryPMT.cpp rename to DataManager/DataModel-lite/HKGeometryPMT.cpp diff --git a/leaf/DataModel-lite/HKGeometryPMT.hpp b/DataManager/DataModel-lite/HKGeometryPMT.hpp similarity index 93% rename from leaf/DataModel-lite/HKGeometryPMT.hpp rename to DataManager/DataModel-lite/HKGeometryPMT.hpp index 79682fb..52a6997 100644 --- a/leaf/DataModel-lite/HKGeometryPMT.hpp +++ b/DataManager/DataModel-lite/HKGeometryPMT.hpp @@ -137,10 +137,23 @@ class HKGeometryPMT : public HKObject { //! Set PMT Orientation /*! - \param x ROOT::Math::XYZVector + \param in ROOT::Math::XYZVector + \return `true` if successful, `false` if not + */ + virtual bool SetOrientation(UNUSED_PARAM ROOT::Math::XYZVector& in) { return false; } + + //! Get PMT Bad flag + /*! + \return bool. Indicate if the PMT is bad or not + */ + virtual bool GetBadFlag() const { return false; } + + //! Set PMT Bad flag + /*! + \param in bool \return `true` if successful, `false` if not */ - virtual bool SetPoSetOrientationsitionInCm(UNUSED_PARAM ROOT::Math::XYZVector& in) { return false; } + virtual bool SetBadFlag(UNUSED_PARAM bool in) { return false; } ClassDef(HKGeometryPMT, 1); //!< ROOT Class definition }; @@ -187,14 +200,15 @@ class HKGeometryPMTCollection : public HKObjectCollection { return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, NULL); } - //! Wrapper for std::vector back() virtual HKGeometryPMT* back() { return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, NULL); } //! Wrapper for std::vector size() - virtual size_t size() const { return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0); } + virtual size_t size() const { + return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0); + } //! Wrapper for std::vector resize() /*! @@ -308,13 +322,11 @@ template class HKGeometryPMTCollectionT : public HKGeometryPMTCollectio /*! \param entries integer. Number of entries */ - void resize(size_t entries) override { - contents->resize(entries); -#ifdef HK_USE_ROOT7 - for (auto& ptr : *contents) { ptr = std::make_unique(); } -#else - for (auto& ptr : *contents) { ptr = std::make_unique(); } -#endif + void resize(size_t entries) override { + contents->resize(entries); + for(auto& ptr : *contents) { + ptr = std::make_unique(); + } } //! Wrapper for std::vector push_back() diff --git a/leaf/DataModel-lite/HKGeometryPMTV1.cpp b/DataManager/DataModel-lite/HKGeometryPMTV1.cpp similarity index 92% rename from leaf/DataModel-lite/HKGeometryPMTV1.cpp rename to DataManager/DataModel-lite/HKGeometryPMTV1.cpp index 7906b39..c8105c7 100644 --- a/leaf/DataModel-lite/HKGeometryPMTV1.cpp +++ b/DataManager/DataModel-lite/HKGeometryPMTV1.cpp @@ -6,6 +6,7 @@ HKGeometryPMTV1::HKGeometryPMTV1() { m_pmt_sub_id = 0; m_pmt_position.SetXYZ(-9999., -9999., -9999.); m_pmt_orientation.SetXYZ(-9999., -9999., -9999.); + m_pmt_bad_flag = false; this->Reset(); } @@ -18,6 +19,7 @@ HKGeometryPMTV1::HKGeometryPMTV1(HKGeometryPMT* in) { m_pmt_sub_id = in->GetSubID(); m_pmt_position = in->GetPositionInCm(); m_pmt_orientation = in->GetOrientation(); + m_pmt_bad_flag = in->GetBadFlag(); } HKGeometryPMTV1::~HKGeometryPMTV1() { diff --git a/leaf/DataModel-lite/HKGeometryPMTV1.hpp b/DataManager/DataModel-lite/HKGeometryPMTV1.hpp similarity index 90% rename from leaf/DataModel-lite/HKGeometryPMTV1.hpp rename to DataManager/DataModel-lite/HKGeometryPMTV1.hpp index 617454f..f9ba9fa 100644 --- a/leaf/DataModel-lite/HKGeometryPMTV1.hpp +++ b/DataManager/DataModel-lite/HKGeometryPMTV1.hpp @@ -147,11 +147,27 @@ class HKGeometryPMTV1 : public HKGeometryPMT { \param x ROOT::Math::XYZVector \return `true` if successful, `false` if not */ - bool SetPoSetOrientationsitionInCm(ROOT::Math::XYZVector& in) override { + bool SetOrientation(ROOT::Math::XYZVector& in) override { m_pmt_orientation = in; return true; } + //! Get PMT Bad flag + /*! + \return bool. Indicate if the PMT is bad or not + */ + bool GetBadFlag() const override { return m_pmt_bad_flag; } + + //! Set PMT Bad flag + /*! + \param in bool + \return `true` if successful, `false` if not + */ + bool SetBadFlag(bool in) override { + m_pmt_bad_flag = in; + return true; + } + private: // v1 data members @@ -160,6 +176,7 @@ class HKGeometryPMTV1 : public HKGeometryPMT { unsigned int m_pmt_sub_id; //!< PMT sub id (0 for 20" or OD PMT, 1-19 for mPMT's 3" PMTs) ROOT::Math::XYZVector m_pmt_position; //!< Position in cm ROOT::Math::XYZVector m_pmt_orientation; //!< Normalized orientation + bool m_pmt_bad_flag; //!< Whether the PMT is bad or not ClassDefOverride(HKGeometryPMTV1, 1); //!< ROOT Class definition }; diff --git a/leaf/DataModel-lite/HKGeometryV1.cpp b/DataManager/DataModel-lite/HKGeometryV1.cpp similarity index 100% rename from leaf/DataModel-lite/HKGeometryV1.cpp rename to DataManager/DataModel-lite/HKGeometryV1.cpp diff --git a/leaf/DataModel-lite/HKGeometryV1.hpp b/DataManager/DataModel-lite/HKGeometryV1.hpp similarity index 100% rename from leaf/DataModel-lite/HKGeometryV1.hpp rename to DataManager/DataModel-lite/HKGeometryV1.hpp diff --git a/leaf/DataModel-lite/HKHit.cpp b/DataManager/DataModel-lite/HKHit.cpp similarity index 100% rename from leaf/DataModel-lite/HKHit.cpp rename to DataManager/DataModel-lite/HKHit.cpp diff --git a/leaf/DataModel-lite/HKHit.hpp b/DataManager/DataModel-lite/HKHit.hpp similarity index 100% rename from leaf/DataModel-lite/HKHit.hpp rename to DataManager/DataModel-lite/HKHit.hpp diff --git a/leaf/DataModel-lite/HKHitV1.cpp b/DataManager/DataModel-lite/HKHitV1.cpp similarity index 100% rename from leaf/DataModel-lite/HKHitV1.cpp rename to DataManager/DataModel-lite/HKHitV1.cpp diff --git a/leaf/DataModel-lite/HKHitV1.hpp b/DataManager/DataModel-lite/HKHitV1.hpp similarity index 100% rename from leaf/DataModel-lite/HKHitV1.hpp rename to DataManager/DataModel-lite/HKHitV1.hpp diff --git a/leaf/DataModel-lite/HKObject.cpp b/DataManager/DataModel-lite/HKObject.cpp similarity index 100% rename from leaf/DataModel-lite/HKObject.cpp rename to DataManager/DataModel-lite/HKObject.cpp diff --git a/leaf/DataModel-lite/HKObject.hpp b/DataManager/DataModel-lite/HKObject.hpp similarity index 100% rename from leaf/DataModel-lite/HKObject.hpp rename to DataManager/DataModel-lite/HKObject.hpp diff --git a/leaf/DataModel-lite/LinkDef.h b/DataManager/DataModel-lite/LinkDef.h similarity index 100% rename from leaf/DataModel-lite/LinkDef.h rename to DataManager/DataModel-lite/LinkDef.h diff --git a/leaf/GNUmakefile b/DataManager/GNUmakefile similarity index 90% rename from leaf/GNUmakefile rename to DataManager/GNUmakefile index 94c9c3f..eba9a81 100755 --- a/leaf/GNUmakefile +++ b/DataManager/GNUmakefile @@ -3,8 +3,8 @@ OSNAME = $(shell uname -s) HOST = $(shell uname -n) OSNAMEMODE = $(OSNAME) -SOURCES = LEAF.cpp -HEADERS = LEAF.hpp +SOURCES = HKManager.cpp +HEADERS = HKManager.hpp include ../Makefile/Makefile.${OSNAME} @@ -28,12 +28,11 @@ LIBS += -L../libWCSIM -lWCSimRoot LIBS += $(shell root-config --libs) -lMinuit LIB_DATAMODEL = ../lib/libDataModelLite.so -LIB_MANAGER = ../lib/libHKManager.so -LIB_FITTER = ../lib/libLEAF.so +LIB_MANAGER = ../lib/libDataManager.so PCM_LIB_DATAMODEL = ../lib/libDataModelLite_rdict.pcm PCM_DATAMODEL = ../lib/DataModelRootDict_rdict.pcm -LIBS_OBJECTS = $(LIB_DATAMODEL) $(LIB_MANAGER) $(LIB_FITTER) +LIBS_OBJECTS = $(LIB_DATAMODEL) $(LIB_MANAGER) DATAMODEL_SOURCES = $(filter-out DataModel-lite/DataModelRootDict.cpp, $(wildcard DataModel-lite/*.cpp)) DATAMODEL_SRC_NOP = $(DATAMODEL_SOURCES:DataModel-lite/%=./%) @@ -56,11 +55,7 @@ DIRECTORY_CHECK: mkdir ../lib; \ fi -# library -$(LIB_FITTER): LEAF.o LEAFUtilities.o SplineUtilities.o - @echo '<< generating ' $@ ' >>' - @$(SOMAKER) $(SOFLAGS) -o $@ $^ $(LIBS) - +# library $(LIB_MANAGER): HKManager.o @echo '<< generating ' $@ ' >>' @$(SOMAKER) $(SOFLAGS) -o $@ $^ $(LIBS) @@ -125,7 +120,8 @@ clean: @echo '<< cleaning >>' @rm -f .depend @rm -f ./*.o - @rm -f ./../lib/lib*.so + @rm -f $(LIB_MANAGER) + @rm -f $(LIB_DATAMODEL) @rm -f ./../lib/*Dict* @rm -f ./../lib/*.pcm @rm -f ./*Dict* diff --git a/leaf/HKManager.cpp b/DataManager/HKManager.cpp similarity index 100% rename from leaf/HKManager.cpp rename to DataManager/HKManager.cpp diff --git a/leaf/HKManager.hpp b/DataManager/HKManager.hpp similarity index 100% rename from leaf/HKManager.hpp rename to DataManager/HKManager.hpp diff --git a/LEAF/GNUmakefile b/LEAF/GNUmakefile new file mode 100755 index 0000000..5aed2f0 --- /dev/null +++ b/LEAF/GNUmakefile @@ -0,0 +1,91 @@ + +OSNAME = $(shell uname -s) +HOST = $(shell uname -n) +OSNAMEMODE = $(OSNAME) + +SOURCES = LEAF.cpp +HEADERS = LEAF.hpp + +include ../Makefile/Makefile.${OSNAME} + +# set compiler options for ROOT +CXXFLAGS_BASE += $(shell root-config --cflags) +CXXFLAGS_BASE += '-fPIC' -Wall -Wpedantic -Wno-long-long -DDATAMODEL_LITE + +CXXFLAGS = $(CXXFLAGS_BASE) -std=c++17 + +ROOT_VERSION = $(shell root-config --version | cut -d'.' -f1,2) +ifeq ($(shell echo "$(ROOT_VERSION) >= 6.0" | bc -l), 1) + HK_USE_ROOT7 = 1 + CXXFLAGS += -DHK_USE_ROOT7 +endif + +INCFLAGS = -I. -I$(shell root-config --incdir) +INCFLAGS += -I../libWCSIM/include +INCFLAGS += -I../DataManager/DataModel-lite + +LIBS += -L../libWCSIM -lWCSimRoot +LIBS += $(shell root-config --libs) -lMinuit + +LIB_FITTER = ../lib/libLEAF.so + +LIBS_OBJECTS = $(LIB_FITTER) + +all: .depend ROOT_CHECK DIRECTORY_CHECK $(LIBS_OBJECTS) + +ROOT_CHECK: +ifeq ($(HK_USE_ROOT7),1) + @echo '<< compile with ROOT7 >>' +else + @echo '<< compile with old ROOT >>' + @echo $(DATAMODEL_SOURCES) +endif + +DIRECTORY_CHECK: + @if [ ! -d ../lib ]; then \ + mkdir ../lib; \ + fi + +# library +$(LIB_FITTER): LEAF.o LEAFConfig.o LEAFUtilities.o SplineUtilities.o + @echo '<< generating ' $@ ' >>' + @$(SOMAKER) $(SOFLAGS) -o $@ $^ $(LIBS) + +# default rules +.cc.o: + @echo '<< compiling' $< '>>' + @$(CXX) $(CXXFLAGS) $(INCFLAGS) -c $< + +.cpp.o: + @echo '<< compiling' $< '>>' + @$(CXX) $(CXXFLAGS) $(INCFLAGS) -c $< + +%.o: %.cc %.hh + @echo '<< compiling' $< '>>' + @$(CXX) $(CXXFLAGS) $(INCFLAGS) -c -o $@ $< + +%.o: %.cpp %.hpp + @echo '<< compiling' $< '>>' + @$(CXX) $(CXXFLAGS) $(INCFLAGS) -c -o $@ $< + +%.o: %.C %.h + @echo '<< compiling' $< '>>' + @$(CXX) $(CXXFLAGS) $(INCFLAGS) -c -o $@ $< + + +################################################### +# auto-generate dependencies using g++ -M +.depend: $(SOURCES) $(HEADERS) + @#rm .depend + @echo '<< checking dependencies >>' + @g++ -M $(CXXFLAGS) $(INCFLAGS) $(SOURCES) > .depend + +-include .depend + +# cleaner +clean: + @echo '<< cleaning >>' + @rm -f .depend + @rm -f ./*.o + @rm -f $(LIB_FITTER) + diff --git a/leaf/LEAF.cpp b/LEAF/LEAF.cpp similarity index 100% rename from leaf/LEAF.cpp rename to LEAF/LEAF.cpp diff --git a/leaf/LEAF.hpp b/LEAF/LEAF.hpp similarity index 88% rename from leaf/LEAF.hpp rename to LEAF/LEAF.hpp index 898e7c1..e906789 100644 --- a/leaf/LEAF.hpp +++ b/LEAF/LEAF.hpp @@ -62,7 +62,6 @@ #include #include - #include "Constants/mPMTs.hpp" #include "Enums/PMTType.hpp" #include "HKGeometry.hpp" @@ -73,8 +72,6 @@ #include "LEAFUtilities.hpp" #include "SplineUtilities.hpp" -std::mutex mtx; - namespace LEAFStructures { struct FitterOutput { @@ -121,18 +118,17 @@ namespace LEAFStructures { } namespace LEAFThreads { - void SearchVertex_thread(int iStart, int iIte, int tolerance=1, bool likelihood=false, double lowerLimit=LEAFConfig::fSTimePDFLimitsQueueNegative, double upperLimit=LEAFConfig::fSTimePDFLimitsQueuePositive, int directionality=false); - void MinimizeVertex_thread(int iStart, int iIte, std::vector initialVertex, ROOT::Math::XYZTVector limits, double stepSize, int nCandidates = 1, int tolerance = 1, int verbose=0, bool likelihood=false, bool average=false, double lowerLimit=LEAFConfig::fSTimePDFLimitsQueueNegative, double upperLimit=LEAFConfig::fSTimePDFLimitsQueuePositive, int directionality = true, float FilterThreshold = 180); + void SearchVertex_thread(int iStart, int iIte, int tolerance, bool likelihood, double lowerLimit, double upperLimit, int directionality); + void MinimizeVertex_thread(int iStart, int iIte, std::vector initialVertex, ROOT::Math::XYZTVector limits, double stepSize, int nCandidates, int tolerance, int verbose, bool likelihood, bool average, double lowerLimit, double upperLimit, int directionality, float FilterThreshold); }; namespace LEAFLikelihoods { - void MinuitDirNLL(int& nDim, double* gout, double& NLL, double* par, int flg); - void MinuitLikelihood(int& nDim, double * gout, double & NLL, double par[], int flg); - void MinuitJointNLL(int& nDim, double * gout, double & NLL, double par[], int flg); + void MinuitDirNLL(int& nDim, double* gout, double& NLL, double* par, int flg); + void MinuitLikelihood(int& nDim, double * gout, double & NLL, double par[], int flg); + void MinuitJointNLL(int& nDim, double * gout, double & NLL, double par[], int flg); }; -class LEAF -{ +class LEAF { public: static LEAF* GetME(); void DeleteME(); @@ -175,8 +171,8 @@ class LEAF /* VERTEX FITTER */ /*****************/ - void SearchVertex_thread(int iStart, int iIte, int tolerance=1, bool likelihood=false, double lowerLimit=LEAFConfig::fSTimePDFLimitsQueueNegative, double upperLimit=LEAFConfig::fSTimePDFLimitsQueuePositive, int directionality=false); - void MinimizeVertex_thread(int iStart, int iIte, std::vector initialVertex, ROOT::Math::XYZTVector limits, double stepSize, int nCandidates = 1, int tolerance = 1, int verbose=0, bool likelihood=false, bool average=false, double lowerLimit=LEAFConfig::fSTimePDFLimitsQueueNegative, double upperLimit=LEAFConfig::fSTimePDFLimitsQueuePositive, int directionality = true, float FilterThreshold = 180); + void SearchVertex_thread(int iStart, int iIte, int tolerance, bool likelihood, double lowerLimit, double upperLimit, int directionality); + void MinimizeVertex_thread(int iStart, int iIte, std::vector initialVertex, ROOT::Math::XYZTVector limits, double stepSize, int nCandidates, int tolerance , int verbose, bool likelihood, bool average, double lowerLimit, double upperLimit, int directionality, float FilterThreshold); /***************/ /* LIKELIHOODS */ @@ -200,7 +196,7 @@ class LEAF double GoodnessOfFit(ROOT::Math::XYZTVector vertexPosition, double NLL_theory, double lowerLimit, double upperLimit, bool killEdges, bool scaleDR, int directionality); - private: + public: /*******************/ /* INTERNAL STRUCT */ @@ -268,7 +264,7 @@ class LEAF std::vector SearchVertex_Main(int tolerance, bool likelihood, double lowerLimit, double upperLimit, int directionality); //? Second Step Parallelized version - std::vector MinimizeVertex_Main(std::vector initialVertex, ROOT::Math::XYZTVector limits, double stepSize, int nCandidates = 1, int tolerance = 1, int verbose=0, bool likelihood=false, bool average=false, double lowerLimit=LEAFConfig::fSTimePDFLimitsQueueNegative, double upperLimit=LEAFConfig::fSTimePDFLimitsQueuePositive, int directionality = true, float FilterThreshold = 180); + std::vector MinimizeVertex_Main(std::vector initialVertex, ROOT::Math::XYZTVector limits, double stepSize, int nCandidates, int tolerance, int verbose, bool likelihood, bool average, double lowerLimit, double upperLimit, int directionality, float FilterThreshold); /********************/ /* DIRECTION FITTER */ diff --git a/LEAF/LEAFConfig.cpp b/LEAF/LEAFConfig.cpp new file mode 100644 index 0000000..918ba09 --- /dev/null +++ b/LEAF/LEAFConfig.cpp @@ -0,0 +1,126 @@ +#include "LEAFConfig.hpp" + +std::mutex LEAFConfig::mtx = std::mutex(); + +double LEAFConfig::fTankRadius = 0.0; +double LEAFConfig::fTankHeight = 0.0; +double LEAFConfig::fTankHalfHeight = 0.0; + +bool LEAFConfig::fStepByStep = false; // Step by step mode was not test and is not supported by multithreading +bool LEAFConfig::fUseDirectionality = false; +bool LEAFConfig::fHighEnergy = false; +bool LEAFConfig::fDoubleNLL = true; + +// If true, we apply same cuts for timing as B&L PMT when searching vertex. +// Otherwise, we do not apply them and use all the hits. +// The latter is particularly useful when directionality is added, as it can kill DR hits. +bool LEAFConfig::fLimit_mPMT = true; + +double LEAFConfig::fDirectionPDF_maxResidual = 15.0; +double LEAFConfig::fDirectionPDF_minResidual = -5.0; + +double LEAFConfig::fSTimePDFLimitsQueueNegative = -3.; //-5;//-3;//-1.5;//-3;//-10; +double LEAFConfig::fSTimePDFLimitsQueuePositive = 4.; // 10;//4;//3;//4;//500; +double LEAFConfig::fSTimePDFLimitsQueueNegative_fullTimeWindow = 0.; //-1.5;//-3;//-10; +double LEAFConfig::fSTimePDFLimitsQueuePositive_fullTimeWindow = 0.; // 3;//4;//500; +double LEAFConfig::fTimeWindowSizeFull = 1500; +int LEAFConfig::fAveraging = 20; // Number of points we used to average the vertex on. + +double LEAFConfig::fMinimizeLimitsNegative = -700; +double LEAFConfig::fMinimizeLimitsPositive = 1000; + +double LEAFConfig::fHitTimeLimitsNegative = -5; //-10;//-5;//-5 //-5 +double LEAFConfig::fHitTimeLimitsPositive = 7; // 15;//7;//7 //7 + +double LEAFConfig::fSearchVtxStep = 300; // in cm, the step size for coarse grid search + +double LEAFConfig::fSearchVtxTolerance = 60; // Number of candidate vertex that are kept after coarse grid search + +double LEAFConfig::fIntegrationTimeWindow = 50; // in ns //? never Used ??? +bool LEAFConfig::fDirTakeAll = false; +double LEAFConfig::fThetaStep = 5 * TMath::DegToRad(); +double LEAFConfig::fPhiStep = 5 * TMath::DegToRad(); +int LEAFConfig::fDirTolerance = 50; +double LEAFConfig::fLightSpeed = C_WATER_CM_NS; +double LEAFConfig::fPDFNorm_fullTimeWindow = 0.; +std::vector LEAFConfig::fActivePMTTypes = {PMTType::kID}; +//std::vector LEAFConfig::fActivePMTTypes = {PMTType::kID, PMTType::kmPMT}; + +void LEAFConfig::Initialize(double lTankRadius, double lTankHeight) { + // Only write change here: + + fTankRadius = lTankRadius; + fTankHeight = lTankHeight; + fTankHalfHeight = fTankHeight / 2.; + + //*** These maps describe what will be loaded from the config file given */ + + std::map envVariables = { + {"SearchVtxStep", &fSearchVtxStep}, + {"SearchVtxTolerance", &fSearchVtxTolerance}, + {"HitTimeLimitsNegative", &fHitTimeLimitsNegative}, + {"HitTimeLimitsPositive", &fHitTimeLimitsPositive}, + {"MinimizeLimitsNegative", &fMinimizeLimitsNegative}, + {"MinimizeLimitsPositive", &fMinimizeLimitsPositive}, + {"IntegrationTimeWindow", &fIntegrationTimeWindow}, + {"TimeWindowSizeFull", &fTimeWindowSizeFull}, + {"STimePDFLimitsQueueNegative", &fSTimePDFLimitsQueueNegative}, + {"STimePDFLimitsQueuePositive", &fSTimePDFLimitsQueuePositive}, + {"STimePDFLimitsQueueNegative_fullTimeWindow", &fSTimePDFLimitsQueueNegative_fullTimeWindow}, + {"STimePDFLimitsQueuePositive_fullTimeWindow", &fSTimePDFLimitsQueuePositive_fullTimeWindow}, + {"DirectionPDF_maxResidual", &fDirectionPDF_maxResidual}, + {"DirectionPDF_minResidual", &fDirectionPDF_minResidual}, + {"ThetaStep", &fThetaStep}, + {"PhiStep", &fPhiStep} + }; + + std::map envIntVariables = { + {"Averaging", &fAveraging}, + {"DirTolerance", &fDirTolerance} + }; + + std::map envBoolVariables = { + {"Limit_mPMT", &fLimit_mPMT}, + {"UseDirectionality", &fUseDirectionality}, + {"StepByStep", &fStepByStep}, + {"HighEnergy", &fHighEnergy}, + {"DoubleNLL", &fDoubleNLL}, + {"DirTakeAll", &fDirTakeAll}, + }; + + for (const auto& [envName, variable] : envVariables) { + const char* envValue = std::getenv(envName.c_str()); + if (envValue != nullptr) { + *variable = std::stod(envValue); + std::cout << envName << " is set to " << *variable << std::endl; + } + else std::cout << "Environment variable " << envName << " is not set. Using default value : "<< *variable << std::endl; + } + + for (const auto& [envName, variable] : envIntVariables) { + const char* envValue = std::getenv(envName.c_str()); + if (envValue != nullptr) { + *variable = std::stoi(envValue); + std::cout << envName << " is set to " << *variable << std::endl; + } + else std::cout << "Environment variable " << envName << " is not set. Using default value : "<< *variable << std::endl; + } + + for (const auto& [envName, variable] : envBoolVariables) { + const char* envValue = std::getenv(envName.c_str()); + if (envValue != nullptr) { + std::string valueStr(envValue); + if (valueStr == "true" || valueStr == "1") { + *variable = true; + std::cout << envName << " is set to true" << std::endl; + } + else if (valueStr == "false" || valueStr == "0") { + *variable = false; + std::cout << envName << " is set to false" << std::endl; + } + else std::cout << "Environment variable " << envName << " has an invalid value. Using default value : "<< *variable << std::endl; + } + else std::cout << "Environment variable " << envName << " is not set. Using default value : "<< *variable << std::endl; + } + +} \ No newline at end of file diff --git a/LEAF/LEAFConfig.hpp b/LEAF/LEAFConfig.hpp new file mode 100644 index 0000000..5195290 --- /dev/null +++ b/LEAF/LEAFConfig.hpp @@ -0,0 +1,76 @@ +#ifndef LEAFCONFIG_HPP +#define LEAFCONFIG_HPP + +#include +#include +#include +#include +#include +#include "Enums/PMTType.hpp" + +#define VERBOSE 0 + +#undef VERBOSE_NLL // In Likelihood Computation + +#define N_THREAD 2 // Default for sukap +#ifndef C_WATER_CM_NS +#define C_WATER_CM_NS 21.849964 // light celerity in water, in centimeter per ns. +#endif + + +class LEAFConfig { + + public: + static std::mutex mtx; + + //* Geometry & Constants + static double fTankRadius; + static double fTankHeight; + static double fTankHalfHeight; + static double fLightSpeed; + + //* PDFs + static double fSTimePDFLimitsQueueNegative; + static double fSTimePDFLimitsQueuePositive; + static double fSTimePDFLimitsQueueNegative_fullTimeWindow; + static double fSTimePDFLimitsQueuePositive_fullTimeWindow; + static double fPDFNorm_fullTimeWindow; + + static double fDirectionPDF_maxResidual; + static double fDirectionPDF_minResidual; + + //* Overall Fit Parameters + static double fTimeWindowSizeFull; + static double fIntegrationTimeWindow; + static bool fStepByStep; + static bool fUseDirectionality; + static bool fDoubleNLL; + static bool fLimit_mPMT; + static int fAveraging; + static bool fHighEnergy; + static double fSearchVtxStep; + static double fSearchVtxTolerance; + + //* Step 1 Specific Parameters + static double fHitTimeLimitsNegative; + static double fHitTimeLimitsPositive; + + //* Step 2 Specific Parameters + static double fMinimizeLimitsNegative; + static double fMinimizeLimitsPositive; + + //* Direction Fit Parameters + static bool fDirTakeAll; + static double fThetaStep; + static double fPhiStep; + static int fDirTolerance; + + //! List of active PMT types + static std::vector fActivePMTTypes; + + static void Initialize(double lTankRadius, double lTankHeight); + + +}; // class LEAFConfig + +#endif \ No newline at end of file diff --git a/leaf/LEAFSrcFitter.cpp b/LEAF/LEAFSrcFitter.cpp similarity index 93% rename from leaf/LEAFSrcFitter.cpp rename to LEAF/LEAFSrcFitter.cpp index b5a6358..1a2952c 100644 --- a/leaf/LEAFSrcFitter.cpp +++ b/LEAF/LEAFSrcFitter.cpp @@ -50,15 +50,15 @@ ROOT::Math::XYZVector LEAF::FitDirection(const ROOT::Math::XYZTVector& vertex, b //? To be removed for real data where true dir is not known, no impact on the fit // fOutput.stepOneContainsTrueDir = (int)ContainsTrueDir(&candidates, fTrueDir); //* a quick check to see if the step one works (one of the candidate is near the true direction) - if (verbose >= 2) { - for (unsigned int j = 0; j < candidates.size(); j++) { + if (verbose >= 2) { + for (unsigned int j = 0; j < candidates.size(); j++) { std::cout << "Candidate " << "theta = " << candidates[j].theta * TMath::RadToDeg() << " deg, " << "phi = " << candidates[j].phi * TMath::RadToDeg() << " deg, " << "NLL = " << candidates[j].nll << std::endl; } - } + } DirectionCandidate finalCandidate = this->MinimizeDirection(vertex, candidates, limits, verbose); @@ -68,7 +68,7 @@ ROOT::Math::XYZVector LEAF::FitDirection(const ROOT::Math::XYZTVector& vertex, b fPerformances.dir_minimize_ct = timer2.RealTime(); - return fOutput.dir; + return fOutput.dir; } ROOT::Math::XYZVector LEAF::FitDirectionQuick(const ROOT::Math::XYZTVector& vertex) { @@ -117,20 +117,20 @@ std::vector LEAF::SearchDirection(const ROOT::Math::XY { std::vector candidates; - // Grid search over theta and phi - for (double theta = 0.0; theta <= TMath::Pi(); theta += LEAFConfig::fThetaStep) { - for (double phi = -TMath::Pi(); phi < TMath::Pi(); phi += LEAFConfig::fPhiStep) { - // Store the candidate - DirectionCandidate candidate; - candidate.theta = theta; - candidate.phi = phi; - candidate.nll = this->Dir_NLL(vertex, theta, phi); - candidates.push_back(candidate); - } - } + // Grid search over theta and phi + for (double theta = 0.0; theta <= TMath::Pi(); theta += LEAFConfig::fThetaStep) { + for (double phi = -TMath::Pi(); phi < TMath::Pi(); phi += LEAFConfig::fPhiStep) { + // Store the candidate + DirectionCandidate candidate; + candidate.theta = theta; + candidate.phi = phi; + candidate.nll = this->Dir_NLL(vertex, theta, phi); + candidates.push_back(candidate); + } + } - std::sort(candidates.begin(), candidates.end(), LEAF::SortingNLL()); + std::sort(candidates.begin(), candidates.end(), LEAF::SortingNLL()); // Select the best candidates based on tolerance while((int)candidates.size() > tolerance) candidates.pop_back(); @@ -140,24 +140,23 @@ std::vector LEAF::SearchDirection(const ROOT::Math::XY //MIGRAD Optimization LEAF::DirectionCandidate LEAF::MinimizeDirection(const ROOT::Math::XYZTVector& vertex, std::vector& candidates, ROOT::Math::XYZTVector limits, int verbose) { - // Create a minimizer - TFitter* minimizer = new TFitter(7); // 2 parameters: theta, phi - TMinuit* minuit = minimizer->GetMinuit(); + // Create a minimizer + TFitter* minimizer = new TFitter(7); // 2 parameters: theta, phi + TMinuit* minuit = minimizer->GetMinuit(); - double arglist[10]; - int err = 0; - double p1 = verbose - 1; - minimizer->ExecuteCommand("SET PRINTOUT", &p1, 1); - minuit->SetErrorDef(1); + double arglist[10]; + int err = 0; + double p1 = verbose - 1; + minimizer->ExecuteCommand("SET PRINTOUT", &p1, 1); + minuit->SetErrorDef(1); - if (verbose < 2) minuit->mnexcm("SET NOWarnings", 0, 0, err); + if (verbose < 2) minuit->mnexcm("SET NOWarnings", 0, 0, err); - arglist[0] = 2; - minuit->mnexcm("SET STR", arglist, 1, err); - minimizer->SetFCN(LEAFLikelihoods::MinuitDirNLL); + arglist[0] = 2; + minuit->mnexcm("SET STR", arglist, 1, err); + minimizer->SetFCN(LEAFLikelihoods::MinuitDirNLL); - for (int icand = 0; icand < (int)candidates.size(); icand++) - { + for (int icand = 0; icand < (int)candidates.size(); icand++) { // Set initial parameters and bounds minimizer->SetParameter(0, "theta", candidates[icand].theta, 2*TMath::Pi()/180, 0.0, TMath::Pi()); minimizer->SetParameter(1, "phi", candidates[icand].phi, 2*TMath::Pi()/180, -TMath::Pi(), TMath::Pi()); @@ -191,11 +190,11 @@ LEAF::DirectionCandidate LEAF::MinimizeDirection(const ROOT::Math::XYZTVector& v } std::sort(candidates.begin(), candidates.end(), LEAF::SortingNLL()); - // Optional: Print the refined parameters - // if (verbose >= 2) std::cout << "After refinement: theta = " << optimizedParameters[0] * TMath::RadToDeg() << " deg, phi = " << optimizedParameters[1] * TMath::RadToDeg() << " deg" << std::endl; + // Optional: Print the refined parameters + // if (verbose >= 2) std::cout << "After refinement: theta = " << optimizedParameters[0] * TMath::RadToDeg() << " deg, phi = " << optimizedParameters[1] * TMath::RadToDeg() << " deg" << std::endl; - delete minimizer; - return candidates[0]; // Returns [theta, phi] + delete minimizer; + return candidates[0]; // Returns [theta, phi] } @@ -256,12 +255,11 @@ std::vector LEAF::SearchVertex_Main(int tolerance, int iCand_Step = (int)fPositionList.size()/fThread; if(iCand_Step < 1) iCand_Step = 1; - mtx.lock(); + LEAFConfig::mtx.lock(); fVtxThreadOutput.clear(); - mtx.unlock(); + LEAFConfig::mtx.unlock(); - for(int iStart=0; iStart<(int)fPositionList.size(); iStart+=iCand_Step) - { + for(int iStart=0; iStart<(int)fPositionList.size(); iStart+=iCand_Step) { std::thread tThrd( LEAFThreads::SearchVertex_thread, iStart, iCand_Step, @@ -276,10 +274,10 @@ std::vector LEAF::SearchVertex_Main(int tolerance, for(auto &th: lThreadList) if(th.joinable()) th.join(); // 2) collect partial results from fThreadOutput. - mtx.lock(); + LEAFConfig::mtx.lock(); lOutputFinal = fVtxThreadOutput; fVtxThreadOutput.clear(); - mtx.unlock(); + LEAFConfig::mtx.unlock(); // 3) Sort by NLL and keep 'tolerance' number of candidates std::sort(lOutputFinal.begin(), lOutputFinal.end(), LEAF::SortingNLL()); @@ -338,24 +336,23 @@ void LEAF::SearchVertex_thread(int iStart, int iIte, int tolerance, bool likelih // Check if mutex is already lock, if not -> lock // We don't want simultaneous modification of the common output - mtx.lock(); + LEAFConfig::mtx.lock(); for (unsigned int iPos = 0; iPos < tVtxContainer.size(); iPos++) { fVtxThreadOutput.push_back(tVtxContainer[iPos]); } - mtx.unlock(); + LEAFConfig::mtx.unlock(); } -std::vector LEAF::MinimizeVertex_Main(std::vector initialVertex, ROOT::Math::XYZTVector limits, double stepSize, int nCandidates, int tolerance, int verbose, bool likelihood, bool average, double lowerLimit, double upperLimit, int directionality, float FilterThreshold) -{ +std::vector LEAF::MinimizeVertex_Main(std::vector initialVertex, ROOT::Math::XYZTVector limits, double stepSize, int nCandidates, int tolerance, int verbose, bool likelihood, bool average, double lowerLimit, double upperLimit, int directionality, float FilterThreshold) { std::vector lThreadList; std::vector lOutputFinal; int iCand_Step = nCandidates / fThread; if (iCand_Step < 1) iCand_Step = 1; - mtx.lock(); + LEAFConfig::mtx.lock(); fVtxThreadOutput.clear(); - mtx.unlock(); + LEAFConfig::mtx.unlock(); for (int iStart = 0; iStart < nCandidates; iStart += iCand_Step) { std::thread tThrd(LEAFThreads::MinimizeVertex_thread, iStart, iCand_Step, @@ -369,10 +366,10 @@ std::vector LEAF::MinimizeVertex_Main(std::vector< // Check if mutex is already lock, if not -> lock // We don't want simultaneous modification of the common output - mtx.lock(); + LEAFConfig::mtx.lock(); lOutputFinal = fVtxThreadOutput; fVtxThreadOutput.clear(); - mtx.unlock(); + LEAFConfig::mtx.unlock(); std::sort(lOutputFinal.begin(), lOutputFinal.end(), LEAF::SortingNLL()); @@ -392,9 +389,9 @@ void LEAF::MinimizeVertex_thread(int iStart, int iIte, std::vector tVtxContainer; - mtx.lock(); + LEAFConfig::mtx.lock(); TFitter *minimizer = new TFitter(14); // 4=nb de params? - mtx.unlock(); + LEAFConfig::mtx.unlock(); TMinuit *minuit = minimizer->GetMinuit(); double arglist[20]; @@ -498,12 +495,12 @@ void LEAF::MinimizeVertex_thread(int iStart, int iIte, std::vector lock // We don't want simultaneous modification of the common output - mtx.lock(); + LEAFConfig::mtx.lock(); for (unsigned int iPos = 0; iPos < tVtxContainer.size(); iPos++) { fVtxThreadOutput.push_back(tVtxContainer[iPos]); } delete minimizer; - mtx.unlock(); + LEAFConfig::mtx.unlock(); } diff --git a/leaf/LEAFSrcInputs.cpp b/LEAF/LEAFSrcInputs.cpp similarity index 100% rename from leaf/LEAFSrcInputs.cpp rename to LEAF/LEAFSrcInputs.cpp diff --git a/leaf/LEAFSrcLikelihoods.cpp b/LEAF/LEAFSrcLikelihoods.cpp similarity index 100% rename from leaf/LEAFSrcLikelihoods.cpp rename to LEAF/LEAFSrcLikelihoods.cpp diff --git a/leaf/LEAFUtilities.cpp b/LEAF/LEAFUtilities.cpp similarity index 100% rename from leaf/LEAFUtilities.cpp rename to LEAF/LEAFUtilities.cpp diff --git a/leaf/LEAFUtilities.hpp b/LEAF/LEAFUtilities.hpp similarity index 100% rename from leaf/LEAFUtilities.hpp rename to LEAF/LEAFUtilities.hpp diff --git a/LEAF/LinkDef.h b/LEAF/LinkDef.h new file mode 100644 index 0000000..2c6e3b2 --- /dev/null +++ b/LEAF/LinkDef.h @@ -0,0 +1,8 @@ +#ifdef __CINT__ + #pragma link C++ namespace LEAFConfig + ; + #pragma link C++ namespace LEAFUtilities + ; + #pragma link C++ namespace SplineUtilities + ; + #pragma link C++ namespace LEAFLikelihoods + ; + #pragma link C++ namespace LEAFStructures + ; + #pragma link C++ class LEAF+; +#endif diff --git a/leaf/SplineUtilities.cpp b/LEAF/SplineUtilities.cpp similarity index 100% rename from leaf/SplineUtilities.cpp rename to LEAF/SplineUtilities.cpp diff --git a/leaf/SplineUtilities.hpp b/LEAF/SplineUtilities.hpp similarity index 100% rename from leaf/SplineUtilities.hpp rename to LEAF/SplineUtilities.hpp diff --git a/example/GNUmakefile b/example/GNUmakefile index 28a8b73..4593d43 100644 --- a/example/GNUmakefile +++ b/example/GNUmakefile @@ -17,13 +17,14 @@ endif INCFLAGS = -I. #INCFLAGS += -I$(shell root-config --incdir) #included in --cflags INCFLAGS += -I$(LEAFDIR)/libWCSIM/include -INCFLAGS += -I$(LEAFDIR)/leaf -INCFLAGS += -I$(LEAFDIR)/leaf/DataModel-lite +INCFLAGS += -I$(LEAFDIR)/LEAF +INCFLAGS += -I$(LEAFDIR)/DataManager/ +INCFLAGS += -I$(LEAFDIR)/DataManager/DataModel-lite LIBS += -L$(LEAFDIR)/libWCSIM -lWCSimRoot LIBS += $(shell root-config --libs) -lMinuit # LIBS_BONSAI += -L${BONSAIDIR} -lWCSimBonsai -LIBS_LEAF += -L${LEAFDIR}/lib -lLEAF -lHKManager -lDataModelLite +LIBS_LEAF += -L${LEAFDIR}/lib -lLEAF -lDataManager -lDataModelLite OBJECT = analysis analysis_fullrec diff --git a/example/env.sh b/example/env.sh index d388c56..3d0b67b 100644 --- a/example/env.sh +++ b/example/env.sh @@ -1,6 +1,6 @@ export LEAFDIR=../ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LEAFDIR/lib -export ROOT_INCLUDE_PATH=${LEAFDIR}/leaf/DataModel-lite +export ROOT_INCLUDE_PATH=${LEAFDIR}/LEAF/DataModel-lite export WCSIMDIR=${LEAFDIR}/libWCSIM export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$WCSIMDIR \ No newline at end of file diff --git a/leaf/DataModel-lite/HKDarkNoiseV1.cpp b/leaf/DataModel-lite/HKDarkNoiseV1.cpp deleted file mode 100644 index 30393e9..0000000 --- a/leaf/DataModel-lite/HKDarkNoiseV1.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "HKDarkNoiseV1.hpp" - -HKDarkNoiseV1::HKDarkNoiseV1() { - this->Reset(); -} - -HKDarkNoiseV1::HKDarkNoiseV1(HKDarkNoise* in) { - // Load variable here: - - // v1 copies - // m_a = in->GetA(); -} - -HKDarkNoiseV1::~HKDarkNoiseV1() { - this->Reset(); -} - -void HKDarkNoiseV1::Reset() { - // Initialize variable here: - // Note, reset is called for every new event, so variables needing to be initialized - // once for a full file should be defined in the creator - - // v1 resets - // m_a = 0; -} diff --git a/leaf/DataModel-lite/HKGeometryPMT copy.hpp b/leaf/DataModel-lite/HKGeometryPMT copy.hpp deleted file mode 100644 index 1634ed9..0000000 --- a/leaf/DataModel-lite/HKGeometryPMT copy.hpp +++ /dev/null @@ -1,351 +0,0 @@ -#ifndef HK_GEOMETRYPMT_HPP -#define HK_GEOMETRYPMT_HPP - -/************************************************* - * HKGeometryPMT.hpp - * - Author: T. Dealtry - * - Date: 2024/11/14 - ************************************************/ - -#include -#include -#include - -#include "Enums/PMTType.hpp" -#include "HKObject.hpp" - -/************************************************ - * HKGeometryPMT class definition - ***********************************************/ -class HKGeometryPMT : public HKObject { - public: - - HKGeometryPMT(); //!< Constructor - - //! Create HKGeometryPMT from an HKGeometryPMT pointor - /*! - \param in HKGeometryPMT* - */ - HKGeometryPMT(HKGeometryPMT* in); - - virtual ~HKGeometryPMT() = 0; //!< Destructor - virtual void Reset() = 0; //!< Reset function, called after each event - virtual unsigned int GetVersion() const = 0; //!< Return the class version number - - static std::string GetBaseNameStatic() { - return "HKGeometryPMT"; - } //!< Static function. Return the class base name - - std::string GetBaseName() const { - return HKGeometryPMT::GetBaseNameStatic(); - } //!< Return the class base name - - // v1 functions - //! Get PMTSoftwareID - /*! - \return unsigned int - */ - virtual unsigned int GetPMTSoftwareID() const { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0); - } - - //! Set PMTSoftwareID - /*! - \param in unsigned int - \return `true` if successful, `false` if not - */ - virtual bool SetPMTSoftwareID(UNUSED_PARAM unsigned int in) { return false; } - - //! Get PMT Type - /*! - \return PMTType - */ - virtual PMTType GetType() const { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, PMTType::kUndefined); - } - - //! Set PMT Type - /*! - \param in PMTType - \return `true` if successful, `false` if not - */ - virtual bool SetType(UNUSED_PARAM PMTType in) { return false; } - - //! Get sub ID - /*! - Return the PMT sub ID number. 0 for 20" PMT and OD PMT. 1-19 for mPMT's 3" PMTs - \return unsigned int - */ - virtual unsigned int GetSubID() const { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0); - } - - //! Set sub ID - /*! - Set the PMT sub ID number. 0 for 20" PMT and OD PMT. 1-19 for mPMT's 3" PMTs - \param in unsigned int - \return `true` if successful, `false` if not - */ - virtual bool SetSubID(UNUSED_PARAM unsigned int in) { return false; } - - //! Get PMT Position in cm - /*! - \return ROOT::Math::XYZVector. position over [x,y,z] - */ - virtual ROOT::Math::XYZVector GetPositionInCm() const { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, - ROOT::Math::XYZVector()); - } - - //! Set PMT Position in cm - /*! - \param x double - \param y double - \param z double - \return `true` if successful, `false` if not - */ - virtual bool SetPositionInCm(UNUSED_PARAM double x, UNUSED_PARAM double y, UNUSED_PARAM double z) { - return false; - } - - //! Set PMT Position in cm - /*! - \param x ROOT::Math::XYZVector - \return `true` if successful, `false` if not - */ - virtual bool SetPositionInCm(UNUSED_PARAM ROOT::Math::XYZVector& in) { return false; } - - //! Get PMT Orientation - /*! - \return ROOT::Math::XYZVector. orientation over [x,y,z] - */ - virtual ROOT::Math::XYZVector GetOrientation() const { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, - ROOT::Math::XYZVector()); - } - - //! Set PMT Orientation - /*! - \param x double - \param y double - \param z double - \return `true` if successful, `false` if not - */ - virtual bool SetOrientation(UNUSED_PARAM double x, UNUSED_PARAM double y, UNUSED_PARAM double z) { - return false; - } - - //! Set PMT Orientation - /*! - \param x ROOT::Math::XYZVector - \return `true` if successful, `false` if not - */ - virtual bool SetPoSetOrientationsitionInCm(UNUSED_PARAM ROOT::Math::XYZVector& in) { return false; } - - ClassDef(HKGeometryPMT, 1); //!< ROOT Class definition -}; - -/************************************************ - * HKGeometryPMTCollection base class definition - * - * Collection class wrapping a vector of HKGeometryPMT - ***********************************************/ -class HKGeometryPMTCollection : public HKObjectCollection { - public: - - HKGeometryPMTCollection() {} //!< Creator - - virtual ~HKGeometryPMTCollection() = 0; //!< Destructor - virtual void Reset() = 0; //!< Reset function, called after each event - virtual unsigned int GetVersion() const = 0; //!< Return the contained class version number - - static std::string GetBaseNameStatic() { - return "HKGeometryPMTCollection"; - } //!< Static function. Return the class base name - - std::string GetBaseName() const { - return HKGeometryPMTCollection::GetBaseNameStatic(); - } //!< Return the class base name - - //! operator [] - /*! - \param i integer. Entry index - */ - virtual HKGeometryPMT* operator[](UNUSED_PARAM int i) { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, NULL); - } - - //! Wrapper for std::vector at() - /*! - \param i integer. Entry index - */ - virtual HKGeometryPMT* at(UNUSED_PARAM int i) { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, NULL); - } - - virtual const HKGeometryPMT* at(UNUSED_PARAM int i) const { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, NULL); - } - - - //! Wrapper for std::vector back() - virtual HKGeometryPMT* back() { - return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, NULL); - } - - //! Wrapper for std::vector size() - virtual size_t size() const { return HKFormatError::ThrowErrorVersion(__PRETTY_FUNCTION__, 0); } - - //! Wrapper for std::vector resize() - /*! - \param entries integer. Number of entries - */ - virtual void resize(UNUSED_PARAM size_t entries) { return; } - - //! Wrapper for std::vector push_back() - /*! - \param in HKGeometryPMT*. Object to be inserted - */ - virtual void push_back(UNUSED_PARAM HKGeometryPMT* in) { return; } - - //! Wrapper for std::vector emplace_back() - /*! - \param in HKGeometryPMT*. Object to be inserted - */ - virtual void emplace_back(UNUSED_PARAM HKGeometryPMT* in) { return; } - - //! Emplace back an HKGeometryPMT instance in the collection - virtual void AddGeometryPMT() { return; } - - private: - -#ifndef HK_USE_ROOT7 - //! Return the pointor to the unique_ptr - virtual std::unique_ptr > >* GetVectorUniquePointor() { - return HKFormatError::ThrowErrorVersion< - std::unique_ptr > >*>(__PRETTY_FUNCTION__, NULL); - } - - //! Return the pointor to the vector - virtual std::vector >* GetVectorPointor() { - return HKFormatError::ThrowErrorVersion >*>( - __PRETTY_FUNCTION__, - NULL); - } - - template friend class HKBranchManagerCollection; -#endif - - ClassDef(HKGeometryPMTCollection, 1); //!< Class definition for ROOT -}; - -/************************************************ - * HKGeometryPMTCollectionTemplate definition - * - * Collection class wrapping a vector of HKGeometryPMT - ***********************************************/ -template class HKGeometryPMTCollectionT : public HKGeometryPMTCollection { - - static_assert(std::is_base_of::value, "T must inherit from HKGeometryPMT"); - - public: - - HKGeometryPMTCollectionT(bool initialize = true) { - if(initialize) { -#ifdef HK_USE_ROOT7 - contents = std::make_shared > >(); -#else - contents = std::make_unique > >(); -#endif - this->Reset(); - } - } //!< Creator - - //! Constructor. Initialize the collection with specified number of entries - /*! - \param entries integer. Number of entries - */ - HKGeometryPMTCollectionT(size_t entries) { - this->Reset(); - this->resize(entries); - } - - ~HKGeometryPMTCollectionT() override { this->Reset(); } //!< Destructor - - void Reset() override { - contents->clear(); - } //!< Reset function, called after each event. Clear the collection. - - static constexpr unsigned int GetVersionStatic() { - return T::GetVersionStatic(); - } //!< Static function. Return the contained class version number - - unsigned int GetVersion() const override { - return T::GetVersionStatic(); - } //!< Return the contained class version number - - //! operator [] - /*! - \param i integer. Entry index - */ - HKGeometryPMT* operator[](int i) override { return (*contents)[i].get(); } // Use at(i) here too? - - //! Wrapper for std::vector at() - /*! - \param i integer. Entry index - */ - HKGeometryPMT* at(int i) override { return contents->at(i).get(); } - - const HKGeometryPMT* at(int i) const { return contents->at(i).get(); } - - //! Wrapper for std::vector back() - HKGeometryPMT* back() override { return contents->back().get(); } - - //! Wrapper for std::vector size() - size_t size() const override { return contents->size(); } - - //! Wrapper for std::vector resize() - /*! - \param entries integer. Number of entries - */ - void resize(size_t entries) override { contents->resize(entries); } - - //! Wrapper for std::vector push_back() - /*! - \param in HKGeometryPMT*. Object to be inserted - */ - void push_back(HKGeometryPMT* in) override { contents->push_back(std::make_unique(in)); } - - //! Wrapper for std::vector emplace_back() - /*! - \param in HKGeometryPMT*. Object to be inserted - */ - void emplace_back(HKGeometryPMT* in) override { contents->emplace_back(std::make_unique(in)); } - - //! Emplace back an empty HKGeometryPMT instance in the collection - void AddGeometryPMT() override { contents->emplace_back(std::make_unique()); } - - private: - -#ifdef HK_USE_ROOT7 - std::shared_ptr > > contents; //!< Vector of HKGeometryPMT - - template friend class HKDataMemberCollectionCreator; -#else - //! Return the pointor to the unique_ptr - std::unique_ptr > >* GetVectorUniquePointor() override { - return &contents; - } - - //! Return the pointor to the vector - std::vector >* GetVectorPointor() override { return contents.get(); } - - std::unique_ptr > > contents; //!< Vector of HKGeometryPMT - - template friend class HKBranchManagerCollection; -#endif - - ClassDefOverride(HKGeometryPMTCollectionT, 1); //!< Class definition for ROOT -}; - -#endif diff --git a/leaf/LEAFConfig.hpp b/leaf/LEAFConfig.hpp deleted file mode 100644 index f08dcb5..0000000 --- a/leaf/LEAFConfig.hpp +++ /dev/null @@ -1,200 +0,0 @@ -#ifndef LEAFCONFIG_HPP -#define LEAFCONFIG_HPP - -#include -#include -#include -#include -#include "Enums/PMTType.hpp" - -#define VERBOSE 0 - -#undef VERBOSE_VTX // In SearchVertex -#undef VERBOSE_NLL // In Likelihood Computation - -#define VTX_X 0 -#define VTX_Y 1 -#define VTX_Z 2 -#define VTX_T 3 - -#define N_THREAD 2 // Default for sukap -#define C_WATER_CM_NS 21.849964 // light celerity in water, in centimeter per ns. - -namespace LEAFConfig { - - //* Geometry & Constants - double fTankRadius; - double fTankHeight; - double fTankHalfHeight; - double fLightSpeed = C_WATER_CM_NS; - - //* PDFs - double fSTimePDFLimitsQueueNegative = -3.; - double fSTimePDFLimitsQueuePositive = 4.; - double fSTimePDFLimitsQueueNegative_fullTimeWindow = 0.; - double fSTimePDFLimitsQueuePositive_fullTimeWindow = 0.; - double fPDFNorm_fullTimeWindow = 0.; - - double fDirectionPDF_maxResidual = 15.0; - double fDirectionPDF_minResidual = -5.0; - - //* Overall Fit Parameters - double fTimeWindowSizeFull = 1500.; - double fIntegrationTimeWindow = 50.; - bool fStepByStep = false; - bool fUseDirectionality = false; - bool fDoubleNLL = false; - bool fLimit_mPMT = true; - int fAveraging = 20; - bool fHighEnergy = false; - double fSearchVtxStep = 300.; - double fSearchVtxTolerance = 60; - - //* Step 1 Specific Parameters - double fHitTimeLimitsNegative = -5; - double fHitTimeLimitsPositive = -7; - - //* Step 2 Specific Parameters - double fMinimizeLimitsNegative = -700; - double fMinimizeLimitsPositive = 1000; - - //* Direction Fit Parameters - bool fDirTakeAll = false; - double fThetaStep = 5 * TMath::DegToRad(); - double fPhiStep = 5 * TMath::DegToRad(); - int fDirTolerance = 50; - - //! List of active PMT types - std::vector fActivePMTTypes; - - void Initialize(double lTankRadius, double lTankHeight) { - fTankRadius = lTankRadius; - fTankHeight = lTankHeight; - fTankHalfHeight = fTankHeight / 2.; - - fStepByStep = false; // Step by step mode was not test and is not supported by multithreading - fUseDirectionality = false; - fHighEnergy = false; - fDoubleNLL = true; - - // If true, we apply same cuts for timing as B&L PMT when searching vertex. - // Otherwise, we do not apply them and use all the hits. - // The latter is particularly useful when directionality is added, as it can kill DR hits. - fLimit_mPMT = true; - - fSTimePDFLimitsQueueNegative = -3.; //-5;//-3;//-1.5;//-3;//-10; - fSTimePDFLimitsQueuePositive = 4.; // 10;//4;//3;//4;//500; - fSTimePDFLimitsQueueNegative_fullTimeWindow = 0.; //-1.5;//-3;//-10; - fSTimePDFLimitsQueuePositive_fullTimeWindow = 0.; // 3;//4;//500; - fTimeWindowSizeFull = 1500; - fAveraging = 20; // Number of points we used to average the vertex on. - - fMinimizeLimitsNegative = -700; - fMinimizeLimitsPositive = 1000; - - fHitTimeLimitsNegative = -5; //-10;//-5;//-5 //-5 - fHitTimeLimitsPositive = 7; // 15;//7;//7 //7 - - fSearchVtxStep = 300; // in cm, the step size for coarse grid search - - fSearchVtxTolerance = 60; // Number of candidate vertex that are kept after coarse grid search - - fIntegrationTimeWindow = 50; // in ns //? never Used ??? - fDirTakeAll = false; - fThetaStep = 5 * TMath::DegToRad(); - fPhiStep = 5 * TMath::DegToRad(); - fDirTolerance = 50; - - //* Compute light speed: - fLightSpeed = C_WATER_CM_NS; - - fPDFNorm_fullTimeWindow = 0.; - - fActivePMTTypes = {PMTType::kID}; - //fActivePMTTypes = {PMTType::kID, PMTType::kmPMT}; - - //*** These maps describe what will be loaded from the config file given */ - - std::map envVariables = - { - {"SearchVtxStep", &fSearchVtxStep}, - {"SearchVtxTolerance", &fSearchVtxTolerance}, - {"HitTimeLimitsNegative", &fHitTimeLimitsNegative}, - {"HitTimeLimitsPositive", &fHitTimeLimitsPositive}, - {"MinimizeLimitsNegative", &fMinimizeLimitsNegative}, - {"MinimizeLimitsPositive", &fMinimizeLimitsPositive}, - {"IntegrationTimeWindow", &fIntegrationTimeWindow}, - {"TimeWindowSizeFull", &fTimeWindowSizeFull}, - {"STimePDFLimitsQueueNegative", &fSTimePDFLimitsQueueNegative}, - {"STimePDFLimitsQueuePositive", &fSTimePDFLimitsQueuePositive}, - {"STimePDFLimitsQueueNegative_fullTimeWindow", &fSTimePDFLimitsQueueNegative_fullTimeWindow}, - {"STimePDFLimitsQueuePositive_fullTimeWindow", &fSTimePDFLimitsQueuePositive_fullTimeWindow}, - {"DirectionPDF_maxResidual", &fDirectionPDF_maxResidual}, - {"DirectionPDF_minResidual", &fDirectionPDF_minResidual}, - {"ThetaStep", &fThetaStep}, - {"PhiStep", &fPhiStep} - }; - - std::map envIntVariables = - { - {"Averaging", &fAveraging}, - {"DirTolerance", &fDirTolerance} - }; - - std::map envBoolVariables = - { - {"Limit_mPMT", &fLimit_mPMT}, - {"UseDirectionality", &fUseDirectionality}, - {"StepByStep", &fStepByStep}, - {"HighEnergy", &fHighEnergy}, - {"DoubleNLL", &fDoubleNLL}, - {"DirTakeAll", &fDirTakeAll}, - }; - - for (const auto& [envName, variable] : envVariables) - { - const char* envValue = std::getenv(envName.c_str()); - if (envValue != nullptr) - { - *variable = std::stod(envValue); - std::cout << envName << " is set to " << *variable << std::endl; - } - else std::cout << "Environment variable " << envName << " is not set. Using default value : "<< *variable << std::endl; - } - - for (const auto& [envName, variable] : envIntVariables) - { - const char* envValue = std::getenv(envName.c_str()); - if (envValue != nullptr) - { - *variable = std::stoi(envValue); - std::cout << envName << " is set to " << *variable << std::endl; - } - else std::cout << "Environment variable " << envName << " is not set. Using default value : "<< *variable << std::endl; - } - - for (const auto& [envName, variable] : envBoolVariables) - { - const char* envValue = std::getenv(envName.c_str()); - if (envValue != nullptr) - { - std::string valueStr(envValue); - if (valueStr == "true" || valueStr == "1") - { - *variable = true; - std::cout << envName << " is set to true" << std::endl; - } - else if (valueStr == "false" || valueStr == "0") - { - *variable = false; - std::cout << envName << " is set to false" << std::endl; - } - else std::cout << "Environment variable " << envName << " has an invalid value. Using default value : "<< *variable << std::endl; - } - else std::cout << "Environment variable " << envName << " is not set. Using default value : "<< *variable << std::endl; - } - - } -}; // namespace LEAFConfig - -#endif \ No newline at end of file diff --git a/leaf/LinkDef.h b/leaf/LinkDef.h deleted file mode 100644 index 0dc23e5..0000000 --- a/leaf/LinkDef.h +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef __MAKECINT__ -#pragma link C++ class BQFitter+; -#endif