From 14819229bf8963b3eb9d77ebe3fd4d8d45fe880a Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 2 Sep 2024 21:25:53 +0200 Subject: [PATCH 01/68] basic geometry and data format for new detector --- Common/SimConfig/src/SimConfig.cxx | 9 +- .../DetectorsCommonDataFormats/DetID.h | 12 +- DataFormats/Detectors/Upgrades/CMakeLists.txt | 1 + .../Detectors/Upgrades/FVD/CMakeLists.txt | 19 ++ .../Upgrades/FVD/include/DataFormatsFVD/Hit.h | 108 +++++++++ .../Upgrades/FVD/src/DataFormatsFVDLinkDef.h | 21 ++ .../Detectors/Upgrades/FVD/src/Hits.cxx | 0 .../Headers/include/Headers/DataHeader.h | 1 + Detectors/Upgrades/ALICE3/CMakeLists.txt | 3 +- Detectors/Upgrades/ALICE3/FVD/CMakeLists.txt | 13 + Detectors/Upgrades/ALICE3/FVD/README.md | 10 + .../Upgrades/ALICE3/FVD/base/CMakeLists.txt | 19 ++ Detectors/Upgrades/ALICE3/FVD/base/README.md | 17 ++ .../FVD/base/include/FVDBase/FVDBaseParam.h | 34 +++ .../FVD/base/include/FVDBase/GeometryTGeo.h | 81 +++++++ .../ALICE3/FVD/base/src/FVDBaseLinkDef.h | 20 ++ .../ALICE3/FVD/base/src/GeometryTGeo.cxx | 157 ++++++++++++ .../ALICE3/FVD/simulation/CMakeLists.txt | 20 ++ .../include/FVDSimulation/Detector.h | 109 +++++++++ .../ALICE3/FVD/simulation/src/Detector.cxx | 228 ++++++++++++++++++ .../FVD/simulation/src/FVDSimulationLinkDef.h | 21 ++ macro/build_geometry.C | 6 + run/CMakeLists.txt | 1 + 23 files changed, 901 insertions(+), 9 deletions(-) create mode 100644 DataFormats/Detectors/Upgrades/FVD/CMakeLists.txt create mode 100644 DataFormats/Detectors/Upgrades/FVD/include/DataFormatsFVD/Hit.h create mode 100644 DataFormats/Detectors/Upgrades/FVD/src/DataFormatsFVDLinkDef.h create mode 100644 DataFormats/Detectors/Upgrades/FVD/src/Hits.cxx create mode 100644 Detectors/Upgrades/ALICE3/FVD/CMakeLists.txt create mode 100644 Detectors/Upgrades/ALICE3/FVD/README.md create mode 100644 Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt create mode 100644 Detectors/Upgrades/ALICE3/FVD/base/README.md create mode 100644 Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h create mode 100644 Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h create mode 100644 Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h create mode 100644 Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx create mode 100644 Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt create mode 100644 Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h create mode 100644 Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx create mode 100644 Detectors/Upgrades/ALICE3/FVD/simulation/src/FVDSimulationLinkDef.h diff --git a/Common/SimConfig/src/SimConfig.cxx b/Common/SimConfig/src/SimConfig.cxx index 9a10b26547ce6..40a97fae843b4 100644 --- a/Common/SimConfig/src/SimConfig.cxx +++ b/Common/SimConfig/src/SimConfig.cxx @@ -98,7 +98,8 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules[i] != "TF3" && activeModules[i] != "RCH" && activeModules[i] != "MI3" && - activeModules[i] != "ECL") { + activeModules[i] != "ECL" && + activeModules[i] != "FVD") { LOGP(fatal, "List of active modules contains {}, which is not a module from the upgrades.", activeModules[i]); } } @@ -112,7 +113,8 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules[i] == "TF3" || activeModules[i] == "RCH" || activeModules[i] == "MI3" || - activeModules[i] == "ECL") { + activeModules[i] == "ECL" || + activeModules[i] == "FVD") { LOGP(fatal, "List of active modules contains {}, which is not a run 3 module", activeModules[i]); } } @@ -130,6 +132,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs d == DetID::TF3 || d == DetID::RCH || d == DetID::ECL || + d == DetID::FVD || d == DetID::MI3) { activeModules.emplace_back(DetID::getName(d)); } @@ -149,7 +152,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules.emplace_back("SHIL"); for (int d = DetID::First; d <= DetID::Last; ++d) { #ifdef ENABLE_UPGRADES - if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT && d != DetID::TF3 && d != DetID::RCH && d != DetID::ECL && d != DetID::MI3) { + if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT && d != DetID::TF3 && d != DetID::RCH && d != DetID::ECL && d != DetID::FVD && d != DetID::MI3) { activeModules.emplace_back(DetID::getName(d)); } } diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h index a2767c7620cdd..ebcce137d8c2c 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h @@ -87,9 +87,10 @@ class DetID static constexpr ID RCH = 23; static constexpr ID MI3 = 24; static constexpr ID ECL = 25; - static constexpr ID Last = ECL; + static constexpr ID FVD = 26; + static constexpr ID Last = FVD; #else - static constexpr ID Last = FOC; ///< if extra detectors added, update this !!! + static constexpr ID Last = FVD; ///< if extra detectors added, update this !!! #endif static constexpr ID First = ITS; @@ -181,7 +182,7 @@ class DetID // detector names, will be defined in DataSources static constexpr const char* sDetNames[nDetectors + 1] = ///< defined detector names #ifdef ENABLE_UPGRADES - {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", nullptr}; + {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FVD", nullptr}; #else {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", nullptr}; #endif @@ -195,7 +196,7 @@ class DetID #ifdef ENABLE_UPGRADES , o2h::gDataOriginIT3, o2h::gDataOriginTRK, o2h::gDataOriginFT3, o2h::gDataOriginFCT, o2h::gDataOriginTF3, - o2h::gDataOriginRCH, o2h::gDataOriginMI3, o2h::gDataOriginECL + o2h::gDataOriginRCH, o2h::gDataOriginMI3, o2h::gDataOriginECL, o2h::gDataOriginFVD #endif }; #endif // GPUCA_GPUCODE_DEVICE @@ -211,10 +212,11 @@ GPUconstexpr() DetID::mask_t sMasks[DetID::nDetectors] = ///< detectot masks DetID::mask_t(math_utils::bit2Mask(DetID::CPV)), DetID::mask_t(math_utils::bit2Mask(DetID::EMC)), DetID::mask_t(math_utils::bit2Mask(DetID::HMP)), DetID::mask_t(math_utils::bit2Mask(DetID::MFT)), DetID::mask_t(math_utils::bit2Mask(DetID::MCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MID)), DetID::mask_t(math_utils::bit2Mask(DetID::ZDC)), DetID::mask_t(math_utils::bit2Mask(DetID::FT0)), DetID::mask_t(math_utils::bit2Mask(DetID::FV0)), DetID::mask_t(math_utils::bit2Mask(DetID::FDD)), DetID::mask_t(math_utils::bit2Mask(DetID::TST)), DetID::mask_t(math_utils::bit2Mask(DetID::CTP)), DetID::mask_t(math_utils::bit2Mask(DetID::FOC)) + #ifdef ENABLE_UPGRADES , DetID::mask_t(math_utils::bit2Mask(DetID::IT3)), DetID::mask_t(math_utils::bit2Mask(DetID::TRK)), DetID::mask_t(math_utils::bit2Mask(DetID::FT3)), DetID::mask_t(math_utils::bit2Mask(DetID::FCT)), DetID::mask_t(math_utils::bit2Mask(DetID::TF3)), - DetID::mask_t(math_utils::bit2Mask(DetID::RCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MI3)), DetID::mask_t(math_utils::bit2Mask(DetID::ECL)) + DetID::mask_t(math_utils::bit2Mask(DetID::RCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MI3)), DetID::mask_t(math_utils::bit2Mask(DetID::ECL)), DetID::mask_t(math_utils::bit2Mask(DetID::FVD)) #endif }; } // namespace detid_internal diff --git a/DataFormats/Detectors/Upgrades/CMakeLists.txt b/DataFormats/Detectors/Upgrades/CMakeLists.txt index a2d470b8ff6d5..a231c129e931f 100644 --- a/DataFormats/Detectors/Upgrades/CMakeLists.txt +++ b/DataFormats/Detectors/Upgrades/CMakeLists.txt @@ -10,3 +10,4 @@ # or submit itself to any jurisdiction. message(STATUS "Building dataformats for upgrades") +add_subdirectory(FVD) diff --git a/DataFormats/Detectors/Upgrades/FVD/CMakeLists.txt b/DataFormats/Detectors/Upgrades/FVD/CMakeLists.txt new file mode 100644 index 0000000000000..ac3f66e2b7f88 --- /dev/null +++ b/DataFormats/Detectors/Upgrades/FVD/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +o2_add_library(DataFormatsFVD + PUBLIC_LINK_LIBRARIES O2::FVDBase + O2::CommonDataFormat +) + +o2_target_root_dictionary(DataFormatsFVD + HEADERS include/DataFormatsFVD/Hit.h +) diff --git a/DataFormats/Detectors/Upgrades/FVD/include/DataFormatsFVD/Hit.h b/DataFormats/Detectors/Upgrades/FVD/include/DataFormatsFVD/Hit.h new file mode 100644 index 0000000000000..3c9397f8be403 --- /dev/null +++ b/DataFormats/Detectors/Upgrades/FVD/include/DataFormatsFVD/Hit.h @@ -0,0 +1,108 @@ +// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifndef ALICEO2_FVD_HIT_H_ +#define ALICEO2_FVD_HIT_H_ + +#include "SimulationDataFormat/BaseHits.h" // for BasicXYZEHit +#include "CommonUtils/ShmAllocator.h" +#include "TVector3.h" + +namespace o2 +{ +namespace fvd +{ + +class Hit : public o2::BasicXYZEHit +{ + + public: + Hit() = default; + + inline Hit(int trackID, + int cellID, + const math_utils::Point3D& startPos, + const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, + double startE, + double endTime, + double eLoss, + int particlePdg); + + // Entrance position getters + math_utils::Point3D const& GetPosStart() const { return mPositionStart; } + Float_t GetStartX() const { return mPositionStart.X(); } + Float_t GetStartY() const { return mPositionStart.Y(); } + Float_t GetStartZ() const { return mPositionStart.Z(); } + template + void GetStartPosition(F& x, F& y, F& z) const + { + x = GetStartX(); + y = GetStartY(); + z = GetStartZ(); + } + + // Momentum getters + math_utils::Vector3D const& GetMomentum() const { return mMomentumStart; } + + math_utils::Vector3D& GetMomentum() { return mMomentumStart; } + Float_t GetPx() const { return mMomentumStart.X(); } + Float_t GetPy() const { return mMomentumStart.Y(); } + Float_t GetPz() const { return mMomentumStart.Z(); } + Float_t GetE() const { return mEnergyStart; } + + Float_t GetTotalEnergyAtEntrance() const { return GetE(); } + + int GetParticlePdg() const {return mParticlePdg;} + + void Print(const Option_t* opt) const; + + private: + int mParticlePdg; + float mEnergyStart; + math_utils::Vector3D mMomentumStart; ///< momentum at entrance + math_utils::Point3D mPositionStart; + ClassDefNV(Hit, 1); + +}; + +Hit::Hit(int trackID, + int detID, + const math_utils::Point3D& startPos, + const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, + double startE, + double endTime, + double eLoss, + Int_t particlePdg) + : BasicXYZEHit(endPos.X(), + endPos.Y(), + endPos.Z(), + endTime, + eLoss, + trackID, + detID) +{ +} + +} // namespace fvd +} // namespace o2 + +#ifdef USESHM +namespace std +{ +template <> +class allocator : public o2::utils::ShmAllocator +{ +}; +} // namespace std +#endif +#endif diff --git a/DataFormats/Detectors/Upgrades/FVD/src/DataFormatsFVDLinkDef.h b/DataFormats/Detectors/Upgrades/FVD/src/DataFormatsFVDLinkDef.h new file mode 100644 index 0000000000000..6a976734918fe --- /dev/null +++ b/DataFormats/Detectors/Upgrades/FVD/src/DataFormatsFVDLinkDef.h @@ -0,0 +1,21 @@ +// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::fvd::Hit + ; +#pragma link C++ class vector < o2::fvd::Hit> + ; + +#endif diff --git a/DataFormats/Detectors/Upgrades/FVD/src/Hits.cxx b/DataFormats/Detectors/Upgrades/FVD/src/Hits.cxx new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/DataFormats/Headers/include/Headers/DataHeader.h b/DataFormats/Headers/include/Headers/DataHeader.h index 2dbfbd67d8d6c..1f1ae422154f8 100644 --- a/DataFormats/Headers/include/Headers/DataHeader.h +++ b/DataFormats/Headers/include/Headers/DataHeader.h @@ -588,6 +588,7 @@ constexpr o2::header::DataOrigin gDataOriginTF3{"TF3"}; constexpr o2::header::DataOrigin gDataOriginRCH{"RCH"}; constexpr o2::header::DataOrigin gDataOriginMI3{"MI3"}; constexpr o2::header::DataOrigin gDataOriginECL{"ECL"}; // upgrades +constexpr o2::header::DataOrigin gDataOriginFVD{"FVD"}; // upgrades constexpr o2::header::DataOrigin gDataOriginGPU{"GPU"}; diff --git a/Detectors/Upgrades/ALICE3/CMakeLists.txt b/Detectors/Upgrades/ALICE3/CMakeLists.txt index 0c2bbe5e02a47..077cb427b62e5 100644 --- a/Detectors/Upgrades/ALICE3/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/CMakeLists.txt @@ -12,10 +12,11 @@ add_subdirectory(Passive) add_subdirectory(TRK) add_subdirectory(ECal) +add_subdirectory(FVD) add_subdirectory(FT3) add_subdirectory(FCT) add_subdirectory(AOD) add_subdirectory(IOTOF) add_subdirectory(RICH) add_subdirectory(MID) -add_subdirectory(macros) \ No newline at end of file +add_subdirectory(macros) diff --git a/Detectors/Upgrades/ALICE3/FVD/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/CMakeLists.txt new file mode 100644 index 0000000000000..3dde618f9d57a --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +add_subdirectory(base) +add_subdirectory(simulation) diff --git a/Detectors/Upgrades/ALICE3/FVD/README.md b/Detectors/Upgrades/ALICE3/FVD/README.md new file mode 100644 index 0000000000000..7cd905ef2cb22 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/README.md @@ -0,0 +1,10 @@ + + +# ALICE 3 FORVARD DETECTOR + +This is top page for the FVD detector documentation. + + diff --git a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt new file mode 100644 index 0000000000000..a108874226b22 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +o2_add_library(FVDBase + SOURCES src/GeometryTGeo.cxx + PUBLIC_LINK_LIBRARIES O2::DetectorsBase) + +o2_target_root_dictionary(FVDBase + HEADERS include/FVDBase/GeometryTGeo.h + include/FVDBase/FVDBaseParam.h) + diff --git a/Detectors/Upgrades/ALICE3/FVD/base/README.md b/Detectors/Upgrades/ALICE3/FVD/base/README.md new file mode 100644 index 0000000000000..1fba33c47b690 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/base/README.md @@ -0,0 +1,17 @@ + + +# FV0 Base + +## Geometry + +The `o2::fv0::Geometry` class represents the geometry of the FV0 detector as used in simulation. It also provides utility methods for retrieving the center locations of the detector cells. See the below example for how to use the `Geometry` class to query the FV0 cell locations. Note that these are the ideal locations, and that any misalignment is not considered. + +```cpp +o2::fv0::Geometry* fv0Geometry = o2::fv0::Geometry::instance(o2::fv0::Geometry::eUninitialized); +o2::fv0::Point3Dsimple cellPosition = fv0Geometry->getReadoutCenter(chId); +float x = cellPosition.x; +float y = cellPosition.y; +float z = cellPosition.z; +``` diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h new file mode 100644 index 0000000000000..2239a66e81428 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -0,0 +1,34 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file FVDBaseParam.g +/// \brief General constants in FVD +/// +/// \author Maciej Slupecki, University of Jyvaskyla, Finland + +#ifndef ALICEO2_FVD_FVDBASEPARAM_ +#define ALICEO2_FVD_FVDBASEPARAM_ + +#include "FVDBase/GeometryTGeo.h" + +namespace o2 +{ +namespace fvd +{ + +struct FVDBaseParam { + static constexpr int nFvdChannels = GeometryTGeo::getNumberOfReadoutChannels(); + static constexpr int nFvdChannelsPlusRef = nFvdChannels + 1; +}; + +} // namespace fvd +} // namespace o2 +#endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h new file mode 100644 index 0000000000000..6b26079ccddd8 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h @@ -0,0 +1,81 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +#ifndef ALICEO2_FVD_GEOMETRYTGEO_H_ +#define ALICEO2_FVD_GEOMETRYTGEO_H_ + +#include + +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsCommonDataFormats/DetID.h" +#include +#include +#include +#include +#include +#include +#include + +namespace o2 +{ +namespace fvd +{ + +/// FVD Geometry type +class GeometryTGeo : public o2::detectors::DetMatrixCache +{ + public: + GeometryTGeo(); + + void Build() const; + void fillMatrixCache(int mask); + virtual ~GeometryTGeo(); + + static GeometryTGeo* Instance(); + + void getGlobalPosition(float& x, float& y, float& z); + static constexpr int getNumberOfReadoutChannelsA() { return sNumberOfReadoutChannelsA; }; + static constexpr int getNumberOfReadoutChannelsC() { return sNumberOfReadoutChannelsC; }; + static constexpr int getNumberOfReadoutChannels() { return sNumberOfReadoutChannelsA + sNumberOfCellsC; } + + static constexpr o2::detectors::DetID::ID getDetID() { return o2::detectors::DetID::FVD; } + + int getCellId(int nmod, int nring, int nsec) const; + int getCurrentCellId(const TVirtualMC* fMC) const; + + private: + + static constexpr float sDzScintillator = 4; + static constexpr float sXGlobal = 0; + static constexpr float sYGlobal = 0; + static constexpr float sZGlobalA = 1700. - sDzScintillator/2; + static constexpr float sZGlobalC = -1950. + sDzScintillator/2; + + static constexpr int sNumberOfCellSectors = 8; + static constexpr int sNumberOfCellRingsA = 5; // 3 + static constexpr int sNumberOfCellRingsC = 6; + static constexpr int sNumberOfCellsA = sNumberOfCellRingsA * sNumberOfCellSectors; + static constexpr int sNumberOfCellsC = sNumberOfCellRingsC * sNumberOfCellSectors; + static constexpr int sNumberOfReadoutChannelsA = sNumberOfCellsA; + static constexpr int sNumberOfReadoutChannelsC = sNumberOfCellsC; + + static constexpr float sCellRingRadiiA[sNumberOfCellRingsA + 1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; + static constexpr float sCellRingRadiiC[sNumberOfCellRingsC + 1] = {3.5, 17., 30.5, 44., 57.5, 71.}; + + static std::unique_ptr sInstance; + + TGeoVolumeAssembly* buildModuleA() const; + TGeoVolumeAssembly* buildModuleC() const; + + ClassDefNV(GeometryTGeo, 1); +}; +} // namespace fvd +} // namespace o2 +#endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h new file mode 100644 index 0000000000000..8cf0cafc49a9b --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h @@ -0,0 +1,20 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::fvd::GeometryTGeo + ; + +#endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx new file mode 100644 index 0000000000000..f25c7199799cc --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx @@ -0,0 +1,157 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "FVDBase/GeometryTGeo.h" + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace o2::fvd; +namespace o2 +{ +namespace fvd +{ + +std::unique_ptr GeometryTGeo::sInstance; + +GeometryTGeo::GeometryTGeo() : DetMatrixCache() +{ + if (sInstance) { + LOGP(fatal, "Invalid use of public constructor: o2::fvd::GeometryTGeo instance exists"); + } + Build(); +} + +GeometryTGeo::~GeometryTGeo() {} + +void GeometryTGeo::Build() const +{ + // Top volume of FVD detector + // A side + TGeoVolumeAssembly *vFVDA = buildModuleA(); + LOG(info) << "FVD: building geometry. The name of the volume is '" << vFVDA->GetName() << "'"; + + TGeoVolume* vCaveRB24 = gGeoManager->GetVolume("caveRB24"); + if (!vCaveRB24) { + LOG(fatal) << "Could not find the top volume for A-side"; + } + + vCaveRB24->AddNode(vFVDA, 0, new TGeoTranslation(sXGlobal, sYGlobal, sZGlobalA)); + + // C side + TGeoVolume* vCave = gGeoManager->GetVolume("cave"); + if (!vCave) { + LOG(fatal) << "Could not find the top volume for C-side"; + } + + TGeoVolumeAssembly *vFVDC = buildModuleC(); + LOG(info) << "FVD: building geometry. The name of the volume is '" << vFVDC->GetName() << "'"; + + vCave->AddNode(vFVDC, 1, new TGeoTranslation(sXGlobal, sYGlobal, sZGlobalC)); +} + +TGeoVolumeAssembly* GeometryTGeo::buildModuleA() const +{ + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDA"); // A or C + + const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + + const float dphiDeg = 45.; + + for (int ir = 0; ir < sNumberOfCellRingsA; ir++) { + for (int ic = 0; ic < sNumberOfCellSectors; ic ++) { + int cellId = ic + ir; + std::string tbsName = "tbs" + std::to_string(cellId); + std::string nodeName = "node" + std::to_string(cellId); + float rmin = sCellRingRadiiA[ir]; + float rmax = sCellRingRadiiA[ir+1]; + float phimin = dphiDeg; + float phimax = dphiDeg; + auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, sDzScintillator, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + mod->AddNode(nod, cellId); + } + } + + return mod; +} + +TGeoVolumeAssembly* GeometryTGeo::buildModuleC() const +{ + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDC"); // A or C + + const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + + const float dphiDeg = 45.; + + for (int ir = 0; ir < sNumberOfCellRingsC; ir++) { + for (int ic = 0; ic < sNumberOfCellSectors; ic ++) { + int cellId = ic + ir + sNumberOfCellsA; + std::string tbsName = "tbs" + std::to_string(cellId); + std::string nodeName = "node" + std::to_string(cellId); + float rmin = sCellRingRadiiC[ir]; + float rmax = sCellRingRadiiC[ir+1]; + float phimin = dphiDeg; + float phimax = dphiDeg; + auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, sDzScintillator, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + mod->AddNode(nod, cellId); + } + } + + return mod; +} + +int GeometryTGeo::getCellId(int nmod, int nring, int nsec) const +{ + return nmod * sNumberOfCellRingsA + 8 * nring + nsec; +} + +int GeometryTGeo::getCurrentCellId(const TVirtualMC* fMC) const +{ + int moduleId = -1; + int sectorId = -1; + int ringId = -1; + + fMC->CurrentVolOffID(2, moduleId); + fMC->CurrentVolOffID(1, sectorId); + fMC->CurrentVolOffID(0, ringId); + int cellId = getCellId(moduleId, ringId, sectorId); + + return cellId; +} + +void GeometryTGeo::fillMatrixCache(int mask) +{ +} + + + +GeometryTGeo* GeometryTGeo::Instance() +{ + if (!sInstance) { + sInstance = std::unique_ptr(new GeometryTGeo()); + } + return sInstance.get(); +} + +} // namespace fvd +} //namespace o2 diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt new file mode 100644 index 0000000000000..c5062092349df --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +o2_add_library(FVDSimulation + SOURCES src/Detector.cxx + PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat + O2::DataFormatsFVD) + +o2_target_root_dictionary(FVDSimulation + HEADERS include/FVDSimulation/Detector.h) + + diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h new file mode 100644 index 0000000000000..c839659de6f9b --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h @@ -0,0 +1,109 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifndef ALICEO2_FVD_DETECTOR_H_ +#define ALICEO2_FVD_DETECTOR_H_ + +#include "SimulationDataFormat/BaseHits.h" +#include "DetectorsBase/Detector.h" +#include "DataFormatsFVD/Hit.h" +#include "FVDBase/GeometryTGeo.h" + +class FairModule; +class FairVolume; +class TGeoVolume; + +namespace o2 +{ +namespace fvd +{ +class GeometryTGeo; +class Hit; +class Detector : public o2::base::DetImpl +{ + public: + Detector(Bool_t Active); + + Detector() = default; + ~Detector() override; + + void InitializeO2Detector() override; + + Bool_t ProcessHits(FairVolume* v = nullptr) override; + + /// Registers the produced collections in FAIRRootManager + void Register() override; + + o2::fvd::Hit* addHit(Int_t trackId, Int_t cellId, + const math_utils::Point3D& startPos, const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, double startE, + double endTime, double eLoss, Int_t particlePdg); + + std::vector* getHits(Int_t iColl) + { + if (iColl == 0) { + return mHits; + } + return nullptr; + } + + void Reset() override; + void EndOfEvent() override { Reset(); } + + void CreateMaterials(); + void ConstructGeometry() override; + + enum EMedia { + Scintillator, + }; + + + + private: + Detector(const Detector& rhs); + Detector& operator=(const Detector&); + + std::vector* mHits = nullptr; + GeometryTGeo* mGeometry = nullptr; + + /// Transient data about track passing the sensor, needed by ProcessHits() + struct TrackData { // this is transient + bool mHitStarted; //! hit creation started + TLorentzVector mPositionStart; //! position at entrance + TLorentzVector mMomentumStart; //! momentum + double mEnergyLoss; //! energy loss + } mTrackData; //! + + template + friend class o2::base::DetImpl; + ClassDefOverride(Detector, 1); +}; + +// Input and output function for standard C++ input/output. +std::ostream& operator<<(std::ostream& os, Detector& source); +std::istream& operator>>(std::istream& os, Detector& source); + +} // namespace fvd +} // namespace o2 + +#ifdef USESHM +namespace o2 +{ +namespace base +{ +template <> +struct UseShm { + static constexpr bool value = true; +}; +} // namespace base +} // namespace o2 +#endif +#endif diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx new file mode 100644 index 0000000000000..efd308ca0486e --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -0,0 +1,228 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "DataFormatsFVD/Hit.h" + +#include "FVDBase/GeometryTGeo.h" + +#include "FVDSimulation/Detector.h" + +#include "DetectorsBase/Stack.h" +#include "Field/MagneticField.h" + +#include "TVirtualMC.h" +#include "TLorentzVector.h" +#include "TVector3.h" +#include "TGeoManager.h" +#include "TRandom.h" + +#include +#include "FairRootManager.h" +#include "FairVolume.h" +#include "FairRootManager.h" + +using namespace o2::fvd; +using o2::fvd::GeometryTGeo; +using o2::fvd::Hit; + +ClassImp(o2::fvd::Detector); + +//_____________________________________________________________________________ +Detector::Detector(Bool_t Active) + : o2::base::DetImpl("FVD", Active), + mHits(o2::utils::createSimVector()), + mGeometry(nullptr) +{ +} + +//_____________________________________________________________________________ +Detector::Detector(const Detector& src) + : o2::base::DetImpl(src), + mHits(o2::utils::createSimVector()) +{ +} + +//_____________________________________________________________________________ +Detector& Detector::operator=(const Detector& src) +{ + + if (this == &src) { + return *this; + } + // base class assignment + base::Detector::operator=(src); + + mHits = nullptr; + return *this; +} + +//_____________________________________________________________________________ +Detector::~Detector() +{ + + if (mHits) { + o2::utils::freeSimVector(mHits); + } +} + +//_____________________________________________________________________________ +void Detector::InitializeO2Detector() +{ + LOG(info) << "FVD: Initializing O2 detector. Adding sensitive volumes."; + + TGeoVolume* vol; + + vol = gGeoManager->GetVolume("FVDA"); + if (!vol) { + LOG(fatal) << "can't find volume FVDA"; + } else { + AddSensitiveVolume(vol); + } + + vol = gGeoManager->GetVolume("FVDC"); + if (!vol) { + LOG(fatal) << "can't find volume FVDC"; + } else { + AddSensitiveVolume(vol); + } +} + +//_____________________________________________________________________________ +Bool_t Detector::ProcessHits(FairVolume* vol) +{ + // This method is called from the MC stepping + + // Track only charged particles and photons + bool isPhotonTrack = false; + Int_t particlePdg = fMC->TrackPid(); + if (particlePdg == 22) { // If particle is standard PDG photon + isPhotonTrack = true; + } + if (!(isPhotonTrack || fMC->TrackCharge())) { + return kFALSE; + } + + // Check track status to define when hit is started and when it is stopped + bool startHit = false, stopHit = false; + if ((fMC->IsTrackEntering()) || (fMC->IsTrackInside() && !mTrackData.mHitStarted)) { + startHit = true; + } else if ((fMC->IsTrackExiting() || fMC->IsTrackOut() || fMC->IsTrackStop())) { + stopHit = true; + } + + // Increment energy loss at all steps except entrance + if (!startHit) { + mTrackData.mEnergyLoss += fMC->Edep(); + } + + // Track is entering or created in the volume + // Start registering new hit, defined as the combination of all the steps from a given particle + if (startHit) { + mTrackData.mHitStarted = true; + mTrackData.mEnergyLoss = 0.; + fMC->TrackMomentum(mTrackData.mMomentumStart); + fMC->TrackPosition(mTrackData.mPositionStart); + } + + if (stopHit) { + TLorentzVector positionStop; + fMC->TrackPosition(positionStop); + Int_t trackID = fMC->GetStack()->GetCurrentTrackNumber(); + + // Get unique ID of the detector cell (sensitive volume) + Int_t cellId = mGeometry->getCurrentCellId(fMC); + + math_utils::Point3D posStart(mTrackData.mPositionStart.X(), mTrackData.mPositionStart.Y(), mTrackData.mPositionStart.Z()); + math_utils::Point3D posStop(positionStop.X(), positionStop.Y(), positionStop.Z()); + math_utils::Vector3D momStart(mTrackData.mMomentumStart.Px(), mTrackData.mMomentumStart.Py(), mTrackData.mMomentumStart.Pz()); + addHit(trackID, cellId, posStart, posStop, momStart, + mTrackData.mMomentumStart.E(), positionStop.T(), + mTrackData.mEnergyLoss, particlePdg); + } else { + return kFALSE; // do noting more + } + + return kTRUE; +} + +//_____________________________________________________________________________ +o2::fvd::Hit* Detector::addHit(Int_t trackId, Int_t cellId, + const math_utils::Point3D& startPos, const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, double startE, + double endTime, double eLoss, Int_t particlePdg) +{ + mHits->emplace_back(trackId, cellId, startPos, endPos, startMom, startE, endTime, eLoss, particlePdg); + auto stack = (o2::data::Stack*)fMC->GetStack(); + stack->addHit(GetDetId()); + return &(mHits->back()); +} + +//_____________________________________________________________________________ +void Detector::CreateMaterials() +{ + + Float_t density, as[11], zs[11], ws[11]; + Double_t radLength, absLength, a_ad, z_ad; + Int_t id; + + // EJ-204 scintillator, based on polyvinyltoluene + const Int_t nScint = 2; + Float_t aScint[nScint] = {1.00784, 12.0107}; + Float_t zScint[nScint] = {1, 6}; + Float_t wScint[nScint] = {0.07085, 0.92915}; // based on EJ-204 datasheet: n_atoms/cm3 + const Float_t dScint = 1.023; + + Int_t matId = 0; // tmp material id number + const Int_t unsens = 0, sens = 1; // sensitive or unsensitive medium + // + Int_t fieldType = 3; // Field type + Float_t maxField = 5.0; // Field max. + + Float_t tmaxfd = -10.0; // max deflection angle due to magnetic field in one step + Float_t stemax = 0.1; // max step allowed [cm] + Float_t deemax = 1.0; // maximum fractional energy loss in one step 0Build(); +} +//_____________________________________________________________________________ +void Detector::Register() +{ + // This will create a branch in the output tree called Hit, setting the last + // parameter to kFALSE means that this collection will not be written to the file, + // it will exist only during the simulation + + if (FairRootManager::Instance()) { + FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE); + } +} + +//_____________________________________________________________________________ +void Detector::Reset() +{ + if (!o2::utils::ShmManager::Instance().isOperational()) { + mHits->clear(); + } +} diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/FVDSimulationLinkDef.h b/Detectors/Upgrades/ALICE3/FVD/simulation/src/FVDSimulationLinkDef.h new file mode 100644 index 0000000000000..314a69baa54da --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/FVDSimulationLinkDef.h @@ -0,0 +1,21 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::fvd::Detector + ; +#pragma link C++ class o2::base::DetImpl < o2::fvd::Detector> + ; + +#endif diff --git a/macro/build_geometry.C b/macro/build_geometry.C index af74e7860ba3d..9a7703ef9bcb9 100644 --- a/macro/build_geometry.C +++ b/macro/build_geometry.C @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -263,6 +264,11 @@ void build_geometry(FairRunSim* run = nullptr) addReadoutDetector(new o2::ecal::Detector(isReadout("ECL"))); } + if (isActivated("FVD")) { + // FIT-FVD + addReadoutDetector(new o2::fvd::Detector(isReadout("FVD"))); + } + if (isActivated("MI3")) { // ALICE 3 MID addReadoutDetector(new o2::mi3::Detector(isReadout("MI3"))); diff --git a/run/CMakeLists.txt b/run/CMakeLists.txt index fccb3f0085642..893b3bc3f96c6 100644 --- a/run/CMakeLists.txt +++ b/run/CMakeLists.txt @@ -46,6 +46,7 @@ target_link_libraries(allsim $<$:O2::IOTOFSimulation> $<$:O2::RICHSimulation> $<$:O2::ECalSimulation> + $<$:O2::FVDSimulation> $<$:O2::MI3Simulation> O2::Generators) From c417fcbd14e13b23eb6a18a5979b7ea24a3fccdf Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Tue, 3 Sep 2024 10:39:43 +0200 Subject: [PATCH 02/68] fixed geometry and json --- .../ALICE3/FVD/base/src/GeometryTGeo.cxx | 18 ++++++++---------- .../include/FVDSimulation/Detector.h | 2 +- run/o2simdefaultdetectorlist.json | 1 + 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx index f25c7199799cc..859e881acfc68 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx @@ -46,22 +46,20 @@ void GeometryTGeo::Build() const { // Top volume of FVD detector // A side - TGeoVolumeAssembly *vFVDA = buildModuleA(); - LOG(info) << "FVD: building geometry. The name of the volume is '" << vFVDA->GetName() << "'"; - - TGeoVolume* vCaveRB24 = gGeoManager->GetVolume("caveRB24"); - if (!vCaveRB24) { - LOG(fatal) << "Could not find the top volume for A-side"; - } - vCaveRB24->AddNode(vFVDA, 0, new TGeoTranslation(sXGlobal, sYGlobal, sZGlobalA)); - - // C side TGeoVolume* vCave = gGeoManager->GetVolume("cave"); if (!vCave) { LOG(fatal) << "Could not find the top volume for C-side"; } + // A side + TGeoVolumeAssembly *vFVDA = buildModuleA(); + LOG(info) << "FVD: building geometry. The name of the volume is '" << vFVDA->GetName() << "'"; + + vCave->AddNode(vFVDA, 0, new TGeoTranslation(sXGlobal, sYGlobal, sZGlobalA)); + + // C side + TGeoVolumeAssembly *vFVDC = buildModuleC(); LOG(info) << "FVD: building geometry. The name of the volume is '" << vFVDC->GetName() << "'"; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h index c839659de6f9b..83d1833453812 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h @@ -84,7 +84,7 @@ class Detector : public o2::base::DetImpl template friend class o2::base::DetImpl; - ClassDefOverride(Detector, 1); + ClassDefOverride(Detector, 2); }; // Input and output function for standard C++ input/output. diff --git a/run/o2simdefaultdetectorlist.json b/run/o2simdefaultdetectorlist.json index 697fafcba5872..c133dc5c802d3 100644 --- a/run/o2simdefaultdetectorlist.json +++ b/run/o2simdefaultdetectorlist.json @@ -58,6 +58,7 @@ "RCH", "MI3", "ECL", + "FVD", "HALL", "MAG", "A3IP", From 44bef8c7fec0cf5cf198828ef5da15916da0b558 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Tue, 3 Sep 2024 13:23:09 +0200 Subject: [PATCH 03/68] fixed hits --- .../Common/include/DetectorsCommonDataFormats/SimTraits.h | 3 ++- Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h index 8f9cbcfbdba43..4f68107b172df 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h @@ -99,7 +99,8 @@ class SimTraits /*TF3*/ VS{ "TF3Hit" }, /*RCH*/ VS{ "RCHHit" }, /*MI3*/ VS{ "MI3Hit" }, - /*ECL*/ VS{ "ECLHit" } + /*ECL*/ VS{ "ECLHit" }, + /*FVD*/ VS{ "FVDHit" } #endif }; // clang-format on diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index efd308ca0486e..ecdc11d3b09d1 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -192,10 +192,10 @@ void Detector::CreateMaterials() Float_t epsil = 0.03; // tracking precision [cm] Float_t stmin = -0.001; // minimum step due to continuous processes [cm] (negative value: choose it automatically) - LOG(info) << "FVD: createMaterials(): fieldType " << fieldType << ", maxField " << maxField; + LOG(info) << "FVD: CreateMaterials(): fieldType " << fieldType << ", maxField " << maxField; - o2::base::Detector::Mixture(++matId, "Scintillator$", aScint, zScint, dScint, nScint, wScint); - o2::base::Detector::Medium(Scintillator, "Scintillator$", matId, unsens, fieldType, maxField, + o2::base::Detector::Mixture(++matId, "Scintillator", aScint, zScint, dScint, nScint, wScint); + o2::base::Detector::Medium(Scintillator, "Scintillator", matId, unsens, fieldType, maxField, tmaxfd, stemax, deemax, epsil, stmin); } From deadde875067dc57418a8d031aa8e00f2dca287e Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Tue, 3 Sep 2024 22:38:51 +0200 Subject: [PATCH 04/68] updated geometry and detector source code --- .../Upgrades/ALICE3/FVD/base/CMakeLists.txt | 1 + .../FVD/base/include/FVDBase/FVDBaseParam.h | 22 ++- .../FVD/base/include/FVDBase/GeometryTGeo.h | 27 +-- .../ALICE3/FVD/base/src/FVDBaseLinkDef.h | 2 + .../ALICE3/FVD/base/src/FVDBaseParam.cxx | 14 ++ .../ALICE3/FVD/base/src/GeometryTGeo.cxx | 110 +++--------- .../include/FVDSimulation/Detector.h | 28 +-- .../ALICE3/FVD/simulation/src/Detector.cxx | 166 ++++++++++++------ 8 files changed, 179 insertions(+), 191 deletions(-) create mode 100644 Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx diff --git a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt index a108874226b22..52ace04ba1136 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt @@ -11,6 +11,7 @@ o2_add_library(FVDBase SOURCES src/GeometryTGeo.cxx + src/FVDBaseParam.cxx PUBLIC_LINK_LIBRARIES O2::DetectorsBase) o2_target_root_dictionary(FVDBase diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 2239a66e81428..bb438f6dbce1c 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -9,24 +9,30 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file FVDBaseParam.g -/// \brief General constants in FVD -/// -/// \author Maciej Slupecki, University of Jyvaskyla, Finland - #ifndef ALICEO2_FVD_FVDBASEPARAM_ #define ALICEO2_FVD_FVDBASEPARAM_ #include "FVDBase/GeometryTGeo.h" +#include "CommonUtils/ConfigurableParamHelper.h" namespace o2 { namespace fvd { +struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { + static constexpr int nCellA = 40; // 24 + static constexpr int nCellC = 48; + static constexpr int nRingsA = 5; //3 + static constexpr int nRingsC = 6; + + static constexpr float dzScint = 4.; + static constexpr float rRingsA[int(nCellA/8)+1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; + static constexpr float rRingsC[int(nCellC/8)+1] = {3.5, 17., 30.5, 44., 57.5, 71.}; + + static constexpr float zModA = 1700; + static constexpr float zModC = -1950; -struct FVDBaseParam { - static constexpr int nFvdChannels = GeometryTGeo::getNumberOfReadoutChannels(); - static constexpr int nFvdChannelsPlusRef = nFvdChannels + 1; + O2ParamDef(FVDBaseParam, "FVDBase"); }; } // namespace fvd diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h index 6b26079ccddd8..432c1793b8fe1 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h @@ -32,18 +32,15 @@ namespace fvd class GeometryTGeo : public o2::detectors::DetMatrixCache { public: - GeometryTGeo(); + GeometryTGeo(bool build, int loadTrans); - void Build() const; + void Build(int loadTrans); void fillMatrixCache(int mask); virtual ~GeometryTGeo(); static GeometryTGeo* Instance(); void getGlobalPosition(float& x, float& y, float& z); - static constexpr int getNumberOfReadoutChannelsA() { return sNumberOfReadoutChannelsA; }; - static constexpr int getNumberOfReadoutChannelsC() { return sNumberOfReadoutChannelsC; }; - static constexpr int getNumberOfReadoutChannels() { return sNumberOfReadoutChannelsA + sNumberOfCellsC; } static constexpr o2::detectors::DetID::ID getDetID() { return o2::detectors::DetID::FVD; } @@ -52,28 +49,8 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache private: - static constexpr float sDzScintillator = 4; - static constexpr float sXGlobal = 0; - static constexpr float sYGlobal = 0; - static constexpr float sZGlobalA = 1700. - sDzScintillator/2; - static constexpr float sZGlobalC = -1950. + sDzScintillator/2; - - static constexpr int sNumberOfCellSectors = 8; - static constexpr int sNumberOfCellRingsA = 5; // 3 - static constexpr int sNumberOfCellRingsC = 6; - static constexpr int sNumberOfCellsA = sNumberOfCellRingsA * sNumberOfCellSectors; - static constexpr int sNumberOfCellsC = sNumberOfCellRingsC * sNumberOfCellSectors; - static constexpr int sNumberOfReadoutChannelsA = sNumberOfCellsA; - static constexpr int sNumberOfReadoutChannelsC = sNumberOfCellsC; - - static constexpr float sCellRingRadiiA[sNumberOfCellRingsA + 1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; - static constexpr float sCellRingRadiiC[sNumberOfCellRingsC + 1] = {3.5, 17., 30.5, 44., 57.5, 71.}; - static std::unique_ptr sInstance; - TGeoVolumeAssembly* buildModuleA() const; - TGeoVolumeAssembly* buildModuleC() const; - ClassDefNV(GeometryTGeo, 1); }; } // namespace fvd diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h index 8cf0cafc49a9b..43cb1224b28e2 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h @@ -16,5 +16,7 @@ #pragma link off all functions; #pragma link C++ class o2::fvd::GeometryTGeo + ; +#pragma link C++ class o2::fvd::FVDBaseParam + ; +#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::fvd::FVDBaseParam> + ; #endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx new file mode 100644 index 0000000000000..6bc99ba1a055f --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx @@ -0,0 +1,14 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "FVDBase/FVDBaseParam.h" + +O2ParamImpl(o2::fvd::FVDBaseParam); diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx index 859e881acfc68..298c92d01b03e 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx @@ -10,20 +10,12 @@ // or submit itself to any jurisdiction. #include "FVDBase/GeometryTGeo.h" +#include "FVDBase/FVDBaseParam.h" #include #include -#include -#include -#include -#include -#include -#include -#include -#include - using namespace o2::fvd; namespace o2 { @@ -32,95 +24,47 @@ namespace fvd std::unique_ptr GeometryTGeo::sInstance; -GeometryTGeo::GeometryTGeo() : DetMatrixCache() +GeometryTGeo::GeometryTGeo(bool build, int loadTrans) : DetMatrixCache() { if (sInstance) { LOGP(fatal, "Invalid use of public constructor: o2::fvd::GeometryTGeo instance exists"); } - Build(); + if (build) { + Build(loadTrans); + } } GeometryTGeo::~GeometryTGeo() {} -void GeometryTGeo::Build() const +GeometryTGeo* GeometryTGeo::Instance() { - // Top volume of FVD detector - // A side - - TGeoVolume* vCave = gGeoManager->GetVolume("cave"); - if (!vCave) { - LOG(fatal) << "Could not find the top volume for C-side"; + if (!sInstance) { + sInstance = std::unique_ptr(new GeometryTGeo(true, 0)); } - - // A side - TGeoVolumeAssembly *vFVDA = buildModuleA(); - LOG(info) << "FVD: building geometry. The name of the volume is '" << vFVDA->GetName() << "'"; - - vCave->AddNode(vFVDA, 0, new TGeoTranslation(sXGlobal, sYGlobal, sZGlobalA)); - - // C side - - TGeoVolumeAssembly *vFVDC = buildModuleC(); - LOG(info) << "FVD: building geometry. The name of the volume is '" << vFVDC->GetName() << "'"; - - vCave->AddNode(vFVDC, 1, new TGeoTranslation(sXGlobal, sYGlobal, sZGlobalC)); + return sInstance.get(); } -TGeoVolumeAssembly* GeometryTGeo::buildModuleA() const +void GeometryTGeo::Build(int loadTrans) { - TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDA"); // A or C - - const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); - - const float dphiDeg = 45.; - - for (int ir = 0; ir < sNumberOfCellRingsA; ir++) { - for (int ic = 0; ic < sNumberOfCellSectors; ic ++) { - int cellId = ic + ir; - std::string tbsName = "tbs" + std::to_string(cellId); - std::string nodeName = "node" + std::to_string(cellId); - float rmin = sCellRingRadiiA[ir]; - float rmax = sCellRingRadiiA[ir+1]; - float phimin = dphiDeg; - float phimax = dphiDeg; - auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, sDzScintillator, phimin, phimax); - auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - mod->AddNode(nod, cellId); - } + if (isBuilt()) { + LOGP(warning, "Already built"); + return; // already initialized } - return mod; + if (!gGeoManager) { + LOGP(fatal, "Geometry is not loaded"); + } + + fillMatrixCache(loadTrans); } -TGeoVolumeAssembly* GeometryTGeo::buildModuleC() const +void GeometryTGeo::fillMatrixCache(int mask) { - TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDC"); // A or C - - const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); - - const float dphiDeg = 45.; - - for (int ir = 0; ir < sNumberOfCellRingsC; ir++) { - for (int ic = 0; ic < sNumberOfCellSectors; ic ++) { - int cellId = ic + ir + sNumberOfCellsA; - std::string tbsName = "tbs" + std::to_string(cellId); - std::string nodeName = "node" + std::to_string(cellId); - float rmin = sCellRingRadiiC[ir]; - float rmax = sCellRingRadiiC[ir+1]; - float phimin = dphiDeg; - float phimax = dphiDeg; - auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, sDzScintillator, phimin, phimax); - auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - mod->AddNode(nod, cellId); - } - } - - return mod; } int GeometryTGeo::getCellId(int nmod, int nring, int nsec) const { - return nmod * sNumberOfCellRingsA + 8 * nring + nsec; + return nmod * FVDBaseParam::nCellA + 8 * nring + nsec; } int GeometryTGeo::getCurrentCellId(const TVirtualMC* fMC) const @@ -137,19 +81,5 @@ int GeometryTGeo::getCurrentCellId(const TVirtualMC* fMC) const return cellId; } -void GeometryTGeo::fillMatrixCache(int mask) -{ -} - - - -GeometryTGeo* GeometryTGeo::Instance() -{ - if (!sInstance) { - sInstance = std::unique_ptr(new GeometryTGeo()); - } - return sInstance.get(); -} - } // namespace fvd } //namespace o2 diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h index 83d1833453812..da95cb4eebb60 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h @@ -35,12 +35,7 @@ class Detector : public o2::base::DetImpl Detector() = default; ~Detector() override; - void InitializeO2Detector() override; - - Bool_t ProcessHits(FairVolume* v = nullptr) override; - - /// Registers the produced collections in FAIRRootManager - void Register() override; + void ConstructGeometry() override; o2::fvd::Hit* addHit(Int_t trackId, Int_t cellId, const math_utils::Point3D& startPos, const math_utils::Point3D& endPos, @@ -55,24 +50,33 @@ class Detector : public o2::base::DetImpl return nullptr; } + // Mandatory overrides + void BeginPrimary() override { ; } + void FinishPrimary() override { ; } + void InitializeO2Detector() override; + void PostTrack() override { ; } + void PreTrack() override { ; } + bool ProcessHits(FairVolume* v = nullptr) override; + void EndOfEvent() override; + void Register() override; void Reset() override; - void EndOfEvent() override { Reset(); } - void CreateMaterials(); - void ConstructGeometry() override; + void createMaterials(); + void buildModules(); enum EMedia { Scintillator, }; - - private: Detector(const Detector& rhs); Detector& operator=(const Detector&); std::vector* mHits = nullptr; - GeometryTGeo* mGeometry = nullptr; + GeometryTGeo* mGeometryTGeo = nullptr; + + TGeoVolumeAssembly* buildModuleA(); + TGeoVolumeAssembly* buildModuleC(); /// Transient data about track passing the sensor, needed by ProcessHits() struct TrackData { // this is transient diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index ecdc11d3b09d1..8e05128325509 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -11,46 +11,49 @@ #include "DataFormatsFVD/Hit.h" -#include "FVDBase/GeometryTGeo.h" - #include "FVDSimulation/Detector.h" +#include "FVDBase/GeometryTGeo.h" +#include "FVDBase/FVDBaseParam.h" + #include "DetectorsBase/Stack.h" #include "Field/MagneticField.h" -#include "TVirtualMC.h" -#include "TLorentzVector.h" -#include "TVector3.h" -#include "TGeoManager.h" -#include "TRandom.h" - #include #include "FairRootManager.h" #include "FairVolume.h" #include "FairRootManager.h" +#include "TVirtualMC.h" +#include "TLorentzVector.h" +#include "TVector3.h" +#include +#include +#include +#include +#include +#include +#include "TRandom.h" + using namespace o2::fvd; using o2::fvd::GeometryTGeo; using o2::fvd::Hit; ClassImp(o2::fvd::Detector); -//_____________________________________________________________________________ Detector::Detector(Bool_t Active) : o2::base::DetImpl("FVD", Active), mHits(o2::utils::createSimVector()), - mGeometry(nullptr) + mGeometryTGeo(nullptr) { } -//_____________________________________________________________________________ Detector::Detector(const Detector& src) : o2::base::DetImpl(src), mHits(o2::utils::createSimVector()) { } -//_____________________________________________________________________________ Detector& Detector::operator=(const Detector& src) { @@ -64,7 +67,6 @@ Detector& Detector::operator=(const Detector& src) return *this; } -//_____________________________________________________________________________ Detector::~Detector() { @@ -73,33 +75,15 @@ Detector::~Detector() } } -//_____________________________________________________________________________ void Detector::InitializeO2Detector() { - LOG(info) << "FVD: Initializing O2 detector. Adding sensitive volumes."; - - TGeoVolume* vol; - - vol = gGeoManager->GetVolume("FVDA"); - if (!vol) { - LOG(fatal) << "can't find volume FVDA"; - } else { - AddSensitiveVolume(vol); - } - - vol = gGeoManager->GetVolume("FVDC"); - if (!vol) { - LOG(fatal) << "can't find volume FVDC"; - } else { - AddSensitiveVolume(vol); - } + LOG(info) << "Initialize FVD detector"; + mGeometryTGeo = GeometryTGeo::Instance(); } -//_____________________________________________________________________________ Bool_t Detector::ProcessHits(FairVolume* vol) { // This method is called from the MC stepping - // Track only charged particles and photons bool isPhotonTrack = false; Int_t particlePdg = fMC->TrackPid(); @@ -138,7 +122,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol) Int_t trackID = fMC->GetStack()->GetCurrentTrackNumber(); // Get unique ID of the detector cell (sensitive volume) - Int_t cellId = mGeometry->getCurrentCellId(fMC); + Int_t cellId = mGeometryTGeo->getCurrentCellId(fMC); math_utils::Point3D posStart(mTrackData.mPositionStart.X(), mTrackData.mPositionStart.Y(), mTrackData.mPositionStart.Z()); math_utils::Point3D posStop(positionStop.X(), positionStop.Y(), positionStop.Z()); @@ -147,13 +131,12 @@ Bool_t Detector::ProcessHits(FairVolume* vol) mTrackData.mMomentumStart.E(), positionStop.T(), mTrackData.mEnergyLoss, particlePdg); } else { - return kFALSE; // do noting more + return kFALSE; // do nothing more } return kTRUE; } -//_____________________________________________________________________________ o2::fvd::Hit* Detector::addHit(Int_t trackId, Int_t cellId, const math_utils::Point3D& startPos, const math_utils::Point3D& endPos, const math_utils::Vector3D& startMom, double startE, @@ -165,8 +148,36 @@ o2::fvd::Hit* Detector::addHit(Int_t trackId, Int_t cellId, return &(mHits->back()); } -//_____________________________________________________________________________ -void Detector::CreateMaterials() +void Detector::ConstructGeometry() +{ + createMaterials(); + buildModules(); +} + + +void Detector::EndOfEvent() { + Reset(); +} + +void Detector::Register() +{ + // This will create a branch in the output tree called Hit, setting the last + // parameter to kFALSE means that this collection will not be written to the file, + // it will exist only during the simulation + + if (FairRootManager::Instance()) { + FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE); + } +} + +void Detector::Reset() +{ + if (!o2::utils::ShmManager::Instance().isOperational()) { + mHits->clear(); + } +} + +void Detector::createMaterials() { Float_t density, as[11], zs[11], ws[11]; @@ -197,32 +208,75 @@ void Detector::CreateMaterials() o2::base::Detector::Mixture(++matId, "Scintillator", aScint, zScint, dScint, nScint, wScint); o2::base::Detector::Medium(Scintillator, "Scintillator", matId, unsens, fieldType, maxField, tmaxfd, stemax, deemax, epsil, stmin); - } -//_____________________________________________________________________________ -void Detector::ConstructGeometry() +void Detector::buildModules() { - CreateMaterials(); - mGeometry = new GeometryTGeo(); - mGeometry->Build(); + LOGP(info, "Creating FVD geometry"); + + TGeoVolume* vCave = gGeoManager->GetVolume("cave"); + if (!vCave) { + LOG(fatal) << "Could not find the top volume!"; + } + + // create modules + TGeoVolumeAssembly *vFVDA = buildModuleA(); + TGeoVolumeAssembly *vFVDC = buildModuleC(); + + vCave->AddNode(vFVDA, 0, new TGeoTranslation(0., 0., FVDBaseParam::zModA)); + vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., FVDBaseParam::zModC)); } -//_____________________________________________________________________________ -void Detector::Register() -{ - // This will create a branch in the output tree called Hit, setting the last - // parameter to kFALSE means that this collection will not be written to the file, - // it will exist only during the simulation - if (FairRootManager::Instance()) { - FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE); +TGeoVolumeAssembly* Detector::buildModuleA() +{ + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDA"); + + const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + + const float dphiDeg = 45.; + + for (int ir = 0; ir < FVDBaseParam::nRingsA; ir++) { + for (int ic = 0; ic < 8; ic ++) { + int cellId = ic + ir; + std::string tbsName = "tbs" + std::to_string(cellId); + std::string nodeName = "node" + std::to_string(cellId); + float rmin = FVDBaseParam::rRingsA[ir]; + float rmax = FVDBaseParam::rRingsA[ir+1]; + float phimin = dphiDeg; + float phimax = dphiDeg; + float dz = FVDBaseParam::dzScint; + auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + mod->AddNode(nod, cellId); + } } + + return mod; } -//_____________________________________________________________________________ -void Detector::Reset() +TGeoVolumeAssembly* Detector::buildModuleC() { - if (!o2::utils::ShmManager::Instance().isOperational()) { - mHits->clear(); + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDC"); + + const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + + const float dphiDeg = 45.; + + for (int ir = 0; ir < FVDBaseParam::nRingsC; ir++) { + for (int ic = 0; ic < 8; ic ++) { + int cellId = ic + ir + FVDBaseParam::nCellA; + std::string tbsName = "tbs" + std::to_string(cellId); + std::string nodeName = "node" + std::to_string(cellId); + float rmin = FVDBaseParam::rRingsC[ir]; + float rmax = FVDBaseParam::rRingsC[ir+1]; + float phimin = dphiDeg; + float phimax = dphiDeg; + float dz = FVDBaseParam::dzScint; + auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + mod->AddNode(nod, cellId); + } } + + return mod; } From dd8656ec2a36018af5e2632ee291ffd2de4998e6 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Tue, 3 Sep 2024 22:38:51 +0200 Subject: [PATCH 05/68] updated geometry and detector source code --- .../DetectorsCommonDataFormats/DetID.h | 2 +- .../Upgrades/ALICE3/FVD/base/CMakeLists.txt | 1 + .../FVD/base/include/FVDBase/FVDBaseParam.h | 22 ++- .../FVD/base/include/FVDBase/GeometryTGeo.h | 27 +-- .../ALICE3/FVD/base/src/FVDBaseLinkDef.h | 2 + .../ALICE3/FVD/base/src/FVDBaseParam.cxx | 14 ++ .../ALICE3/FVD/base/src/GeometryTGeo.cxx | 110 +++--------- .../include/FVDSimulation/Detector.h | 28 +-- .../ALICE3/FVD/simulation/src/Detector.cxx | 166 ++++++++++++------ 9 files changed, 180 insertions(+), 192 deletions(-) create mode 100644 Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h index ebcce137d8c2c..d7c3e3f72cc30 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h @@ -90,7 +90,7 @@ class DetID static constexpr ID FVD = 26; static constexpr ID Last = FVD; #else - static constexpr ID Last = FVD; ///< if extra detectors added, update this !!! + static constexpr ID Last = FOC; ///< if extra detectors added, update this !!! #endif static constexpr ID First = ITS; diff --git a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt index a108874226b22..52ace04ba1136 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt @@ -11,6 +11,7 @@ o2_add_library(FVDBase SOURCES src/GeometryTGeo.cxx + src/FVDBaseParam.cxx PUBLIC_LINK_LIBRARIES O2::DetectorsBase) o2_target_root_dictionary(FVDBase diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 2239a66e81428..bb438f6dbce1c 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -9,24 +9,30 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file FVDBaseParam.g -/// \brief General constants in FVD -/// -/// \author Maciej Slupecki, University of Jyvaskyla, Finland - #ifndef ALICEO2_FVD_FVDBASEPARAM_ #define ALICEO2_FVD_FVDBASEPARAM_ #include "FVDBase/GeometryTGeo.h" +#include "CommonUtils/ConfigurableParamHelper.h" namespace o2 { namespace fvd { +struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { + static constexpr int nCellA = 40; // 24 + static constexpr int nCellC = 48; + static constexpr int nRingsA = 5; //3 + static constexpr int nRingsC = 6; + + static constexpr float dzScint = 4.; + static constexpr float rRingsA[int(nCellA/8)+1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; + static constexpr float rRingsC[int(nCellC/8)+1] = {3.5, 17., 30.5, 44., 57.5, 71.}; + + static constexpr float zModA = 1700; + static constexpr float zModC = -1950; -struct FVDBaseParam { - static constexpr int nFvdChannels = GeometryTGeo::getNumberOfReadoutChannels(); - static constexpr int nFvdChannelsPlusRef = nFvdChannels + 1; + O2ParamDef(FVDBaseParam, "FVDBase"); }; } // namespace fvd diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h index 6b26079ccddd8..432c1793b8fe1 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h @@ -32,18 +32,15 @@ namespace fvd class GeometryTGeo : public o2::detectors::DetMatrixCache { public: - GeometryTGeo(); + GeometryTGeo(bool build, int loadTrans); - void Build() const; + void Build(int loadTrans); void fillMatrixCache(int mask); virtual ~GeometryTGeo(); static GeometryTGeo* Instance(); void getGlobalPosition(float& x, float& y, float& z); - static constexpr int getNumberOfReadoutChannelsA() { return sNumberOfReadoutChannelsA; }; - static constexpr int getNumberOfReadoutChannelsC() { return sNumberOfReadoutChannelsC; }; - static constexpr int getNumberOfReadoutChannels() { return sNumberOfReadoutChannelsA + sNumberOfCellsC; } static constexpr o2::detectors::DetID::ID getDetID() { return o2::detectors::DetID::FVD; } @@ -52,28 +49,8 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache private: - static constexpr float sDzScintillator = 4; - static constexpr float sXGlobal = 0; - static constexpr float sYGlobal = 0; - static constexpr float sZGlobalA = 1700. - sDzScintillator/2; - static constexpr float sZGlobalC = -1950. + sDzScintillator/2; - - static constexpr int sNumberOfCellSectors = 8; - static constexpr int sNumberOfCellRingsA = 5; // 3 - static constexpr int sNumberOfCellRingsC = 6; - static constexpr int sNumberOfCellsA = sNumberOfCellRingsA * sNumberOfCellSectors; - static constexpr int sNumberOfCellsC = sNumberOfCellRingsC * sNumberOfCellSectors; - static constexpr int sNumberOfReadoutChannelsA = sNumberOfCellsA; - static constexpr int sNumberOfReadoutChannelsC = sNumberOfCellsC; - - static constexpr float sCellRingRadiiA[sNumberOfCellRingsA + 1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; - static constexpr float sCellRingRadiiC[sNumberOfCellRingsC + 1] = {3.5, 17., 30.5, 44., 57.5, 71.}; - static std::unique_ptr sInstance; - TGeoVolumeAssembly* buildModuleA() const; - TGeoVolumeAssembly* buildModuleC() const; - ClassDefNV(GeometryTGeo, 1); }; } // namespace fvd diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h index 8cf0cafc49a9b..43cb1224b28e2 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h @@ -16,5 +16,7 @@ #pragma link off all functions; #pragma link C++ class o2::fvd::GeometryTGeo + ; +#pragma link C++ class o2::fvd::FVDBaseParam + ; +#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::fvd::FVDBaseParam> + ; #endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx new file mode 100644 index 0000000000000..6bc99ba1a055f --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx @@ -0,0 +1,14 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "FVDBase/FVDBaseParam.h" + +O2ParamImpl(o2::fvd::FVDBaseParam); diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx index 859e881acfc68..298c92d01b03e 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx @@ -10,20 +10,12 @@ // or submit itself to any jurisdiction. #include "FVDBase/GeometryTGeo.h" +#include "FVDBase/FVDBaseParam.h" #include #include -#include -#include -#include -#include -#include -#include -#include -#include - using namespace o2::fvd; namespace o2 { @@ -32,95 +24,47 @@ namespace fvd std::unique_ptr GeometryTGeo::sInstance; -GeometryTGeo::GeometryTGeo() : DetMatrixCache() +GeometryTGeo::GeometryTGeo(bool build, int loadTrans) : DetMatrixCache() { if (sInstance) { LOGP(fatal, "Invalid use of public constructor: o2::fvd::GeometryTGeo instance exists"); } - Build(); + if (build) { + Build(loadTrans); + } } GeometryTGeo::~GeometryTGeo() {} -void GeometryTGeo::Build() const +GeometryTGeo* GeometryTGeo::Instance() { - // Top volume of FVD detector - // A side - - TGeoVolume* vCave = gGeoManager->GetVolume("cave"); - if (!vCave) { - LOG(fatal) << "Could not find the top volume for C-side"; + if (!sInstance) { + sInstance = std::unique_ptr(new GeometryTGeo(true, 0)); } - - // A side - TGeoVolumeAssembly *vFVDA = buildModuleA(); - LOG(info) << "FVD: building geometry. The name of the volume is '" << vFVDA->GetName() << "'"; - - vCave->AddNode(vFVDA, 0, new TGeoTranslation(sXGlobal, sYGlobal, sZGlobalA)); - - // C side - - TGeoVolumeAssembly *vFVDC = buildModuleC(); - LOG(info) << "FVD: building geometry. The name of the volume is '" << vFVDC->GetName() << "'"; - - vCave->AddNode(vFVDC, 1, new TGeoTranslation(sXGlobal, sYGlobal, sZGlobalC)); + return sInstance.get(); } -TGeoVolumeAssembly* GeometryTGeo::buildModuleA() const +void GeometryTGeo::Build(int loadTrans) { - TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDA"); // A or C - - const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); - - const float dphiDeg = 45.; - - for (int ir = 0; ir < sNumberOfCellRingsA; ir++) { - for (int ic = 0; ic < sNumberOfCellSectors; ic ++) { - int cellId = ic + ir; - std::string tbsName = "tbs" + std::to_string(cellId); - std::string nodeName = "node" + std::to_string(cellId); - float rmin = sCellRingRadiiA[ir]; - float rmax = sCellRingRadiiA[ir+1]; - float phimin = dphiDeg; - float phimax = dphiDeg; - auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, sDzScintillator, phimin, phimax); - auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - mod->AddNode(nod, cellId); - } + if (isBuilt()) { + LOGP(warning, "Already built"); + return; // already initialized } - return mod; + if (!gGeoManager) { + LOGP(fatal, "Geometry is not loaded"); + } + + fillMatrixCache(loadTrans); } -TGeoVolumeAssembly* GeometryTGeo::buildModuleC() const +void GeometryTGeo::fillMatrixCache(int mask) { - TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDC"); // A or C - - const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); - - const float dphiDeg = 45.; - - for (int ir = 0; ir < sNumberOfCellRingsC; ir++) { - for (int ic = 0; ic < sNumberOfCellSectors; ic ++) { - int cellId = ic + ir + sNumberOfCellsA; - std::string tbsName = "tbs" + std::to_string(cellId); - std::string nodeName = "node" + std::to_string(cellId); - float rmin = sCellRingRadiiC[ir]; - float rmax = sCellRingRadiiC[ir+1]; - float phimin = dphiDeg; - float phimax = dphiDeg; - auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, sDzScintillator, phimin, phimax); - auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - mod->AddNode(nod, cellId); - } - } - - return mod; } int GeometryTGeo::getCellId(int nmod, int nring, int nsec) const { - return nmod * sNumberOfCellRingsA + 8 * nring + nsec; + return nmod * FVDBaseParam::nCellA + 8 * nring + nsec; } int GeometryTGeo::getCurrentCellId(const TVirtualMC* fMC) const @@ -137,19 +81,5 @@ int GeometryTGeo::getCurrentCellId(const TVirtualMC* fMC) const return cellId; } -void GeometryTGeo::fillMatrixCache(int mask) -{ -} - - - -GeometryTGeo* GeometryTGeo::Instance() -{ - if (!sInstance) { - sInstance = std::unique_ptr(new GeometryTGeo()); - } - return sInstance.get(); -} - } // namespace fvd } //namespace o2 diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h index 83d1833453812..da95cb4eebb60 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h @@ -35,12 +35,7 @@ class Detector : public o2::base::DetImpl Detector() = default; ~Detector() override; - void InitializeO2Detector() override; - - Bool_t ProcessHits(FairVolume* v = nullptr) override; - - /// Registers the produced collections in FAIRRootManager - void Register() override; + void ConstructGeometry() override; o2::fvd::Hit* addHit(Int_t trackId, Int_t cellId, const math_utils::Point3D& startPos, const math_utils::Point3D& endPos, @@ -55,24 +50,33 @@ class Detector : public o2::base::DetImpl return nullptr; } + // Mandatory overrides + void BeginPrimary() override { ; } + void FinishPrimary() override { ; } + void InitializeO2Detector() override; + void PostTrack() override { ; } + void PreTrack() override { ; } + bool ProcessHits(FairVolume* v = nullptr) override; + void EndOfEvent() override; + void Register() override; void Reset() override; - void EndOfEvent() override { Reset(); } - void CreateMaterials(); - void ConstructGeometry() override; + void createMaterials(); + void buildModules(); enum EMedia { Scintillator, }; - - private: Detector(const Detector& rhs); Detector& operator=(const Detector&); std::vector* mHits = nullptr; - GeometryTGeo* mGeometry = nullptr; + GeometryTGeo* mGeometryTGeo = nullptr; + + TGeoVolumeAssembly* buildModuleA(); + TGeoVolumeAssembly* buildModuleC(); /// Transient data about track passing the sensor, needed by ProcessHits() struct TrackData { // this is transient diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index ecdc11d3b09d1..8e05128325509 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -11,46 +11,49 @@ #include "DataFormatsFVD/Hit.h" -#include "FVDBase/GeometryTGeo.h" - #include "FVDSimulation/Detector.h" +#include "FVDBase/GeometryTGeo.h" +#include "FVDBase/FVDBaseParam.h" + #include "DetectorsBase/Stack.h" #include "Field/MagneticField.h" -#include "TVirtualMC.h" -#include "TLorentzVector.h" -#include "TVector3.h" -#include "TGeoManager.h" -#include "TRandom.h" - #include #include "FairRootManager.h" #include "FairVolume.h" #include "FairRootManager.h" +#include "TVirtualMC.h" +#include "TLorentzVector.h" +#include "TVector3.h" +#include +#include +#include +#include +#include +#include +#include "TRandom.h" + using namespace o2::fvd; using o2::fvd::GeometryTGeo; using o2::fvd::Hit; ClassImp(o2::fvd::Detector); -//_____________________________________________________________________________ Detector::Detector(Bool_t Active) : o2::base::DetImpl("FVD", Active), mHits(o2::utils::createSimVector()), - mGeometry(nullptr) + mGeometryTGeo(nullptr) { } -//_____________________________________________________________________________ Detector::Detector(const Detector& src) : o2::base::DetImpl(src), mHits(o2::utils::createSimVector()) { } -//_____________________________________________________________________________ Detector& Detector::operator=(const Detector& src) { @@ -64,7 +67,6 @@ Detector& Detector::operator=(const Detector& src) return *this; } -//_____________________________________________________________________________ Detector::~Detector() { @@ -73,33 +75,15 @@ Detector::~Detector() } } -//_____________________________________________________________________________ void Detector::InitializeO2Detector() { - LOG(info) << "FVD: Initializing O2 detector. Adding sensitive volumes."; - - TGeoVolume* vol; - - vol = gGeoManager->GetVolume("FVDA"); - if (!vol) { - LOG(fatal) << "can't find volume FVDA"; - } else { - AddSensitiveVolume(vol); - } - - vol = gGeoManager->GetVolume("FVDC"); - if (!vol) { - LOG(fatal) << "can't find volume FVDC"; - } else { - AddSensitiveVolume(vol); - } + LOG(info) << "Initialize FVD detector"; + mGeometryTGeo = GeometryTGeo::Instance(); } -//_____________________________________________________________________________ Bool_t Detector::ProcessHits(FairVolume* vol) { // This method is called from the MC stepping - // Track only charged particles and photons bool isPhotonTrack = false; Int_t particlePdg = fMC->TrackPid(); @@ -138,7 +122,7 @@ Bool_t Detector::ProcessHits(FairVolume* vol) Int_t trackID = fMC->GetStack()->GetCurrentTrackNumber(); // Get unique ID of the detector cell (sensitive volume) - Int_t cellId = mGeometry->getCurrentCellId(fMC); + Int_t cellId = mGeometryTGeo->getCurrentCellId(fMC); math_utils::Point3D posStart(mTrackData.mPositionStart.X(), mTrackData.mPositionStart.Y(), mTrackData.mPositionStart.Z()); math_utils::Point3D posStop(positionStop.X(), positionStop.Y(), positionStop.Z()); @@ -147,13 +131,12 @@ Bool_t Detector::ProcessHits(FairVolume* vol) mTrackData.mMomentumStart.E(), positionStop.T(), mTrackData.mEnergyLoss, particlePdg); } else { - return kFALSE; // do noting more + return kFALSE; // do nothing more } return kTRUE; } -//_____________________________________________________________________________ o2::fvd::Hit* Detector::addHit(Int_t trackId, Int_t cellId, const math_utils::Point3D& startPos, const math_utils::Point3D& endPos, const math_utils::Vector3D& startMom, double startE, @@ -165,8 +148,36 @@ o2::fvd::Hit* Detector::addHit(Int_t trackId, Int_t cellId, return &(mHits->back()); } -//_____________________________________________________________________________ -void Detector::CreateMaterials() +void Detector::ConstructGeometry() +{ + createMaterials(); + buildModules(); +} + + +void Detector::EndOfEvent() { + Reset(); +} + +void Detector::Register() +{ + // This will create a branch in the output tree called Hit, setting the last + // parameter to kFALSE means that this collection will not be written to the file, + // it will exist only during the simulation + + if (FairRootManager::Instance()) { + FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE); + } +} + +void Detector::Reset() +{ + if (!o2::utils::ShmManager::Instance().isOperational()) { + mHits->clear(); + } +} + +void Detector::createMaterials() { Float_t density, as[11], zs[11], ws[11]; @@ -197,32 +208,75 @@ void Detector::CreateMaterials() o2::base::Detector::Mixture(++matId, "Scintillator", aScint, zScint, dScint, nScint, wScint); o2::base::Detector::Medium(Scintillator, "Scintillator", matId, unsens, fieldType, maxField, tmaxfd, stemax, deemax, epsil, stmin); - } -//_____________________________________________________________________________ -void Detector::ConstructGeometry() +void Detector::buildModules() { - CreateMaterials(); - mGeometry = new GeometryTGeo(); - mGeometry->Build(); + LOGP(info, "Creating FVD geometry"); + + TGeoVolume* vCave = gGeoManager->GetVolume("cave"); + if (!vCave) { + LOG(fatal) << "Could not find the top volume!"; + } + + // create modules + TGeoVolumeAssembly *vFVDA = buildModuleA(); + TGeoVolumeAssembly *vFVDC = buildModuleC(); + + vCave->AddNode(vFVDA, 0, new TGeoTranslation(0., 0., FVDBaseParam::zModA)); + vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., FVDBaseParam::zModC)); } -//_____________________________________________________________________________ -void Detector::Register() -{ - // This will create a branch in the output tree called Hit, setting the last - // parameter to kFALSE means that this collection will not be written to the file, - // it will exist only during the simulation - if (FairRootManager::Instance()) { - FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE); +TGeoVolumeAssembly* Detector::buildModuleA() +{ + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDA"); + + const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + + const float dphiDeg = 45.; + + for (int ir = 0; ir < FVDBaseParam::nRingsA; ir++) { + for (int ic = 0; ic < 8; ic ++) { + int cellId = ic + ir; + std::string tbsName = "tbs" + std::to_string(cellId); + std::string nodeName = "node" + std::to_string(cellId); + float rmin = FVDBaseParam::rRingsA[ir]; + float rmax = FVDBaseParam::rRingsA[ir+1]; + float phimin = dphiDeg; + float phimax = dphiDeg; + float dz = FVDBaseParam::dzScint; + auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + mod->AddNode(nod, cellId); + } } + + return mod; } -//_____________________________________________________________________________ -void Detector::Reset() +TGeoVolumeAssembly* Detector::buildModuleC() { - if (!o2::utils::ShmManager::Instance().isOperational()) { - mHits->clear(); + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDC"); + + const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + + const float dphiDeg = 45.; + + for (int ir = 0; ir < FVDBaseParam::nRingsC; ir++) { + for (int ic = 0; ic < 8; ic ++) { + int cellId = ic + ir + FVDBaseParam::nCellA; + std::string tbsName = "tbs" + std::to_string(cellId); + std::string nodeName = "node" + std::to_string(cellId); + float rmin = FVDBaseParam::rRingsC[ir]; + float rmax = FVDBaseParam::rRingsC[ir+1]; + float phimin = dphiDeg; + float phimax = dphiDeg; + float dz = FVDBaseParam::dzScint; + auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + mod->AddNode(nod, cellId); + } } + + return mod; } From 73d3a4a1c63555645152cb762ad5089e688f5742 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Fri, 6 Sep 2024 09:32:05 +0200 Subject: [PATCH 06/68] minor fixes --- .../FVD/base/include/FVDBase/GeometryTGeo.h | 2 +- .../include/FVDSimulation/Detector.h | 2 ++ .../ALICE3/FVD/simulation/src/Detector.cxx | 23 ++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h index 432c1793b8fe1..45d20d0c59cc5 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h @@ -32,7 +32,7 @@ namespace fvd class GeometryTGeo : public o2::detectors::DetMatrixCache { public: - GeometryTGeo(bool build, int loadTrans); + GeometryTGeo(bool build = false, int loadTrans = 0); void Build(int loadTrans); void fillMatrixCache(int mask); diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h index da95cb4eebb60..a6c373527f87b 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h @@ -78,6 +78,8 @@ class Detector : public o2::base::DetImpl TGeoVolumeAssembly* buildModuleA(); TGeoVolumeAssembly* buildModuleC(); + void defineSensitiveVolumes(); + /// Transient data about track passing the sensor, needed by ProcessHits() struct TrackData { // this is transient bool mHitStarted; //! hit creation started diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 8e05128325509..118a29751dd8b 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -152,6 +152,7 @@ void Detector::ConstructGeometry() { createMaterials(); buildModules(); + defineSensitiveVolumes(); } @@ -237,13 +238,13 @@ TGeoVolumeAssembly* Detector::buildModuleA() for (int ir = 0; ir < FVDBaseParam::nRingsA; ir++) { for (int ic = 0; ic < 8; ic ++) { - int cellId = ic + ir; + int cellId = ic + 8*ir; std::string tbsName = "tbs" + std::to_string(cellId); - std::string nodeName = "node" + std::to_string(cellId); + std::string nodeName = "fvd_node" + std::to_string(cellId); float rmin = FVDBaseParam::rRingsA[ir]; float rmax = FVDBaseParam::rRingsA[ir+1]; - float phimin = dphiDeg; - float phimax = dphiDeg; + float phimin = dphiDeg * ic; + float phimax = dphiDeg * (ic + 1); float dz = FVDBaseParam::dzScint; auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); @@ -264,13 +265,13 @@ TGeoVolumeAssembly* Detector::buildModuleC() for (int ir = 0; ir < FVDBaseParam::nRingsC; ir++) { for (int ic = 0; ic < 8; ic ++) { - int cellId = ic + ir + FVDBaseParam::nCellA; + int cellId = ic + 8*ir + FVDBaseParam::nCellA; std::string tbsName = "tbs" + std::to_string(cellId); - std::string nodeName = "node" + std::to_string(cellId); + std::string nodeName = "fvd_node" + std::to_string(cellId); float rmin = FVDBaseParam::rRingsC[ir]; float rmax = FVDBaseParam::rRingsC[ir+1]; - float phimin = dphiDeg; - float phimax = dphiDeg; + float phimin = dphiDeg * ic; + float phimax = dphiDeg * (ic + 1); float dz = FVDBaseParam::dzScint; auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); @@ -280,3 +281,9 @@ TGeoVolumeAssembly* Detector::buildModuleC() return mod; } + +void Detector::defineSensitiveVolumes() +{ + LOG(info) << "Adding FVD Sentitive Volumes"; + +} From 863ff24b1cd13521fee20d8b9e77750520696a72 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sat, 7 Sep 2024 05:52:46 +0200 Subject: [PATCH 07/68] sensitive volumes --- .../ALICE3/FVD/simulation/src/Detector.cxx | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 118a29751dd8b..7d8e5fab984df 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -237,6 +237,8 @@ TGeoVolumeAssembly* Detector::buildModuleA() const float dphiDeg = 45.; for (int ir = 0; ir < FVDBaseParam::nRingsA; ir++) { + std::string rName = "fvd_ring" + std::to_string(ir+1); + TGeoVolumeAssembly *ring = new TGeoVolumeAssembly(rName.c_str()); for (int ic = 0; ic < 8; ic ++) { int cellId = ic + 8*ir; std::string tbsName = "tbs" + std::to_string(cellId); @@ -248,8 +250,9 @@ TGeoVolumeAssembly* Detector::buildModuleA() float dz = FVDBaseParam::dzScint; auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - mod->AddNode(nod, cellId); + ring->AddNode(nod, cellId); } + mod->AddNode(ring, ir); } return mod; @@ -264,6 +267,8 @@ TGeoVolumeAssembly* Detector::buildModuleC() const float dphiDeg = 45.; for (int ir = 0; ir < FVDBaseParam::nRingsC; ir++) { + std::string rName = "fvd_ring" + std::to_string(ir+1+FVDBaseParam::nRingsA); + TGeoVolumeAssembly *ring = new TGeoVolumeAssembly(rName.c_str()); for (int ic = 0; ic < 8; ic ++) { int cellId = ic + 8*ir + FVDBaseParam::nCellA; std::string tbsName = "tbs" + std::to_string(cellId); @@ -275,8 +280,9 @@ TGeoVolumeAssembly* Detector::buildModuleC() float dz = FVDBaseParam::dzScint; auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - mod->AddNode(nod, cellId); + ring->AddNode(nod, cellId); } + mod->AddNode(ring, ir); } return mod; @@ -285,5 +291,13 @@ TGeoVolumeAssembly* Detector::buildModuleC() void Detector::defineSensitiveVolumes() { LOG(info) << "Adding FVD Sentitive Volumes"; - + TGeoVolume *v; + TString volumeName; + + for (int iv = 0; iv < FVDBaseParam::nCellA + FVDBaseParam::nCellC; iv ++) { + volumeName = "fvd_node" + std::to_string(iv); + v = gGeoManager->GetVolume(volumeName); + LOG(info) << "Adding FVD Sensitive Volume => " << v->GetName(); + AddSensitiveVolume(v); + } } From 69019f6246e6d21cf8b0d48ade975e0007c3379d Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 12 Sep 2024 12:57:16 +0200 Subject: [PATCH 08/68] geometry update --- .../FVD/base/include/FVDBase/FVDBaseParam.h | 16 ++++++++-------- .../ALICE3/FVD/simulation/src/Detector.cxx | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index bb438f6dbce1c..1a4cb957af028 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -20,17 +20,17 @@ namespace o2 namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { - static constexpr int nCellA = 40; // 24 - static constexpr int nCellC = 48; - static constexpr int nRingsA = 5; //3 - static constexpr int nRingsC = 6; + static constexpr int nCellA = 48; + static constexpr int nCellC = 40; //24 + static constexpr int nRingsA = 6; + static constexpr int nRingsC = 5; //3 static constexpr float dzScint = 4.; - static constexpr float rRingsA[int(nCellA/8)+1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; - static constexpr float rRingsC[int(nCellC/8)+1] = {3.5, 17., 30.5, 44., 57.5, 71.}; + static constexpr float rRingsA[int(nCellA/8)+1] = {3.5, 14.8, 22.8, 37.3, 48.5, 59.8, 71.}; + static constexpr float rRingsC[int(nCellC/8)+1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; - static constexpr float zModA = 1700; - static constexpr float zModC = -1950; + static constexpr float zModA = 1950; + static constexpr float zModC = -1700; O2ParamDef(FVDBaseParam, "FVDBase"); }; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 7d8e5fab984df..3b9717425de73 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -122,7 +122,8 @@ Bool_t Detector::ProcessHits(FairVolume* vol) Int_t trackID = fMC->GetStack()->GetCurrentTrackNumber(); // Get unique ID of the detector cell (sensitive volume) - Int_t cellId = mGeometryTGeo->getCurrentCellId(fMC); + // Int_t cellId = mGeometryTGeo->getCurrentCellId(fMC); + int cellId = vol->getVolumeId(); math_utils::Point3D posStart(mTrackData.mPositionStart.X(), mTrackData.mPositionStart.Y(), mTrackData.mPositionStart.Z()); math_utils::Point3D posStop(positionStop.X(), positionStop.Y(), positionStop.Z()); From 84943c26b39ce8aee2aca0dfa482a70d0d9217cf Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 12 Sep 2024 14:25:17 +0200 Subject: [PATCH 09/68] geometry update --- .../FVD/base/include/FVDBase/FVDBaseParam.h | 16 ++++++++-------- .../ALICE3/FVD/simulation/src/Detector.cxx | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 1a4cb957af028..9751ab696040c 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -20,17 +20,17 @@ namespace o2 namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { - static constexpr int nCellA = 48; - static constexpr int nCellC = 40; //24 - static constexpr int nRingsA = 6; - static constexpr int nRingsC = 5; //3 + static constexpr int nCellA = 40; //24 + static constexpr int nCellC = 48; + static constexpr int nRingsA = 5; //3 + static constexpr int nRingsC = 6; static constexpr float dzScint = 4.; - static constexpr float rRingsA[int(nCellA/8)+1] = {3.5, 14.8, 22.8, 37.3, 48.5, 59.8, 71.}; - static constexpr float rRingsC[int(nCellC/8)+1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; + static constexpr float rRingsA[int(nCellA/8)+1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; + static constexpr float rRingsC[int(nCellC/8)+1] = {3.5, 14.8, 22.8, 37.3, 48.5, 59.8, 71.}; - static constexpr float zModA = 1950; - static constexpr float zModC = -1700; + static constexpr float zModA = 1700; + static constexpr float zModC = -1950; O2ParamDef(FVDBaseParam, "FVDBase"); }; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 3b9717425de73..48d689c934734 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -225,7 +225,7 @@ void Detector::buildModules() TGeoVolumeAssembly *vFVDA = buildModuleA(); TGeoVolumeAssembly *vFVDC = buildModuleC(); - vCave->AddNode(vFVDA, 0, new TGeoTranslation(0., 0., FVDBaseParam::zModA)); + vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., FVDBaseParam::zModA)); vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., FVDBaseParam::zModC)); } From 7c92e445fd184a8dd8b560f9a1b862864b630dfc Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 16 Sep 2024 22:27:41 +0200 Subject: [PATCH 10/68] enable hits --- DataFormats/Detectors/Upgrades/CMakeLists.txt | 1 - .../Detectors/Upgrades/FVD/CMakeLists.txt | 19 -- .../Upgrades/FVD/include/DataFormatsFVD/Hit.h | 108 ------- .../Upgrades/FVD/src/DataFormatsFVDLinkDef.h | 21 -- .../Detectors/Upgrades/FVD/src/Hits.cxx | 0 .../FVD/base/include/FVDBase/FVDBaseParam.h | 24 +- .../FVD/base/include/FVDBase/GeometryTGeo.h | 4 - .../ALICE3/FVD/base/src/GeometryTGeo.cxx | 25 +- .../ALICE3/FVD/simulation/CMakeLists.txt | 11 +- .../include/FVDSimulation/Detector.h | 62 +++- .../ALICE3/FVD/simulation/src/Detector.cxx | 287 ++++++++++-------- .../display/backend/GPUDisplayBackend.cxx | 2 +- .../display/frontend/GPUDisplayFrontend.cxx | 8 +- .../display/frontend/GPUDisplayKeys.cxx | 11 +- .../display/render/GPUDisplayDraw.cxx | 3 +- 15 files changed, 253 insertions(+), 333 deletions(-) delete mode 100644 DataFormats/Detectors/Upgrades/FVD/CMakeLists.txt delete mode 100644 DataFormats/Detectors/Upgrades/FVD/include/DataFormatsFVD/Hit.h delete mode 100644 DataFormats/Detectors/Upgrades/FVD/src/DataFormatsFVDLinkDef.h delete mode 100644 DataFormats/Detectors/Upgrades/FVD/src/Hits.cxx diff --git a/DataFormats/Detectors/Upgrades/CMakeLists.txt b/DataFormats/Detectors/Upgrades/CMakeLists.txt index a231c129e931f..a2d470b8ff6d5 100644 --- a/DataFormats/Detectors/Upgrades/CMakeLists.txt +++ b/DataFormats/Detectors/Upgrades/CMakeLists.txt @@ -10,4 +10,3 @@ # or submit itself to any jurisdiction. message(STATUS "Building dataformats for upgrades") -add_subdirectory(FVD) diff --git a/DataFormats/Detectors/Upgrades/FVD/CMakeLists.txt b/DataFormats/Detectors/Upgrades/FVD/CMakeLists.txt deleted file mode 100644 index ac3f66e2b7f88..0000000000000 --- a/DataFormats/Detectors/Upgrades/FVD/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2019-2020 CERN and copyright holders of ALICE O2. -# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -# All rights not expressly granted are reserved. -# -# This software is distributed under the terms of the GNU General Public -# License v3 (GPL Version 3), copied verbatim in the file "COPYING". -# -# In applying this license CERN does not waive the privileges and immunities -# granted to it by virtue of its status as an Intergovernmental Organization -# or submit itself to any jurisdiction. - -o2_add_library(DataFormatsFVD - PUBLIC_LINK_LIBRARIES O2::FVDBase - O2::CommonDataFormat -) - -o2_target_root_dictionary(DataFormatsFVD - HEADERS include/DataFormatsFVD/Hit.h -) diff --git a/DataFormats/Detectors/Upgrades/FVD/include/DataFormatsFVD/Hit.h b/DataFormats/Detectors/Upgrades/FVD/include/DataFormatsFVD/Hit.h deleted file mode 100644 index 3c9397f8be403..0000000000000 --- a/DataFormats/Detectors/Upgrades/FVD/include/DataFormatsFVD/Hit.h +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#ifndef ALICEO2_FVD_HIT_H_ -#define ALICEO2_FVD_HIT_H_ - -#include "SimulationDataFormat/BaseHits.h" // for BasicXYZEHit -#include "CommonUtils/ShmAllocator.h" -#include "TVector3.h" - -namespace o2 -{ -namespace fvd -{ - -class Hit : public o2::BasicXYZEHit -{ - - public: - Hit() = default; - - inline Hit(int trackID, - int cellID, - const math_utils::Point3D& startPos, - const math_utils::Point3D& endPos, - const math_utils::Vector3D& startMom, - double startE, - double endTime, - double eLoss, - int particlePdg); - - // Entrance position getters - math_utils::Point3D const& GetPosStart() const { return mPositionStart; } - Float_t GetStartX() const { return mPositionStart.X(); } - Float_t GetStartY() const { return mPositionStart.Y(); } - Float_t GetStartZ() const { return mPositionStart.Z(); } - template - void GetStartPosition(F& x, F& y, F& z) const - { - x = GetStartX(); - y = GetStartY(); - z = GetStartZ(); - } - - // Momentum getters - math_utils::Vector3D const& GetMomentum() const { return mMomentumStart; } - - math_utils::Vector3D& GetMomentum() { return mMomentumStart; } - Float_t GetPx() const { return mMomentumStart.X(); } - Float_t GetPy() const { return mMomentumStart.Y(); } - Float_t GetPz() const { return mMomentumStart.Z(); } - Float_t GetE() const { return mEnergyStart; } - - Float_t GetTotalEnergyAtEntrance() const { return GetE(); } - - int GetParticlePdg() const {return mParticlePdg;} - - void Print(const Option_t* opt) const; - - private: - int mParticlePdg; - float mEnergyStart; - math_utils::Vector3D mMomentumStart; ///< momentum at entrance - math_utils::Point3D mPositionStart; - ClassDefNV(Hit, 1); - -}; - -Hit::Hit(int trackID, - int detID, - const math_utils::Point3D& startPos, - const math_utils::Point3D& endPos, - const math_utils::Vector3D& startMom, - double startE, - double endTime, - double eLoss, - Int_t particlePdg) - : BasicXYZEHit(endPos.X(), - endPos.Y(), - endPos.Z(), - endTime, - eLoss, - trackID, - detID) -{ -} - -} // namespace fvd -} // namespace o2 - -#ifdef USESHM -namespace std -{ -template <> -class allocator : public o2::utils::ShmAllocator -{ -}; -} // namespace std -#endif -#endif diff --git a/DataFormats/Detectors/Upgrades/FVD/src/DataFormatsFVDLinkDef.h b/DataFormats/Detectors/Upgrades/FVD/src/DataFormatsFVDLinkDef.h deleted file mode 100644 index 6a976734918fe..0000000000000 --- a/DataFormats/Detectors/Upgrades/FVD/src/DataFormatsFVDLinkDef.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019-2024 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -#ifdef __CLING__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; - -#pragma link C++ class o2::fvd::Hit + ; -#pragma link C++ class vector < o2::fvd::Hit> + ; - -#endif diff --git a/DataFormats/Detectors/Upgrades/FVD/src/Hits.cxx b/DataFormats/Detectors/Upgrades/FVD/src/Hits.cxx deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 9751ab696040c..0d4f2e0f2796b 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -20,21 +20,25 @@ namespace o2 namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { - static constexpr int nCellA = 40; //24 - static constexpr int nCellC = 48; - static constexpr int nRingsA = 5; //3 - static constexpr int nRingsC = 6; - - static constexpr float dzScint = 4.; - static constexpr float rRingsA[int(nCellA/8)+1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; - static constexpr float rRingsC[int(nCellC/8)+1] = {3.5, 14.8, 22.8, 37.3, 48.5, 59.8, 71.}; - static constexpr float zModA = 1700; - static constexpr float zModC = -1950; +// int nringsA = 5; // 3 +// int nringsC = 6; + int nsect = 8; + + float dzscint = 4.; + std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; + std::vector ringsC = {3.5, 14.8, 22.8, 37.3, 48.5, 59.8, 71.}; + + int nringsA = ringsA.size() - 1; + int nringsC = ringsC.size() - 1; + + float zmodA = 1700; + float zmodC = -1950; O2ParamDef(FVDBaseParam, "FVDBase"); }; } // namespace fvd } // namespace o2 + #endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h index 45d20d0c59cc5..dd965262798a0 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h @@ -44,11 +44,7 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache static constexpr o2::detectors::DetID::ID getDetID() { return o2::detectors::DetID::FVD; } - int getCellId(int nmod, int nring, int nsec) const; - int getCurrentCellId(const TVirtualMC* fMC) const; - private: - static std::unique_ptr sInstance; ClassDefNV(GeometryTGeo, 1); diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx index 298c92d01b03e..0eaa4e2f39c04 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx @@ -17,7 +17,7 @@ #include using namespace o2::fvd; -namespace o2 +namespace o2 { namespace fvd { @@ -46,7 +46,7 @@ GeometryTGeo* GeometryTGeo::Instance() void GeometryTGeo::Build(int loadTrans) { - if (isBuilt()) { + if (isBuilt()) { LOGP(warning, "Already built"); return; // already initialized } @@ -62,24 +62,5 @@ void GeometryTGeo::fillMatrixCache(int mask) { } -int GeometryTGeo::getCellId(int nmod, int nring, int nsec) const -{ - return nmod * FVDBaseParam::nCellA + 8 * nring + nsec; -} - -int GeometryTGeo::getCurrentCellId(const TVirtualMC* fMC) const -{ - int moduleId = -1; - int sectorId = -1; - int ringId = -1; - - fMC->CurrentVolOffID(2, moduleId); - fMC->CurrentVolOffID(1, sectorId); - fMC->CurrentVolOffID(0, ringId); - int cellId = getCellId(moduleId, ringId, sectorId); - - return cellId; -} - } // namespace fvd -} //namespace o2 +} // namespace o2 diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt index c5062092349df..30177cfa3adb1 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt @@ -10,11 +10,12 @@ # or submit itself to any jurisdiction. o2_add_library(FVDSimulation - SOURCES src/Detector.cxx - PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat - O2::DataFormatsFVD) + SOURCES src/Detector.cxx + PUBLIC_LINK_LIBRARIES O2::FVDBase + O2::ITSMFTSimulation + ROOT::Physics) o2_target_root_dictionary(FVDSimulation - HEADERS include/FVDSimulation/Detector.h) - + HEADERS include/FVDSimulation/Detector.h) +o2_data_file(COPY data DESTINATION Detectors/FVD/simulation) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h index a6c373527f87b..1ad50d371ff4f 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h @@ -9,15 +9,22 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file Detector.h +/// \brief Definition of the Detector class + #ifndef ALICEO2_FVD_DETECTOR_H_ #define ALICEO2_FVD_DETECTOR_H_ #include "SimulationDataFormat/BaseHits.h" #include "DetectorsBase/Detector.h" -#include "DataFormatsFVD/Hit.h" #include "FVDBase/GeometryTGeo.h" +#include "FVDBase/FVDBaseParam.h" +#include "ITSMFTSimulation/Hit.h" +#include "Rtypes.h" +#include "TGeoManager.h" +#include "TLorentzVector.h" +#include "TVector3.h" -class FairModule; class FairVolume; class TGeoVolume; @@ -26,23 +33,36 @@ namespace o2 namespace fvd { class GeometryTGeo; -class Hit; +} +} + +namespace o2 +{ +namespace fvd +{ + class Detector : public o2::base::DetImpl { public: - Detector(Bool_t Active); + Detector(bool Active); Detector() = default; + ~Detector() override; void ConstructGeometry() override; - o2::fvd::Hit* addHit(Int_t trackId, Int_t cellId, - const math_utils::Point3D& startPos, const math_utils::Point3D& endPos, - const math_utils::Vector3D& startMom, double startE, - double endTime, double eLoss, Int_t particlePdg); - - std::vector* getHits(Int_t iColl) + /// This method is an example of how to add your own point of type Hit to the clones array + o2::itsmft::Hit* addHit(int trackID, int detID, + const TVector3& startPos, + const TVector3& endPos, + const TVector3& startMom, + double startE, + double endTime, double eLoss, + unsigned int startStatus, + unsigned int endStatus); + + std::vector* getHits(Int_t iColl) { if (iColl == 0) { return mHits; @@ -69,28 +89,40 @@ class Detector : public o2::base::DetImpl }; private: - Detector(const Detector& rhs); + Detector(const Detector&); Detector& operator=(const Detector&); - std::vector* mHits = nullptr; - GeometryTGeo* mGeometryTGeo = nullptr; + std::vector* mHits = nullptr; + GeometryTGeo* mGeometryTGeo = nullptr; TGeoVolumeAssembly* buildModuleA(); TGeoVolumeAssembly* buildModuleC(); + int mNumberOfRingsA; + int mNumberOfRingsC; + int mNumberOfSectors; + float mDzScint; + + std::vector mRingRadiiA; + std::vector mRingRadiiC; + + float mZmodA; + float mZmodC; + void defineSensitiveVolumes(); /// Transient data about track passing the sensor, needed by ProcessHits() struct TrackData { // this is transient bool mHitStarted; //! hit creation started - TLorentzVector mPositionStart; //! position at entrance + unsigned char mTrkStatusStart; //! track status flag + TLorentzVector mPositionStart; //! position at entrance TLorentzVector mMomentumStart; //! momentum double mEnergyLoss; //! energy loss } mTrackData; //! template friend class o2::base::DetImpl; - ClassDefOverride(Detector, 2); + ClassDefOverride(Detector, 1); }; // Input and output function for standard C++ input/output. diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 48d689c934734..836b261ee0d4d 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -9,19 +9,25 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include "DataFormatsFVD/Hit.h" +/// \file Detector.cxx +/// \brief Implementation of the Detector class +#include "ITSMFTSimulation/Hit.h" #include "FVDSimulation/Detector.h" - #include "FVDBase/GeometryTGeo.h" #include "FVDBase/FVDBaseParam.h" #include "DetectorsBase/Stack.h" +#include "SimulationDataFormat/TrackReference.h" #include "Field/MagneticField.h" +// FairRoot includes +#include "FairDetector.h" #include -#include "FairRootManager.h" -#include "FairVolume.h" +#include "FairRootManager.h" +#include "FairRun.h" +#include "FairRuntimeDb.h" +#include "FairVolume.h" #include "FairRootManager.h" #include "TVirtualMC.h" @@ -35,33 +41,49 @@ #include #include "TRandom.h" -using namespace o2::fvd; -using o2::fvd::GeometryTGeo; -using o2::fvd::Hit; +class FairModule; -ClassImp(o2::fvd::Detector); +class TGeoMedium; -Detector::Detector(Bool_t Active) - : o2::base::DetImpl("FVD", Active), - mHits(o2::utils::createSimVector()), - mGeometryTGeo(nullptr) +using namespace o2::fvd; +using o2::itsmft::Hit; + +Detector::Detector(bool active) + : o2::base::DetImpl("FVD", true), + mHits(o2::utils::createSimVector()), + mGeometryTGeo(nullptr), + mTrackData() { + auto& baseParam = FVDBaseParam::Instance(); + mNumberOfRingsA = baseParam.nringsA; + mNumberOfRingsC = baseParam.nringsC; + mNumberOfSectors = baseParam.nsect; + + mDzScint = baseParam.dzscint; + + mRingRadiiA = baseParam.ringsA; + mRingRadiiC = baseParam.ringsC; + + mZmodA = baseParam.zmodA; + mZmodC = baseParam.zmodC; } -Detector::Detector(const Detector& src) - : o2::base::DetImpl(src), - mHits(o2::utils::createSimVector()) +Detector::Detector(const Detector& rhs) + : o2::base::DetImpl(rhs), + mTrackData(), + mHits(o2::utils::createSimVector()) { } -Detector& Detector::operator=(const Detector& src) +Detector& Detector::operator=(const Detector& rhs) { - if (this == &src) { + if (this == &rhs) { return *this; } // base class assignment - base::Detector::operator=(src); + base::Detector::operator=(rhs); + mTrackData = rhs.mTrackData; mHits = nullptr; return *this; @@ -79,86 +101,110 @@ void Detector::InitializeO2Detector() { LOG(info) << "Initialize FVD detector"; mGeometryTGeo = GeometryTGeo::Instance(); + defineSensitiveVolumes(); } -Bool_t Detector::ProcessHits(FairVolume* vol) +bool Detector::ProcessHits(FairVolume* vol) { // This method is called from the MC stepping // Track only charged particles and photons - bool isPhotonTrack = false; - Int_t particlePdg = fMC->TrackPid(); - if (particlePdg == 22) { // If particle is standard PDG photon - isPhotonTrack = true; - } - if (!(isPhotonTrack || fMC->TrackCharge())) { + if (fMC->TrackCharge()) { return kFALSE; } + + auto stack = (o2::data::Stack*)fMC->GetStack(); + + int cellId = vol->getVolumeId(); // Check track status to define when hit is started and when it is stopped bool startHit = false, stopHit = false; - if ((fMC->IsTrackEntering()) || (fMC->IsTrackInside() && !mTrackData.mHitStarted)) { + unsigned char status = 0; + + Int_t currVolId, offId; + + if (fMC->IsTrackEntering()) { + status |= Hit::kTrackEntering; + } + if (fMC->IsTrackInside()) { + status |= Hit::kTrackInside; + } + if (fMC->IsTrackExiting()) { + status |= Hit::kTrackExiting; + } + if (fMC->IsTrackOut()) { + status |= Hit::kTrackOut; + } + if (fMC->IsTrackStop()) { + status |= Hit::kTrackStopped; + } + if (fMC->IsTrackAlive()) { + status |= Hit::kTrackAlive; + } + + // track is entering or created in the volume + if ((status & Hit::kTrackEntering) || (status & Hit::kTrackInside && !mTrackData.mHitStarted)) { startHit = true; - } else if ((fMC->IsTrackExiting() || fMC->IsTrackOut() || fMC->IsTrackStop())) { + } else if ((status & (Hit::kTrackExiting | Hit::kTrackOut | Hit::kTrackStopped))) { stopHit = true; } - // Increment energy loss at all steps except entrance + // increment energy loss at all steps except entrance if (!startHit) { mTrackData.mEnergyLoss += fMC->Edep(); } + if (!(startHit | stopHit)) { + return kFALSE; // do noting + } - // Track is entering or created in the volume - // Start registering new hit, defined as the combination of all the steps from a given particle if (startHit) { mTrackData.mHitStarted = true; mTrackData.mEnergyLoss = 0.; fMC->TrackMomentum(mTrackData.mMomentumStart); fMC->TrackPosition(mTrackData.mPositionStart); + mTrackData.mTrkStatusStart = true; } if (stopHit) { TLorentzVector positionStop; fMC->TrackPosition(positionStop); - Int_t trackID = fMC->GetStack()->GetCurrentTrackNumber(); - - // Get unique ID of the detector cell (sensitive volume) - // Int_t cellId = mGeometryTGeo->getCurrentCellId(fMC); - int cellId = vol->getVolumeId(); - - math_utils::Point3D posStart(mTrackData.mPositionStart.X(), mTrackData.mPositionStart.Y(), mTrackData.mPositionStart.Z()); - math_utils::Point3D posStop(positionStop.X(), positionStop.Y(), positionStop.Z()); - math_utils::Vector3D momStart(mTrackData.mMomentumStart.Px(), mTrackData.mMomentumStart.Py(), mTrackData.mMomentumStart.Pz()); - addHit(trackID, cellId, posStart, posStop, momStart, - mTrackData.mMomentumStart.E(), positionStop.T(), - mTrackData.mEnergyLoss, particlePdg); + Int_t trackId = fMC->GetStack()->GetCurrentTrackNumber(); + + Hit *p = addHit(trackId, cellId, mTrackData.mPositionStart.Vect(), positionStop.Vect(), + mTrackData.mMomentumStart.Vect(), mTrackData.mMomentumStart.E(), + positionStop.T(), mTrackData.mEnergyLoss, mTrackData.mTrkStatusStart, + status); + stack->addHit(GetDetId()); } else { - return kFALSE; // do nothing more + return false; // do nothing more } - - return kTRUE; + return true; } -o2::fvd::Hit* Detector::addHit(Int_t trackId, Int_t cellId, - const math_utils::Point3D& startPos, const math_utils::Point3D& endPos, - const math_utils::Vector3D& startMom, double startE, - double endTime, double eLoss, Int_t particlePdg) +o2::itsmft::Hit* Detector::addHit(Int_t trackId, Int_t cellId, + const TVector3& startPos, + const TVector3& endPos, + const TVector3& startMom, + double startE, + double endTime, + double eLoss, + unsigned int startStatus, + unsigned int endStatus) { - mHits->emplace_back(trackId, cellId, startPos, endPos, startMom, startE, endTime, eLoss, particlePdg); - auto stack = (o2::data::Stack*)fMC->GetStack(); - stack->addHit(GetDetId()); + mHits->emplace_back(trackId, cellId, startPos, + endPos, startMom, startE, endTime, eLoss, startStatus, endStatus); return &(mHits->back()); } -void Detector::ConstructGeometry() +void Detector::ConstructGeometry() { - createMaterials(); - buildModules(); - defineSensitiveVolumes(); + createMaterials(); + buildModules(); + //defineSensitiveVolumes(); } - -void Detector::EndOfEvent() { - Reset(); +void Detector::EndOfEvent() +{ + Reset(); } void Detector::Register() @@ -195,16 +241,16 @@ void Detector::createMaterials() Int_t matId = 0; // tmp material id number const Int_t unsens = 0, sens = 1; // sensitive or unsensitive medium - // - Int_t fieldType = 3; // Field type - Float_t maxField = 5.0; // Field max. + // + Int_t fieldType = 3; // Field type + Float_t maxField = 5.0; // Field max. Float_t tmaxfd = -10.0; // max deflection angle due to magnetic field in one step Float_t stemax = 0.1; // max step allowed [cm] Float_t deemax = 1.0; // maximum fractional energy loss in one step 0GetVolume("cave"); if (!vCave) { - LOG(fatal) << "Could not find the top volume!"; + LOG(fatal) << "Could not find the top volume!"; } // create modules - TGeoVolumeAssembly *vFVDA = buildModuleA(); - TGeoVolumeAssembly *vFVDC = buildModuleC(); + TGeoVolumeAssembly* vFVDA = buildModuleA(); + TGeoVolumeAssembly* vFVDC = buildModuleC(); - vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., FVDBaseParam::zModA)); - vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., FVDBaseParam::zModC)); + vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., mZmodA)); + vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., mZmodC)); } TGeoVolumeAssembly* Detector::buildModuleA() { TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDA"); - const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); - - const float dphiDeg = 45.; - - for (int ir = 0; ir < FVDBaseParam::nRingsA; ir++) { - std::string rName = "fvd_ring" + std::to_string(ir+1); - TGeoVolumeAssembly *ring = new TGeoVolumeAssembly(rName.c_str()); - for (int ic = 0; ic < 8; ic ++) { - int cellId = ic + 8*ir; - std::string tbsName = "tbs" + std::to_string(cellId); - std::string nodeName = "fvd_node" + std::to_string(cellId); - float rmin = FVDBaseParam::rRingsA[ir]; - float rmax = FVDBaseParam::rRingsA[ir+1]; - float phimin = dphiDeg * ic; - float phimax = dphiDeg * (ic + 1); - float dz = FVDBaseParam::dzScint; - auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); - auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - ring->AddNode(nod, cellId); - } - mod->AddNode(ring, ir); + const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + + float dphiDeg = 360./mNumberOfSectors; + + for (int ir = 0; ir < mNumberOfRingsA; ir++) { + std::string rName = "fvd_ring" + std::to_string(ir + 1); + TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); + for (int ic = 0; ic < mNumberOfSectors; ic++) { + int cellId = ic + mNumberOfSectors * ir; + std::string nodeName = "fvd_node" + std::to_string(cellId); + float rmin = mRingRadiiA[ir]; + float rmax = mRingRadiiA[ir + 1]; + float phimin = dphiDeg * ic; + float phimax = dphiDeg * (ic + 1); + auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + ring->AddNode(nod, cellId); + } + mod->AddNode(ring, ir); } return mod; @@ -263,27 +307,25 @@ TGeoVolumeAssembly* Detector::buildModuleC() { TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDC"); - const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); - - const float dphiDeg = 45.; - - for (int ir = 0; ir < FVDBaseParam::nRingsC; ir++) { - std::string rName = "fvd_ring" + std::to_string(ir+1+FVDBaseParam::nRingsA); - TGeoVolumeAssembly *ring = new TGeoVolumeAssembly(rName.c_str()); - for (int ic = 0; ic < 8; ic ++) { - int cellId = ic + 8*ir + FVDBaseParam::nCellA; - std::string tbsName = "tbs" + std::to_string(cellId); - std::string nodeName = "fvd_node" + std::to_string(cellId); - float rmin = FVDBaseParam::rRingsC[ir]; - float rmax = FVDBaseParam::rRingsC[ir+1]; - float phimin = dphiDeg * ic; - float phimax = dphiDeg * (ic + 1); - float dz = FVDBaseParam::dzScint; - auto tbs = new TGeoTubeSeg(tbsName.c_str(), rmin, rmax, dz, phimin, phimax); - auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - ring->AddNode(nod, cellId); - } - mod->AddNode(ring, ir); + const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + + float dphiDeg = 360./mNumberOfSectors; + + for (int ir = 0; ir < mNumberOfRingsC; ir++) { + std::string rName = "fvd_ring" + std::to_string(ir + 1 + mNumberOfRingsA); + TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); + for (int ic = 0; ic < mNumberOfSectors; ic++) { + int cellId = ic + mNumberOfSectors * (ir + mNumberOfRingsA); + std::string nodeName = "fvd_node" + std::to_string(cellId); + float rmin = mRingRadiiC[ir]; + float rmax = mRingRadiiC[ir + 1]; + float phimin = dphiDeg * ic; + float phimax = dphiDeg * (ic + 1); + auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + ring->AddNode(nod, cellId); + } + mod->AddNode(ring, ir); } return mod; @@ -291,14 +333,19 @@ TGeoVolumeAssembly* Detector::buildModuleC() void Detector::defineSensitiveVolumes() { - LOG(info) << "Adding FVD Sentitive Volumes"; - TGeoVolume *v; - TString volumeName; - - for (int iv = 0; iv < FVDBaseParam::nCellA + FVDBaseParam::nCellC; iv ++) { - volumeName = "fvd_node" + std::to_string(iv); - v = gGeoManager->GetVolume(volumeName); - LOG(info) << "Adding FVD Sensitive Volume => " << v->GetName(); - AddSensitiveVolume(v); - } + LOG(info) << "Adding FVD Sentitive Volumes"; + TGeoVolume* v; + TString volumeName; + + int nCellA = mNumberOfRingsA*mNumberOfSectors; + int nCellC = mNumberOfRingsC*mNumberOfSectors; + + for (int iv = 0; iv < nCellA + nCellC; iv++) { + volumeName = "fvd_node" + std::to_string(iv); + v = gGeoManager->GetVolume(volumeName); + LOG(info) << "Adding FVD Sensitive Volume => " << v->GetName(); + AddSensitiveVolume(v); + } } + +ClassImp(o2::fvd::Detector); diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx b/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx index 86722d5d44df6..c6edd5cd40419 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx @@ -48,7 +48,7 @@ GPUDisplayBackend* GPUDisplayBackend::getBackend(const char* type) return new GPUDisplayBackendVulkan; } else #endif - if (strcmp(type, "opengl") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "opengl") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayBackendOpenGL; } else { GPUError("Requested renderer not available"); diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx index fc5bec4a3d6fb..437ff654fe9d8 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx @@ -122,7 +122,7 @@ GPUDisplayFrontend* GPUDisplayFrontend::getFrontend(const char* type) } else #endif #ifdef _WIN32 - if (strcmp(type, "windows") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "windows") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayFrontendWindows; } else #elif defined(GPUCA_BUILD_EVENT_DISPLAY_X11) @@ -131,17 +131,17 @@ GPUDisplayFrontend* GPUDisplayFrontend::getFrontend(const char* type) } else #endif #if defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW) - if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayFrontendGlfw; } else #endif #ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND - if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) { + if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) { return new GPUDisplayFrontendWayland; } else #endif #ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT - if (strcmp(type, "glut") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "glut") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayFrontendGlut; } else #endif diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx index 16f76468c663a..9a2481d1964cb 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx @@ -175,7 +175,12 @@ void GPUDisplay::HandleKey(unsigned char key) mCfgH.markClusters <<= 1; } SetInfo("Cluster flag highlight mask set to %d (%s)", mCfgH.markClusters, - mCfgH.markClusters == 0 ? "off" : mCfgH.markClusters == 1 ? "split pad" : mCfgH.markClusters == 2 ? "split time" : mCfgH.markClusters == 4 ? "edge" : mCfgH.markClusters == 8 ? "singlePad" : mCfgH.markClusters == 0x10 ? "reject distance" : "reject error"); + mCfgH.markClusters == 0 ? "off" : mCfgH.markClusters == 1 ? "split pad" + : mCfgH.markClusters == 2 ? "split time" + : mCfgH.markClusters == 4 ? "edge" + : mCfgH.markClusters == 8 ? "singlePad" + : mCfgH.markClusters == 0x10 ? "reject distance" + : "reject error"); } else if (key == 'z') { mCfgH.markFakeClusters ^= 1; SetInfo("Marking fake clusters: %s", mCfgH.markFakeClusters ? "on" : "off"); @@ -389,7 +394,9 @@ void GPUDisplay::HandleKey(unsigned char key) if (mCfgL.animationMode == 6) { SetInfo("Animation mode %d - Centered on origin", mCfgL.animationMode); } else { - SetInfo("Animation mode %d - Position: %s, Direction: %s", mCfgL.animationMode, (mCfgL.animationMode & 2) ? "Spherical (spherical rotation)" : (mCfgL.animationMode & 4) ? "Spherical (Euler angles)" : "Cartesian", (mCfgL.animationMode & 1) ? "Euler angles" : "Quaternion"); + SetInfo("Animation mode %d - Position: %s, Direction: %s", mCfgL.animationMode, (mCfgL.animationMode & 2) ? "Spherical (spherical rotation)" : (mCfgL.animationMode & 4) ? "Spherical (Euler angles)" + : "Cartesian", + (mCfgL.animationMode & 1) ? "Euler angles" : "Quaternion"); } } else if (key == 'u') { mCfgH.trackFilter = (mCfgH.trackFilter + 1) % (mConfig.filterMacros.size() + 1); diff --git a/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx b/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx index 0b0eed697de2d..801ec0abddbe8 100644 --- a/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx +++ b/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx @@ -127,7 +127,8 @@ GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, unsigned in size_t startCountInner = mVertexBuffer[iSlice].size(); if (mOverlayTFClusters.size() > 0 || iCol == 0 || mNCollissions) { const int firstCluster = (mOverlayTFClusters.size() > 1 && iCol > 0) ? mOverlayTFClusters[iCol - 1][iSlice] : 0; - const int lastCluster = (mOverlayTFClusters.size() > 1 && iCol + 1 < mOverlayTFClusters.size()) ? mOverlayTFClusters[iCol][iSlice] : (mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] : 0); + const int lastCluster = (mOverlayTFClusters.size() > 1 && iCol + 1 < mOverlayTFClusters.size()) ? mOverlayTFClusters[iCol][iSlice] : (mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] + : 0); const bool checkClusterCollision = mQA && mNCollissions && mOverlayTFClusters.size() == 0 && mIOPtrs->clustersNative && mIOPtrs->clustersNative->clustersMCTruth; for (int cidInSlice = firstCluster; cidInSlice < lastCluster; cidInSlice++) { const int cid = GET_CID(iSlice, cidInSlice); From 2b00551a7544732a01b1d9a36d477670555c647a Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 16 Sep 2024 22:29:26 +0200 Subject: [PATCH 11/68] enable hits --- .../FVD/base/include/FVDBase/FVDBaseParam.h | 8 ++--- .../include/FVDSimulation/Detector.h | 30 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 0d4f2e0f2796b..b5cf3d8c8e32e 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -21,9 +21,9 @@ namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { -// int nringsA = 5; // 3 -// int nringsC = 6; - int nsect = 8; + // int nringsA = 5; // 3 + // int nringsC = 6; + int nsect = 8; float dzscint = 4.; std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; @@ -40,5 +40,5 @@ struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { } // namespace fvd } // namespace o2 - + #endif diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h index 1ad50d371ff4f..b6b473489946f 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h @@ -19,11 +19,11 @@ #include "DetectorsBase/Detector.h" #include "FVDBase/GeometryTGeo.h" #include "FVDBase/FVDBaseParam.h" -#include "ITSMFTSimulation/Hit.h" -#include "Rtypes.h" -#include "TGeoManager.h" -#include "TLorentzVector.h" -#include "TVector3.h" +#include "ITSMFTSimulation/Hit.h" +#include "Rtypes.h" +#include "TGeoManager.h" +#include "TLorentzVector.h" +#include "TVector3.h" class FairVolume; class TGeoVolume; @@ -34,7 +34,7 @@ namespace fvd { class GeometryTGeo; } -} +} // namespace o2 namespace o2 { @@ -53,14 +53,14 @@ class Detector : public o2::base::DetImpl void ConstructGeometry() override; /// This method is an example of how to add your own point of type Hit to the clones array - o2::itsmft::Hit* addHit(int trackID, int detID, - const TVector3& startPos, - const TVector3& endPos, - const TVector3& startMom, - double startE, - double endTime, double eLoss, - unsigned int startStatus, - unsigned int endStatus); + o2::itsmft::Hit* addHit(int trackID, int detID, + const TVector3& startPos, + const TVector3& endPos, + const TVector3& startMom, + double startE, + double endTime, double eLoss, + unsigned int startStatus, + unsigned int endStatus); std::vector* getHits(Int_t iColl) { @@ -105,7 +105,7 @@ class Detector : public o2::base::DetImpl std::vector mRingRadiiA; std::vector mRingRadiiC; - + float mZmodA; float mZmodC; From c070c3ff228d7bba61bb33662ead77bcdf4136eb Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 16 Sep 2024 22:29:37 +0200 Subject: [PATCH 12/68] enable hits --- Detectors/Upgrades/ALICE3/FVD/simulation/data/simcuts.dat | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Detectors/Upgrades/ALICE3/FVD/simulation/data/simcuts.dat diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/data/simcuts.dat b/Detectors/Upgrades/ALICE3/FVD/simulation/data/simcuts.dat new file mode 100644 index 0000000000000..e69de29bb2d1d From 1ea137b441c2dfc29c210bbe61c6a537834c01ca Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 18 Sep 2024 12:32:59 +0200 Subject: [PATCH 13/68] fix channel ids --- .../include/FVDSimulation/Detector.h | 2 + .../ALICE3/FVD/simulation/src/Detector.cxx | 39 +++++++++++++++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h index b6b473489946f..9afcb6e251945 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h @@ -111,6 +111,8 @@ class Detector : public o2::base::DetImpl void defineSensitiveVolumes(); + int getChannelId(TVector3 vec); + /// Transient data about track passing the sensor, needed by ProcessHits() struct TrackData { // this is transient bool mHitStarted; //! hit creation started diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 836b261ee0d4d..21d11406f28c8 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -167,9 +167,11 @@ bool Detector::ProcessHits(FairVolume* vol) if (stopHit) { TLorentzVector positionStop; fMC->TrackPosition(positionStop); - Int_t trackId = fMC->GetStack()->GetCurrentTrackNumber(); + int trackId = fMC->GetStack()->GetCurrentTrackNumber(); - Hit *p = addHit(trackId, cellId, mTrackData.mPositionStart.Vect(), positionStop.Vect(), + int chId = getChannelId(mTrackData.mPositionStart.Vect()); + + Hit *p = addHit(trackId, chId /*cellId*/, mTrackData.mPositionStart.Vect(), positionStop.Vect(), mTrackData.mMomentumStart.Vect(), mTrackData.mMomentumStart.E(), positionStop.T(), mTrackData.mEnergyLoss, mTrackData.mTrkStatusStart, status); @@ -199,7 +201,6 @@ void Detector::ConstructGeometry() { createMaterials(); buildModules(); - //defineSensitiveVolumes(); } void Detector::EndOfEvent() @@ -271,8 +272,8 @@ void Detector::buildModules() TGeoVolumeAssembly* vFVDA = buildModuleA(); TGeoVolumeAssembly* vFVDC = buildModuleC(); - vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., mZmodA)); - vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., mZmodC)); + vCave->AddNode(vFVDA, 2, new TGeoTranslation(0., 0., mZmodA)); + vCave->AddNode(vFVDC, 2, new TGeoTranslation(0., 0., mZmodC)); } TGeoVolumeAssembly* Detector::buildModuleA() @@ -297,7 +298,7 @@ TGeoVolumeAssembly* Detector::buildModuleA() auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); ring->AddNode(nod, cellId); } - mod->AddNode(ring, ir); + mod->AddNode(ring, 1); } return mod; @@ -325,7 +326,7 @@ TGeoVolumeAssembly* Detector::buildModuleC() auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); ring->AddNode(nod, cellId); } - mod->AddNode(ring, ir); + mod->AddNode(ring, 1); } return mod; @@ -348,4 +349,28 @@ void Detector::defineSensitiveVolumes() } } +int Detector::getChannelId(TVector3 vec) +{ + float phi = vec.Phi(); + if (phi < 0) phi += TMath::TwoPi(); + float r = vec.Perp(); + float z = vec.Z(); + + int isect = int(phi/(TMath::Pi()/4)); + + std::vectorrd = z > 0 ? mRingRadiiA : mRingRadiiC; + int noff = z > 0 ? 0 : mNumberOfRingsA*mNumberOfSectors; + + int ir = 0; + + for (int i = 1; i < rd.size(); i++) { + if (r < rd[i]) + break; + else + ir ++; + } + + return ir * mNumberOfSectors + isect + noff; +} + ClassImp(o2::fvd::Detector); From 340cf4770fc3b956fb9bde1215b542646222d382 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 18 Sep 2024 16:31:13 +0200 Subject: [PATCH 14/68] More flexible confgurable parameters --- .../ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h | 11 +++-------- .../Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 12 +++++++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index b5cf3d8c8e32e..9a1d1d17a4981 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -21,19 +21,14 @@ namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { - // int nringsA = 5; // 3 - // int nringsC = 6; - int nsect = 8; - - float dzscint = 4.; + static constexpr int nsect = 8; + std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; std::vector ringsC = {3.5, 14.8, 22.8, 37.3, 48.5, 59.8, 71.}; - int nringsA = ringsA.size() - 1; - int nringsC = ringsC.size() - 1; - float zmodA = 1700; float zmodC = -1950; + float dzscint = 4.; O2ParamDef(FVDBaseParam, "FVDBase"); }; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 21d11406f28c8..303638e40f021 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -55,8 +55,6 @@ Detector::Detector(bool active) mTrackData() { auto& baseParam = FVDBaseParam::Instance(); - mNumberOfRingsA = baseParam.nringsA; - mNumberOfRingsC = baseParam.nringsC; mNumberOfSectors = baseParam.nsect; mDzScint = baseParam.dzscint; @@ -64,6 +62,9 @@ Detector::Detector(bool active) mRingRadiiA = baseParam.ringsA; mRingRadiiC = baseParam.ringsC; + mNumberOfRingsA = mRingRadiiA.size() - 1; + mNumberOfRingsC = mRingRadiiC.size() - 1; + mZmodA = baseParam.zmodA; mZmodC = baseParam.zmodC; } @@ -108,7 +109,12 @@ bool Detector::ProcessHits(FairVolume* vol) { // This method is called from the MC stepping // Track only charged particles and photons - if (fMC->TrackCharge()) { + bool isPhotonTrack = false; + Int_t particlePdg = fMC->TrackPid(); + if (particlePdg == 22) { // If particle is standard PDG photon + isPhotonTrack = true; + } + if (!(isPhotonTrack || fMC->TrackCharge())) { return kFALSE; } From f77b1c2c94cd7b3d5a93547546d746251ac2dc90 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 18 Sep 2024 16:53:09 +0200 Subject: [PATCH 15/68] More flexible confgurable parameters --- .../FVD/base/include/FVDBase/FVDBaseParam.h | 2 +- .../ALICE3/FVD/simulation/src/Detector.cxx | 101 +++++++++--------- 2 files changed, 52 insertions(+), 51 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 9a1d1d17a4981..3b32be64444ac 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -22,7 +22,7 @@ namespace fvd struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { static constexpr int nsect = 8; - + std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; std::vector ringsC = {3.5, 14.8, 22.8, 37.3, 48.5, 59.8, 71.}; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 303638e40f021..265f900c72bd1 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -22,12 +22,12 @@ #include "Field/MagneticField.h" // FairRoot includes -#include "FairDetector.h" +#include "FairDetector.h" #include -#include "FairRootManager.h" -#include "FairRun.h" -#include "FairRuntimeDb.h" -#include "FairVolume.h" +#include "FairRootManager.h" +#include "FairRun.h" +#include "FairRuntimeDb.h" +#include "FairVolume.h" #include "FairRootManager.h" #include "TVirtualMC.h" @@ -54,19 +54,19 @@ Detector::Detector(bool active) mGeometryTGeo(nullptr), mTrackData() { - auto& baseParam = FVDBaseParam::Instance(); - mNumberOfSectors = baseParam.nsect; + auto& baseParam = FVDBaseParam::Instance(); + mNumberOfSectors = baseParam.nsect; - mDzScint = baseParam.dzscint; + mDzScint = baseParam.dzscint; - mRingRadiiA = baseParam.ringsA; - mRingRadiiC = baseParam.ringsC; + mRingRadiiA = baseParam.ringsA; + mRingRadiiC = baseParam.ringsC; - mNumberOfRingsA = mRingRadiiA.size() - 1; - mNumberOfRingsC = mRingRadiiC.size() - 1; + mNumberOfRingsA = mRingRadiiA.size() - 1; + mNumberOfRingsC = mRingRadiiC.size() - 1; - mZmodA = baseParam.zmodA; - mZmodC = baseParam.zmodC; + mZmodA = baseParam.zmodA; + mZmodC = baseParam.zmodC; } Detector::Detector(const Detector& rhs) @@ -117,7 +117,7 @@ bool Detector::ProcessHits(FairVolume* vol) if (!(isPhotonTrack || fMC->TrackCharge())) { return kFALSE; } - + auto stack = (o2::data::Stack*)fMC->GetStack(); int cellId = vol->getVolumeId(); @@ -125,7 +125,7 @@ bool Detector::ProcessHits(FairVolume* vol) // Check track status to define when hit is started and when it is stopped bool startHit = false, stopHit = false; unsigned char status = 0; - + Int_t currVolId, offId; if (fMC->IsTrackEntering()) { @@ -175,12 +175,12 @@ bool Detector::ProcessHits(FairVolume* vol) fMC->TrackPosition(positionStop); int trackId = fMC->GetStack()->GetCurrentTrackNumber(); - int chId = getChannelId(mTrackData.mPositionStart.Vect()); + int chId = getChannelId(mTrackData.mPositionStart.Vect()); - Hit *p = addHit(trackId, chId /*cellId*/, mTrackData.mPositionStart.Vect(), positionStop.Vect(), - mTrackData.mMomentumStart.Vect(), mTrackData.mMomentumStart.E(), - positionStop.T(), mTrackData.mEnergyLoss, mTrackData.mTrkStatusStart, - status); + Hit* p = addHit(trackId, chId /*cellId*/, mTrackData.mPositionStart.Vect(), positionStop.Vect(), + mTrackData.mMomentumStart.Vect(), mTrackData.mMomentumStart.E(), + positionStop.T(), mTrackData.mEnergyLoss, mTrackData.mTrkStatusStart, + status); stack->addHit(GetDetId()); } else { return false; // do nothing more @@ -189,17 +189,17 @@ bool Detector::ProcessHits(FairVolume* vol) } o2::itsmft::Hit* Detector::addHit(Int_t trackId, Int_t cellId, - const TVector3& startPos, - const TVector3& endPos, - const TVector3& startMom, - double startE, - double endTime, - double eLoss, - unsigned int startStatus, - unsigned int endStatus) + const TVector3& startPos, + const TVector3& endPos, + const TVector3& startMom, + double startE, + double endTime, + double eLoss, + unsigned int startStatus, + unsigned int endStatus) { - mHits->emplace_back(trackId, cellId, startPos, - endPos, startMom, startE, endTime, eLoss, startStatus, endStatus); + mHits->emplace_back(trackId, cellId, startPos, + endPos, startMom, startE, endTime, eLoss, startStatus, endStatus); return &(mHits->back()); } @@ -288,7 +288,7 @@ TGeoVolumeAssembly* Detector::buildModuleA() const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); - float dphiDeg = 360./mNumberOfSectors; + float dphiDeg = 360. / mNumberOfSectors; for (int ir = 0; ir < mNumberOfRingsA; ir++) { std::string rName = "fvd_ring" + std::to_string(ir + 1); @@ -316,7 +316,7 @@ TGeoVolumeAssembly* Detector::buildModuleC() const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); - float dphiDeg = 360./mNumberOfSectors; + float dphiDeg = 360. / mNumberOfSectors; for (int ir = 0; ir < mNumberOfRingsC; ir++) { std::string rName = "fvd_ring" + std::to_string(ir + 1 + mNumberOfRingsA); @@ -344,8 +344,8 @@ void Detector::defineSensitiveVolumes() TGeoVolume* v; TString volumeName; - int nCellA = mNumberOfRingsA*mNumberOfSectors; - int nCellC = mNumberOfRingsC*mNumberOfSectors; + int nCellA = mNumberOfRingsA * mNumberOfSectors; + int nCellC = mNumberOfRingsC * mNumberOfSectors; for (int iv = 0; iv < nCellA + nCellC; iv++) { volumeName = "fvd_node" + std::to_string(iv); @@ -357,26 +357,27 @@ void Detector::defineSensitiveVolumes() int Detector::getChannelId(TVector3 vec) { - float phi = vec.Phi(); - if (phi < 0) phi += TMath::TwoPi(); - float r = vec.Perp(); - float z = vec.Z(); + float phi = vec.Phi(); + if (phi < 0) + phi += TMath::TwoPi(); + float r = vec.Perp(); + float z = vec.Z(); - int isect = int(phi/(TMath::Pi()/4)); + int isect = int(phi / (TMath::Pi() / 4)); - std::vectorrd = z > 0 ? mRingRadiiA : mRingRadiiC; - int noff = z > 0 ? 0 : mNumberOfRingsA*mNumberOfSectors; + std::vector rd = z > 0 ? mRingRadiiA : mRingRadiiC; + int noff = z > 0 ? 0 : mNumberOfRingsA * mNumberOfSectors; - int ir = 0; + int ir = 0; - for (int i = 1; i < rd.size(); i++) { - if (r < rd[i]) - break; - else - ir ++; - } + for (int i = 1; i < rd.size(); i++) { + if (r < rd[i]) + break; + else + ir++; + } - return ir * mNumberOfSectors + isect + noff; + return ir * mNumberOfSectors + isect + noff; } ClassImp(o2::fvd::Detector); From 63bff65025cabc8cf224ef3cac7161f95145790e Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 23 Sep 2024 11:20:39 +0200 Subject: [PATCH 16/68] update parameters and geometry --- .../ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h | 2 +- .../Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 13 +++++++------ macro/build_geometry.C | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 3b32be64444ac..903e4739d41ca 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -21,7 +21,7 @@ namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { - static constexpr int nsect = 8; + int nsect = 8; std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; std::vector ringsC = {3.5, 14.8, 22.8, 37.3, 48.5, 59.8, 71.}; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 265f900c72bd1..f5fb75b89f36e 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -270,16 +270,16 @@ void Detector::buildModules() LOGP(info, "Creating FVD geometry"); TGeoVolume* vCave = gGeoManager->GetVolume("cave"); + if (!vCave) { - LOG(fatal) << "Could not find the top volume!"; + LOG(fatal) << "Could not find the top volume (cave)!"; } - // create modules TGeoVolumeAssembly* vFVDA = buildModuleA(); - TGeoVolumeAssembly* vFVDC = buildModuleC(); + vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., mZmodA - mDzScint/2.)); - vCave->AddNode(vFVDA, 2, new TGeoTranslation(0., 0., mZmodA)); - vCave->AddNode(vFVDC, 2, new TGeoTranslation(0., 0., mZmodC)); + TGeoVolumeAssembly* vFVDC = buildModuleC(); + vCave->AddNode(vFVDC, 2, new TGeoTranslation(0., 0., mZmodC + mDzScint/2.)); } TGeoVolumeAssembly* Detector::buildModuleA() @@ -341,9 +341,9 @@ TGeoVolumeAssembly* Detector::buildModuleC() void Detector::defineSensitiveVolumes() { LOG(info) << "Adding FVD Sentitive Volumes"; + TGeoVolume* v; TString volumeName; - int nCellA = mNumberOfRingsA * mNumberOfSectors; int nCellC = mNumberOfRingsC * mNumberOfSectors; @@ -353,6 +353,7 @@ void Detector::defineSensitiveVolumes() LOG(info) << "Adding FVD Sensitive Volume => " << v->GetName(); AddSensitiveVolume(v); } + } int Detector::getChannelId(TVector3 vec) diff --git a/macro/build_geometry.C b/macro/build_geometry.C index 9a7703ef9bcb9..f3e18948ba453 100644 --- a/macro/build_geometry.C +++ b/macro/build_geometry.C @@ -265,7 +265,7 @@ void build_geometry(FairRunSim* run = nullptr) } if (isActivated("FVD")) { - // FIT-FVD + // ALICE3 FVD addReadoutDetector(new o2::fvd::Detector(isReadout("FVD"))); } From 266c9a4c58c3c93028ebaef45e9984a2ddbc731f Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sun, 6 Oct 2024 19:42:33 +0200 Subject: [PATCH 17/68] fixed ring sizes --- .../ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h | 2 +- .../Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 903e4739d41ca..584eed383e31f 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -24,7 +24,7 @@ struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { int nsect = 8; std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; - std::vector ringsC = {3.5, 14.8, 22.8, 37.3, 48.5, 59.8, 71.}; + std::vector ringsC = {3.5, 14.75, 26.0, 37.25, 48.5, 59.75, 71.}; float zmodA = 1700; float zmodC = -1950; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index f5fb75b89f36e..6ba00e49696f0 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -57,7 +57,7 @@ Detector::Detector(bool active) auto& baseParam = FVDBaseParam::Instance(); mNumberOfSectors = baseParam.nsect; - mDzScint = baseParam.dzscint; + mDzScint = baseParam.dzscint/2; mRingRadiiA = baseParam.ringsA; mRingRadiiC = baseParam.ringsC; @@ -120,7 +120,7 @@ bool Detector::ProcessHits(FairVolume* vol) auto stack = (o2::data::Stack*)fMC->GetStack(); - int cellId = vol->getVolumeId(); + //int cellId = vol->getVolumeId(); // Check track status to define when hit is started and when it is stopped bool startHit = false, stopHit = false; @@ -276,10 +276,10 @@ void Detector::buildModules() } TGeoVolumeAssembly* vFVDA = buildModuleA(); - vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., mZmodA - mDzScint/2.)); - TGeoVolumeAssembly* vFVDC = buildModuleC(); - vCave->AddNode(vFVDC, 2, new TGeoTranslation(0., 0., mZmodC + mDzScint/2.)); + + vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., mZmodA/* - mDzScint/2.*/)); + vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., mZmodC/* + mDzScint/2.*/)); } TGeoVolumeAssembly* Detector::buildModuleA() @@ -302,6 +302,7 @@ TGeoVolumeAssembly* Detector::buildModuleA() float phimax = dphiDeg * (ic + 1); auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + nod->SetLineColor(kRed); ring->AddNode(nod, cellId); } mod->AddNode(ring, 1); @@ -330,6 +331,7 @@ TGeoVolumeAssembly* Detector::buildModuleC() float phimax = dphiDeg * (ic + 1); auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + nod->SetLineColor(kBlue); ring->AddNode(nod, cellId); } mod->AddNode(ring, 1); From 358535a7084eac9540af8ec1e41c8dd5ee25fed4 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 10 Oct 2024 14:42:34 +0200 Subject: [PATCH 18/68] merge conflict --- .../display/3rdparty/KHR/khrplatform.h | 24 +- GPU/GPUTracking/display/GPUDisplay.cxx | 44 ++-- GPU/GPUTracking/display/GPUDisplay.h | 148 +++++------ GPU/GPUTracking/display/GPUDisplayInterface.h | 16 +- .../display/backend/GPUDisplayBackend.cxx | 18 +- .../display/backend/GPUDisplayBackend.h | 48 ++-- .../backend/GPUDisplayBackendOpenGL.cxx | 90 +++---- .../display/backend/GPUDisplayBackendOpenGL.h | 100 ++++---- .../backend/GPUDisplayBackendVulkan.cxx | 134 +++++----- .../display/backend/GPUDisplayBackendVulkan.h | 38 +-- .../display/filterMacros/TRDCandidate.C | 2 +- .../display/filterMacros/filterGPUTrack.C | 2 +- .../display/filterMacros/filterTPCTrack.C | 2 +- GPU/GPUTracking/display/filterMacros/hasTRD.C | 2 +- .../display/frontend/GPUDisplayFrontend.cxx | 24 +- .../display/frontend/GPUDisplayFrontend.h | 114 ++++----- .../frontend/GPUDisplayFrontendGlfw.cxx | 58 +++-- .../display/frontend/GPUDisplayFrontendGlfw.h | 36 +-- .../frontend/GPUDisplayFrontendGlut.cxx | 40 +-- .../display/frontend/GPUDisplayFrontendGlut.h | 28 +- .../display/frontend/GPUDisplayFrontendNone.h | 2 +- .../frontend/GPUDisplayFrontendWayland.cxx | 38 +-- .../frontend/GPUDisplayFrontendWayland.h | 22 +- .../frontend/GPUDisplayFrontendWindows.cxx | 20 +- .../frontend/GPUDisplayFrontendWindows.h | 4 +- .../frontend/GPUDisplayFrontendX11.cxx | 58 ++--- .../display/frontend/GPUDisplayFrontendX11.h | 14 +- .../display/frontend/GPUDisplayGUIWrapper.cxx | 8 +- .../display/frontend/GPUDisplayGUIWrapper.h | 6 +- .../display/frontend/GPUDisplayKeys.cxx | 59 ++--- .../display/helpers/GPUDisplayAnimation.cxx | 26 +- .../GPUDisplayBackendOpenGLMagneticField.cxx | 26 +- .../display/helpers/GPUDisplayColors.inc | 8 +- .../display/helpers/GPUDisplayHelpers.cxx | 2 +- .../helpers/GPUDisplayInterpolation.cxx | 20 +- .../helpers/GPUDisplayMagneticField.cxx | 20 +- .../display/helpers/GPUDisplayMagneticField.h | 32 +-- .../display/helpers/GPUDisplayROOT.cxx | 4 +- GPU/GPUTracking/display/helpers/bitmapfile.h | 30 +-- .../helpers/field-uniform-exporter.cxx | 18 +- .../display/render/GPUDisplayDraw.cxx | 239 +++++++++--------- .../display/render/GPUDisplayImportEvent.cxx | 48 ++-- .../display/shaders/GPUDisplayShaders.h | 156 ++++++------ 43 files changed, 911 insertions(+), 917 deletions(-) diff --git a/GPU/GPUTracking/display/3rdparty/KHR/khrplatform.h b/GPU/GPUTracking/display/3rdparty/KHR/khrplatform.h index b6648a9a3d2b9..9fb630df9b8ad 100644 --- a/GPU/GPUTracking/display/3rdparty/KHR/khrplatform.h +++ b/GPU/GPUTracking/display/3rdparty/KHR/khrplatform.h @@ -186,11 +186,11 @@ typedef unsigned __int64 khronos_uint64_t; typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; +typedef long khronos_int64_t; +typedef unsigned long khronos_uint64_t; #else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; +typedef long khronos_int64_t; +typedef unsigned long khronos_uint64_t; #endif /* __arch64__ */ #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 @@ -234,15 +234,15 @@ typedef unsigned short int khronos_uint16_t; * to be the only LLP64 architecture in current use. */ #ifdef _WIN64 -typedef signed long long int khronos_intptr_t; -typedef unsigned long long int khronos_uintptr_t; -typedef signed long long int khronos_ssize_t; -typedef unsigned long long int khronos_usize_t; +typedef signed long khronos_intptr_t; +typedef unsigned long khronos_uintptr_t; +typedef signed long khronos_ssize_t; +typedef unsigned long khronos_usize_t; #else -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; +typedef signed long khronos_intptr_t; +typedef unsigned long khronos_uintptr_t; +typedef signed long khronos_ssize_t; +typedef unsigned long khronos_usize_t; #endif #if KHRONOS_SUPPORT_FLOAT diff --git a/GPU/GPUTracking/display/GPUDisplay.cxx b/GPU/GPUTracking/display/GPUDisplay.cxx index 59d6d978c3eaf..74d89fbf6de81 100644 --- a/GPU/GPUTracking/display/GPUDisplay.cxx +++ b/GPU/GPUTracking/display/GPUDisplay.cxx @@ -109,9 +109,9 @@ void GPUDisplay::calcXYZ(const float* matrix) }*/ } -void GPUDisplay::SetCollisionFirstCluster(unsigned int collision, int slice, int cluster) +void GPUDisplay::SetCollisionFirstCluster(uint32_t collision, int32_t slice, int32_t cluster) { - mNCollissions = std::max(mNCollissions, collision + 1); + mNCollissions = std::max(mNCollissions, collision + 1); mOverlayTFClusters.resize(mNCollissions); mOverlayTFClusters[collision][slice] = cluster; } @@ -128,13 +128,13 @@ void GPUDisplay::mAnimateCloseQuaternion(float* v, float lastx, float lasty, flo float distPos2 = (lastx - v[0]) * (lastx - v[0]) + (lasty - v[1]) * (lasty - v[1]) + (lastz - v[2]) * (lastz - v[2]) + (lastw - v[3]) * (lastw - v[3]); float distNeg2 = (lastx + v[0]) * (lastx + v[0]) + (lasty + v[1]) * (lasty + v[1]) + (lastz + v[2]) * (lastz + v[2]) + (lastw + v[3]) * (lastw + v[3]); if (distPos2 > distNeg2) { - for (int i = 0; i < 4; i++) { + for (int32_t i = 0; i < 4; i++) { v[i] = -v[i]; } } } -void GPUDisplay::ResizeScene(int width, int height, bool init) +void GPUDisplay::ResizeScene(int32_t width, int32_t height, bool init) { if (height == 0) { // Prevent A Divide By Zero By height = 1; // Making Height Equal One @@ -160,9 +160,9 @@ inline void GPUDisplay::drawVertices(const vboList& v, const GPUDisplayBackend:: mNDrawCalls += mBackend->drawVertices(v, t); } -int GPUDisplay::InitDisplay(bool initFailure) +int32_t GPUDisplay::InitDisplay(bool initFailure) { - int retVal = initFailure; + int32_t retVal = initFailure; try { if (!initFailure) { retVal = InitDisplay_internal(); @@ -175,7 +175,7 @@ int GPUDisplay::InitDisplay(bool initFailure) return (retVal); } -int GPUDisplay::InitDisplay_internal() +int32_t GPUDisplay::InitDisplay_internal() { mThreadBuffers.resize(getNumThreads()); mThreadTracks.resize(getNumThreads()); @@ -184,7 +184,7 @@ int GPUDisplay::InitDisplay_internal() } mYFactor = mBackend->getYFactor(); mDrawTextInCompatMode = !mBackend->mFreetypeInitialized && mFrontend->mCanDrawText == 1; - int height = 0, width = 0; + int32_t height = 0, width = 0; mFrontend->getSize(width, height); if (height == 0 || width == 0) { width = GPUDisplayFrontend::INIT_WIDTH; @@ -199,12 +199,12 @@ void GPUDisplay::ExitDisplay() mBackend->ExitBackend(); } -int GPUDisplay::DrawGLScene() +int32_t GPUDisplay::DrawGLScene() { // Make sure event gets not overwritten during display mSemLockDisplay.Lock(); - int retVal = 0; + int32_t retVal = 0; if (mChain) { mIOPtrs = &mChain->mIOPtrs; mCalib = &mChain->calib(); @@ -227,7 +227,7 @@ int GPUDisplay::DrawGLScene() void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix) { - int mMouseWheelTmp = mFrontend->mMouseWheel; + int32_t mMouseWheelTmp = mFrontend->mMouseWheel; mFrontend->mMouseWheel = 0; bool lookOrigin = mCfgR.camLookOrigin ^ mFrontend->mKeys[mFrontend->KEY_ALT]; bool yUp = mCfgR.camYUp ^ mFrontend->mKeys[mFrontend->KEY_CTRL] ^ lookOrigin; @@ -270,10 +270,10 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla mResetScene = 0; } else { - float moveZ = scalefactor * ((float)mMouseWheelTmp / 150 + (float)(mFrontend->mKeys[(unsigned char)'W'] - mFrontend->mKeys[(unsigned char)'S']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]) * 0.2f * mFPSScale); + float moveZ = scalefactor * ((float)mMouseWheelTmp / 150 + (float)(mFrontend->mKeys[(uint8_t)'W'] - mFrontend->mKeys[(uint8_t)'S']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]) * 0.2f * mFPSScale); float moveY = scalefactor * ((float)(mFrontend->mKeys[mFrontend->KEY_PAGEDOWN] - mFrontend->mKeys[mFrontend->KEY_PAGEUP]) * 0.2f * mFPSScale); - float moveX = scalefactor * ((float)(mFrontend->mKeys[(unsigned char)'A'] - mFrontend->mKeys[(unsigned char)'D']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]) * 0.2f * mFPSScale); - float rotRoll = rotatescalefactor * mFPSScale * 2 * (mFrontend->mKeys[(unsigned char)'E'] - mFrontend->mKeys[(unsigned char)'F']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]); + float moveX = scalefactor * ((float)(mFrontend->mKeys[(uint8_t)'A'] - mFrontend->mKeys[(uint8_t)'D']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]) * 0.2f * mFPSScale); + float rotRoll = rotatescalefactor * mFPSScale * 2 * (mFrontend->mKeys[(uint8_t)'E'] - mFrontend->mKeys[(uint8_t)'F']) * (!mFrontend->mKeys[mFrontend->KEY_SHIFT]); float rotYaw = rotatescalefactor * mFPSScale * 2 * (mFrontend->mKeys[mFrontend->KEY_RIGHT] - mFrontend->mKeys[mFrontend->KEY_LEFT]); float rotPitch = rotatescalefactor * mFPSScale * 2 * (mFrontend->mKeys[mFrontend->KEY_DOWN] - mFrontend->mKeys[mFrontend->KEY_UP]); @@ -289,7 +289,7 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla rotPitch += rotatescalefactor * mouseScale * ((float)mFrontend->mMouseMvY - (float)mFrontend->mMouseDnY); } - if (mFrontend->mKeys[(unsigned char)'<'] && !mFrontend->mKeysShift[(unsigned char)'<']) { + if (mFrontend->mKeys[(uint8_t)'<'] && !mFrontend->mKeysShift[(uint8_t)'<']) { mAnimationDelay += moveX; if (mAnimationDelay < 0.05f) { mAnimationDelay = 0.05f; @@ -379,7 +379,7 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla // Graphichs Options float minSize = 0.4f / (mCfgR.drawQualityDownsampleFSAA > 1 ? mCfgR.drawQualityDownsampleFSAA : 1); - int deltaLine = mFrontend->mKeys[(unsigned char)'+'] * mFrontend->mKeysShift[(unsigned char)'+'] - mFrontend->mKeys[(unsigned char)'-'] * mFrontend->mKeysShift[(unsigned char)'-']; + int32_t deltaLine = mFrontend->mKeys[(uint8_t)'+'] * mFrontend->mKeysShift[(uint8_t)'+'] - mFrontend->mKeys[(uint8_t)'-'] * mFrontend->mKeysShift[(uint8_t)'-']; mCfgL.lineWidth += (float)deltaLine * mFPSScale * 0.02f * mCfgL.lineWidth; if (mCfgL.lineWidth < minSize) { mCfgL.lineWidth = minSize; @@ -389,7 +389,7 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla mUpdateDrawCommands = 1; } minSize *= 2; - int deltaPoint = mFrontend->mKeys[(unsigned char)'+'] * (!mFrontend->mKeysShift[(unsigned char)'+']) - mFrontend->mKeys[(unsigned char)'-'] * (!mFrontend->mKeysShift[(unsigned char)'-']); + int32_t deltaPoint = mFrontend->mKeys[(uint8_t)'+'] * (!mFrontend->mKeysShift[(uint8_t)'+']) - mFrontend->mKeys[(uint8_t)'-'] * (!mFrontend->mKeysShift[(uint8_t)'-']); mCfgL.pointSize += (float)deltaPoint * mFPSScale * 0.02f * mCfgL.pointSize; if (mCfgL.pointSize < minSize) { mCfgL.pointSize = minSize; @@ -414,9 +414,9 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla void GPUDisplay::DrawGLScene_drawCommands() { -#define LOOP_SLICE for (int iSlice = (mCfgL.drawSlice == -1 ? 0 : mCfgL.drawRelatedSlices ? (mCfgL.drawSlice % (NSLICES / 4)) : mCfgL.drawSlice); iSlice < NSLICES; iSlice += (mCfgL.drawSlice == -1 ? 1 : mCfgL.drawRelatedSlices ? (NSLICES / 4) : NSLICES)) -#define LOOP_SLICE2 for (int iSlice = (mCfgL.drawSlice == -1 ? 0 : mCfgL.drawRelatedSlices ? (mCfgL.drawSlice % (NSLICES / 4)) : mCfgL.drawSlice) % (NSLICES / 2); iSlice < NSLICES / 2; iSlice += (mCfgL.drawSlice == -1 ? 1 : mCfgL.drawRelatedSlices ? (NSLICES / 4) : NSLICES)) -#define LOOP_COLLISION for (int iCol = (mCfgL.showCollision == -1 ? 0 : mCfgL.showCollision); iCol < mNCollissions; iCol += (mCfgL.showCollision == -1 ? 1 : mNCollissions)) +#define LOOP_SLICE for (int32_t iSlice = (mCfgL.drawSlice == -1 ? 0 : mCfgL.drawRelatedSlices ? (mCfgL.drawSlice % (NSLICES / 4)) : mCfgL.drawSlice); iSlice < NSLICES; iSlice += (mCfgL.drawSlice == -1 ? 1 : mCfgL.drawRelatedSlices ? (NSLICES / 4) : NSLICES)) +#define LOOP_SLICE2 for (int32_t iSlice = (mCfgL.drawSlice == -1 ? 0 : mCfgL.drawRelatedSlices ? (mCfgL.drawSlice % (NSLICES / 4)) : mCfgL.drawSlice) % (NSLICES / 2); iSlice < NSLICES / 2; iSlice += (mCfgL.drawSlice == -1 ? 1 : mCfgL.drawRelatedSlices ? (NSLICES / 4) : NSLICES)) +#define LOOP_COLLISION for (int32_t iCol = (mCfgL.showCollision == -1 ? 0 : mCfgL.showCollision); iCol < mNCollissions; iCol += (mCfgL.showCollision == -1 ? 1 : mNCollissions)) #define LOOP_COLLISION_COL(cmd) \ LOOP_COLLISION \ { \ @@ -636,7 +636,7 @@ void GPUDisplay::DrawGLScene_internal(float animateTime, bool renderToMixBuffer) if (mUpdateVertexLists && mIOPtrs) { size_t totalVertizes = DrawGLScene_updateVertexList(); if (showTimer) { - printf("Event visualization time: %'d us (vertices %'lld / %'lld bytes)\n", (int)(mTimerDraw.GetCurrentElapsedTime() * 1000000.), (long long int)totalVertizes, (long long int)(totalVertizes * sizeof(mVertexBuffer[0][0]))); + printf("Event visualization time: %'d us (vertices %'ld / %'ld bytes)\n", (int32_t)(mTimerDraw.GetCurrentElapsedTime() * 1000000.), (int64_t)totalVertizes, (int64_t)(totalVertizes * sizeof(mVertexBuffer[0][0]))); } } @@ -714,7 +714,7 @@ void GPUDisplay::ShowNextEvent(const GPUTrackingInOutPointers* ptrs) void GPUDisplay::WaitForNextEvent() { mSemLockDisplay.Lock(); } -int GPUDisplay::StartDisplay() +int32_t GPUDisplay::StartDisplay() { if (mFrontend->StartDisplay()) { return (1); diff --git a/GPU/GPUTracking/display/GPUDisplay.h b/GPU/GPUTracking/display/GPUDisplay.h index 78638bfaca4a6..38dacae60c51a 100644 --- a/GPU/GPUTracking/display/GPUDisplay.h +++ b/GPU/GPUTracking/display/GPUDisplay.h @@ -44,30 +44,30 @@ class GPUDisplay : public GPUDisplayInterface GPUDisplay(const GPUDisplay&) = delete; ~GPUDisplay() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void ShowNextEvent(const GPUTrackingInOutPointers* ptrs = nullptr) override; void WaitForNextEvent() override; - void SetCollisionFirstCluster(unsigned int collision, int slice, int cluster) override; + void SetCollisionFirstCluster(uint32_t collision, int32_t slice, int32_t cluster) override; void UpdateCalib(const GPUCalibObjectsConst* calib) override { mCalib = calib; } void UpdateParam(const GPUParam* param) override { mParam = param; } - void HandleKey(unsigned char key); - int DrawGLScene(); - void HandleSendKey(int key); - int InitDisplay(bool initFailure = false); + void HandleKey(uint8_t key); + int32_t DrawGLScene(); + void HandleSendKey(int32_t key); + int32_t InitDisplay(bool initFailure = false); void ExitDisplay(); - void ResizeScene(int width, int height, bool init = false); + void ResizeScene(int32_t width, int32_t height, bool init = false); const GPUSettingsDisplayRenderer& cfgR() const { return mCfgR; } const GPUSettingsDisplayLight& cfgL() const { return mCfgL; } const GPUSettingsDisplayHeavy& cfgH() const { return mCfgH; } const GPUSettingsDisplay& cfg() const { return mConfig; } bool useMultiVBO() const { return mUseMultiVBO; } - int updateDrawCommands() const { return mUpdateDrawCommands; } - int updateRenderPipeline() const { return mUpdateRenderPipeline; } + int32_t updateDrawCommands() const { return mUpdateDrawCommands; } + int32_t updateRenderPipeline() const { return mUpdateRenderPipeline; } GPUDisplayBackend* backend() const { return mBackend.get(); } - vecpod* vertexBufferStart() { return mVertexBufferStart; } - const vecpod* vertexBufferCount() const { return mVertexBufferCount; } + vecpod* vertexBufferStart() { return mVertexBufferStart; } + const vecpod* vertexBufferCount() const { return mVertexBufferCount; } struct vtx { float x, y, z; vtx(float a, float b, float c) : x(a), y(b), z(c) {} @@ -76,20 +76,20 @@ class GPUDisplay : public GPUDisplayInterface const GPUParam* param() { return mParam; } GPUDisplayFrontend* frontend() { return mFrontend; } bool drawTextInCompatMode() const { return mDrawTextInCompatMode; } - int& drawTextFontSize() { return mDrawTextFontSize; } + int32_t& drawTextFontSize() { return mDrawTextFontSize; } private: - static constexpr int NSLICES = GPUChainTracking::NSLICES; + static constexpr int32_t NSLICES = GPUChainTracking::NSLICES; static constexpr float GL_SCALE_FACTOR = (1.f / 100.f); - static constexpr const int N_POINTS_TYPE = 15; - static constexpr const int N_POINTS_TYPE_TPC = 9; - static constexpr const int N_POINTS_TYPE_TRD = 2; - static constexpr const int N_POINTS_TYPE_TOF = 2; - static constexpr const int N_POINTS_TYPE_ITS = 2; - static constexpr const int N_LINES_TYPE = 7; - static constexpr const int N_FINAL_TYPE = 4; - static constexpr int TRACK_TYPE_ID_LIMIT = 100; + static constexpr const int32_t N_POINTS_TYPE = 15; + static constexpr const int32_t N_POINTS_TYPE_TPC = 9; + static constexpr const int32_t N_POINTS_TYPE_TRD = 2; + static constexpr const int32_t N_POINTS_TYPE_TOF = 2; + static constexpr const int32_t N_POINTS_TYPE_ITS = 2; + static constexpr const int32_t N_LINES_TYPE = 7; + static constexpr const int32_t N_FINAL_TYPE = 4; + static constexpr int32_t TRACK_TYPE_ID_LIMIT = 100; enum PointTypes { tCLUSTER = 0, tINITLINK = 1, tLINK = 2, @@ -111,19 +111,19 @@ class GPUDisplay : public GPUDisplayInterface struct threadVertexBuffer { vecpod buffer; - vecpod start[N_FINAL_TYPE]; - vecpod count[N_FINAL_TYPE]; - std::pair*, vecpod*> vBuf[N_FINAL_TYPE]; + vecpod start[N_FINAL_TYPE]; + vecpod count[N_FINAL_TYPE]; + std::pair*, vecpod*> vBuf[N_FINAL_TYPE]; threadVertexBuffer() : buffer() { - for (int i = 0; i < N_FINAL_TYPE; i++) { + for (int32_t i = 0; i < N_FINAL_TYPE; i++) { vBuf[i].first = start + i; vBuf[i].second = count + i; } } void clear() { - for (int i = 0; i < N_FINAL_TYPE; i++) { + for (int32_t i = 0; i < N_FINAL_TYPE; i++) { start[i].clear(); count[i].clear(); } @@ -148,15 +148,15 @@ class GPUDisplay : public GPUDisplayInterface void DrawGLScene_cameraAndAnimation(float animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix); size_t DrawGLScene_updateVertexList(); void DrawGLScene_drawCommands(); - int InitDisplay_internal(); - int getNumThreads(); + int32_t InitDisplay_internal(); + int32_t getNumThreads(); void disableUnsupportedOptions(); - int buildTrackFilter(); - const GPUTPCTracker& sliceTracker(int iSlice); + int32_t buildTrackFilter(); + const GPUTPCTracker& sliceTracker(int32_t iSlice); const GPUTRDGeometry* trdGeometry(); const GPUTrackingInOutPointers* mIOPtrs = nullptr; - void insertVertexList(std::pair*, vecpod*>& vBuf, size_t first, size_t last); - void insertVertexList(int iSlice, size_t first, size_t last); + void insertVertexList(std::pair*, vecpod*>& vBuf, size_t first, size_t last); + void insertVertexList(int32_t iSlice, size_t first, size_t last); template void SetInfo(Args... args) { @@ -175,7 +175,7 @@ class GPUDisplay : public GPUDisplayInterface void resetAnimation(); void removeAnimationPoint(); void startAnimation(); - int animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix); + int32_t animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix); void showInfo(const char* info); void ActivateColor(); void SetColorTRD(); @@ -192,23 +192,23 @@ class GPUDisplay : public GPUDisplayInterface void SetColorGrid(); void SetColorGridTRD(); void SetColorMarked(); - void SetCollisionColor(int col); + void SetCollisionColor(int32_t col); void updateConfig(); - void drawPointLinestrip(int iSlice, int cid, int id, int id_limit = TRACK_TYPE_ID_LIMIT); - vboList DrawClusters(int iSlice, int select, unsigned int iCol); - vboList DrawSpacePointsTRD(int iSlice, int select, int iCol); - vboList DrawSpacePointsTOF(int iSlice, int select, int iCol); - vboList DrawSpacePointsITS(int iSlice, int select, int iCol); - vboList DrawLinks(const GPUTPCTracker& tracker, int id, bool dodown = false); + void drawPointLinestrip(int32_t iSlice, int32_t cid, int32_t id, int32_t id_limit = TRACK_TYPE_ID_LIMIT); + vboList DrawClusters(int32_t iSlice, int32_t select, uint32_t iCol); + vboList DrawSpacePointsTRD(int32_t iSlice, int32_t select, int32_t iCol); + vboList DrawSpacePointsTOF(int32_t iSlice, int32_t select, int32_t iCol); + vboList DrawSpacePointsITS(int32_t iSlice, int32_t select, int32_t iCol); + vboList DrawLinks(const GPUTPCTracker& tracker, int32_t id, bool dodown = false); vboList DrawSeeds(const GPUTPCTracker& tracker); vboList DrawTracklets(const GPUTPCTracker& tracker); - vboList DrawTracks(const GPUTPCTracker& tracker, int global); - void DrawTrackITS(int trackId, int iSlice); + vboList DrawTracks(const GPUTPCTracker& tracker, int32_t global); + void DrawTrackITS(int32_t trackId, int32_t iSlice); GPUDisplay::vboList DrawFinalITS(); template - void DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, std::array, 2>& trackList, threadVertexBuffer& threadBuffer); + void DrawFinal(int32_t iSlice, int32_t /*iCol*/, GPUTPCGMPropagator* prop, std::array, 2>& trackList, threadVertexBuffer& threadBuffer); vboList DrawGrid(const GPUTPCTracker& tracker); - vboList DrawGridTRD(int sector); + vboList DrawGridTRD(int32_t sector); void DoScreenshot(const char* filename, std::vector& pixels, float animateTime = -1.f); void PrintHelp(); void createQuaternionFromMatrix(float* v, const float* mat); @@ -228,15 +228,15 @@ class GPUDisplay : public GPUDisplayInterface qSem mSemLockDisplay; bool mDrawTextInCompatMode = false; - int mDrawTextFontSize = 0; + int32_t mDrawTextFontSize = 0; - int mNDrawCalls = 0; + int32_t mNDrawCalls = 0; bool mUseMultiVBO = false; std::array mDrawColor = {1.f, 1.f, 1.f, 1.f}; - int mTestSetting = 0; + int32_t mTestSetting = 0; float mAngleRollOrigin = -1e9; float mMaxClusterZ = -1; @@ -248,12 +248,12 @@ class GPUDisplay : public GPUDisplayInterface float mRPhiTheta[3]; float mQuat[4]; - vecpod> mOverlayTFClusters; - int mNCollissions = 1; + vecpod> mOverlayTFClusters; + int32_t mNCollissions = 1; vecpod mVertexBuffer[NSLICES]; - vecpod mVertexBufferStart[NSLICES]; - vecpod mVertexBufferCount[NSLICES]; + vecpod mVertexBufferStart[NSLICES]; + vecpod mVertexBufferCount[NSLICES]; std::unique_ptr mGlobalPosPtr; std::unique_ptr mGlobalPosPtrTRD; @@ -265,48 +265,48 @@ class GPUDisplay : public GPUDisplayInterface float4* mGlobalPosTRD2; float4* mGlobalPosITS; float4* mGlobalPosTOF; - int mNMaxClusters = 0; - int mNMaxSpacePointsTRD = 0; - int mNMaxClustersITS = 0; - int mNMaxClustersTOF = 0; - int mCurrentClusters = 0; - int mCurrentSpacePointsTRD = 0; - int mCurrentClustersITS = 0; - int mCurrentClustersTOF = 0; - vecpod mTRDTrackIds; + int32_t mNMaxClusters = 0; + int32_t mNMaxSpacePointsTRD = 0; + int32_t mNMaxClustersITS = 0; + int32_t mNMaxClustersTOF = 0; + int32_t mCurrentClusters = 0; + int32_t mCurrentSpacePointsTRD = 0; + int32_t mCurrentClustersITS = 0; + int32_t mCurrentClustersTOF = 0; + vecpod mTRDTrackIds; vecpod mITSStandaloneTracks; std::vector mTrackFilter; bool mUpdateTrackFilter = false; - int mUpdateVertexLists = 1; - int mUpdateEventData = 0; - int mUpdateDrawCommands = 1; - int mUpdateRenderPipeline = 0; - volatile int mResetScene = 0; + int32_t mUpdateVertexLists = 1; + int32_t mUpdateEventData = 0; + int32_t mUpdateDrawCommands = 1; + int32_t mUpdateRenderPipeline = 0; + volatile int32_t mResetScene = 0; - int mAnimate = 0; + int32_t mAnimate = 0; HighResTimer mAnimationTimer; - int mAnimationFrame = 0; - int mAnimationLastBase = 0; - int mAnimateScreenshot = 0; - int mAnimationExport = 0; + int32_t mAnimationFrame = 0; + int32_t mAnimationLastBase = 0; + int32_t mAnimateScreenshot = 0; + int32_t mAnimationExport = 0; bool mAnimationChangeConfig = true; float mAnimationDelay = 2.f; vecpod mAnimateVectors[9]; vecpod mAnimateConfig; opengl_spline mAnimationSplines[8]; - int mPrintInfoText = 1; + int32_t mPrintInfoText = 1; bool mPrintInfoTextAlways = 0; char mInfoText2[1024]; HighResTimer mInfoText2Timer, mInfoHelpTimer; std::vector mThreadBuffers; - std::vector, 2>, NSLICES>>> mThreadTracks; - volatile int mInitResult = 0; + std::vector, 2>, NSLICES>>> mThreadTracks; + volatile int32_t mInitResult = 0; float mFPSScale = 1, mFPSScaleadjust = 0; - int mFramesDone = 0, mFramesDoneFPS = 0; + int32_t mFramesDone = 0, mFramesDoneFPS = 0; HighResTimer mTimerFPS, mTimerDisplay, mTimerDraw; vboList mGlDLLines[NSLICES][N_LINES_TYPE]; vecpod> mGlDLFinal[NSLICES]; diff --git a/GPU/GPUTracking/display/GPUDisplayInterface.h b/GPU/GPUTracking/display/GPUDisplayInterface.h index 431da46de33b9..49cdb7e9e2038 100644 --- a/GPU/GPUTracking/display/GPUDisplayInterface.h +++ b/GPU/GPUTracking/display/GPUDisplayInterface.h @@ -30,10 +30,10 @@ class GPUDisplayInterface public: GPUDisplayInterface(const GPUDisplayInterface&) = delete; virtual ~GPUDisplayInterface(); - virtual int StartDisplay() = 0; + virtual int32_t StartDisplay() = 0; virtual void ShowNextEvent(const GPUTrackingInOutPointers* ptrs = nullptr) = 0; virtual void WaitForNextEvent() = 0; - virtual void SetCollisionFirstCluster(unsigned int collision, int slice, int cluster) = 0; + virtual void SetCollisionFirstCluster(uint32_t collision, int32_t slice, int32_t cluster) = 0; virtual void UpdateCalib(const GPUCalibObjectsConst* calib) = 0; virtual void UpdateParam(const GPUParam* param) = 0; static GPUDisplayInterface* getDisplay(GPUDisplayFrontendInterface* frontend, GPUChainTracking* chain, GPUQA* qa, const GPUParam* param = nullptr, const GPUCalibObjectsConst* calib = nullptr, const GPUSettingsDisplay* config = nullptr); @@ -49,12 +49,12 @@ class GPUDisplayFrontendInterface static GPUDisplayFrontendInterface* getFrontend(const char* type); virtual void DisplayExit() = 0; virtual bool EnableSendKey() = 0; - virtual int getDisplayControl() const = 0; - virtual int getSendKey() const = 0; - virtual int getNeedUpdate() const = 0; - virtual void setDisplayControl(int v) = 0; - virtual void setSendKey(int v) = 0; - virtual void setNeedUpdate(int v) = 0; + virtual int32_t getDisplayControl() const = 0; + virtual int32_t getSendKey() const = 0; + virtual int32_t getNeedUpdate() const = 0; + virtual void setDisplayControl(int32_t v) = 0; + virtual void setSendKey(int32_t v) = 0; + virtual void setNeedUpdate(int32_t v) = 0; virtual const char* frontendName() const = 0; protected: diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx b/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx index c6edd5cd40419..15b759e658354 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackend.cxx @@ -48,7 +48,7 @@ GPUDisplayBackend* GPUDisplayBackend::getBackend(const char* type) return new GPUDisplayBackendVulkan; } else #endif - if (strcmp(type, "opengl") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "opengl") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayBackendOpenGL; } else { GPUError("Requested renderer not available"); @@ -56,9 +56,9 @@ GPUDisplayBackend* GPUDisplayBackend::getBackend(const char* type) return nullptr; } -int GPUDisplayBackend::InitBackend() +int32_t GPUDisplayBackend::InitBackend() { - int retVal = InitBackendA(); + int32_t retVal = InitBackendA(); if (retVal) { return retVal; } @@ -100,14 +100,14 @@ int GPUDisplayBackend::InitBackend() return 0; } - int fontSize = mDisplay->cfg().fontSize; + int32_t fontSize = mDisplay->cfg().fontSize; mDisplay->drawTextFontSize() = fontSize; if (smoothFont()) { fontSize *= 4; // Font size scaled by 4, can be downsampled } FT_Set_Pixel_Sizes(face, 0, fontSize); - for (unsigned int i = 0; i < 128; i++) { + for (uint32_t i = 0; i < 128; i++) { if (FT_Load_Char(face, i, FT_LOAD_RENDER)) { GPUError("Error loading freetype symbol"); return 0; @@ -140,9 +140,9 @@ void GPUDisplayBackend::fillIndirectCmdBuffer() mCmdBuffer.clear(); mIndirectSliceOffset.resize(GPUCA_NSLICES); // TODO: Check if this can be parallelized - for (int iSlice = 0; iSlice < GPUCA_NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < GPUCA_NSLICES; iSlice++) { mIndirectSliceOffset[iSlice] = mCmdBuffer.size(); - for (unsigned int k = 0; k < mDisplay->vertexBufferStart()[iSlice].size(); k++) { + for (uint32_t k = 0; k < mDisplay->vertexBufferStart()[iSlice].size(); k++) { mCmdBuffer.emplace_back(mDisplay->vertexBufferCount()[iSlice][k], 1, mDisplay->vertexBufferStart()[iSlice][k], 0); } } @@ -151,8 +151,8 @@ void GPUDisplayBackend::fillIndirectCmdBuffer() float GPUDisplayBackend::getDownsampleFactor(bool screenshot) { float factor = 1.0f; - int fsaa = mDisplay->cfgR().drawQualityDownsampleFSAA; - int screenshotScale = mDisplay->cfgR().screenshotScaleFactor; + int32_t fsaa = mDisplay->cfgR().drawQualityDownsampleFSAA; + int32_t screenshotScale = mDisplay->cfgR().screenshotScaleFactor; if (fsaa) { factor *= fsaa; } diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackend.h b/GPU/GPUTracking/display/backend/GPUDisplayBackend.h index 1ce279f6f9bb7..8f00f39b97ce3 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackend.h +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackend.h @@ -42,11 +42,11 @@ class GPUDisplayBackend GPUDisplayBackend(); virtual ~GPUDisplayBackend(); - virtual int ExtInit() { return 0; }; + virtual int32_t ExtInit() { return 0; }; virtual bool CoreProfile() { return false; }; - virtual unsigned int DepthBits() = 0; + virtual uint32_t DepthBits() = 0; - typedef std::tuple vboList; + typedef std::tuple vboList; enum drawType { POINTS = 0, @@ -61,30 +61,30 @@ class GPUDisplayBackend }; struct DrawArraysIndirectCommand { - DrawArraysIndirectCommand(unsigned int a = 0, unsigned int b = 0, unsigned int c = 0, unsigned int d = 0) : count(a), instanceCount(b), first(c), baseInstance(d) {} - unsigned int count; - unsigned int instanceCount; + DrawArraysIndirectCommand(uint32_t a = 0, uint32_t b = 0, uint32_t c = 0, uint32_t d = 0) : count(a), instanceCount(b), first(c), baseInstance(d) {} + uint32_t count; + uint32_t instanceCount; - unsigned int first; - unsigned int baseInstance; + uint32_t first; + uint32_t baseInstance; }; struct FontSymbol { - int size[2]; - int offset[2]; - int advance; + int32_t size[2]; + int32_t offset[2]; + int32_t advance; }; - virtual unsigned int drawVertices(const vboList& v, const drawType t) = 0; - virtual unsigned int drawField() { return 0; } + virtual uint32_t drawVertices(const vboList& v, const drawType t) = 0; + virtual uint32_t drawField() { return 0; } virtual void ActivateColor(std::array& color) = 0; virtual void setQuality() {}; virtual void SetVSync(bool enable) {}; virtual bool backendNeedRedraw() { return true; } virtual void setDepthBuffer() = 0; - virtual int InitBackendA() = 0; + virtual int32_t InitBackendA() = 0; virtual void ExitBackendA() = 0; - int InitBackend(); + int32_t InitBackend(); void ExitBackend(); virtual void loadDataToGPU(size_t totalVertizes) = 0; virtual void prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot = false, bool toMixBuffer = false, float includeMixImage = 0.f) = 0; @@ -96,16 +96,16 @@ class GPUDisplayBackend virtual void lineWidthFactor(float factor) = 0; backendTypes backendType() const { return mBackendType; } const char* backendName() const { return mBackendName; } - virtual void resizeScene(unsigned int width, unsigned int height) {} + virtual void resizeScene(uint32_t width, uint32_t height) {} virtual size_t needMultiVBO() { return 0; } virtual void OpenGLPrint(const char* s, float x, float y, float* color, float scale) = 0; static GPUDisplayBackend* getBackend(const char* type); std::vector getPixels(); virtual float getYFactor() const { return 1.0f; } - virtual int getMaxMSAA() const { return 16; } + virtual int32_t getMaxMSAA() const { return 16; } protected: - virtual void addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) = 0; + virtual void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) = 0; virtual void initializeTextDrawing() = 0; float getDownsampleFactor(bool screenshot = false); @@ -113,18 +113,18 @@ class GPUDisplayBackend bool smoothFont(); GPUDisplay* mDisplay = nullptr; - std::vector mIndirectSliceOffset; + std::vector mIndirectSliceOffset; vecpod mCmdBuffer; bool mFreetypeInitialized = false; bool mFrontendCompatTextDraw = false; std::vector mScreenshotPixels; - int mDownsampleFactor = 1; + int32_t mDownsampleFactor = 1; - unsigned int mRenderWidth = 0; - unsigned int mRenderHeight = 0; - unsigned int mScreenWidth = 0; - unsigned int mScreenHeight = 0; + uint32_t mRenderWidth = 0; + uint32_t mRenderHeight = 0; + uint32_t mScreenWidth = 0; + uint32_t mScreenHeight = 0; backendTypes mBackendType = TYPE_INVALID; const char* mBackendName = nullptr; diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.cxx b/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.cxx index c25fbede428ca..b92872a79c6de 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.cxx +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.cxx @@ -60,12 +60,12 @@ GPUDisplayBackendOpenGL::GPUDisplayBackendOpenGL() } #ifdef GPUCA_DISPLAY_GL3W -int GPUDisplayBackendOpenGL::ExtInit() +int32_t GPUDisplayBackendOpenGL::ExtInit() { return gl3wInit(); } #else -int GPUDisplayBackendOpenGL::ExtInit() +int32_t GPUDisplayBackendOpenGL::ExtInit() { return glewInit(); } @@ -83,17 +83,17 @@ bool GPUDisplayBackendOpenGL::CoreProfile() #endif // #define CHKERR(cmd) {cmd;} -#define CHKERR(cmd) \ - do { \ - (cmd); \ - GLenum err = glGetError(); \ - while (err != GL_NO_ERROR) { \ - GPUError("OpenGL Error %d: %s (%s: %d)", (int)err, (const char*)gluErrorString(err), __FILE__, __LINE__); \ - throw std::runtime_error("OpenGL Failure"); \ - } \ +#define CHKERR(cmd) \ + do { \ + (cmd); \ + GLenum err = glGetError(); \ + while (err != GL_NO_ERROR) { \ + GPUError("OpenGL Error %d: %s (%s: %d)", (int32_t)err, (const char*)gluErrorString(err), __FILE__, __LINE__); \ + throw std::runtime_error("OpenGL Failure"); \ + } \ } while (false) -unsigned int GPUDisplayBackendOpenGL::DepthBits() +uint32_t GPUDisplayBackendOpenGL::DepthBits() { GLint depthBits = 0; #ifndef GPUCA_DISPLAY_OPENGL_CORE @@ -102,7 +102,7 @@ unsigned int GPUDisplayBackendOpenGL::DepthBits() return depthBits; } -void GPUDisplayBackendOpenGL::createFB(GLfb& fb, bool tex, bool withDepth, bool msaa, unsigned int width, unsigned int height) +void GPUDisplayBackendOpenGL::createFB(GLfb& fb, bool tex, bool withDepth, bool msaa, uint32_t width, uint32_t height) { fb.tex = tex; fb.depth = withDepth; @@ -154,7 +154,7 @@ void GPUDisplayBackendOpenGL::createFB(GLfb& fb, bool tex, bool withDepth, bool GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { - GPUError("Error creating framebuffer (tex %d) - incomplete (%d)", (int)tex, status); + GPUError("Error creating framebuffer (tex %d) - incomplete (%d)", (int32_t)tex, status); exit(1); } CHKERR(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFboId)); @@ -180,7 +180,7 @@ void GPUDisplayBackendOpenGL::deleteFB(GLfb& fb) fb.created = false; } -unsigned int GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType tt) +uint32_t GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType tt) { static constexpr GLenum types[3] = {GL_POINTS, GL_LINES, GL_LINE_STRIP}; GLenum t = types[tt]; @@ -210,7 +210,7 @@ unsigned int GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawT if (mDisplay->cfgR().useGLIndirectDraw) { CHKERR(glMultiDrawArraysIndirect(t, (void*)(size_t)((mIndirectSliceOffset[iSlice] + first) * sizeof(DrawArraysIndirectCommand)), count, 0)); } else if (OPENGL_EMULATE_MULTI_DRAW) { - for (unsigned int k = 0; k < count; k++) { + for (uint32_t k = 0; k < count; k++) { CHKERR(glDrawArrays(t, mDisplay->vertexBufferStart()[iSlice][first + k], mDisplay->vertexBufferCount()[iSlice][first + k])); } } else { @@ -257,7 +257,7 @@ void GPUDisplayBackendOpenGL::setDepthBuffer() } } -void GPUDisplayBackendOpenGL::setFrameBuffer(unsigned int newID) +void GPUDisplayBackendOpenGL::setFrameBuffer(uint32_t newID) { if (newID == 0) { CHKERR(glBindFramebuffer(GL_FRAMEBUFFER, 0)); @@ -269,9 +269,9 @@ void GPUDisplayBackendOpenGL::setFrameBuffer(unsigned int newID) } } -int GPUDisplayBackendOpenGL::checkShaderStatus(unsigned int shader) +int32_t GPUDisplayBackendOpenGL::checkShaderStatus(uint32_t shader) { - int status, loglen; + int32_t status, loglen; glGetShaderiv(shader, GL_COMPILE_STATUS, &status); if (!status) { printf("failed to compile shader\n"); @@ -285,9 +285,9 @@ int GPUDisplayBackendOpenGL::checkShaderStatus(unsigned int shader) return 0; } -int GPUDisplayBackendOpenGL::checkProgramStatus(unsigned int program) +int32_t GPUDisplayBackendOpenGL::checkProgramStatus(uint32_t program) { - int status, loglen; + int32_t status, loglen; glGetProgramiv(program, GL_LINK_STATUS, &status); if (!status) { printf("failed to link program\n"); @@ -301,14 +301,14 @@ int GPUDisplayBackendOpenGL::checkProgramStatus(unsigned int program) return 0; } -int GPUDisplayBackendOpenGL::InitBackendA() +int32_t GPUDisplayBackendOpenGL::InitBackendA() { if (mDisplay->param()->par.debugLevel >= 2) { auto renderer = glGetString(GL_RENDERER); GPUInfo("Renderer: %s", (const char*)renderer); } - int glVersion[2] = {0, 0}; + int32_t glVersion[2] = {0, 0}; glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]); glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]); if (glVersion[0] < GPUDisplayFrontend::GL_MIN_VERSION_MAJOR || (glVersion[0] == GPUDisplayFrontend::GL_MIN_VERSION_MAJOR && glVersion[1] < GPUDisplayFrontend::GL_MIN_VERSION_MINOR)) { @@ -457,7 +457,7 @@ void GPUDisplayBackendOpenGL::loadDataToGPU(size_t totalVertizes) { // TODO: Check if this can be parallelized if (mDisplay->useMultiVBO()) { - for (int i = 0; i < GPUCA_NSLICES; i++) { + for (int32_t i = 0; i < GPUCA_NSLICES; i++) { CHKERR(glNamedBufferData(mVBOId[i], mDisplay->vertexBuffer()[i].size() * sizeof(mDisplay->vertexBuffer()[i][0]), mDisplay->vertexBuffer()[i].data(), GL_STATIC_DRAW)); } } else { @@ -551,7 +551,7 @@ void GPUDisplayBackendOpenGL::finishDraw(bool doScreenshot, bool toMixBuffer, fl } if (mDisplay->cfgR().drawQualityMSAA) { - unsigned int dstId = toMixBuffer ? mMixBuffer.fb_id : (mDownsampleFactor != 1 ? mOffscreenBuffer.fb_id : 0); + uint32_t dstId = toMixBuffer ? mMixBuffer.fb_id : (mDownsampleFactor != 1 ? mOffscreenBuffer.fb_id : 0); CHKERR(glBlitNamedFramebuffer(mOffscreenBufferMSAA.fb_id, dstId, 0, 0, mRenderWidth, mRenderHeight, 0, 0, mRenderWidth, mRenderHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR)); } if (includeMixImage > 0) { @@ -569,9 +569,9 @@ void GPUDisplayBackendOpenGL::finishDraw(bool doScreenshot, bool toMixBuffer, fl void GPUDisplayBackendOpenGL::readImageToPixels() { - int scaleFactor = mDisplay->cfgR().screenshotScaleFactor; - unsigned int width = mScreenWidth * scaleFactor; - unsigned int height = mScreenHeight * scaleFactor; + int32_t scaleFactor = mDisplay->cfgR().screenshotScaleFactor; + uint32_t width = mScreenWidth * scaleFactor; + uint32_t height = mScreenHeight * scaleFactor; GLfb tmpBuffer; if (mDisplay->cfgR().drawQualityDownsampleFSAA && mDisplay->cfgR().screenshotScaleFactor != 1) { createFB(tmpBuffer, false, true, false, width, height); @@ -680,21 +680,21 @@ void GPUDisplayBackendOpenGL::lineWidthFactor(float factor) CHKERR(glLineWidth(mDisplay->cfgL().lineWidth * mDownsampleFactor * factor)); } -void GPUDisplayBackendOpenGL::addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) +void GPUDisplayBackendOpenGL::addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) { - int oldAlign; + int32_t oldAlign; CHKERR(glGetIntegerv(GL_UNPACK_ALIGNMENT, &oldAlign)); CHKERR(glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); - if (symbol != (int)mFontSymbols.size()) { + if (symbol != (int32_t)mFontSymbols.size()) { throw std::runtime_error("Incorrect symbol ID"); } - unsigned int texId; + uint32_t texId; glGenTextures(1, &texId); - std::vector tmp; + std::vector tmp; if (!smoothFont()) { tmp.resize(sizex * sizey); - unsigned char* src = (unsigned char*)data; - for (int i = 0; i < sizex * sizey; i++) { + uint8_t* src = (uint8_t*)data; + for (int32_t i = 0; i < sizex * sizey; i++) { tmp[i] = src[i] > 128 ? 255 : 0; } data = tmp.data(); @@ -736,8 +736,8 @@ void GPUDisplayBackendOpenGL::OpenGLPrint(const char* s, float x, float y, float scale *= 0.25f; // Font size is 48 to have nice bitmap, scale to size 12 } for (const char* c = s; *c; c++) { - if ((int)*c > (int)mFontSymbols.size()) { - GPUError("Trying to draw unsupported symbol: %d > %d\n", (int)*c, (int)mFontSymbols.size()); + if ((int32_t)*c > (int32_t)mFontSymbols.size()) { + GPUError("Trying to draw unsupported symbol: %d > %d\n", (int32_t)*c, (int32_t)mFontSymbols.size()); continue; } FontSymbolOpenGL sym = mFontSymbols[*c]; @@ -779,7 +779,7 @@ void GPUDisplayBackendOpenGL::ClearOffscreenBuffers() } } -void GPUDisplayBackendOpenGL::resizeScene(unsigned int width, unsigned int height) +void GPUDisplayBackendOpenGL::resizeScene(uint32_t width, uint32_t height) { mScreenWidth = width; mScreenHeight = height; @@ -821,27 +821,27 @@ void GPUDisplayBackendOpenGL::updateRenderer(bool withScreenshot) GPUDisplayBackendOpenGL::GPUDisplayBackendOpenGL() { } -int GPUDisplayBackendOpenGL::checkShaderStatus(unsigned int shader) { return 0; } -int GPUDisplayBackendOpenGL::checkProgramStatus(unsigned int program) { return 0; } -int GPUDisplayBackendOpenGL::ExtInit() { throw std::runtime_error("Insufficnet OpenGL version"); } +int32_t GPUDisplayBackendOpenGL::checkShaderStatus(uint32_t shader) { return 0; } +int32_t GPUDisplayBackendOpenGL::checkProgramStatus(uint32_t program) { return 0; } +int32_t GPUDisplayBackendOpenGL::ExtInit() { throw std::runtime_error("Insufficnet OpenGL version"); } bool GPUDisplayBackendOpenGL::CoreProfile() { return false; } -unsigned int GPUDisplayBackendOpenGL::DepthBits() { return 0; } -unsigned int GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType t) { return 0; } +uint32_t GPUDisplayBackendOpenGL::DepthBits() { return 0; } +uint32_t GPUDisplayBackendOpenGL::drawVertices(const vboList& v, const drawType t) { return 0; } void GPUDisplayBackendOpenGL::ActivateColor(std::array& color) {} void GPUDisplayBackendOpenGL::setQuality() {} void GPUDisplayBackendOpenGL::setDepthBuffer() {} -int GPUDisplayBackendOpenGL::InitBackendA() { throw std::runtime_error("Insufficnet OpenGL version"); } +int32_t GPUDisplayBackendOpenGL::InitBackendA() { throw std::runtime_error("Insufficnet OpenGL version"); } void GPUDisplayBackendOpenGL::ExitBackendA() {} void GPUDisplayBackendOpenGL::loadDataToGPU(size_t totalVertizes) {} void GPUDisplayBackendOpenGL::prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot, bool toMixBuffer, float includeMixImage) {} -void GPUDisplayBackendOpenGL::resizeScene(unsigned int width, unsigned int height) {} +void GPUDisplayBackendOpenGL::resizeScene(uint32_t width, uint32_t height) {} void GPUDisplayBackendOpenGL::finishDraw(bool doScreenshot, bool toMixBuffer, float includeMixImage) {} void GPUDisplayBackendOpenGL::finishFrame(bool doScreenshot, bool toMixBuffer, float includeMixImage) {} void GPUDisplayBackendOpenGL::prepareText() {} void GPUDisplayBackendOpenGL::finishText() {} void GPUDisplayBackendOpenGL::pointSizeFactor(float factor) {} void GPUDisplayBackendOpenGL::lineWidthFactor(float factor) {} -void GPUDisplayBackendOpenGL::addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) {} +void GPUDisplayBackendOpenGL::addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) {} void GPUDisplayBackendOpenGL::initializeTextDrawing() {} void GPUDisplayBackendOpenGL::OpenGLPrint(const char* s, float x, float y, float* color, float scale) {} #endif // GPUCA_BUILD_EVENT_DISPLAY_OPENGL diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.h b/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.h index f7e2d4ee44460..b1bcb25740ed4 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.h +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackendOpenGL.h @@ -22,7 +22,7 @@ namespace GPUCA_NAMESPACE::gpu { struct GLfb { - unsigned int fb_id = 0, fbCol_id = 0, fbDepth_id = 0; + uint32_t fb_id = 0, fbCol_id = 0, fbDepth_id = 0; bool tex = false; bool msaa = false; bool depth = false; @@ -33,30 +33,30 @@ class GPUDisplayBackendOpenGL : public GPUDisplayBackend public: GPUDisplayBackendOpenGL(); ~GPUDisplayBackendOpenGL() override = default; - int ExtInit() override; + int32_t ExtInit() override; bool CoreProfile() override; - unsigned int DepthBits() override; + uint32_t DepthBits() override; protected: - void createFB(GLfb& fb, bool tex, bool withDepth, bool msaa, unsigned int width, unsigned int height); + void createFB(GLfb& fb, bool tex, bool withDepth, bool msaa, uint32_t width, uint32_t height); void deleteFB(GLfb& fb); - unsigned int drawVertices(const vboList& v, const drawType t) override; - unsigned int drawField() override; + uint32_t drawVertices(const vboList& v, const drawType t) override; + uint32_t drawField() override; void ActivateColor(std::array& color) override; void setQuality() override; void setDepthBuffer() override; - void setFrameBuffer(unsigned int newID = 0); - int InitBackendA() override; - int InitMagFieldVisualization(); + void setFrameBuffer(uint32_t newID = 0); + int32_t InitBackendA() override; + int32_t InitMagFieldVisualization(); void ExitBackendA() override; void ExitMagFieldVisualization(); - static int checkShaderStatus(unsigned int shader); - static int checkProgramStatus(unsigned int program); + static int32_t checkShaderStatus(uint32_t shader); + static int32_t checkProgramStatus(uint32_t program); void clearScreen(bool alphaOnly = false); void loadDataToGPU(size_t totalVertizes) override; void prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot, bool toMixBuffer, float includeMixImage) override; - void resizeScene(unsigned int width, unsigned int height) override; + void resizeScene(uint32_t width, uint32_t height) override; void updateRenderer(bool withScreenshot); void ClearOffscreenBuffers(); void finishDraw(bool doScreenshot, bool toMixBuffer, float includeMixImage) override; @@ -69,51 +69,51 @@ class GPUDisplayBackendOpenGL : public GPUDisplayBackend size_t needMultiVBO() override { return 0x100000000ll; } void readImageToPixels(); - void addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) override; + void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) override; void initializeTextDrawing() override; void OpenGLPrint(const char* s, float x, float y, float* color, float scale) override; struct FontSymbolOpenGL : public FontSymbol { - unsigned int texId; + uint32_t texId; }; - unsigned int mVertexShader; - unsigned int mFragmentShader; - unsigned int mVertexShaderTexture; - unsigned int mVertexShaderPassthrough; - unsigned int mFragmentShaderTexture; - unsigned int mFragmentShaderText; - unsigned int mGeometryShader; - unsigned int mShaderProgram; - unsigned int mShaderProgramText; - unsigned int mShaderProgramTexture; - unsigned int mShaderProgramField; - unsigned int mVertexArray; - - unsigned int mIndirectId; - std::vector mVBOId; + uint32_t mVertexShader; + uint32_t mFragmentShader; + uint32_t mVertexShaderTexture; + uint32_t mVertexShaderPassthrough; + uint32_t mFragmentShaderTexture; + uint32_t mFragmentShaderText; + uint32_t mGeometryShader; + uint32_t mShaderProgram; + uint32_t mShaderProgramText; + uint32_t mShaderProgramTexture; + uint32_t mShaderProgramField; + uint32_t mVertexArray; + + uint32_t mIndirectId; + std::vector mVBOId; std::vector mFontSymbols; - int mModelViewProjId; - int mColorId; - int mModelViewProjIdTexture; - int mAlphaIdTexture; - int mModelViewProjIdText; - int mColorIdText; - unsigned int mSPIRVModelViewBuffer; - unsigned int mSPIRVColorBuffer; - - unsigned int mFieldModelViewBuffer; - unsigned int mFieldModelConstantsBuffer; - unsigned int mSolenoidSegmentsBuffer; - unsigned int mSolenoidParameterizationBuffer; - unsigned int mDipoleSegmentsBuffer; - unsigned int mDipoleParameterizationBuffer; - - unsigned int VAO_text, VBO_text; - - unsigned int VAO_texture, VBO_texture; - - unsigned int VAO_field, VBO_field; + int32_t mModelViewProjId; + int32_t mColorId; + int32_t mModelViewProjIdTexture; + int32_t mAlphaIdTexture; + int32_t mModelViewProjIdText; + int32_t mColorIdText; + uint32_t mSPIRVModelViewBuffer; + uint32_t mSPIRVColorBuffer; + + uint32_t mFieldModelViewBuffer; + uint32_t mFieldModelConstantsBuffer; + uint32_t mSolenoidSegmentsBuffer; + uint32_t mSolenoidParameterizationBuffer; + uint32_t mDipoleSegmentsBuffer; + uint32_t mDipoleParameterizationBuffer; + + uint32_t VAO_text, VBO_text; + + uint32_t VAO_texture, VBO_texture; + + uint32_t VAO_field, VBO_field; bool mSPIRVShaders = false; diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx b/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx index a6920942b9990..5491555ace8d2 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.cxx @@ -32,13 +32,13 @@ QGET_LD_BINARY_SYMBOLS(shaders_shaders_fragmentTexture_frag_spv); QGET_LD_BINARY_SYMBOLS(shaders_shaders_fragmentText_frag_spv); // #define CHKERR(cmd) {cmd;} -#define CHKERR(cmd) \ - do { \ - auto tmp_internal_retVal = cmd; \ - if ((int)tmp_internal_retVal < 0) { \ - GPUError("VULKAN ERROR: %d: %s (%s: %d)", (int)tmp_internal_retVal, "ERROR", __FILE__, __LINE__); \ - throw std::runtime_error("Vulkan Failure"); \ - } \ +#define CHKERR(cmd) \ + do { \ + auto tmp_internal_retVal = cmd; \ + if ((int32_t)tmp_internal_retVal < 0) { \ + GPUError("VULKAN ERROR: %d: %s (%s: %d)", (int32_t)tmp_internal_retVal, "ERROR", __FILE__, __LINE__); \ + throw std::runtime_error("Vulkan Failure"); \ + } \ } while (false) GPUDisplayBackendVulkan::GPUDisplayBackendVulkan() @@ -50,7 +50,7 @@ GPUDisplayBackendVulkan::~GPUDisplayBackendVulkan() = default; // ---------------------------- VULKAN HELPERS ---------------------------- -static int checkVulkanLayersSupported(const std::vector& validationLayers) +static int32_t checkVulkanLayersSupported(const std::vector& validationLayers) { std::vector availableLayers = vk::enumerateInstanceLayerProperties(); for (const char* layerName : validationLayers) { @@ -113,7 +113,7 @@ vk::Extent2D GPUDisplayBackendVulkan::chooseSwapExtent(const vk::SurfaceCapabili if (capabilities.currentExtent.width != std::numeric_limits::max()) { return capabilities.currentExtent; } else { - int width, height; + int32_t width, height; mDisplay->frontend()->getSize(width, height); vk::Extent2D actualExtent = {(uint32_t)width, (uint32_t)height}; actualExtent.width = std::clamp(actualExtent.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width); @@ -221,7 +221,7 @@ static void createImageI(vk::Device device, vk::PhysicalDevice physicalDevice, v device.bindImageMemory(image, imageMemory, 0); } -static unsigned int getMaxUsableSampleCount(vk::PhysicalDeviceProperties& physicalDeviceProperties) +static uint32_t getMaxUsableSampleCount(vk::PhysicalDeviceProperties& physicalDeviceProperties) { vk::SampleCountFlags counts = physicalDeviceProperties.limits.framebufferColorSampleCounts & physicalDeviceProperties.limits.framebufferDepthSampleCounts; if (counts & vk::SampleCountFlagBits::e64) { @@ -240,7 +240,7 @@ static unsigned int getMaxUsableSampleCount(vk::PhysicalDeviceProperties& physic return 1; } -static vk::SampleCountFlagBits getMSAASamplesFlag(unsigned int msaa) +static vk::SampleCountFlagBits getMSAASamplesFlag(uint32_t msaa) { if (msaa == 2) { return vk::SampleCountFlagBits::e2; @@ -281,7 +281,7 @@ double GPUDisplayBackendVulkan::checkDevice(vk::PhysicalDevice device, const std std::vector queueFamilies = device.getQueueFamilyProperties(); bool found = false; - for (unsigned int i = 0; i < queueFamilies.size(); i++) { + for (uint32_t i = 0; i < queueFamilies.size(); i++) { if (!(queueFamilies[i].queueFlags & vk::QueueFlagBits::eGraphics)) { return (-1); } @@ -299,9 +299,9 @@ double GPUDisplayBackendVulkan::checkDevice(vk::PhysicalDevice device, const std } std::vector availableExtensions = device.enumerateDeviceExtensionProperties(nullptr); - unsigned int extensionsFound = 0; - for (unsigned int i = 0; i < reqDeviceExtensions.size(); i++) { - for (unsigned int j = 0; j < availableExtensions.size(); j++) { + uint32_t extensionsFound = 0; + for (uint32_t i = 0; i < reqDeviceExtensions.size(); i++) { + for (uint32_t j = 0; j < availableExtensions.size(); j++) { if (strcmp(reqDeviceExtensions[i], availableExtensions[j].extensionName) == 0) { extensionsFound++; break; @@ -326,7 +326,7 @@ double GPUDisplayBackendVulkan::checkDevice(vk::PhysicalDevice device, const std score += 1e11; } - for (unsigned int i = 0; i < memoryProperties.memoryHeapCount; i++) { + for (uint32_t i = 0; i < memoryProperties.memoryHeapCount; i++) { if (memoryProperties.memoryHeaps[i].flags & vk::MemoryHeapFlagBits::eDeviceLocal) { score += memoryProperties.memoryHeaps[i].size; } @@ -354,7 +354,7 @@ void GPUDisplayBackendVulkan::createDevice() const std::vector reqValidationLayers = { "VK_LAYER_KHRONOS_validation"}; auto debugCallback = [](VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData) -> VkBool32 { - static int throwOnError = getenv("GPUCA_VULKAN_VALIDATION_THROW") ? atoi(getenv("GPUCA_VULKAN_VALIDATION_THROW")) : 0; + static int32_t throwOnError = getenv("GPUCA_VULKAN_VALIDATION_THROW") ? atoi(getenv("GPUCA_VULKAN_VALIDATION_THROW")) : 0; static bool showVulkanValidationInfo = getenv("GPUCA_VULKAN_VALIDATION_INFO") && atoi(getenv("GPUCA_VULKAN_VALIDATION_INFO")); switch (messageSeverity) { case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: @@ -429,7 +429,7 @@ void GPUDisplayBackendVulkan::createDevice() throw std::runtime_error("No Vulkan device present!"); } double bestScore = -1.; - for (unsigned int i = 0; i < devices.size(); i++) { + for (uint32_t i = 0; i < devices.size(); i++) { double score = checkDevice(devices[i], reqDeviceExtensions); if (mDisplay->param()->par.debugLevel >= 2) { vk::PhysicalDeviceProperties deviceProperties = devices[i].getProperties(); @@ -441,7 +441,7 @@ void GPUDisplayBackendVulkan::createDevice() } } if (mDisplay->cfg().vulkan.forceDevice != -1) { - if (mDisplay->cfg().vulkan.forceDevice < 0 || mDisplay->cfg().vulkan.forceDevice >= (int)devices.size()) { + if (mDisplay->cfg().vulkan.forceDevice < 0 || mDisplay->cfg().vulkan.forceDevice >= (int32_t)devices.size()) { throw std::runtime_error("Invalid Vulkan device selected"); } mPhysicalDevice = devices[mDisplay->cfg().vulkan.forceDevice]; @@ -463,7 +463,7 @@ void GPUDisplayBackendVulkan::createDevice() mCubicFilterSupported = (bool)(formatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eSampledImageFilterCubicEXT); bool mailboxSupported = std::find(mSwapChainDetails.presentModes.begin(), mSwapChainDetails.presentModes.end(), vk::PresentModeKHR::eMailbox) != mSwapChainDetails.presentModes.end(); if (mDisplay->param()->par.debugLevel >= 2) { - GPUInfo("Max MSAA: %d, 32 bit Z buffer %d, 32 bit Z buffer + stencil buffer %d, Cubic Filtering %d, Mailbox present mode %d\n", (int)mMaxMSAAsupported, (int)mZSupported, (int)mStencilSupported, (int)mCubicFilterSupported, (int)mailboxSupported); + GPUInfo("Max MSAA: %d, 32 bit Z buffer %d, 32 bit Z buffer + stencil buffer %d, Cubic Filtering %d, Mailbox present mode %d\n", (int32_t)mMaxMSAAsupported, (int32_t)mZSupported, (int32_t)mStencilSupported, (int32_t)mCubicFilterSupported, (int32_t)mailboxSupported); } vk::DeviceQueueCreateInfo queueCreateInfo{}; @@ -536,7 +536,7 @@ void GPUDisplayBackendVulkan::createSemaphoresAndFences() mMixFinishedSemaphore.resize(mFramesInFlight); mDownsampleFinishedSemaphore.resize(mFramesInFlight); mInFlightFence.resize(mFramesInFlight); - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { mImageAvailableSemaphore[i] = mDevice.createSemaphore(semaphoreInfo, nullptr); mRenderFinishedSemaphore[i] = mDevice.createSemaphore(semaphoreInfo, nullptr); mTextFinishedSemaphore[i] = mDevice.createSemaphore(semaphoreInfo, nullptr); @@ -563,10 +563,10 @@ void GPUDisplayBackendVulkan::clearSemaphoresAndFences() void GPUDisplayBackendVulkan::createUniformLayoutsAndBuffers() { - for (int j = 0; j < 3; j++) { + for (int32_t j = 0; j < 3; j++) { mUniformBuffersMat[j].resize(mFramesInFlight); mUniformBuffersCol[j].resize(mFramesInFlight); - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { mUniformBuffersMat[j][i] = createBuffer(sizeof(hmm_mat4), nullptr, vk::BufferUsageFlagBits::eUniformBuffer, mDisplay->cfg().vulkan.uniformBuffersInDeviceMemory ? 2 : 0); mUniformBuffersCol[j][i] = createBuffer(sizeof(float) * 4, nullptr, vk::BufferUsageFlagBits::eUniformBuffer, mDisplay->cfg().vulkan.uniformBuffersInDeviceMemory ? 2 : 0); } @@ -608,14 +608,14 @@ void GPUDisplayBackendVulkan::createUniformLayoutsAndBuffers() vk::DescriptorSetAllocateInfo allocInfo{}; allocInfo.descriptorPool = mDescriptorPool; allocInfo.descriptorSetCount = (uint32_t)mFramesInFlight; - for (int j = 0; j < 3; j++) { // 0 = Render, 1 = Text, 2 = Texture + for (int32_t j = 0; j < 3; j++) { // 0 = Render, 1 = Text, 2 = Texture std::vector layouts(mFramesInFlight, j ? mUniformDescriptorTexture : mUniformDescriptor); allocInfo.pSetLayouts = layouts.data(); mDescriptorSets[j] = mDevice.allocateDescriptorSets(allocInfo); - for (int k = 0; k < 2; k++) { + for (int32_t k = 0; k < 2; k++) { auto& mUniformBuffers = k ? mUniformBuffersCol[j] : mUniformBuffersMat[j]; - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { vk::DescriptorBufferInfo bufferInfo{}; bufferInfo.buffer = mUniformBuffers[i].buffer; bufferInfo.offset = 0; @@ -645,13 +645,13 @@ void GPUDisplayBackendVulkan::clearUniformLayoutsAndBuffers() mDevice.destroyDescriptorSetLayout(mUniformDescriptor, nullptr); mDevice.destroyDescriptorSetLayout(mUniformDescriptorTexture, nullptr); mDevice.destroyDescriptorPool(mDescriptorPool, nullptr); - for (int j = 0; j < 3; j++) { + for (int32_t j = 0; j < 3; j++) { clearVector(mUniformBuffersMat[j], [&](auto& x) { clearBuffer(x); }); clearVector(mUniformBuffersCol[j], [&](auto& x) { clearBuffer(x); }); } } -void GPUDisplayBackendVulkan::setMixDescriptor(int descriptorIndex, int imageIndex) +void GPUDisplayBackendVulkan::setMixDescriptor(int32_t descriptorIndex, int32_t imageIndex) { vk::DescriptorImageInfo imageInfo{}; imageInfo.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal; @@ -741,7 +741,7 @@ void GPUDisplayBackendVulkan::createSwapChain(bool forScreenshot, bool forMixing mSwapChain = mDevice.createSwapchainKHR(swapCreateInfo, nullptr); mSwapChainImages = mDevice.getSwapchainImagesKHR(mSwapChain); - unsigned int oldFramesInFlight = mFramesInFlight; + uint32_t oldFramesInFlight = mFramesInFlight; mImageCount = mSwapChainImages.size(); mFramesInFlight = mDisplay->cfg().vulkan.nFramesInFlight == 0 ? mImageCount : mDisplay->cfg().vulkan.nFramesInFlight; mCommandBufferPerImage = mFramesInFlight == mImageCount; @@ -759,7 +759,7 @@ void GPUDisplayBackendVulkan::createSwapChain(bool forScreenshot, bool forMixing } mSwapChainImageViews.resize(mImageCount); - for (unsigned int i = 0; i < mImageCount; i++) { + for (uint32_t i = 0; i < mImageCount; i++) { mSwapChainImageViews[i] = createImageViewI(mDevice, mSwapChainImages[i], mSurfaceFormat.format); } } @@ -774,7 +774,7 @@ void GPUDisplayBackendVulkan::recreateRendering(bool forScreenshot, bool forMixi { mDevice.waitIdle(); bool needUpdateSwapChain = mMustUpdateSwapChain || mDownsampleFactor != getDownsampleFactor(forScreenshot) || mSwapchainImageReadable != forScreenshot; - bool needUpdateOffscreenBuffers = needUpdateSwapChain || mMSAASampleCount != getMSAASamplesFlag(std::min(mMaxMSAAsupported, mDisplay->cfgR().drawQualityMSAA)) || mZActive != (mZSupported && mDisplay->cfgL().depthBuffer) || mMixingSupported != forMixing; + bool needUpdateOffscreenBuffers = needUpdateSwapChain || mMSAASampleCount != getMSAASamplesFlag(std::min(mMaxMSAAsupported, mDisplay->cfgR().drawQualityMSAA)) || mZActive != (mZSupported && mDisplay->cfgL().depthBuffer) || mMixingSupported != forMixing; clearPipeline(); if (needUpdateOffscreenBuffers) { clearOffscreenBuffers(); @@ -792,7 +792,7 @@ void GPUDisplayBackendVulkan::recreateRendering(bool forScreenshot, bool forMixi void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool forMixing) { - mMSAASampleCount = getMSAASamplesFlag(std::min(mMaxMSAAsupported, mDisplay->cfgR().drawQualityMSAA)); + mMSAASampleCount = getMSAASamplesFlag(std::min(mMaxMSAAsupported, mDisplay->cfgR().drawQualityMSAA)); mZActive = mZSupported && mDisplay->cfgL().depthBuffer; mMixingSupported = forMixing; @@ -823,7 +823,7 @@ void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool fo colorAttachmentResolve.stencilStoreOp = vk::AttachmentStoreOp::eDontCare; colorAttachmentResolve.initialLayout = vk::ImageLayout::eUndefined; colorAttachmentResolve.finalLayout = mDownsampleFSAA ? vk::ImageLayout::eColorAttachmentOptimal : vk::ImageLayout::ePresentSrcKHR; - int nAttachments = 0; + int32_t nAttachments = 0; vk::AttachmentReference colorAttachmentRef{}; colorAttachmentRef.attachment = nAttachments++; colorAttachmentRef.layout = vk::ImageLayout::eColorAttachmentOptimal; @@ -866,7 +866,7 @@ void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool fo renderPassInfo.pDependencies = &dependency; mRenderPass = mDevice.createRenderPass(renderPassInfo, nullptr); - const unsigned int imageCountWithMixImages = mImageCount * (mMixingSupported ? 2 : 1); + const uint32_t imageCountWithMixImages = mImageCount * (mMixingSupported ? 2 : 1); mRenderTargetView.resize(imageCountWithMixImages); mFramebuffers.resize(imageCountWithMixImages); if (mDownsampleFSAA) { @@ -919,7 +919,7 @@ void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool fo mRenderPassTexture = mDevice.createRenderPass(renderPassInfo, nullptr); } - for (unsigned int i = 0; i < imageCountWithMixImages; i++) { + for (uint32_t i = 0; i < imageCountWithMixImages; i++) { if (i < mImageCount) { // Main render chain // primary buffer mSwapChainImageViews[i] created as part of createSwapChain, not here } else if (!mDownsampleFSAA) { // for rendering to mixBuffer @@ -990,7 +990,7 @@ void GPUDisplayBackendVulkan::createOffscreenBuffers(bool forScreenshot, bool fo mMixingTextureVertexArray = createBuffer(sizeof(vertices), &vertices[0][0], vk::BufferUsageFlagBits::eVertexBuffer, 1); if (mCommandBufferPerImage) { - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { setMixDescriptor(i, i); } } @@ -1157,7 +1157,7 @@ void GPUDisplayBackendVulkan::createPipeline() mPipelines.resize(mMixingSupported ? 5 : 4); static constexpr vk::PrimitiveTopology types[3] = {vk::PrimitiveTopology::ePointList, vk::PrimitiveTopology::eLineList, vk::PrimitiveTopology::eLineStrip}; - for (unsigned int i = 0; i < mPipelines.size(); i++) { + for (uint32_t i = 0; i < mPipelines.size(); i++) { if (i == 4) { // Texture rendering bindingDescription.stride = 4 * sizeof(float); attributeDescriptions.format = vk::Format::eR32G32B32A32Sfloat; @@ -1203,7 +1203,7 @@ void GPUDisplayBackendVulkan::createPipeline() } } -void GPUDisplayBackendVulkan::startFillCommandBuffer(vk::CommandBuffer& commandBuffer, unsigned int imageIndex, bool toMixBuffer) +void GPUDisplayBackendVulkan::startFillCommandBuffer(vk::CommandBuffer& commandBuffer, uint32_t imageIndex, bool toMixBuffer) { commandBuffer.reset({}); @@ -1284,7 +1284,7 @@ void GPUDisplayBackendVulkan::writeToBuffer(VulkanBuffer& buffer, size_t size, c } } -GPUDisplayBackendVulkan::VulkanBuffer GPUDisplayBackendVulkan::createBuffer(size_t size, const void* srcData, vk::BufferUsageFlags type, int deviceMemory) +GPUDisplayBackendVulkan::VulkanBuffer GPUDisplayBackendVulkan::createBuffer(size_t size, const void* srcData, vk::BufferUsageFlags type, int32_t deviceMemory) { vk::MemoryPropertyFlags properties; if (deviceMemory) { @@ -1372,7 +1372,7 @@ void GPUDisplayBackendVulkan::writeToImage(VulkanImage& image, const void* srcDa clearBuffer(tmp); } -GPUDisplayBackendVulkan::VulkanImage GPUDisplayBackendVulkan::createImage(unsigned int sizex, unsigned int sizey, const void* srcData, size_t srcSize, vk::Format format) +GPUDisplayBackendVulkan::VulkanImage GPUDisplayBackendVulkan::createImage(uint32_t sizex, uint32_t sizey, const void* srcData, size_t srcSize, vk::Format format) { VulkanImage image; createImageI(mDevice, mPhysicalDevice, image.image, image.memory, sizex, sizey, format, vk::ImageUsageFlagBits::eTransferDst | vk::ImageUsageFlagBits::eSampled, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::ImageTiling::eOptimal, vk::SampleCountFlagBits::e1); @@ -1398,7 +1398,7 @@ void GPUDisplayBackendVulkan::clearImage(VulkanImage& image) // ---------------------------- VULKAN INIT EXIT ---------------------------- -int GPUDisplayBackendVulkan::InitBackendA() +int32_t GPUDisplayBackendVulkan::InitBackendA() { mEnableValidationLayers = mDisplay->param() && mDisplay->param()->par.debugLevel >= 2; mFramesInFlight = 2; @@ -1436,7 +1436,7 @@ void GPUDisplayBackendVulkan::ExitBackendA() // ---------------------------- USER CODE ---------------------------- -void GPUDisplayBackendVulkan::resizeScene(unsigned int width, unsigned int height) +void GPUDisplayBackendVulkan::resizeScene(uint32_t width, uint32_t height) { if (mScreenWidth == width && mScreenHeight == height) { return; @@ -1461,7 +1461,7 @@ void GPUDisplayBackendVulkan::loadDataToGPU(size_t totalVertizes) needRecordCommandBuffers(); } -unsigned int GPUDisplayBackendVulkan::drawVertices(const vboList& v, const drawType tt) +uint32_t GPUDisplayBackendVulkan::drawVertices(const vboList& v, const drawType tt) { auto first = std::get<0>(v); auto count = std::get<1>(v); @@ -1480,7 +1480,7 @@ unsigned int GPUDisplayBackendVulkan::drawVertices(const vboList& v, const drawT if (mDisplay->cfgR().useGLIndirectDraw) { mCurrentCommandBuffer.drawIndirect(mIndirectCommandBuffer.buffer, (mIndirectSliceOffset[iSlice] + first) * sizeof(DrawArraysIndirectCommand), count, sizeof(DrawArraysIndirectCommand)); } else { - for (unsigned int k = 0; k < count; k++) { + for (uint32_t k = 0; k < count; k++) { mCurrentCommandBuffer.draw(mDisplay->vertexBufferCount()[iSlice][first + k], 1, mDisplay->vertexBufferStart()[iSlice][first + k], 0); } } @@ -1777,9 +1777,9 @@ void GPUDisplayBackendVulkan::needRecordCommandBuffers() std::fill(mCommandBufferUpToDate.begin(), mCommandBufferUpToDate.end(), false); } -void GPUDisplayBackendVulkan::addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) +void GPUDisplayBackendVulkan::addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) { - if (symbol != (int)mFontSymbols.size()) { + if (symbol != (int32_t)mFontSymbols.size()) { throw std::runtime_error("Incorrect symbol ID"); } mFontSymbols.emplace_back(FontSymbolVulkan{{{sizex, sizey}, {offsetx, offsety}, advance}, nullptr, 0.f, 0.f, 0.f, 0.f}); @@ -1792,29 +1792,29 @@ void GPUDisplayBackendVulkan::addFontSymbol(int symbol, int sizex, int sizey, in void GPUDisplayBackendVulkan::initializeTextDrawing() { - int maxSizeX = 0, maxSizeY = 0, maxBigX = 0, maxBigY = 0, maxRowY = 0; + int32_t maxSizeX = 0, maxSizeY = 0, maxBigX = 0, maxBigY = 0, maxRowY = 0; bool smooth = smoothFont(); // Build a mega texture containing all fonts for (auto& symbol : mFontSymbols) { maxSizeX = std::max(maxSizeX, symbol.size[0]); maxSizeY = std::max(maxSizeY, symbol.size[1]); } - unsigned int nn = ceil(std::sqrt(mFontSymbols.size())); - int sizex = nn * maxSizeX; - int sizey = nn * maxSizeY; + uint32_t nn = ceil(std::sqrt(mFontSymbols.size())); + int32_t sizex = nn * maxSizeX; + int32_t sizey = nn * maxSizeY; std::unique_ptr bigImage{new char[sizex * sizey]}; memset(bigImage.get(), 0, sizex * sizey); - int rowy = 0, colx = 0; - for (unsigned int i = 0; i < mFontSymbols.size(); i++) { + int32_t rowy = 0, colx = 0; + for (uint32_t i = 0; i < mFontSymbols.size(); i++) { auto& s = mFontSymbols[i]; if (colx + s.size[0] > sizex) { colx = 0; rowy += maxRowY; maxRowY = 0; } - for (int k = 0; k < s.size[1]; k++) { - for (int j = 0; j < s.size[0]; j++) { - char val = s.data.get()[j + k * s.size[0]]; + for (int32_t k = 0; k < s.size[1]; k++) { + for (int32_t j = 0; j < s.size[0]; j++) { + int8_t val = s.data.get()[j + k * s.size[0]]; if (!smooth) { val = val < 0 ? 0xFF : 0; } @@ -1832,13 +1832,13 @@ void GPUDisplayBackendVulkan::initializeTextDrawing() colx += s.size[0]; } if (maxBigX != sizex) { - for (int y = 1; y < maxBigY; y++) { + for (int32_t y = 1; y < maxBigY; y++) { memmove(bigImage.get() + y * maxBigX, bigImage.get() + y * sizex, maxBigX); } } sizex = maxBigX; sizey = maxBigY; - for (unsigned int i = 0; i < mFontSymbols.size(); i++) { + for (uint32_t i = 0; i < mFontSymbols.size(); i++) { auto& s = mFontSymbols[i]; s.x0 /= sizex; s.x1 /= sizex; @@ -1856,7 +1856,7 @@ void GPUDisplayBackendVulkan::updateFontTextureDescriptor() imageInfo.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal; imageInfo.imageView = mFontImage.view; imageInfo.sampler = mTextureSampler; - for (unsigned int i = 0; i < mFramesInFlight; i++) { + for (uint32_t i = 0; i < mFramesInFlight; i++) { vk::WriteDescriptorSet descriptorWrite{}; descriptorWrite.dstSet = mDescriptorSets[1][i]; descriptorWrite.dstBinding = 2; @@ -1880,8 +1880,8 @@ void GPUDisplayBackendVulkan::OpenGLPrint(const char* s, float x, float y, float } for (const char* c = s; *c; c++) { - if ((int)*c > (int)mFontSymbols.size()) { - GPUError("Trying to draw unsupported symbol: %d > %d\n", (int)*c, (int)mFontSymbols.size()); + if ((int32_t)*c > (int32_t)mFontSymbols.size()) { + GPUError("Trying to draw unsupported symbol: %d > %d\n", (int32_t)*c, (int32_t)mFontSymbols.size()); continue; } const FontSymbolVulkan& sym = mFontSymbols[*c]; @@ -1919,9 +1919,9 @@ void GPUDisplayBackendVulkan::OpenGLPrint(const char* s, float x, float y, float void GPUDisplayBackendVulkan::readImageToPixels(vk::Image image, vk::ImageLayout layout, std::vector& pixels) { - unsigned int width = mScreenWidth * mDisplay->cfgR().screenshotScaleFactor; - unsigned int height = mScreenHeight * mDisplay->cfgR().screenshotScaleFactor; - static constexpr int bytesPerPixel = 4; + uint32_t width = mScreenWidth * mDisplay->cfgR().screenshotScaleFactor; + uint32_t height = mScreenHeight * mDisplay->cfgR().screenshotScaleFactor; + static constexpr int32_t bytesPerPixel = 4; pixels.resize(width * height * bytesPerPixel); vk::Image dstImage, dstImage2, src2; @@ -1932,8 +1932,8 @@ void GPUDisplayBackendVulkan::readImageToPixels(vk::Image image, vk::ImageLayout if (mDisplay->cfgR().screenshotScaleFactor != 1) { createImageI(mDevice, mPhysicalDevice, dstImage2, dstImageMemory2, width, height, mSurfaceFormat.format, vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::ImageTiling::eOptimal); cmdImageMemoryBarrier(cmdBuffer, dstImage2, {}, vk::AccessFlagBits::eTransferWrite, vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer); - vk::Offset3D blitSizeSrc = {(int)mRenderWidth, (int)mRenderHeight, 1}; - vk::Offset3D blitSizeDst = {(int)width, (int)height, 1}; + vk::Offset3D blitSizeSrc = {(int32_t)mRenderWidth, (int32_t)mRenderHeight, 1}; + vk::Offset3D blitSizeDst = {(int32_t)width, (int32_t)height, 1}; vk::ImageBlit imageBlitRegion{}; imageBlitRegion.srcSubresource.aspectMask = vk::ImageAspectFlagBits::eColor; imageBlitRegion.srcSubresource.layerCount = 1; @@ -1968,7 +1968,7 @@ void GPUDisplayBackendVulkan::readImageToPixels(vk::Image image, vk::ImageLayout const char* data; CHKERR(mDevice.mapMemory(dstImageMemory, 0, VK_WHOLE_SIZE, {}, (void**)&data)); data += subResourceLayout.offset; - for (unsigned int i = 0; i < height; i++) { + for (uint32_t i = 0; i < height; i++) { memcpy(pixels.data() + i * width * bytesPerPixel, data + (height - i - 1) * width * bytesPerPixel, width * bytesPerPixel); } mDevice.unmapMemory(dstImageMemory); @@ -1980,7 +1980,7 @@ void GPUDisplayBackendVulkan::readImageToPixels(vk::Image image, vk::ImageLayout } } -unsigned int GPUDisplayBackendVulkan::DepthBits() +uint32_t GPUDisplayBackendVulkan::DepthBits() { return 32; } diff --git a/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.h b/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.h index 480dd321dbfdb..00310e58dd5a8 100644 --- a/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.h +++ b/GPU/GPUTracking/display/backend/GPUDisplayBackendVulkan.h @@ -31,7 +31,7 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend GPUDisplayBackendVulkan(); ~GPUDisplayBackendVulkan() override; - unsigned int DepthBits() override; + uint32_t DepthBits() override; protected: struct SwapChainSupportDetails { @@ -43,13 +43,13 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend vk::Buffer buffer; vk::DeviceMemory memory; size_t size = 0; - int deviceMemory; + int32_t deviceMemory; }; struct VulkanImage { vk::Image image; vk::ImageView view; vk::DeviceMemory memory; - unsigned int sizex = 0, sizey = 0; + uint32_t sizex = 0, sizey = 0; vk::Format format; }; struct FontSymbolVulkan : public GPUDisplayBackend::FontSymbol { @@ -62,12 +62,12 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend float color[4]; }; - unsigned int drawVertices(const vboList& v, const drawType t) override; + uint32_t drawVertices(const vboList& v, const drawType t) override; void ActivateColor(std::array& color) override; void SetVSync(bool enable) override { mMustUpdateSwapChain = true; }; void setDepthBuffer() override {}; bool backendNeedRedraw() override; - int InitBackendA() override; + int32_t InitBackendA() override; void ExitBackendA() override; void loadDataToGPU(size_t totalVertizes) override; void prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot, bool toMixBuffer, float includeMixImage) override; @@ -76,25 +76,25 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend void prepareText() override; void finishText() override; void mixImages(vk::CommandBuffer cmdBuffer, float mixSlaveImage); - void setMixDescriptor(int descriptorIndex, int imageIndex); + void setMixDescriptor(int32_t descriptorIndex, int32_t imageIndex); void pointSizeFactor(float factor) override; void lineWidthFactor(float factor) override; - void resizeScene(unsigned int width, unsigned int height) override; + void resizeScene(uint32_t width, uint32_t height) override; float getYFactor() const override { return -1.0f; } - int getMaxMSAA() const override { return mMaxMSAAsupported; } + int32_t getMaxMSAA() const override { return mMaxMSAAsupported; } double checkDevice(vk::PhysicalDevice device, const std::vector& reqDeviceExtensions); vk::Extent2D chooseSwapExtent(const vk::SurfaceCapabilitiesKHR& capabilities); void transitionImageLayout(vk::CommandBuffer commandBuffer, vk::Image image, vk::Format format, vk::ImageLayout oldLayout, vk::ImageLayout newLayout); - VulkanBuffer createBuffer(size_t size, const void* srcData = nullptr, vk::BufferUsageFlags type = vk::BufferUsageFlagBits::eVertexBuffer, int deviceMemory = 1); + VulkanBuffer createBuffer(size_t size, const void* srcData = nullptr, vk::BufferUsageFlags type = vk::BufferUsageFlagBits::eVertexBuffer, int32_t deviceMemory = 1); void writeToBuffer(VulkanBuffer& buffer, size_t size, const void* srcData); void clearBuffer(VulkanBuffer& buffer); - VulkanImage createImage(unsigned int sizex, unsigned int sizey, const void* srcData = nullptr, size_t srcSize = 0, vk::Format format = vk::Format::eR8G8B8A8Srgb); + VulkanImage createImage(uint32_t sizex, uint32_t sizey, const void* srcData = nullptr, size_t srcSize = 0, vk::Format format = vk::Format::eR8G8B8A8Srgb); void writeToImage(VulkanImage& image, const void* srcData, size_t srcSize); void clearImage(VulkanImage& image); void clearVertexBuffers(); - void startFillCommandBuffer(vk::CommandBuffer& commandBuffer, unsigned int imageIndex, bool toMixBuffer = false); + void startFillCommandBuffer(vk::CommandBuffer& commandBuffer, uint32_t imageIndex, bool toMixBuffer = false); void endFillCommandBuffer(vk::CommandBuffer& commandBuffer); vk::CommandBuffer getSingleTimeCommandBuffer(); void submitSingleTimeCommandBuffer(vk::CommandBuffer commandBuffer); @@ -124,11 +124,11 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend void recreateRendering(bool forScreenshot = false, bool forMixing = false); void needRecordCommandBuffers(); - void addFontSymbol(int symbol, int sizex, int sizey, int offsetx, int offsety, int advance, void* data) override; + void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) override; void initializeTextDrawing() override; void OpenGLPrint(const char* s, float x, float y, float* color, float scale) override; - unsigned int mGraphicsFamily; + uint32_t mGraphicsFamily; SwapChainSupportDetails mSwapChainDetails; bool mEnableValidationLayers = false; @@ -165,13 +165,13 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend bool mCommandBufferPerImage = false; bool mCommandInfrastructureCreated = false; - unsigned int mImageCount = 0; - unsigned int mFramesInFlight = 0; - int mCurrentFrame = 0; + uint32_t mImageCount = 0; + uint32_t mFramesInFlight = 0; + int32_t mCurrentFrame = 0; uint32_t mCurrentImageIndex = 0; - int mCurrentBufferSet = 0; + int32_t mCurrentBufferSet = 0; vk::CommandBuffer mCurrentCommandBuffer; - int mCurrentCommandBufferLastPipeline = -1; + int32_t mCurrentCommandBufferLastPipeline = -1; std::vector mCommandBuffers; std::vector mCommandBuffersDownsample; @@ -205,7 +205,7 @@ class GPUDisplayBackendVulkan : public GPUDisplayBackend bool mSwapchainImageReadable = false; vk::SampleCountFlagBits mMSAASampleCount = vk::SampleCountFlagBits::e16; - unsigned int mMaxMSAAsupported = 0; + uint32_t mMaxMSAAsupported = 0; bool mZActive = false; bool mZSupported = false; bool mStencilSupported = false; diff --git a/GPU/GPUTracking/display/filterMacros/TRDCandidate.C b/GPU/GPUTracking/display/filterMacros/TRDCandidate.C index a58558b0b52a0..f00681d0ca335 100644 --- a/GPU/GPUTracking/display/filterMacros/TRDCandidate.C +++ b/GPU/GPUTracking/display/filterMacros/TRDCandidate.C @@ -4,7 +4,7 @@ using namespace o2::gpu; void gpuDisplayTrackFilter(std::vector* filter, const GPUTrackingInOutPointers* ioPtrs, const GPUConstantMem* processors) { - for (unsigned int i = 0; i < filter->size(); i++) { + for (uint32_t i = 0; i < filter->size(); i++) { (*filter)[i] = processors->trdTrackerGPU.PreCheckTrackTRDCandidate(ioPtrs->mergedTracks[i]) && processors->trdTrackerGPU.CheckTrackTRDCandidate((GPUTRDTrackGPU)ioPtrs->mergedTracks[i]); } } diff --git a/GPU/GPUTracking/display/filterMacros/filterGPUTrack.C b/GPU/GPUTracking/display/filterMacros/filterGPUTrack.C index 1c70fbd7768fa..886ed29611553 100644 --- a/GPU/GPUTracking/display/filterMacros/filterGPUTrack.C +++ b/GPU/GPUTracking/display/filterMacros/filterGPUTrack.C @@ -10,7 +10,7 @@ using namespace o2::gpu; void gpuDisplayTrackFilter(std::vector* filter, const GPUTrackingInOutPointers* ioPtrs, const GPUConstantMem* processors) { - for (unsigned int i = 0; i < filter->size(); i++) { + for (uint32_t i = 0; i < filter->size(); i++) { auto& trk = ioPtrs->mergedTracks[i]; (*filter)[i] = fabsf(trk.GetParam().GetQPt()) < 1.0f; } diff --git a/GPU/GPUTracking/display/filterMacros/filterTPCTrack.C b/GPU/GPUTracking/display/filterMacros/filterTPCTrack.C index b2d161d967f2f..636cdd0319011 100644 --- a/GPU/GPUTracking/display/filterMacros/filterTPCTrack.C +++ b/GPU/GPUTracking/display/filterMacros/filterTPCTrack.C @@ -12,7 +12,7 @@ using namespace o2::gpu; void gpuDisplayTrackFilter(std::vector* filter, const GPUTrackingInOutPointers* ioPtrs, const GPUConstantMem* processors) { - for (unsigned int i = 0; i < filter->size(); i++) { + for (uint32_t i = 0; i < filter->size(); i++) { auto& trk = ioPtrs->outputTracksTPCO2[i]; (*filter)[i] = fabsf(trk.getQ2Pt()) < 1.0f; } diff --git a/GPU/GPUTracking/display/filterMacros/hasTRD.C b/GPU/GPUTracking/display/filterMacros/hasTRD.C index 355fd213c57fd..cd98fb2fe349b 100644 --- a/GPU/GPUTracking/display/filterMacros/hasTRD.C +++ b/GPU/GPUTracking/display/filterMacros/hasTRD.C @@ -6,7 +6,7 @@ void gpuDisplayTrackFilter(std::vector* filter, const GPUTrackingInOutPoin if (!ioPtrs->tpcLinkTRD) { return; } - for (unsigned int i = 0; i < filter->size(); i++) { + for (uint32_t i = 0; i < filter->size(); i++) { (*filter)[i] = ioPtrs->tpcLinkTRD[i] != -1; } } diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx index 437ff654fe9d8..b48d5b994fcf8 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx @@ -48,7 +48,7 @@ GPUDisplayFrontend::~GPUDisplayFrontend() = default; void* GPUDisplayFrontend::FrontendThreadWrapper(void* ptr) { GPUDisplayFrontend* me = reinterpret_cast(ptr); - int retVal = me->FrontendMain(); + int32_t retVal = me->FrontendMain(); if (retVal == -1) { me->InitDisplay(true); } @@ -63,15 +63,15 @@ void GPUDisplayFrontend::HandleSendKey() } } -void GPUDisplayFrontend::HandleKey(unsigned char key) { mDisplay->HandleKey(key); } -int GPUDisplayFrontend::DrawGLScene() { return mDisplay->DrawGLScene(); } -void GPUDisplayFrontend::ResizeScene(int width, int height) +void GPUDisplayFrontend::HandleKey(uint8_t key) { mDisplay->HandleKey(key); } +int32_t GPUDisplayFrontend::DrawGLScene() { return mDisplay->DrawGLScene(); } +void GPUDisplayFrontend::ResizeScene(int32_t width, int32_t height) { mDisplayHeight = height; mDisplayWidth = width; mDisplay->ResizeScene(width, height); } -int GPUDisplayFrontend::InitDisplay(bool initFailure) { return mDisplay->InitDisplay(initFailure); } +int32_t GPUDisplayFrontend::InitDisplay(bool initFailure) { return mDisplay->InitDisplay(initFailure); } void GPUDisplayFrontend::ExitDisplay() { mDisplay->ExitDisplay(); @@ -89,9 +89,9 @@ void GPUDisplayFrontend::stopGUI() #endif } -int GPUDisplayFrontend::startGUI() +int32_t GPUDisplayFrontend::startGUI() { - int retVal = 1; + int32_t retVal = 1; #ifdef GPUCA_BUILD_EVENT_DISPLAY_QT if (!mGUI) { mGUI.reset(new GPUDisplayGUIWrapper); @@ -122,7 +122,7 @@ GPUDisplayFrontend* GPUDisplayFrontend::getFrontend(const char* type) } else #endif #ifdef _WIN32 - if (strcmp(type, "windows") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "windows") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayFrontendWindows; } else #elif defined(GPUCA_BUILD_EVENT_DISPLAY_X11) @@ -131,17 +131,17 @@ GPUDisplayFrontend* GPUDisplayFrontend::getFrontend(const char* type) } else #endif #if defined(GPUCA_STANDALONE) && defined(GPUCA_BUILD_EVENT_DISPLAY_GLFW) - if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "glfw") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayFrontendGlfw; } else #endif #ifdef GPUCA_BUILD_EVENT_DISPLAY_WAYLAND - if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) { + if (strcmp(type, "wayland") == 0 || (strcmp(type, "auto") == 0 && getenv("XDG_SESSION_TYPE") && strcmp(getenv("XDG_SESSION_TYPE"), "wayland") == 0)) { return new GPUDisplayFrontendWayland; } else #endif #ifdef GPUCA_BUILD_EVENT_DISPLAY_GLUT - if (strcmp(type, "glut") == 0 || strcmp(type, "auto") == 0) { + if (strcmp(type, "glut") == 0 || strcmp(type, "auto") == 0) { return new GPUDisplayFrontendGlut; } else #endif @@ -156,7 +156,7 @@ GPUDisplayBackend* GPUDisplayFrontend::backend() return mDisplay->backend(); } -int& GPUDisplayFrontend::drawTextFontSize() +int32_t& GPUDisplayFrontend::drawTextFontSize() { return mDisplay->drawTextFontSize(); } diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h index c1e41eac81bb7..1c459d77beee9 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h @@ -44,10 +44,10 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface }; // Compile time minimum version defined in GPUDisplay.h, keep in sync! - static constexpr int GL_MIN_VERSION_MAJOR = 4; - static constexpr int GL_MIN_VERSION_MINOR = 5; + static constexpr int32_t GL_MIN_VERSION_MAJOR = 4; + static constexpr int32_t GL_MIN_VERSION_MINOR = 5; - virtual int StartDisplay() = 0; // Start the display. This function returns, and should spawn a thread that runs the display, and calls InitDisplay + virtual int32_t StartDisplay() = 0; // Start the display. This function returns, and should spawn a thread that runs the display, and calls InitDisplay void DisplayExit() override = 0; // Stop the display. Display thread should call ExitDisplay and the function returns after the thread has terminated virtual void SwitchFullscreen(bool set) = 0; // Toggle full-screen mode virtual void ToggleMaximized(bool set) = 0; // Maximize window @@ -56,79 +56,79 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface virtual void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) = 0; // Print text on the display (needs the backend to build the font) GPUDisplayBackend* backend(); static GPUDisplayFrontend* getFrontend(const char* type); - virtual void getSize(int& width, int& height) { width = height = 0; } - virtual int getVulkanSurface(void* instance, void* surface) { return 1; } - virtual unsigned int getReqVulkanExtensions(const char**& p) { return 0; }; + virtual void getSize(int32_t& width, int32_t& height) { width = height = 0; } + virtual int32_t getVulkanSurface(void* instance, void* surface) { return 1; } + virtual uint32_t getReqVulkanExtensions(const char**& p) { return 0; }; - int getDisplayControl() const override { return mDisplayControl; } - int getSendKey() const override { return mSendKey; } - int getNeedUpdate() const override { return mNeedUpdate; } - void setDisplayControl(int v) override { mDisplayControl = v; } - void setSendKey(int v) override { mSendKey = v; } - void setNeedUpdate(int v) override { mNeedUpdate = v; } + int32_t getDisplayControl() const override { return mDisplayControl; } + int32_t getSendKey() const override { return mSendKey; } + int32_t getNeedUpdate() const override { return mNeedUpdate; } + void setDisplayControl(int32_t v) override { mDisplayControl = v; } + void setSendKey(int32_t v) override { mSendKey = v; } + void setNeedUpdate(int32_t v) override { mNeedUpdate = v; } frontendTypes frontendType() const { return mFrontendType; } const char* frontendName() const override { return mFrontendName; } - int startGUI(); + int32_t startGUI(); void stopGUI(); bool isGUIRunning(); // volatile variables to exchange control informations between display and backend - volatile int mDisplayControl = 0; // Control for next event (=1) or quit (=2) - volatile int mSendKey = 0; // Key sent by external entity (usually console), may be ignored by backend. - volatile int mNeedUpdate = 0; // flag that backend shall update the GL window, and call DrawGLScene + volatile int32_t mDisplayControl = 0; // Control for next event (=1) or quit (=2) + volatile int32_t mSendKey = 0; // Key sent by external entity (usually console), may be ignored by backend. + volatile int32_t mNeedUpdate = 0; // flag that backend shall update the GL window, and call DrawGLScene protected: - virtual int FrontendMain() = 0; + virtual int32_t FrontendMain() = 0; static void* FrontendThreadWrapper(void*); - static constexpr int INIT_WIDTH = 1024, INIT_HEIGHT = 768; // Initial window size, before maximizing + static constexpr int32_t INIT_WIDTH = 1024, INIT_HEIGHT = 768; // Initial window size, before maximizing static constexpr const char* DISPLAY_WINDOW_NAME = "GPU CA Standalone Event Display"; // Title of event display set by backend // Constant key codes for special mKeys (to unify different treatment in X11 / Windows / GLUT / etc.) - static constexpr int KEY_UP = 1; - static constexpr int KEY_DOWN = 2; - static constexpr int KEY_LEFT = 3; - static constexpr int KEY_RIGHT = 4; - static constexpr int KEY_PAGEUP = 5; - static constexpr int KEY_PAGEDOWN = 6; - static constexpr int KEY_SHIFT = 8; - static constexpr int KEY_ALT = 9; - static constexpr int KEY_RALT = 10; - static constexpr int KEY_CTRL = 11; - static constexpr int KEY_RCTRL = 12; - static constexpr int KEY_ENTER = 13; // fixed at 13 - static constexpr int KEY_F1 = 14; - static constexpr int KEY_F2 = 15; - static constexpr int KEY_F3 = 26; - static constexpr int KEY_F4 = 17; - static constexpr int KEY_F5 = 18; - static constexpr int KEY_F6 = 19; - static constexpr int KEY_F7 = 20; - static constexpr int KEY_F8 = 21; - static constexpr int KEY_F9 = 22; - static constexpr int KEY_F10 = 23; - static constexpr int KEY_F11 = 24; - static constexpr int KEY_F12 = 25; - static constexpr int KEY_INSERT = 26; - static constexpr int KEY_ESCAPE = 27; // fixed at 27 - static constexpr int KEY_HOME = 28; - static constexpr int KEY_END = 29; - static constexpr int KEY_SPACE = 32; // fixed at 32 + static constexpr int32_t KEY_UP = 1; + static constexpr int32_t KEY_DOWN = 2; + static constexpr int32_t KEY_LEFT = 3; + static constexpr int32_t KEY_RIGHT = 4; + static constexpr int32_t KEY_PAGEUP = 5; + static constexpr int32_t KEY_PAGEDOWN = 6; + static constexpr int32_t KEY_SHIFT = 8; + static constexpr int32_t KEY_ALT = 9; + static constexpr int32_t KEY_RALT = 10; + static constexpr int32_t KEY_CTRL = 11; + static constexpr int32_t KEY_RCTRL = 12; + static constexpr int32_t KEY_ENTER = 13; // fixed at 13 + static constexpr int32_t KEY_F1 = 14; + static constexpr int32_t KEY_F2 = 15; + static constexpr int32_t KEY_F3 = 26; + static constexpr int32_t KEY_F4 = 17; + static constexpr int32_t KEY_F5 = 18; + static constexpr int32_t KEY_F6 = 19; + static constexpr int32_t KEY_F7 = 20; + static constexpr int32_t KEY_F8 = 21; + static constexpr int32_t KEY_F9 = 22; + static constexpr int32_t KEY_F10 = 23; + static constexpr int32_t KEY_F11 = 24; + static constexpr int32_t KEY_F12 = 25; + static constexpr int32_t KEY_INSERT = 26; + static constexpr int32_t KEY_ESCAPE = 27; // fixed at 27 + static constexpr int32_t KEY_HOME = 28; + static constexpr int32_t KEY_END = 29; + static constexpr int32_t KEY_SPACE = 32; // fixed at 32 // Keyboard / Mouse actions bool mMouseDn = false; // Mouse button down bool mMouseDnR = false; // Right mouse button down float mMouseDnX, mMouseDnY; // X/Y position where mouse button was pressed float mMouseMvX, mMouseMvY; // Current mouse pointer position - int mMouseWheel = 0; // Incremental value of mouse wheel, ca +/- 100 per wheel tick + int32_t mMouseWheel = 0; // Incremental value of mouse wheel, ca +/- 100 per wheel tick bool mKeys[256] = {false}; // Array of mKeys currently pressed bool mKeysShift[256] = {false}; // Array whether shift was held during key-press - int mDisplayHeight = INIT_HEIGHT; - int mDisplayWidth = INIT_WIDTH; - int mCanDrawText = 0; // 1 = in compat mode, 2 = with shader + int32_t mDisplayHeight = INIT_HEIGHT; + int32_t mDisplayWidth = INIT_WIDTH; + int32_t mCanDrawText = 0; // 1 = in compat mode, 2 = with shader - int mMaxFPSRate = 0; // run at highest possible frame rate, do not sleep in between frames + int32_t mMaxFPSRate = 0; // run at highest possible frame rate, do not sleep in between frames GPUDisplay* mDisplay = nullptr; // Ptr to display, not owning, set by display when it connects to backend GPUDisplayBackend* mBackend = nullptr; // Ptr to backend, not owning @@ -138,13 +138,13 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface std::unique_ptr mGUI; - void HandleKey(unsigned char key); // Callback for handling key presses - int DrawGLScene(); // Callback to draw the GL scene + void HandleKey(uint8_t key); // Callback for handling key presses + int32_t DrawGLScene(); // Callback to draw the GL scene void HandleSendKey(); // Optional callback to handle key press from external source (e.g. stdin by default) - void ResizeScene(int width, int height); // Callback when GL window is resized - int InitDisplay(bool initFailure = false); // Callback to initialize the GL Display (to be called in StartDisplay) + void ResizeScene(int32_t width, int32_t height); // Callback when GL window is resized + int32_t InitDisplay(bool initFailure = false); // Callback to initialize the GL Display (to be called in StartDisplay) void ExitDisplay(); // Callback to clean up the GL Display - int& drawTextFontSize(); + int32_t& drawTextFontSize(); }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx index 1644bb23d5b94..d9cfbedf3ba53 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx @@ -22,7 +22,7 @@ #endif #if defined(GPUCA_O2_LIB) && !defined(GPUCA_DISPLAY_GL3W) // Hack: we have to define this in order to initialize gl3w, cannot include the header as it clashes with glew -extern "C" int gl3wInit(); +extern "C" int32_t gl3wInit(); #endif #ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN @@ -56,7 +56,7 @@ GPUDisplayFrontendGlfw::GPUDisplayFrontendGlfw() static GPUDisplayFrontendGlfw* me = nullptr; -int GPUDisplayFrontendGlfw::GetKey(int key) +int32_t GPUDisplayFrontendGlfw::GetKey(int32_t key) { if (key == GLFW_KEY_KP_SUBTRACT) { return ('-'); @@ -154,31 +154,31 @@ int GPUDisplayFrontendGlfw::GetKey(int key) return (0); } -void GPUDisplayFrontendGlfw::GetKey(int key, int scancode, int mods, int& keyOut, int& keyPressOut) +void GPUDisplayFrontendGlfw::GetKey(int32_t key, int32_t scancode, int32_t mods, int32_t& keyOut, int32_t& keyPressOut) { - int specialKey = GetKey(key); + int32_t specialKey = GetKey(key); const char* str = glfwGetKeyName(key, scancode); char localeKey = str ? str[0] : 0; if ((mods & GLFW_MOD_SHIFT) && localeKey >= 'a' && localeKey <= 'z') { localeKey += 'A' - 'a'; } - // GPUInfo("Key: key %d (%c) scancode %d -> %d (%c) special %d (%c)", key, (char)key, scancode, (int)localeKey, localeKey, specialKey, (char)specialKey); + // GPUInfo("Key: key %d (%c) scancode %d -> %d (%c) special %d (%c)", key, (char)key, scancode, (int32_t)localeKey, localeKey, specialKey, (char)specialKey); if (specialKey) { keyOut = keyPressOut = specialKey; } else { - keyOut = keyPressOut = (unsigned char)localeKey; + keyOut = keyPressOut = (uint8_t)localeKey; if (keyPressOut >= 'a' && keyPressOut <= 'z') { keyPressOut += 'A' - 'a'; } } } -void GPUDisplayFrontendGlfw::error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); } +void GPUDisplayFrontendGlfw::error_callback(int32_t error, const char* description) { fprintf(stderr, "Error: %s\n", description); } -void GPUDisplayFrontendGlfw::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) +void GPUDisplayFrontendGlfw::key_callback(GLFWwindow* window, int32_t key, int32_t scancode, int32_t action, int32_t mods) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, scancode, mods, handleKey, keyPress); if (handleKey < 32) { if (action == GLFW_PRESS) { @@ -193,27 +193,29 @@ void GPUDisplayFrontendGlfw::key_callback(GLFWwindow* window, int key, int scanc if (action == GLFW_PRESS) { me->mLastKeyDown = handleKey; } else if (action == GLFW_RELEASE) { - keyPress = (unsigned char)me->mKeyDownMap[handleKey]; + keyPress = (uint8_t)me->mKeyDownMap[handleKey]; me->mKeys[keyPress] = false; me->mKeysShift[keyPress] = false; } } } -void GPUDisplayFrontendGlfw::char_callback(GLFWwindow* window, unsigned int codepoint) +void GPUDisplayFrontendGlfw::char_callback(GLFWwindow* window, uint32_t codepoint) { - // GPUInfo("Key (char callback): %d %c - key: %d", codepoint, (char)codepoint, (int)me->mLastKeyDown); - int keyPress = codepoint; - if (keyPress >= 'a' && keyPress <= 'z') { - keyPress += 'A' - 'a'; - } - me->mKeyDownMap[me->mLastKeyDown] = keyPress; - me->mKeys[keyPress] = true; - me->mKeysShift[keyPress] = me->mKeys[KEY_SHIFT]; - me->HandleKey(codepoint); + // GPUInfo("Key (char callback): %d %c - key: %d", codepoint, (char)codepoint, (int32_t)me->mLastKeyDown); + if (codepoint < 256) { + uint8_t keyPress = codepoint; + if (keyPress >= 'a' && keyPress <= 'z') { + keyPress += 'A' - 'a'; + } + me->mKeyDownMap[me->mLastKeyDown] = keyPress; + me->mKeys[keyPress] = true; + me->mKeysShift[keyPress] = me->mKeys[KEY_SHIFT]; + me->HandleKey(codepoint); + } } -void GPUDisplayFrontendGlfw::mouseButton_callback(GLFWwindow* window, int button, int action, int mods) +void GPUDisplayFrontendGlfw::mouseButton_callback(GLFWwindow* window, int32_t button, int32_t action, int32_t mods) { if (action == GLFW_PRESS) { if (button == 0) { @@ -240,7 +242,7 @@ void GPUDisplayFrontendGlfw::cursorPos_callback(GLFWwindow* window, double x, do me->mMouseMvY = y; } -void GPUDisplayFrontendGlfw::resize_callback(GLFWwindow* window, int width, int height) { me->ResizeScene(width, height); } +void GPUDisplayFrontendGlfw::resize_callback(GLFWwindow* window, int32_t width, int32_t height) { me->ResizeScene(width, height); } #ifdef GPUCA_O2_LIB void GPUDisplayFrontendGlfw::DisplayLoop() @@ -254,7 +256,7 @@ void GPUDisplayFrontendGlfw::DisplayLoop() } #endif -int GPUDisplayFrontendGlfw::FrontendMain() +int32_t GPUDisplayFrontendGlfw::FrontendMain() { me = this; @@ -392,7 +394,7 @@ void GPUDisplayFrontendGlfw::OpenGLPrint(const char* s, float x, float y, float void GPUDisplayFrontendGlfw::SwitchFullscreen(bool set) { - GPUInfo("Setting Full Screen %d", (int)set); + GPUInfo("Setting Full Screen %d", (int32_t)set); if (set) { glfwGetWindowPos(mWindow, &mWindowX, &mWindowY); glfwGetWindowSize(mWindow, &mWindowWidth, &mWindowHeight); @@ -415,7 +417,7 @@ void GPUDisplayFrontendGlfw::ToggleMaximized(bool set) void GPUDisplayFrontendGlfw::SetVSync(bool enable) { glfwSwapInterval(enable); } -int GPUDisplayFrontendGlfw::StartDisplay() +int32_t GPUDisplayFrontendGlfw::StartDisplay() { static pthread_t hThread; if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) { @@ -434,12 +436,12 @@ bool GPUDisplayFrontendGlfw::EnableSendKey() #endif } -void GPUDisplayFrontendGlfw::getSize(int& width, int& height) +void GPUDisplayFrontendGlfw::getSize(int32_t& width, int32_t& height) { glfwGetFramebufferSize(mWindow, &width, &height); } -int GPUDisplayFrontendGlfw::getVulkanSurface(void* instance, void* surface) +int32_t GPUDisplayFrontendGlfw::getVulkanSurface(void* instance, void* surface) { #ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN return glfwCreateWindowSurface(*(VkInstance*)instance, mWindow, nullptr, (VkSurfaceKHR*)surface) != VK_SUCCESS; @@ -448,7 +450,7 @@ int GPUDisplayFrontendGlfw::getVulkanSurface(void* instance, void* surface) #endif } -unsigned int GPUDisplayFrontendGlfw::getReqVulkanExtensions(const char**& p) +uint32_t GPUDisplayFrontendGlfw::getReqVulkanExtensions(const char**& p) { uint32_t glfwExtensionCount = 0; #ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.h index 5f2bd26ed9375..792abcf64b839 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.h @@ -28,41 +28,41 @@ class GPUDisplayFrontendGlfw : public GPUDisplayFrontend GPUDisplayFrontendGlfw(); ~GPUDisplayFrontendGlfw() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; void SetVSync(bool enable) override; void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; bool EnableSendKey() override; - void getSize(int& width, int& height) override; - int getVulkanSurface(void* instance, void* surface) override; - unsigned int getReqVulkanExtensions(const char**& p) override; + void getSize(int32_t& width, int32_t& height) override; + int32_t getVulkanSurface(void* instance, void* surface) override; + uint32_t getReqVulkanExtensions(const char**& p) override; private: - int FrontendMain() override; + int32_t FrontendMain() override; static void DisplayLoop(); - static void error_callback(int error, const char* description); - static void key_callback(GLFWwindow* mWindow, int key, int scancode, int action, int mods); - static void char_callback(GLFWwindow* window, unsigned int codepoint); - static void mouseButton_callback(GLFWwindow* mWindow, int button, int action, int mods); + static void error_callback(int32_t error, const char* description); + static void key_callback(GLFWwindow* mWindow, int32_t key, int32_t scancode, int32_t action, int32_t mods); + static void char_callback(GLFWwindow* window, uint32_t codepoint); + static void mouseButton_callback(GLFWwindow* mWindow, int32_t button, int32_t action, int32_t mods); static void scroll_callback(GLFWwindow* mWindow, double x, double y); static void cursorPos_callback(GLFWwindow* mWindow, double x, double y); - static void resize_callback(GLFWwindow* mWindow, int width, int height); - static int GetKey(int key); - static void GetKey(int keyin, int scancode, int mods, int& keyOut, int& keyPressOut); + static void resize_callback(GLFWwindow* mWindow, int32_t width, int32_t height); + static int32_t GetKey(int32_t key); + static void GetKey(int32_t keyin, int32_t scancode, int32_t mods, int32_t& keyOut, int32_t& keyPressOut); GLFWwindow* mWindow; volatile bool mGlfwRunning = false; pthread_mutex_t mSemLockExit = PTHREAD_MUTEX_INITIALIZER; - int mWindowX = 0; - int mWindowY = 0; - int mWindowWidth = INIT_WIDTH; - int mWindowHeight = INIT_HEIGHT; - char mKeyDownMap[256] = {0}; - unsigned char mLastKeyDown = 0; + int32_t mWindowX = 0; + int32_t mWindowY = 0; + int32_t mWindowWidth = INIT_WIDTH; + int32_t mWindowHeight = INIT_HEIGHT; + uint8_t mKeyDownMap[256] = {0}; + uint8_t mLastKeyDown = 0; bool mUseIMGui = false; }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx index a165e51840e0c..ab435586820e8 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx @@ -44,7 +44,7 @@ void GPUDisplayFrontendGlut::glutLoopFunc() displayFunc(); } -int GPUDisplayFrontendGlut::GetKey(int key) +int32_t GPUDisplayFrontendGlut::GetKey(int32_t key) { if (key == GLUT_KEY_UP) { return KEY_UP; @@ -125,10 +125,10 @@ int GPUDisplayFrontendGlut::GetKey(int key) return (0); } -void GPUDisplayFrontendGlut::GetKey(int key, int& keyOut, int& keyPressOut, bool special) +void GPUDisplayFrontendGlut::GetKey(int32_t key, int32_t& keyOut, int32_t& keyPressOut, bool special) { - int specialKey = special ? GetKey(key) : 0; - // GPUInfo("Key: key %d (%c) (special %d) -> %d (%c) special %d (%c)", key, (char) key, (int) special, (int) key, key, specialKey, (char) specialKey); + int32_t specialKey = special ? GetKey(key) : 0; + // GPUInfo("Key: key %d (%c) (special %d) -> %d (%c) special %d (%c)", key, (char) key, (int32_t) special, (int32_t) key, key, specialKey, (char) specialKey); if (specialKey) { keyOut = keyPressOut = specialKey; @@ -140,41 +140,41 @@ void GPUDisplayFrontendGlut::GetKey(int key, int& keyOut, int& keyPressOut, bool } } -void GPUDisplayFrontendGlut::keyboardDownFunc(unsigned char key, int x, int y) +void GPUDisplayFrontendGlut::keyboardDownFunc(uint8_t key, int32_t x, int32_t y) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, handleKey, keyPress, false); me->mKeysShift[keyPress] = glutGetModifiers() & GLUT_ACTIVE_SHIFT; me->mKeys[keyPress] = true; me->HandleKey(handleKey); } -void GPUDisplayFrontendGlut::keyboardUpFunc(unsigned char key, int x, int y) +void GPUDisplayFrontendGlut::keyboardUpFunc(uint8_t key, int32_t x, int32_t y) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, handleKey, keyPress, false); me->mKeys[keyPress] = false; me->mKeysShift[keyPress] = false; } -void GPUDisplayFrontendGlut::specialDownFunc(int key, int x, int y) +void GPUDisplayFrontendGlut::specialDownFunc(int32_t key, int32_t x, int32_t y) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, handleKey, keyPress, true); me->mKeysShift[keyPress] = glutGetModifiers() & GLUT_ACTIVE_SHIFT; me->mKeys[keyPress] = true; me->HandleKey(handleKey); } -void GPUDisplayFrontendGlut::specialUpFunc(int key, int x, int y) +void GPUDisplayFrontendGlut::specialUpFunc(int32_t key, int32_t x, int32_t y) { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(key, handleKey, keyPress, true); me->mKeys[keyPress] = false; me->mKeysShift[keyPress] = false; } -void GPUDisplayFrontendGlut::ResizeSceneWrapper(int width, int height) +void GPUDisplayFrontendGlut::ResizeSceneWrapper(int32_t width, int32_t height) { if (!me->mFullScreen) { me->mWidth = width; @@ -183,7 +183,7 @@ void GPUDisplayFrontendGlut::ResizeSceneWrapper(int width, int height) me->ResizeScene(width, height); } -void GPUDisplayFrontendGlut::mouseFunc(int button, int state, int x, int y) +void GPUDisplayFrontendGlut::mouseFunc(int32_t button, int32_t state, int32_t x, int32_t y) { if (button == 3) { me->mMouseWheel += 100; @@ -206,15 +206,15 @@ void GPUDisplayFrontendGlut::mouseFunc(int button, int state, int x, int y) } } -void GPUDisplayFrontendGlut::mouseMoveFunc(int x, int y) +void GPUDisplayFrontendGlut::mouseMoveFunc(int32_t x, int32_t y) { me->mMouseMvX = x; me->mMouseMvY = y; } -void GPUDisplayFrontendGlut::mMouseWheelFunc(int button, int dir, int x, int y) { me->mMouseWheel += dir; } +void GPUDisplayFrontendGlut::mMouseWheelFunc(int32_t button, int32_t dir, int32_t x, int32_t y) { me->mMouseWheel += dir; } -int GPUDisplayFrontendGlut::FrontendMain() +int32_t GPUDisplayFrontendGlut::FrontendMain() { if (backend()->backendType() != GPUDisplayBackend::TYPE_OPENGL) { fprintf(stderr, "Only OpenGL backend supported\n"); @@ -226,7 +226,7 @@ int GPUDisplayFrontendGlut::FrontendMain() drawTextFontSize() = 12; } - int nopts = 2; + int32_t nopts = 2; char opt1[] = "progname"; char opt2[] = "-direct"; char* opts[] = {opt1, opt2}; @@ -293,7 +293,7 @@ void GPUDisplayFrontendGlut::OpenGLPrint(const char* s, float x, float y, float } glColor4f(r, g, b, a); glRasterPos2f(x, y); - glutBitmapString(GLUT_BITMAP_HELVETICA_12, (const unsigned char*)s); + glutBitmapString(GLUT_BITMAP_HELVETICA_12, (const uint8_t*)s); #endif } @@ -310,7 +310,7 @@ void GPUDisplayFrontendGlut::SwitchFullscreen(bool set) void GPUDisplayFrontendGlut::ToggleMaximized(bool set) {} void GPUDisplayFrontendGlut::SetVSync(bool enable) {} -int GPUDisplayFrontendGlut::StartDisplay() +int32_t GPUDisplayFrontendGlut::StartDisplay() { static pthread_t hThread; if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) { diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.h index 90d69a48ef79f..71d7d17c935c8 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.h @@ -26,7 +26,7 @@ class GPUDisplayFrontendGlut : public GPUDisplayFrontend GPUDisplayFrontendGlut(); ~GPUDisplayFrontendGlut() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; @@ -34,26 +34,26 @@ class GPUDisplayFrontendGlut : public GPUDisplayFrontend void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; private: - int FrontendMain() override; + int32_t FrontendMain() override; static void displayFunc(); static void glutLoopFunc(); - static void keyboardUpFunc(unsigned char key, int x, int y); - static void keyboardDownFunc(unsigned char key, int x, int y); - static void specialUpFunc(int key, int x, int y); - static void specialDownFunc(int key, int x, int y); - static void mouseMoveFunc(int x, int y); - static void mMouseWheelFunc(int button, int dir, int x, int y); - static void mouseFunc(int button, int state, int x, int y); - static void ResizeSceneWrapper(int width, int height); - static int GetKey(int key); - static void GetKey(int keyin, int& keyOut, int& keyPressOut, bool special); + static void keyboardUpFunc(uint8_t key, int32_t x, int32_t y); + static void keyboardDownFunc(uint8_t key, int32_t x, int32_t y); + static void specialUpFunc(int32_t key, int32_t x, int32_t y); + static void specialDownFunc(int32_t key, int32_t x, int32_t y); + static void mouseMoveFunc(int32_t x, int32_t y); + static void mMouseWheelFunc(int32_t button, int32_t dir, int32_t x, int32_t y); + static void mouseFunc(int32_t button, int32_t state, int32_t x, int32_t y); + static void ResizeSceneWrapper(int32_t width, int32_t height); + static int32_t GetKey(int32_t key); + static void GetKey(int32_t keyin, int32_t& keyOut, int32_t& keyPressOut, bool special); volatile bool mGlutRunning = false; pthread_mutex_t mSemLockExit = PTHREAD_MUTEX_INITIALIZER; - int mWidth = INIT_WIDTH; - int mHeight = INIT_HEIGHT; + int32_t mWidth = INIT_WIDTH; + int32_t mHeight = INIT_HEIGHT; bool mFullScreen = false; }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendNone.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendNone.h index 6eebbf2c9c168..c95927c6655b9 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendNone.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendNone.h @@ -24,7 +24,7 @@ class GPUDisplayFrontendNone : public GPUDisplayFrontend GPUDisplayFrontendNone() = default; ~GPUDisplayFrontendNone() override = default; - int StartDisplay() override { return 1; } + int32_t StartDisplay() override { return 1; } void DisplayExit() override {} void SwitchFullscreen(bool set) override {} void ToggleMaximized(bool set) override {} diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx index 6c85336f9791a..b920259a1e70d 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx @@ -59,9 +59,9 @@ struct CCallWrapper { } }; -int GPUDisplayFrontendWayland::GetKey(unsigned int key, unsigned int state) +int32_t GPUDisplayFrontendWayland::GetKey(uint32_t key, uint32_t state) { - int retVal = 0; + int32_t retVal = 0; if (mXKBkeymap) { xkb_keysym_t sym = xkb_state_key_get_one_sym(mXKBstate, key + 8); if (sym == 65453) { @@ -138,10 +138,10 @@ int GPUDisplayFrontendWayland::GetKey(unsigned int key, unsigned int state) return retVal; } -void GPUDisplayFrontendWayland::createBuffer(unsigned int width, unsigned int height) +void GPUDisplayFrontendWayland::createBuffer(uint32_t width, uint32_t height) { - const unsigned int stride = width * 4; - const unsigned int size = stride * height; + const uint32_t stride = width * 4; + const uint32_t size = stride * height; if (ftruncate(mFd, size) < 0) { throw std::runtime_error("Error setting waysland shm file size"); } @@ -160,7 +160,7 @@ void GPUDisplayFrontendWayland::createBuffer(unsigned int width, unsigned int he wl_surface_commit(mSurface); } -void GPUDisplayFrontendWayland::recreateBuffer(unsigned int width, unsigned int height) +void GPUDisplayFrontendWayland::recreateBuffer(uint32_t width, uint32_t height) { wl_surface_attach(mSurface, nullptr, 0, 0); wl_surface_commit(mSurface); @@ -169,7 +169,7 @@ void GPUDisplayFrontendWayland::recreateBuffer(unsigned int width, unsigned int createBuffer(width, height); } -int GPUDisplayFrontendWayland::FrontendMain() +int32_t GPUDisplayFrontendWayland::FrontendMain() { if (backend()->backendType() != GPUDisplayBackend::TYPE_VULKAN) { fprintf(stderr, "Only Vulkan backend supported\n"); @@ -232,7 +232,7 @@ int GPUDisplayFrontendWayland::FrontendMain() const wl_pointer_listener pointer_listener = {.enter = pointer_enter, .leave = pointer_leave, .motion = pointer_motion, .button = pointer_button, .axis = pointer_axis, .frame = nullptr, .axis_source = nullptr, .axis_stop = nullptr, .axis_discrete = nullptr}; #pragma GCC diagnostic pop - auto keyboard_keymap = [](void* data, wl_keyboard* wl_keyboard, uint format, int fd, uint size) { + auto keyboard_keymap = [](void* data, wl_keyboard* wl_keyboard, uint32_t format, int32_t fd, uint32_t size) { GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data; if (me->mXKBkeymap) { xkb_state_unref(me->mXKBstate); @@ -244,12 +244,12 @@ int GPUDisplayFrontendWayland::FrontendMain() munmap(keymap_string, size); close(fd); }; - auto keyboard_enter = [](void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface, wl_array* keys) {}; - auto keyboard_leave = [](void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface) {}; - auto keyboard_key = [](void* data, wl_keyboard* wl_keyboard, uint serial, uint time, uint key, uint state) { + auto keyboard_enter = [](void* data, wl_keyboard* wl_keyboard, uint32_t serial, wl_surface* surface, wl_array* keys) {}; + auto keyboard_leave = [](void* data, wl_keyboard* wl_keyboard, uint32_t serial, wl_surface* surface) {}; + auto keyboard_key = [](void* data, wl_keyboard* wl_keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data; - int symbol = me->GetKey(key, state); - int keyPress = (symbol >= 'a' && symbol <= 'z') ? symbol + 'A' - 'a' : symbol; + int32_t symbol = me->GetKey(key, state); + int32_t keyPress = (symbol >= 'a' && symbol <= 'z') ? symbol + 'A' - 'a' : symbol; if (state == XKB_KEY_DOWN) { me->mKeys[keyPress] = true; me->mKeysShift[keyPress] = me->mKeys[KEY_SHIFT]; @@ -259,11 +259,11 @@ int GPUDisplayFrontendWayland::FrontendMain() me->mKeysShift[keyPress] = false; } }; - auto keyboard_modifiers = [](void* data, wl_keyboard* wl_keyboard, uint serial, uint mods_depressed, uint mods_latched, uint mods_locked, uint group) { + auto keyboard_modifiers = [](void* data, wl_keyboard* wl_keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) { GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data; xkb_state_update_mask(me->mXKBstate, mods_depressed, mods_latched, mods_locked, 0, 0, group); }; - auto keyboard_repat = [](void* data, wl_keyboard* wl_keyboard, int rate, int delay) {}; + auto keyboard_repat = [](void* data, wl_keyboard* wl_keyboard, int32_t rate, int32_t delay) {}; const wl_keyboard_listener keyboard_listener = {.keymap = keyboard_keymap, .enter = keyboard_enter, .leave = keyboard_leave, .key = keyboard_key, .modifiers = keyboard_modifiers, .repeat_info = keyboard_repat}; auto xdg_wm_base_ping = [](void* data, struct xdg_wm_base* xdg_wm_base, uint32_t serial) { @@ -471,7 +471,7 @@ void GPUDisplayFrontendWayland::SetVSync(bool enable) { } -int GPUDisplayFrontendWayland::StartDisplay() +int32_t GPUDisplayFrontendWayland::StartDisplay() { static pthread_t hThread; if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) { @@ -481,13 +481,13 @@ int GPUDisplayFrontendWayland::StartDisplay() return (0); } -void GPUDisplayFrontendWayland::getSize(int& width, int& height) +void GPUDisplayFrontendWayland::getSize(int32_t& width, int32_t& height) { width = mDisplayWidth; height = mDisplayHeight; } -int GPUDisplayFrontendWayland::getVulkanSurface(void* instance, void* surface) +int32_t GPUDisplayFrontendWayland::getVulkanSurface(void* instance, void* surface) { VkWaylandSurfaceCreateInfoKHR info{}; info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; @@ -497,7 +497,7 @@ int GPUDisplayFrontendWayland::getVulkanSurface(void* instance, void* surface) return vkCreateWaylandSurfaceKHR(*(VkInstance*)instance, &info, nullptr, (VkSurfaceKHR*)surface) != VK_SUCCESS; } -unsigned int GPUDisplayFrontendWayland::getReqVulkanExtensions(const char**& p) +uint32_t GPUDisplayFrontendWayland::getReqVulkanExtensions(const char**& p) { static const char* exts[] = {"VK_KHR_surface", "VK_KHR_wayland_surface"}; p = exts; diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h index 1ae8b8acbe243..f13c6fe831e0d 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h @@ -36,21 +36,21 @@ class GPUDisplayFrontendWayland : public GPUDisplayFrontend GPUDisplayFrontendWayland(); ~GPUDisplayFrontendWayland() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; void SetVSync(bool enable) override; void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; - void getSize(int& width, int& height) override; - int getVulkanSurface(void* instance, void* surface) override; - unsigned int getReqVulkanExtensions(const char**& p) override; + void getSize(int32_t& width, int32_t& height) override; + int32_t getVulkanSurface(void* instance, void* surface) override; + uint32_t getReqVulkanExtensions(const char**& p) override; private: - int FrontendMain() override; - int GetKey(unsigned int key, unsigned int state); - void createBuffer(unsigned int width, unsigned int height); - void recreateBuffer(unsigned int width, unsigned int height); + int32_t FrontendMain() override; + int32_t GetKey(uint32_t key, uint32_t state); + void createBuffer(uint32_t width, uint32_t height); + void recreateBuffer(uint32_t width, uint32_t height); pthread_mutex_t mSemLockExit = PTHREAD_MUTEX_INITIALIZER; volatile bool mDisplayRunning = false; @@ -71,7 +71,7 @@ class GPUDisplayFrontendWayland : public GPUDisplayFrontend wl_output* mOutput = nullptr; - int mFd = 0; + int32_t mFd = 0; wl_shm_pool* mPool; wl_buffer* mBuffer; @@ -82,8 +82,8 @@ class GPUDisplayFrontendWayland : public GPUDisplayFrontend zxdg_decoration_manager_v1* mDecManager = nullptr; // zxdg_toplevel_decoration_v1* mXdgDecoration = nullptr; - int mWidthRequested = 0; - int mHeightRequested = 0; + int32_t mWidthRequested = 0; + int32_t mHeightRequested = 0; }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.cxx index 75a1d04e2fc51..d8e05a3f03b9b 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.cxx @@ -37,7 +37,7 @@ bool fullscreen = TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default POINT mouseCursorPos; -volatile int mouseReset = false; +volatile int32_t mouseReset = false; void KillGLWindow() // Properly Kill The Window { @@ -78,17 +78,17 @@ void KillGLWindow() // Properly Kill The Window } } -BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) +BOOL CreateGLWindow(char* title, int32_t width, int32_t height, int32_t bits, bool fullscreenflag) { GLuint PixelFormat; // Holds The Results After Searching For A Match WNDCLASS wc; // Windows Class Structure DWORD dwExStyle; // Window Extended Style DWORD dwStyle; // Window Style RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values - WindowRect.left = (long)0; // Set Left Value To 0 - WindowRect.right = (long)width; // Set Right Value To Requested Width - WindowRect.top = (long)0; // Set Top Value To 0 - WindowRect.bottom = (long)height; // Set Bottom Value To Requested Height + WindowRect.left = (int64_t)0; // Set Left Value To 0 + WindowRect.right = (int64_t)width; // Set Right Value To Requested Width + WindowRect.top = (int64_t)0; // Set Top Value To 0 + WindowRect.bottom = (int64_t)height; // Set Bottom Value To Requested Height fullscreen = fullscreenflag; // Set The Global Fullscreen Flag @@ -150,7 +150,7 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format - (unsigned char)bits, // Select Our Color Depth + (uint8_t)bits, // Select Our Color Depth 0, 0, 0, @@ -217,7 +217,7 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree return TRUE; } -int GetKey(int key) +int32_t GetKey(int32_t key) { if (key == 107 || key == 187) { return ('+'); @@ -322,7 +322,7 @@ GPUDisplayFrontendWindows::GPUDisplayFrontendWindows() mFrontendName = "Win32"; } -int GPUDisplayFrontendWindows::FrontendMain() +int32_t GPUDisplayFrontendWindows::FrontendMain() { MSG msg; BOOL done = FALSE; @@ -376,7 +376,7 @@ void SwitchFullscreen(bool set) {} void ToggleMaximized(bool set) {} void SetVSync(bool enable) {} -int GPUDisplayFrontendWindows::StartDisplay() +int32_t GPUDisplayFrontendWindows::StartDisplay() { HANDLE hThread; if ((hThread = CreateThread(nullptr, nullptr, &OpenGLWrapper, this, nullptr, nullptr)) == nullptr) { diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.h index cd5e333931628..62b1a7437a58f 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendWindows.h @@ -25,7 +25,7 @@ class GPUDisplayFrontendWindows : public GPUDisplayFrontend GPUDisplayFrontendWindows(); ~GPUDisplayFrontendWindows() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; @@ -33,7 +33,7 @@ class GPUDisplayFrontendWindows : public GPUDisplayFrontend void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; private: - int FrontendMain() override; + int32_t FrontendMain() override; }; } // namespace GPUCA_NAMESPACE::gpu diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx index c1fae89b7227f..2ef2ccca92baf 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx @@ -28,7 +28,7 @@ #include #endif -typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*); +typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int32_t*); using namespace GPUCA_NAMESPACE::gpu; @@ -38,7 +38,7 @@ GPUDisplayFrontendX11::GPUDisplayFrontendX11() mFrontendName = "X11"; } -int GPUDisplayFrontendX11::GetKey(int key) +int32_t GPUDisplayFrontendX11::GetKey(int32_t key) { if (key == 65453) { return ('-'); @@ -139,16 +139,16 @@ int GPUDisplayFrontendX11::GetKey(int key) return 0; } -void GPUDisplayFrontendX11::GetKey(XEvent& event, int& keyOut, int& keyPressOut) +void GPUDisplayFrontendX11::GetKey(XEvent& event, int32_t& keyOut, int32_t& keyPressOut) { char tmpString[9]; KeySym sym; if (XLookupString(&event.xkey, tmpString, 8, &sym, nullptr) == 0) { tmpString[0] = 0; } - int specialKey = GetKey(sym); - int localeKey = (unsigned char)tmpString[0]; - // GPUInfo("Key: keycode %d -> sym %d (%c) key %d (%c) special %d (%c)", (int)event.xkey.keycode, (int)sym, (char)sym, (int)localeKey, (char)localeKey, (int)specialKey, (char)specialKey); + int32_t specialKey = GetKey(sym); + int32_t localeKey = (uint8_t)tmpString[0]; + // GPUInfo("Key: keycode %d -> sym %d (%c) key %d (%c) special %d (%c)", (int32_t)event.xkey.keycode, (int32_t)sym, (char)sym, (int32_t)localeKey, (char)localeKey, (int32_t)specialKey, (char)specialKey); if (specialKey) { keyOut = keyPressOut = specialKey; @@ -182,15 +182,15 @@ void GPUDisplayFrontendX11::OpenGLPrint(const char* s, float x, float y, float r #endif } -int GPUDisplayFrontendX11::FrontendMain() +int32_t GPUDisplayFrontendX11::FrontendMain() { XSetWindowAttributes windowAttributes; XVisualInfo* visualInfo = nullptr; XEvent event; Colormap colorMap; GLXContext glxContext = nullptr; - int errorBase; - int eventBase; + int32_t errorBase; + int32_t eventBase; // Open a connection to the X server mDisplay = XOpenDisplay(nullptr); @@ -215,13 +215,13 @@ int GPUDisplayFrontendX11::FrontendMain() } // Require MSAA, double buffering, and Depth buffer - int attribs[] = {GLX_X_RENDERABLE, True, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, GLX_DOUBLEBUFFER, True, - // GLX_SAMPLE_BUFFERS , 1, //Disable MSAA here, we do it by rendering to offscreenbuffer - // GLX_SAMPLES , MSAA_SAMPLES, - None}; + int32_t attribs[] = {GLX_X_RENDERABLE, True, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, GLX_DOUBLEBUFFER, True, + // GLX_SAMPLE_BUFFERS , 1, //Disable MSAA here, we do it by rendering to offscreenbuffer + // GLX_SAMPLES , MSAA_SAMPLES, + None}; GLXFBConfig fbconfig = nullptr; - int fbcount; + int32_t fbcount; GLXFBConfig* fbc = glXChooseFBConfig(mDisplay, DefaultScreen(mDisplay), attribs, &fbcount); if (fbc == nullptr || fbcount == 0) { GPUError("Failed to get MSAA GLXFBConfig"); @@ -240,7 +240,7 @@ int GPUDisplayFrontendX11::FrontendMain() // Create an OpenGL rendering context glXCreateContextAttribsARBProc glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddressARB((const GLubyte*)"glXCreateContextAttribsARB"); if (glXCreateContextAttribsARB) { - int context_attribs[] = { + int32_t context_attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, GL_MIN_VERSION_MAJOR, GLX_CONTEXT_MINOR_VERSION_ARB, GL_MIN_VERSION_MINOR, GLX_CONTEXT_PROFILE_MASK_ARB, mBackend->CoreProfile() ? GLX_CONTEXT_CORE_PROFILE_BIT_ARB : GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, @@ -291,8 +291,8 @@ int GPUDisplayFrontendX11::FrontendMain() GPUError("XLoadQueryFont failed."); return (-1); } else { - int first = font_info->min_char_or_byte2; - int last = font_info->max_char_or_byte2; + int32_t first = font_info->min_char_or_byte2; + int32_t last = font_info->max_char_or_byte2; glXUseXFont(font_info->fid, first, last - first + 1, mFontBase + first); } } @@ -309,7 +309,7 @@ int GPUDisplayFrontendX11::FrontendMain() XMapWindow(mDisplay, mWindow); XFlush(mDisplay); - int x11_fd = ConnectionNumber(mDisplay); + int32_t x11_fd = ConnectionNumber(mDisplay); // Enable vsync if (backend()->backendType() == GPUDisplayBackend::TYPE_OPENGL && vsync_supported) { @@ -331,10 +331,10 @@ int GPUDisplayFrontendX11::FrontendMain() std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now(); while (1) { - int num_ready_fds; + int32_t num_ready_fds; struct timeval tv; fd_set in_fds; - int waitCount = 0; + int32_t waitCount = 0; do { FD_ZERO(&in_fds); FD_SET(x11_fd, &in_fds); @@ -399,7 +399,7 @@ int GPUDisplayFrontendX11::FrontendMain() } case KeyPress: { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(event, handleKey, keyPress); mKeysShift[keyPress] = mKeys[KEY_SHIFT]; mKeys[keyPress] = true; @@ -408,7 +408,7 @@ int GPUDisplayFrontendX11::FrontendMain() } case KeyRelease: { - int handleKey = 0, keyPress = 0; + int32_t handleKey = 0, keyPress = 0; GetKey(event, handleKey, keyPress); mKeys[keyPress] = false; mKeysShift[keyPress] = false; @@ -514,11 +514,11 @@ void GPUDisplayFrontendX11::ToggleMaximized(bool set) void GPUDisplayFrontendX11::SetVSync(bool enable) { if (backend()->backendType() == GPUDisplayBackend::TYPE_OPENGL && vsync_supported) { - mGlXSwapIntervalEXT(mDisplay, glXGetCurrentDrawable(), (int)enable); + mGlXSwapIntervalEXT(mDisplay, glXGetCurrentDrawable(), (int32_t)enable); } } -int GPUDisplayFrontendX11::StartDisplay() +int32_t GPUDisplayFrontendX11::StartDisplay() { static pthread_t hThread; if (pthread_create(&hThread, nullptr, FrontendThreadWrapper, this)) { @@ -528,11 +528,11 @@ int GPUDisplayFrontendX11::StartDisplay() return (0); } -void GPUDisplayFrontendX11::getSize(int& width, int& height) +void GPUDisplayFrontendX11::getSize(int32_t& width, int32_t& height) { Window root_return; - int x_return, y_return; - unsigned int width_return, height_return, border_width_return, depth_return; + int32_t x_return, y_return; + uint32_t width_return, height_return, border_width_return, depth_return; if (XGetGeometry(mDisplay, mWindow, &root_return, &x_return, &y_return, &width_return, &height_return, &border_width_return, &depth_return) == 0) { throw std::runtime_error("Cannot query X11 window geometry"); } @@ -540,7 +540,7 @@ void GPUDisplayFrontendX11::getSize(int& width, int& height) height = height_return; } -int GPUDisplayFrontendX11::getVulkanSurface(void* instance, void* surface) +int32_t GPUDisplayFrontendX11::getVulkanSurface(void* instance, void* surface) { #ifdef GPUCA_BUILD_EVENT_DISPLAY_VULKAN VkXlibSurfaceCreateInfoKHR info{}; @@ -554,7 +554,7 @@ int GPUDisplayFrontendX11::getVulkanSurface(void* instance, void* surface) #endif } -unsigned int GPUDisplayFrontendX11::getReqVulkanExtensions(const char**& p) +uint32_t GPUDisplayFrontendX11::getReqVulkanExtensions(const char**& p) { static const char* exts[] = {"VK_KHR_surface", "VK_KHR_xlib_surface"}; p = exts; diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.h b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.h index e53961db97399..16920ce77460e 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.h @@ -29,20 +29,20 @@ class GPUDisplayFrontendX11 : public GPUDisplayFrontend GPUDisplayFrontendX11(); ~GPUDisplayFrontendX11() override = default; - int StartDisplay() override; + int32_t StartDisplay() override; void DisplayExit() override; void SwitchFullscreen(bool set) override; void ToggleMaximized(bool set) override; void SetVSync(bool enable) override; void OpenGLPrint(const char* s, float x, float y, float r, float g, float b, float a, bool fromBotton = true) override; - void getSize(int& width, int& height) override; - int getVulkanSurface(void* instance, void* surface) override; - unsigned int getReqVulkanExtensions(const char**& p) override; + void getSize(int32_t& width, int32_t& height) override; + int32_t getVulkanSurface(void* instance, void* surface) override; + uint32_t getReqVulkanExtensions(const char**& p) override; private: - int FrontendMain() override; - int GetKey(int key); - void GetKey(XEvent& event, int& keyOut, int& keyPressOut); + int32_t FrontendMain() override; + int32_t GetKey(int32_t key); + void GetKey(XEvent& event, int32_t& keyOut, int32_t& keyPressOut); pthread_mutex_t mSemLockExit = PTHREAD_MUTEX_INITIALIZER; volatile bool mDisplayRunning = false; diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.cxx index 000019dbd9446..a5ba968f9e50d 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.cxx @@ -76,7 +76,7 @@ void GPUDisplayGUIWrapper::UpdateTimer() void GPUDisplayGUIWrapper::guiThread() { - static int tmp_argc = 1; + static int32_t tmp_argc = 1; static const char* tmp_argv[2] = {"GPU CA Standalone Event Display GUI", NULL}; mO->app.reset(new QApplication(tmp_argc, (char**)tmp_argv)); while (!mO->terminate) { @@ -116,7 +116,7 @@ void GPUDisplayGUIWrapper::guiThread() mO->app.reset(nullptr); } -int GPUDisplayGUIWrapper::start() +int32_t GPUDisplayGUIWrapper::start() { if (!mO->started) { { @@ -134,7 +134,7 @@ int GPUDisplayGUIWrapper::start() return 0; } -int GPUDisplayGUIWrapper::stop() +int32_t GPUDisplayGUIWrapper::stop() { if (mO->started) { mO->stop = true; @@ -148,7 +148,7 @@ int GPUDisplayGUIWrapper::stop() return 0; } -int GPUDisplayGUIWrapper::focus() +int32_t GPUDisplayGUIWrapper::focus() { if (mO->started) { } diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.h b/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.h index 855e949ac409c..ef632c6f2d54b 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.h +++ b/GPU/GPUTracking/display/frontend/GPUDisplayGUIWrapper.h @@ -30,9 +30,9 @@ class GPUDisplayGUIWrapper bool isRunning() const; void UpdateTimer(); - int start(); - int stop(); - int focus(); + int32_t start(); + int32_t stop(); + int32_t focus(); private: std::unique_ptr mO; diff --git a/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx b/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx index 9a2481d1964cb..1842c276a580c 100644 --- a/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx +++ b/GPU/GPUTracking/display/frontend/GPUDisplayKeys.cxx @@ -71,12 +71,12 @@ const char* HelpText[] = { void GPUDisplay::PrintHelp() { mInfoHelpTimer.ResetStart(); - for (unsigned int i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) { + for (uint32_t i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) { GPUInfo("%s", HelpText[i]); } } -void GPUDisplay::HandleKey(unsigned char key) +void GPUDisplay::HandleKey(uint8_t key) { GPUSettingsDisplayHeavy oldCfgH = mCfgH; GPUSettingsDisplayLight oldCfgL = mCfgL; @@ -152,10 +152,10 @@ void GPUDisplay::HandleKey(unsigned char key) } } else if (key == 'F') { mCfgR.fullScreen ^= 1; - SetInfo("Toggling full screen (%d)", (int)mCfgR.fullScreen); + SetInfo("Toggling full screen (%d)", (int32_t)mCfgR.fullScreen); } else if (key == '_') { mCfgR.maximized ^= 1; - SetInfo("Toggling Maximized window (%d)", (int)mCfgR.maximized); + SetInfo("Toggling Maximized window (%d)", (int32_t)mCfgR.maximized); } else if (key == 'R') { mCfgR.maxFPSRate ^= 1; SetInfo("FPS rate %s", mCfgR.maxFPSRate ? "not limited" : "limited"); @@ -175,12 +175,7 @@ void GPUDisplay::HandleKey(unsigned char key) mCfgH.markClusters <<= 1; } SetInfo("Cluster flag highlight mask set to %d (%s)", mCfgH.markClusters, - mCfgH.markClusters == 0 ? "off" : mCfgH.markClusters == 1 ? "split pad" - : mCfgH.markClusters == 2 ? "split time" - : mCfgH.markClusters == 4 ? "edge" - : mCfgH.markClusters == 8 ? "singlePad" - : mCfgH.markClusters == 0x10 ? "reject distance" - : "reject error"); + mCfgH.markClusters == 0 ? "off" : mCfgH.markClusters == 1 ? "split pad" : mCfgH.markClusters == 2 ? "split time" : mCfgH.markClusters == 4 ? "edge" : mCfgH.markClusters == 8 ? "singlePad" : mCfgH.markClusters == 0x10 ? "reject distance" : "reject error"); } else if (key == 'z') { mCfgH.markFakeClusters ^= 1; SetInfo("Marking fake clusters: %s", mCfgH.markFakeClusters ? "on" : "off"); @@ -318,40 +313,40 @@ void GPUDisplay::HandleKey(unsigned char key) } else if (key == mFrontend->KEY_F1) { if (mFrontend->mKeysShift[mFrontend->KEY_F1]) { mCfgH.drawTPCTracks ^= 1; - SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int)mCfgH.drawTPCTracks, (int)mCfgH.drawTRDTracks, (int)mCfgH.drawTOFTracks, (int)mCfgH.drawITSTracks); + SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks); } else { mCfgL.drawTPC ^= 1; - SetInfo("Showing TPC Clusters: %d", (int)mCfgL.drawTPC); + SetInfo("Showing TPC Clusters: %d", (int32_t)mCfgL.drawTPC); } } else if (key == mFrontend->KEY_F2) { if (mFrontend->mKeysShift[mFrontend->KEY_F2]) { mCfgH.drawTRDTracks ^= 1; - SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int)mCfgH.drawTPCTracks, (int)mCfgH.drawTRDTracks, (int)mCfgH.drawTOFTracks, (int)mCfgH.drawITSTracks); + SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks); } else { mCfgL.drawTRD ^= 1; - SetInfo("Showing TRD Tracklets: %d", (int)mCfgL.drawTRD); + SetInfo("Showing TRD Tracklets: %d", (int32_t)mCfgL.drawTRD); } } else if (key == mFrontend->KEY_F3) { if (mFrontend->mKeysShift[mFrontend->KEY_F3]) { mCfgH.drawTOFTracks ^= 1; - SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int)mCfgH.drawTPCTracks, (int)mCfgH.drawTRDTracks, (int)mCfgH.drawTOFTracks, (int)mCfgH.drawITSTracks); + SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks); } else { mCfgL.drawTOF ^= 1; - SetInfo("Showing TOF Hits: %d", (int)mCfgL.drawTOF); + SetInfo("Showing TOF Hits: %d", (int32_t)mCfgL.drawTOF); } } else if (key == mFrontend->KEY_F4) { if (mFrontend->mKeysShift[mFrontend->KEY_F4]) { mCfgH.drawITSTracks ^= 1; - SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int)mCfgH.drawTPCTracks, (int)mCfgH.drawTRDTracks, (int)mCfgH.drawTOFTracks, (int)mCfgH.drawITSTracks); + SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks); } else { mCfgL.drawITS ^= 1; - SetInfo("Showing ITS Clusters: %d", (int)mCfgL.drawITS); + SetInfo("Showing ITS Clusters: %d", (int32_t)mCfgL.drawITS); } } else if (key == mFrontend->KEY_F12 && mFrontend->mKeysShift[mFrontend->KEY_F12]) { mCfgH.drawTracksAndFilter ^= 1; SetInfo("Track filter: %s", mCfgH.drawTracksAndFilter ? "AND" : "OR"); } else if (key == 't') { - static int nScreenshot = 1; + static int32_t nScreenshot = 1; char fname[32]; snprintf(fname, 32, "screenshot%d.bmp", nScreenshot++); mRequestScreenshot = true; @@ -378,7 +373,7 @@ void GPUDisplay::HandleKey(unsigned char key) SetInfo("Interpolating visualization settings during Animation %s", mAnimationChangeConfig ? "enabled" : "disabled"); } else if (key == 'Y') { setAnimationPoint(); - SetInfo("Added Animation point (%d points, %6.2f seconds)", (int)mAnimateVectors[0].size(), mAnimateVectors[0].back()); + SetInfo("Added Animation point (%d points, %6.2f seconds)", (int32_t)mAnimateVectors[0].size(), mAnimateVectors[0].back()); } else if (key == 'X') { resetAnimation(); SetInfo("Reset Animation points", 1); @@ -394,9 +389,7 @@ void GPUDisplay::HandleKey(unsigned char key) if (mCfgL.animationMode == 6) { SetInfo("Animation mode %d - Centered on origin", mCfgL.animationMode); } else { - SetInfo("Animation mode %d - Position: %s, Direction: %s", mCfgL.animationMode, (mCfgL.animationMode & 2) ? "Spherical (spherical rotation)" : (mCfgL.animationMode & 4) ? "Spherical (Euler angles)" - : "Cartesian", - (mCfgL.animationMode & 1) ? "Euler angles" : "Quaternion"); + SetInfo("Animation mode %d - Position: %s, Direction: %s", mCfgL.animationMode, (mCfgL.animationMode & 2) ? "Spherical (spherical rotation)" : (mCfgL.animationMode & 4) ? "Spherical (Euler angles)" : "Cartesian", (mCfgL.animationMode & 1) ? "Euler angles" : "Quaternion"); } } else if (key == 'u') { mCfgH.trackFilter = (mCfgH.trackFilter + 1) % (mConfig.filterMacros.size() + 1); @@ -405,7 +398,7 @@ void GPUDisplay::HandleKey(unsigned char key) } else if (key == 'o') { FILE* ftmp = fopen("glpos.tmp", "w+b"); if (ftmp) { - int retval = fwrite(&mViewMatrix, sizeof(mViewMatrix), 1, ftmp); + int32_t retval = fwrite(&mViewMatrix, sizeof(mViewMatrix), 1, ftmp); if (retval != 1) { GPUError("Error writing position to file"); } else { @@ -419,7 +412,7 @@ void GPUDisplay::HandleKey(unsigned char key) } else if (key == 'p') { FILE* ftmp = fopen("glpos.tmp", "rb"); if (ftmp) { - int retval = fread(&mViewMatrix, 1, sizeof(mViewMatrix), ftmp); + int32_t retval = fread(&mViewMatrix, 1, sizeof(mViewMatrix), ftmp); if (retval == sizeof(mViewMatrix)) { GPUInfo("Position read from file"); } else { @@ -434,9 +427,9 @@ void GPUDisplay::HandleKey(unsigned char key) FILE* ftmp = fopen("glanimation.tmp", "w+b"); if (ftmp) { fwrite(&mCfgL, sizeof(mCfgL), 1, ftmp); - int size = mAnimateVectors[0].size(); + int32_t size = mAnimateVectors[0].size(); fwrite(&size, sizeof(size), 1, ftmp); - for (int i = 0; i < 9; i++) { + for (int32_t i = 0; i < 9; i++) { fwrite(mAnimateVectors[i].data(), sizeof(mAnimateVectors[i][0]), size, ftmp); } fwrite(mAnimateConfig.data(), sizeof(mAnimateConfig[0]), size, ftmp); @@ -448,10 +441,10 @@ void GPUDisplay::HandleKey(unsigned char key) } else if (key == 'P') { FILE* ftmp = fopen("glanimation.tmp", "rb"); if (ftmp) { - int retval = fread(&mCfgL, sizeof(mCfgL), 1, ftmp); - int size; + int32_t retval = fread(&mCfgL, sizeof(mCfgL), 1, ftmp); + int32_t size; retval += fread(&size, sizeof(size), 1, ftmp); - for (int i = 0; i < 9; i++) { + for (int32_t i = 0; i < 9; i++) { mAnimateVectors[i].resize(size); retval += fread(mAnimateVectors[i].data(), sizeof(mAnimateVectors[i][0]), size, ftmp); } @@ -521,12 +514,12 @@ void GPUDisplay::HandleKey(unsigned char key) } } -void GPUDisplay::HandleSendKey(int key) +void GPUDisplay::HandleSendKey(int32_t key) { // GPUError("key %d '%c'", key, (char) key); bool shifted = key >= 'A' && key <= 'Z'; - int press = key; + int32_t press = key; if (press >= 'a' && press <= 'z') { press += 'A' - 'a'; } @@ -538,7 +531,7 @@ void GPUDisplay::HandleSendKey(int key) void GPUDisplay::PrintGLHelpText(float colorValue) { - for (unsigned int i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) { + for (uint32_t i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) { OpenGLPrint(HelpText[i], 40.f, 35 + std::max(20, mDrawTextFontSize + 4) * (1 + i), colorValue, colorValue, colorValue, mInfoHelpTimer.GetCurrentElapsedTime() >= 5 ? (6 - mInfoHelpTimer.GetCurrentElapsedTime()) : 1, false); } } diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayAnimation.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayAnimation.cxx index 8d023fb70cb16..77b7181a3a377 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayAnimation.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayAnimation.cxx @@ -35,7 +35,7 @@ void GPUDisplay::setAnimationPoint() mAnimateVectors[2].emplace_back(anglePhi); mAnimateVectors[3].emplace_back(angleTheta); } else { - for (int i = 0; i < 3; i++) { + for (int32_t i = 0; i < 3; i++) { mAnimateVectors[i + 1].emplace_back(mXYZ[i]); } // Cartesian @@ -44,7 +44,7 @@ void GPUDisplay::setAnimationPoint() mAnimateVectors[4].emplace_back(r); if (mCfgL.animationMode & 1) // Euler-angles { - for (int i = 0; i < 3; i++) { + for (int32_t i = 0; i < 3; i++) { float newangle = mAngle[i]; if (mAnimateVectors[0].size()) { mAnimationCloseAngle(newangle, mAnimateVectors[i + 5].back()); @@ -58,13 +58,13 @@ void GPUDisplay::setAnimationPoint() if (mAnimateVectors[0].size()) { mAnimateCloseQuaternion(v, mAnimateVectors[5].back(), mAnimateVectors[6].back(), mAnimateVectors[7].back(), mAnimateVectors[8].back()); } - for (int i = 0; i < 4; i++) { + for (int32_t i = 0; i < 4; i++) { mAnimateVectors[i + 5].emplace_back(v[i]); } } float delay = 0.f; if (mAnimateVectors[0].size()) { - delay = mAnimateVectors[0].back() + ((int)(mAnimationDelay * 20)) / 20.f; + delay = mAnimateVectors[0].back() + ((int32_t)(mAnimationDelay * 20)) / 20.f; } mAnimateVectors[0].emplace_back(delay); mAnimateConfig.emplace_back(mCfgL); @@ -72,7 +72,7 @@ void GPUDisplay::setAnimationPoint() void GPUDisplay::resetAnimation() { - for (int i = 0; i < 9; i++) { + for (int32_t i = 0; i < 9; i++) { mAnimateVectors[i].clear(); } mAnimateConfig.clear(); @@ -84,7 +84,7 @@ void GPUDisplay::removeAnimationPoint() if (mAnimateVectors[0].size() == 0) { return; } - for (int i = 0; i < 9; i++) { + for (int32_t i = 0; i < 9; i++) { mAnimateVectors[i].pop_back(); } mAnimateConfig.pop_back(); @@ -92,7 +92,7 @@ void GPUDisplay::removeAnimationPoint() void GPUDisplay::startAnimation() { - for (int i = 0; i < 8; i++) { + for (int32_t i = 0; i < 8; i++) { mAnimationSplines[i].create(mAnimateVectors[0], mAnimateVectors[i + 1]); } mAnimationTimer.ResetStart(); @@ -101,7 +101,7 @@ void GPUDisplay::startAnimation() mAnimationLastBase = 0; } -int GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix) +int32_t GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4& nextViewMatrix) { float time = animateTime; if (mAnimate && time < 0) { @@ -125,12 +125,12 @@ int GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4 return 0; } float vals[8]; - for (int i = 0; i < 8; i++) { + for (int32_t i = 0; i < 8; i++) { vals[i] = mAnimationSplines[i].evaluate(time); } if (mAnimationChangeConfig && animateTime < 0) { - int base = 0; - int k = mAnimateVectors[0].size() - 1; + int32_t base = 0; + int32_t k = mAnimateVectors[0].size() - 1; while (base < k && time > mAnimateVectors[0][base]) { base++; } @@ -162,7 +162,7 @@ int GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4 if (mag < 0.0001f) { vals[7] = 1; } else { - for (int i = 0; i < 4; i++) { + for (int32_t i = 0; i < 4; i++) { vals[4 + i] /= mag; } } @@ -184,7 +184,7 @@ int GPUDisplay::animateCamera(float& animateTime, float& mixSlaveImage, hmm_mat4 r = 1; } r = vals[3] / r; - for (int i = 0; i < 3; i++) { + for (int32_t i = 0; i < 3; i++) { vals[i] *= r; } } diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayBackendOpenGLMagneticField.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayBackendOpenGLMagneticField.cxx index ad1fd33cab686..16166baa9a91c 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayBackendOpenGLMagneticField.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayBackendOpenGLMagneticField.cxx @@ -49,17 +49,17 @@ using namespace GPUCA_NAMESPACE::gpu; #ifdef GPUCA_BUILD_EVENT_DISPLAY_OPENGL -#define CHKERR(cmd) \ - do { \ - (cmd); \ - GLenum err = glGetError(); \ - while (err != GL_NO_ERROR) { \ - GPUError("OpenGL Error %d: %s (%s: %d)", (int)err, (const char*)gluErrorString(err), __FILE__, __LINE__); \ - throw std::runtime_error("OpenGL Failure"); \ - } \ +#define CHKERR(cmd) \ + do { \ + (cmd); \ + GLenum err = glGetError(); \ + while (err != GL_NO_ERROR) { \ + GPUError("OpenGL Error %d: %s (%s: %d)", (int32_t)err, (const char*)gluErrorString(err), __FILE__, __LINE__); \ + throw std::runtime_error("OpenGL Failure"); \ + } \ } while (false) -int GPUDisplayBackendOpenGL::InitMagFieldVisualization() +int32_t GPUDisplayBackendOpenGL::InitMagFieldVisualization() { #ifndef GPUCA_NO_FMT mMagneticFieldVisualization = std::make_unique(); @@ -144,13 +144,13 @@ int GPUDisplayBackendOpenGL::InitMagFieldVisualization() return 0; } -unsigned int GPUDisplayBackendOpenGL::drawField() +uint32_t GPUDisplayBackendOpenGL::drawField() { if (!mMagneticFieldVisualization) { return InitMagFieldVisualization(); // next frame will fill MVP matrix } - if (mMagneticFieldVisualization->mFieldLineSeedPoints.size() != (unsigned int)mDisplay->cfgL().bFieldLinesCount) { + if (mMagneticFieldVisualization->mFieldLineSeedPoints.size() != (uint32_t)mDisplay->cfgL().bFieldLinesCount) { mMagneticFieldVisualization->generateSeedPoints(mDisplay->cfgL().bFieldLinesCount); CHKERR(glNamedBufferData(VBO_field, mMagneticFieldVisualization->mFieldLineSeedPoints.size() * sizeof(GPUDisplayMagneticField::vtx), mMagneticFieldVisualization->mFieldLineSeedPoints.data(), GL_STATIC_DRAW)); } @@ -196,10 +196,10 @@ void GPUDisplayBackendOpenGL::ExitMagFieldVisualization() } #else // GPUCA_BUILD_EVENT_DISPLAY_OPENGL -int GPUDisplayBackendOpenGL::InitMagFieldVisualization() +int32_t GPUDisplayBackendOpenGL::InitMagFieldVisualization() { return 0; } -unsigned int GPUDisplayBackendOpenGL::drawField() { return 0; } +uint32_t GPUDisplayBackendOpenGL::drawField() { return 0; } void GPUDisplayBackendOpenGL::ExitMagFieldVisualization() {} #endif // GPUCA_BUILD_EVENT_DISPLAY_OPENGL diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayColors.inc b/GPU/GPUTracking/display/helpers/GPUDisplayColors.inc index 75093ab191804..2994af86980d8 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayColors.inc +++ b/GPU/GPUTracking/display/helpers/GPUDisplayColors.inc @@ -162,11 +162,11 @@ inline void GPUDisplay::SetColorMarked() } ActivateColor(); } -inline void GPUDisplay::SetCollisionColor(int col) +inline void GPUDisplay::SetCollisionColor(int32_t col) { - int red = (col * 2) % 5; - int blue = (2 + col * 3) % 7; - int green = (4 + col * 5) % 6; + int32_t red = (col * 2) % 5; + int32_t blue = (2 + col * 3) % 7; + int32_t green = (4 + col * 5) % 6; if (mCfgL.invertColors && red == 4 && blue == 5 && green == 6) { red = 0; } diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayHelpers.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayHelpers.cxx index a41be9d9e278a..cd73cc0b9b34f 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayHelpers.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayHelpers.cxx @@ -23,7 +23,7 @@ using namespace GPUCA_NAMESPACE::gpu; -int GPUDisplay::getNumThreads() +int32_t GPUDisplay::getNumThreads() { if (mChain) { return mChain->GetProcessingSettings().ompThreads; diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayInterpolation.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayInterpolation.cxx index d3a2a4d584460..3df61bfc81110 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayInterpolation.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayInterpolation.cxx @@ -27,9 +27,9 @@ void GPUDisplay::opengl_spline::create(const vecpod& x, const vecpod %f", i, x[i], y[i]); } } @@ -39,36 +39,36 @@ void GPUDisplay::opengl_spline::create(const vecpod& x, const vecpod h(k + 1), alpha(k + 1), l(k + 1), mu(k + 1), z(k + 1); - for (int i = 0; i <= k; i++) { + for (int32_t i = 0; i <= k; i++) { ma[i] = y[i]; } - for (int i = 0; i < k; i++) { + for (int32_t i = 0; i < k; i++) { h[i] = x[i + 1] - x[i]; } - for (int i = 1; i < k; i++) { + for (int32_t i = 1; i < k; i++) { alpha[i] = 3.f / h[i] * (ma[i + 1] - ma[i]) - 3.f / h[i - 1] * (ma[i] - ma[i - 1]); } l[0] = l[k] = 1; mu[0] = z[0] = z[k] = mc[k] = 0; - for (int i = 1; i < k; i++) { + for (int32_t i = 1; i < k; i++) { l[i] = 2.f * (x[i + 1] - x[i - 1]) - h[i - 1] * mu[i - 1]; mu[i] = h[i] / l[i]; z[i] = (alpha[i] - h[i - 1] * z[i - 1]) / l[i]; } - for (int i = k - 1; i >= 0; i--) { + for (int32_t i = k - 1; i >= 0; i--) { mc[i] = z[i] - mu[i] * mc[i + 1]; mb[i] = (ma[i + 1] - ma[i]) / h[i] - h[i] / 3.f * (mc[i + 1] + 2.f * mc[i]); md[i] = (mc[i + 1] - mc[i]) / (3.f * h[i]); } - for (int i = 0; i <= k; i++) { + for (int32_t i = 0; i <= k; i++) { mx[i] = x[i]; } } float GPUDisplay::opengl_spline::evaluate(float x) { - int base = 0; - const int k = mx.size() - 1; + int32_t base = 0; + const int32_t k = mx.size() - 1; if (k < 0) { return (0); } diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.cxx index 357274e2decfc..352f029ab3648 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.cxx @@ -47,9 +47,9 @@ void GPUDisplayMagneticField::generateSeedPoints(std::size_t count) std::mt19937 rng(0xDEADBEEF); // TODO: fetch these values from somewhere? - std::uniform_int_distribution generator_x(-512, 512); - std::uniform_int_distribution generator_y(-512, 512); - std::uniform_int_distribution generator_z(-455 - 1312, -455 + 1312); + std::uniform_int_distribution generator_x(-512, 512); + std::uniform_int_distribution generator_y(-512, 512); + std::uniform_int_distribution generator_z(-455 - 1312, -455 + 1312); mFieldLineSeedPoints.clear(); @@ -131,7 +131,7 @@ std::tuple loadParams(std::i } #ifndef GPUCA_O2_LIB -int GPUDisplayMagneticField::initializeUniforms() +int32_t GPUDisplayMagneticField::initializeUniforms() { mSolenoidSegments = std::make_unique(); mDipoleSegments = std::make_unique(); @@ -177,7 +177,7 @@ int GPUDisplayMagneticField::initializeUniforms() #endif #if !defined(GPUCA_NO_ROOT) && defined(GPUCA_O2_LIB) -int GPUDisplayMagneticField::initializeUniforms() +int32_t GPUDisplayMagneticField::initializeUniforms() { mRenderConstantsUniform = std::make_unique(); @@ -198,7 +198,7 @@ int GPUDisplayMagneticField::initializeUniforms() return initializeUniformsFromField(field); } -int GPUDisplayMagneticField::initializeUniformsFromField(o2::field::MagneticField* field) +int32_t GPUDisplayMagneticField::initializeUniformsFromField(o2::field::MagneticField* field) { const auto chebMap = field->getMeasuredMap(); @@ -279,8 +279,8 @@ int GPUDisplayMagneticField::initializeUniformsFromField(o2::field::MagneticFiel const auto getParameterSolenoid = [chebMap](Int_t i) { return chebMap->getParameterSolenoid(i); }; const auto getParameterDipole = [chebMap](Int_t i) { return chebMap->getParameterDipole(i); }; - auto countArraySizes = [](int numberOfParametrization, auto& getParameter) { - int TotalRows = 0, TotalColumns = 0, TotalCoefficients = 0; + auto countArraySizes = [](int32_t numberOfParametrization, auto& getParameter) { + int32_t TotalRows = 0, TotalColumns = 0, TotalCoefficients = 0; UShort_t MaxChebyshevOrder = 0; for (auto i = 0; i < numberOfParametrization; ++i) { @@ -389,8 +389,8 @@ int GPUDisplayMagneticField::initializeUniformsFromField(o2::field::MagneticFiel mDipoleSegments = std::make_unique(); loadSegments(dipoleTableInfo, *mDipoleSegments); - auto initParametrization = [](int numberOfParametrization, auto& getParameter, auto& parametrizationUniform) { - int ColsAtRowOffset = 0, CofsAtRowOffset = 0, CofsAtColOffset = 0, Coeffs = 0; + auto initParametrization = [](int32_t numberOfParametrization, auto& getParameter, auto& parametrizationUniform) { + int32_t ColsAtRowOffset = 0, CofsAtRowOffset = 0, CofsAtColOffset = 0, Coeffs = 0; for (auto i = 0; i < numberOfParametrization; ++i) { const auto param = getParameter(i); diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.h b/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.h index 3ec9682b6b6b3..f8461e4c036f4 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.h +++ b/GPU/GPUTracking/display/helpers/GPUDisplayMagneticField.h @@ -51,7 +51,7 @@ class GPUDisplayMagneticField static constexpr std::size_t MAX_CHEBYSHEV_ORDER = 32; struct RenderConstantsUniform { - unsigned int StepCount; + uint32_t StepCount; float StepSize; }; @@ -61,21 +61,21 @@ class GPUDisplayMagneticField float MaxZ; float MultiplicativeFactor; - int ZSegments; + int32_t ZSegments; float SegDim1[MAX_DIM1_SEGMENTS]; - int BegSegDim2[MAX_DIM1_SEGMENTS]; - int NSegDim2[MAX_DIM1_SEGMENTS]; + int32_t BegSegDim2[MAX_DIM1_SEGMENTS]; + int32_t NSegDim2[MAX_DIM1_SEGMENTS]; float SegDim2[MAX_DIM2_SEGMENTS]; - int BegSegDim3[MAX_DIM2_SEGMENTS]; - int NSegDim3[MAX_DIM2_SEGMENTS]; + int32_t BegSegDim3[MAX_DIM2_SEGMENTS]; + int32_t NSegDim3[MAX_DIM2_SEGMENTS]; float SegDim3[MAX_DIM3_SEGMENTS]; - int SegID[MAX_DIM3_SEGMENTS]; + int32_t SegID[MAX_DIM3_SEGMENTS]; }; template @@ -85,15 +85,15 @@ class GPUDisplayMagneticField float BMin[MAX_PARAMETERIZATIONS]; float BMax[MAX_PARAMETERIZATIONS]; - int NRows[MAX_PARAMETERIZATIONS]; - int ColsAtRowOffset[MAX_PARAMETERIZATIONS]; - int CofsAtRowOffset[MAX_PARAMETERIZATIONS]; + int32_t NRows[MAX_PARAMETERIZATIONS]; + int32_t ColsAtRowOffset[MAX_PARAMETERIZATIONS]; + int32_t CofsAtRowOffset[MAX_PARAMETERIZATIONS]; - int NColsAtRow[MAX_ROWS]; - int CofsAtColOffset[MAX_ROWS]; + int32_t NColsAtRow[MAX_ROWS]; + int32_t CofsAtColOffset[MAX_ROWS]; - int NCofsAtCol[MAX_COLUMNS]; - int AtColCoefOffset[MAX_COLUMNS]; + int32_t NCofsAtCol[MAX_COLUMNS]; + int32_t AtColCoefOffset[MAX_COLUMNS]; float Coeffs[MAX_COEFFICIENTS]; }; @@ -110,9 +110,9 @@ class GPUDisplayMagneticField vtx(float a, float b, float c) : x(a), y(b), z(c) {} }; - int initializeUniforms(); + int32_t initializeUniforms(); #ifdef GPUCA_O2_LIB - int initializeUniformsFromField(o2::field::MagneticField* field); + int32_t initializeUniformsFromField(o2::field::MagneticField* field); #endif void generateSeedPoints(std::size_t count); diff --git a/GPU/GPUTracking/display/helpers/GPUDisplayROOT.cxx b/GPU/GPUTracking/display/helpers/GPUDisplayROOT.cxx index cb81b485bc6dd..4d99c3aa38cfc 100644 --- a/GPU/GPUTracking/display/helpers/GPUDisplayROOT.cxx +++ b/GPU/GPUTracking/display/helpers/GPUDisplayROOT.cxx @@ -25,7 +25,7 @@ using namespace GPUCA_NAMESPACE::gpu; #include "TSystem.h" #include "TMethodCall.h" -int GPUDisplay::buildTrackFilter() +int32_t GPUDisplay::buildTrackFilter() { if (!mCfgH.trackFilter) { return 0; @@ -54,7 +54,7 @@ int GPUDisplay::buildTrackFilter() #else -int GPUDisplay::buildTrackFilter() +int32_t GPUDisplay::buildTrackFilter() { } diff --git a/GPU/GPUTracking/display/helpers/bitmapfile.h b/GPU/GPUTracking/display/helpers/bitmapfile.h index 274993633e36e..ead2b80045cc6 100644 --- a/GPU/GPUTracking/display/helpers/bitmapfile.h +++ b/GPU/GPUTracking/display/helpers/bitmapfile.h @@ -13,24 +13,24 @@ /// \author David Rohr struct BITMAPFILEHEADER { - unsigned short bfType; - unsigned int bfSize; - unsigned int bfReserved; - unsigned int bfOffBits; + uint16_t bfType; + uint32_t bfSize; + uint32_t bfReserved; + uint32_t bfOffBits; } __attribute__((packed)); struct BITMAPINFOHEADER { - unsigned int biSize; - unsigned int biWidth; - unsigned int biHeight; - unsigned short biPlanes; - unsigned short biBitCount; - unsigned int biCompression; - unsigned int biSizeImage; - unsigned int biXPelsPerMeter; - unsigned int biYPelsPerMeter; - unsigned int biClrUsed; - unsigned int biClrImportant; + uint32_t biSize; + uint32_t biWidth; + uint32_t biHeight; + uint16_t biPlanes; + uint16_t biBitCount; + uint32_t biCompression; + uint32_t biSizeImage; + uint32_t biXPelsPerMeter; + uint32_t biYPelsPerMeter; + uint32_t biClrUsed; + uint32_t biClrImportant; } __attribute__((packed)); enum BI_Compression { BI_RGB = 0x0000, diff --git a/GPU/GPUTracking/display/helpers/field-uniform-exporter.cxx b/GPU/GPUTracking/display/helpers/field-uniform-exporter.cxx index 3f564f5bc8e5b..d8210979efa64 100644 --- a/GPU/GPUTracking/display/helpers/field-uniform-exporter.cxx +++ b/GPU/GPUTracking/display/helpers/field-uniform-exporter.cxx @@ -24,7 +24,7 @@ namespace bpo = boost::program_options; using namespace GPUCA_NAMESPACE::gpu; template -void saveSegments(std::ofstream& file, int NSegDim1, int NSegDim2, int NSegDim3, GPUDisplayMagneticField::SegmentsUniform& segments) +void saveSegments(std::ofstream& file, int32_t NSegDim1, int32_t NSegDim2, int32_t NSegDim3, GPUDisplayMagneticField::SegmentsUniform& segments) { file.write(reinterpret_cast(&segments.MinZ), sizeof(segments.MinZ)); file.write(reinterpret_cast(&segments.MaxZ), sizeof(segments.MaxZ)); @@ -51,7 +51,7 @@ void saveSegments(std::ofstream& file, int NSegDim1, int NSegDim2, int NSegDim3, } template -void saveParams(std::ofstream& file, int numberOfParametrization, int Nrows, int Ncolums, int Ncoeffs, GPUDisplayMagneticField::ParametrizationUniform& param) +void saveParams(std::ofstream& file, int32_t numberOfParametrization, int32_t Nrows, int32_t Ncolums, int32_t Ncoeffs, GPUDisplayMagneticField::ParametrizationUniform& param) { file.write(reinterpret_cast(&numberOfParametrization), sizeof(std::int32_t)); @@ -66,20 +66,20 @@ void saveParams(std::ofstream& file, int numberOfParametrization, int Nrows, int file.write(reinterpret_cast(&Nrows), sizeof(std::int32_t)); - file.write(reinterpret_cast(param.NColsAtRow), Nrows * sizeof(int)); - file.write(reinterpret_cast(param.CofsAtColOffset), Nrows * sizeof(int)); + file.write(reinterpret_cast(param.NColsAtRow), Nrows * sizeof(int32_t)); + file.write(reinterpret_cast(param.CofsAtColOffset), Nrows * sizeof(int32_t)); - file.write(reinterpret_cast(&Ncolums), sizeof(int)); + file.write(reinterpret_cast(&Ncolums), sizeof(int32_t)); - file.write(reinterpret_cast(param.NCofsAtCol), Ncolums * sizeof(int)); - file.write(reinterpret_cast(param.AtColCoefOffset), Ncolums * sizeof(int)); + file.write(reinterpret_cast(param.NCofsAtCol), Ncolums * sizeof(int32_t)); + file.write(reinterpret_cast(param.AtColCoefOffset), Ncolums * sizeof(int32_t)); - file.write(reinterpret_cast(&Ncoeffs), sizeof(int)); + file.write(reinterpret_cast(&Ncoeffs), sizeof(int32_t)); file.write(reinterpret_cast(param.Coeffs), Ncoeffs * sizeof(float)); } -int main(int argc, char** argv) +int32_t main(int argc, char** argv) { bpo::options_description options("Field Uniform exporter options"); diff --git a/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx b/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx index 801ec0abddbe8..ab7ebf6811766 100644 --- a/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx +++ b/GPU/GPUTracking/display/render/GPUDisplayDraw.cxx @@ -47,9 +47,9 @@ using namespace GPUCA_NAMESPACE::gpu; #define SEPERATE_GLOBAL_TRACKS_LIMIT (mCfgH.separateGlobalTracks ? tGLOBALTRACK : TRACK_TYPE_ID_LIMIT) const GPUTRDGeometry* GPUDisplay::trdGeometry() { return (GPUTRDGeometry*)mCalib->trdGeometry; } -const GPUTPCTracker& GPUDisplay::sliceTracker(int iSlice) { return mChain->GetTPCSliceTrackers()[iSlice]; } +const GPUTPCTracker& GPUDisplay::sliceTracker(int32_t iSlice) { return mChain->GetTPCSliceTrackers()[iSlice]; } -inline void GPUDisplay::insertVertexList(std::pair*, vecpod*>& vBuf, size_t first, size_t last) +inline void GPUDisplay::insertVertexList(std::pair*, vecpod*>& vBuf, size_t first, size_t last) { if (first == last) { return; @@ -57,13 +57,13 @@ inline void GPUDisplay::insertVertexList(std::pair*, vecpodemplace_back(first); vBuf.second->emplace_back(last - first); } -inline void GPUDisplay::insertVertexList(int iSlice, size_t first, size_t last) +inline void GPUDisplay::insertVertexList(int32_t iSlice, size_t first, size_t last) { - std::pair*, vecpod*> vBuf(mVertexBufferStart + iSlice, mVertexBufferCount + iSlice); + std::pair*, vecpod*> vBuf(mVertexBufferStart + iSlice, mVertexBufferCount + iSlice); insertVertexList(vBuf, first, last); } -inline void GPUDisplay::drawPointLinestrip(int iSlice, int cid, int id, int id_limit) +inline void GPUDisplay::drawPointLinestrip(int32_t iSlice, int32_t cid, int32_t id, int32_t id_limit) { mVertexBuffer[iSlice].emplace_back(mGlobalPos[cid].x, mGlobalPos[cid].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPos[cid].z); if (mGlobalPos[cid].w < id_limit) { @@ -71,14 +71,14 @@ inline void GPUDisplay::drawPointLinestrip(int iSlice, int cid, int id, int id_l } } -GPUDisplay::vboList GPUDisplay::DrawSpacePointsTRD(int iSlice, int select, int iCol) +GPUDisplay::vboList GPUDisplay::DrawSpacePointsTRD(int32_t iSlice, int32_t select, int32_t iCol) { size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); if (iCol == 0) { - for (unsigned int i = 0; i < mIOPtrs->nTRDTracklets; i++) { - int iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector()); + for (uint32_t i = 0; i < mIOPtrs->nTRDTracklets; i++) { + int32_t iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector()); bool draw = iSlice == iSec && mGlobalPosTRD[i].w == select; if (draw) { mVertexBuffer[iSlice].emplace_back(mGlobalPosTRD[i].x, mGlobalPosTRD[i].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTRD[i].z); @@ -91,13 +91,13 @@ GPUDisplay::vboList GPUDisplay::DrawSpacePointsTRD(int iSlice, int select, int i return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawSpacePointsTOF(int iSlice, int select, int iCol) +GPUDisplay::vboList GPUDisplay::DrawSpacePointsTOF(int32_t iSlice, int32_t select, int32_t iCol) { size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); if (iCol == 0 && iSlice == 0) { - for (unsigned int i = 0; i < mIOPtrs->nTOFClusters; i++) { + for (uint32_t i = 0; i < mIOPtrs->nTOFClusters; i++) { mVertexBuffer[iSlice].emplace_back(mGlobalPosTOF[i].x, mGlobalPosTOF[i].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTOF[i].z); } } @@ -106,13 +106,13 @@ GPUDisplay::vboList GPUDisplay::DrawSpacePointsTOF(int iSlice, int select, int i return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawSpacePointsITS(int iSlice, int select, int iCol) +GPUDisplay::vboList GPUDisplay::DrawSpacePointsITS(int32_t iSlice, int32_t select, int32_t iCol) { size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); if (iCol == 0 && iSlice == 0 && mIOPtrs->itsClusters) { - for (unsigned int i = 0; i < mIOPtrs->nItsClusters; i++) { + for (uint32_t i = 0; i < mIOPtrs->nItsClusters; i++) { mVertexBuffer[iSlice].emplace_back(mGlobalPosITS[i].x, mGlobalPosITS[i].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosITS[i].z); } } @@ -121,17 +121,16 @@ GPUDisplay::vboList GPUDisplay::DrawSpacePointsITS(int iSlice, int select, int i return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, unsigned int iCol) +GPUDisplay::vboList GPUDisplay::DrawClusters(int32_t iSlice, int32_t select, uint32_t iCol) { size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); if (mOverlayTFClusters.size() > 0 || iCol == 0 || mNCollissions) { - const int firstCluster = (mOverlayTFClusters.size() > 1 && iCol > 0) ? mOverlayTFClusters[iCol - 1][iSlice] : 0; - const int lastCluster = (mOverlayTFClusters.size() > 1 && iCol + 1 < mOverlayTFClusters.size()) ? mOverlayTFClusters[iCol][iSlice] : (mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] - : 0); + const int32_t firstCluster = (mOverlayTFClusters.size() > 1 && iCol > 0) ? mOverlayTFClusters[iCol - 1][iSlice] : 0; + const int32_t lastCluster = (mOverlayTFClusters.size() > 1 && iCol + 1 < mOverlayTFClusters.size()) ? mOverlayTFClusters[iCol][iSlice] : (mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] : 0); const bool checkClusterCollision = mQA && mNCollissions && mOverlayTFClusters.size() == 0 && mIOPtrs->clustersNative && mIOPtrs->clustersNative->clustersMCTruth; - for (int cidInSlice = firstCluster; cidInSlice < lastCluster; cidInSlice++) { - const int cid = GET_CID(iSlice, cidInSlice); + for (int32_t cidInSlice = firstCluster; cidInSlice < lastCluster; cidInSlice++) { + const int32_t cid = GET_CID(iSlice, cidInSlice); #ifdef GPUCA_TPC_GEOMETRY_O2 if (checkClusterCollision) { const auto& labels = mIOPtrs->clustersNative->clustersMCTruth->getLabels(cid); @@ -148,7 +147,7 @@ GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, unsigned in bool draw = mGlobalPos[cid].w == select; if (mCfgH.markAdjacentClusters) { - const int attach = mIOPtrs->mergedTrackHitAttachment[cid]; + const int32_t attach = mIOPtrs->mergedTrackHitAttachment[cid]; if (attach) { if (mCfgH.markAdjacentClusters >= 32) { if (mQA && mQA->clusterRemovable(attach, mCfgH.markAdjacentClusters == 33)) { @@ -169,7 +168,7 @@ GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, unsigned in } } } else if (mCfgH.markClusters) { - short flags; + int16_t flags; if (mParam->par.earlyTpcTransform) { flags = mIOPtrs->clusterData[iSlice][cidInSlice].flags; } else { @@ -190,23 +189,23 @@ GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, unsigned in return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawLinks(const GPUTPCTracker& tracker, int id, bool dodown) +GPUDisplay::vboList GPUDisplay::DrawLinks(const GPUTPCTracker& tracker, int32_t id, bool dodown) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); if (mCfgH.clustersOnly) { return (vboList(0, 0, iSlice)); } size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); - for (int i = 0; i < GPUCA_ROW_COUNT; i++) { + for (int32_t i = 0; i < GPUCA_ROW_COUNT; i++) { const GPUTPCRow& row = tracker.Data().Row(i); if (i < GPUCA_ROW_COUNT - 2) { const GPUTPCRow& rowUp = tracker.Data().Row(i + 2); - for (int j = 0; j < row.NHits(); j++) { + for (int32_t j = 0; j < row.NHits(); j++) { if (tracker.Data().HitLinkUpData(row, j) != CALINK_INVAL) { - const int cid1 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, j)); - const int cid2 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(rowUp, tracker.Data().HitLinkUpData(row, j))); + const int32_t cid1 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, j)); + const int32_t cid2 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(rowUp, tracker.Data().HitLinkUpData(row, j))); drawPointLinestrip(iSlice, cid1, id); drawPointLinestrip(iSlice, cid2, id); } @@ -215,10 +214,10 @@ GPUDisplay::vboList GPUDisplay::DrawLinks(const GPUTPCTracker& tracker, int id, if (dodown && i >= 2) { const GPUTPCRow& rowDown = tracker.Data().Row(i - 2); - for (int j = 0; j < row.NHits(); j++) { + for (int32_t j = 0; j < row.NHits(); j++) { if (tracker.Data().HitLinkDownData(row, j) != CALINK_INVAL) { - const int cid1 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, j)); - const int cid2 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(rowDown, tracker.Data().HitLinkDownData(row, j))); + const int32_t cid1 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, j)); + const int32_t cid2 = GET_CID(iSlice, tracker.Data().ClusterDataIndex(rowDown, tracker.Data().HitLinkDownData(row, j))); drawPointLinestrip(iSlice, cid1, id); drawPointLinestrip(iSlice, cid2, id); } @@ -231,19 +230,19 @@ GPUDisplay::vboList GPUDisplay::DrawLinks(const GPUTPCTracker& tracker, int id, GPUDisplay::vboList GPUDisplay::DrawSeeds(const GPUTPCTracker& tracker) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); if (mCfgH.clustersOnly) { return (vboList(0, 0, iSlice)); } size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int i = 0; i < *tracker.NStartHits(); i++) { + for (uint32_t i = 0; i < *tracker.NStartHits(); i++) { const GPUTPCHitId& hit = tracker.TrackletStartHit(i); size_t startCountInner = mVertexBuffer[iSlice].size(); - int ir = hit.RowIndex(); + int32_t ir = hit.RowIndex(); calink ih = hit.HitIndex(); do { const GPUTPCRow& row = tracker.Data().Row(ir); - const int cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, ih)); + const int32_t cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, ih)); drawPointLinestrip(iSlice, cid, tSEED); ir += 2; ih = tracker.Data().HitLinkUpData(row, ih); @@ -255,20 +254,20 @@ GPUDisplay::vboList GPUDisplay::DrawSeeds(const GPUTPCTracker& tracker) GPUDisplay::vboList GPUDisplay::DrawTracklets(const GPUTPCTracker& tracker) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); if (mCfgH.clustersOnly) { return (vboList(0, 0, iSlice)); } size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int i = 0; i < *tracker.NTracklets(); i++) { + for (uint32_t i = 0; i < *tracker.NTracklets(); i++) { const GPUTPCTracklet& tracklet = tracker.Tracklet(i); size_t startCountInner = mVertexBuffer[iSlice].size(); float4 oldpos; - for (int j = tracklet.FirstRow(); j <= tracklet.LastRow(); j++) { + for (int32_t j = tracklet.FirstRow(); j <= tracklet.LastRow(); j++) { const calink rowHit = tracker.TrackletRowHits()[tracklet.FirstHit() + (j - tracklet.FirstRow())]; if (rowHit != CALINK_INVAL && rowHit != CALINK_DEAD_CHANNEL) { const GPUTPCRow& row = tracker.Data().Row(j); - const int cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, rowHit)); + const int32_t cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, rowHit)); oldpos = mGlobalPos[cid]; drawPointLinestrip(iSlice, cid, tTRACKLET); } @@ -278,20 +277,20 @@ GPUDisplay::vboList GPUDisplay::DrawTracklets(const GPUTPCTracker& tracker) return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawTracks(const GPUTPCTracker& tracker, int global) +GPUDisplay::vboList GPUDisplay::DrawTracks(const GPUTPCTracker& tracker, int32_t global) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); if (mCfgH.clustersOnly) { return (vboList(0, 0, iSlice)); } size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int i = (global ? tracker.CommonMemory()->nLocalTracks : 0); i < (global ? *tracker.NTracks() : tracker.CommonMemory()->nLocalTracks); i++) { + for (uint32_t i = (global ? tracker.CommonMemory()->nLocalTracks : 0); i < (global ? *tracker.NTracks() : tracker.CommonMemory()->nLocalTracks); i++) { GPUTPCTrack& track = tracker.Tracks()[i]; size_t startCountInner = mVertexBuffer[iSlice].size(); - for (int j = 0; j < track.NHits(); j++) { + for (int32_t j = 0; j < track.NHits(); j++) { const GPUTPCHitId& hit = tracker.TrackHits()[track.FirstHitID() + j]; const GPUTPCRow& row = tracker.Data().Row(hit.RowIndex()); - const int cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, hit.HitIndex())); + const int32_t cid = GET_CID(iSlice, tracker.Data().ClusterDataIndex(row, hit.HitIndex())); drawPointLinestrip(iSlice, cid, tSLICETRACK + global); } insertVertexList(iSlice, startCountInner, mVertexBuffer[iSlice].size()); @@ -299,12 +298,12 @@ GPUDisplay::vboList GPUDisplay::DrawTracks(const GPUTPCTracker& tracker, int glo return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -void GPUDisplay::DrawTrackITS(int trackId, int iSlice) +void GPUDisplay::DrawTrackITS(int32_t trackId, int32_t iSlice) { #ifdef GPUCA_HAVE_O2HEADERS const auto& trk = mIOPtrs->itsTracks[trackId]; - for (int k = 0; k < trk.getNClusters(); k++) { - int cid = mIOPtrs->itsTrackClusIdx[trk.getFirstClusterEntry() + k]; + for (int32_t k = 0; k < trk.getNClusters(); k++) { + int32_t cid = mIOPtrs->itsTrackClusIdx[trk.getFirstClusterEntry() + k]; mVertexBuffer[iSlice].emplace_back(mGlobalPosITS[cid].x, mGlobalPosITS[cid].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosITS[cid].z); mGlobalPosITS[cid].w = tITSATTACHED; } @@ -313,9 +312,9 @@ void GPUDisplay::DrawTrackITS(int trackId, int iSlice) GPUDisplay::vboList GPUDisplay::DrawFinalITS() { - const int iSlice = 0; + const int32_t iSlice = 0; size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int i = 0; i < mIOPtrs->nItsTracks; i++) { + for (uint32_t i = 0; i < mIOPtrs->nItsTracks; i++) { if (mITSStandaloneTracks[i]) { size_t startCountInner = mVertexBuffer[iSlice].size(); DrawTrackITS(i, iSlice); @@ -326,24 +325,24 @@ GPUDisplay::vboList GPUDisplay::DrawFinalITS() } template -void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, std::array, 2>& trackList, threadVertexBuffer& threadBuffer) +void GPUDisplay::DrawFinal(int32_t iSlice, int32_t /*iCol*/, GPUTPCGMPropagator* prop, std::array, 2>& trackList, threadVertexBuffer& threadBuffer) { auto& vBuf = threadBuffer.vBuf; auto& buffer = threadBuffer.buffer; - unsigned int nTracks = std::max(trackList[0].size(), trackList[1].size()); + uint32_t nTracks = std::max(trackList[0].size(), trackList[1].size()); if (mCfgH.clustersOnly) { nTracks = 0; } - for (unsigned int ii = 0; ii < nTracks; ii++) { - int i = 0; + for (uint32_t ii = 0; ii < nTracks; ii++) { + int32_t i = 0; const T* track = nullptr; - int lastCluster = -1; + int32_t lastCluster = -1; while (true) { if (ii >= trackList[0].size()) { break; } i = trackList[0][ii]; - int nClusters; + int32_t nClusters; if constexpr (std::is_same_v) { track = &mIOPtrs->mergedTracks[i]; nClusters = track->NClusters(); @@ -376,7 +375,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s // Print TOF part of track if constexpr (std::is_same_v) { if (mIOPtrs->tpcLinkTOF && mIOPtrs->tpcLinkTOF[i] != -1 && mIOPtrs->nTOFClusters) { - int cid = mIOPtrs->tpcLinkTOF[i]; + int32_t cid = mIOPtrs->tpcLinkTOF[i]; drawing = true; mVertexBuffer[iSlice].emplace_back(mGlobalPosTOF[cid].x, mGlobalPosTOF[cid].y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTOF[cid].z); mGlobalPosTOF[cid].w = tTOFATTACHED; @@ -385,8 +384,8 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s // Print TRD part of track auto tmpDoTRDTracklets = [&](const auto& trk) { - for (int k = 5; k >= 0; k--) { - int cid = trk.getTrackletIndex(k); + for (int32_t k = 5; k >= 0; k--) { + int32_t cid = trk.getTrackletIndex(k); if (cid < 0) { continue; } @@ -397,7 +396,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } }; if (std::is_same_v || (!mIOPtrs->tpcLinkTRD && mIOPtrs->trdTracksO2)) { - if (mChain && ((int)mConfig.showTPCTracksFromO2Format == (int)mChain->GetProcessingSettings().trdTrackModelO2) && mTRDTrackIds[i] != -1 && mIOPtrs->nTRDTracklets) { + if (mChain && ((int32_t)mConfig.showTPCTracksFromO2Format == (int32_t)mChain->GetProcessingSettings().trdTrackModelO2) && mTRDTrackIds[i] != -1 && mIOPtrs->nTRDTracklets) { if (mIOPtrs->trdTracksO2) { #ifdef GPUCA_HAVE_O2HEADERS tmpDoTRDTracklets(mIOPtrs->trdTracksO2[mTRDTrackIds[i]]); @@ -417,19 +416,19 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } // Print TPC part of track - for (int k = 0; k < nClusters; k++) { + for (int32_t k = 0; k < nClusters; k++) { if constexpr (std::is_same_v) { if (mCfgH.hideRejectedClusters && (mIOPtrs->mergedTrackHits[track->FirstClusterRef() + k].state & GPUTPCGMMergedTrackHit::flagReject)) { continue; } } - int cid; + int32_t cid; if constexpr (std::is_same_v) { cid = mIOPtrs->mergedTrackHits[track->FirstClusterRef() + k].num; } else { cid = &track->getCluster(mIOPtrs->outputClusRefsTPCO2, k, *mIOPtrs->clustersNative) - mIOPtrs->clustersNative->clustersLinear; } - int w = mGlobalPos[cid].w; + int32_t w = mGlobalPos[cid].w; if (drawing) { drawPointLinestrip(iSlice, cid, tFINALTRACK, SEPERATE_GLOBAL_TRACKS_LIMIT); } @@ -473,7 +472,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } // Propagate track paramters / plot MC tracks - for (int iMC = 0; iMC < 2; iMC++) { + for (int32_t iMC = 0; iMC < 2; iMC++) { if (iMC) { if (ii >= trackList[1].size()) { continue; @@ -489,7 +488,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } size_t startCountInner = mVertexBuffer[iSlice].size(); - for (int inFlyDirection = 0; inFlyDirection < 2; inFlyDirection++) { + for (int32_t inFlyDirection = 0; inFlyDirection < 2; inFlyDirection++) { GPUTPCGMPhysicalTrackModel trkParam; float ZOffset = 0; float x = 0; @@ -575,7 +574,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s } float alpha = alphaOrg; vecpod& useBuffer = iMC && inFlyDirection == 0 ? buffer : mVertexBuffer[iSlice]; - int nPoints = 0; + int32_t nPoints = 0; while (nPoints++ < 5000) { if ((inFlyDirection == 0 && x < 0) || (inFlyDirection && x * x + trkParam.Y() * trkParam.Y() > (iMC ? (450 * 450) : (300 * 300)))) { @@ -619,7 +618,7 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s if (inFlyDirection == 0) { if (iMC) { - for (int k = (int)buffer.size() - 1; k >= 0; k--) { + for (int32_t k = (int32_t)buffer.size() - 1; k >= 0; k--) { mVertexBuffer[iSlice].emplace_back(buffer[k]); } } else { @@ -635,12 +634,12 @@ void GPUDisplay::DrawFinal(int iSlice, int /*iCol*/, GPUTPCGMPropagator* prop, s GPUDisplay::vboList GPUDisplay::DrawGrid(const GPUTPCTracker& tracker) { - int iSlice = tracker.ISlice(); + int32_t iSlice = tracker.ISlice(); size_t startCount = mVertexBufferStart[iSlice].size(); size_t startCountInner = mVertexBuffer[iSlice].size(); - for (int i = 0; i < GPUCA_ROW_COUNT; i++) { + for (int32_t i = 0; i < GPUCA_ROW_COUNT; i++) { const GPUTPCRow& row = tracker.Data().Row(i); - for (int j = 0; j <= (signed)row.Grid().Ny(); j++) { + for (int32_t j = 0; j <= (signed)row.Grid().Ny(); j++) { float z1 = row.Grid().ZMin(); float z2 = row.Grid().ZMax(); float x = row.X() + mCfgH.xAdd; @@ -658,7 +657,7 @@ GPUDisplay::vboList GPUDisplay::DrawGrid(const GPUTPCTracker& tracker) mVertexBuffer[iSlice].emplace_back(xx1 * GL_SCALE_FACTOR, yy1 * GL_SCALE_FACTOR * mYFactor, zz1 * GL_SCALE_FACTOR); mVertexBuffer[iSlice].emplace_back(xx2 * GL_SCALE_FACTOR, yy2 * GL_SCALE_FACTOR * mYFactor, zz2 * GL_SCALE_FACTOR); } - for (int j = 0; j <= (signed)row.Grid().Nz(); j++) { + for (int32_t j = 0; j <= (signed)row.Grid().Nz(); j++) { float y1 = row.Grid().YMin(); float y2 = row.Grid().YMax(); float x = row.X() + mCfgH.xAdd; @@ -681,7 +680,7 @@ GPUDisplay::vboList GPUDisplay::DrawGrid(const GPUTPCTracker& tracker) return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice)); } -GPUDisplay::vboList GPUDisplay::DrawGridTRD(int sector) +GPUDisplay::vboList GPUDisplay::DrawGridTRD(int32_t sector) { // TODO: tilted pads ignored at the moment size_t startCount = mVertexBufferStart[sector].size(); @@ -689,20 +688,20 @@ GPUDisplay::vboList GPUDisplay::DrawGridTRD(int sector) #ifdef GPUCA_HAVE_O2HEADERS auto* geo = trdGeometry(); if (geo) { - int trdsector = NSLICES / 2 - 1 - sector; + int32_t trdsector = NSLICES / 2 - 1 - sector; float alpha = geo->GetAlpha() / 2.f + geo->GetAlpha() * trdsector; if (trdsector >= 9) { alpha -= 2 * CAMath::Pi(); } - for (int iLy = 0; iLy < GPUTRDTracker::EGPUTRDTracker::kNLayers; ++iLy) { - for (int iStack = 0; iStack < GPUTRDTracker::EGPUTRDTracker::kNStacks; ++iStack) { - int iDet = geo->GetDetector(iLy, iStack, trdsector); + for (int32_t iLy = 0; iLy < GPUTRDTracker::EGPUTRDTracker::kNLayers; ++iLy) { + for (int32_t iStack = 0; iStack < GPUTRDTracker::EGPUTRDTracker::kNStacks; ++iStack) { + int32_t iDet = geo->GetDetector(iLy, iStack, trdsector); auto matrix = geo->GetClusterMatrix(iDet); if (!matrix) { continue; } auto pp = geo->GetPadPlane(iDet); - for (int i = 0; i < pp->GetNrows(); ++i) { + for (int32_t i = 0; i < pp->GetNrows(); ++i) { float xyzLoc1[3]; float xyzLoc2[3]; float xyzGlb1[3]; @@ -722,7 +721,7 @@ GPUDisplay::vboList GPUDisplay::DrawGridTRD(int sector) mVertexBuffer[sector].emplace_back(xyzGlb1[0] * GL_SCALE_FACTOR, xyzGlb1[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb1[2] * GL_SCALE_FACTOR); mVertexBuffer[sector].emplace_back(xyzGlb2[0] * GL_SCALE_FACTOR, xyzGlb2[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb2[2] * GL_SCALE_FACTOR); } - for (int j = 0; j < pp->GetNcols(); ++j) { + for (int32_t j = 0; j < pp->GetNcols(); ++j) { float xyzLoc1[3]; float xyzLoc2[3]; float xyzGlb1[3]; @@ -752,38 +751,38 @@ GPUDisplay::vboList GPUDisplay::DrawGridTRD(int sector) size_t GPUDisplay::DrawGLScene_updateVertexList() { - for (int i = 0; i < NSLICES; i++) { + for (int32_t i = 0; i < NSLICES; i++) { mVertexBuffer[i].clear(); mVertexBufferStart[i].clear(); mVertexBufferCount[i].clear(); } - for (int i = 0; i < mCurrentClusters; i++) { + for (int32_t i = 0; i < mCurrentClusters; i++) { mGlobalPos[i].w = tCLUSTER; } - for (int i = 0; i < mCurrentSpacePointsTRD; i++) { + for (int32_t i = 0; i < mCurrentSpacePointsTRD; i++) { mGlobalPosTRD[i].w = tTRDCLUSTER; } - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = 0; i < N_POINTS_TYPE; i++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = 0; i < N_POINTS_TYPE; i++) { mGlDLPoints[iSlice][i].resize(mNCollissions); } - for (int i = 0; i < N_FINAL_TYPE; i++) { + for (int32_t i = 0; i < N_FINAL_TYPE; i++) { mGlDLFinal[iSlice].resize(mNCollissions); } } GPUCA_OPENMP(parallel num_threads(getNumThreads())) { #ifdef WITH_OPENMP - int numThread = omp_get_thread_num(); - int numThreads = omp_get_num_threads(); + int32_t numThread = omp_get_thread_num(); + int32_t numThreads = omp_get_num_threads(); #else - int numThread = 0, numThreads = 1; + int32_t numThread = 0, numThreads = 1; #endif if (mChain && (mChain->GetRecoSteps() & GPUDataTypes::RecoStep::TPCSliceTracking)) { GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { GPUTPCTracker& tracker = (GPUTPCTracker&)sliceTracker(iSlice); tracker.SetPointersDataLinks(tracker.LinkTmpMemory()); mGlDLLines[iSlice][tINITLINK] = DrawLinks(tracker, tINITLINK, true); @@ -792,7 +791,7 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() GPUCA_OPENMP(barrier) GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { const GPUTPCTracker& tracker = sliceTracker(iSlice); mGlDLLines[iSlice][tLINK] = DrawLinks(tracker, tLINK); @@ -807,25 +806,25 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() GPUCA_OPENMP(barrier) GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { const GPUTPCTracker& tracker = sliceTracker(iSlice); mGlDLLines[iSlice][tGLOBALTRACK] = DrawTracks(tracker, 1); } GPUCA_OPENMP(barrier) } mThreadTracks[numThread].resize(mNCollissions); - for (int i = 0; i < mNCollissions; i++) { - for (int j = 0; j < NSLICES; j++) { - for (int k = 0; k < 2; k++) { + for (int32_t i = 0; i < mNCollissions; i++) { + for (int32_t j = 0; j < NSLICES; j++) { + for (int32_t k = 0; k < 2; k++) { mThreadTracks[numThread][i][j][k].clear(); } } } if (mConfig.showTPCTracksFromO2Format) { #ifdef GPUCA_TPC_GEOMETRY_O2 - unsigned int col = 0; + uint32_t col = 0; GPUCA_OPENMP(for) - for (unsigned int i = 0; i < mIOPtrs->nOutputTracksTPCO2; i++) { + for (uint32_t i = 0; i < mIOPtrs->nOutputTracksTPCO2; i++) { uint8_t sector, row; if (mIOPtrs->clustersNative) { mIOPtrs->outputTracksTPCO2[i].getCluster(mIOPtrs->outputClusRefsTPCO2, 0, *mIOPtrs->clustersNative, sector, row); @@ -840,7 +839,7 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() #endif } else { GPUCA_OPENMP(for) - for (unsigned int i = 0; i < mIOPtrs->nMergedTracks; i++) { + for (uint32_t i = 0; i < mIOPtrs->nMergedTracks; i++) { const GPUTPCGMMergedTrack* track = &mIOPtrs->mergedTracks[i]; if (track->NClusters() == 0) { continue; @@ -848,8 +847,8 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() if (mCfgH.hideRejectedTracks && !track->OK()) { continue; } - int slice = mIOPtrs->mergedTrackHits[track->FirstClusterRef() + track->NClusters() - 1].slice; - unsigned int col = 0; + int32_t slice = mIOPtrs->mergedTrackHits[track->FirstClusterRef() + track->NClusters() - 1].slice; + uint32_t col = 0; if (mQA) { const auto& label = mQA->GetMCTrackLabel(i); #ifdef GPUCA_TPC_GEOMETRY_O2 @@ -863,9 +862,9 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() mThreadTracks[numThread][col][slice][0].emplace_back(i); } } - for (unsigned int col = 0; col < mIOPtrs->nMCInfosTPCCol; col++) { + for (uint32_t col = 0; col < mIOPtrs->nMCInfosTPCCol; col++) { GPUCA_OPENMP(for) - for (unsigned int i = mIOPtrs->mcInfosTPCCol[col].first; i < mIOPtrs->mcInfosTPCCol[col].first + mIOPtrs->mcInfosTPCCol[col].num; i++) { + for (uint32_t i = mIOPtrs->mcInfosTPCCol[col].first; i < mIOPtrs->mcInfosTPCCol[col].first + mIOPtrs->mcInfosTPCCol[col].num; i++) { const GPUTPCMCInfo& mc = mIOPtrs->mcInfosTPC[i]; if (mc.charge == 0.f) { continue; @@ -878,7 +877,7 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() if (alpha < 0) { alpha += 2 * CAMath::Pi(); } - int slice = alpha / (2 * CAMath::Pi()) * 18; + int32_t slice = alpha / (2 * CAMath::Pi()) * 18; if (mc.z < 0) { slice += 18; } @@ -893,10 +892,10 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() prop.SetPolynomialField(&mParam->polynomialField); GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mThreadBuffers[numThread].clear(); - for (int iSet = 0; iSet < numThreads; iSet++) { + for (int32_t iSet = 0; iSet < numThreads; iSet++) { #ifdef GPUCA_HAVE_O2HEADERS if (mConfig.showTPCTracksFromO2Format) { DrawFinal(iSlice, iCol, &prop, mThreadTracks[iSet][iCol][iSlice], mThreadBuffers[numThread]); @@ -907,9 +906,9 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() } } vboList* list = &mGlDLFinal[iSlice][iCol][0]; - for (int i = 0; i < N_FINAL_TYPE; i++) { + for (int32_t i = 0; i < N_FINAL_TYPE; i++) { size_t startCount = mVertexBufferStart[iSlice].size(); - for (unsigned int j = 0; j < mThreadBuffers[numThread].start[i].size(); j++) { + for (uint32_t j = 0; j < mThreadBuffers[numThread].start[i].size(); j++) { mVertexBufferStart[iSlice].emplace_back(mThreadBuffers[numThread].start[i][j]); mVertexBufferCount[iSlice].emplace_back(mThreadBuffers[numThread].count[i][j]); } @@ -920,9 +919,9 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() GPUCA_OPENMP(barrier) GPUCA_OPENMP(for) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = 0; i < N_POINTS_TYPE_TPC; i++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = 0; i < N_POINTS_TYPE_TPC; i++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mGlDLPoints[iSlice][i][iCol] = DrawClusters(iSlice, i, iCol); } } @@ -932,26 +931,26 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() mGlDLFinalITS = DrawFinalITS(); - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = N_POINTS_TYPE_TPC; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD; i++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = N_POINTS_TYPE_TPC; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD; i++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mGlDLPoints[iSlice][i][iCol] = DrawSpacePointsTRD(iSlice, i, iCol); } } } - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF; i++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF; i++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mGlDLPoints[iSlice][i][iCol] = DrawSpacePointsTOF(iSlice, i, iCol); } } break; // TODO: Only slice 0 filled for now } - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - for (int i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF + N_POINTS_TYPE_ITS; i++) { - for (int iCol = 0; iCol < mNCollissions; iCol++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF + N_POINTS_TYPE_ITS; i++) { + for (int32_t iCol = 0; iCol < mNCollissions; iCol++) { mGlDLPoints[iSlice][i][iCol] = DrawSpacePointsITS(iSlice, i, iCol); } } @@ -960,19 +959,19 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() mUpdateVertexLists = 0; size_t totalVertizes = 0; - for (int i = 0; i < NSLICES; i++) { + for (int32_t i = 0; i < NSLICES; i++) { totalVertizes += mVertexBuffer[i].size(); } if (totalVertizes > 0xFFFFFFFF) { - throw std::runtime_error("Display vertex count exceeds 32bit uint counter"); + throw std::runtime_error("Display vertex count exceeds 32bit uint32_t counter"); } size_t needMultiVBOSize = mBackend->needMultiVBO(); mUseMultiVBO = needMultiVBOSize && (totalVertizes * sizeof(mVertexBuffer[0][0]) >= needMultiVBOSize); if (!mUseMultiVBO) { size_t totalYet = mVertexBuffer[0].size(); mVertexBuffer[0].resize(totalVertizes); - for (int i = 1; i < GPUCA_NSLICES; i++) { - for (unsigned int j = 0; j < mVertexBufferStart[i].size(); j++) { + for (int32_t i = 1; i < GPUCA_NSLICES; i++) { + for (uint32_t j = 0; j < mVertexBufferStart[i].size(); j++) { mVertexBufferStart[i][j] += totalYet; } memcpy(&mVertexBuffer[0][totalYet], &mVertexBuffer[i][0], mVertexBuffer[i].size() * sizeof(mVertexBuffer[i][0])); @@ -981,7 +980,7 @@ size_t GPUDisplay::DrawGLScene_updateVertexList() } } mBackend->loadDataToGPU(totalVertizes); - for (int i = 0; i < (mUseMultiVBO ? GPUCA_NSLICES : 1); i++) { + for (int32_t i = 0; i < (mUseMultiVBO ? GPUCA_NSLICES : 1); i++) { mVertexBuffer[i].clear(); } return totalVertizes; diff --git a/GPU/GPUTracking/display/render/GPUDisplayImportEvent.cxx b/GPU/GPUTracking/display/render/GPUDisplayImportEvent.cxx index b1e6dfe21fb97..072119f7d528f 100644 --- a/GPU/GPUTracking/display/render/GPUDisplayImportEvent.cxx +++ b/GPU/GPUTracking/display/render/GPUDisplayImportEvent.cxx @@ -44,7 +44,7 @@ void GPUDisplay::DrawGLScene_updateEventData() mCurrentClusters = mIOPtrs->clustersNative->nClustersTotal; } else { mCurrentClusters = 0; - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { mCurrentClusters += mIOPtrs->nClusterData[iSlice]; } } @@ -77,18 +77,18 @@ void GPUDisplay::DrawGLScene_updateEventData() mGlobalPosTOF = mGlobalPosPtrTOF.get(); } - unsigned int nTpcMergedTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks; + uint32_t nTpcMergedTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks; if ((size_t)nTpcMergedTracks > mTRDTrackIds.size()) { mTRDTrackIds.resize(nTpcMergedTracks); } if (mIOPtrs->nItsTracks > mITSStandaloneTracks.size()) { mITSStandaloneTracks.resize(mIOPtrs->nItsTracks); } - for (unsigned int i = 0; i < nTpcMergedTracks; i++) { + for (uint32_t i = 0; i < nTpcMergedTracks; i++) { mTRDTrackIds[i] = -1; } auto tmpDoTRDTracklets = [&](auto* trdTracks) { - for (unsigned int i = 0; i < mIOPtrs->nTRDTracks; i++) { + for (uint32_t i = 0; i < mIOPtrs->nTRDTracks; i++) { if (trdTracks[i].getNtracklets()) { mTRDTrackIds[trdTracks[i].getRefGlobalTrackIdRaw()] = i; } @@ -104,7 +104,7 @@ void GPUDisplay::DrawGLScene_updateEventData() if (mIOPtrs->nItsTracks) { std::fill(mITSStandaloneTracks.begin(), mITSStandaloneTracks.end(), true); if (mIOPtrs->tpcLinkITS) { - for (unsigned int i = 0; i < nTpcMergedTracks; i++) { + for (uint32_t i = 0; i < nTpcMergedTracks; i++) { if (mIOPtrs->tpcLinkITS[i] != -1) { mITSStandaloneTracks[mIOPtrs->tpcLinkITS[i]] = false; } @@ -113,18 +113,18 @@ void GPUDisplay::DrawGLScene_updateEventData() } if (mCfgH.trackFilter) { - unsigned int nTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks; + uint32_t nTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks; mTrackFilter.resize(nTracks); std::fill(mTrackFilter.begin(), mTrackFilter.end(), true); if (buildTrackFilter()) { SetInfo("Error running track filter from %s", mConfig.filterMacros[mCfgH.trackFilter - 1].c_str()); } else { - unsigned int nFiltered = 0; - for (unsigned int i = 0; i < mTrackFilter.size(); i++) { + uint32_t nFiltered = 0; + for (uint32_t i = 0; i < mTrackFilter.size(); i++) { nFiltered += !mTrackFilter[i]; } if (mUpdateTrackFilter) { - SetInfo("Applied track filter %s - filtered %u / %u", mConfig.filterMacros[mCfgH.trackFilter - 1].c_str(), nFiltered, (unsigned int)mTrackFilter.size()); + SetInfo("Applied track filter %s - filtered %u / %u", mConfig.filterMacros[mCfgH.trackFilter - 1].c_str(), nFiltered, (uint32_t)mTrackFilter.size()); } } } @@ -132,19 +132,19 @@ void GPUDisplay::DrawGLScene_updateEventData() mMaxClusterZ = 0; GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ)) - for (int iSlice = 0; iSlice < NSLICES; iSlice++) { - int row = 0; - unsigned int nCls = mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] - : 0; - for (unsigned int i = 0; i < nCls; i++) { - int cid; + for (int32_t iSlice = 0; iSlice < NSLICES; iSlice++) { + int32_t row = 0; + uint32_t nCls = mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSlice] + : 0; + for (uint32_t i = 0; i < nCls; i++) { + int32_t cid; if (mParam->par.earlyTpcTransform) { const auto& cl = mIOPtrs->clusterData[iSlice][i]; cid = cl.id; row = cl.row; } else { cid = mIOPtrs->clustersNative->clusterOffset[iSlice][0] + i; - while (row < GPUCA_ROW_COUNT - 1 && mIOPtrs->clustersNative->clusterOffset[iSlice][row + 1] <= (unsigned int)cid) { + while (row < GPUCA_ROW_COUNT - 1 && mIOPtrs->clustersNative->clusterOffset[iSlice][row + 1] <= (uint32_t)cid) { row++; } } @@ -176,11 +176,11 @@ void GPUDisplay::DrawGLScene_updateEventData() } } - int trdTriggerRecord = -1; + int32_t trdTriggerRecord = -1; float trdZoffset = 0; GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ) firstprivate(trdTriggerRecord, trdZoffset)) - for (int i = 0; i < mCurrentSpacePointsTRD; i++) { - while (mParam->par.continuousTracking && trdTriggerRecord < (int)mIOPtrs->nTRDTriggerRecords - 1 && mIOPtrs->trdTrackletIdxFirst[trdTriggerRecord + 1] <= i) { + for (int32_t i = 0; i < mCurrentSpacePointsTRD; i++) { + while (mParam->par.continuousTracking && trdTriggerRecord < (int32_t)mIOPtrs->nTRDTriggerRecords - 1 && mIOPtrs->trdTrackletIdxFirst[trdTriggerRecord + 1] <= i) { trdTriggerRecord++; #ifdef GPUCA_HAVE_O2HEADERS float trdTime = mIOPtrs->trdTriggerTimes[trdTriggerRecord] * 1e3 / o2::constants::lhc::LHCBunchSpacingNS / o2::tpc::constants::LHCBCPERTIMEBIN; @@ -188,7 +188,7 @@ void GPUDisplay::DrawGLScene_updateEventData() #endif } const auto& sp = mIOPtrs->trdSpacePoints[i]; - int iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector()); + int32_t iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector()); float4* ptr = &mGlobalPosTRD[i]; mParam->Slice2Global(iSec, sp.getX() + mCfgH.xAdd, sp.getY(), sp.getZ(), &ptr->x, &ptr->y, &ptr->z); ptr->z += ptr->z > 0 ? trdZoffset : -trdZoffset; @@ -212,7 +212,7 @@ void GPUDisplay::DrawGLScene_updateEventData() } GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ)) - for (int i = 0; i < mCurrentClustersTOF; i++) { + for (int32_t i = 0; i < mCurrentClustersTOF; i++) { #ifdef GPUCA_HAVE_O2HEADERS float4* ptr = &mGlobalPosTOF[i]; mParam->Slice2Global(mIOPtrs->tofClusters[i].getSector(), mIOPtrs->tofClusters[i].getX() + mCfgH.xAdd, mIOPtrs->tofClusters[i].getY(), mIOPtrs->tofClusters[i].getZ(), &ptr->x, &ptr->y, &ptr->z); @@ -241,8 +241,8 @@ void GPUDisplay::DrawGLScene_updateEventData() itsROFhalfLen = alpParams.roFrameLengthInBC / (float)o2::tpc::constants::LHCBCPERTIMEBIN / 2; } #endif - int i = 0; - for (unsigned int j = 0; j < mIOPtrs->nItsClusterROF; j++) { + int32_t i = 0; + for (uint32_t j = 0; j < mIOPtrs->nItsClusterROF; j++) { float ZOffset = 0; if (mParam->par.continuousTracking) { o2::InteractionRecord startIR = o2::InteractionRecord(0, mIOPtrs->settingsTF && mIOPtrs->settingsTF->hasTfStartOrbit ? mIOPtrs->settingsTF->tfStartOrbit : 0); @@ -252,7 +252,7 @@ void GPUDisplay::DrawGLScene_updateEventData() if (i != mIOPtrs->itsClusterROF[j].getFirstEntry()) { throw std::runtime_error("Inconsistent ITS data, number of clusters does not match ROF content"); } - for (int k = 0; k < mIOPtrs->itsClusterROF[j].getNEntries(); k++) { + for (int32_t k = 0; k < mIOPtrs->itsClusterROF[j].getNEntries(); k++) { float4* ptr = &mGlobalPosITS[i]; const auto& cl = mIOPtrs->itsClusters[i]; auto* itsGeo = o2::its::GeometryTGeo::Instance(); diff --git a/GPU/GPUTracking/display/shaders/GPUDisplayShaders.h b/GPU/GPUTracking/display/shaders/GPUDisplayShaders.h index 9f365d59ecc5b..ff22006ceb37e 100644 --- a/GPU/GPUTracking/display/shaders/GPUDisplayShaders.h +++ b/GPU/GPUTracking/display/shaders/GPUDisplayShaders.h @@ -126,7 +126,7 @@ void main() static constexpr const char* fieldModelShaderCode = R"( layout(std430, binding = 0) restrict readonly buffer field_config_ssbo { - uint StepCount; + uint32_t StepCount; float StepSize; } field_config; @@ -135,19 +135,19 @@ layout(std430, binding = 1) restrict readonly buffer sol_segment_ssbo { float MaxZ; float MultiplicativeFactor; - int ZSegments; + int32_t ZSegments; float SegZSol[SOL_Z_SEGS]; - int BegSegPSol[SOL_Z_SEGS]; - int NSegPSol[SOL_Z_SEGS]; + int32_t BegSegPSol[SOL_Z_SEGS]; + int32_t NSegPSol[SOL_Z_SEGS]; float SegPSol[SOL_P_SEGS]; - int BegSegRSol[SOL_P_SEGS]; - int NSegRSol[SOL_P_SEGS]; + int32_t BegSegRSol[SOL_P_SEGS]; + int32_t NSegRSol[SOL_P_SEGS]; float SegRSol[SOL_R_SEGS]; - int SegIDSol[SOL_R_SEGS]; + int32_t SegIDSol[SOL_R_SEGS]; } sol_segment; layout(std430, binding = 2) restrict readonly buffer dip_segment_ssbo { @@ -155,19 +155,19 @@ layout(std430, binding = 2) restrict readonly buffer dip_segment_ssbo { float MaxZ; float MultiplicativeFactor; - int ZSegments; + int32_t ZSegments; float SegZDip[DIP_Z_SEGS]; - int BegSegYDip[DIP_Z_SEGS]; - int NSegYDip[DIP_Z_SEGS]; + int32_t BegSegYDip[DIP_Z_SEGS]; + int32_t NSegYDip[DIP_Z_SEGS]; float SegYDip[DIP_Y_SEGS]; - int BegSegXDip[DIP_Y_SEGS]; - int NSegXDip[DIP_Y_SEGS]; + int32_t BegSegXDip[DIP_Y_SEGS]; + int32_t NSegXDip[DIP_Y_SEGS]; float SegXDip[DIP_X_SEGS]; - int SegIDDip[DIP_X_SEGS]; + int32_t SegIDDip[DIP_X_SEGS]; } dip_segment; layout(std430, binding = 3) restrict readonly buffer sol_params_ssbo { @@ -175,15 +175,15 @@ layout(std430, binding = 3) restrict readonly buffer sol_params_ssbo { float BScales[DIMENSIONS*SOL_PARAMS]; float BMin[DIMENSIONS*SOL_PARAMS]; float BMax[DIMENSIONS*SOL_PARAMS]; - int NRows[DIMENSIONS*SOL_PARAMS]; - int ColsAtRowOffset[DIMENSIONS*SOL_PARAMS]; - int CofsAtRowOffset[DIMENSIONS*SOL_PARAMS]; + int32_t NRows[DIMENSIONS*SOL_PARAMS]; + int32_t ColsAtRowOffset[DIMENSIONS*SOL_PARAMS]; + int32_t CofsAtRowOffset[DIMENSIONS*SOL_PARAMS]; - int NColsAtRow[SOL_ROWS]; - int CofsAtColOffset[SOL_ROWS]; + int32_t NColsAtRow[SOL_ROWS]; + int32_t CofsAtColOffset[SOL_ROWS]; - int NCofsAtCol[SOL_COLUMNS]; - int AtColCoefOffset[SOL_COLUMNS]; + int32_t NCofsAtCol[SOL_COLUMNS]; + int32_t AtColCoefOffset[SOL_COLUMNS]; float Coeffs[SOL_COEFFS]; } sol_params; @@ -193,15 +193,15 @@ layout(std430, binding = 4) restrict readonly buffer dip_params_ssbo { float BScales[DIMENSIONS*DIP_PARAMS]; float BMin[DIMENSIONS*DIP_PARAMS]; float BMax[DIMENSIONS*DIP_PARAMS]; - int NRows[DIMENSIONS*DIP_PARAMS]; - int ColsAtRowOffset[DIMENSIONS*DIP_PARAMS]; - int CofsAtRowOffset[DIMENSIONS*DIP_PARAMS]; + int32_t NRows[DIMENSIONS*DIP_PARAMS]; + int32_t ColsAtRowOffset[DIMENSIONS*DIP_PARAMS]; + int32_t CofsAtRowOffset[DIMENSIONS*DIP_PARAMS]; - int NColsAtRow[DIP_ROWS]; - int CofsAtColOffset[DIP_ROWS]; + int32_t NColsAtRow[DIP_ROWS]; + int32_t CofsAtColOffset[DIP_ROWS]; - int NCofsAtCol[DIP_COLUMNS]; - int AtColCoefOffset[DIP_COLUMNS]; + int32_t NCofsAtCol[DIP_COLUMNS]; + int32_t AtColCoefOffset[DIP_COLUMNS]; float Coeffs[DIP_COEFFS]; } dip_params; @@ -213,18 +213,18 @@ vec3 CarttoCyl(vec3 pos) { return vec3(length(pos.xy), atan(pos.y, pos.x), pos.z); } -int findSolSegment(vec3 pos) { - int rid,pid,zid; +int32_t findSolSegment(vec3 pos) { + int32_t rid,pid,zid; for(zid=0; zid < sol_segment.ZSegments; zid++) if(pos.z=0;i--) { + for (int32_t i=ncf;i>=0;i--) { b.zy = b.yx; b.x = arr[i]; b.x = dot(t1, b); @@ -287,7 +287,7 @@ float cheb1DArray(float x, float arr[MAX_CHEB_ORDER], int ncf) { return dot(t, b); } -float cheb1DParamsSol(float x, int coeff_offset, int ncf) { +float cheb1DParamsSol(float x, int32_t coeff_offset, int32_t ncf) { if(ncf <= 0) return 0.0f; const float x2 = 2*x; @@ -297,7 +297,7 @@ float cheb1DParamsSol(float x, int coeff_offset, int ncf) { const vec3 t1 = vec3(1, x2, -1); - for (int i=ncf;i>=0;i--) { + for (int32_t i=ncf;i>=0;i--) { b.zy = b.yx; b.x = sol_params.Coeffs[coeff_offset + i]; b.x = dot(t1, b); @@ -307,7 +307,7 @@ float cheb1DParamsSol(float x, int coeff_offset, int ncf) { return dot(t, b); } -float cheb1DParamsDip(float x, int coeff_offset, int ncf) { +float cheb1DParamsDip(float x, int32_t coeff_offset, int32_t ncf) { if(ncf <= 0) return 0.0f; const float x2 = 2*x; @@ -317,7 +317,7 @@ float cheb1DParamsDip(float x, int coeff_offset, int ncf) { const vec3 t1 = vec3(1, x2, -1); - for (int i=ncf;i>=0;i--) { + for (int32_t i=ncf;i>=0;i--) { b.zy = b.yx; b.x = dip_params.Coeffs[coeff_offset + i]; b.x = dot(t1, b); @@ -331,8 +331,8 @@ bool IsBetween(vec3 sMin, vec3 val, vec3 sMax) { return all(lessThanEqual(sMin, val)) && all(lessThanEqual(val, sMax)); } -bool IsInsideSol(int segID, vec3 rphiz) { - const int index = DIMENSIONS*segID; +bool IsInsideSol(int32_t segID, vec3 rphiz) { + const int32_t index = DIMENSIONS*segID; const vec3 seg_min = vec3(sol_params.BMin[index+0], sol_params.BMin[index+1], sol_params.BMin[index+2]); const vec3 seg_max = vec3(sol_params.BMax[index+0], sol_params.BMax[index+1], sol_params.BMax[index+2]); @@ -340,8 +340,8 @@ bool IsInsideSol(int segID, vec3 rphiz) { return IsBetween(seg_min, rphiz, seg_max); } -bool IsInsideDip(int segID, vec3 pos) { - const int index = DIMENSIONS*segID; +bool IsInsideDip(int32_t segID, vec3 pos) { + const int32_t index = DIMENSIONS*segID; const vec3 seg_min = vec3(dip_params.BMin[index+0], dip_params.BMin[index+1], dip_params.BMin[index+2]); const vec3 seg_max = vec3(dip_params.BMax[index+0], dip_params.BMax[index+1], dip_params.BMax[index+2]); @@ -349,21 +349,21 @@ bool IsInsideDip(int segID, vec3 pos) { return IsBetween(seg_min, pos, seg_max); } -float Eval3DSol(int segID, int dim, vec3 internal) { - const int index = DIMENSIONS*segID; - const int n_rows = sol_params.NRows[index+dim]; - const int cols_at_row_offset = sol_params.ColsAtRowOffset[index+dim]; - const int coeffs_at_row_offset = sol_params.CofsAtRowOffset[index+dim]; +float Eval3DSol(int32_t segID, int32_t dim, vec3 internal) { + const int32_t index = DIMENSIONS*segID; + const int32_t n_rows = sol_params.NRows[index+dim]; + const int32_t cols_at_row_offset = sol_params.ColsAtRowOffset[index+dim]; + const int32_t coeffs_at_row_offset = sol_params.CofsAtRowOffset[index+dim]; - for(int row = 0; row < n_rows; row++) { - const int n_cols = sol_params.NColsAtRow[cols_at_row_offset+row]; - const int coeff_at_col_offset = sol_params.CofsAtColOffset[cols_at_row_offset+row]; + for(int32_t row = 0; row < n_rows; row++) { + const int32_t n_cols = sol_params.NColsAtRow[cols_at_row_offset+row]; + const int32_t coeff_at_col_offset = sol_params.CofsAtColOffset[cols_at_row_offset+row]; - for(int col = 0; col < n_cols; col++) { - const int n_coeffs = sol_params.NCofsAtCol[coeff_at_col_offset+col]; - const int per_col_coeff_offset = sol_params.AtColCoefOffset[coeff_at_col_offset+col]; + for(int32_t col = 0; col < n_cols; col++) { + const int32_t n_coeffs = sol_params.NCofsAtCol[coeff_at_col_offset+col]; + const int32_t per_col_coeff_offset = sol_params.AtColCoefOffset[coeff_at_col_offset+col]; - const int coeffs_offset = coeffs_at_row_offset + per_col_coeff_offset; + const int32_t coeffs_offset = coeffs_at_row_offset + per_col_coeff_offset; tmpCfs1[col] = cheb1DParamsSol(internal.z, coeffs_offset,n_coeffs); } @@ -373,26 +373,26 @@ float Eval3DSol(int segID, int dim, vec3 internal) { return cheb1DArray(internal.x, tmpCfs0, n_rows); } -vec3 EvalSol(int segID, vec3 rphiz) { +vec3 EvalSol(int32_t segID, vec3 rphiz) { const vec3 internal = mapToInternalSol(segID, rphiz); return vec3(Eval3DSol(segID, 0, internal), Eval3DSol(segID, 1, internal), Eval3DSol(segID, 2, internal)); } -float Eval3DDip(int segID, int dim, vec3 internal) { - const int index = DIMENSIONS*segID; - const int n_rows = dip_params.NRows[index+dim]; - const int cols_at_row_offset = dip_params.ColsAtRowOffset[index+dim]; - const int coeffs_at_row_offset = dip_params.CofsAtRowOffset[index+dim]; +float Eval3DDip(int32_t segID, int32_t dim, vec3 internal) { + const int32_t index = DIMENSIONS*segID; + const int32_t n_rows = dip_params.NRows[index+dim]; + const int32_t cols_at_row_offset = dip_params.ColsAtRowOffset[index+dim]; + const int32_t coeffs_at_row_offset = dip_params.CofsAtRowOffset[index+dim]; - for(int row = 0; row < n_rows; row++) { - const int n_cols = dip_params.NColsAtRow[cols_at_row_offset+row]; - const int coeff_at_col_offset = dip_params.CofsAtColOffset[cols_at_row_offset+row]; + for(int32_t row = 0; row < n_rows; row++) { + const int32_t n_cols = dip_params.NColsAtRow[cols_at_row_offset+row]; + const int32_t coeff_at_col_offset = dip_params.CofsAtColOffset[cols_at_row_offset+row]; - for(int col = 0; col < n_cols; col++) { - const int n_coeffs = dip_params.NCofsAtCol[coeff_at_col_offset+col]; - const int per_col_coeff_offset = dip_params.AtColCoefOffset[coeff_at_col_offset+col]; + for(int32_t col = 0; col < n_cols; col++) { + const int32_t n_coeffs = dip_params.NCofsAtCol[coeff_at_col_offset+col]; + const int32_t per_col_coeff_offset = dip_params.AtColCoefOffset[coeff_at_col_offset+col]; - const int coeffs_offset = coeffs_at_row_offset + per_col_coeff_offset; + const int32_t coeffs_offset = coeffs_at_row_offset + per_col_coeff_offset; tmpCfs1[col] = cheb1DParamsDip(internal.z, coeffs_offset, n_coeffs); } @@ -402,7 +402,7 @@ float Eval3DDip(int segID, int dim, vec3 internal) { return cheb1DArray(internal.x, tmpCfs0, n_rows); } -vec3 EvalDip(int segID, vec3 pos) { +vec3 EvalDip(int32_t segID, vec3 pos) { const vec3 internal = mapToInternalDip(segID, pos); return vec3(Eval3DDip(segID, 0, internal), Eval3DDip(segID, 1, internal), Eval3DDip(segID, 2, internal)); } @@ -421,14 +421,14 @@ vec3 MachineField(vec3 pos) { vec3 SolDipField(vec3 pos) { if(pos.z > sol_segment.MinZ) { const vec3 rphiz = CarttoCyl(pos); - const int segID = findSolSegment(rphiz); + const int32_t segID = findSolSegment(rphiz); if(segID >=0 && IsInsideSol(segID, rphiz)) { const vec3 brphiz = EvalSol(segID, rphiz); return CyltoCartCylB(rphiz, brphiz) * sol_segment.MultiplicativeFactor; } } - const int segID = findDipSegment(pos); + const int32_t segID = findDipSegment(pos); if(segID >= 0 && IsInsideDip(segID, pos)) { return EvalDip(segID, pos) * dip_segment.MultiplicativeFactor; } @@ -458,7 +458,7 @@ const float positionScale = 100.0f; void main() { vec3 position = gl_in[0].gl_Position.xyz; - for(uint i = 0; i < field_config.StepCount; ++i) { + for(uint32_t i = 0; i < field_config.StepCount; ++i) { gl_Position = um.ModelViewProj * vec4(position/positionScale, 1.0f); EmitVertex(); const vec3 b_vec = Field(position); From ddb07fe3c0060586ece1293405b0399c612f6f0b Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Tue, 15 Oct 2024 11:47:56 +0200 Subject: [PATCH 19/68] GPU --- GPU/GPUTracking/display/GPUDisplayInterface.h | 1 + 1 file changed, 1 insertion(+) diff --git a/GPU/GPUTracking/display/GPUDisplayInterface.h b/GPU/GPUTracking/display/GPUDisplayInterface.h index 49cdb7e9e2038..0e7c00c1bb7b0 100644 --- a/GPU/GPUTracking/display/GPUDisplayInterface.h +++ b/GPU/GPUTracking/display/GPUDisplayInterface.h @@ -15,6 +15,7 @@ #ifndef GPUDISPLAYINTERFACE_H #define GPUDISPLAYINTERFACE_H +#include #include "GPUSettings.h" namespace GPUCA_NAMESPACE From 17cab7baacfdd8d063465d315058c16b9a407143 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 6 Nov 2024 16:42:34 +0100 Subject: [PATCH 20/68] GPU --- GPU/GPUTracking/display/GPUDisplayInterface.h:36 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 GPU/GPUTracking/display/GPUDisplayInterface.h:36 diff --git a/GPU/GPUTracking/display/GPUDisplayInterface.h:36 b/GPU/GPUTracking/display/GPUDisplayInterface.h:36 new file mode 100644 index 0000000000000..e69de29bb2d1d From 6cbbc4ca2c6186aa1a1dd5c9459ce59bce6bd03b Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 6 Nov 2024 16:49:43 +0100 Subject: [PATCH 21/68] fix conflicts --- .../ALICE3/FVD/simulation/src/Detector.cxx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 6ba00e49696f0..458ea905a4b8e 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -383,4 +383,28 @@ int Detector::getChannelId(TVector3 vec) return ir * mNumberOfSectors + isect + noff; } +int Detector::getChannelId(TVector3 vec) +{ + float phi = vec.Phi(); + if (phi < 0) phi += TMath::TwoPi(); + float r = vec.Perp(); + float z = vec.Z(); + + int isect = int(phi/(TMath::Pi()/4)); + + std::vectorrd = z > 0 ? mRingRadiiA : mRingRadiiC; + int noff = z > 0 ? 0 : mNumberOfRingsA*mNumberOfSectors; + + int ir = 0; + + for (int i = 1; i < rd.size(); i++) { + if (r < rd[i]) + break; + else + ir ++; + } + + return ir * mNumberOfSectors + isect + noff; +} + ClassImp(o2::fvd::Detector); From ca61de35f2ee9d1706fe56ffb9abb3c80adf0d1f Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 6 Nov 2024 16:54:46 +0100 Subject: [PATCH 22/68] resolve conflicts --- .../FVD/base/include/FVDBase/FVDBaseParam.h | 4 ++ .../ALICE3/FVD/simulation/src/Detector.cxx | 39 ++++++++++++------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 584eed383e31f..d766b785ebe48 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -21,7 +21,11 @@ namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { +<<<<<<< HEAD int nsect = 8; +======= + static constexpr int nsect = 8; +>>>>>>> f77b1c2c94 (More flexible confgurable parameters) std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; std::vector ringsC = {3.5, 14.75, 26.0, 37.25, 48.5, 59.75, 71.}; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 458ea905a4b8e..18f09e358fa82 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -57,7 +57,11 @@ Detector::Detector(bool active) auto& baseParam = FVDBaseParam::Instance(); mNumberOfSectors = baseParam.nsect; +<<<<<<< HEAD mDzScint = baseParam.dzscint/2; +======= + mDzScint = baseParam.dzscint; +>>>>>>> f77b1c2c94 (More flexible confgurable parameters) mRingRadiiA = baseParam.ringsA; mRingRadiiC = baseParam.ringsC; @@ -346,6 +350,10 @@ void Detector::defineSensitiveVolumes() TGeoVolume* v; TString volumeName; +<<<<<<< HEAD +======= + +>>>>>>> f77b1c2c94 (More flexible confgurable parameters) int nCellA = mNumberOfRingsA * mNumberOfSectors; int nCellC = mNumberOfRingsC * mNumberOfSectors; @@ -385,26 +393,27 @@ int Detector::getChannelId(TVector3 vec) int Detector::getChannelId(TVector3 vec) { - float phi = vec.Phi(); - if (phi < 0) phi += TMath::TwoPi(); - float r = vec.Perp(); - float z = vec.Z(); + float phi = vec.Phi(); + if (phi < 0) + phi += TMath::TwoPi(); + float r = vec.Perp(); + float z = vec.Z(); - int isect = int(phi/(TMath::Pi()/4)); + int isect = int(phi / (TMath::Pi() / 4)); - std::vectorrd = z > 0 ? mRingRadiiA : mRingRadiiC; - int noff = z > 0 ? 0 : mNumberOfRingsA*mNumberOfSectors; + std::vector rd = z > 0 ? mRingRadiiA : mRingRadiiC; + int noff = z > 0 ? 0 : mNumberOfRingsA * mNumberOfSectors; - int ir = 0; + int ir = 0; - for (int i = 1; i < rd.size(); i++) { - if (r < rd[i]) - break; - else - ir ++; - } + for (int i = 1; i < rd.size(); i++) { + if (r < rd[i]) + break; + else + ir++; + } - return ir * mNumberOfSectors + isect + noff; + return ir * mNumberOfSectors + isect + noff; } ClassImp(o2::fvd::Detector); From 2955b510c7c612ec1d99a20f0404bb3efec8f09e Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 27 Nov 2024 13:51:29 +0100 Subject: [PATCH 23/68] head --- .../FVD/base/include/FVDBase/FVDBaseParam.h | 4 --- .../ALICE3/FVD/simulation/src/Detector.cxx | 32 ------------------- 2 files changed, 36 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index d766b785ebe48..584eed383e31f 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -21,11 +21,7 @@ namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { -<<<<<<< HEAD int nsect = 8; -======= - static constexpr int nsect = 8; ->>>>>>> f77b1c2c94 (More flexible confgurable parameters) std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; std::vector ringsC = {3.5, 14.75, 26.0, 37.25, 48.5, 59.75, 71.}; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 18f09e358fa82..efe045fcce591 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -57,11 +57,7 @@ Detector::Detector(bool active) auto& baseParam = FVDBaseParam::Instance(); mNumberOfSectors = baseParam.nsect; -<<<<<<< HEAD mDzScint = baseParam.dzscint/2; -======= - mDzScint = baseParam.dzscint; ->>>>>>> f77b1c2c94 (More flexible confgurable parameters) mRingRadiiA = baseParam.ringsA; mRingRadiiC = baseParam.ringsC; @@ -350,10 +346,7 @@ void Detector::defineSensitiveVolumes() TGeoVolume* v; TString volumeName; -<<<<<<< HEAD -======= ->>>>>>> f77b1c2c94 (More flexible confgurable parameters) int nCellA = mNumberOfRingsA * mNumberOfSectors; int nCellC = mNumberOfRingsC * mNumberOfSectors; @@ -391,29 +384,4 @@ int Detector::getChannelId(TVector3 vec) return ir * mNumberOfSectors + isect + noff; } -int Detector::getChannelId(TVector3 vec) -{ - float phi = vec.Phi(); - if (phi < 0) - phi += TMath::TwoPi(); - float r = vec.Perp(); - float z = vec.Z(); - - int isect = int(phi / (TMath::Pi() / 4)); - - std::vector rd = z > 0 ? mRingRadiiA : mRingRadiiC; - int noff = z > 0 ? 0 : mNumberOfRingsA * mNumberOfSectors; - - int ir = 0; - - for (int i = 1; i < rd.size(); i++) { - if (r < rd[i]) - break; - else - ir++; - } - - return ir * mNumberOfSectors + isect + noff; -} - ClassImp(o2::fvd::Detector); From 74d91387afe4cacefe23a1a57788c77d1c525d92 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Tue, 3 Dec 2024 17:49:58 +0100 Subject: [PATCH 24/68] added Constants.h to store constants --- Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt | 3 ++- .../Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h | 2 +- Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt index 52ace04ba1136..c2e0193fca8c8 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt @@ -16,5 +16,6 @@ o2_add_library(FVDBase o2_target_root_dictionary(FVDBase HEADERS include/FVDBase/GeometryTGeo.h - include/FVDBase/FVDBaseParam.h) + include/FVDBase/Constants.h + include/FVDBase/FVDBaseParam.h) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 584eed383e31f..c6c61204344bf 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -21,7 +21,7 @@ namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { - int nsect = 8; +// int nsect = 8; std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; std::vector ringsC = {3.5, 14.75, 26.0, 37.25, 48.5, 59.75, 71.}; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index efe045fcce591..ad12a20d61d97 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -16,6 +16,7 @@ #include "FVDSimulation/Detector.h" #include "FVDBase/GeometryTGeo.h" #include "FVDBase/FVDBaseParam.h" +#include "FVDBase/Constants.h" #include "DetectorsBase/Stack.h" #include "SimulationDataFormat/TrackReference.h" @@ -55,7 +56,6 @@ Detector::Detector(bool active) mTrackData() { auto& baseParam = FVDBaseParam::Instance(); - mNumberOfSectors = baseParam.nsect; mDzScint = baseParam.dzscint/2; @@ -67,6 +67,8 @@ Detector::Detector(bool active) mZmodA = baseParam.zmodA; mZmodC = baseParam.zmodC; + + mNumberOfSectors = Constants::nsect; } Detector::Detector(const Detector& rhs) From 2ead4bedd9d2762f5900ce234264b14bf11b1010 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Fri, 13 Dec 2024 16:18:22 +0100 Subject: [PATCH 25/68] Adding Constants.h and correcting formatting issues --- .../Upgrades/ALICE3/FVD/base/CMakeLists.txt | 12 +++---- .../FVD/base/include/FVDBase/Constants.h | 31 +++++++++++++++++++ .../FVD/base/include/FVDBase/FVDBaseParam.h | 2 -- .../ALICE3/FVD/simulation/src/Detector.cxx | 1 - run/CMakeLists.txt | 4 +-- 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h diff --git a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt index c2e0193fca8c8..6846d4cbe62eb 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt @@ -10,12 +10,12 @@ # or submit itself to any jurisdiction. o2_add_library(FVDBase - SOURCES src/GeometryTGeo.cxx - src/FVDBaseParam.cxx - PUBLIC_LINK_LIBRARIES O2::DetectorsBase) + SOURCES src/GeometryTGeo.cxx + src/FVDBaseParam.cxx + PUBLIC_LINK_LIBRARIES O2::DetectorsBase) o2_target_root_dictionary(FVDBase - HEADERS include/FVDBase/GeometryTGeo.h - include/FVDBase/Constants.h - include/FVDBase/FVDBaseParam.h) + HEADERS include/FVDBase/GeometryTGeo.h + include/FVDBase/Constants.h + include/FVDBase/FVDBaseParam.h) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h new file mode 100644 index 0000000000000..f48768888dfdb --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h @@ -0,0 +1,31 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file Constants.h +/// \brief General constants in FV0 +/// +/// \author Maciej Slupecki, University of Jyvaskyla, Finland + +#ifndef ALICEO2_FVD_CONSTANTS_ +#define ALICEO2_FVD_CONSTANTS_ + +namespace o2 +{ +namespace fvd +{ + +struct Constants { + static constexpr int nsect = 8; +}; + +} // namespace fvd +} // namespace o2 +#endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index c6c61204344bf..464bb2e424fdc 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -21,8 +21,6 @@ namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { -// int nsect = 8; - std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; std::vector ringsC = {3.5, 14.75, 26.0, 37.25, 48.5, 59.75, 71.}; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index ad12a20d61d97..6f2b49d773fa0 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -358,7 +358,6 @@ void Detector::defineSensitiveVolumes() LOG(info) << "Adding FVD Sensitive Volume => " << v->GetName(); AddSensitiveVolume(v); } - } int Detector::getChannelId(TVector3 vec) diff --git a/run/CMakeLists.txt b/run/CMakeLists.txt index 399d38e35ea96..1b81d5c15b4d0 100644 --- a/run/CMakeLists.txt +++ b/run/CMakeLists.txt @@ -46,7 +46,7 @@ target_link_libraries(allsim $<$:O2::IOTOFSimulation> $<$:O2::RICHSimulation> $<$:O2::ECalSimulation> - $<$:O2::FVDSimulation> + $<$:O2::FVDSimulation> $<$:O2::MI3Simulation> O2::Generators) @@ -339,4 +339,4 @@ install(FILES o2-sim-client.py PERMISSIONS GROUP_READ GROUP_EXECUTE OWNER_EXECUT install(DIRECTORY SimExamples/ DESTINATION examples PATTERN * - PERMISSIONS GROUP_READ GROUP_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ WORLD_EXECUTE WORLD_READ) \ No newline at end of file + PERMISSIONS GROUP_READ GROUP_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ WORLD_EXECUTE WORLD_READ) From 0b61e19aaa346ce2db21c53740bd494a2f91303b Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Fri, 13 Dec 2024 16:22:07 +0100 Subject: [PATCH 26/68] Adding Constants.h and correcting formatting issues --- Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt index 6846d4cbe62eb..3f40518714c8e 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt @@ -11,11 +11,10 @@ o2_add_library(FVDBase SOURCES src/GeometryTGeo.cxx - src/FVDBaseParam.cxx - PUBLIC_LINK_LIBRARIES O2::DetectorsBase) + src/FVDBaseParam.cxx + PUBLIC_LINK_LIBRARIES O2::DetectorsBase) o2_target_root_dictionary(FVDBase - HEADERS include/FVDBase/GeometryTGeo.h - include/FVDBase/Constants.h - include/FVDBase/FVDBaseParam.h) - + HEADERS include/FVDBase/GeometryTGeo.h + include/FVDBase/Constants.h + include/FVDBase/FVDBaseParam.h) From 0ab8a28edf6aeacbeb7ff995dc84e036ff14dd57 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Fri, 13 Dec 2024 16:24:12 +0100 Subject: [PATCH 27/68] Adding Constants.h and correcting formatting issues --- Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt index 3f40518714c8e..0b8f8041cb3d7 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt @@ -10,7 +10,7 @@ # or submit itself to any jurisdiction. o2_add_library(FVDBase - SOURCES src/GeometryTGeo.cxx + SOURCES src/GeometryTGeo.cxx src/FVDBaseParam.cxx PUBLIC_LINK_LIBRARIES O2::DetectorsBase) From 69209115ddd3364fd17d10f749d4b5cd25c8c3d7 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Fri, 13 Dec 2024 16:29:14 +0100 Subject: [PATCH 28/68] Adding Constants.h and correcting formatting issues --- Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 6f2b49d773fa0..1e2111a33feaf 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -280,8 +280,8 @@ void Detector::buildModules() TGeoVolumeAssembly* vFVDA = buildModuleA(); TGeoVolumeAssembly* vFVDC = buildModuleC(); - vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., mZmodA/* - mDzScint/2.*/)); - vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., mZmodC/* + mDzScint/2.*/)); + vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., mZmodA /* - mDzScint/2.*/)); + vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., mZmodC /* + mDzScint/2.*/)); } TGeoVolumeAssembly* Detector::buildModuleA() From df6da1c5057ca6f417af4eb562164fd194c66b56 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Fri, 13 Dec 2024 16:31:13 +0100 Subject: [PATCH 29/68] Adding Constants.h and correcting formatting issues --- Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 1e2111a33feaf..af90cde4ad212 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -57,7 +57,7 @@ Detector::Detector(bool active) { auto& baseParam = FVDBaseParam::Instance(); - mDzScint = baseParam.dzscint/2; + mDzScint = baseParam.dzscint / 2; mRingRadiiA = baseParam.ringsA; mRingRadiiC = baseParam.ringsC; From 76eaa665ca811e44e0b8ccf59f4b12cfe7098054 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Fri, 13 Dec 2024 16:39:11 +0100 Subject: [PATCH 30/68] Adding Constants.h and correcting formatting issues --- Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index af90cde4ad212..d49a84f7f089e 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -122,7 +122,7 @@ bool Detector::ProcessHits(FairVolume* vol) auto stack = (o2::data::Stack*)fMC->GetStack(); - //int cellId = vol->getVolumeId(); + // int cellId = vol->getVolumeId(); // Check track status to define when hit is started and when it is stopped bool startHit = false, stopHit = false; From 327a0950cd459011db369f360503cff9faf0101f Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sat, 21 Dec 2024 18:08:12 +0100 Subject: [PATCH 31/68] created new namespace --- .../FVD/base/include/FVDBase/Constants.h | 3 +- .../FVD/base/include/FVDBase/FVDBaseParam.h | 5 +- .../ALICE3/FVD/base/src/FVDBaseLinkDef.h | 1 + .../include/FVDSimulation/Detector.h | 6 +- .../ALICE3/FVD/simulation/src/Detector.cxx | 61 ++++++++++--------- 5 files changed, 41 insertions(+), 35 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h index f48768888dfdb..82a40c65a90f8 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h @@ -21,9 +21,10 @@ namespace o2 { namespace fvd { - struct Constants { static constexpr int nsect = 8; + static constexpr int nringsA = 5; + static constexpr int nringsC = 6; }; } // namespace fvd diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h index 464bb2e424fdc..d41a3d93b6875 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h @@ -13,6 +13,7 @@ #define ALICEO2_FVD_FVDBASEPARAM_ #include "FVDBase/GeometryTGeo.h" +#include "FVDBase/Constants.h" #include "CommonUtils/ConfigurableParamHelper.h" namespace o2 @@ -21,8 +22,8 @@ namespace fvd { struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { - std::vector ringsA = {3., 14.8, 26.6, 38.4, 50.2, 62.}; - std::vector ringsC = {3.5, 14.75, 26.0, 37.25, 48.5, 59.75, 71.}; + float ringsA[Constants::nringsA + 1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; + float ringsC[Constants::nringsC + 1] = {3.5, 14.75, 26.0, 37.25, 48.5, 59.75, 71.}; float zmodA = 1700; float zmodC = -1950; diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h index 43cb1224b28e2..379fc014095c3 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h +++ b/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h @@ -15,6 +15,7 @@ #pragma link off all classes; #pragma link off all functions; +#pragma link C++ class o2::fvd::Constants + ; #pragma link C++ class o2::fvd::GeometryTGeo + ; #pragma link C++ class o2::fvd::FVDBaseParam + ; #pragma link C++ class o2::conf::ConfigurableParamHelper < o2::fvd::FVDBaseParam> + ; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h index 9afcb6e251945..b1e2d42ba2f52 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h @@ -98,13 +98,13 @@ class Detector : public o2::base::DetImpl TGeoVolumeAssembly* buildModuleA(); TGeoVolumeAssembly* buildModuleC(); + int mNumberOfSectors; int mNumberOfRingsA; int mNumberOfRingsC; - int mNumberOfSectors; float mDzScint; - std::vector mRingRadiiA; - std::vector mRingRadiiC; + std::vector mRingRadiiA = {}; + std::vector mRingRadiiC = {}; float mZmodA; float mZmodC; diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index d49a84f7f089e..662f56c1324b8 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -55,20 +55,23 @@ Detector::Detector(bool active) mGeometryTGeo(nullptr), mTrackData() { + mNumberOfRingsA = Constants::nringsA; + mNumberOfRingsC = Constants::nringsC; + mNumberOfSectors = Constants::nsect; + auto& baseParam = FVDBaseParam::Instance(); mDzScint = baseParam.dzscint / 2; - mRingRadiiA = baseParam.ringsA; - mRingRadiiC = baseParam.ringsC; - - mNumberOfRingsA = mRingRadiiA.size() - 1; - mNumberOfRingsC = mRingRadiiC.size() - 1; + for (int i = 0; i <= mNumberOfRingsA + 1; i ++) { + mRingRadiiA.emplace_back(baseParam.ringsA[i]); + } + for (int i = 0; i <= mNumberOfRingsC + 1; i ++) { + mRingRadiiC.emplace_back(baseParam.ringsC[i]); + } mZmodA = baseParam.zmodA; mZmodC = baseParam.zmodC; - - mNumberOfSectors = Constants::nsect; } Detector::Detector(const Detector& rhs) @@ -112,7 +115,7 @@ bool Detector::ProcessHits(FairVolume* vol) // This method is called from the MC stepping // Track only charged particles and photons bool isPhotonTrack = false; - Int_t particlePdg = fMC->TrackPid(); + int particlePdg = fMC->TrackPid(); if (particlePdg == 22) { // If particle is standard PDG photon isPhotonTrack = true; } @@ -128,7 +131,7 @@ bool Detector::ProcessHits(FairVolume* vol) bool startHit = false, stopHit = false; unsigned char status = 0; - Int_t currVolId, offId; + int currVolId, offId; if (fMC->IsTrackEntering()) { status |= Hit::kTrackEntering; @@ -190,7 +193,7 @@ bool Detector::ProcessHits(FairVolume* vol) return true; } -o2::itsmft::Hit* Detector::addHit(Int_t trackId, Int_t cellId, +o2::itsmft::Hit* Detector::addHit(int trackId, int cellId, const TVector3& startPos, const TVector3& endPos, const TVector3& startMom, @@ -237,28 +240,28 @@ void Detector::Reset() void Detector::createMaterials() { - Float_t density, as[11], zs[11], ws[11]; - Double_t radLength, absLength, a_ad, z_ad; - Int_t id; + float density, as[11], zs[11], ws[11]; + double radLength, absLength, a_ad, z_ad; + int id; // EJ-204 scintillator, based on polyvinyltoluene - const Int_t nScint = 2; - Float_t aScint[nScint] = {1.00784, 12.0107}; - Float_t zScint[nScint] = {1, 6}; - Float_t wScint[nScint] = {0.07085, 0.92915}; // based on EJ-204 datasheet: n_atoms/cm3 - const Float_t dScint = 1.023; - - Int_t matId = 0; // tmp material id number - const Int_t unsens = 0, sens = 1; // sensitive or unsensitive medium + const int nScint = 2; + float aScint[nScint] = {1.00784, 12.0107}; + float zScint[nScint] = {1, 6}; + float wScint[nScint] = {0.07085, 0.92915}; // based on EJ-204 datasheet: n_atoms/cm3 + const float dScint = 1.023; + + int matId = 0; // tmp material id number + const int unsens = 0, sens = 1; // sensitive or unsensitive medium // - Int_t fieldType = 3; // Field type - Float_t maxField = 5.0; // Field max. - - Float_t tmaxfd = -10.0; // max deflection angle due to magnetic field in one step - Float_t stemax = 0.1; // max step allowed [cm] - Float_t deemax = 1.0; // maximum fractional energy loss in one step 0 Date: Sat, 21 Dec 2024 18:19:57 +0100 Subject: [PATCH 32/68] created new namespace --- Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 662f56c1324b8..14d3e80e51a65 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -179,7 +179,6 @@ bool Detector::ProcessHits(FairVolume* vol) TLorentzVector positionStop; fMC->TrackPosition(positionStop); int trackId = fMC->GetStack()->GetCurrentTrackNumber(); - int chId = getChannelId(mTrackData.mPositionStart.Vect()); Hit* p = addHit(trackId, chId /*cellId*/, mTrackData.mPositionStart.Vect(), positionStop.Vect(), From 2b8a26e3cf4b59bed13713f000d414590c89e111 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sat, 21 Dec 2024 18:29:32 +0100 Subject: [PATCH 33/68] created new namespace --- .../Upgrades/ALICE3/FVD/simulation/src/Detector.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx index 14d3e80e51a65..1032c8edfde9a 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx @@ -63,11 +63,11 @@ Detector::Detector(bool active) mDzScint = baseParam.dzscint / 2; - for (int i = 0; i <= mNumberOfRingsA + 1; i ++) { - mRingRadiiA.emplace_back(baseParam.ringsA[i]); + for (int i = 0; i <= mNumberOfRingsA + 1; i++) { + mRingRadiiA.emplace_back(baseParam.ringsA[i]); } - for (int i = 0; i <= mNumberOfRingsC + 1; i ++) { - mRingRadiiC.emplace_back(baseParam.ringsC[i]); + for (int i = 0; i <= mNumberOfRingsC + 1; i++) { + mRingRadiiC.emplace_back(baseParam.ringsC[i]); } mZmodA = baseParam.zmodA; @@ -252,7 +252,7 @@ void Detector::createMaterials() int matId = 0; // tmp material id number const int unsens = 0, sens = 1; // sensitive or unsensitive medium - // + // int fieldType = 3; // Field type float maxField = 5.0; // Field max. From fbf45955748c24856a4e5a0c8b56faa24892080f Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 27 Jan 2025 19:45:17 +0100 Subject: [PATCH 34/68] change name of the detector --- Common/SimConfig/src/SimConfig.cxx | 8 +-- .../DetectorsCommonDataFormats/DetID.h | 10 ++-- .../DetectorsCommonDataFormats/SimTraits.h | 2 +- .../Headers/include/Headers/DataHeader.h | 2 +- Detectors/Upgrades/ALICE3/CMakeLists.txt | 2 +- .../ALICE3/{FVD => FD}/CMakeLists.txt | 0 .../Upgrades/ALICE3/{FVD => FD}/README.md | 2 +- .../ALICE3/{FVD => FD}/base/CMakeLists.txt | 12 ++--- .../ALICE3/{FVD => FD}/base/README.md | 0 .../base/include/FDBase}/Constants.h | 8 +-- .../base/include/FDBase/FDBaseParam.h} | 16 +++--- .../base/include/FDBase}/GeometryTGeo.h | 14 ++--- .../base/src/FDBaseLinkDef.h} | 8 +-- .../base/src/FDBaseParam.cxx} | 4 +- .../{FVD => FD}/base/src/GeometryTGeo.cxx | 14 ++--- .../{FVD => FD}/simulation/CMakeLists.txt | 10 ++-- .../{FVD => FD}/simulation/data/simcuts.dat | 0 .../include/FDSimulation}/Detector.h | 16 +++--- .../{FVD => FD}/simulation/src/Detector.cxx | 52 +++++++++---------- .../simulation/src/FDSimulationLinkDef.h} | 4 +- macro/build_geometry.C | 8 +-- run/CMakeLists.txt | 2 +- run/o2simdefaultdetectorlist.json | 2 +- 23 files changed, 98 insertions(+), 98 deletions(-) rename Detectors/Upgrades/ALICE3/{FVD => FD}/CMakeLists.txt (100%) rename Detectors/Upgrades/ALICE3/{FVD => FD}/README.md (68%) rename Detectors/Upgrades/ALICE3/{FVD => FD}/base/CMakeLists.txt (73%) rename Detectors/Upgrades/ALICE3/{FVD => FD}/base/README.md (100%) rename Detectors/Upgrades/ALICE3/{FVD/base/include/FVDBase => FD/base/include/FDBase}/Constants.h (89%) rename Detectors/Upgrades/ALICE3/{FVD/base/include/FVDBase/FVDBaseParam.h => FD/base/include/FDBase/FDBaseParam.h} (75%) rename Detectors/Upgrades/ALICE3/{FVD/base/include/FVDBase => FD/base/include/FDBase}/GeometryTGeo.h (85%) rename Detectors/Upgrades/ALICE3/{FVD/base/src/FVDBaseLinkDef.h => FD/base/src/FDBaseLinkDef.h} (81%) rename Detectors/Upgrades/ALICE3/{FVD/base/src/FVDBaseParam.cxx => FD/base/src/FDBaseParam.cxx} (88%) rename Detectors/Upgrades/ALICE3/{FVD => FD}/base/src/GeometryTGeo.cxx (81%) rename Detectors/Upgrades/ALICE3/{FVD => FD}/simulation/CMakeLists.txt (73%) rename Detectors/Upgrades/ALICE3/{FVD => FD}/simulation/data/simcuts.dat (100%) rename Detectors/Upgrades/ALICE3/{FVD/simulation/include/FVDSimulation => FD/simulation/include/FDSimulation}/Detector.h (94%) rename Detectors/Upgrades/ALICE3/{FVD => FD}/simulation/src/Detector.cxx (87%) rename Detectors/Upgrades/ALICE3/{FVD/simulation/src/FVDSimulationLinkDef.h => FD/simulation/src/FDSimulationLinkDef.h} (85%) diff --git a/Common/SimConfig/src/SimConfig.cxx b/Common/SimConfig/src/SimConfig.cxx index 9d20c6dc67aa9..8bbccfad59923 100644 --- a/Common/SimConfig/src/SimConfig.cxx +++ b/Common/SimConfig/src/SimConfig.cxx @@ -99,7 +99,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules[i] != "RCH" && activeModules[i] != "MI3" && activeModules[i] != "ECL" && - activeModules[i] != "FVD") { + activeModules[i] != "FD") { LOGP(fatal, "List of active modules contains {}, which is not a module from the upgrades.", activeModules[i]); } } @@ -114,7 +114,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules[i] == "RCH" || activeModules[i] == "MI3" || activeModules[i] == "ECL" || - activeModules[i] == "FVD") { + activeModules[i] == "FD") { LOGP(fatal, "List of active modules contains {}, which is not a run 3 module", activeModules[i]); } } @@ -132,7 +132,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs d == DetID::TF3 || d == DetID::RCH || d == DetID::ECL || - d == DetID::FVD || + d == DetID::FD || d == DetID::MI3) { activeModules.emplace_back(DetID::getName(d)); } @@ -152,7 +152,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules.emplace_back("SHIL"); for (int d = DetID::First; d <= DetID::Last; ++d) { #ifdef ENABLE_UPGRADES - if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT && d != DetID::TF3 && d != DetID::RCH && d != DetID::ECL && d != DetID::FVD && d != DetID::MI3) { + if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT && d != DetID::TF3 && d != DetID::RCH && d != DetID::ECL && d != DetID::FD && d != DetID::MI3) { activeModules.emplace_back(DetID::getName(d)); } } diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h index d7c3e3f72cc30..25a1669942107 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h @@ -87,8 +87,8 @@ class DetID static constexpr ID RCH = 23; static constexpr ID MI3 = 24; static constexpr ID ECL = 25; - static constexpr ID FVD = 26; - static constexpr ID Last = FVD; + static constexpr ID FD = 26; + static constexpr ID Last = FD; #else static constexpr ID Last = FOC; ///< if extra detectors added, update this !!! #endif @@ -182,7 +182,7 @@ class DetID // detector names, will be defined in DataSources static constexpr const char* sDetNames[nDetectors + 1] = ///< defined detector names #ifdef ENABLE_UPGRADES - {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FVD", nullptr}; + {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD", nullptr}; #else {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", nullptr}; #endif @@ -196,7 +196,7 @@ class DetID #ifdef ENABLE_UPGRADES , o2h::gDataOriginIT3, o2h::gDataOriginTRK, o2h::gDataOriginFT3, o2h::gDataOriginFCT, o2h::gDataOriginTF3, - o2h::gDataOriginRCH, o2h::gDataOriginMI3, o2h::gDataOriginECL, o2h::gDataOriginFVD + o2h::gDataOriginRCH, o2h::gDataOriginMI3, o2h::gDataOriginECL, o2h::gDataOriginFD #endif }; #endif // GPUCA_GPUCODE_DEVICE @@ -216,7 +216,7 @@ GPUconstexpr() DetID::mask_t sMasks[DetID::nDetectors] = ///< detectot masks #ifdef ENABLE_UPGRADES , DetID::mask_t(math_utils::bit2Mask(DetID::IT3)), DetID::mask_t(math_utils::bit2Mask(DetID::TRK)), DetID::mask_t(math_utils::bit2Mask(DetID::FT3)), DetID::mask_t(math_utils::bit2Mask(DetID::FCT)), DetID::mask_t(math_utils::bit2Mask(DetID::TF3)), - DetID::mask_t(math_utils::bit2Mask(DetID::RCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MI3)), DetID::mask_t(math_utils::bit2Mask(DetID::ECL)), DetID::mask_t(math_utils::bit2Mask(DetID::FVD)) + DetID::mask_t(math_utils::bit2Mask(DetID::RCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MI3)), DetID::mask_t(math_utils::bit2Mask(DetID::ECL)), DetID::mask_t(math_utils::bit2Mask(DetID::FD)) #endif }; } // namespace detid_internal diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h index 4f68107b172df..37c4b790d181b 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h @@ -100,7 +100,7 @@ class SimTraits /*RCH*/ VS{ "RCHHit" }, /*MI3*/ VS{ "MI3Hit" }, /*ECL*/ VS{ "ECLHit" }, - /*FVD*/ VS{ "FVDHit" } + /*FD */ VS{ "FDHit" } #endif }; // clang-format on diff --git a/DataFormats/Headers/include/Headers/DataHeader.h b/DataFormats/Headers/include/Headers/DataHeader.h index 1f1ae422154f8..6bd24fc49ebc3 100644 --- a/DataFormats/Headers/include/Headers/DataHeader.h +++ b/DataFormats/Headers/include/Headers/DataHeader.h @@ -588,7 +588,7 @@ constexpr o2::header::DataOrigin gDataOriginTF3{"TF3"}; constexpr o2::header::DataOrigin gDataOriginRCH{"RCH"}; constexpr o2::header::DataOrigin gDataOriginMI3{"MI3"}; constexpr o2::header::DataOrigin gDataOriginECL{"ECL"}; // upgrades -constexpr o2::header::DataOrigin gDataOriginFVD{"FVD"}; // upgrades +constexpr o2::header::DataOrigin gDataOriginFD{"FD"}; // upgrades constexpr o2::header::DataOrigin gDataOriginGPU{"GPU"}; diff --git a/Detectors/Upgrades/ALICE3/CMakeLists.txt b/Detectors/Upgrades/ALICE3/CMakeLists.txt index 077cb427b62e5..0cd027e9bf8e0 100644 --- a/Detectors/Upgrades/ALICE3/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/CMakeLists.txt @@ -12,7 +12,7 @@ add_subdirectory(Passive) add_subdirectory(TRK) add_subdirectory(ECal) -add_subdirectory(FVD) +add_subdirectory(FD) add_subdirectory(FT3) add_subdirectory(FCT) add_subdirectory(AOD) diff --git a/Detectors/Upgrades/ALICE3/FVD/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt similarity index 100% rename from Detectors/Upgrades/ALICE3/FVD/CMakeLists.txt rename to Detectors/Upgrades/ALICE3/FD/CMakeLists.txt diff --git a/Detectors/Upgrades/ALICE3/FVD/README.md b/Detectors/Upgrades/ALICE3/FD/README.md similarity index 68% rename from Detectors/Upgrades/ALICE3/FVD/README.md rename to Detectors/Upgrades/ALICE3/FD/README.md index 7cd905ef2cb22..53264cb89914a 100644 --- a/Detectors/Upgrades/ALICE3/FVD/README.md +++ b/Detectors/Upgrades/ALICE3/FD/README.md @@ -4,7 +4,7 @@ # ALICE 3 FORVARD DETECTOR -This is top page for the FVD detector documentation. +This is top page for the FD detector documentation. diff --git a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt similarity index 73% rename from Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt rename to Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt index 0b8f8041cb3d7..65de538eb0ea1 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt @@ -9,12 +9,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2_add_library(FVDBase +o2_add_library(FDBase SOURCES src/GeometryTGeo.cxx - src/FVDBaseParam.cxx + src/FDBaseParam.cxx PUBLIC_LINK_LIBRARIES O2::DetectorsBase) -o2_target_root_dictionary(FVDBase - HEADERS include/FVDBase/GeometryTGeo.h - include/FVDBase/Constants.h - include/FVDBase/FVDBaseParam.h) +o2_target_root_dictionary(FDBase + HEADERS include/FDBase/GeometryTGeo.h + include/FDBase/Constants.h + include/FDBase/FDBaseParam.h) diff --git a/Detectors/Upgrades/ALICE3/FVD/base/README.md b/Detectors/Upgrades/ALICE3/FD/base/README.md similarity index 100% rename from Detectors/Upgrades/ALICE3/FVD/base/README.md rename to Detectors/Upgrades/ALICE3/FD/base/README.md diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h similarity index 89% rename from Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h rename to Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h index 82a40c65a90f8..6c6c65de6da8d 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/Constants.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h @@ -14,12 +14,12 @@ /// /// \author Maciej Slupecki, University of Jyvaskyla, Finland -#ifndef ALICEO2_FVD_CONSTANTS_ -#define ALICEO2_FVD_CONSTANTS_ +#ifndef ALICEO2_FD_CONSTANTS_ +#define ALICEO2_FD_CONSTANTS_ namespace o2 { -namespace fvd +namespace fd { struct Constants { static constexpr int nsect = 8; @@ -27,6 +27,6 @@ struct Constants { static constexpr int nringsC = 6; }; -} // namespace fvd +} // namespace fd } // namespace o2 #endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h similarity index 75% rename from Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h rename to Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h index d41a3d93b6875..729d66572157e 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/FVDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h @@ -9,18 +9,18 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#ifndef ALICEO2_FVD_FVDBASEPARAM_ -#define ALICEO2_FVD_FVDBASEPARAM_ +#ifndef ALICEO2_FD_FDBASEPARAM_ +#define ALICEO2_FD_FDBASEPARAM_ -#include "FVDBase/GeometryTGeo.h" -#include "FVDBase/Constants.h" +#include "FDBase/GeometryTGeo.h" +#include "FDBase/Constants.h" #include "CommonUtils/ConfigurableParamHelper.h" namespace o2 { -namespace fvd +namespace fd { -struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { +struct FDBaseParam : public o2::conf::ConfigurableParamHelper { float ringsA[Constants::nringsA + 1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; float ringsC[Constants::nringsC + 1] = {3.5, 14.75, 26.0, 37.25, 48.5, 59.75, 71.}; @@ -29,10 +29,10 @@ struct FVDBaseParam : public o2::conf::ConfigurableParamHelper { float zmodC = -1950; float dzscint = 4.; - O2ParamDef(FVDBaseParam, "FVDBase"); + O2ParamDef(FDBaseParam, "FDBase"); }; -} // namespace fvd +} // namespace fd } // namespace o2 #endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h similarity index 85% rename from Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h rename to Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h index dd965262798a0..1c39e01b43f2e 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/include/FVDBase/GeometryTGeo.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h @@ -8,8 +8,8 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#ifndef ALICEO2_FVD_GEOMETRYTGEO_H_ -#define ALICEO2_FVD_GEOMETRYTGEO_H_ +#ifndef ALICEO2_FD_GEOMETRYTGEO_H_ +#define ALICEO2_FD_GEOMETRYTGEO_H_ #include @@ -25,10 +25,10 @@ namespace o2 { -namespace fvd +namespace fd { -/// FVD Geometry type +/// FD Geometry type class GeometryTGeo : public o2::detectors::DetMatrixCache { public: @@ -42,13 +42,13 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache void getGlobalPosition(float& x, float& y, float& z); - static constexpr o2::detectors::DetID::ID getDetID() { return o2::detectors::DetID::FVD; } + static constexpr o2::detectors::DetID::ID getDetID() { return o2::detectors::DetID::FD; } private: - static std::unique_ptr sInstance; + static std::unique_ptr sInstance; ClassDefNV(GeometryTGeo, 1); }; -} // namespace fvd +} // namespace fd } // namespace o2 #endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h b/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h similarity index 81% rename from Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h rename to Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h index 379fc014095c3..208667adbf818 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseLinkDef.h +++ b/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h @@ -15,9 +15,9 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class o2::fvd::Constants + ; -#pragma link C++ class o2::fvd::GeometryTGeo + ; -#pragma link C++ class o2::fvd::FVDBaseParam + ; -#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::fvd::FVDBaseParam> + ; +#pragma link C++ class o2::fd::Constants + ; +#pragma link C++ class o2::fd::GeometryTGeo + ; +#pragma link C++ class o2::fd::FDBaseParam + ; +#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::fd::FDBaseParam> + ; #endif diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx b/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx similarity index 88% rename from Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx rename to Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx index 6bc99ba1a055f..576e76b7b796c 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/FVDBaseParam.cxx +++ b/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx @@ -9,6 +9,6 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include "FVDBase/FVDBaseParam.h" +#include "FDBase/FDBaseParam.h" -O2ParamImpl(o2::fvd::FVDBaseParam); +O2ParamImpl(o2::fd::FDBaseParam); diff --git a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx similarity index 81% rename from Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx rename to Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx index 0eaa4e2f39c04..b4f7acd0f4bae 100644 --- a/Detectors/Upgrades/ALICE3/FVD/base/src/GeometryTGeo.cxx +++ b/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx @@ -9,25 +9,25 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include "FVDBase/GeometryTGeo.h" -#include "FVDBase/FVDBaseParam.h" +#include "FDBase/GeometryTGeo.h" +#include "FDBase/FDBaseParam.h" #include #include -using namespace o2::fvd; +using namespace o2::fd; namespace o2 { -namespace fvd +namespace fd { -std::unique_ptr GeometryTGeo::sInstance; +std::unique_ptr GeometryTGeo::sInstance; GeometryTGeo::GeometryTGeo(bool build, int loadTrans) : DetMatrixCache() { if (sInstance) { - LOGP(fatal, "Invalid use of public constructor: o2::fvd::GeometryTGeo instance exists"); + LOGP(fatal, "Invalid use of public constructor: o2::fd::GeometryTGeo instance exists"); } if (build) { Build(loadTrans); @@ -62,5 +62,5 @@ void GeometryTGeo::fillMatrixCache(int mask) { } -} // namespace fvd +} // namespace fd } // namespace o2 diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt similarity index 73% rename from Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt rename to Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt index 30177cfa3adb1..2882dd9350537 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt @@ -9,13 +9,13 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2_add_library(FVDSimulation +o2_add_library(FDSimulation SOURCES src/Detector.cxx - PUBLIC_LINK_LIBRARIES O2::FVDBase + PUBLIC_LINK_LIBRARIES O2::FDBase O2::ITSMFTSimulation ROOT::Physics) -o2_target_root_dictionary(FVDSimulation - HEADERS include/FVDSimulation/Detector.h) +o2_target_root_dictionary(FDSimulation + HEADERS include/FDSimulation/Detector.h) -o2_data_file(COPY data DESTINATION Detectors/FVD/simulation) +o2_data_file(COPY data DESTINATION Detectors/FD/simulation) diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/data/simcuts.dat b/Detectors/Upgrades/ALICE3/FD/simulation/data/simcuts.dat similarity index 100% rename from Detectors/Upgrades/ALICE3/FVD/simulation/data/simcuts.dat rename to Detectors/Upgrades/ALICE3/FD/simulation/data/simcuts.dat diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h similarity index 94% rename from Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h rename to Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h index b1e2d42ba2f52..198bca4b7fd17 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/include/FVDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h @@ -12,13 +12,13 @@ /// \file Detector.h /// \brief Definition of the Detector class -#ifndef ALICEO2_FVD_DETECTOR_H_ -#define ALICEO2_FVD_DETECTOR_H_ +#ifndef ALICEO2_FD_DETECTOR_H_ +#define ALICEO2_FD_DETECTOR_H_ #include "SimulationDataFormat/BaseHits.h" #include "DetectorsBase/Detector.h" -#include "FVDBase/GeometryTGeo.h" -#include "FVDBase/FVDBaseParam.h" +#include "FDBase/GeometryTGeo.h" +#include "FDBase/FDBaseParam.h" #include "ITSMFTSimulation/Hit.h" #include "Rtypes.h" #include "TGeoManager.h" @@ -30,7 +30,7 @@ class TGeoVolume; namespace o2 { -namespace fvd +namespace fd { class GeometryTGeo; } @@ -38,7 +38,7 @@ class GeometryTGeo; namespace o2 { -namespace fvd +namespace fd { class Detector : public o2::base::DetImpl @@ -131,7 +131,7 @@ class Detector : public o2::base::DetImpl std::ostream& operator<<(std::ostream& os, Detector& source); std::istream& operator>>(std::istream& os, Detector& source); -} // namespace fvd +} // namespace fd } // namespace o2 #ifdef USESHM @@ -140,7 +140,7 @@ namespace o2 namespace base { template <> -struct UseShm { +struct UseShm { static constexpr bool value = true; }; } // namespace base diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx similarity index 87% rename from Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx rename to Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 1032c8edfde9a..5ec9e757b42b8 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -13,10 +13,10 @@ /// \brief Implementation of the Detector class #include "ITSMFTSimulation/Hit.h" -#include "FVDSimulation/Detector.h" -#include "FVDBase/GeometryTGeo.h" -#include "FVDBase/FVDBaseParam.h" -#include "FVDBase/Constants.h" +#include "FDSimulation/Detector.h" +#include "FDBase/GeometryTGeo.h" +#include "FDBase/FDBaseParam.h" +#include "FDBase/Constants.h" #include "DetectorsBase/Stack.h" #include "SimulationDataFormat/TrackReference.h" @@ -46,11 +46,11 @@ class FairModule; class TGeoMedium; -using namespace o2::fvd; +using namespace o2::fd; using o2::itsmft::Hit; Detector::Detector(bool active) - : o2::base::DetImpl("FVD", true), + : o2::base::DetImpl("FD", true), mHits(o2::utils::createSimVector()), mGeometryTGeo(nullptr), mTrackData() @@ -59,7 +59,7 @@ Detector::Detector(bool active) mNumberOfRingsC = Constants::nringsC; mNumberOfSectors = Constants::nsect; - auto& baseParam = FVDBaseParam::Instance(); + auto& baseParam = FDBaseParam::Instance(); mDzScint = baseParam.dzscint / 2; @@ -105,7 +105,7 @@ Detector::~Detector() void Detector::InitializeO2Detector() { - LOG(info) << "Initialize FVD detector"; + LOG(info) << "Initialize FD detector"; mGeometryTGeo = GeometryTGeo::Instance(); defineSensitiveVolumes(); } @@ -262,7 +262,7 @@ void Detector::createMaterials() float epsil = 0.03; // tracking precision [cm] float stmin = -0.001; // minimum step due to continuous processes [cm] (negative value: choose it automatically) - LOG(info) << "FVD: CreateMaterials(): fieldType " << fieldType << ", maxField " << maxField; + LOG(info) << "FD: CreateMaterials(): fieldType " << fieldType << ", maxField " << maxField; o2::base::Detector::Mixture(++matId, "Scintillator", aScint, zScint, dScint, nScint, wScint); o2::base::Detector::Medium(Scintillator, "Scintillator", matId, unsens, fieldType, maxField, @@ -271,7 +271,7 @@ void Detector::createMaterials() void Detector::buildModules() { - LOGP(info, "Creating FVD geometry"); + LOGP(info, "Creating FD geometry"); TGeoVolume* vCave = gGeoManager->GetVolume("cave"); @@ -279,27 +279,27 @@ void Detector::buildModules() LOG(fatal) << "Could not find the top volume (cave)!"; } - TGeoVolumeAssembly* vFVDA = buildModuleA(); - TGeoVolumeAssembly* vFVDC = buildModuleC(); + TGeoVolumeAssembly* vFDA = buildModuleA(); + TGeoVolumeAssembly* vFDC = buildModuleC(); - vCave->AddNode(vFVDA, 1, new TGeoTranslation(0., 0., mZmodA /* - mDzScint/2.*/)); - vCave->AddNode(vFVDC, 1, new TGeoTranslation(0., 0., mZmodC /* + mDzScint/2.*/)); + vCave->AddNode(vFDA, 1, new TGeoTranslation(0., 0., mZmodA /* - mDzScint/2.*/)); + vCave->AddNode(vFDC, 1, new TGeoTranslation(0., 0., mZmodC /* + mDzScint/2.*/)); } TGeoVolumeAssembly* Detector::buildModuleA() { - TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDA"); + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FDA"); - const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + const TGeoMedium* medium = gGeoManager->GetMedium("FD_Scintillator"); float dphiDeg = 360. / mNumberOfSectors; for (int ir = 0; ir < mNumberOfRingsA; ir++) { - std::string rName = "fvd_ring" + std::to_string(ir + 1); + std::string rName = "fd_ring" + std::to_string(ir + 1); TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); for (int ic = 0; ic < mNumberOfSectors; ic++) { int cellId = ic + mNumberOfSectors * ir; - std::string nodeName = "fvd_node" + std::to_string(cellId); + std::string nodeName = "fd_node" + std::to_string(cellId); float rmin = mRingRadiiA[ir]; float rmax = mRingRadiiA[ir + 1]; float phimin = dphiDeg * ic; @@ -317,18 +317,18 @@ TGeoVolumeAssembly* Detector::buildModuleA() TGeoVolumeAssembly* Detector::buildModuleC() { - TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FVDC"); + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FDC"); - const TGeoMedium* medium = gGeoManager->GetMedium("FVD_Scintillator"); + const TGeoMedium* medium = gGeoManager->GetMedium("FD_Scintillator"); float dphiDeg = 360. / mNumberOfSectors; for (int ir = 0; ir < mNumberOfRingsC; ir++) { - std::string rName = "fvd_ring" + std::to_string(ir + 1 + mNumberOfRingsA); + std::string rName = "fd_ring" + std::to_string(ir + 1 + mNumberOfRingsA); TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); for (int ic = 0; ic < mNumberOfSectors; ic++) { int cellId = ic + mNumberOfSectors * (ir + mNumberOfRingsA); - std::string nodeName = "fvd_node" + std::to_string(cellId); + std::string nodeName = "fd_node" + std::to_string(cellId); float rmin = mRingRadiiC[ir]; float rmax = mRingRadiiC[ir + 1]; float phimin = dphiDeg * ic; @@ -346,7 +346,7 @@ TGeoVolumeAssembly* Detector::buildModuleC() void Detector::defineSensitiveVolumes() { - LOG(info) << "Adding FVD Sentitive Volumes"; + LOG(info) << "Adding FD Sentitive Volumes"; TGeoVolume* v; TString volumeName; @@ -355,9 +355,9 @@ void Detector::defineSensitiveVolumes() int nCellC = mNumberOfRingsC * mNumberOfSectors; for (int iv = 0; iv < nCellA + nCellC; iv++) { - volumeName = "fvd_node" + std::to_string(iv); + volumeName = "fd_node" + std::to_string(iv); v = gGeoManager->GetVolume(volumeName); - LOG(info) << "Adding FVD Sensitive Volume => " << v->GetName(); + LOG(info) << "Adding FD Sensitive Volume => " << v->GetName(); AddSensitiveVolume(v); } } @@ -387,4 +387,4 @@ int Detector::getChannelId(TVector3 vec) return ir * mNumberOfSectors + isect + noff; } -ClassImp(o2::fvd::Detector); +ClassImp(o2::fd::Detector); diff --git a/Detectors/Upgrades/ALICE3/FVD/simulation/src/FVDSimulationLinkDef.h b/Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h similarity index 85% rename from Detectors/Upgrades/ALICE3/FVD/simulation/src/FVDSimulationLinkDef.h rename to Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h index 314a69baa54da..3071b7811b154 100644 --- a/Detectors/Upgrades/ALICE3/FVD/simulation/src/FVDSimulationLinkDef.h +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h @@ -15,7 +15,7 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class o2::fvd::Detector + ; -#pragma link C++ class o2::base::DetImpl < o2::fvd::Detector> + ; +#pragma link C++ class o2::fd::Detector + ; +#pragma link C++ class o2::base::DetImpl < o2::fd::Detector> + ; #endif diff --git a/macro/build_geometry.C b/macro/build_geometry.C index f3e18948ba453..aa8cc58d0d86f 100644 --- a/macro/build_geometry.C +++ b/macro/build_geometry.C @@ -55,7 +55,7 @@ #include #include #include -#include +#include #include #include #include @@ -264,9 +264,9 @@ void build_geometry(FairRunSim* run = nullptr) addReadoutDetector(new o2::ecal::Detector(isReadout("ECL"))); } - if (isActivated("FVD")) { - // ALICE3 FVD - addReadoutDetector(new o2::fvd::Detector(isReadout("FVD"))); + if (isActivated("FD")) { + // ALICE3 FD + addReadoutDetector(new o2::fd::Detector(isReadout("FD"))); } if (isActivated("MI3")) { diff --git a/run/CMakeLists.txt b/run/CMakeLists.txt index 1b81d5c15b4d0..db3727921bea1 100644 --- a/run/CMakeLists.txt +++ b/run/CMakeLists.txt @@ -46,7 +46,7 @@ target_link_libraries(allsim $<$:O2::IOTOFSimulation> $<$:O2::RICHSimulation> $<$:O2::ECalSimulation> - $<$:O2::FVDSimulation> + $<$:O2::FDSimulation> $<$:O2::MI3Simulation> O2::Generators) diff --git a/run/o2simdefaultdetectorlist.json b/run/o2simdefaultdetectorlist.json index c133dc5c802d3..e8f51a2211c5c 100644 --- a/run/o2simdefaultdetectorlist.json +++ b/run/o2simdefaultdetectorlist.json @@ -58,7 +58,7 @@ "RCH", "MI3", "ECL", - "FVD", + "FD", "HALL", "MAG", "A3IP", From c7bf68d9cd8cf7b10122b211a92eecd398f7280d Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 27 Jan 2025 19:53:53 +0100 Subject: [PATCH 35/68] change name of the detector --- DataFormats/Headers/include/Headers/DataHeader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/Headers/include/Headers/DataHeader.h b/DataFormats/Headers/include/Headers/DataHeader.h index 6bd24fc49ebc3..a2cb772df422f 100644 --- a/DataFormats/Headers/include/Headers/DataHeader.h +++ b/DataFormats/Headers/include/Headers/DataHeader.h @@ -588,7 +588,7 @@ constexpr o2::header::DataOrigin gDataOriginTF3{"TF3"}; constexpr o2::header::DataOrigin gDataOriginRCH{"RCH"}; constexpr o2::header::DataOrigin gDataOriginMI3{"MI3"}; constexpr o2::header::DataOrigin gDataOriginECL{"ECL"}; // upgrades -constexpr o2::header::DataOrigin gDataOriginFD{"FD"}; // upgrades +constexpr o2::header::DataOrigin gDataOriginFD{"FD"}; // upgrades constexpr o2::header::DataOrigin gDataOriginGPU{"GPU"}; From e02c8b48a82789b0b49dc2929c35cd37d3960b5e Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 29 Jan 2025 12:53:04 +0100 Subject: [PATCH 36/68] check errors --- Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx | 2 +- .../Upgrades/ALICE3/FD/simulation/src/Detector.cxx | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx index b4f7acd0f4bae..69c40fd42b876 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx +++ b/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx @@ -34,7 +34,7 @@ GeometryTGeo::GeometryTGeo(bool build, int loadTrans) : DetMatrixCache() } } -GeometryTGeo::~GeometryTGeo() {} +GeometryTGeo::~GeometryTGeo() = default; GeometryTGeo* GeometryTGeo::Instance() { diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 5ec9e757b42b8..fb8008cadb687 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -365,8 +365,10 @@ void Detector::defineSensitiveVolumes() int Detector::getChannelId(TVector3 vec) { float phi = vec.Phi(); - if (phi < 0) + if (phi < 0) { phi += TMath::TwoPi(); + } + float r = vec.Perp(); float z = vec.Z(); @@ -378,10 +380,12 @@ int Detector::getChannelId(TVector3 vec) int ir = 0; for (int i = 1; i < rd.size(); i++) { - if (r < rd[i]) + if (r < rd[i]) { break; - else + } + else { ir++; + } } return ir * mNumberOfSectors + isect + noff; From a37a782e7a1cd23c6090d07d1f0cef4a453e8bb4 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 29 Jan 2025 13:04:16 +0100 Subject: [PATCH 37/68] check errors --- Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index fb8008cadb687..fbd8e975c76e8 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -382,8 +382,7 @@ int Detector::getChannelId(TVector3 vec) for (int i = 1; i < rd.size(); i++) { if (r < rd[i]) { break; - } - else { + } else { ir++; } } From dcef2915652c8bb516a8f64166e0dc1efba7cb6b Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sun, 2 Feb 2025 18:11:49 +0100 Subject: [PATCH 38/68] Flexible ring radii, a new Boolean switch for module A, module coverage in eta independent of their position --- .../ALICE3/FD/base/include/FDBase/Constants.h | 6 +++ .../FD/base/include/FDBase/FDBaseParam.h | 9 ++-- .../include/FDSimulation/Detector.h | 3 ++ .../ALICE3/FD/simulation/src/Detector.cxx | 43 ++++++++++++++----- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h index 6c6c65de6da8d..35ccd95b3e745 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h @@ -25,6 +25,12 @@ struct Constants { static constexpr int nsect = 8; static constexpr int nringsA = 5; static constexpr int nringsC = 6; + + static constexpr float etaMax = 7.0f; + static constexpr float etaMin = 4.0f; + + static constexpr int nringsA_withFCT = 4; + static constexpr float etaMinA_withFCT = 5.0f; }; } // namespace fd diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h index 729d66572157e..09e294b8d3f42 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h @@ -22,12 +22,11 @@ namespace fd { struct FDBaseParam : public o2::conf::ConfigurableParamHelper { - float ringsA[Constants::nringsA + 1] = {3., 14.8, 26.6, 38.4, 50.2, 62.}; - float ringsC[Constants::nringsC + 1] = {3.5, 14.75, 26.0, 37.25, 48.5, 59.75, 71.}; + float zmodA = 1700.0f; + float zmodC = -1950.0f; + float dzscint = 4.0f; - float zmodA = 1700; - float zmodC = -1950; - float dzscint = 4.; + bool withFCT = true; O2ParamDef(FDBaseParam, "FDBase"); }; diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h index 198bca4b7fd17..7143f22825cac 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h @@ -98,6 +98,8 @@ class Detector : public o2::base::DetImpl TGeoVolumeAssembly* buildModuleA(); TGeoVolumeAssembly* buildModuleC(); + float ringRadius(float zmod, float eta); + int mNumberOfSectors; int mNumberOfRingsA; int mNumberOfRingsC; @@ -106,6 +108,7 @@ class Detector : public o2::base::DetImpl std::vector mRingRadiiA = {}; std::vector mRingRadiiC = {}; + float mEtaMax, mEtaMin, mEtaMinA; float mZmodA; float mZmodC; diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index fbd8e975c76e8..9bb65f1aa4f62 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -55,23 +55,37 @@ Detector::Detector(bool active) mGeometryTGeo(nullptr), mTrackData() { - mNumberOfRingsA = Constants::nringsA; mNumberOfRingsC = Constants::nringsC; mNumberOfSectors = Constants::nsect; + mEtaMax = Constants::etaMax; + mEtaMin = Constants::etaMin; + auto& baseParam = FDBaseParam::Instance(); + if (baseParam.withFCT) { + mNumberOfRingsA = Constants::nringsA_withFCT; + mEtaMinA = Constants::etaMinA_withFCT; + } else { + mNumberOfRingsA = Constants::nringsA; + mEtaMinA = mEtaMin; + } + mDzScint = baseParam.dzscint / 2; + mZmodA = baseParam.zmodA; + mZmodC = baseParam.zmodC; for (int i = 0; i <= mNumberOfRingsA + 1; i++) { - mRingRadiiA.emplace_back(baseParam.ringsA[i]); + float eta = mEtaMax - i * (mEtaMax - mEtaMinA) / mNumberOfRingsA; + float r = ringRadius(mZmodA, eta); + mRingRadiiA.emplace_back(r); } + for (int i = 0; i <= mNumberOfRingsC + 1; i++) { - mRingRadiiC.emplace_back(baseParam.ringsC[i]); + float eta = -mEtaMax + i * (mEtaMax - mEtaMin) / mNumberOfRingsC; + float r = ringRadius(mZmodC, eta); + mRingRadiiC.emplace_back(r); } - - mZmodA = baseParam.zmodA; - mZmodC = baseParam.zmodC; } Detector::Detector(const Detector& rhs) @@ -297,11 +311,12 @@ TGeoVolumeAssembly* Detector::buildModuleA() for (int ir = 0; ir < mNumberOfRingsA; ir++) { std::string rName = "fd_ring" + std::to_string(ir + 1); TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); + float rmin = mRingRadiiA[ir]; + float rmax = mRingRadiiA[ir + 1]; + LOG(info) << "ring" << ir << ": from " << rmin << " to " << rmax; for (int ic = 0; ic < mNumberOfSectors; ic++) { int cellId = ic + mNumberOfSectors * ir; std::string nodeName = "fd_node" + std::to_string(cellId); - float rmin = mRingRadiiA[ir]; - float rmax = mRingRadiiA[ir + 1]; float phimin = dphiDeg * ic; float phimax = dphiDeg * (ic + 1); auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); @@ -326,11 +341,12 @@ TGeoVolumeAssembly* Detector::buildModuleC() for (int ir = 0; ir < mNumberOfRingsC; ir++) { std::string rName = "fd_ring" + std::to_string(ir + 1 + mNumberOfRingsA); TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); + float rmin = mRingRadiiC[ir]; + float rmax = mRingRadiiC[ir + 1]; + LOG(info) << "ring" << ir + mNumberOfRingsA << ": from " << rmin << " to " << rmax; for (int ic = 0; ic < mNumberOfSectors; ic++) { int cellId = ic + mNumberOfSectors * (ir + mNumberOfRingsA); std::string nodeName = "fd_node" + std::to_string(cellId); - float rmin = mRingRadiiC[ir]; - float rmax = mRingRadiiC[ir + 1]; float phimin = dphiDeg * ic; float phimax = dphiDeg * (ic + 1); auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); @@ -354,6 +370,8 @@ void Detector::defineSensitiveVolumes() int nCellA = mNumberOfRingsA * mNumberOfSectors; int nCellC = mNumberOfRingsC * mNumberOfSectors; + LOG(info) << "number of A rings = " << mNumberOfRingsA << " number of cells = " << nCellA; + for (int iv = 0; iv < nCellA + nCellC; iv++) { volumeName = "fd_node" + std::to_string(iv); v = gGeoManager->GetVolume(volumeName); @@ -390,4 +408,9 @@ int Detector::getChannelId(TVector3 vec) return ir * mNumberOfSectors + isect + noff; } +float Detector::ringRadius(float z, float eta) +{ + return z * TMath::Tan(2 * TMath::ATan(TMath::Exp(-eta))); +} + ClassImp(o2::fd::Detector); From f27e878357a8fb149542cb4924a9d89ca7a1cec5 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 3 Feb 2025 08:14:41 +0100 Subject: [PATCH 39/68] correct default number of ring of A side --- Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h index 35ccd95b3e745..ecab005034988 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h @@ -29,7 +29,7 @@ struct Constants { static constexpr float etaMax = 7.0f; static constexpr float etaMin = 4.0f; - static constexpr int nringsA_withFCT = 4; + static constexpr int nringsA_withFCT = 3; static constexpr float etaMinA_withFCT = 5.0f; }; From 78555d82ae8d87616d06e21f1ff015555ccfb255 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 10 Feb 2025 10:14:10 +0100 Subject: [PATCH 40/68] Modified default parameters --- .../ALICE3/FD/base/include/FDBase/Constants.h | 9 +++++---- .../ALICE3/FD/base/include/FDBase/FDBaseParam.h | 4 ++-- .../FD/simulation/include/FDSimulation/Detector.h | 3 ++- .../Upgrades/ALICE3/FD/simulation/src/Detector.cxx | 12 ++++++------ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h index ecab005034988..7e9871175953e 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h @@ -23,14 +23,15 @@ namespace fd { struct Constants { static constexpr int nsect = 8; - static constexpr int nringsA = 5; + static constexpr int nringsA = 3; static constexpr int nringsC = 6; static constexpr float etaMax = 7.0f; - static constexpr float etaMin = 4.0f; + static constexpr float etaMinC = 4.0f; + static constexpr float etaMinA = 5.0f; - static constexpr int nringsA_withFCT = 3; - static constexpr float etaMinA_withFCT = 5.0f; + static constexpr int nringsA_noFCT = 5; + static constexpr float etaMinA_noFCT = 4.0f; }; } // namespace fd diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h index 09e294b8d3f42..a8168e4c15ead 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h @@ -23,10 +23,10 @@ namespace fd struct FDBaseParam : public o2::conf::ConfigurableParamHelper { float zmodA = 1700.0f; - float zmodC = -1950.0f; + float zmodC = -1850.0f; float dzscint = 4.0f; - bool withFCT = true; + bool noFCT = false; O2ParamDef(FDBaseParam, "FDBase"); }; diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h index 7143f22825cac..ee3a05e70d6e5 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h @@ -108,7 +108,8 @@ class Detector : public o2::base::DetImpl std::vector mRingRadiiA = {}; std::vector mRingRadiiC = {}; - float mEtaMax, mEtaMin, mEtaMinA; + float mEtaMax; + float mEtaMinC, mEtaMinA; float mZmodA; float mZmodC; diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 9bb65f1aa4f62..feeea0b534465 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -59,16 +59,16 @@ Detector::Detector(bool active) mNumberOfSectors = Constants::nsect; mEtaMax = Constants::etaMax; - mEtaMin = Constants::etaMin; + mEtaMinC = Constants::etaMinC; auto& baseParam = FDBaseParam::Instance(); - if (baseParam.withFCT) { - mNumberOfRingsA = Constants::nringsA_withFCT; - mEtaMinA = Constants::etaMinA_withFCT; + if (baseParam.noFCT) { + mNumberOfRingsA = Constants::nringsA_noFCT; + mEtaMinA = Constants::etaMinA_noFCT; } else { mNumberOfRingsA = Constants::nringsA; - mEtaMinA = mEtaMin; + mEtaMinA = Constants::etaMinA; } mDzScint = baseParam.dzscint / 2; @@ -82,7 +82,7 @@ Detector::Detector(bool active) } for (int i = 0; i <= mNumberOfRingsC + 1; i++) { - float eta = -mEtaMax + i * (mEtaMax - mEtaMin) / mNumberOfRingsC; + float eta = -mEtaMax + i * (mEtaMax - mEtaMinC) / mNumberOfRingsC; float r = ringRadius(mZmodC, eta); mRingRadiiC.emplace_back(r); } From ca2c0fba7c8af2101d001d63ad095c0d94624709 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 10 Feb 2025 12:50:35 +0100 Subject: [PATCH 41/68] Hits from charged tracks only --- Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index feeea0b534465..81abf2e627715 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -127,13 +127,7 @@ void Detector::InitializeO2Detector() bool Detector::ProcessHits(FairVolume* vol) { // This method is called from the MC stepping - // Track only charged particles and photons - bool isPhotonTrack = false; - int particlePdg = fMC->TrackPid(); - if (particlePdg == 22) { // If particle is standard PDG photon - isPhotonTrack = true; - } - if (!(isPhotonTrack || fMC->TrackCharge())) { + if (!(fMC->TrackCharge())) { return kFALSE; } From e2b6b288d4ad58a5d6ed514f9556d29376bcca80 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Tue, 11 Feb 2025 14:39:31 +0100 Subject: [PATCH 42/68] Fixed hit merging --- .../ALICE3/FD/base/include/FDBase/Constants.h | 8 ++++---- .../FD/simulation/include/FDSimulation/Detector.h | 8 ++++---- .../Upgrades/ALICE3/FD/simulation/src/Detector.cxx | 11 ++++------- run/O2HitMerger.h | 5 +++++ 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h index 7e9871175953e..e18c83811bf8a 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h @@ -22,15 +22,15 @@ namespace o2 namespace fd { struct Constants { - static constexpr int nsect = 8; - static constexpr int nringsA = 3; - static constexpr int nringsC = 6; + static constexpr unsigned int nsect = 8; + static constexpr unsigned int nringsA = 3; + static constexpr unsigned int nringsC = 6; static constexpr float etaMax = 7.0f; static constexpr float etaMinC = 4.0f; static constexpr float etaMinA = 5.0f; - static constexpr int nringsA_noFCT = 5; + static constexpr unsigned int nringsA_noFCT = 5; static constexpr float etaMinA_noFCT = 4.0f; }; diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h index ee3a05e70d6e5..2771ffb5c41ca 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h @@ -100,9 +100,9 @@ class Detector : public o2::base::DetImpl float ringRadius(float zmod, float eta); - int mNumberOfSectors; - int mNumberOfRingsA; - int mNumberOfRingsC; + unsigned int mNumberOfSectors; + unsigned int mNumberOfRingsA; + unsigned int mNumberOfRingsC; float mDzScint; std::vector mRingRadiiA = {}; @@ -115,7 +115,7 @@ class Detector : public o2::base::DetImpl void defineSensitiveVolumes(); - int getChannelId(TVector3 vec); + unsigned int getChannelId(TVector3 vec); /// Transient data about track passing the sensor, needed by ProcessHits() struct TrackData { // this is transient diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 81abf2e627715..f503f883bc05c 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -138,9 +138,6 @@ bool Detector::ProcessHits(FairVolume* vol) // Check track status to define when hit is started and when it is stopped bool startHit = false, stopHit = false; unsigned char status = 0; - - int currVolId, offId; - if (fMC->IsTrackEntering()) { status |= Hit::kTrackEntering; } @@ -186,8 +183,8 @@ bool Detector::ProcessHits(FairVolume* vol) if (stopHit) { TLorentzVector positionStop; fMC->TrackPosition(positionStop); - int trackId = fMC->GetStack()->GetCurrentTrackNumber(); - int chId = getChannelId(mTrackData.mPositionStart.Vect()); + int trackId = stack->GetCurrentTrackNumber(); + unsigned int chId = getChannelId(mTrackData.mPositionStart.Vect()); Hit* p = addHit(trackId, chId /*cellId*/, mTrackData.mPositionStart.Vect(), positionStop.Vect(), mTrackData.mMomentumStart.Vect(), mTrackData.mMomentumStart.E(), @@ -374,7 +371,7 @@ void Detector::defineSensitiveVolumes() } } -int Detector::getChannelId(TVector3 vec) +unsigned int Detector::getChannelId(TVector3 vec) { float phi = vec.Phi(); if (phi < 0) { @@ -384,7 +381,7 @@ int Detector::getChannelId(TVector3 vec) float r = vec.Perp(); float z = vec.Z(); - int isect = int(phi / (TMath::Pi() / 4)); + int isect = int(phi / (TMath::TwoPi() / mNumberOfSectors)); std::vector rd = z > 0 ? mRingRadiiA : mRingRadiiC; int noff = z > 0 ? 0 : mNumberOfRingsA * mNumberOfSectors; diff --git a/run/O2HitMerger.h b/run/O2HitMerger.h index bd905548b58f3..68e709bc72140 100644 --- a/run/O2HitMerger.h +++ b/run/O2HitMerger.h @@ -78,6 +78,7 @@ #include #include #include +#include #endif #include @@ -1020,6 +1021,10 @@ void O2HitMerger::initDetInstances() mDetectorInstances[i] = std::move(std::make_unique(true)); counter++; } + if (i == DetID::FD) { + mDetectorInstances[i] = std::move(std::make_unique(true)); + counter++; + } #endif } if (counter != DetID::nDetectors) { From f2b04d4dbe0e9619080a42192ca75500f71824fe Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 6 Mar 2025 14:26:42 +0100 Subject: [PATCH 43/68] return to the previous choice --- .../Upgrades/ALICE3/FD/base/include/FDBase/Constants.h | 6 +++--- .../Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h | 2 +- Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h index e18c83811bf8a..47beefad3aee6 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h @@ -23,15 +23,15 @@ namespace fd { struct Constants { static constexpr unsigned int nsect = 8; - static constexpr unsigned int nringsA = 3; + static constexpr unsigned int nringsA = 5; static constexpr unsigned int nringsC = 6; static constexpr float etaMax = 7.0f; static constexpr float etaMinC = 4.0f; static constexpr float etaMinA = 5.0f; - static constexpr unsigned int nringsA_noFCT = 5; - static constexpr float etaMinA_noFCT = 4.0f; + static constexpr unsigned int nringsA_withMG = 3; + static constexpr float etaMinA_withMG = 5.0f; }; } // namespace fd diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h index a8168e4c15ead..3a00597b1e88a 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h @@ -26,7 +26,7 @@ struct FDBaseParam : public o2::conf::ConfigurableParamHelper { float zmodC = -1850.0f; float dzscint = 4.0f; - bool noFCT = false; + bool withMG = false; // modified geometry O2ParamDef(FDBaseParam, "FDBase"); }; diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index f503f883bc05c..3660b1fd8600f 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -63,9 +63,9 @@ Detector::Detector(bool active) auto& baseParam = FDBaseParam::Instance(); - if (baseParam.noFCT) { - mNumberOfRingsA = Constants::nringsA_noFCT; - mEtaMinA = Constants::etaMinA_noFCT; + if (baseParam.withMG) { + mNumberOfRingsA = Constants::nringsA_withMG; + mEtaMinA = Constants::etaMinA_withMG; } else { mNumberOfRingsA = Constants::nringsA; mEtaMinA = Constants::etaMinA; From 35eb86e889ead6a3f536fd16b808699372f3e327 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sun, 9 Mar 2025 08:42:31 +0100 Subject: [PATCH 44/68] updated eta min/max definitions --- .../ALICE3/FD/base/include/FDBase/Constants.h | 3 +-- .../FD/simulation/include/FDSimulation/Detector.h | 7 +++---- .../Upgrades/ALICE3/FD/simulation/src/Detector.cxx | 12 +++++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h index 47beefad3aee6..687fa52143039 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h @@ -27,8 +27,7 @@ struct Constants { static constexpr unsigned int nringsC = 6; static constexpr float etaMax = 7.0f; - static constexpr float etaMinC = 4.0f; - static constexpr float etaMinA = 5.0f; + static constexpr float etaMin = 4.0f; static constexpr unsigned int nringsA_withMG = 3; static constexpr float etaMinA_withMG = 5.0f; diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h index 2771ffb5c41ca..482935f9198e5 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h @@ -108,10 +108,9 @@ class Detector : public o2::base::DetImpl std::vector mRingRadiiA = {}; std::vector mRingRadiiC = {}; - float mEtaMax; - float mEtaMinC, mEtaMinA; - float mZmodA; - float mZmodC; + float mEtaMaxA, mEtaMaxC; + float mEtaMinA, mEtaMinC; + float mZmodA, mZmodC; void defineSensitiveVolumes(); diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 3660b1fd8600f..5eebe1345a0ca 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -58,8 +58,10 @@ Detector::Detector(bool active) mNumberOfRingsC = Constants::nringsC; mNumberOfSectors = Constants::nsect; - mEtaMax = Constants::etaMax; - mEtaMinC = Constants::etaMinC; + mEtaMinA = Constants::etaMin; + mEtaMaxA = Constants::etaMax; + mEtaMinC = -Constants::etaMax; + mEtaMaxC = -Constants::etaMin; auto& baseParam = FDBaseParam::Instance(); @@ -68,7 +70,7 @@ Detector::Detector(bool active) mEtaMinA = Constants::etaMinA_withMG; } else { mNumberOfRingsA = Constants::nringsA; - mEtaMinA = Constants::etaMinA; + mEtaMinA = Constants::etaMin; } mDzScint = baseParam.dzscint / 2; @@ -76,13 +78,13 @@ Detector::Detector(bool active) mZmodC = baseParam.zmodC; for (int i = 0; i <= mNumberOfRingsA + 1; i++) { - float eta = mEtaMax - i * (mEtaMax - mEtaMinA) / mNumberOfRingsA; + float eta = mEtaMaxA - i * (mEtaMaxA - mEtaMinA) / mNumberOfRingsA; float r = ringRadius(mZmodA, eta); mRingRadiiA.emplace_back(r); } for (int i = 0; i <= mNumberOfRingsC + 1; i++) { - float eta = -mEtaMax + i * (mEtaMax - mEtaMinC) / mNumberOfRingsC; + float eta = mEtaMaxC - i * (mEtaMaxC - mEtaMinC) / mNumberOfRingsC; float r = ringRadius(mZmodC, eta); mRingRadiiC.emplace_back(r); } From 4ead62064254d99be6013a815ea13b303db7afe9 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 10 Mar 2025 06:38:00 +0100 Subject: [PATCH 45/68] updated eta definitions --- Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 5eebe1345a0ca..536a936f6a53e 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -74,6 +74,7 @@ Detector::Detector(bool active) } mDzScint = baseParam.dzscint / 2; + mZmodA = baseParam.zmodA; mZmodC = baseParam.zmodC; @@ -84,7 +85,7 @@ Detector::Detector(bool active) } for (int i = 0; i <= mNumberOfRingsC + 1; i++) { - float eta = mEtaMaxC - i * (mEtaMaxC - mEtaMinC) / mNumberOfRingsC; + float eta = mEtaMinC + i * (mEtaMaxC - mEtaMinC) / mNumberOfRingsC; float r = ringRadius(mZmodC, eta); mRingRadiiC.emplace_back(r); } From f264f9af9a2381dce66d05a8ebff41219514df05 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Wed, 19 Mar 2025 16:42:37 +0100 Subject: [PATCH 46/68] remove spurious files --- Detectors/Upgrades/ALICE3/FD/simulation/data/simcuts.dat | 0 GPU/GPUTracking/display/GPUDisplayInterface.h | 1 - 2 files changed, 1 deletion(-) delete mode 100644 Detectors/Upgrades/ALICE3/FD/simulation/data/simcuts.dat diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/data/simcuts.dat b/Detectors/Upgrades/ALICE3/FD/simulation/data/simcuts.dat deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/GPU/GPUTracking/display/GPUDisplayInterface.h b/GPU/GPUTracking/display/GPUDisplayInterface.h index f2dcda51d8f4b..3c6928c78e5a1 100644 --- a/GPU/GPUTracking/display/GPUDisplayInterface.h +++ b/GPU/GPUTracking/display/GPUDisplayInterface.h @@ -15,7 +15,6 @@ #ifndef GPUDISPLAYINTERFACE_H #define GPUDISPLAYINTERFACE_H -#include #include "GPUSettings.h" namespace o2::gpu From e0fa607f8e679856553cd5ce3f0fc6f9ebb81fad Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 20 Mar 2025 07:35:37 +0100 Subject: [PATCH 47/68] Update CMake --- Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt index 2882dd9350537..c17b0244ae9e1 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt @@ -17,5 +17,3 @@ o2_add_library(FDSimulation o2_target_root_dictionary(FDSimulation HEADERS include/FDSimulation/Detector.h) - -o2_data_file(COPY data DESTINATION Detectors/FD/simulation) From acd685be27a3285ff6c5c64a435ed21b3445bed1 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sun, 30 Mar 2025 18:13:21 +0200 Subject: [PATCH 48/68] removed GPU file --- GPU/GPUTracking/display/GPUDisplayInterface.h:36 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 GPU/GPUTracking/display/GPUDisplayInterface.h:36 diff --git a/GPU/GPUTracking/display/GPUDisplayInterface.h:36 b/GPU/GPUTracking/display/GPUDisplayInterface.h:36 deleted file mode 100644 index e69de29bb2d1d..0000000000000 From 7eeb149cf5c7eaf04e1b99fc4a4c9e1f52ecef36 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sun, 30 Mar 2025 18:27:15 +0200 Subject: [PATCH 49/68] Add FD detector --- .github/workflows/clean-test.yml | 10 +- Common/SimConfig/src/SimConfig.cxx | 9 +- .../DetectorsCommonDataFormats/DetID.h | 10 +- .../DetectorsCommonDataFormats/SimTraits.h | 3 +- .../Headers/include/Headers/DataHeader.h | 1 + Detectors/FIT/FT0/macros/FT0Misaligner.C | 44 +- .../FIT/FV0/base/include/FV0Base/Geometry.h | 12 + Detectors/FIT/FV0/macros/FV0Misaligner.C | 46 +- Detectors/FIT/FV0/simulation/src/Detector.cxx | 19 +- Detectors/FIT/macros/CMakeLists.txt | 4 + Detectors/FIT/macros/readAlignParam.C | 51 +++ Detectors/FIT/macros/readFT0hits.C | 29 +- Detectors/FIT/macros/readFV0hits.C | 37 +- Detectors/Upgrades/ALICE3/CMakeLists.txt | 3 +- Detectors/Upgrades/ALICE3/FD/CMakeLists.txt | 13 + Detectors/Upgrades/ALICE3/FD/README.md | 10 + .../Upgrades/ALICE3/FD/base/CMakeLists.txt | 20 + Detectors/Upgrades/ALICE3/FD/base/README.md | 17 + .../ALICE3/FD/base/include/FDBase/Constants.h | 38 ++ .../FD/base/include/FDBase/FDBaseParam.h | 37 ++ .../FD/base/include/FDBase/GeometryTGeo.h | 54 +++ .../ALICE3/FD/base/src/FDBaseLinkDef.h | 23 + .../ALICE3/FD/base/src/FDBaseParam.cxx | 14 + .../ALICE3/FD/base/src/GeometryTGeo.cxx | 66 +++ .../ALICE3/FD/simulation/CMakeLists.txt | 19 + .../include/FDSimulation/Detector.h | 152 +++++++ .../ALICE3/FD/simulation/src/Detector.cxx | 410 ++++++++++++++++++ .../FD/simulation/src/FDSimulationLinkDef.h | 21 + .../Core/include/Framework/DeviceControl.h | 2 + .../Core/include/Framework/PluginManager.h | 2 +- .../src/FrameworkGUIDataRelayerUsage.cxx | 95 +++- .../src/FrameworkGUIDataRelayerUsage.h | 5 +- .../src/FrameworkGUIDevicesGraph.cxx | 3 +- GPU/Common/CMakeLists.txt | 5 + GPU/Common/GPUCommonAlgorithm.h | 2 +- GPU/Common/GPUCommonAlgorithmThrust.h | 13 +- GPU/Common/GPUCommonDef.h | 2 +- GPU/GPUTracking/Base/GPUConstantMem.h | 4 +- GPU/GPUTracking/Base/GPUParam.cxx | 4 +- GPU/GPUTracking/Base/GPUReconstructionCPU.cxx | 24 +- GPU/GPUTracking/Base/GPUReconstructionCPU.h | 15 +- .../Base/GPUReconstructionKernelMacros.h | 27 +- .../Base/GPUReconstructionKernels.h | 20 +- .../Base/GPUReconstructionProcessing.cxx | 68 +-- .../Base/GPUReconstructionProcessing.h | 11 +- GPU/GPUTracking/Base/cuda/CMakeLists.txt | 8 +- .../Base/cuda/GPUReconstructionCUDA.cu | 24 +- .../Base/cuda/GPUReconstructionCUDA.h | 2 - .../GPUReconstructionCUDAExternalProvider.cu | 3 +- .../Base/cuda/GPUReconstructionCUDAGenRTC.cxx | 101 +++-- ... => GPUReconstructionCUDAIncludesSystem.h} | 6 +- .../Base/cuda/GPUReconstructionCUDAKernels.cu | 30 +- .../GPUReconstructionCUDAkernel.template.cu | 3 +- .../Base/cuda/GPUReconstructionCUDArtc.cu | 2 +- GPU/GPUTracking/Base/hip/CMakeLists.txt | 10 +- ...h => GPUReconstructionHIPIncludesSystem.h} | 6 +- .../GPUReconstructionHIPkernel.template.hip | 3 +- GPU/GPUTracking/Base/opencl/CMakeLists.txt | 6 +- .../Base/opencl/GPUReconstructionOCL.cxx | 4 + .../Base/opencl/GPUReconstructionOCL.h | 2 - .../opencl/GPUReconstructionOCLKernels.cxx | 4 +- GPU/GPUTracking/CMakeLists.txt | 24 +- GPU/GPUTracking/Definitions/GPUDef.h | 2 +- .../Definitions/GPUDefConstantsAndSettings.h | 4 +- .../Definitions/GPUDefParameters.template.h | 27 ++ ...Parameters.h => GPUDefParametersDefault.h} | 336 ++++++++++++-- .../GPUDefParametersLoad.template.inc | 56 +++ GPU/GPUTracking/Definitions/GPUSettingsList.h | 26 +- .../GPUTrackingLinkDef_O2_DataTypes.h | 1 + .../Global/GPUChainTrackingSectorTracker.cxx | 2 +- GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx | 2 +- .../GPUTPCTrackletConstructor.cxx | 75 +--- .../SectorTracker/GPUTPCTrackletConstructor.h | 11 +- .../Standalone/Benchmark/standalone.cxx | 22 - GPU/GPUTracking/Standalone/CMakeLists.txt | 7 +- GPU/GPUTracking/Standalone/tools/createGeo.C | 14 + GPU/GPUTracking/Standalone/tools/createGeo.sh | 11 + GPU/GPUTracking/Standalone/tools/createLUT.C | 14 + .../Standalone/tools/dumpGPUDefParam.C | 38 ++ .../Standalone/tools/dumpTRDClusterMatrices.C | 11 + .../tools/switchToAliRootLicense.sh | 26 -- GPU/GPUTracking/TPCClusterFinder/CfConsts.h | 5 - .../cmake/GPUNoFastMathKernels.template.h | 5 + GPU/GPUTracking/cmake/kernel_helpers.cmake | 4 +- GPU/GPUTracking/kernels.cmake | 7 +- GPU/GPUTracking/utils/qmaths_helpers.h | 41 +- cmake/O2RootMacroExclusionList.cmake | 2 +- dependencies/FindO2GPU.cmake | 57 ++- macro/build_geometry.C | 6 + prodtests/full-system-test/dpl-workflow.sh | 8 +- run/CMakeLists.txt | 3 +- run/O2HitMerger.h | 5 + .../Pythia8_HepMC_Wrapper/Pythia8HepMC3.macro | 44 ++ .../Pythia8_HepMC_Wrapper/README.md | 16 + run/SimExamples/Pythia8_HepMC_Wrapper/run.sh | 19 + run/SimExamples/README.md | 1 + run/o2simdefaultdetectorlist.json | 1 + 97 files changed, 2105 insertions(+), 516 deletions(-) create mode 100644 Detectors/FIT/macros/readAlignParam.C create mode 100644 Detectors/Upgrades/ALICE3/FD/CMakeLists.txt create mode 100644 Detectors/Upgrades/ALICE3/FD/README.md create mode 100644 Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt create mode 100644 Detectors/Upgrades/ALICE3/FD/base/README.md create mode 100644 Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h create mode 100644 Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h create mode 100644 Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h create mode 100644 Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h create mode 100644 Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx create mode 100644 Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx create mode 100644 Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt create mode 100644 Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h create mode 100644 Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx create mode 100644 Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h rename GPU/GPUTracking/Base/cuda/{GPUReconstructionCUDAIncludesHost.h => GPUReconstructionCUDAIncludesSystem.h} (91%) rename GPU/GPUTracking/Base/hip/{GPUReconstructionHIPIncludesHost.h => GPUReconstructionHIPIncludesSystem.h} (89%) create mode 100644 GPU/GPUTracking/Definitions/GPUDefParameters.template.h rename GPU/GPUTracking/Definitions/{GPUDefGPUParameters.h => GPUDefParametersDefault.h} (69%) create mode 100644 GPU/GPUTracking/Definitions/GPUDefParametersLoad.template.inc create mode 100644 GPU/GPUTracking/Standalone/tools/dumpGPUDefParam.C delete mode 100755 GPU/GPUTracking/Standalone/tools/switchToAliRootLicense.sh create mode 100644 run/SimExamples/Pythia8_HepMC_Wrapper/Pythia8HepMC3.macro create mode 100644 run/SimExamples/Pythia8_HepMC_Wrapper/README.md create mode 100755 run/SimExamples/Pythia8_HepMC_Wrapper/run.sh diff --git a/.github/workflows/clean-test.yml b/.github/workflows/clean-test.yml index cbc524910c33e..0f15301d4eed9 100644 --- a/.github/workflows/clean-test.yml +++ b/.github/workflows/clean-test.yml @@ -19,10 +19,6 @@ name: Clean PR checks # Warning: the check_* keys are magic and must consist of the string # "check_" followed by the applicable check name exactly. The # "description" field is only the human-readable label for the input. - 'check_build/O2/o2': - description: build/O2/o2 - type: boolean - default: true 'check_build/AliceO2/O2/o2/macOS': description: build/AliceO2/O2/o2/macOS type: boolean @@ -31,14 +27,10 @@ name: Clean PR checks description: build/AliceO2/O2/o2/macOS-arm type: boolean default: true - 'check_build/O2/fullCI': + 'check_build/O2/fullCI_slc9': description: build/O2/fullCI type: boolean default: true - 'check_build/O2/o2-cs8': - description: build/O2/o2-cs8 - type: boolean - default: true 'check_build/O2/o2-dataflow-cs8': description: build/O2/o2-dataflow-cs8 type: boolean diff --git a/Common/SimConfig/src/SimConfig.cxx b/Common/SimConfig/src/SimConfig.cxx index 9407a3c556179..59c1e868987bd 100644 --- a/Common/SimConfig/src/SimConfig.cxx +++ b/Common/SimConfig/src/SimConfig.cxx @@ -98,7 +98,8 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules[i] != "TF3" && activeModules[i] != "RCH" && activeModules[i] != "MI3" && - activeModules[i] != "ECL") { + activeModules[i] != "ECL" && + activeModules[i] != "FD") { LOGP(fatal, "List of active modules contains {}, which is not a module from the upgrades.", activeModules[i]); } } @@ -112,7 +113,8 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules[i] == "TF3" || activeModules[i] == "RCH" || activeModules[i] == "MI3" || - activeModules[i] == "ECL") { + activeModules[i] == "ECL" || + activeModules[i] == "FD") { LOGP(fatal, "List of active modules contains {}, which is not a run 3 module", activeModules[i]); } } @@ -130,6 +132,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs d == DetID::TF3 || d == DetID::RCH || d == DetID::ECL || + d == DetID::FD || d == DetID::MI3) { activeModules.emplace_back(DetID::getName(d)); } @@ -149,7 +152,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules.emplace_back("SHIL"); for (int d = DetID::First; d <= DetID::Last; ++d) { #ifdef ENABLE_UPGRADES - if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT && d != DetID::TF3 && d != DetID::RCH && d != DetID::ECL && d != DetID::MI3) { + if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT && d != DetID::TF3 && d != DetID::RCH && d != DetID::ECL && d != DetID::FD && d != DetID::MI3) { activeModules.emplace_back(DetID::getName(d)); } } diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h index a2767c7620cdd..25a1669942107 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h @@ -87,7 +87,8 @@ class DetID static constexpr ID RCH = 23; static constexpr ID MI3 = 24; static constexpr ID ECL = 25; - static constexpr ID Last = ECL; + static constexpr ID FD = 26; + static constexpr ID Last = FD; #else static constexpr ID Last = FOC; ///< if extra detectors added, update this !!! #endif @@ -181,7 +182,7 @@ class DetID // detector names, will be defined in DataSources static constexpr const char* sDetNames[nDetectors + 1] = ///< defined detector names #ifdef ENABLE_UPGRADES - {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", nullptr}; + {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD", nullptr}; #else {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", nullptr}; #endif @@ -195,7 +196,7 @@ class DetID #ifdef ENABLE_UPGRADES , o2h::gDataOriginIT3, o2h::gDataOriginTRK, o2h::gDataOriginFT3, o2h::gDataOriginFCT, o2h::gDataOriginTF3, - o2h::gDataOriginRCH, o2h::gDataOriginMI3, o2h::gDataOriginECL + o2h::gDataOriginRCH, o2h::gDataOriginMI3, o2h::gDataOriginECL, o2h::gDataOriginFD #endif }; #endif // GPUCA_GPUCODE_DEVICE @@ -211,10 +212,11 @@ GPUconstexpr() DetID::mask_t sMasks[DetID::nDetectors] = ///< detectot masks DetID::mask_t(math_utils::bit2Mask(DetID::CPV)), DetID::mask_t(math_utils::bit2Mask(DetID::EMC)), DetID::mask_t(math_utils::bit2Mask(DetID::HMP)), DetID::mask_t(math_utils::bit2Mask(DetID::MFT)), DetID::mask_t(math_utils::bit2Mask(DetID::MCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MID)), DetID::mask_t(math_utils::bit2Mask(DetID::ZDC)), DetID::mask_t(math_utils::bit2Mask(DetID::FT0)), DetID::mask_t(math_utils::bit2Mask(DetID::FV0)), DetID::mask_t(math_utils::bit2Mask(DetID::FDD)), DetID::mask_t(math_utils::bit2Mask(DetID::TST)), DetID::mask_t(math_utils::bit2Mask(DetID::CTP)), DetID::mask_t(math_utils::bit2Mask(DetID::FOC)) + #ifdef ENABLE_UPGRADES , DetID::mask_t(math_utils::bit2Mask(DetID::IT3)), DetID::mask_t(math_utils::bit2Mask(DetID::TRK)), DetID::mask_t(math_utils::bit2Mask(DetID::FT3)), DetID::mask_t(math_utils::bit2Mask(DetID::FCT)), DetID::mask_t(math_utils::bit2Mask(DetID::TF3)), - DetID::mask_t(math_utils::bit2Mask(DetID::RCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MI3)), DetID::mask_t(math_utils::bit2Mask(DetID::ECL)) + DetID::mask_t(math_utils::bit2Mask(DetID::RCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MI3)), DetID::mask_t(math_utils::bit2Mask(DetID::ECL)), DetID::mask_t(math_utils::bit2Mask(DetID::FD)) #endif }; } // namespace detid_internal diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h index 8f9cbcfbdba43..37c4b790d181b 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/SimTraits.h @@ -99,7 +99,8 @@ class SimTraits /*TF3*/ VS{ "TF3Hit" }, /*RCH*/ VS{ "RCHHit" }, /*MI3*/ VS{ "MI3Hit" }, - /*ECL*/ VS{ "ECLHit" } + /*ECL*/ VS{ "ECLHit" }, + /*FD */ VS{ "FDHit" } #endif }; // clang-format on diff --git a/DataFormats/Headers/include/Headers/DataHeader.h b/DataFormats/Headers/include/Headers/DataHeader.h index 2dbfbd67d8d6c..a2cb772df422f 100644 --- a/DataFormats/Headers/include/Headers/DataHeader.h +++ b/DataFormats/Headers/include/Headers/DataHeader.h @@ -588,6 +588,7 @@ constexpr o2::header::DataOrigin gDataOriginTF3{"TF3"}; constexpr o2::header::DataOrigin gDataOriginRCH{"RCH"}; constexpr o2::header::DataOrigin gDataOriginMI3{"MI3"}; constexpr o2::header::DataOrigin gDataOriginECL{"ECL"}; // upgrades +constexpr o2::header::DataOrigin gDataOriginFD{"FD"}; // upgrades constexpr o2::header::DataOrigin gDataOriginGPU{"GPU"}; diff --git a/Detectors/FIT/FT0/macros/FT0Misaligner.C b/Detectors/FIT/FT0/macros/FT0Misaligner.C index 7585411066934..9621d1a079bc9 100644 --- a/Detectors/FIT/FT0/macros/FT0Misaligner.C +++ b/Detectors/FIT/FT0/macros/FT0Misaligner.C @@ -1,15 +1,30 @@ +// Copyright 2021-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file FT0Misaligner.C +/// \brief ROOT macro for creating an FT0 geometry alignment object. Based on ITSMisaligner.C +/// +/// \author Andreas Molander andreas.molander@cern.ch, Alla Maevskaya + #if !defined(__CLING__) || defined(__ROOTCLING__) -//#define ENABLE_UPGRADES + +#include "CCDB/CcdbApi.h" #include "DetectorsCommonDataFormats/DetID.h" #include "DetectorsCommonDataFormats/DetectorNameConf.h" #include "DetectorsCommonDataFormats/AlignParam.h" -#include "DetectorsBase/GeometryManager.h" -#include "CCDB/CcdbApi.h" -#include "FT0Base/Geometry.h" -#include + #include #include #include + #endif using AlgPar = std::array; @@ -23,19 +38,15 @@ void FT0Misaligner(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080" const std::string& fileName = "FT0Alignment.root") { std::vector params; - o2::base::GeometryManager::loadGeometry("", false); - // auto geom = o2::ft0::Geometry::Instance(); AlgPar pars; bool glo = true; o2::detectors::DetID detFT0("FT0"); - // FT0 detector - //set A side std::string symNameA = "FT0A"; pars = generateMisalignment(xA, yA, zA, psiA, thetaA, phiA); params.emplace_back(symNameA.c_str(), -1, pars[0], pars[1], pars[2], pars[3], pars[4], pars[5], glo); - //set C side + std::string symNameC = "FT0C"; pars = generateMisalignment(xC, yC, zC, psiC, thetaC, phiC); params.emplace_back(symNameC.c_str(), -1, pars[0], pars[1], pars[2], pars[3], pars[4], pars[5], glo); @@ -57,14 +68,15 @@ void FT0Misaligner(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080" algFile.Close(); } } + AlgPar generateMisalignment(double x, double y, double z, double psi, double theta, double phi) { AlgPar pars; - pars[0] = gRandom->Gaus(0, x); - pars[1] = gRandom->Gaus(0, y); - pars[2] = gRandom->Gaus(0, z); - pars[3] = gRandom->Gaus(0, psi); - pars[4] = gRandom->Gaus(0, theta); - pars[5] = gRandom->Gaus(0, phi); + pars[0] = x; + pars[1] = y; + pars[2] = z; + pars[3] = psi; + pars[4] = theta; + pars[5] = phi; return std::move(pars); } diff --git a/Detectors/FIT/FV0/base/include/FV0Base/Geometry.h b/Detectors/FIT/FV0/base/include/FV0Base/Geometry.h index 3b50be7441ec2..ec87c07c57c45 100644 --- a/Detectors/FIT/FV0/base/include/FV0Base/Geometry.h +++ b/Detectors/FIT/FV0/base/include/FV0Base/Geometry.h @@ -133,6 +133,16 @@ class Geometry return o2::base::GeometryManager::getPNEntry(getDetID(), index); } + static std::string getDetectorRightSymName() + { + return sDetectorRightName + "_0"; + } + + static std::string getDetectorLeftSymName() + { + return sDetectorLeftName + "_1"; + } + /// Get the density of the PMTs. static constexpr float getPmtDensity() { @@ -143,6 +153,8 @@ class Geometry explicit Geometry(EGeoType initType); inline static const std::string sDetectorName = "FV0"; + inline static const std::string sDetectorRightName = sDetectorName + "RIGHT"; + inline static const std::string sDetectorLeftName = sDetectorName + "LEFT"; // General geometry constants static constexpr float sEpsilon = 0.01; ///< Used to make one spatial dimension infinitesimally larger than other diff --git a/Detectors/FIT/FV0/macros/FV0Misaligner.C b/Detectors/FIT/FV0/macros/FV0Misaligner.C index 500bdaf565965..88f7a0b82b8b3 100644 --- a/Detectors/FIT/FV0/macros/FV0Misaligner.C +++ b/Detectors/FIT/FV0/macros/FV0Misaligner.C @@ -1,13 +1,32 @@ +// Copyright 2021-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file FV0Misaligner.C +/// \brief ROOT macro for creating an FV0 geometry alignment object. The alignment object will align both +/// detector halves in the same way. Based on ITSMisaligner.C +/// +/// \author Andreas Molander andreas.molander@cern.ch, Alla Maevskaya + #if !defined(__CLING__) || defined(__ROOTCLING__) + +#include "CCDB/CcdbApi.h" #include "DetectorsCommonDataFormats/DetID.h" #include "DetectorsCommonDataFormats/DetectorNameConf.h" #include "DetectorsCommonDataFormats/AlignParam.h" -#include "DetectorsBase/GeometryManager.h" -#include "CCDB/CcdbApi.h" -#include +#include "FV0Base/Geometry.h" + #include #include #include + #endif using AlgPar = std::array; @@ -20,16 +39,14 @@ void FV0Misaligner(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080" const std::string& fileName = "FV0Alignment.root") { std::vector params; - o2::base::GeometryManager::loadGeometry("", false); AlgPar pars; bool glo = true; o2::detectors::DetID detFV0("FV0"); - // FV0 detector - for (int ihalf = 1; ihalf < 3; ihalf++) { - std::string symName = Form("FV0half_%i", ihalf); - pars = generateMisalignment(x, y, z, psi, theta, phi); + pars = generateMisalignment(x, y, z, psi, theta, phi); + + for (auto& symName : {o2::fv0::Geometry::getDetectorRightSymName(), o2::fv0::Geometry::getDetectorLeftSymName()}) { params.emplace_back(symName.c_str(), -1, pars[0], pars[1], pars[2], pars[3], pars[4], pars[5], glo); } @@ -50,14 +67,15 @@ void FV0Misaligner(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080" algFile.Close(); } } + AlgPar generateMisalignment(double x, double y, double z, double psi, double theta, double phi) { AlgPar pars; - pars[0] = gRandom->Gaus(0, x); - pars[1] = gRandom->Gaus(0, y); - pars[2] = gRandom->Gaus(0, z); - pars[3] = gRandom->Gaus(0, psi); - pars[4] = gRandom->Gaus(0, theta); - pars[5] = gRandom->Gaus(0, phi); + pars[0] = x; + pars[1] = y; + pars[2] = z; + pars[3] = psi; + pars[4] = theta; + pars[5] = phi; return std::move(pars); } diff --git a/Detectors/FIT/FV0/simulation/src/Detector.cxx b/Detectors/FIT/FV0/simulation/src/Detector.cxx index 8cf1f5530e93d..07eb9053bf3b8 100644 --- a/Detectors/FIT/FV0/simulation/src/Detector.cxx +++ b/Detectors/FIT/FV0/simulation/src/Detector.cxx @@ -280,6 +280,7 @@ void Detector::ConstructGeometry() // mGeometry->enableComponent(Geometry::eAluminiumContainer, false); mGeometry->buildGeometry(); } + void Detector::addAlignableVolumes() const { // @@ -292,19 +293,19 @@ void Detector::addAlignableVolumes() const LOG(info) << "FV0: Add alignable volumes"; if (!gGeoManager) { - LOG(fatal) << "TGeoManager doesn't exist !"; + LOG(fatal) << "TGeoManager doesn't exist!"; return; } - TString volPath, symName; - for (auto& half : {"RIGHT_0", "LEFT_1"}) { - volPath = Form("/cave_1/barrel_1/FV0_1/FV0%s", half); - symName = Form("FV0%s", half); - LOG(info) << "FV0: Add alignable volume: " << symName << ": " << volPath; - if (!gGeoManager->SetAlignableEntry(symName.Data(), volPath.Data())) { - LOG(fatal) << "FV0: Unable to set alignable entry! " << symName << ": " << volPath; + auto addAlignabelVolume = [](const std::string& volPath, const std::string& symName) -> void { + LOG(info) << "FV0: Add alignable volume: " << symName << " <-> " << volPath; + if (!gGeoManager->SetAlignableEntry(symName.c_str(), volPath.c_str())) { + LOG(fatal) << "FV0: Unable to set alignable entry! " << symName << " <-> " << volPath; } - } + }; + + addAlignabelVolume("/cave_1/barrel_1/FV0_1/FV0RIGHT_0", Geometry::getDetectorRightSymName()); + addAlignabelVolume("/cave_1/barrel_1/FV0_1/FV0LEFT_1", Geometry::getDetectorLeftSymName()); } o2::fv0::Hit* Detector::addHit(Int_t trackId, Int_t cellId, diff --git a/Detectors/FIT/macros/CMakeLists.txt b/Detectors/FIT/macros/CMakeLists.txt index e7debb4184325..a6bf1799a5dde 100644 --- a/Detectors/FIT/macros/CMakeLists.txt +++ b/Detectors/FIT/macros/CMakeLists.txt @@ -45,5 +45,9 @@ o2_add_test_root_macro(compareRecPoints.C O2::DataFormatsFIT LABELS fit) +o2_add_test_root_macro(readAlignParam.C + PUBLIC_LINK_LIBRARIES O2::CCDB + LABELS fit) + o2_data_file(COPY readFITDCSdata.C DESTINATION Detectors/FIT/macros/) o2_data_file(COPY readFITDeadChannelMap.C DESTINATION Detectors/FIT/macros/) \ No newline at end of file diff --git a/Detectors/FIT/macros/readAlignParam.C b/Detectors/FIT/macros/readAlignParam.C new file mode 100644 index 0000000000000..c438e7a0c86a5 --- /dev/null +++ b/Detectors/FIT/macros/readAlignParam.C @@ -0,0 +1,51 @@ +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file readAlignParam.C +/// \brief ROOT macro for reading geometry alignment parameters +/// +/// \author Andreas Molander + +#if !defined(__CLING__) || defined(__ROOTCLING__) + +#include "CCDB/BasicCCDBManager.h" +#include "DetectorsCommonDataFormats/AlignParam.h" +#include "DetectorsCommonDataFormats/DetID.h" +#include "DetectorsCommonDataFormats/DetectorNameConf.h" + +#include +#include + +#endif + +int readAlignParam(const std::string& detectorName = "FT0", + long timestamp = -1, + const std::string& ccdbUrl = "https://alice-ccdb.cern.ch") +{ + o2::ccdb::BasicCCDBManager& ccdbManager = o2::ccdb::BasicCCDBManager::instance(); + ccdbManager.setURL(ccdbUrl); + ccdbManager.setTimestamp(timestamp); + + const o2::detectors::DetID detID(detectorName.c_str()); + const std::string alignmentPath = o2::base::DetectorNameConf::getAlignmentPath(detID); + const auto alignments = ccdbManager.get>(alignmentPath); + + if (!alignments) { + std::cerr << "No alignment parameters found at " << alignmentPath << std::endl; + return 1; + } + + for (auto alignment : *alignments) { + alignment.print(); + } + + return 0; +} \ No newline at end of file diff --git a/Detectors/FIT/macros/readFT0hits.C b/Detectors/FIT/macros/readFT0hits.C index 14d25fa4a99a8..fafcaac570311 100644 --- a/Detectors/FIT/macros/readFT0hits.C +++ b/Detectors/FIT/macros/readFT0hits.C @@ -1,13 +1,29 @@ +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + #if !defined(__CLING__) || defined(__ROOTCLING__) + +#include "DataFormatsFIT/Triggers.h" #include "DataFormatsFT0/Digit.h" #include "DataFormatsFT0/HitType.h" #include "SimulationDataFormat/MCEventHeader.h" #include +#include #include #include #include "DetectorsCommonDataFormats/DetID.h" #include "DetectorsCommonDataFormats/DetectorNameConf.h" +#endif + void readFT0hits() { @@ -24,6 +40,8 @@ void readFT0hits() TH2F* hPel = new TH2F("hPelDig", "N p.e. ", 220, 0, 220, 500, 0, 10000); TH2F* hXYA = new TH2F("hXYA", "X vs Y A side", 400, -20, 20, 400, -20, 20); TH2F* hXYC = new TH2F("hXYC", "X vs Y C side", 400, -20, 20, 400, -20, 20); + TH1F* hZA = new TH1F("hZA", "Z A side", 200, 330, 340); + TH1F* hZC = new TH1F("hZC", "Z C side", 200, -90, -80); gDirectory = cwd; @@ -59,10 +77,13 @@ void readFT0hits() hTimeHitA->Fill(detID, hit_time[detID] - 11.04); hTimeHitC->Fill(detID, hit_time[detID] - 2.91); countE[detID]++; - if (detID < 96) + if (detID < 96) { hXYA->Fill(hit.GetX(), hit.GetY()); - if (detID > 95) + hZA->Fill(hit.GetZ()); + } else { hXYC->Fill(hit.GetX(), hit.GetY()); + hZC->Fill(hit.GetZ()); + } } for (int ii = 0; ii < 220; ii++) { if (countE[ii] > 100) { @@ -82,6 +103,6 @@ void readFT0hits() hMultHit->Write(); hXYA->Write(); hXYC->Write(); - + hZA->Write(); + hZC->Write(); } // end of macro -#endif diff --git a/Detectors/FIT/macros/readFV0hits.C b/Detectors/FIT/macros/readFV0hits.C index 5b0dfa8428dc7..933138fb1434b 100644 --- a/Detectors/FIT/macros/readFV0hits.C +++ b/Detectors/FIT/macros/readFV0hits.C @@ -1,3 +1,14 @@ +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + #if !defined(__CLING__) || defined(__ROOTCLING__) #include @@ -22,6 +33,8 @@ #include "DetectorsCommonDataFormats/DetectorNameConf.h" #include "DetectorsCommonDataFormats/DetID.h" +#endif + void AdjustStatBox(TH1* h, float x1ndc, float x2ndc, float y1ndc, float y2ndc) { gPad->Update(); @@ -54,6 +67,9 @@ void InitHistoNames(std::vector& vhName, std::vector& vPdg) vhName.push_back("hElossDet"); vhName.push_back("hEtotVsR"); vhName.push_back("hEtotVsEloss"); + vhName.push_back("hXY"); + vhName.push_back("hXYzoom"); + vhName.push_back("hZ"); for (UInt_t ipdg = 0; ipdg < vPdg.size(); ipdg++) { std::stringstream ss; @@ -63,7 +79,7 @@ void InitHistoNames(std::vector& vhName, std::vector& vPdg) } } -void readFV0Hits(std::string simPrefix = "o2sim", UInt_t rebin = 1) +void readFV0hits(std::string simPrefix = "o2sim", UInt_t rebin = 1) { using namespace o2::detectors; std::string simFName(o2::base::DetectorNameConf::getHitsFileName(DetID::FV0, simPrefix)); @@ -85,6 +101,9 @@ void readFV0Hits(std::string simPrefix = "o2sim", UInt_t rebin = 1) TH2F* hElossDet = new TH2F(vHistoNames.at(8).c_str(), "", nEl, 0, el1, nCells, 0, nCells); TH2F* hEtotVsR = new TH2F(vHistoNames.at(9).c_str(), "", 30000, 0, 300, 80, 0, 80); TH2F* hEtotVsEloss = new TH2F(vHistoNames.at(10).c_str(), "", 30000, 0, 300, nEl, 0, el1); + TH2F* hXY = new TH2F(vHistoNames.at(11).c_str(), "", 200, -100, 100, 200, -100, 100); + TH2F* hXYzoom = new TH2F(vHistoNames.at(12).c_str(), "", 200, -20, 20, 200, -20, 20); + TH1F* hZ = new TH1F(vHistoNames.at(13).c_str(), "", 200, 315, 325); // Setup histo properties hElossDet->SetXTitle("Energy loss [MeV]"); @@ -96,6 +115,14 @@ void readFV0Hits(std::string simPrefix = "o2sim", UInt_t rebin = 1) hEtotVsEloss->SetXTitle("Total energy at entrance [MeV]"); hEtotVsEloss->SetYTitle("Energy loss [MeV]"); hEtotVsEloss->SetZTitle("Counts"); + hXY->SetXTitle("X [cm]"); + hXY->SetYTitle("Y [cm]"); + hXY->SetZTitle("Counts"); + hXYzoom->SetXTitle("X [cm]"); + hXYzoom->SetYTitle("Y [cm]"); + hXYzoom->SetZTitle("Counts"); + hZ->SetXTitle("Hit Z-coordinate [cm]"); + hZ->SetYTitle("Counts"); for (UInt_t ih = 0; ih < vhElossVsDistance.size(); ih++) { TH2F* h = vhElossVsDistance.at(ih); std::stringstream ss; @@ -124,6 +151,9 @@ void readFV0Hits(std::string simPrefix = "o2sim", UInt_t rebin = 1) vh.push_back(hEtotVsEloss); vh.insert(vh.end(), vhElossVsDistance.begin(), vhElossVsDistance.end()); vh.insert(vh.end(), vhElossVsEtot.begin(), vhElossVsEtot.end()); + vh.push_back(hXY); + vh.push_back(hXYzoom); + vh.push_back(hZ); for (UInt_t ih = 0; ih < vh.size(); ih++) { vh[ih]->SetDirectory(0); vh[ih]->GetXaxis()->SetTitleSize(fontsize); @@ -177,6 +207,9 @@ void readFV0Hits(std::string simPrefix = "o2sim", UInt_t rebin = 1) vhElossVsDistance.at(vhElossVsDistance.size() - 1)->Fill(hit->GetEnergyLoss() * 1e3, distance); vhElossVsEtot.at(vhElossVsEtot.size() - 1)->Fill(hit->GetEnergyLoss() * 1e3, hit->GetTotalEnergyAtEntrance() * 1e3); } + hXY->Fill(hit->GetX(), hit->GetY()); + hXYzoom->Fill(hit->GetX(), hit->GetY()); + hZ->Fill(hit->GetZ()); } } @@ -323,5 +356,3 @@ int compareFV0Hits(std::string simFName1 = "fv0hit-rawhistos.root", std::string } return 0; } - -#endif diff --git a/Detectors/Upgrades/ALICE3/CMakeLists.txt b/Detectors/Upgrades/ALICE3/CMakeLists.txt index 0c2bbe5e02a47..0cd027e9bf8e0 100644 --- a/Detectors/Upgrades/ALICE3/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/CMakeLists.txt @@ -12,10 +12,11 @@ add_subdirectory(Passive) add_subdirectory(TRK) add_subdirectory(ECal) +add_subdirectory(FD) add_subdirectory(FT3) add_subdirectory(FCT) add_subdirectory(AOD) add_subdirectory(IOTOF) add_subdirectory(RICH) add_subdirectory(MID) -add_subdirectory(macros) \ No newline at end of file +add_subdirectory(macros) diff --git a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt new file mode 100644 index 0000000000000..3dde618f9d57a --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +add_subdirectory(base) +add_subdirectory(simulation) diff --git a/Detectors/Upgrades/ALICE3/FD/README.md b/Detectors/Upgrades/ALICE3/FD/README.md new file mode 100644 index 0000000000000..53264cb89914a --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/README.md @@ -0,0 +1,10 @@ + + +# ALICE 3 FORVARD DETECTOR + +This is top page for the FD detector documentation. + + diff --git a/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt new file mode 100644 index 0000000000000..65de538eb0ea1 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +o2_add_library(FDBase + SOURCES src/GeometryTGeo.cxx + src/FDBaseParam.cxx + PUBLIC_LINK_LIBRARIES O2::DetectorsBase) + +o2_target_root_dictionary(FDBase + HEADERS include/FDBase/GeometryTGeo.h + include/FDBase/Constants.h + include/FDBase/FDBaseParam.h) diff --git a/Detectors/Upgrades/ALICE3/FD/base/README.md b/Detectors/Upgrades/ALICE3/FD/base/README.md new file mode 100644 index 0000000000000..1fba33c47b690 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/base/README.md @@ -0,0 +1,17 @@ + + +# FV0 Base + +## Geometry + +The `o2::fv0::Geometry` class represents the geometry of the FV0 detector as used in simulation. It also provides utility methods for retrieving the center locations of the detector cells. See the below example for how to use the `Geometry` class to query the FV0 cell locations. Note that these are the ideal locations, and that any misalignment is not considered. + +```cpp +o2::fv0::Geometry* fv0Geometry = o2::fv0::Geometry::instance(o2::fv0::Geometry::eUninitialized); +o2::fv0::Point3Dsimple cellPosition = fv0Geometry->getReadoutCenter(chId); +float x = cellPosition.x; +float y = cellPosition.y; +float z = cellPosition.z; +``` diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h new file mode 100644 index 0000000000000..687fa52143039 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h @@ -0,0 +1,38 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file Constants.h +/// \brief General constants in FV0 +/// +/// \author Maciej Slupecki, University of Jyvaskyla, Finland + +#ifndef ALICEO2_FD_CONSTANTS_ +#define ALICEO2_FD_CONSTANTS_ + +namespace o2 +{ +namespace fd +{ +struct Constants { + static constexpr unsigned int nsect = 8; + static constexpr unsigned int nringsA = 5; + static constexpr unsigned int nringsC = 6; + + static constexpr float etaMax = 7.0f; + static constexpr float etaMin = 4.0f; + + static constexpr unsigned int nringsA_withMG = 3; + static constexpr float etaMinA_withMG = 5.0f; +}; + +} // namespace fd +} // namespace o2 +#endif diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h new file mode 100644 index 0000000000000..3a00597b1e88a --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h @@ -0,0 +1,37 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifndef ALICEO2_FD_FDBASEPARAM_ +#define ALICEO2_FD_FDBASEPARAM_ + +#include "FDBase/GeometryTGeo.h" +#include "FDBase/Constants.h" +#include "CommonUtils/ConfigurableParamHelper.h" + +namespace o2 +{ +namespace fd +{ +struct FDBaseParam : public o2::conf::ConfigurableParamHelper { + + float zmodA = 1700.0f; + float zmodC = -1850.0f; + float dzscint = 4.0f; + + bool withMG = false; // modified geometry + + O2ParamDef(FDBaseParam, "FDBase"); +}; + +} // namespace fd +} // namespace o2 + +#endif diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h new file mode 100644 index 0000000000000..1c39e01b43f2e --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h @@ -0,0 +1,54 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +#ifndef ALICEO2_FD_GEOMETRYTGEO_H_ +#define ALICEO2_FD_GEOMETRYTGEO_H_ + +#include + +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsCommonDataFormats/DetID.h" +#include +#include +#include +#include +#include +#include +#include + +namespace o2 +{ +namespace fd +{ + +/// FD Geometry type +class GeometryTGeo : public o2::detectors::DetMatrixCache +{ + public: + GeometryTGeo(bool build = false, int loadTrans = 0); + + void Build(int loadTrans); + void fillMatrixCache(int mask); + virtual ~GeometryTGeo(); + + static GeometryTGeo* Instance(); + + void getGlobalPosition(float& x, float& y, float& z); + + static constexpr o2::detectors::DetID::ID getDetID() { return o2::detectors::DetID::FD; } + + private: + static std::unique_ptr sInstance; + + ClassDefNV(GeometryTGeo, 1); +}; +} // namespace fd +} // namespace o2 +#endif diff --git a/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h b/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h new file mode 100644 index 0000000000000..208667adbf818 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h @@ -0,0 +1,23 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::fd::Constants + ; +#pragma link C++ class o2::fd::GeometryTGeo + ; +#pragma link C++ class o2::fd::FDBaseParam + ; +#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::fd::FDBaseParam> + ; + +#endif diff --git a/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx b/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx new file mode 100644 index 0000000000000..576e76b7b796c --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx @@ -0,0 +1,14 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "FDBase/FDBaseParam.h" + +O2ParamImpl(o2::fd::FDBaseParam); diff --git a/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx new file mode 100644 index 0000000000000..69c40fd42b876 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx @@ -0,0 +1,66 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "FDBase/GeometryTGeo.h" +#include "FDBase/FDBaseParam.h" + +#include + +#include + +using namespace o2::fd; +namespace o2 +{ +namespace fd +{ + +std::unique_ptr GeometryTGeo::sInstance; + +GeometryTGeo::GeometryTGeo(bool build, int loadTrans) : DetMatrixCache() +{ + if (sInstance) { + LOGP(fatal, "Invalid use of public constructor: o2::fd::GeometryTGeo instance exists"); + } + if (build) { + Build(loadTrans); + } +} + +GeometryTGeo::~GeometryTGeo() = default; + +GeometryTGeo* GeometryTGeo::Instance() +{ + if (!sInstance) { + sInstance = std::unique_ptr(new GeometryTGeo(true, 0)); + } + return sInstance.get(); +} + +void GeometryTGeo::Build(int loadTrans) +{ + if (isBuilt()) { + LOGP(warning, "Already built"); + return; // already initialized + } + + if (!gGeoManager) { + LOGP(fatal, "Geometry is not loaded"); + } + + fillMatrixCache(loadTrans); +} + +void GeometryTGeo::fillMatrixCache(int mask) +{ +} + +} // namespace fd +} // namespace o2 diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt new file mode 100644 index 0000000000000..c17b0244ae9e1 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +o2_add_library(FDSimulation + SOURCES src/Detector.cxx + PUBLIC_LINK_LIBRARIES O2::FDBase + O2::ITSMFTSimulation + ROOT::Physics) + +o2_target_root_dictionary(FDSimulation + HEADERS include/FDSimulation/Detector.h) diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h new file mode 100644 index 0000000000000..482935f9198e5 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h @@ -0,0 +1,152 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file Detector.h +/// \brief Definition of the Detector class + +#ifndef ALICEO2_FD_DETECTOR_H_ +#define ALICEO2_FD_DETECTOR_H_ + +#include "SimulationDataFormat/BaseHits.h" +#include "DetectorsBase/Detector.h" +#include "FDBase/GeometryTGeo.h" +#include "FDBase/FDBaseParam.h" +#include "ITSMFTSimulation/Hit.h" +#include "Rtypes.h" +#include "TGeoManager.h" +#include "TLorentzVector.h" +#include "TVector3.h" + +class FairVolume; +class TGeoVolume; + +namespace o2 +{ +namespace fd +{ +class GeometryTGeo; +} +} // namespace o2 + +namespace o2 +{ +namespace fd +{ + +class Detector : public o2::base::DetImpl +{ + public: + Detector(bool Active); + + Detector() = default; + + ~Detector() override; + + void ConstructGeometry() override; + + /// This method is an example of how to add your own point of type Hit to the clones array + o2::itsmft::Hit* addHit(int trackID, int detID, + const TVector3& startPos, + const TVector3& endPos, + const TVector3& startMom, + double startE, + double endTime, double eLoss, + unsigned int startStatus, + unsigned int endStatus); + + std::vector* getHits(Int_t iColl) + { + if (iColl == 0) { + return mHits; + } + return nullptr; + } + + // Mandatory overrides + void BeginPrimary() override { ; } + void FinishPrimary() override { ; } + void InitializeO2Detector() override; + void PostTrack() override { ; } + void PreTrack() override { ; } + bool ProcessHits(FairVolume* v = nullptr) override; + void EndOfEvent() override; + void Register() override; + void Reset() override; + + void createMaterials(); + void buildModules(); + + enum EMedia { + Scintillator, + }; + + private: + Detector(const Detector&); + Detector& operator=(const Detector&); + + std::vector* mHits = nullptr; + GeometryTGeo* mGeometryTGeo = nullptr; + + TGeoVolumeAssembly* buildModuleA(); + TGeoVolumeAssembly* buildModuleC(); + + float ringRadius(float zmod, float eta); + + unsigned int mNumberOfSectors; + unsigned int mNumberOfRingsA; + unsigned int mNumberOfRingsC; + float mDzScint; + + std::vector mRingRadiiA = {}; + std::vector mRingRadiiC = {}; + + float mEtaMaxA, mEtaMaxC; + float mEtaMinA, mEtaMinC; + float mZmodA, mZmodC; + + void defineSensitiveVolumes(); + + unsigned int getChannelId(TVector3 vec); + + /// Transient data about track passing the sensor, needed by ProcessHits() + struct TrackData { // this is transient + bool mHitStarted; //! hit creation started + unsigned char mTrkStatusStart; //! track status flag + TLorentzVector mPositionStart; //! position at entrance + TLorentzVector mMomentumStart; //! momentum + double mEnergyLoss; //! energy loss + } mTrackData; //! + + template + friend class o2::base::DetImpl; + ClassDefOverride(Detector, 1); +}; + +// Input and output function for standard C++ input/output. +std::ostream& operator<<(std::ostream& os, Detector& source); +std::istream& operator>>(std::istream& os, Detector& source); + +} // namespace fd +} // namespace o2 + +#ifdef USESHM +namespace o2 +{ +namespace base +{ +template <> +struct UseShm { + static constexpr bool value = true; +}; +} // namespace base +} // namespace o2 +#endif +#endif diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx new file mode 100644 index 0000000000000..536a936f6a53e --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -0,0 +1,410 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file Detector.cxx +/// \brief Implementation of the Detector class + +#include "ITSMFTSimulation/Hit.h" +#include "FDSimulation/Detector.h" +#include "FDBase/GeometryTGeo.h" +#include "FDBase/FDBaseParam.h" +#include "FDBase/Constants.h" + +#include "DetectorsBase/Stack.h" +#include "SimulationDataFormat/TrackReference.h" +#include "Field/MagneticField.h" + +// FairRoot includes +#include "FairDetector.h" +#include +#include "FairRootManager.h" +#include "FairRun.h" +#include "FairRuntimeDb.h" +#include "FairVolume.h" +#include "FairRootManager.h" + +#include "TVirtualMC.h" +#include "TLorentzVector.h" +#include "TVector3.h" +#include +#include +#include +#include +#include +#include +#include "TRandom.h" + +class FairModule; + +class TGeoMedium; + +using namespace o2::fd; +using o2::itsmft::Hit; + +Detector::Detector(bool active) + : o2::base::DetImpl("FD", true), + mHits(o2::utils::createSimVector()), + mGeometryTGeo(nullptr), + mTrackData() +{ + mNumberOfRingsC = Constants::nringsC; + mNumberOfSectors = Constants::nsect; + + mEtaMinA = Constants::etaMin; + mEtaMaxA = Constants::etaMax; + mEtaMinC = -Constants::etaMax; + mEtaMaxC = -Constants::etaMin; + + auto& baseParam = FDBaseParam::Instance(); + + if (baseParam.withMG) { + mNumberOfRingsA = Constants::nringsA_withMG; + mEtaMinA = Constants::etaMinA_withMG; + } else { + mNumberOfRingsA = Constants::nringsA; + mEtaMinA = Constants::etaMin; + } + + mDzScint = baseParam.dzscint / 2; + + mZmodA = baseParam.zmodA; + mZmodC = baseParam.zmodC; + + for (int i = 0; i <= mNumberOfRingsA + 1; i++) { + float eta = mEtaMaxA - i * (mEtaMaxA - mEtaMinA) / mNumberOfRingsA; + float r = ringRadius(mZmodA, eta); + mRingRadiiA.emplace_back(r); + } + + for (int i = 0; i <= mNumberOfRingsC + 1; i++) { + float eta = mEtaMinC + i * (mEtaMaxC - mEtaMinC) / mNumberOfRingsC; + float r = ringRadius(mZmodC, eta); + mRingRadiiC.emplace_back(r); + } +} + +Detector::Detector(const Detector& rhs) + : o2::base::DetImpl(rhs), + mTrackData(), + mHits(o2::utils::createSimVector()) +{ +} + +Detector& Detector::operator=(const Detector& rhs) +{ + + if (this == &rhs) { + return *this; + } + // base class assignment + base::Detector::operator=(rhs); + mTrackData = rhs.mTrackData; + + mHits = nullptr; + return *this; +} + +Detector::~Detector() +{ + + if (mHits) { + o2::utils::freeSimVector(mHits); + } +} + +void Detector::InitializeO2Detector() +{ + LOG(info) << "Initialize FD detector"; + mGeometryTGeo = GeometryTGeo::Instance(); + defineSensitiveVolumes(); +} + +bool Detector::ProcessHits(FairVolume* vol) +{ + // This method is called from the MC stepping + if (!(fMC->TrackCharge())) { + return kFALSE; + } + + auto stack = (o2::data::Stack*)fMC->GetStack(); + + // int cellId = vol->getVolumeId(); + + // Check track status to define when hit is started and when it is stopped + bool startHit = false, stopHit = false; + unsigned char status = 0; + if (fMC->IsTrackEntering()) { + status |= Hit::kTrackEntering; + } + if (fMC->IsTrackInside()) { + status |= Hit::kTrackInside; + } + if (fMC->IsTrackExiting()) { + status |= Hit::kTrackExiting; + } + if (fMC->IsTrackOut()) { + status |= Hit::kTrackOut; + } + if (fMC->IsTrackStop()) { + status |= Hit::kTrackStopped; + } + if (fMC->IsTrackAlive()) { + status |= Hit::kTrackAlive; + } + + // track is entering or created in the volume + if ((status & Hit::kTrackEntering) || (status & Hit::kTrackInside && !mTrackData.mHitStarted)) { + startHit = true; + } else if ((status & (Hit::kTrackExiting | Hit::kTrackOut | Hit::kTrackStopped))) { + stopHit = true; + } + + // increment energy loss at all steps except entrance + if (!startHit) { + mTrackData.mEnergyLoss += fMC->Edep(); + } + if (!(startHit | stopHit)) { + return kFALSE; // do noting + } + + if (startHit) { + mTrackData.mHitStarted = true; + mTrackData.mEnergyLoss = 0.; + fMC->TrackMomentum(mTrackData.mMomentumStart); + fMC->TrackPosition(mTrackData.mPositionStart); + mTrackData.mTrkStatusStart = true; + } + + if (stopHit) { + TLorentzVector positionStop; + fMC->TrackPosition(positionStop); + int trackId = stack->GetCurrentTrackNumber(); + unsigned int chId = getChannelId(mTrackData.mPositionStart.Vect()); + + Hit* p = addHit(trackId, chId /*cellId*/, mTrackData.mPositionStart.Vect(), positionStop.Vect(), + mTrackData.mMomentumStart.Vect(), mTrackData.mMomentumStart.E(), + positionStop.T(), mTrackData.mEnergyLoss, mTrackData.mTrkStatusStart, + status); + stack->addHit(GetDetId()); + } else { + return false; // do nothing more + } + return true; +} + +o2::itsmft::Hit* Detector::addHit(int trackId, int cellId, + const TVector3& startPos, + const TVector3& endPos, + const TVector3& startMom, + double startE, + double endTime, + double eLoss, + unsigned int startStatus, + unsigned int endStatus) +{ + mHits->emplace_back(trackId, cellId, startPos, + endPos, startMom, startE, endTime, eLoss, startStatus, endStatus); + return &(mHits->back()); +} + +void Detector::ConstructGeometry() +{ + createMaterials(); + buildModules(); +} + +void Detector::EndOfEvent() +{ + Reset(); +} + +void Detector::Register() +{ + // This will create a branch in the output tree called Hit, setting the last + // parameter to kFALSE means that this collection will not be written to the file, + // it will exist only during the simulation + + if (FairRootManager::Instance()) { + FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE); + } +} + +void Detector::Reset() +{ + if (!o2::utils::ShmManager::Instance().isOperational()) { + mHits->clear(); + } +} + +void Detector::createMaterials() +{ + + float density, as[11], zs[11], ws[11]; + double radLength, absLength, a_ad, z_ad; + int id; + + // EJ-204 scintillator, based on polyvinyltoluene + const int nScint = 2; + float aScint[nScint] = {1.00784, 12.0107}; + float zScint[nScint] = {1, 6}; + float wScint[nScint] = {0.07085, 0.92915}; // based on EJ-204 datasheet: n_atoms/cm3 + const float dScint = 1.023; + + int matId = 0; // tmp material id number + const int unsens = 0, sens = 1; // sensitive or unsensitive medium + // + int fieldType = 3; // Field type + float maxField = 5.0; // Field max. + + float tmaxfd = -10.0; // max deflection angle due to magnetic field in one step + float stemax = 0.1; // max step allowed [cm] + float deemax = 1.0; // maximum fractional energy loss in one step 0GetVolume("cave"); + + if (!vCave) { + LOG(fatal) << "Could not find the top volume (cave)!"; + } + + TGeoVolumeAssembly* vFDA = buildModuleA(); + TGeoVolumeAssembly* vFDC = buildModuleC(); + + vCave->AddNode(vFDA, 1, new TGeoTranslation(0., 0., mZmodA /* - mDzScint/2.*/)); + vCave->AddNode(vFDC, 1, new TGeoTranslation(0., 0., mZmodC /* + mDzScint/2.*/)); +} + +TGeoVolumeAssembly* Detector::buildModuleA() +{ + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FDA"); + + const TGeoMedium* medium = gGeoManager->GetMedium("FD_Scintillator"); + + float dphiDeg = 360. / mNumberOfSectors; + + for (int ir = 0; ir < mNumberOfRingsA; ir++) { + std::string rName = "fd_ring" + std::to_string(ir + 1); + TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); + float rmin = mRingRadiiA[ir]; + float rmax = mRingRadiiA[ir + 1]; + LOG(info) << "ring" << ir << ": from " << rmin << " to " << rmax; + for (int ic = 0; ic < mNumberOfSectors; ic++) { + int cellId = ic + mNumberOfSectors * ir; + std::string nodeName = "fd_node" + std::to_string(cellId); + float phimin = dphiDeg * ic; + float phimax = dphiDeg * (ic + 1); + auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + nod->SetLineColor(kRed); + ring->AddNode(nod, cellId); + } + mod->AddNode(ring, 1); + } + + return mod; +} + +TGeoVolumeAssembly* Detector::buildModuleC() +{ + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FDC"); + + const TGeoMedium* medium = gGeoManager->GetMedium("FD_Scintillator"); + + float dphiDeg = 360. / mNumberOfSectors; + + for (int ir = 0; ir < mNumberOfRingsC; ir++) { + std::string rName = "fd_ring" + std::to_string(ir + 1 + mNumberOfRingsA); + TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); + float rmin = mRingRadiiC[ir]; + float rmax = mRingRadiiC[ir + 1]; + LOG(info) << "ring" << ir + mNumberOfRingsA << ": from " << rmin << " to " << rmax; + for (int ic = 0; ic < mNumberOfSectors; ic++) { + int cellId = ic + mNumberOfSectors * (ir + mNumberOfRingsA); + std::string nodeName = "fd_node" + std::to_string(cellId); + float phimin = dphiDeg * ic; + float phimax = dphiDeg * (ic + 1); + auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); + auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); + nod->SetLineColor(kBlue); + ring->AddNode(nod, cellId); + } + mod->AddNode(ring, 1); + } + + return mod; +} + +void Detector::defineSensitiveVolumes() +{ + LOG(info) << "Adding FD Sentitive Volumes"; + + TGeoVolume* v; + TString volumeName; + + int nCellA = mNumberOfRingsA * mNumberOfSectors; + int nCellC = mNumberOfRingsC * mNumberOfSectors; + + LOG(info) << "number of A rings = " << mNumberOfRingsA << " number of cells = " << nCellA; + + for (int iv = 0; iv < nCellA + nCellC; iv++) { + volumeName = "fd_node" + std::to_string(iv); + v = gGeoManager->GetVolume(volumeName); + LOG(info) << "Adding FD Sensitive Volume => " << v->GetName(); + AddSensitiveVolume(v); + } +} + +unsigned int Detector::getChannelId(TVector3 vec) +{ + float phi = vec.Phi(); + if (phi < 0) { + phi += TMath::TwoPi(); + } + + float r = vec.Perp(); + float z = vec.Z(); + + int isect = int(phi / (TMath::TwoPi() / mNumberOfSectors)); + + std::vector rd = z > 0 ? mRingRadiiA : mRingRadiiC; + int noff = z > 0 ? 0 : mNumberOfRingsA * mNumberOfSectors; + + int ir = 0; + + for (int i = 1; i < rd.size(); i++) { + if (r < rd[i]) { + break; + } else { + ir++; + } + } + + return ir * mNumberOfSectors + isect + noff; +} + +float Detector::ringRadius(float z, float eta) +{ + return z * TMath::Tan(2 * TMath::ATan(TMath::Exp(-eta))); +} + +ClassImp(o2::fd::Detector); diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h b/Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h new file mode 100644 index 0000000000000..3071b7811b154 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h @@ -0,0 +1,21 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::fd::Detector + ; +#pragma link C++ class o2::base::DetImpl < o2::fd::Detector> + ; + +#endif diff --git a/Framework/Core/include/Framework/DeviceControl.h b/Framework/Core/include/Framework/DeviceControl.h index ce946e8e77fbf..03889c00f6cf9 100644 --- a/Framework/Core/include/Framework/DeviceControl.h +++ b/Framework/Core/include/Framework/DeviceControl.h @@ -52,6 +52,8 @@ struct DeviceControl { int logStreams = 0; /// An incremental number to identify the device state int requestedState = 0; + /// The first window in the records buffer to display in GUI + int firstWnd = 1; }; } // namespace o2::framework diff --git a/Framework/Core/include/Framework/PluginManager.h b/Framework/Core/include/Framework/PluginManager.h index d6b16f01ad713..96281942e667d 100644 --- a/Framework/Core/include/Framework/PluginManager.h +++ b/Framework/Core/include/Framework/PluginManager.h @@ -87,7 +87,7 @@ struct PluginManager { #else auto libraryName = fmt::format("lib{}.so", loadablePlugin.library); #endif - auto ret = uv_dlopen(libraryName.c_str(), &handle); + auto ret = uv_dlopen(loadablePlugin.library.empty() ? nullptr : libraryName.c_str(), &handle); if (ret != 0) { LOGP(error, "Could not load library {}", loadablePlugin.library); LOG(error) << uv_dlerror(&handle); diff --git a/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx b/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx index 8e683d46131ea..c39e268fa90a7 100644 --- a/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx +++ b/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx @@ -17,8 +17,7 @@ #include "Framework/DataProcessingStates.h" #include "InspectorHelpers.h" #include "PaletteHelpers.h" -#include "Framework/Logger.h" -#include +#include "FrameworkGUIDataRelayerUsage.h" #include #include @@ -27,11 +26,11 @@ static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return Im namespace o2::framework::gui { - // This is to display the information in the data relayer struct HeatMapHelper { template - static void draw(const char* name, + static void draw(const char* /*name*/, + int& v, ImVec2 const& sizeHint, std::function const& getNumInputs, std::function const& getNumRecords, @@ -42,21 +41,69 @@ struct HeatMapHelper { std::function const& getColor, std::function const& describeCell) { - ImVec2 size = ImVec2(sizeHint.x, std::min(sizeHint.y, 16.f * getNumItems(0) + 2)); - ImU32 BORDER_COLOR = ImColor(200, 200, 200, 255); - ImU32 BACKGROUND_COLOR = ImColor(20, 20, 20, 255); + float padding = 1; + // add slider to scroll between the grid display windows + size_t nw = getNumRecords() / WND; + ImGui::PushItemWidth(sizeHint.x); + ImGui::SliderInt("##window", &v, 1, nw, "wnd: %d", ImGuiSliderFlags_AlwaysClamp); + ImVec2 sliderMin = ImGui::GetItemRectMin(); + constexpr float MAX_BOX_X_SIZE = 16.f; constexpr float MAX_BOX_Y_SIZE = 16.f; + + ImVec2 size = ImVec2(sizeHint.x, std::min(sizeHint.y, MAX_BOX_Y_SIZE * getNumItems(0) + 2)); + ImU32 BORDER_COLOR = ImColor(200, 200, 200, 255); + ImU32 BACKGROUND_COLOR = ImColor(20, 20, 20, 255); + ImU32 BORDER_COLOR_A = ImColor(200, 200, 200, 0); + ImU32 BACKGROUND_COLOR_A = ImColor(0, 0, 0, 0); + ImDrawList* drawList = ImGui::GetWindowDrawList(); - ImVec2 winPos = ImGui::GetCursorScreenPos() + ImVec2{0, 7}; - auto records = getNumRecords(); - auto boxSizeX = std::min(size.x / records, MAX_BOX_X_SIZE); - auto numInputs = getNumInputs(); + ImVec2 winPos = sliderMin; + // overlay activity indicator on the slider + auto xsz = size.x / nw; + drawList->AddRectFilled( + ImVec2{0., 0.} + winPos, + ImVec2{size.x, size.y} + winPos, + BACKGROUND_COLOR_A); + drawList->AddRect( + ImVec2{0. - 1, -1} + winPos, + ImVec2{size.x + 1, size.y - 1} + winPos, + BORDER_COLOR_A); + + const static auto colorA = ImColor(ImVec4{0.945, 0.096, 0.278, 0.5}); + const static auto colorE = ImColor(ImVec4{0, 0, 0, 0}); + + drawList->PrimReserve(nw * 6, nw * 4); + for (size_t iw = 0; iw < nw; ++iw) { + ImVec2 xOffset{iw * xsz + 2 * padding, 0}; + ImVec2 xSize{xsz - 2 * padding, 0}; + ImVec2 yOffset{0, 2 * padding}; + ImVec2 ySize{0, 16 - 4 * padding}; + bool active = 0; + for (size_t ir = iw; ir < ((iw + WND > getNumRecords()) ? getNumRecords() : iw + WND); ++ir) { + for (size_t i = 0; i < getNumItems(ir); ++i) { + active = getValue(*getItem(ir, i)) > 0; + if (active) { + break; + } + } + } + drawList->PrimRect( + xOffset + yOffset + winPos, + xOffset + xSize + yOffset + ySize + winPos, + active ? colorA : colorE); + } + + // display the grid + size_t recordsWindow = v * WND; + auto boxSizeX = std::min(size.x / WND, MAX_BOX_X_SIZE); + auto numInputs = getNumInputs(); + winPos = ImGui::GetCursorScreenPos() + ImVec2{0, 7}; ImGui::InvisibleButton("sensible area", ImVec2(size.x, size.y)); if (ImGui::IsItemHovered()) { auto pos = ImGui::GetMousePos() - winPos; - auto slot = std::lround(std::trunc(pos.x / size.x * records)); + auto slot = (v - 1) * WND + std::lround(std::trunc(pos.x / size.x * WND)); auto row = std::lround(std::trunc(pos.y / size.y * numInputs)); describeCell(row, slot); } @@ -69,21 +116,21 @@ struct HeatMapHelper { ImVec2(0. - 1, -1) + winPos, ImVec2{size.x + 1, size.y - 1} + winPos, BORDER_COLOR); - float padding = 1; size_t totalRects = 0; - for (size_t ri = 0, re = getNumRecords(); ri < re; ri++) { + for (size_t ri = (v - 1) * WND; ri < recordsWindow; ri++) { auto record = getRecord(ri); totalRects += getNumItems(record); } drawList->PrimReserve(totalRects * 6, totalRects * 4); - for (size_t ri = 0, re = getNumRecords(); ri < re; ri++) { + for (size_t ri = (v - 1) * WND; ri < recordsWindow; ri++) { auto record = getRecord(ri); - ImVec2 xOffset{(ri * boxSizeX) + padding, 0}; + ImVec2 xOffset{((ri - (v - 1) * WND) * boxSizeX) + padding, 0}; ImVec2 xSize{boxSizeX - 2 * padding, 0}; - auto boxSizeY = std::min(size.y / getNumItems(record), MAX_BOX_Y_SIZE); - for (size_t mi = 0, me = getNumItems(record); mi < me; mi++) { + auto me = getNumItems(record); + auto boxSizeY = std::min(size.y / me, MAX_BOX_Y_SIZE); + for (size_t mi = 0; mi < me; mi++) { ImVec2 yOffSet{0, (mi * boxSizeY) + padding}; ImVec2 ySize{0, boxSizeY - 2 * padding}; @@ -98,11 +145,12 @@ struct HeatMapHelper { } }; -void displayDataRelayer(DeviceMetricsInfo const& metrics, - DeviceInfo const& info, +void displayDataRelayer(DeviceMetricsInfo const& /*metrics*/, + DeviceInfo const& /*info*/, DeviceSpec const& spec, DataProcessingStates const& states, - ImVec2 const& size) + ImVec2 const& size, + int& v) { auto getNumInputs = [&states]() -> size_t { auto& inputsView = states.statesViews[(int)ProcessingStateId::DATA_QUERIES]; @@ -146,7 +194,7 @@ void displayDataRelayer(DeviceMetricsInfo const& metrics, } char const* const beginData = strchr(buffer + view.first, ' ') + 1; // Protect against buffer overflows - if (view.size <= beginData - buffer + i - view.first) { + if ((size_t)view.size <= beginData - buffer + i - view.first) { return &error; } return (int8_t const*)beginData + i; }; @@ -184,7 +232,7 @@ void displayDataRelayer(DeviceMetricsInfo const& metrics, if ((end - input) == 0) { continue; } - if (i == row) { + if (i == (size_t)row) { ImGui::Text("%d %.*s (%s)", row, int(end - input), input, InspectorHelpers::getLifeTimeStr(spec.inputs[i].matcher.lifetime).c_str()); break; } @@ -226,6 +274,7 @@ void displayDataRelayer(DeviceMetricsInfo const& metrics, if (getNumRecords()) { HeatMapHelper::draw("DataRelayer", + v, size, getNumInputs, getNumRecords, diff --git a/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.h b/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.h index 8c4941474d8a7..8bea06829f0dc 100644 --- a/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.h +++ b/Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.h @@ -9,6 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#include "Framework/DeviceSpec.h" class ImVec2; namespace o2::framework @@ -19,9 +20,9 @@ class DataProcessingStates; namespace gui { - +static constexpr int WND = 16; /// View of the DataRelayer metrics for a given DeviceInfo -void displayDataRelayer(DeviceMetricsInfo const& metrics, DeviceInfo const& info, DeviceSpec const& spec, DataProcessingStates const&, ImVec2 const& size); +void displayDataRelayer(DeviceMetricsInfo const& metrics, DeviceInfo const& info, DeviceSpec const& spec, DataProcessingStates const&, ImVec2 const& size, int& v); } // namespace gui } // namespace o2::framework diff --git a/Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx b/Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx index 89126cf303a66..1c4ddd7e6aabf 100644 --- a/Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx +++ b/Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx @@ -713,7 +713,8 @@ void showTopologyNodeGraph(WorkspaceGUIState& state, default: break; } - gui::displayDataRelayer(metricsInfos[node->ID], infos[node->ID], specs[node->ID], allStates[node->ID], ImVec2(140., 90.)); + + gui::displayDataRelayer(metricsInfos[node->ID], infos[node->ID], specs[node->ID], allStates[node->ID], ImVec2(200., 160.), controls[node->ID].firstWnd); ImGui::EndGroup(); // Save the size of what we have emitted and whether any of the widgets are being used diff --git a/GPU/Common/CMakeLists.txt b/GPU/Common/CMakeLists.txt index efac4fc436758..6951c3b2339b8 100644 --- a/GPU/Common/CMakeLists.txt +++ b/GPU/Common/CMakeLists.txt @@ -64,3 +64,8 @@ if(ALIGPU_BUILD_TYPE STREQUAL "O2") endif() install(FILES ${HDRS_INSTALL} DESTINATION include/GPU) endif() + +if(ALIGPU_BUILD_TYPE STREQUAL "Standalone") + install(FILES ${HDRS_INSTALL} + DESTINATION include) +endif() diff --git a/GPU/Common/GPUCommonAlgorithm.h b/GPU/Common/GPUCommonAlgorithm.h index 5c19dda27f593..417c9e0d1f8c1 100644 --- a/GPU/Common/GPUCommonAlgorithm.h +++ b/GPU/Common/GPUCommonAlgorithm.h @@ -214,7 +214,7 @@ typedef GPUCommonAlgorithm CAAlgo; } // namespace o2::gpu -#if (((defined(__CUDACC__) && !defined(__clang__)) || defined(__HIPCC__))) && !defined(GPUCA_GPUCODE_GENRTC) && !defined(GPUCA_GPUCODE_HOSTONLY) +#if (((defined(__CUDACC__) && !defined(__clang__)) || defined(__HIPCC__))) && !defined(GPUCA_GPUCODE_HOSTONLY) #include "GPUCommonAlgorithmThrust.h" diff --git a/GPU/Common/GPUCommonAlgorithmThrust.h b/GPU/Common/GPUCommonAlgorithmThrust.h index 049071227a58e..7af3138d45490 100644 --- a/GPU/Common/GPUCommonAlgorithmThrust.h +++ b/GPU/Common/GPUCommonAlgorithmThrust.h @@ -15,6 +15,7 @@ #ifndef GPUCOMMONALGORITHMTHRUST_H #define GPUCOMMONALGORITHMTHRUST_H +#ifndef GPUCA_GPUCODE_COMPILEKERNELS #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #include @@ -25,14 +26,19 @@ #include "GPUCommonDef.h" #include "GPUCommonHelpers.h" +#ifndef __HIPCC__ // CUDA +#include +#else // HIP +#include +#endif +#endif // GPUCA_GPUCODE_COMPILEKERNELS + #ifndef __HIPCC__ // CUDA #define GPUCA_THRUST_NAMESPACE thrust::cuda #define GPUCA_CUB_NAMESPACE cub -#include #else // HIP #define GPUCA_THRUST_NAMESPACE thrust::hip #define GPUCA_CUB_NAMESPACE hipcub -#include #endif namespace o2::gpu @@ -90,6 +96,7 @@ GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T* begin, T* end, const S& co thrust::sort(GPUCA_THRUST_NAMESPACE::par, thrustBegin, thrustEnd, comp); } +#ifndef GPUCA_GPUCODE_COMPILEKERNELS template GPUhi() void GPUCommonAlgorithm::sortOnDevice(auto* rec, int32_t stream, T* begin, size_t N, const S& comp) { @@ -105,6 +112,8 @@ GPUhi() void GPUCommonAlgorithm::sortOnDevice(auto* rec, int32_t stream, T* begi GPUChkErrS(GPUCA_CUB_NAMESPACE::DeviceMergeSort::SortKeys(tempMem, tempSize, begin, N, comp, rec->mInternals->Streams[stream])); #endif } +#endif // #ifndef GPUCA_GPUCODE_COMPILEKERNELS + } // namespace o2::gpu #undef GPUCA_THRUST_NAMESPACE diff --git a/GPU/Common/GPUCommonDef.h b/GPU/Common/GPUCommonDef.h index 78da104a0c029..d7e99f53d4ce8 100644 --- a/GPU/Common/GPUCommonDef.h +++ b/GPU/Common/GPUCommonDef.h @@ -58,7 +58,7 @@ #if (defined(__CUDACC__) && defined(GPUCA_CUDA_NO_CONSTANT_MEMORY)) || (defined(__HIPCC__) && defined(GPUCA_HIP_NO_CONSTANT_MEMORY)) || (defined(__OPENCL__) && defined(GPUCA_OPENCL_NO_CONSTANT_MEMORY)) #define GPUCA_NO_CONSTANT_MEMORY -#elif defined(__CUDACC__) || defined(__HIPCC__) +#elif (defined(__CUDACC__) || defined(__HIPCC__)) && !defined(GPUCA_GPUCODE_HOSTONLY) #define GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM #endif diff --git a/GPU/GPUTracking/Base/GPUConstantMem.h b/GPU/GPUTracking/Base/GPUConstantMem.h index e0b06f0a3ea55..532c270431d99 100644 --- a/GPU/GPUTracking/Base/GPUConstantMem.h +++ b/GPU/GPUTracking/Base/GPUConstantMem.h @@ -95,7 +95,7 @@ union GPUConstantMemCopyable { static constexpr size_t gGPUConstantMemBufferSize = (sizeof(GPUConstantMem) + sizeof(uint4) - 1); #endif } // namespace o2::gpu -#if defined(GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM) && !defined(GPUCA_GPUCODE_HOSTONLY) +#if defined(GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM) GPUconstant() o2::gpu::GPUConstantMemCopyable gGPUConstantMemBuffer; // TODO: This should go into o2::gpu namespace, but then CUDA or HIP would not find the symbol #endif // GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM namespace o2::gpu @@ -104,7 +104,7 @@ namespace o2::gpu // Must be placed here, to avoid circular header dependency GPUdi() GPUconstantref() const GPUConstantMem* GPUProcessor::GetConstantMem() const { -#if defined(GPUCA_GPUCODE_DEVICE) && defined(GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM) && !defined(GPUCA_GPUCODE_HOSTONLY) +#if defined(GPUCA_GPUCODE_DEVICE) && defined(GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM) return &GPUCA_CONSMEM; #else return mConstantMem; diff --git a/GPU/GPUTracking/Base/GPUParam.cxx b/GPU/GPUTracking/Base/GPUParam.cxx index bbca150df405a..b835e1b198eea 100644 --- a/GPU/GPUTracking/Base/GPUParam.cxx +++ b/GPU/GPUTracking/Base/GPUParam.cxx @@ -193,12 +193,10 @@ void GPUParamRTC::setFrom(const GPUParam& param) std::string GPUParamRTC::generateRTCCode(const GPUParam& param, bool useConstexpr) { - return "#ifndef GPUCA_GPUCODE_DEVICE\n" - "#include \n" + return "#include \n" "#include \n" "#include \n" "#include \n" - "#endif\n" "namespace o2::gpu { class GPUDisplayFrontendInterface; }\n" + qConfigPrintRtc(std::make_tuple(¶m.rec.tpc, ¶m.rec.trd, ¶m.rec, ¶m.par), useConstexpr); } diff --git a/GPU/GPUTracking/Base/GPUReconstructionCPU.cxx b/GPU/GPUTracking/Base/GPUReconstructionCPU.cxx index a8a83fdbd9203..d714c6833d18d 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionCPU.cxx +++ b/GPU/GPUTracking/Base/GPUReconstructionCPU.cxx @@ -16,7 +16,7 @@ #include "GPUReconstructionIncludes.h" #include "GPUReconstructionThreading.h" #include "GPUChain.h" - +#include "GPUDefParameters.h" #include "GPUTPCClusterData.h" #include "GPUTPCSectorOutCluster.h" #include "GPUTPCGMMergedTrack.h" @@ -120,15 +120,27 @@ void GPUReconstructionCPUBackend::runKernelBackend(const krnlSetupArgs -krnlProperties GPUReconstructionCPUBackend::getKernelPropertiesBackend() +template +gpu_reconstruction_kernels::krnlProperties GPUReconstructionCPU::getKernelProperties(int gpu) { - return krnlProperties{1, 1}; + if (gpu == -1) { + gpu = IsGPU(); + } + const auto num = GetKernelNum(); + const auto* p = gpu ? mParDevice : mParCPU; + gpu_reconstruction_kernels::krnlProperties ret = {p->par_LB_maxThreads[num], p->par_LB_minBlocks[num], p->par_LB_forceBlocks[num]}; + if (ret.nThreads == 0) { + ret.nThreads = gpu ? mThreadCount : 1u; + } + if (ret.minBlocks == 0) { + ret.minBlocks = 1; + } + return ret; } -#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types) \ +#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types, ...) \ template void GPUReconstructionCPUBackend::runKernelBackend(const krnlSetupArgs& args); \ - template krnlProperties GPUReconstructionCPUBackend::getKernelPropertiesBackend(); + template krnlProperties GPUReconstructionCPU::getKernelProperties(int gpu); #include "GPUReconstructionKernelList.h" #undef GPUCA_KRNL diff --git a/GPU/GPUTracking/Base/GPUReconstructionCPU.h b/GPU/GPUTracking/Base/GPUReconstructionCPU.h index fd999ec2304e1..163b00c804d7f 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionCPU.h +++ b/GPU/GPUTracking/Base/GPUReconstructionCPU.h @@ -38,8 +38,6 @@ class GPUReconstructionCPUBackend : public GPUReconstructionProcessing void runKernelBackend(const gpu_reconstruction_kernels::krnlSetupArgs& args); template void runKernelBackendInternal(const gpu_reconstruction_kernels::krnlSetupTime& _xyz, const Args&... args); - template - gpu_reconstruction_kernels::krnlProperties getKernelPropertiesBackend(); }; class GPUReconstructionCPU : public GPUReconstructionKernels @@ -55,10 +53,7 @@ class GPUReconstructionCPU : public GPUReconstructionKernels void runKernel(krnlSetup&& setup, Args&&... args); template - const gpu_reconstruction_kernels::krnlProperties getKernelProperties() - { - return getKernelPropertiesImpl(gpu_reconstruction_kernels::classArgument()); - } + gpu_reconstruction_kernels::krnlProperties getKernelProperties(int gpu = -1); virtual int32_t GPUDebug(const char* state = "UNKNOWN", int32_t stream = -1, bool force = false); int32_t GPUStuck() { return mGPUStuck; } @@ -77,13 +72,15 @@ class GPUReconstructionCPU : public GPUReconstructionKernels, bool cpuFallback, double& timer, krnlSetup&& setup GPUCA_M_STRIP(x_arguments)) \ { \ + krnlSetupArgs args(setup.x, setup.y, setup.z, timer GPUCA_M_STRIP(x_forward)); \ + const uint32_t num = GetKernelNum(); \ if (cpuFallback) { \ - GPUReconstructionCPU::runKernelImpl(krnlSetupArgs(setup.x, setup.y, setup.z, timer GPUCA_M_STRIP(x_forward))); \ + GPUReconstructionCPU::runKernelImpl(num, &args); \ } else { \ - runKernelImpl(krnlSetupArgs(setup.x, setup.y, setup.z, timer GPUCA_M_STRIP(x_forward))); \ + runKernelImpl(num, &args); \ } \ } #include "GPUReconstructionKernelList.h" diff --git a/GPU/GPUTracking/Base/GPUReconstructionKernelMacros.h b/GPU/GPUTracking/Base/GPUReconstructionKernelMacros.h index 0b1a501ebc094..b3f6c6ec817fd 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionKernelMacros.h +++ b/GPU/GPUTracking/Base/GPUReconstructionKernelMacros.h @@ -38,21 +38,18 @@ #ifndef GPUCA_KRNL_CUSTOM #define GPUCA_KRNL_CUSTOM(...) #endif -#define GPUCA_KRNL_REG_EXTRREG(...) GPUCA_M_STRIP(__VA_ARGS__) -#define GPUCA_KRNL_CUSTOM_EXTRREG(MODE, ...) GPUCA_ATTRRES_XCUSTOM(MODE, __VA_ARGS__) -#define GPUCA_KRNL_NONE_EXTRREG(MODE, ...) GPUCA_ATTRRES_XNONE(MODE, __VA_ARGS__) -#define GPUCA_ATTRRES_REG(MODE, reg, num, ...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_KRNL_REG, MODE))(num) GPUCA_ATTRRES_XREG (MODE, __VA_ARGS__) -#define GPUCA_ATTRRES_CUSTOM(MODE, custom, args, ...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_KRNL_CUSTOM, MODE))(args) GPUCA_ATTRRES_XCUSTOM(MODE, __VA_ARGS__) -#define GPUCA_ATTRRES_NONE(MODE, none, ...) GPUCA_ATTRRES_XNONE(MODE, __VA_ARGS__) -#define GPUCA_ATTRRES_(MODE, ...) -#define GPUCA_ATTRRES_XNONE(MODE, ...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_ATTRRES_, GPUCA_M_FIRST(__VA_ARGS__)))(MODE, __VA_ARGS__) -#define GPUCA_ATTRRES_XCUSTOM(MODE, ...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_ATTRRES_, GPUCA_M_FIRST(__VA_ARGS__)))(MODE, __VA_ARGS__) -#define GPUCA_ATTRRES_XREG(MODE, ...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_ATTRRES_, GPUCA_M_FIRST(__VA_ARGS__)))(MODE, __VA_ARGS__) -#define GPUCA_ATTRRES(MODE, ...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_ATTRRES_, GPUCA_M_FIRST(__VA_ARGS__)))(MODE, __VA_ARGS__) +#define GPUCA_ATTRRES_REG(reg, num, ...) GPUCA_M_EXPAND(GPUCA_KRNL_REG)(num) GPUCA_ATTRRES_XREG (__VA_ARGS__) +#define GPUCA_ATTRRES_CUSTOM(custom, args, ...) GPUCA_M_EXPAND(GPUCA_KRNL_CUSTOM)(args) GPUCA_ATTRRES_XCUSTOM(__VA_ARGS__) +#define GPUCA_ATTRRES_NONE(none, ...) GPUCA_ATTRRES_XNONE(__VA_ARGS__) +#define GPUCA_ATTRRES_(...) +#define GPUCA_ATTRRES_XNONE(...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_ATTRRES_, GPUCA_M_FIRST(__VA_ARGS__)))(__VA_ARGS__) +#define GPUCA_ATTRRES_XCUSTOM(...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_ATTRRES_, GPUCA_M_FIRST(__VA_ARGS__)))(__VA_ARGS__) +#define GPUCA_ATTRRES_XREG(...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_ATTRRES_, GPUCA_M_FIRST(__VA_ARGS__)))(__VA_ARGS__) +#define GPUCA_ATTRRES(...) GPUCA_M_EXPAND(GPUCA_M_CAT(GPUCA_ATTRRES_, GPUCA_M_FIRST(__VA_ARGS__)))(__VA_ARGS__) // GPU Kernel entry point #define GPUCA_KRNLGPU_DEF(x_class, x_attributes, x_arguments, ...) \ - GPUg() void GPUCA_ATTRRES(, GPUCA_M_STRIP(x_attributes)) GPUCA_M_CAT(krnl_, GPUCA_M_KRNL_NAME(x_class))(GPUCA_CONSMEM_PTR int32_t _iSector_internal GPUCA_M_STRIP(x_arguments)) + GPUg() void GPUCA_ATTRRES(GPUCA_M_STRIP(x_attributes)) GPUCA_M_CAT(krnl_, GPUCA_M_KRNL_NAME(x_class))(GPUCA_CONSMEM_PTR int32_t _iSector_internal GPUCA_M_STRIP(x_arguments)) #ifdef GPUCA_KRNL_DEFONLY #define GPUCA_KRNLGPU(...) GPUCA_KRNLGPU_DEF(__VA_ARGS__); @@ -79,12 +76,6 @@ } \ }; -#define GPUCA_KRNL_PROP(x_class, x_attributes) \ - template <> gpu_reconstruction_kernels::krnlProperties GPUCA_M_CAT3(GPUReconstruction, GPUCA_GPUTYPE, Backend)::getKernelPropertiesBackend() { \ - gpu_reconstruction_kernels::krnlProperties ret = gpu_reconstruction_kernels::krnlProperties{GPUCA_ATTRRES(_EXTRREG, GPUCA_M_STRIP(x_attributes))}; \ - return ret.nThreads > 0 ? ret : gpu_reconstruction_kernels::krnlProperties{(int32_t)mThreadCount}; \ - } - #endif // GPUCA_GPUCODE #define GPUCA_KRNL_LB(x_class, x_attributes, ...) GPUCA_KRNL(x_class, (REG, (GPUCA_M_CAT(GPUCA_LB_, GPUCA_M_KRNL_NAME(x_class))), GPUCA_M_STRIP(x_attributes)), __VA_ARGS__) diff --git a/GPU/GPUTracking/Base/GPUReconstructionKernels.h b/GPU/GPUTracking/Base/GPUReconstructionKernels.h index b8f3e3746c743..7f500d471de1f 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionKernels.h +++ b/GPU/GPUTracking/Base/GPUReconstructionKernels.h @@ -95,17 +95,19 @@ class GPUReconstructionKernels : public T template using krnlSetupArgs = gpu_reconstruction_kernels::krnlSetupArgs; -#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types) \ - virtual void runKernelImpl(const krnlSetupArgs& args) \ - { \ - T::template runKernelBackend(args); \ - } \ - virtual gpu_reconstruction_kernels::krnlProperties getKernelPropertiesImpl(gpu_reconstruction_kernels::classArgument) \ - { \ - return T::template getKernelPropertiesBackend(); \ - } + virtual void runKernelImpl(const int num, const void* args) + { + switch (num) { // clang-format off +#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types, x_num) \ + case x_num: { \ + const auto& args2 = *(const krnlSetupArgs*)args; \ + T::template runKernelBackend(args2); \ + break; \ + } #include "GPUReconstructionKernelList.h" #undef GPUCA_KRNL + } // clang-format on + } }; } // namespace o2::gpu diff --git a/GPU/GPUTracking/Base/GPUReconstructionProcessing.cxx b/GPU/GPUTracking/Base/GPUReconstructionProcessing.cxx index bae95ac8d3f38..95a47dec946e6 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionProcessing.cxx +++ b/GPU/GPUTracking/Base/GPUReconstructionProcessing.cxx @@ -12,11 +12,35 @@ /// \file GPUReconstructionProcessing.cxx /// \author David Rohr +#define GPUCA_DEF_PARAMETERS_LOAD_DEFAULTS +#include "GPUDefParametersDefault.h" +#include "GPUDefParametersLoad.inc" + #include "GPUReconstructionProcessing.h" #include "GPUReconstructionThreading.h" using namespace o2::gpu; +GPUReconstructionProcessing::GPUReconstructionProcessing(const GPUSettingsDeviceBackend& cfg) : GPUReconstruction(cfg) +{ + if (mMaster == nullptr) { + mParCPU = new GPUDefParameters(o2::gpu::internal::GPUDefParametersLoad()); + mParDevice = new GPUDefParameters(); + } else { + GPUReconstructionProcessing* master = dynamic_cast(mMaster); + mParCPU = master->mParCPU; + mParDevice = master->mParDevice; + } +} + +GPUReconstructionProcessing::~GPUReconstructionProcessing() +{ + if (mMaster == nullptr) { + delete mParCPU; + delete mParDevice; + } +} + int32_t GPUReconstructionProcessing::getNKernelHostThreads(bool splitCores) { int32_t nThreads = 0; @@ -119,38 +143,22 @@ std::unique_ptr GPUReconstructionProc gpu_reconstruction_kernels::threadContext::threadContext() = default; gpu_reconstruction_kernels::threadContext::~threadContext() = default; -template -uint32_t GPUReconstructionProcessing::GetKernelNum(int32_t k) -{ - static int32_t num = k; - if (num < 0) { - throw std::runtime_error("Internal Error - Kernel Number not Set"); - } - return num; -} - -namespace o2::gpu::internal -{ -static std::vector initKernelNames() -{ - std::vector retVal; -#define GPUCA_KRNL(x_class, ...) \ - GPUReconstructionProcessing::GetKernelNum(retVal.size()); \ - retVal.emplace_back(GPUCA_M_STR(GPUCA_M_KRNL_NAME(x_class))); +const std::vector GPUReconstructionProcessing::mKernelNames = { +#define GPUCA_KRNL(x_class, ...) GPUCA_M_STR(GPUCA_M_KRNL_NAME(x_class)), #include "GPUReconstructionKernelList.h" #undef GPUCA_KRNL - return retVal; -} -} // namespace o2::gpu::internal - -const std::vector GPUReconstructionProcessing::mKernelNames = o2::gpu::internal::initKernelNames(); - -#define GPUCA_KRNL(x_class, ...) \ - template uint32_t GPUReconstructionProcessing::GetKernelNum(int32_t); \ - template <> \ - const char* GPUReconstructionProcessing::GetKernelName() \ - { \ - return GPUCA_M_STR(GPUCA_M_KRNL_NAME(x_class)); \ +}; + +#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types, x_num) \ + template <> \ + uint32_t GPUReconstructionProcessing::GetKernelNum() \ + { \ + return x_num; \ + } \ + template <> \ + const char* GPUReconstructionProcessing::GetKernelName() \ + { \ + return GPUCA_M_STR(GPUCA_M_KRNL_NAME(x_class)); \ } #include "GPUReconstructionKernelList.h" #undef GPUCA_KRNL diff --git a/GPU/GPUTracking/Base/GPUReconstructionProcessing.h b/GPU/GPUTracking/Base/GPUReconstructionProcessing.h index b0466efceac24..2428027118c0a 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionProcessing.h +++ b/GPU/GPUTracking/Base/GPUReconstructionProcessing.h @@ -25,6 +25,8 @@ namespace o2::gpu { +struct GPUDefParameters; + namespace gpu_reconstruction_kernels { struct deviceEvent { @@ -63,7 +65,7 @@ class threadContext class GPUReconstructionProcessing : public GPUReconstruction { public: - ~GPUReconstructionProcessing() override = default; + ~GPUReconstructionProcessing() override; // Threading int32_t getNKernelHostThreads(bool splitCores); @@ -78,7 +80,7 @@ class GPUReconstructionProcessing : public GPUReconstruction static const char* GetKernelName(); const std::string& GetKernelName(int32_t i) const { return mKernelNames[i]; } template - static uint32_t GetKernelNum(int32_t k = -1); + static uint32_t GetKernelNum(); // Public queries for timers auto& getRecoStepTimer(RecoStep step) { return mTimersRecoSteps[getRecoStepNum(step)]; } @@ -101,7 +103,7 @@ class GPUReconstructionProcessing : public GPUReconstruction }; protected: - GPUReconstructionProcessing(const GPUSettingsDeviceBackend& cfg) : GPUReconstruction(cfg) {} + GPUReconstructionProcessing(const GPUSettingsDeviceBackend& cfg); using deviceEvent = gpu_reconstruction_kernels::deviceEvent; static const std::vector mKernelNames; @@ -132,6 +134,9 @@ class GPUReconstructionProcessing : public GPUReconstruction template HighResTimer& getTimer(const char* name, int32_t num = -1); + GPUDefParameters* mParCPU = nullptr; + GPUDefParameters* mParDevice = nullptr; + private: uint32_t getNextTimerId(); timerMeta* getTimerById(uint32_t id, bool increment = true); diff --git a/GPU/GPUTracking/Base/cuda/CMakeLists.txt b/GPU/GPUTracking/Base/cuda/CMakeLists.txt index de54f09fdc2e1..843fc3464e151 100644 --- a/GPU/GPUTracking/Base/cuda/CMakeLists.txt +++ b/GPU/GPUTracking/Base/cuda/CMakeLists.txt @@ -18,7 +18,7 @@ endif() message(STATUS "Building GPUTracking with CUDA support ${TMP_TARGET}") set(SRCS GPUReconstructionCUDA.cu GPUReconstructionCUDAGenRTC.cxx GPUReconstructionCUDAKernels.cu) -set(HDRS GPUReconstructionCUDA.h GPUReconstructionCUDAInternals.h GPUReconstructionCUDAHelpers.inc GPUReconstructionCUDADef.h GPUReconstructionCUDAIncludesHost.h) +set(HDRS GPUReconstructionCUDA.h GPUReconstructionCUDAInternals.h GPUReconstructionCUDAHelpers.inc GPUReconstructionCUDADef.h GPUReconstructionCUDAIncludesSystem.h) # -------------------------------- Prepare RTC ------------------------------------------------------- enable_language(ASM) if(ALIGPU_BUILD_TYPE STREQUAL "O2") @@ -67,8 +67,8 @@ set(GPU_RTC_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionCUDArtc) # cmake-format: off add_custom_command( OUTPUT ${GPU_RTC_BIN}.src - COMMAND cp ${GPUDIR}/Base/cuda/GPUReconstructionCUDAIncludesHost.h ${GPU_RTC_BIN}.src - COMMAND ${CMAKE_CXX_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_CUDA_STANDARD} -D__CUDA_ARCH__=${RTC_CUDA_ARCH} -D__CUDACC__ -x c++ -nostdinc -E ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src + COMMAND cp ${GPUDIR}/Base/cuda/GPUReconstructionCUDAIncludesSystem.h ${GPU_RTC_BIN}.src + COMMAND ${CMAKE_CXX_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_CUDA_STANDARD} -D__CUDA_ARCH__=${RTC_CUDA_ARCH} -D__CUDACC__ -x c++ -nostdinc -E -P ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src MAIN_DEPENDENCY ${GPU_RTC_SRC} IMPLICIT_DEPENDS CXX ${GPU_RTC_SRC} COMMAND_EXPAND_LISTS @@ -84,7 +84,7 @@ add_custom_target(${MODULE}_CUDA_SRC_CHK ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR} add_custom_command( OUTPUT ${GPU_RTC_BIN}.command - COMMAND echo -n "${CMAKE_CUDA_COMPILER} -forward-unknown-to-host-compiler ${GPU_RTC_DEFINES} ${GPU_RTC_FLAGS_SEPARATED} -x cu -fatbin" > ${GPU_RTC_BIN}.command + COMMAND echo -n "${CMAKE_CUDA_COMPILER} -forward-unknown-to-host-compiler ${GPU_RTC_DEFINES} ${GPU_RTC_FLAGS_SEPARATED} -x cu -fatbin -Xcudafe --diag_suppress=177" > ${GPU_RTC_BIN}.command COMMAND_EXPAND_LISTS VERBATIM COMMENT "Preparing CUDA RTC command file ${GPU_RTC_BIN}.command" ) diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu index f87d5c8189cdc..4cfdf7febabd7 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu @@ -13,8 +13,14 @@ /// \author David Rohr #define GPUCA_GPUCODE_HOSTONLY -#include "GPUReconstructionCUDAIncludesHost.h" +#define GPUCA_DEF_PARAMETERS_LOAD_DEFAULTS +#include "GPUReconstructionCUDADef.h" +#include "GPUDefParametersDefault.h" +#include "GPUDefParametersLoad.inc" + +#include "GPUReconstructionCUDAIncludesSystem.h" +#include "GPUReconstructionCUDADef.h" #include #include "GPUReconstructionCUDA.h" @@ -51,11 +57,14 @@ GPUReconstructionCUDABackend::GPUReconstructionCUDABackend(const GPUSettingsDevi { if (mMaster == nullptr) { mInternals = new GPUReconstructionCUDAInternals; + *mParDevice = o2::gpu::internal::GPUDefParametersLoad(); } + mDeviceBackendSettings.deviceType = DeviceType::CUDA; } GPUReconstructionCUDABackend::~GPUReconstructionCUDABackend() { + Exit(); // Make sure we destroy everything (in particular the ITS tracker) before we exit CUDA if (mMaster == nullptr) { delete mInternals; } @@ -69,7 +78,6 @@ int32_t GPUReconstructionCUDABackend::GPUChkErrInternal(const int64_t error, con GPUReconstructionCUDA::GPUReconstructionCUDA(const GPUSettingsDeviceBackend& cfg) : GPUReconstructionKernels(cfg) { - mDeviceBackendSettings.deviceType = DeviceType::CUDA; #ifndef __HIPCC__ // CUDA mRtcSrcExtension = ".cu"; mRtcBinExtension = ".fatbin"; @@ -78,11 +86,7 @@ GPUReconstructionCUDA::GPUReconstructionCUDA(const GPUSettingsDeviceBackend& cfg mRtcBinExtension = ".o"; #endif } - -GPUReconstructionCUDA::~GPUReconstructionCUDA() -{ - Exit(); // Make sure we destroy everything (in particular the ITS tracker) before we exit CUDA -} +GPUReconstructionCUDA::~GPUReconstructionCUDA() {} GPUReconstruction* GPUReconstruction_Create_CUDA(const GPUSettingsDeviceBackend& cfg) { return new GPUReconstructionCUDA(cfg); } @@ -110,7 +114,7 @@ int32_t GPUReconstructionCUDA::InitDevice_Runtime() constexpr int32_t reqVerMaj = 2; constexpr int32_t reqVerMin = 0; #endif - if (mProcessingSettings.rtc.enable && mProcessingSettings.rtc.runTest == 2) { + if (mProcessingSettings.rtc.enable && mProcessingSettings.rtctech.runTest == 2) { genAndLoadRTC(); exit(0); } @@ -429,14 +433,14 @@ void GPUReconstructionCUDA::genAndLoadRTC() throw std::runtime_error("Runtime compilation failed"); } for (uint32_t i = 0; i < nCompile; i++) { - if (mProcessingSettings.rtc.runTest != 2) { + if (mProcessingSettings.rtctech.runTest != 2) { mInternals->kernelModules.emplace_back(std::make_unique()); GPUChkErr(cuModuleLoad(mInternals->kernelModules.back().get(), (filename + "_" + std::to_string(i) + mRtcBinExtension).c_str())); } remove((filename + "_" + std::to_string(i) + mRtcSrcExtension).c_str()); remove((filename + "_" + std::to_string(i) + mRtcBinExtension).c_str()); } - if (mProcessingSettings.rtc.runTest == 2) { + if (mProcessingSettings.rtctech.runTest == 2) { return; } loadKernelModules(mProcessingSettings.rtc.compilePerKernel); diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.h b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.h index a98b14a873ca0..ac5920f769f25 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.h +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.h @@ -44,8 +44,6 @@ class GPUReconstructionCUDABackend : public GPUReconstructionDeviceBase void runKernelBackend(const krnlSetupArgs& args); template void runKernelBackendInternal(const krnlSetupTime& _xyz, const Args&... args); - template - gpu_reconstruction_kernels::krnlProperties getKernelPropertiesBackend(); void getRTCKernelCalls(std::vector& kernels); diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAExternalProvider.cu b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAExternalProvider.cu index 534f5e8606897..9a23fcb460aa4 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAExternalProvider.cu +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAExternalProvider.cu @@ -12,7 +12,8 @@ /// \file GPUReconstructionCUDAExternalProvider.cu /// \author David Rohr -#include "GPUReconstructionCUDAIncludesHost.h" +#include "GPUReconstructionCUDAIncludesSystem.h" +#include "GPUReconstructionCUDADef.h" #include "GPUReconstructionCUDA.h" #include "GPUReconstructionCUDAInternals.h" diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx index 51d3bd4044e8d..c3d614b8d9f98 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx @@ -13,6 +13,10 @@ /// \author David Rohr #define GPUCA_GPUCODE_HOSTONLY +#define GPUCA_DEF_PARAMETERS_LOAD_DEFAULTS +#include "GPUDefParametersDefault.h" +#include "GPUDefParametersLoad.inc" + #include "GPUReconstructionCUDA.h" #include "GPUParamRTC.h" #include "GPUDefMacros.h" @@ -52,28 +56,50 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile) kernelsall += kernels[i] + "\n"; } - std::string baseCommand = (mProcessingSettings.RTCprependCommand != "" ? (mProcessingSettings.RTCprependCommand + " ") : ""); + std::string baseCommand = (mProcessingSettings.rtctech.prependCommand != "" ? (mProcessingSettings.rtctech.prependCommand + " ") : ""); baseCommand += (getenv("O2_GPU_RTC_OVERRIDE_CMD") ? std::string(getenv("O2_GPU_RTC_OVERRIDE_CMD")) : std::string(_binary_GPUReconstructionCUDArtc_command_start, _binary_GPUReconstructionCUDArtc_command_len)); - baseCommand += std::string(" ") + (mProcessingSettings.RTCoverrideArchitecture != "" ? mProcessingSettings.RTCoverrideArchitecture : std::string(_binary_GPUReconstructionCUDArtc_command_arch_start, _binary_GPUReconstructionCUDArtc_command_arch_len)); + baseCommand += std::string(" ") + (mProcessingSettings.rtctech.overrideArchitecture != "" ? mProcessingSettings.rtctech.overrideArchitecture : std::string(_binary_GPUReconstructionCUDArtc_command_arch_start, _binary_GPUReconstructionCUDArtc_command_arch_len)); + + if (mProcessingSettings.rtctech.loadLaunchBoundsFromFile.size()) { + FILE* fp = fopen(mProcessingSettings.rtctech.loadLaunchBoundsFromFile.c_str(), "rb"); + if (fp == nullptr) { + throw std::runtime_error("Cannot open launch bounds parameter module file"); + } + fseek(fp, 0, SEEK_END); + size_t size = ftell(fp); + if (size != sizeof(*mParDevice)) { + throw std::runtime_error("launch bounds parameter file has incorrect size"); + } + fseek(fp, 0, SEEK_SET); + if (fread(mParDevice, 1, size, fp) != size) { + throw std::runtime_error("Error reading launch bounds parameter file"); + } + fclose(fp); + } + const std::string launchBounds = o2::gpu::internal::GPUDefParametersExport(*mParDevice, true); + if (mProcessingSettings.rtctech.printLaunchBounds || mProcessingSettings.debugLevel >= 3) { + GPUInfo("RTC Launch Bounds:\n%s", launchBounds.c_str()); + } - char shasource[21], shaparam[21], shacmd[21], shakernels[21]; + char shasource[21], shaparam[21], shacmd[21], shakernels[21], shabounds[21]; if (mProcessingSettings.rtc.cacheOutput) { o2::framework::internal::SHA1(shasource, _binary_GPUReconstructionCUDArtc_src_start, _binary_GPUReconstructionCUDArtc_src_len); o2::framework::internal::SHA1(shaparam, rtcparam.c_str(), rtcparam.size()); o2::framework::internal::SHA1(shacmd, baseCommand.c_str(), baseCommand.size()); o2::framework::internal::SHA1(shakernels, kernelsall.c_str(), kernelsall.size()); + o2::framework::internal::SHA1(shabounds, launchBounds.c_str(), launchBounds.size()); } nCompile = mProcessingSettings.rtc.compilePerKernel ? kernels.size() : 1; bool cacheLoaded = false; int32_t fd = 0; if (mProcessingSettings.rtc.cacheOutput) { - if (mProcessingSettings.RTCcacheFolder != ".") { - std::filesystem::create_directories(mProcessingSettings.RTCcacheFolder); + if (mProcessingSettings.rtctech.cacheFolder != ".") { + std::filesystem::create_directories(mProcessingSettings.rtctech.cacheFolder); } - if (mProcessingSettings.rtc.cacheMutex) { + if (mProcessingSettings.rtctech.cacheMutex) { mode_t mask = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - fd = open((mProcessingSettings.RTCcacheFolder + "/cache.lock").c_str(), O_RDWR | O_CREAT | O_CLOEXEC, mask); + fd = open((mProcessingSettings.rtctech.cacheFolder + "/cache.lock").c_str(), O_RDWR | O_CREAT | O_CLOEXEC, mask); if (fd == -1) { throw std::runtime_error("Error opening rtc cache mutex lock file"); } @@ -83,37 +109,34 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile) } } - FILE* fp = fopen((mProcessingSettings.RTCcacheFolder + "/rtc.cuda.cache").c_str(), "rb"); + FILE* fp = fopen((mProcessingSettings.rtctech.cacheFolder + "/rtc.cuda.cache").c_str(), "rb"); char sharead[20]; if (fp) { size_t len; while (true) { - if (fread(sharead, 1, 20, fp) != 20) { - throw std::runtime_error("Cache file corrupt"); - } - if (!mProcessingSettings.rtc.ignoreCacheValid && memcmp(sharead, shasource, 20)) { - GPUInfo("Cache file content outdated (source)"); - break; - } - if (fread(sharead, 1, 20, fp) != 20) { - throw std::runtime_error("Cache file corrupt"); - } - if (!mProcessingSettings.rtc.ignoreCacheValid && memcmp(sharead, shaparam, 20)) { - GPUInfo("Cache file content outdated (param)"); - break; - } - if (fread(sharead, 1, 20, fp) != 20) { - throw std::runtime_error("Cache file corrupt"); - } - if (!mProcessingSettings.rtc.ignoreCacheValid && memcmp(sharead, shacmd, 20)) { - GPUInfo("Cache file content outdated (commandline)"); - break; - } - if (fread(sharead, 1, 20, fp) != 20) { - throw std::runtime_error("Cache file corrupt"); - } - if (!mProcessingSettings.rtc.ignoreCacheValid && memcmp(sharead, shakernels, 20)) { - GPUInfo("Cache file content outdated (kernel definitions)"); + auto checkSHA = [&](const char* shacmp, const char* name) { + if (fread(sharead, 1, 20, fp) != 20) { + throw std::runtime_error("Cache file corrupt"); + } + if (mProcessingSettings.debugLevel >= 3) { + char shaprint1[41], shaprint2[41]; + for (uint32_t i = 0; i < 20; i++) { + sprintf(shaprint1 + 2 * i, "%02X ", shacmp[i]); + sprintf(shaprint2 + 2 * i, "%02X ", sharead[i]); + } + GPUInfo("SHA for %s: expected %s, read %s", name, shaprint1, shaprint2); + } + if (!mProcessingSettings.rtctech.ignoreCacheValid && memcmp(sharead, shacmp, 20)) { + GPUInfo("Cache file content outdated (%s)", name); + return 1; + } + return 0; + }; + if (checkSHA(shasource, "source") || + checkSHA(shaparam, "param") || + checkSHA(shacmd, "command line") || + checkSHA(shakernels, "kernel definitions") || + checkSHA(shabounds, "launch bounds")) { break; } GPUSettingsProcessingRTC cachedSettings; @@ -121,7 +144,7 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile) if (fread(&cachedSettings, sizeof(cachedSettings), 1, fp) != 1) { throw std::runtime_error("Cache file corrupt"); } - if (!mProcessingSettings.rtc.ignoreCacheValid && !(cachedSettings == mProcessingSettings.rtc)) { + if (!mProcessingSettings.rtctech.ignoreCacheValid && !(cachedSettings == mProcessingSettings.rtc)) { GPUInfo("Cache file content outdated (rtc parameters)"); break; } @@ -169,11 +192,12 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile) kernel += mProcessingSettings.rtc.compilePerKernel ? kernels[i] : kernelsall; kernel += "}"; - bool deterministic = mProcessingSettings.rtc.deterministic || o2::gpu::internal::noFastMathKernels.find(GetKernelName(i)) != o2::gpu::internal::noFastMathKernels.end(); + bool deterministic = mProcessingSettings.rtc.deterministic || (mProcessingSettings.rtc.compilePerKernel && o2::gpu::internal::noFastMathKernels.find(GetKernelName(i)) != o2::gpu::internal::noFastMathKernels.end()); const std::string deterministicStr = std::string(deterministic ? "#define GPUCA_DETERMINISTIC_CODE(det, indet) det\n" : "#define GPUCA_DETERMINISTIC_CODE(det, indet) indet\n"); if (fwrite(deterministicStr.c_str(), 1, deterministicStr.size(), fp) != deterministicStr.size() || fwrite(rtcparam.c_str(), 1, rtcparam.size(), fp) != rtcparam.size() || + fwrite(launchBounds.c_str(), 1, launchBounds.size(), fp) != launchBounds.size() || fwrite(_binary_GPUReconstructionCUDArtc_src_start, 1, _binary_GPUReconstructionCUDArtc_src_len, fp) != _binary_GPUReconstructionCUDArtc_src_len || fwrite(kernel.c_str(), 1, kernel.size(), fp) != kernel.size()) { throw std::runtime_error("Error writing file"); @@ -203,7 +227,7 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile) GPUInfo("RTC Compilation finished (%f seconds)", rtcTimer.GetCurrentElapsedTime()); } if (mProcessingSettings.rtc.cacheOutput) { - FILE* fp = fopen((mProcessingSettings.RTCcacheFolder + "/rtc.cuda.cache").c_str(), "w+b"); + FILE* fp = fopen((mProcessingSettings.rtctech.cacheFolder + "/rtc.cuda.cache").c_str(), "w+b"); if (fp == nullptr) { throw std::runtime_error("Cannot open cache file for writing"); } @@ -213,6 +237,7 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile) fwrite(shaparam, 1, 20, fp) != 20 || fwrite(shacmd, 1, 20, fp) != 20 || fwrite(shakernels, 1, 20, fp) != 20 || + fwrite(shabounds, 1, 20, fp) != 20 || fwrite(&mProcessingSettings.rtc, sizeof(mProcessingSettings.rtc), 1, fp) != 1) { throw std::runtime_error("Error writing cache file"); } @@ -240,7 +265,7 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile) fclose(fp); } } - if (mProcessingSettings.rtc.cacheOutput && mProcessingSettings.rtc.cacheMutex) { + if (mProcessingSettings.rtc.cacheOutput && mProcessingSettings.rtctech.cacheMutex) { if (lockf(fd, F_ULOCK, 0)) { throw std::runtime_error("Error unlocking RTC cache mutex file"); } diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesHost.h b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesSystem.h similarity index 91% rename from GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesHost.h rename to GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesSystem.h index e3e26e6482fc4..1cb3679fc30dc 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesHost.h +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesSystem.h @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file GPUReconstructionCUDAIncludes.h +/// \file GPUReconstructionCUDAIncludesSystem.h /// \author David Rohr #ifndef O2_GPU_GPURECONSTRUCTIONCUDAINCLUDES_H @@ -32,8 +32,4 @@ #include #include -#ifndef GPUCA_RTC_CODE -#include "GPUReconstructionCUDADef.h" -#endif - #endif diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAKernels.cu b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAKernels.cu index 4b3f8a767226c..f8efd8428f035 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAKernels.cu +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAKernels.cu @@ -12,7 +12,8 @@ /// \file GPUReconstructionCUDAKernels.cu /// \author David Rohr -#include "GPUReconstructionCUDAIncludesHost.h" +#include "GPUReconstructionCUDAIncludesSystem.h" +#include "GPUReconstructionCUDADef.h" #include "GPUReconstructionCUDA.h" #include "GPUReconstructionCUDAInternals.h" @@ -83,17 +84,14 @@ void GPUReconstructionCUDABackend::runKernelBackend(const krnlSetupArgs(const krnlSetupArgs& args); +#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types, ...) template void GPUReconstructionCUDABackend::runKernelBackend(const krnlSetupArgs& args); #else // ---------- COMPILE_MODE = onefile | rdc ---------- #if defined(GPUCA_KERNEL_COMPILE_MODE) && GPUCA_KERNEL_COMPILE_MODE == 2 #define GPUCA_KRNL_DEFONLY // COMPILE_MODE = rdc #endif -#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types) \ - GPUCA_KRNL_PROP(x_class, x_attributes) \ - GPUCA_KRNL_HOST(x_class, x_attributes, x_arguments, x_forward, x_types) \ +#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types, ...) \ + GPUCA_KRNL_HOST(x_class, x_attributes, x_arguments, x_forward, x_types, __VA_ARGS__) \ template void GPUReconstructionCUDABackend::runKernelBackend(const krnlSetupArgs& args); #ifndef __HIPCC__ // CUDA version @@ -111,13 +109,6 @@ void GPUReconstructionCUDABackend::runKernelBackend(const krnlSetupArgs& kernels) -{ -#define GPUCA_KRNL(...) kernels.emplace_back(GPUCA_M_STR(GPUCA_KRNLGPU(__VA_ARGS__))); -#include "GPUReconstructionKernelList.h" -#undef GPUCA_KRNL -} - #ifndef GPUCA_NO_CONSTANT_MEMORY static GPUReconstructionDeviceBase::deviceConstantMemRegistration registerConstSymbol([]() { void* retVal = nullptr; @@ -127,3 +118,14 @@ static GPUReconstructionDeviceBase::deviceConstantMemRegistration registerConstS return retVal; }); #endif + +void GPUReconstructionCUDABackend::getRTCKernelCalls(std::vector& kernels) +{ +#undef GPUCA_KRNL_LB +#undef __launch_bounds__ +#define GPUCA_KRNL(...) kernels.emplace_back(GPUCA_M_STR(GPUCA_KRNLGPU(__VA_ARGS__))); +#define GPUCA_KRNL_LB(x_class, x_attributes, ...) GPUCA_KRNL(x_class, (REG, (GPUCA_M_CAT(GPUCA_RTC_LB_, GPUCA_M_KRNL_NAME(x_class))), GPUCA_M_STRIP(x_attributes)), __VA_ARGS__) +#include "GPUReconstructionKernelList.h" +#undef GPUCA_KRNL +#undef GPUCA_KRNL_LB +} diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAkernel.template.cu b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAkernel.template.cu index 3140c6b9158ad..847011a70f7f9 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAkernel.template.cu +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAkernel.template.cu @@ -13,9 +13,10 @@ /// \author David Rohr #define GPUCA_GPUCODE_COMPILEKERNELS -#include "GPUReconstructionCUDAIncludesHost.h" +#include "GPUReconstructionCUDAIncludesSystem.h" #define GPUCA_KRNL_REG(args) __launch_bounds__(GPUCA_M_MAX2_3(GPUCA_M_STRIP(args))) #define GPUCA_KRNL(...) GPUCA_KRNLGPU(__VA_ARGS__); +#include "GPUReconstructionCUDADef.h" #include "GPUReconstructionKernelMacros.h" // clang-format off diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDArtc.cu b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDArtc.cu index 919b5c11477ef..50a568ab345cf 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDArtc.cu +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDArtc.cu @@ -16,7 +16,7 @@ #define GPUCA_GPUCODE_COMPILEKERNELS #define GPUCA_RTC_SPECIAL_CODE(...) GPUCA_RTC_SPECIAL_CODE(__VA_ARGS__) #define GPUCA_DETERMINISTIC_CODE(...) GPUCA_DETERMINISTIC_CODE(__VA_ARGS__) -// GPUReconstructionCUDAIncludesHost.h auto-prependended without preprocessor running +// GPUReconstructionCUDAIncludesSystem.h prependended without preprocessor running #include "GPUReconstructionCUDADef.h" #include "GPUReconstructionIncludesDeviceAll.h" diff --git a/GPU/GPUTracking/Base/hip/CMakeLists.txt b/GPU/GPUTracking/Base/hip/CMakeLists.txt index 43259decef956..5796c0c48686b 100644 --- a/GPU/GPUTracking/Base/hip/CMakeLists.txt +++ b/GPU/GPUTracking/Base/hip/CMakeLists.txt @@ -25,7 +25,7 @@ if(NOT DEFINED GPUCA_HIP_HIPIFY_FROM_CUDA OR "${GPUCA_HIP_HIPIFY_FROM_CUDA}") set(GPUCA_HIP_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/hipify) file(MAKE_DIRECTORY ${GPUCA_HIP_SOURCE_DIR}) set(GPUCA_HIP_FILE_LIST GPUReconstructionCUDA.cu GPUReconstructionCUDAExternalProvider.cu GPUReconstructionCUDA.h GPUReconstructionCUDAInternals.h GPUReconstructionCUDAHelpers.inc GPUReconstructionCUDAkernel.template.cu GPUReconstructionCUDADef.h GPUReconstructionCUDAGenRTC.cxx GPUReconstructionCUDAKernels.cu GPUReconstructionCUDArtc.cu) - set(GPUCA_HIP_LOCAL_FILE_LIST GPUReconstructionHIPIncludesHost.h) + set(GPUCA_HIP_LOCAL_FILE_LIST GPUReconstructionHIPIncludesSystem.h) set(HIP_SOURCES "") foreach(file ${GPUCA_HIP_FILE_LIST}) get_filename_component(ABS_CUDA_SORUCE ../cuda/${file} ABSOLUTE) @@ -63,7 +63,7 @@ endif() set(SRCS ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIP.hip ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPKernels.hip) set(SRCS_CXX ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPGenRTC.cxx) -set(HDRS ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIP.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPInternals.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPHelpers.inc ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPDef.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPIncludesHost.h) +set(HDRS ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIP.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPInternals.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPHelpers.inc ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPDef.h ${GPUCA_HIP_SOURCE_DIR}/GPUReconstructionHIPIncludesSystem.h) # -------------------------------- Prepare RTC ------------------------------------------------------- enable_language(ASM) @@ -104,8 +104,8 @@ set(GPU_RTC_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionHIPrtc) # cmake-format: off add_custom_command( OUTPUT ${GPU_RTC_BIN}.src - COMMAND cp ${GPUDIR}/Base/hip/GPUReconstructionHIPIncludesHost.h ${GPU_RTC_BIN}.src - COMMAND ${CMAKE_CXX_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_HIP_STANDARD} -D__HIPCC__ -D__HIP_DEVICE_COMPILE__ -x c++ -nostdinc -E ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src + COMMAND cp ${GPUDIR}/Base/hip/GPUReconstructionHIPIncludesSystem.h ${GPU_RTC_BIN}.src + COMMAND ${CMAKE_CXX_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_HIP_STANDARD} -D__HIPCC__ -D__HIP_DEVICE_COMPILE__ -x c++ -nostdinc -E -P ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src MAIN_DEPENDENCY ${GPU_RTC_SRC} IMPLICIT_DEPENDS CXX ${GPU_RTC_SRC} DEPENDS ${MODULE}_HIPIFIED @@ -122,7 +122,7 @@ add_custom_target(${MODULE}_HIP_SRC_CHK ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ add_custom_command( OUTPUT ${GPU_RTC_BIN}.command - COMMAND echo -n "${CMAKE_HIP_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_FLAGS_SEPARATED} -x hip --cuda-device-only" > ${GPU_RTC_BIN}.command + COMMAND echo -n "${CMAKE_HIP_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_FLAGS_SEPARATED} -x hip --cuda-device-only -Wno-unused-const-variable" > ${GPU_RTC_BIN}.command COMMAND_EXPAND_LISTS VERBATIM COMMENT "Preparing HIP RTC command file ${GPU_RTC_BIN}.command" ) diff --git a/GPU/GPUTracking/Base/hip/GPUReconstructionHIPIncludesHost.h b/GPU/GPUTracking/Base/hip/GPUReconstructionHIPIncludesSystem.h similarity index 89% rename from GPU/GPUTracking/Base/hip/GPUReconstructionHIPIncludesHost.h rename to GPU/GPUTracking/Base/hip/GPUReconstructionHIPIncludesSystem.h index 5506e3925bf80..cfe1121ef1089 100644 --- a/GPU/GPUTracking/Base/hip/GPUReconstructionHIPIncludesHost.h +++ b/GPU/GPUTracking/Base/hip/GPUReconstructionHIPIncludesSystem.h @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file GPUReconstructionHIPIncludesHost.h +/// \file GPUReconstructionHIPIncludesSystem.h /// \author David Rohr #ifndef O2_GPU_RECONSTRUCTIONHIPINCLUDES_H @@ -25,8 +25,4 @@ #include #pragma GCC diagnostic pop -#ifndef GPUCA_RTC_CODE -#include "GPUReconstructionHIPDef.h" -#endif - #endif diff --git a/GPU/GPUTracking/Base/hip/GPUReconstructionHIPkernel.template.hip b/GPU/GPUTracking/Base/hip/GPUReconstructionHIPkernel.template.hip index 427938a3bd704..d5ac1d14c2d9e 100644 --- a/GPU/GPUTracking/Base/hip/GPUReconstructionHIPkernel.template.hip +++ b/GPU/GPUTracking/Base/hip/GPUReconstructionHIPkernel.template.hip @@ -13,9 +13,10 @@ /// \author David Rohr #define GPUCA_GPUCODE_COMPILEKERNELS -#include "GPUReconstructionHIPIncludesHost.h" +#include "GPUReconstructionHIPIncludesSystem.h" #define GPUCA_KRNL_REG(args) __launch_bounds__(GPUCA_M_MAX2_3(GPUCA_M_STRIP(args))) #define GPUCA_KRNL(...) GPUCA_KRNLGPU(__VA_ARGS__); +#include "GPUReconstructionHIPDef.h" #include "GPUReconstructionKernelMacros.h" // clang-format off diff --git a/GPU/GPUTracking/Base/opencl/CMakeLists.txt b/GPU/GPUTracking/Base/opencl/CMakeLists.txt index 48f292a198b9c..7ab70553958ef 100644 --- a/GPU/GPUTracking/Base/opencl/CMakeLists.txt +++ b/GPU/GPUTracking/Base/opencl/CMakeLists.txt @@ -23,9 +23,9 @@ endif() set(CL_SRC ${GPUDIR}/Base/opencl/GPUReconstructionOCL.cl) set(CL_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionOCLCode) -set(OCL_FLAGS -Dcl_clang_storage_class_specifiers -cl-std=CLC++2021) +set(OCL_FLAGS -Dcl_clang_storage_class_specifiers -cl-std=CLC++2021 ${GPUCA_OCL_DENORMALS_FLAGS}) if(NOT GPUCA_DETERMINISTIC_MODE GREATER_EQUAL ${GPUCA_DETERMINISTIC_MODE_MAP_NO_FAST_MATH}) - set(OCL_FLAGS ${OCL_FLAGS} -cl-denorms-are-zero -cl-mad-enable -cl-no-signed-zeros -cl-fast-relaxed-math) + set(OCL_FLAGS ${OCL_FLAGS} -cl-mad-enable -cl-no-signed-zeros -cl-fast-relaxed-math) else() set(OCL_FLAGS ${OCL_FLAGS} ${GPUCA_OCL_NO_FAST_MATH_FLAGS}) endif() @@ -76,7 +76,7 @@ if(OPENCL_ENABLED) # BUILD OpenCL source code for runtime compilation target ${OCL_DEFINECL} -cl-no-stdinc -nostdinc - -E ${CL_SRC} > ${CL_BIN}.src + -E -P ${CL_SRC} > ${CL_BIN}.src MAIN_DEPENDENCY ${CL_SRC} IMPLICIT_DEPENDS CXX ${CL_SRC} COMMAND_EXPAND_LISTS diff --git a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx index e724f0f2cbfcd..7310b8b6041a9 100644 --- a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx +++ b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx @@ -12,7 +12,10 @@ /// \file GPUReconstructionOCL.cxx /// \author David Rohr +#define GPUCA_DEF_PARAMETERS_LOAD_DEFAULTS #include "GPUReconstructionOCLIncludesHost.h" +#include "GPUDefParametersDefault.h" +#include "GPUDefParametersLoad.inc" #include @@ -36,6 +39,7 @@ GPUReconstructionOCLBackend::GPUReconstructionOCLBackend(const GPUSettingsDevice { if (mMaster == nullptr) { mInternals = new GPUReconstructionOCLInternals; + *mParDevice = o2::gpu::internal::GPUDefParametersLoad(); } mDeviceBackendSettings.deviceType = DeviceType::OCL; } diff --git a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.h b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.h index 29951cd43f167..16ef9b5e87fe8 100644 --- a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.h +++ b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.h @@ -58,8 +58,6 @@ class GPUReconstructionOCLBackend : public GPUReconstructionDeviceBase int32_t AddKernel(); template void runKernelBackendInternal(const krnlSetupTime& _xyz, const Args&... args); - template - gpu_reconstruction_kernels::krnlProperties getKernelPropertiesBackend(); GPUReconstructionOCLInternals* mInternals; float mOclVersion; diff --git a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLKernels.cxx b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLKernels.cxx index fff69038c056f..cca634fba65fc 100644 --- a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLKernels.cxx +++ b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCLKernels.cxx @@ -91,8 +91,6 @@ int32_t GPUReconstructionOCLBackend::AddKernels() return 0; } -#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types) \ - GPUCA_KRNL_PROP(x_class, x_attributes) \ - template void GPUReconstructionOCLBackend::runKernelBackend(const krnlSetupArgs& args); +#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types, ...) template void GPUReconstructionOCLBackend::runKernelBackend(const krnlSetupArgs& args); #include "GPUReconstructionKernelList.h" #undef GPUCA_KRNL diff --git a/GPU/GPUTracking/CMakeLists.txt b/GPU/GPUTracking/CMakeLists.txt index ad7dd9c210cd1..fe2fefe2412c0 100644 --- a/GPU/GPUTracking/CMakeLists.txt +++ b/GPU/GPUTracking/CMakeLists.txt @@ -17,11 +17,12 @@ set(MODULE GPUTracking) if(GPUCA_DETERMINISTIC_MODE GREATER_EQUAL ${GPUCA_DETERMINISTIC_MODE_MAP_NO_FAST_MATH}) set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} ${GPUCA_CXX_NO_FAST_MATH_FLAGS}") if(GPUCA_DETERMINISTIC_MODE GREATER_EQUAL ${GPUCA_DETERMINISTIC_MODE_MAP_OPTO2}) - set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} -O2 ${GPUCA_CLANG_FTZ}") + set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} -O2") endif() elseif(NOT CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG") - set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} -O3 -ffast-math ${GPUCA_CLANG_FTZ}") + set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} -O3 -ffast-math") endif() +set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} ${GPUCA_CXX_DENORMALS_FLAGS}") include(cmake/helpers.cmake) @@ -128,7 +129,7 @@ set(HDRS_INSTALL DataTypes/GPUTriggerOutputs.h Debug/GPUROOTDump.h Definitions/GPUDefConstantsAndSettings.h - Definitions/GPUDefGPUParameters.h + Definitions/GPUDefParametersDefault.h Definitions/GPUDef.h Definitions/GPUDefMacros.h Definitions/GPULogging.h @@ -246,10 +247,18 @@ file(GENERATE OUTPUT include_gpu_onthefly/GPUNoFastMathKernels.h INPUT cmake/GPUNoFastMathKernels.template.h ) +file(GENERATE + OUTPUT include_gpu_onthefly/GPUDefParameters.h + INPUT Definitions/GPUDefParameters.template.h +) +file(GENERATE + OUTPUT include_gpu_onthefly/GPUDefParametersLoad.inc + INPUT Definitions/GPUDefParametersLoad.template.inc +) if(NOT ALIGPU_BUILD_TYPE STREQUAL "O2") include_directories(${CMAKE_CURRENT_BINARY_DIR}/include_gpu_onthefly) endif() -set(HDRS_INSTALL ${HDRS_INSTALL} ${CMAKE_CURRENT_BINARY_DIR}/include_gpu_onthefly/GPUReconstructionKernelList.h) +set(HDRS_INSTALL ${HDRS_INSTALL} ${CMAKE_CURRENT_BINARY_DIR}/include_gpu_onthefly/GPUReconstructionKernelList.h ${CMAKE_CURRENT_BINARY_DIR}/include_gpu_onthefly/GPUDefParameters.h ${CMAKE_CURRENT_BINARY_DIR}/include_gpu_onthefly/GPUDefParametersLoad.inc) include(kernels.cmake) # Optional sources depending on optional dependencies @@ -367,13 +376,18 @@ if(ALIGPU_BUILD_TYPE STREQUAL "Standalone") if(GPUCA_CONFIG_ROOT) ROOT_GENERATE_DICTIONARY(G__${targetName} ${HDRS_CINT_O2} ${HDRS_CINT_DATATYPES} ${HDRS_CINT_O2_ADDITIONAL} GPUTrackingLinkDef_Standalone.h MODULE ${targetName}) - INSTALL(FILES + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${targetName}_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/lib${targetName}.rootmap DESTINATION .) else() target_compile_definitions(${targetName} PRIVATE GPUCA_NO_ROOT) endif() + install(FILES ${HDRS_SRCS} ${HDRS_CINT_O2} ${HDRS_CINT_DATATYPES} ${HDRS_INSTALL} + DESTINATION include) + install(DIRECTORY utils + DESTINATION include + FILES_MATCHING PATTERN *.h) endif() # GPUReconstructionLibrary needs to know which GPU backends are enabled for proper error messages diff --git a/GPU/GPUTracking/Definitions/GPUDef.h b/GPU/GPUTracking/Definitions/GPUDef.h index f01e3e6d38332..404f35f971c94 100644 --- a/GPU/GPUTracking/Definitions/GPUDef.h +++ b/GPU/GPUTracking/Definitions/GPUDef.h @@ -18,7 +18,7 @@ #include "GPUCommonDef.h" #include "GPUDefConstantsAndSettings.h" -#include "GPUDefGPUParameters.h" +#include "GPUDefParametersDefault.h" #include "GPUCommonRtypes.h" // Macros for masking ptrs in OpenCL kernel calls as uint64_t (The API only allows us to pass buffer objects) diff --git a/GPU/GPUTracking/Definitions/GPUDefConstantsAndSettings.h b/GPU/GPUTracking/Definitions/GPUDefConstantsAndSettings.h index f18390629f2bc..2d7aca8d71b92 100644 --- a/GPU/GPUTracking/Definitions/GPUDefConstantsAndSettings.h +++ b/GPU/GPUTracking/Definitions/GPUDefConstantsAndSettings.h @@ -13,7 +13,7 @@ /// \author David Rohr // This files contains compile-time constants affecting the GPU algorithms / reconstruction results. -// Architecture-dependant compile-time constants affecting the performance without changing the results are stored in GPUDefGPUParameters.h +// Architecture-dependant compile-time constants affecting the performance without changing the results are stored in GPUDefParameters.h #ifndef GPUDEFCONSTANTSANDSETTINGS_H #define GPUDEFCONSTANTSANDSETTINGS_H @@ -66,7 +66,7 @@ #endif #endif -//#define GPUCA_MERGER_BY_MC_LABEL // Use MC labels for TPC track merging - for performance studies +//#define GPUCA_MERGER_BY_MC_LABEL // Use MC labels for TPC track merging - for performance studies // TODO: Cleanup unneeded options //#define GPUCA_FULL_CLUSTERDATA // Store all cluster information in the cluster data, also those not needed for tracking. //#define GPUCA_TPC_RAW_PROPAGATE_PAD_ROW_TIME // Propagate Pad, Row, Time cluster information to GM //#define GPUCA_GM_USE_FULL_FIELD // Use offline magnetic field during GMPropagator prolongation diff --git a/GPU/GPUTracking/Definitions/GPUDefParameters.template.h b/GPU/GPUTracking/Definitions/GPUDefParameters.template.h new file mode 100644 index 0000000000000..731cb76b89193 --- /dev/null +++ b/GPU/GPUTracking/Definitions/GPUDefParameters.template.h @@ -0,0 +1,27 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GPUDefParameters.h +/// \author David Rohr + +#ifndef GPUDEFPARAMETERS_H +#define GPUDEFPARAMETERS_H + +namespace o2::gpu +{ +struct GPUDefParameters { // clang-format off + int32_t par_LB_maxThreads[$>] = {}; + int32_t par_LB_minBlocks[$>] = {}; + int32_t par_LB_forceBlocks[$>] = {}; +}; // clang-format on +} // namespace o2::gpu + +#endif diff --git a/GPU/GPUTracking/Definitions/GPUDefGPUParameters.h b/GPU/GPUTracking/Definitions/GPUDefParametersDefault.h similarity index 69% rename from GPU/GPUTracking/Definitions/GPUDefGPUParameters.h rename to GPU/GPUTracking/Definitions/GPUDefParametersDefault.h index 910907368e891..60403f3afbffc 100644 --- a/GPU/GPUTracking/Definitions/GPUDefGPUParameters.h +++ b/GPU/GPUTracking/Definitions/GPUDefParametersDefault.h @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file GPUDefGPUParameters.h +/// \file GPUDefParametersDefault.h /// \author David Rohr // This files contains compile-time constants affecting the GPU performance. @@ -17,17 +17,15 @@ // This file also contains all constants describing memory limitations, essentially limiting the total number of tracks, etc. // Compile-time constants affecting the tracking algorithms / results are located in GPUDefConstantsAndSettings.h -#ifndef GPUDEFGPUPARAMETERS_H -#define GPUDEFGPUPARAMETERS_H +#ifndef GPUDEFPARAMETERSDEFAULT_H +#define GPUDEFPARAMETERSDEFAULT_H // clang-format off -#ifndef GPUDEF_H -#error Please include GPUDef.h -#endif - #include "GPUCommonDef.h" #include "GPUDefMacros.h" +// Launch bound definition, 3 optional parameters: maxThreads per block, minBlocks per multiprocessor, force number of blocks (not passed to compiler as launch bounds) + // GPU Run Configuration #ifdef GPUCA_GPUCODE #if defined(GPUCA_GPUTYPE_MI2xx) @@ -282,7 +280,7 @@ #endif // GPUCA_GPUCODE #ifdef GPUCA_GPUCODE - // Default settings, if not already set for selected GPU type + // Default settings for GPU, if not already set for selected GPU type #ifndef GPUCA_THREAD_COUNT #define GPUCA_THREAD_COUNT 256 #endif @@ -334,10 +332,10 @@ #ifndef GPUCA_LB_GPUTPCDecompressionUtilKernels_sortPerSectorRow #define GPUCA_LB_GPUTPCDecompressionUtilKernels_sortPerSectorRow 256 #endif - #ifndef GPUCA_LB_GPUTPCDecompressionUtilKernels_countFilteredClusters + #ifndef GPUCA_LB_GPUTPCDecompressionUtilKernels_countFilteredClusters #define GPUCA_LB_GPUTPCDecompressionUtilKernels_countFilteredClusters 256 #endif - #ifndef GPUCA_LB_GPUTPCDecompressionUtilKernels_storeFilteredClusters + #ifndef GPUCA_LB_GPUTPCDecompressionUtilKernels_storeFilteredClusters #define GPUCA_LB_GPUTPCDecompressionUtilKernels_storeFilteredClusters 256 #endif #ifndef GPUCA_LB_GPUTPCCFDecodeZS @@ -487,10 +485,15 @@ #ifndef GPUCA_LB_GPUTrackingRefitKernel_mode1asTrackParCov #define GPUCA_LB_GPUTrackingRefitKernel_mode1asTrackParCov 256 #endif + #ifndef GPUCA_LB_GPUMemClean16 + #define GPUCA_LB_GPUMemClean16 GPUCA_THREAD_COUNT, 1 + #endif + #ifndef GPUCA_LB_GPUitoa + #define GPUCA_LB_GPUitoa GPUCA_THREAD_COUNT, 1 + #endif #define GPUCA_GET_THREAD_COUNT(...) GPUCA_M_FIRST(__VA_ARGS__) #else - // The following defaults are needed to compile the host code - #define GPUCA_GET_THREAD_COUNT(...) 1 + #define GPUCA_GET_THREAD_COUNT(...) 1 // On the host, a thread is a block, and we run 1 "device thread" per block. #endif #define GPUCA_GET_WARP_COUNT(...) (GPUCA_GET_THREAD_COUNT(__VA_ARGS__) / GPUCA_WARP_SIZE) @@ -514,8 +517,6 @@ #define GPUCA_LB_GPUTPCCFStreamCompaction_scanTop GPUCA_THREAD_COUNT_SCAN #define GPUCA_LB_GPUTPCCFStreamCompaction_scanDown GPUCA_THREAD_COUNT_SCAN #define GPUCA_LB_GPUTPCCFStreamCompaction_compactDigits GPUCA_THREAD_COUNT_SCAN -#define GPUCA_LB_GPUTPCTrackletConstructor_singleSector GPUCA_LB_GPUTPCTrackletConstructor -#define GPUCA_LB_GPUTPCTrackletConstructor_allSectors GPUCA_LB_GPUTPCTrackletConstructor #define GPUCA_LB_GPUTPCCompressionGatherKernels_unbuffered GPUCA_LB_COMPRESSION_GATHER #define GPUCA_LB_GPUTPCCompressionGatherKernels_buffered32 GPUCA_LB_COMPRESSION_GATHER #define GPUCA_LB_GPUTPCCompressionGatherKernels_buffered64 GPUCA_LB_COMPRESSION_GATHER @@ -523,33 +524,33 @@ #define GPUCA_LB_GPUTPCCompressionGatherKernels_multiBlock GPUCA_LB_COMPRESSION_GATHER #if defined(__CUDACC__) || defined(__HIPCC__) -#define GPUCA_SPECIALIZE_THRUST_SORTS + #define GPUCA_SPECIALIZE_THRUST_SORTS #endif #ifndef GPUCA_NEIGHBORSFINDER_REGS -#define GPUCA_NEIGHBORSFINDER_REGS NONE, 0 + #define GPUCA_NEIGHBORSFINDER_REGS NONE, 0 #endif #ifdef GPUCA_GPUCODE #ifndef GPUCA_NEIGHBOURS_FINDER_MAX_NNEIGHUP - #define GPUCA_NEIGHBOURS_FINDER_MAX_NNEIGHUP 6 + #define GPUCA_NEIGHBOURS_FINDER_MAX_NNEIGHUP 6 #endif #ifndef GPUCA_TRACKLET_SELECTOR_HITS_REG_SIZE - #define GPUCA_TRACKLET_SELECTOR_HITS_REG_SIZE 12 + #define GPUCA_TRACKLET_SELECTOR_HITS_REG_SIZE 12 #endif #ifndef GPUCA_ALTERNATE_BORDER_SORT - #define GPUCA_ALTERNATE_BORDER_SORT 0 + #define GPUCA_ALTERNATE_BORDER_SORT 0 #endif #ifndef GPUCA_SORT_BEFORE_FIT - #define GPUCA_SORT_BEFORE_FIT 0 + #define GPUCA_SORT_BEFORE_FIT 0 #endif #ifndef GPUCA_MERGER_SPLIT_LOOP_INTERPOLATION - #define GPUCA_MERGER_SPLIT_LOOP_INTERPOLATION 0 + #define GPUCA_MERGER_SPLIT_LOOP_INTERPOLATION 0 #endif #ifndef GPUCA_COMP_GATHER_KERNEL - #define GPUCA_COMP_GATHER_KERNEL 0 + #define GPUCA_COMP_GATHER_KERNEL 0 #endif #ifndef GPUCA_COMP_GATHER_MODE - #define GPUCA_COMP_GATHER_MODE 2 + #define GPUCA_COMP_GATHER_MODE 2 #endif #else #define GPUCA_NEIGHBOURS_FINDER_MAX_NNEIGHUP 0 @@ -562,20 +563,20 @@ #define GPUCA_COMP_GATHER_MODE 0 #endif #ifndef GPUCA_DEDX_STORAGE_TYPE -#define GPUCA_DEDX_STORAGE_TYPE float + #define GPUCA_DEDX_STORAGE_TYPE float #endif #ifndef GPUCA_MERGER_INTERPOLATION_ERROR_TYPE -#define GPUCA_MERGER_INTERPOLATION_ERROR_TYPE float + #define GPUCA_MERGER_INTERPOLATION_ERROR_TYPE float #endif #define GPUCA_MERGER_INTERPOLATION_ERROR_TYPE_A GPUCA_DETERMINISTIC_CODE(float, GPUCA_MERGER_INTERPOLATION_ERROR_TYPE) #define GPUCA_DEDX_STORAGE_TYPE_A GPUCA_DETERMINISTIC_CODE(float, GPUCA_DEDX_STORAGE_TYPE) #ifndef GPUCA_WARP_SIZE -#ifdef GPUCA_GPUCODE -#define GPUCA_WARP_SIZE 32 -#else -#define GPUCA_WARP_SIZE 1 -#endif + #ifdef GPUCA_GPUCODE + #define GPUCA_WARP_SIZE 32 + #else + #define GPUCA_WARP_SIZE 1 + #endif #endif #define GPUCA_MAX_THREADS 1024 @@ -602,10 +603,10 @@ // #define GPUCA_KERNEL_DEBUGGER_OUTPUT -// Some assertions to make sure out parameters are not invalid -static_assert(GPUCA_MAXN >= GPUCA_NEIGHBOURS_FINDER_MAX_NNEIGHUP, "Invalid GPUCA_NEIGHBOURS_FINDER_MAX_NNEIGHUP"); -static_assert(GPUCA_ROW_COUNT >= GPUCA_TRACKLET_SELECTOR_HITS_REG_SIZE, "Invalid GPUCA_TRACKLET_SELECTOR_HITS_REG_SIZE"); -#ifdef GPUCA_GPUCODE +// Some assertions to make sure the parameters are not invalid +#if defined(GPUCA_GPUCODE) + static_assert(GPUCA_MAXN >= GPUCA_NEIGHBOURS_FINDER_MAX_NNEIGHUP, "Invalid GPUCA_NEIGHBOURS_FINDER_MAX_NNEIGHUP"); + static_assert(GPUCA_ROW_COUNT >= GPUCA_TRACKLET_SELECTOR_HITS_REG_SIZE, "Invalid GPUCA_TRACKLET_SELECTOR_HITS_REG_SIZE"); static_assert(GPUCA_M_FIRST(GPUCA_LB_GPUTPCCompressionKernels_step1unattached) * 2 <= GPUCA_TPC_COMP_CHUNK_SIZE, "Invalid GPUCA_TPC_COMP_CHUNK_SIZE"); #endif @@ -621,5 +622,270 @@ static_assert(GPUCA_ROW_COUNT >= GPUCA_TRACKLET_SELECTOR_HITS_REG_SIZE, "Invalid #define GPUCA_NEW_ALIGNMENT (std::align_val_t{GPUCA_BUFFER_ALIGNMENT}) #define GPUCA_OPERATOR_NEW_ALIGNMENT ,GPUCA_NEW_ALIGNMENT +#ifdef GPUCA_DEF_PARAMETERS_LOAD_DEFAULTS + // Invalid default values, must not be used, but needed for now to make the GPUDefParametersLoad() happy // TOCO: cleanup + #ifndef GPUCA_LB_GPUTPCCreateTrackingData + #define GPUCA_LB_GPUTPCCreateTrackingData 0 + #endif + #ifndef GPUCA_LB_GPUTPCTrackletConstructor + #define GPUCA_LB_GPUTPCTrackletConstructor 0 + #endif + #ifndef GPUCA_LB_GPUTPCTrackletSelector + #define GPUCA_LB_GPUTPCTrackletSelector 0 + #endif + #ifndef GPUCA_LB_GPUTPCNeighboursFinder + #define GPUCA_LB_GPUTPCNeighboursFinder 0 + #endif + #ifndef GPUCA_LB_GPUTPCNeighboursCleaner + #define GPUCA_LB_GPUTPCNeighboursCleaner 0 + #endif + #ifndef GPUCA_LB_GPUTPCExtrapolationTracking + #define GPUCA_LB_GPUTPCExtrapolationTracking 0 + #endif + #ifndef GPUCA_LB_GPUTRDTrackerKernels_gpuVersion + #define GPUCA_LB_GPUTRDTrackerKernels_gpuVersion 0 + #endif + #ifndef GPUCA_LB_GPUTPCCreateOccupancyMap_fill + #define GPUCA_LB_GPUTPCCreateOccupancyMap_fill 0 + #endif + #ifndef GPUCA_LB_GPUTPCCreateOccupancyMap_fold + #define GPUCA_LB_GPUTPCCreateOccupancyMap_fold 0 + #endif + #ifndef GPUCA_LB_GPUTRDTrackerKernels_o2Version + #define GPUCA_LB_GPUTRDTrackerKernels_o2Version 0 + #endif + #ifndef GPUCA_LB_GPUTPCConvertKernel + #define GPUCA_LB_GPUTPCConvertKernel 0 + #endif + #ifndef GPUCA_LB_GPUTPCCompressionKernels_step0attached + #define GPUCA_LB_GPUTPCCompressionKernels_step0attached 0 + #endif + #ifndef GPUCA_LB_GPUTPCCompressionKernels_step1unattached + #define GPUCA_LB_GPUTPCCompressionKernels_step1unattached 0 + #endif + #ifndef GPUCA_LB_GPUTPCDecompressionKernels_step0attached + #define GPUCA_LB_GPUTPCDecompressionKernels_step0attached 0 + #endif + #ifndef GPUCA_LB_GPUTPCDecompressionKernels_step1unattached + #define GPUCA_LB_GPUTPCDecompressionKernels_step1unattached 0 + #endif + #ifndef GPUCA_LB_GPUTPCDecompressionUtilKernels_sortPerSectorRow + #define GPUCA_LB_GPUTPCDecompressionUtilKernels_sortPerSectorRow 0 + #endif + #ifndef GPUCA_LB_GPUTPCDecompressionUtilKernels_countFilteredClusters + #define GPUCA_LB_GPUTPCDecompressionUtilKernels_countFilteredClusters 0 + #endif + #ifndef GPUCA_LB_GPUTPCDecompressionUtilKernels_storeFilteredClusters + #define GPUCA_LB_GPUTPCDecompressionUtilKernels_storeFilteredClusters 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFDecodeZS + #define GPUCA_LB_GPUTPCCFDecodeZS 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFDecodeZSLink + #define GPUCA_LB_GPUTPCCFDecodeZSLink 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFDecodeZSDenseLink + #define GPUCA_LB_GPUTPCCFDecodeZSDenseLink 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFGather + #define GPUCA_LB_GPUTPCCFGather 0 + #endif + #ifndef GPUCA_LB_COMPRESSION_GATHER + #define GPUCA_LB_COMPRESSION_GATHER 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerTrackFit + #define GPUCA_LB_GPUTPCGMMergerTrackFit 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerFollowLoopers + #define GPUCA_LB_GPUTPCGMMergerFollowLoopers 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerSectorRefit + #define GPUCA_LB_GPUTPCGMMergerSectorRefit 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerUnpackResetIds + #define GPUCA_LB_GPUTPCGMMergerUnpackResetIds 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerUnpackGlobal + #define GPUCA_LB_GPUTPCGMMergerUnpackGlobal 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerResolve_step0 + #define GPUCA_LB_GPUTPCGMMergerResolve_step0 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerResolve_step1 + #define GPUCA_LB_GPUTPCGMMergerResolve_step1 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerResolve_step2 + #define GPUCA_LB_GPUTPCGMMergerResolve_step2 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerResolve_step3 + #define GPUCA_LB_GPUTPCGMMergerResolve_step3 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerResolve_step4 + #define GPUCA_LB_GPUTPCGMMergerResolve_step4 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerClearLinks + #define GPUCA_LB_GPUTPCGMMergerClearLinks 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeWithinPrepare + #define GPUCA_LB_GPUTPCGMMergerMergeWithinPrepare 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeSectorsPrepare + #define GPUCA_LB_GPUTPCGMMergerMergeSectorsPrepare 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeBorders_step0 + #define GPUCA_LB_GPUTPCGMMergerMergeBorders_step0 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeBorders_step2 + #define GPUCA_LB_GPUTPCGMMergerMergeBorders_step2 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeCE + #define GPUCA_LB_GPUTPCGMMergerMergeCE 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerLinkExtrapolatedTracks + #define GPUCA_LB_GPUTPCGMMergerLinkExtrapolatedTracks 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerCollect + #define GPUCA_LB_GPUTPCGMMergerCollect 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerSortTracksPrepare + #define GPUCA_LB_GPUTPCGMMergerSortTracksPrepare 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerPrepareClusters_step0 + #define GPUCA_LB_GPUTPCGMMergerPrepareClusters_step0 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerPrepareClusters_step1 + #define GPUCA_LB_GPUTPCGMMergerPrepareClusters_step1 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerPrepareClusters_step2 + #define GPUCA_LB_GPUTPCGMMergerPrepareClusters_step2 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerFinalize_step0 + #define GPUCA_LB_GPUTPCGMMergerFinalize_step0 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerFinalize_step1 + #define GPUCA_LB_GPUTPCGMMergerFinalize_step1 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerFinalize_step2 + #define GPUCA_LB_GPUTPCGMMergerFinalize_step2 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeLoopers_step0 + #define GPUCA_LB_GPUTPCGMMergerMergeLoopers_step0 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeLoopers_step1 + #define GPUCA_LB_GPUTPCGMMergerMergeLoopers_step1 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeLoopers_step2 + #define GPUCA_LB_GPUTPCGMMergerMergeLoopers_step2 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMO2Output_prepare + #define GPUCA_LB_GPUTPCGMO2Output_prepare 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMO2Output_output + #define GPUCA_LB_GPUTPCGMO2Output_output 0 + #endif + #ifndef GPUCA_LB_GPUITSFitterKernels + #define GPUCA_LB_GPUITSFitterKernels 0 + #endif + #ifndef GPUCA_LB_GPUTPCStartHitsFinder + #define GPUCA_LB_GPUTPCStartHitsFinder 0 + #endif + #ifndef GPUCA_LB_GPUTPCStartHitsSorter + #define GPUCA_LB_GPUTPCStartHitsSorter 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFCheckPadBaseline + #define GPUCA_LB_GPUTPCCFCheckPadBaseline 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFChargeMapFiller_fillIndexMap + #define GPUCA_LB_GPUTPCCFChargeMapFiller_fillIndexMap 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFChargeMapFiller_fillFromDigits + #define GPUCA_LB_GPUTPCCFChargeMapFiller_fillFromDigits 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFChargeMapFiller_findFragmentStart + #define GPUCA_LB_GPUTPCCFChargeMapFiller_findFragmentStart 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFPeakFinder + #define GPUCA_LB_GPUTPCCFPeakFinder 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFNoiseSuppression + #define GPUCA_LB_GPUTPCCFNoiseSuppression 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFDeconvolution + #define GPUCA_LB_GPUTPCCFDeconvolution 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFClusterizer + #define GPUCA_LB_GPUTPCCFClusterizer 0 + #endif + #ifndef GPUCA_LB_GPUTPCNNClusterizerKernels + #define GPUCA_LB_GPUTPCNNClusterizerKernels 0 + #endif + #ifndef GPUCA_LB_GPUTrackingRefitKernel_mode0asGPU + #define GPUCA_LB_GPUTrackingRefitKernel_mode0asGPU 0 + #endif + #ifndef GPUCA_LB_GPUTrackingRefitKernel_mode1asTrackParCov + #define GPUCA_LB_GPUTrackingRefitKernel_mode1asTrackParCov 0 + #endif + #ifndef GPUCA_LB_GPUMemClean16 + #define GPUCA_LB_GPUMemClean16 0 + #endif + #ifndef GPUCA_LB_GPUitoa + #define GPUCA_LB_GPUitoa 0 + #endif + #ifndef GPUCA_LB_GPUTPCExtrapolationTrackingCopyNumbers + #define GPUCA_LB_GPUTPCExtrapolationTrackingCopyNumbers 0 + #endif + #ifndef GPUCA_LB_GPUTPCSectorDebugSortKernels_hitData + #define GPUCA_LB_GPUTPCSectorDebugSortKernels_hitData 0 + #endif + #ifndef GPUCA_LB_GPUTPCSectorDebugSortKernels_startHits + #define GPUCA_LB_GPUTPCSectorDebugSortKernels_startHits 0 + #endif + #ifndef GPUCA_LB_GPUTPCSectorDebugSortKernels_sectorTracks + #define GPUCA_LB_GPUTPCSectorDebugSortKernels_sectorTracks 0 + #endif + #ifndef GPUCA_LB_GPUTPCGlobalDebugSortKernels_clearIds + #define GPUCA_LB_GPUTPCGlobalDebugSortKernels_clearIds 0 + #endif + #ifndef GPUCA_LB_GPUTPCGlobalDebugSortKernels_sectorTracks + #define GPUCA_LB_GPUTPCGlobalDebugSortKernels_sectorTracks 0 + #endif + #ifndef GPUCA_LB_GPUTPCGlobalDebugSortKernels_extrapolatedTracks1 + #define GPUCA_LB_GPUTPCGlobalDebugSortKernels_extrapolatedTracks1 0 + #endif + #ifndef GPUCA_LB_GPUTPCGlobalDebugSortKernels_extrapolatedTracks2 + #define GPUCA_LB_GPUTPCGlobalDebugSortKernels_extrapolatedTracks2 0 + #endif + #ifndef GPUCA_LB_GPUTPCGlobalDebugSortKernels_borderTracks + #define GPUCA_LB_GPUTPCGlobalDebugSortKernels_borderTracks 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerUnpackSaveNumber + #define GPUCA_LB_GPUTPCGMMergerUnpackSaveNumber 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeBorders_step1 + #define GPUCA_LB_GPUTPCGMMergerMergeBorders_step1 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerMergeBorders_variant + #define GPUCA_LB_GPUTPCGMMergerMergeBorders_variant 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerSortTracks + #define GPUCA_LB_GPUTPCGMMergerSortTracks 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMMergerSortTracksQPt + #define GPUCA_LB_GPUTPCGMMergerSortTracksQPt 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMO2Output_sort + #define GPUCA_LB_GPUTPCGMO2Output_sort 0 + #endif + #ifndef GPUCA_LB_GPUTPCGMO2Output_mc + #define GPUCA_LB_GPUTPCGMO2Output_mc 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFMCLabelFlattener_setRowOffsets + #define GPUCA_LB_GPUTPCCFMCLabelFlattener_setRowOffsets 0 + #endif + #ifndef GPUCA_LB_GPUTPCCFMCLabelFlattener_flatten + #define GPUCA_LB_GPUTPCCFMCLabelFlattener_flatten 0 + #endif +#endif // GPUCA_DEF_PARAMETERS_LOAD_DEFAULTS + // clang-format on -#endif +#endif // GPUDEFPARAMETERSDEFAULT_H diff --git a/GPU/GPUTracking/Definitions/GPUDefParametersLoad.template.inc b/GPU/GPUTracking/Definitions/GPUDefParametersLoad.template.inc new file mode 100644 index 0000000000000..cd1875ecefcf7 --- /dev/null +++ b/GPU/GPUTracking/Definitions/GPUDefParametersLoad.template.inc @@ -0,0 +1,56 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GPUDefParametersLoad.inc +/// \author David Rohr + +#include "GPUDefParameters.h" +#include "GPUDefMacros.h" +#include +#include + +namespace o2::gpu::internal +{ + +static GPUDefParameters GPUDefParametersLoad() +{ + return GPUDefParameters{ + // clang-format off + {$,REPLACE,[^A-Za-z0-9]+,_>,PREPEND,GPUCA_M_FIRST(GPUCA_LB_>,APPEND,)>,$>}, + {$,REPLACE,[^A-Za-z0-9]+,_>,PREPEND,GPUCA_M_FIRST(GPUCA_M_SHIFT(GPUCA_LB_>,APPEND,$0))>,$>}, + {$,REPLACE,[^A-Za-z0-9]+,_>,PREPEND,GPUCA_M_FIRST(GPUCA_M_SHIFT(GPUCA_M_SHIFT(GPUCA_LB_>,APPEND,$0$0)))>,$>} + // clang-format on + }; +} + +#define GPUCA_EXPORT_KERNEL(name) \ + if (par.par_LB_maxThreads[i] > 0) { \ + o << "#define GPUCA_" << (forRTC ? "RTC_" : "") << "LB_" << GPUCA_M_STR(name) " " << par.par_LB_maxThreads[i]; \ + if (par.par_LB_minBlocks[i] > 0) { \ + o << ", " << par.par_LB_minBlocks[i]; \ + } \ + if (!forRTC && par.par_LB_forceBlocks[i] > 0) { \ + o << ", " << par.par_LB_forceBlocks[i]; \ + } \ + o << "\n"; \ + } \ + i++; + +static std::string GPUDefParametersExport(const GPUDefParameters& par, bool forRTC) +{ + std::stringstream o; // clang-format off + int32_t i = 0; + $,REPLACE,[^A-Za-z0-9]+,_>,PREPEND,GPUCA_EXPORT_KERNEL(>,APPEND,)>, + > + return o.str(); // clang-format on +} + +} // namespace o2::gpu::internal diff --git a/GPU/GPUTracking/Definitions/GPUSettingsList.h b/GPU/GPUTracking/Definitions/GPUSettingsList.h index e0c5f845a475e..5d716d32d928f 100644 --- a/GPU/GPUTracking/Definitions/GPUSettingsList.h +++ b/GPU/GPUTracking/Definitions/GPUSettingsList.h @@ -35,6 +35,9 @@ BeginNamespace(gpu) // Settings concerning the reconstruction, stored as parameters in GPU constant memory // There must be no bool in here, use int8_t, as sizeof(bool) is compiler dependent and fails on GPUs!!!!!! +// Split in different blocks for global and per Detector + +// Reconstruction parameters for TPC, no bool in here !!! BeginSubConfig(GPUSettingsRecTPC, tpc, configStandalone.rec, "RECTPC", 0, "Reconstruction settings", rec_tpc) AddOptionRTC(rejectQPtB5, float, 1.f / GPUCA_MIN_TRACK_PTB5_REJECT_DEFAULT, "", 0, "QPt threshold to reject clusters of TPC tracks (Inverse Pt, scaled to B=0.5T!!!)") AddOptionRTC(hitPickUpFactor, float, 1.f, "", 0, "multiplier for the combined cluster+track error during track following") @@ -161,6 +164,7 @@ AddOptionArray(PID_remap, int8_t, 9, (0, 1, 2, 3, 4, 5, 6, 7, 8), "", 0, "Remap AddHelp("help", 'h') EndConfig() +// Reconstruction parameters for TRD, no bool in here !!! BeginSubConfig(GPUSettingsRecTRD, trd, configStandalone.rec, "RECTRD", 0, "Reconstruction settings", rec_trd) AddOptionRTC(minTrackPt, float, .5f, "", 0, "Min Pt for tracks to be propagated through the TRD") AddOptionRTC(maxChi2, float, 20.f, "", 0, "Max chi2 for TRD tracklets to be matched to a track") @@ -182,11 +186,12 @@ AddOptionRTC(pileupBwdNBC, uint8_t, 80, "", 0, "Pre-trigger Pile-up integration AddHelp("help", 'h') EndConfig() -// Dynamic settings, must NOT use AddOptionRTC(...) !!! +// Dynamic reconstruction parameters, no bool in here!!!, must NOT use AddOptionRTC(...) !!! BeginSubConfig(GPUSettingsRecDynamic, dyn, configStandalone.rec, "RECDYN", 0, "Reconstruction settings", rec_dyn) AddHelp("help", 'h') EndConfig() +// Global reconstruction parameters, no bool in here !!! BeginSubConfig(GPUSettingsRec, rec, configStandalone, "REC", 0, "Reconstruction settings", rec) AddOptionRTC(maxTrackQPtB5, float, 1.f / GPUCA_MIN_TRACK_PTB5_DEFAULT, "", 0, "required max Q/Pt (==min Pt) of tracks") AddOptionRTC(fwdTPCDigitsAsClusters, uint8_t, 0, "", 0, "Forward TPC digits as clusters (if they pass the ZS threshold)") @@ -203,7 +208,7 @@ AddHelp("help", 'h') EndConfig() #ifndef __OPENCL__ -// Settings steering the processing once the device was selected, only available on the host +// Parameters that might affect the RTC code (if these change, the cache cannot be used) BeginSubConfig(GPUSettingsProcessingRTC, rtc, configStandalone.proc, "RTC", 0, "Processing settings", proc_rtc) AddOption(cacheOutput, bool, false, "", 0, "Cache RTC compilation results") AddOption(optConstexpr, bool, true, "", 0, "Replace constant variables by static constexpr expressions") @@ -211,12 +216,23 @@ AddOption(optSpecialCode, int8_t, -1, "", 0, "Insert GPUCA_RTC_SPECIAL_CODE spec AddOption(deterministic, bool, false, "", 0, "Compile RTC in deterministic mode, with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define") AddOption(compilePerKernel, bool, true, "", 0, "Run one RTC compilation per kernel") AddOption(enable, bool, false, "", 0, "Use RTC to optimize GPU code") +AddHelp("help", 'h') +EndConfig() + +// Technical parameters for RunTimeCompilation, which do not change the RTC code +BeginSubConfig(GPUSettingsProcessingRTCtechnical, rtctech, configStandalone.proc, "RTCTECH", 0, "Processing settings", proc_rtctech) AddOption(runTest, int32_t, 0, "", 0, "Do not run the actual benchmark, but just test RTC compilation (1 full test, 2 test only compilation)") AddOption(cacheMutex, bool, true, "", 0, "Use a file lock to serialize access to the cache folder") AddOption(ignoreCacheValid, bool, false, "", 0, "If set, allows to use RTC cached code files even if they are not valid for the current source code / parameters") +AddOption(printLaunchBounds, bool, false, "", 0, "Print launch bounds used for RTC code as debugging option") +AddOption(cacheFolder, std::string, "./rtccache/", "", 0, "Folder in which the cache file is stored") +AddOption(prependCommand, std::string, "", "", 0, "Prepend RTC compilation commands by this string") +AddOption(overrideArchitecture, std::string, "", "", 0, "Override arhcitecture part of RTC compilation command line") // Part of cmdLine, so checked against the cache +AddOption(loadLaunchBoundsFromFile, std::string, "", "", 0, "Load a parameter object containing the launch bounds from a file") AddHelp("help", 'h') EndConfig() +// Parameters that steer reconstruction that do not go to the device, or only in derrived form. BeginSubConfig(GPUSettingsProcessingParam, param, configStandalone.proc, "PARAM", 0, "Processing settings", proc_param) AddOptionArray(tpcErrorParamY, float, 4, (0.06f, 0.24f, 0.12f, 0.1f), "", 0, "TPC Cluster Y Error Parameterization") AddOptionArray(tpcErrorParamZ, float, 4, (0.06f, 0.24f, 0.15f, 0.1f), "", 0, "TPC Cluster Z Error Parameterization") @@ -224,6 +240,7 @@ AddOption(tpcTriggerHandling, bool, true, "", 0, "Enable TPC trigger handling") AddHelp("help", 'h') EndConfig() +// Settings steering the processing of NN Clusterization BeginSubConfig(GPUSettingsProcessingNNclusterizer, nn, configStandalone.proc, "NN", 0, "Processing settings for neural network clusterizer", proc_nn) AddOption(applyNNclusterizer, int, 0, "", 0, "(bool, default = 0), if the neural network clusterizer should be used.") AddOption(nnInferenceDevice, std::string, "CPU", "", 0, "(std::string) Specify inference device (cpu (default), rocm, cuda)") @@ -253,6 +270,7 @@ AddOption(nnSigmoidTrafoClassThreshold, int, 1, "", 0, "If true (default), then AddHelp("help", 'h') EndConfig() +// Settings steering the processing once the device was selected, only available on the host BeginSubConfig(GPUSettingsProcessing, proc, configStandalone, "PROC", 0, "Processing settings", proc) AddOption(deviceNum, int32_t, -1, "gpuDevice", 0, "Set GPU device to use (-1: automatic, -2: for round-robin usage in timeslice-pipeline)") AddOption(gpuDeviceOnly, bool, false, "", 0, "Use only GPU as device (i.e. no CPU for OpenCL)") @@ -320,9 +338,6 @@ AddOption(tpcMaxAttachedClustersPerSectorRow, uint32_t, 51000, "", 0, "Maximum n AddOption(tpcUseOldCPUDecoding, bool, false, "", 0, "Enable old CPU-based TPC decoding") AddOption(tpcApplyCFCutsAtDecoding, bool, false, "", 0, "Apply cluster cuts from clusterization during decoding of compressed clusters") AddOption(tpcApplyClusterFilterOnCPU, uint8_t, 0, "", 0, "Apply custom cluster filter of GPUTPCClusterFilter class, 0: off, 1: debug, 2: PbPb23") -AddOption(RTCcacheFolder, std::string, "./rtccache/", "", 0, "Folder in which the cache file is stored") -AddOption(RTCprependCommand, std::string, "", "", 0, "Prepend RTC compilation commands by this string") -AddOption(RTCoverrideArchitecture, std::string, "", "", 0, "Override arhcitecture part of RTC compilation command line") AddOption(oclPlatformNum, int32_t, -1, "", 0, "Platform to use, in case the backend provides multiple platforms (OpenCL only, -1 = auto-select, -2 query all platforms (also incompatible))") AddOption(oclCompileFromSources, bool, false, "", 0, "Compile OpenCL binary from included source code instead of using included spirv code") AddOption(oclOverrideSourceBuildFlags, std::string, "", "", 0, "Override OCL build flags for compilation from source, put a space for empty options") @@ -330,6 +345,7 @@ AddOption(printSettings, bool, false, "", 0, "Print all settings when initializi AddOption(tpcFreeAllocatedMemoryAfterProcessing, bool, false, "", 0, "Clean all memory allocated by TPC when TPC processing done, only data written to external output resources will remain") AddVariable(eventDisplay, o2::gpu::GPUDisplayFrontendInterface*, nullptr) AddSubConfig(GPUSettingsProcessingRTC, rtc) +AddSubConfig(GPUSettingsProcessingRTCtechnical, rtctech) AddSubConfig(GPUSettingsProcessingParam, param) AddSubConfig(GPUSettingsProcessingNNclusterizer, nn) AddHelp("help", 'h') diff --git a/GPU/GPUTracking/GPUTrackingLinkDef_O2_DataTypes.h b/GPU/GPUTracking/GPUTrackingLinkDef_O2_DataTypes.h index 35ebbabe41672..46fd50464c69b 100644 --- a/GPU/GPUTracking/GPUTrackingLinkDef_O2_DataTypes.h +++ b/GPU/GPUTracking/GPUTrackingLinkDef_O2_DataTypes.h @@ -30,6 +30,7 @@ #pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsProcessing + ; #pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsProcessingParam + ; #pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsProcessingRTC + ; +#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsProcessingRTCtechnical + ; #pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsProcessingNNclusterizer + ; #pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplay + ; #pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplayLight + ; diff --git a/GPU/GPUTracking/Global/GPUChainTrackingSectorTracker.cxx b/GPU/GPUTracking/Global/GPUChainTrackingSectorTracker.cxx index e161f74a31032..3e7447892307a 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingSectorTracker.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingSectorTracker.cxx @@ -105,7 +105,7 @@ int32_t GPUChainTracking::RunTPCTrackingSectors_internal() for (uint32_t iSector = 0; iSector < NSECTORS; iSector++) { processorsShadow()->tpcTrackers[iSector].GPUParametersConst()->gpumem = (char*)mRec->DeviceMemoryBase(); // Initialize Startup Constants - processors()->tpcTrackers[iSector].GPUParameters()->nextStartHit = (((getKernelProperties().minBlocks * BlockCount()) + NSECTORS - 1 - iSector) / NSECTORS) * getKernelProperties().nThreads; + processors()->tpcTrackers[iSector].GPUParameters()->nextStartHit = (((getKernelProperties().minBlocks * BlockCount()) + NSECTORS - 1 - iSector) / NSECTORS) * getKernelProperties().nThreads; processorsShadow()->tpcTrackers[iSector].SetGPUTextureBase(mRec->DeviceMemoryBase()); } diff --git a/GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx b/GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx index 288a24dee5d99..f03964d35ff82 100644 --- a/GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx +++ b/GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx @@ -1740,7 +1740,7 @@ GPUd() void GPUTPCGMMerger::CollectMergedTracks(int32_t nBlocks, int32_t nThread p1.DzDs() = p2.DzDs(); p1.QPt() = p2.QPt(); mergedTrack.SetAlpha(p2.Alpha()); - if (CAMath::Abs(Param().polynomialField.GetNominalBz()) < (0.01f * gpu_common_constants::kCLight)) { + if (CAMath::Abs(Param().polynomialField.GetNominalBz()) < (0.013f * gpu_common_constants::kCLight)) { p1.QPt() = 100.f / Param().rec.bz0Pt10MeV; } diff --git a/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.cxx b/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.cxx index 5a7df0ba8b874..71df683eee1dc 100644 --- a/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.cxx +++ b/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.cxx @@ -476,7 +476,7 @@ GPUdic(2, 1) void GPUTPCTrackletConstructor::DoTracklet(GPUconstantref() GPUTPCT } template <> -GPUdii() void GPUTPCTrackletConstructor::Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& sMem, processorType& GPUrestrict() tracker) +GPUdii() void GPUTPCTrackletConstructor::Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& sMem, processorType& GPUrestrict() tracker) { if (get_local_id(0) == 0) { sMem.mNStartHits = *tracker.NStartHits(); @@ -491,79 +491,6 @@ GPUdii() void GPUTPCTrackletConstructor::Thread -GPUdii() void GPUTPCTrackletConstructor::Thread(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& sMem, processorType& GPUrestrict() tracker0) -{ - GPUconstantref() GPUTPCTracker* GPUrestrict() pTracker = &tracker0; -#ifdef GPUCA_GPUCODE - int32_t mySector = get_group_id(0) % GPUCA_NSECTORS; - int32_t currentSector = -1; - - if (get_local_id(0) == 0) { - sMem.mNextStartHitFirstRun = 1; - } - GPUCA_UNROLL(, U()) - for (uint32_t iSector = 0; iSector < GPUCA_NSECTORS; iSector++) { - GPUconstantref() GPUTPCTracker& GPUrestrict() tracker = pTracker[mySector]; - - GPUTPCThreadMemory rMem; - - while ((rMem.mISH = FetchTracklet(tracker, sMem)) != -2) { - if (rMem.mISH >= 0 && get_local_id(0) < GPUCA_GET_THREAD_COUNT(GPUCA_LB_GPUTPCTrackletConstructor)) { - rMem.mISH += get_local_id(0); - } else { - rMem.mISH = -1; - } - - if (mySector != currentSector) { - if (get_local_id(0) == 0) { - sMem.mNStartHits = *tracker.NStartHits(); - } - CA_SHARED_CACHE(&sMem.mRows[0], tracker.TrackingDataRows(), GPUCA_ROW_COUNT * sizeof(GPUTPCRow)); - GPUbarrier(); - currentSector = mySector; - } - - if (rMem.mISH >= 0 && rMem.mISH < sMem.mNStartHits) { - rMem.mGo = true; - DoTracklet(tracker, sMem, rMem); - } - } - if (++mySector >= GPUCA_NSECTORS) { - mySector = 0; - } - } -#else - for (int32_t iSector = 0; iSector < GPUCA_NSECTORS; iSector++) { - Thread(nBlocks, nThreads, iBlock, iThread, sMem, pTracker[iSector]); - } -#endif -} - -#ifdef GPUCA_GPUCODE - -GPUd() int32_t GPUTPCTrackletConstructor::FetchTracklet(GPUconstantref() GPUTPCTracker& GPUrestrict() tracker, GPUsharedref() GPUSharedMemory& sMem) -{ - const uint32_t nStartHit = *tracker.NStartHits(); - GPUbarrier(); - if (get_local_id(0) == 0) { - int32_t firstStartHit = -2; - if (sMem.mNextStartHitFirstRun == 1) { - firstStartHit = (get_group_id(0) - tracker.ISector()) / GPUCA_NSECTORS * GPUCA_GET_THREAD_COUNT(GPUCA_LB_GPUTPCTrackletConstructor); - sMem.mNextStartHitFirstRun = 0; - } else { - if (tracker.GPUParameters()->nextStartHit < nStartHit) { - firstStartHit = CAMath::AtomicAdd(&tracker.GPUParameters()->nextStartHit, GPUCA_GET_THREAD_COUNT(GPUCA_LB_GPUTPCTrackletConstructor)); - } - } - sMem.mNextStartHitFirst = firstStartHit < (int32_t)nStartHit ? firstStartHit : -2; - } - GPUbarrier(); - return (sMem.mNextStartHitFirst); -} - -#endif // GPUCA_GPUCODE - template <> // FIXME: GPUgeneric() needed to make the clang spirv output link correctly GPUd() int32_t GPUTPCTrackletConstructor::GPUTPCTrackletConstructorExtrapolationTracking(GPUconstantref() GPUTPCTracker& GPUrestrict() tracker, GPUsharedref() GPUTPCExtrapolationTracking::GPUSharedMemory& sMem, GPUTPCTrackParam& GPUrestrict() tParam, int32_t row, int32_t increment, int32_t iTracklet, calink* rowHits) { diff --git a/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.h b/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.h index 0f8314ee0fad4..af87d0276f1c7 100644 --- a/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.h +++ b/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.h @@ -28,14 +28,9 @@ namespace o2::gpu */ class GPUTPCTracker; -class GPUTPCTrackletConstructor +class GPUTPCTrackletConstructor : public GPUKernelTemplate { public: - enum K { - singleSector = 0, - allSectors = 1 - }; - class GPUTPCThreadMemory { friend class GPUTPCTrackletConstructor; //! friend class @@ -89,10 +84,6 @@ class GPUTPCTrackletConstructor GPUd() static void DoTracklet(GPUconstantref() GPUTPCTracker& tracker, GPUsharedref() GPUTPCTrackletConstructor::GPUSharedMemory& sMem, GPUTPCThreadMemory& rMem); -#ifdef GPUCA_GPUCODE - GPUd() static int32_t FetchTracklet(GPUconstantref() GPUTPCTracker& tracker, GPUsharedref() GPUSharedMemory& sMem); -#endif // GPUCA_GPUCODE - template GPUd() static int32_t GPUTPCTrackletConstructorExtrapolationTracking(GPUconstantref() GPUTPCTracker& tracker, GPUsharedref() T& sMem, GPUTPCTrackParam& tParam, int32_t startrow, int32_t increment, int32_t iTracklet, calink* rowHits); diff --git a/GPU/GPUTracking/Standalone/Benchmark/standalone.cxx b/GPU/GPUTracking/Standalone/Benchmark/standalone.cxx index e9cb7c5179c59..2e3e4725bd6aa 100644 --- a/GPU/GPUTracking/Standalone/Benchmark/standalone.cxx +++ b/GPU/GPUTracking/Standalone/Benchmark/standalone.cxx @@ -53,9 +53,6 @@ #include "GPUTPCGMMergedTrack.h" #include "GPUSettings.h" #include -#if not(defined(__ARM_NEON) or defined(__aarch64__)) // ARM doesn't have SSE -#include -#endif #include "GPUO2DataTypes.h" #include "GPUChainITS.h" @@ -85,23 +82,6 @@ std::atomic nIteration, nIterationEnd; std::vector ioPtrEvents; std::vector ioMemEvents; -void SetCPUAndOSSettings() -{ -#if not(defined(__ARM_NEON) or defined(__aarch64__)) // ARM doesn't have SSE -#ifdef FE_DFL_DISABLE_SSE_DENORMS_ENV // Flush and load denormals to zero in any case - fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV); -#else -#ifndef _MM_FLUSH_ZERO_ON -#define _MM_FLUSH_ZERO_ON 0x8000 -#endif -#ifndef _MM_DENORMALS_ZERO_ON -#define _MM_DENORMALS_ZERO_ON 0x0040 -#endif - _mm_setcsr(_mm_getcsr() | (_MM_FLUSH_ZERO_ON | _MM_DENORMALS_ZERO_ON)); -#endif -#endif // ARM -} - int32_t ReadConfiguration(int argc, char** argv) { int32_t qcRet = qConfigParse(argc, (const char**)argv); @@ -740,8 +720,6 @@ int32_t main(int argc, char** argv) { std::unique_ptr recUnique, recUniqueAsync, recUniquePipeline; - SetCPUAndOSSettings(); - if (ReadConfiguration(argc, argv)) { return 1; } diff --git a/GPU/GPUTracking/Standalone/CMakeLists.txt b/GPU/GPUTracking/Standalone/CMakeLists.txt index ed4fc5c9f7e2d..dfc8e8db3bc7a 100644 --- a/GPU/GPUTracking/Standalone/CMakeLists.txt +++ b/GPU/GPUTracking/Standalone/CMakeLists.txt @@ -62,8 +62,11 @@ if (GPUCA_BUILD_DEBUG_SANITIZE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -shared-libasan") endif() endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error -Wall -Wextra -Wshadow -Wno-unused-function -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-unknown-pragmas -Wno-write-strings -Wno-vla-cxx-extension") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic -Wl,--no-undefined") +string(APPEND CMAKE_CXX_FLAGS " -Wno-error -Wall -Wextra -Wshadow -Wno-unused-function -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-unknown-pragmas -Wno-write-strings") +string(APPEND CMAKE_SHARED_LINKER_FLAGS " -rdynamic -Wl,--no-undefined") +if(CMAKE_CXX_COMPILER MATCHES "clang\\+\\+") + string(APPEND CMAKE_CXX_FLAGS " -Wno-vla-cxx-extension") +endif() # Find mandatory packages find_package(TBB REQUIRED) diff --git a/GPU/GPUTracking/Standalone/tools/createGeo.C b/GPU/GPUTracking/Standalone/tools/createGeo.C index 5684f2cc92da6..307d687f716d1 100644 --- a/GPU/GPUTracking/Standalone/tools/createGeo.C +++ b/GPU/GPUTracking/Standalone/tools/createGeo.C @@ -1,3 +1,17 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file CreateGeo.C +/// \author David Rohr + #if !defined(__CLING__) || defined(__ROOTCLING__) #include #include "TRDBase/GeometryFlat.h" diff --git a/GPU/GPUTracking/Standalone/tools/createGeo.sh b/GPU/GPUTracking/Standalone/tools/createGeo.sh index a449e1997a16e..49176f231aa80 100755 --- a/GPU/GPUTracking/Standalone/tools/createGeo.sh +++ b/GPU/GPUTracking/Standalone/tools/createGeo.sh @@ -1,3 +1,14 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + #!/bin/bash PATH=$PATH:/usr/share/Modules/bin/:/home/qon/alice/alibuild diff --git a/GPU/GPUTracking/Standalone/tools/createLUT.C b/GPU/GPUTracking/Standalone/tools/createLUT.C index 83e46da29b9a3..7bb4edbf89f18 100644 --- a/GPU/GPUTracking/Standalone/tools/createLUT.C +++ b/GPU/GPUTracking/Standalone/tools/createLUT.C @@ -1,3 +1,17 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file CreateLUT.C +/// \author David Rohr + #if !defined(__CLING__) || defined(__ROOTCLING__) #include #include "DetectorsBase/MatLayerCylSet.h" diff --git a/GPU/GPUTracking/Standalone/tools/dumpGPUDefParam.C b/GPU/GPUTracking/Standalone/tools/dumpGPUDefParam.C new file mode 100644 index 0000000000000..4a2575c40d79a --- /dev/null +++ b/GPU/GPUTracking/Standalone/tools/dumpGPUDefParam.C @@ -0,0 +1,38 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file dumpGPUDefParam.C +/// \author David Rohr + +// Run e.g. as: +// ROOT_INCLUDE_PATH="`pwd`/include" root -l -q -b src/GPU/GPUTracking/Standalone/tools/dumpGPUDefParam.C'()' + +// Logic for testing to load the default parameters +/*#define GPUCA_GPUCODE +#define GPUCA_GPUTYPE_AMPERE +#define GPUCA_DEF_PARAMETERS_LOAD_DEFAULTS +#define GPUCA_MAXN 40 +#define GPUCA_ROW_COUNT 152 +#define GPUCA_TPC_COMP_CHUNK_SIZE 1024 +#include "GPUDefParametersDefault.h"*/ + +// Load file that sets GPUDefParameters +#include "testParam.h" + +#include "GPUDefParametersLoad.inc" +void dumpGPUDefParam() +{ + auto param = o2::gpu::internal::GPUDefParametersLoad(); + printf("Loaded params:\n%s", o2::gpu::internal::GPUDefParametersExport(param, false).c_str()); + FILE* fp = fopen("parameters.out", "w+b"); + fwrite(¶m, 1, sizeof(param), fp); + fclose(fp); +} diff --git a/GPU/GPUTracking/Standalone/tools/dumpTRDClusterMatrices.C b/GPU/GPUTracking/Standalone/tools/dumpTRDClusterMatrices.C index 757875e4199b3..c747a226f5edf 100644 --- a/GPU/GPUTracking/Standalone/tools/dumpTRDClusterMatrices.C +++ b/GPU/GPUTracking/Standalone/tools/dumpTRDClusterMatrices.C @@ -1,3 +1,14 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + #include "AliCDBManager.h" #include "AliGeomManager.h" #include "AliTRDgeometry.h" diff --git a/GPU/GPUTracking/Standalone/tools/switchToAliRootLicense.sh b/GPU/GPUTracking/Standalone/tools/switchToAliRootLicense.sh deleted file mode 100755 index 94545950805a0..0000000000000 --- a/GPU/GPUTracking/Standalone/tools/switchToAliRootLicense.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -cd ../../../../ -if [ $(ls | grep GPU | wc -l) != "1" ]; then - echo Incorrect directory - exit 1 -fi - -git grep -l "^// Copyright 2019-2020 CERN and copyright holders of ALICE O2." | \ - grep "^GPU/Common/\|^GPU/GPUTracking/\|^GPU/TPCFastTransformation|^GPU/TPCSpaceChargeBase\|^cmake" | \ - xargs -r -n 1 \ - sed -i -e '/Copyright 2019-2020 CERN and copyright holders of ALICE O2./,/or submit itself to any jurisdiction/c\ -//**************************************************************************\ -//* This file is property of and copyright by the ALICE Project *\ -//* ALICE Experiment at CERN, All rights reserved. *\ -//* *\ -//* Primary Authors: Matthias Richter *\ -//* for The ALICE HLT Project. *\ -//* *\ -//* Permission to use, copy, modify and distribute this software and its *\ -//* documentation strictly for non-commercial purposes is hereby granted *\ -//* without fee, provided that the above copyright notice appears in all *\ -//* copies and that both the copyright notice and this permission notice *\ -//* appear in the supporting documentation. The authors make no claims *\ -//* about the suitability of this software for any purpose. It is *\ -//* provided "as is" without express or implied warranty. *\ -//**************************************************************************\' diff --git a/GPU/GPUTracking/TPCClusterFinder/CfConsts.h b/GPU/GPUTracking/TPCClusterFinder/CfConsts.h index 62695f2ae30a5..c600b8f3ea8f8 100644 --- a/GPU/GPUTracking/TPCClusterFinder/CfConsts.h +++ b/GPU/GPUTracking/TPCClusterFinder/CfConsts.h @@ -35,11 +35,6 @@ GPUconstexpr() tpccf::Delta2 InnerNeighbors[8] = {1, 0}, {1, 1}}; -GPUconstexpr() bool InnerTestEq[8] = - { - true, true, true, true, - false, false, false, false}; - GPUconstexpr() tpccf::Delta2 OuterNeighbors[16] = { {-2, -1}, diff --git a/GPU/GPUTracking/cmake/GPUNoFastMathKernels.template.h b/GPU/GPUTracking/cmake/GPUNoFastMathKernels.template.h index dac93277d5ec9..499672bf00b50 100644 --- a/GPU/GPUTracking/cmake/GPUNoFastMathKernels.template.h +++ b/GPU/GPUTracking/cmake/GPUNoFastMathKernels.template.h @@ -12,6 +12,9 @@ /// \file GPUNoFastMathKernels.h /// \author David Rohr +#ifndef GPUNOFASTMATHKERNELS_H +#define GPUNOFASTMATHKERNELS_H + #include #include @@ -21,3 +24,5 @@ namespace o2::gpu::internal static const std::unordered_set noFastMathKernels = {$>,APPEND,">,PREPEND,">,$ >}; // clang-format on } // namespace o2::gpu::internal + +#endif diff --git a/GPU/GPUTracking/cmake/kernel_helpers.cmake b/GPU/GPUTracking/cmake/kernel_helpers.cmake index 99699cc72e940..3c1ad9658566b 100644 --- a/GPU/GPUTracking/cmake/kernel_helpers.cmake +++ b/GPU/GPUTracking/cmake/kernel_helpers.cmake @@ -64,7 +64,9 @@ function(o2_gpu_add_kernel kernel_name kernel_files) endif() set(TMP_PRE "") set(TMP_POST "") - set(TMP_KERNEL "GPUCA_KRNL${TMP_BOUNDS}((${kernel_name}), (${kernel_extra}), (${OPT1}), (${OPT2}), (${OPT3}))\n") + get_property(LIST_KERNELS TARGET O2_GPU_KERNELS PROPERTY O2_GPU_KERNELS) + list(LENGTH LIST_KERNELS KERNEL_COUNT) + set(TMP_KERNEL "GPUCA_KRNL${TMP_BOUNDS}((${kernel_name}), (${kernel_extra}), (${OPT1}), (${OPT2}), (${OPT3}), ${KERNEL_COUNT})\n") separate_arguments(kernel_files NATIVE_COMMAND ${kernel_files}) list(GET kernel_files 0 TMP_KERNEL_CLASS_FILE) if (TMP_KERNEL_CLASS_FILE STREQUAL "=") diff --git a/GPU/GPUTracking/kernels.cmake b/GPU/GPUTracking/kernels.cmake index ad348a84264f0..994f10a516b10 100644 --- a/GPU/GPUTracking/kernels.cmake +++ b/GPU/GPUTracking/kernels.cmake @@ -34,11 +34,10 @@ o2_gpu_add_kernel("GPUTPCNeighboursFinder" "= TPCTRAC o2_gpu_add_kernel("GPUTPCNeighboursCleaner" "= TPCTRACKER" LB) o2_gpu_add_kernel("GPUTPCStartHitsFinder" "= TPCTRACKER" LB) o2_gpu_add_kernel("GPUTPCStartHitsSorter" "= TPCTRACKER" LB) -o2_gpu_add_kernel("GPUTPCTrackletConstructor, singleSector" "= TPCTRACKER" LB) -o2_gpu_add_kernel("GPUTPCTrackletConstructor, allSectors" "= TPCTRACKER" LB) +o2_gpu_add_kernel("GPUTPCTrackletConstructor" "= TPCTRACKER" LB) o2_gpu_add_kernel("GPUTPCTrackletSelector" "= TPCTRACKER" LB) -o2_gpu_add_kernel("GPUMemClean16" "GPUGeneralKernels" "NO_REG, (GPUCA_THREAD_COUNT, 1)" void* ptr "uint64_t" size) -o2_gpu_add_kernel("GPUitoa" "GPUGeneralKernels" "NO_REG, (GPUCA_THREAD_COUNT, 1)" int32_t* ptr "uint64_t" size) +o2_gpu_add_kernel("GPUMemClean16" "GPUGeneralKernels" NO void* ptr "uint64_t" size) +o2_gpu_add_kernel("GPUitoa" "GPUGeneralKernels" NO int32_t* ptr "uint64_t" size) o2_gpu_add_kernel("GPUTPCExtrapolationTrackingCopyNumbers" "GPUTPCExtrapolationTracking TPCTRACKER" NO int32_t n) o2_gpu_add_kernel("GPUTPCExtrapolationTracking" "= TPCTRACKER TPCTRACKLETCONS" LB) o2_gpu_add_kernel("GPUTPCCreateTrackingData" "= TPCTRACKER TPCSECTORDATA" LB) diff --git a/GPU/GPUTracking/utils/qmaths_helpers.h b/GPU/GPUTracking/utils/qmaths_helpers.h index 9c5f704180aaa..5eb3ce4fb2483 100644 --- a/GPU/GPUTracking/utils/qmaths_helpers.h +++ b/GPU/GPUTracking/utils/qmaths_helpers.h @@ -15,24 +15,33 @@ #ifndef QMATH_HELPERS_H #define QMATH_HELPERS_H -#if defined __has_include -#if __has_include() && __has_include() -#include -#include -#if defined(_MM_FLUSH_ZERO_OFF) && defined(_MM_DENORMALS_ZERO_ON) +#if !(defined(__ARM_NEON) || defined(__aarch64__)) && __has_include() // clang-format off + #include + #if __has_include() + #include + #endif +#elif __has_include() + #include +#endif + static void disable_denormals() { - _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); - _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); +#if !(defined(__ARM_NEON) || defined(__aarch64__)) && __has_include() // clang-format off + #if defined(_MM_FLUSH_ZERO_OFF) && defined(_MM_DENORMALS_ZERO_ON) + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); + _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); + #else + #ifndef _MM_FLUSH_ZERO_ON + #define _MM_FLUSH_ZERO_ON 0x8000 + #endif + #ifndef _MM_DENORMALS_ZERO_ON + #define _MM_DENORMALS_ZERO_ON 0x0040 + #endif + _mm_setcsr(_mm_getcsr() | (_MM_FLUSH_ZERO_ON | _MM_DENORMALS_ZERO_ON)); + #endif +#elif __has_include() && defined(FE_DFL_DISABLE_SSE_DENORMS_ENV) + fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV); +#endif // clang-format on } -#define XMM_HAS_DENORMAL_DEACTIVATE -#endif -#endif -#endif -#ifdef XMM_HAS_DENORMAL_DEACTIVATE -#undef XMM_HAS_DENORMAL_DEACTIVATE -#else -static void disable_denormals() {} -#endif #endif diff --git a/cmake/O2RootMacroExclusionList.cmake b/cmake/O2RootMacroExclusionList.cmake index d5596ccc424f4..ab79a802a6e3a 100644 --- a/cmake/O2RootMacroExclusionList.cmake +++ b/cmake/O2RootMacroExclusionList.cmake @@ -43,6 +43,7 @@ list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST GPU/GPUTracking/Merger/macros/fitPolynomialFieldTpc.C # Needs AliRoot AliMagF GPU/GPUTracking/Merger/macros/fitPolynomialFieldTrd.C # Needs AliRoot AliMagF GPU/GPUTracking/Standalone/tools/dumpTRDClusterMatrices.C # Needs AliRoot AliCDBManager, AliGeomManager and AliTRDgeometry + GPU/GPUTracking/Standalone/tools/dumpGPUDefParam.C # Exampple, which needs special headers to work GPU/GPUTracking/TRDTracking/macros/checkDbgOutput.C # Needs AliRoot TStatToolkit GPU/TPCFastTransformation/devtools/loadlibs.C # Special macro GPU/GPUTracking/TRDTracking/macros/run_trd_tracker.C # Not yet ready @@ -58,7 +59,6 @@ list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST macro/CreateSampleIRFrames.C Detectors/Upgrades/ALICE3/macros/ALICE3Field.C) - if(NOT BUILD_SIMULATION) # some complete sub_directories are not added to the build when not building # simulation, so the corresponding o2_add_test_root_macro won't be called at diff --git a/dependencies/FindO2GPU.cmake b/dependencies/FindO2GPU.cmake index 56b53e1be8879..95db55041184f 100644 --- a/dependencies/FindO2GPU.cmake +++ b/dependencies/FindO2GPU.cmake @@ -82,20 +82,22 @@ elseif(NOT GPUCA_DETERMINISTIC_MODE MATCHES "^[0-9]+$") message(FATAL_ERROR "Invalid setting ${GPUCA_DETERMINISTIC_MODE} for GPUCA_DETERMINISTIC_MODE") endif() set(GPUCA_DETERMINISTIC_MODE ${GPUCA_DETERMINISTIC_MODE_MAP_${GPUCA_DETERMINISTIC_MODE}}) - message(STATUS "Set to ${GPUCA_DETERMINISTIC_MODE}") endif() if (CMAKE_SYSTEM_NAME MATCHES Darwin OR NOT CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") - set(GPUCA_CLANG_FTZ "") + set(GPUCA_CXX_DENORMALS_FLAGS "") else() - set(GPUCA_CLANG_FTZ "-mdaz-ftz") + set(GPUCA_CXX_DENORMALS_FLAGS "-mdaz-ftz") endif() -set(GPUCA_CXX_NO_FAST_MATH_FLAGS "-fno-fast-math -ffp-contract=off ${GPUCA_CLANG_FTZ}") -set(GPUCA_CUDA_NO_FAST_MATH_FLAGS "--ftz=true --prec-div=true --prec-sqrt=true --fmad false") -set(GPUCA_OCL_NO_FAST_MATH_FLAGS -cl-fp32-correctly-rounded-divide-sqrt -cl-denorms-are-zero) +set(GPUCA_CUDA_DENORMALS_FLAGS "--ftz=true") +set(GPUCA_OCL_DENORMALS_FLAGS "-cl-denorms-are-zero") +set(GPUCA_HIP_DENORMALS_FLAGS "-fgpu-flush-denormals-to-zero") +set(GPUCA_CXX_NO_FAST_MATH_FLAGS "-fno-fast-math -ffp-contract=off") +set(GPUCA_CUDA_NO_FAST_MATH_FLAGS "--prec-div=true --prec-sqrt=true --fmad false") +set(GPUCA_OCL_NO_FAST_MATH_FLAGS -cl-fp32-correctly-rounded-divide-sqrt ) if(GPUCA_DETERMINISTIC_MODE GREATER_EQUAL ${GPUCA_DETERMINISTIC_MODE_MAP_WHOLEO2}) add_definitions(-DGPUCA_DETERMINISTIC_MODE) - set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} ${GPUCA_CXX_NO_FAST_MATH_FLAGS}") - set(CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} ${GPUCA_CXX_NO_FAST_MATH_FLAGS}") + string(APPEND CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER} " ${GPUCA_CXX_NO_FAST_MATH_FLAGS}") + string(APPEND CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER} " ${GPUCA_CXX_NO_FAST_MATH_FLAGS}") endif() @@ -143,7 +145,8 @@ if(ENABLE_CUDA) endif() endif() if(CMAKE_CUDA_COMPILER) - set(CMAKE_CUDA_FLAGS "-Xcompiler \"${O2_GPU_CMAKE_CXX_FLAGS_NOSTD}\" ${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr --extended-lambda -Xcompiler -Wno-attributes") + set(CMAKE_CUDA_FLAGS "-Xcompiler \"${O2_GPU_CMAKE_CXX_FLAGS_NOSTD}\" ${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr --extended-lambda -Xcompiler -Wno-attributes ${GPUCA_CUDA_DENORMALS_FLAGS}") + set(CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "-Xcompiler \"${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}\" ${CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}") if(GPUCA_KERNEL_RESOURCE_USAGE_VERBOSE) string(APPEND CMAKE_CUDA_FLAGS " -Xptxas -v") endif() @@ -151,19 +154,18 @@ if(ENABLE_CUDA) if (NOT ENABLE_CUDA STREQUAL "AUTO") string(APPEND CMAKE_CUDA_FLAGS " --allow-unsupported-compiler") endif() - set(CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "-Xcompiler \"${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}\" ${CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}") if(CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG") - set(CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} -lineinfo -Xptxas -O0 -Xcompiler -O0") + string(APPEND CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} " -lineinfo -Xptxas -O0") else() - set(CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} -Xptxas -O4 -Xcompiler -O4") + string(APPEND CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} " -Xptxas -O4 -Xcompiler -O4") endif() if(GPUCA_DETERMINISTIC_MODE GREATER_EQUAL ${GPUCA_DETERMINISTIC_MODE_MAP_NO_FAST_MATH}) - set(CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} ${GPUCA_CUDA_NO_FAST_MATH_FLAGS}") + string(APPEND CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} " ${GPUCA_CUDA_NO_FAST_MATH_FLAGS}") elseif(NOT CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG") - set(CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} -use_fast_math --ftz=true")# + string(APPEND CMAKE_CUDA_FLAGS_${CMAKE_BUILD_TYPE_UPPER} " -use_fast_math --ftz=true") endif() if(CMAKE_CXX_FLAGS MATCHES "(^| )-Werror( |$)") - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Werror=cross-execution-space-call") + string(APPEND CMAKE_CUDA_FLAGS " -Werror=cross-execution-space-call") endif() if(GPUCA_CUDA_GCCBIN) list(FILTER CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES EXCLUDE REGEX "^/usr/lib.*/gcc/") # Workaround, since CMake adds old GCC lib paths implicitly if we request that gcc for CUDA @@ -285,27 +287,22 @@ if(ENABLE_HIP) set(HIP_ENABLED ON) set_target_properties(roc::rocthrust PROPERTIES IMPORTED_GLOBAL TRUE) message(STATUS "HIP Found (${hip_HIPCC_EXECUTABLE} version ${hip_VERSION})") - set(O2_HIP_CMAKE_CXX_FLAGS "-fgpu-defer-diag -mllvm -amdgpu-enable-lower-module-lds=false -mllvm -amdgpu-function-calls=true -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -Wno-invalid-constexpr -Wno-ignored-optimization-argument -Wno-unused-private-field -Wno-pass-failed") - if(hip_VERSION VERSION_GREATER_EQUAL "6.0" AND NOT hip_VERSION VERSION_GREATER_EQUAL "6.2") - string(APPEND O2_HIP_CMAKE_CXX_FLAGS " -mllvm -amdgpu-legacy-sgpr-spill-lowering=true") # TODO: Cleanup - endif() + set(CMAKE_HIP_FLAGS "${O2_GPU_CMAKE_CXX_FLAGS_NOSTD} ${CMAKE_HIP_FLAGS} ${GPUCA_HIP_DENORMALS_FLAGS}") + set(CMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} ${CMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}") + string(APPEND CMAKE_HIP_FLAGS " -fgpu-defer-diag -mllvm -amdgpu-enable-lower-module-lds=false -mllvm -amdgpu-function-calls=true -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -Wno-invalid-constexpr -Wno-ignored-optimization-argument -Wno-unused-private-field -Wno-pass-failed ") if(GPUCA_KERNEL_RESOURCE_USAGE_VERBOSE) - string(APPEND O2_HIP_CMAKE_CXX_FLAGS " -Rpass-analysis=kernel-resource-usage") + string(APPEND CMAKE_HIP_FLAGS " -Rpass-analysis=kernel-resource-usage") + endif() + if(NOT GPUCA_DETERMINISTIC_MODE GREATER_EQUAL ${GPUCA_DETERMINISTIC_MODE_MAP_NO_FAST_MATH}) + string(APPEND CMAKE_HIP_FLAGS " -ffast-math") + endif() + if(NOT CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG") + string(APPEND CMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE_UPPER} " -O3") endif() string(REGEX REPLACE "(gfx1[0-9]+;?)" "" CMAKE_HIP_ARCHITECTURES "${CMAKE_HIP_ARCHITECTURES}") # ROCm currently doesn’t support integrated graphics if(HIP_AMDGPUTARGET) set(CMAKE_HIP_ARCHITECTURES "${HIP_AMDGPUTARGET}") # If GPU build is enforced we override autodetection endif() - if(NOT GPUCA_DETERMINISTIC_MODE GREATER_EQUAL ${GPUCA_DETERMINISTIC_MODE_MAP_NO_FAST_MATH}) - string(APPEND O2_HIP_CMAKE_CXX_FLAGS " -fgpu-flush-denormals-to-zero -ffast-math") - endif() - set(CMAKE_HIP_FLAGS "${O2_GPU_CMAKE_CXX_FLAGS_NOSTD} ${CMAKE_HIP_FLAGS} ${O2_HIP_CMAKE_CXX_FLAGS}") - set(CMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} ${CMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}") - if(CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG") - set(CMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} -O0 -ggdb") - else() - set(CMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE_UPPER} "${CMAKE_HIP_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} -O3") - endif() else() set(HIP_ENABLED OFF) endif() diff --git a/macro/build_geometry.C b/macro/build_geometry.C index 93b06eb4bfeae..0d2127fa89d29 100644 --- a/macro/build_geometry.C +++ b/macro/build_geometry.C @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -264,6 +265,11 @@ void build_geometry(FairRunSim* run = nullptr) addReadoutDetector(new o2::ecal::Detector(isReadout("ECL"))); } + if (isActivated("FD")) { + // ALICE3 FD + addReadoutDetector(new o2::fd::Detector(isReadout("FD"))); + } + if (isActivated("MI3")) { // ALICE 3 MID addReadoutDetector(new o2::mi3::Detector(isReadout("MI3"))); diff --git a/prodtests/full-system-test/dpl-workflow.sh b/prodtests/full-system-test/dpl-workflow.sh index 5259bbf951d73..bc92a686ab889 100755 --- a/prodtests/full-system-test/dpl-workflow.sh +++ b/prodtests/full-system-test/dpl-workflow.sh @@ -327,11 +327,11 @@ if has_detector_calib PHS && workflow_has_parameter CALIB; then fi [[ ${O2_GPU_DOUBLE_PIPELINE:-$EPNSYNCMODE} == 1 && $GPUTYPE != "CPU" ]] && GPU_CONFIG+=" --enableDoublePipeline" -[[ ${O2_GPU_RTC:-$EPNSYNCMODE} == 1 ]] && GPU_CONFIG_KEY+="GPU_proc_rtc.enable=1;GPU_proc_rtc.cacheOutput=1;GPU_proc.RTCprependCommand=/usr/bin/env TMPDIR=/tmp /usr/bin/taskset -c 0-191;" -[[ ${O2_GPU_RTC:-$EPNSYNCMODE} == 1 && $EPNSYNCMODE == 1 ]] && GPU_CONFIG_KEY+="GPU_proc.RTCcacheFolder=/var/tmp/o2_gpu_rtc_cache;" +[[ ${O2_GPU_RTC:-$EPNSYNCMODE} == 1 ]] && GPU_CONFIG_KEY+="GPU_proc_rtc.enable=1;GPU_proc_rtc.cacheOutput=1;GPU_proc.RTCTECH.prependCommand=/usr/bin/env TMPDIR=/tmp /usr/bin/taskset -c 0-191;" +[[ ${O2_GPU_RTC:-$EPNSYNCMODE} == 1 && $EPNSYNCMODE == 1 ]] && GPU_CONFIG_KEY+="GPU_proc.RTCTECH.cacheFolder=/var/tmp/o2_gpu_rtc_cache;" if [[ ${O2_GPU_RTC:-$EPNSYNCMODE} == 1 ]] && [[ ( ${ALICE_O2_FST:-0} == 1 && ${FST_TMUX_NO_EPN:-0} == 0 ) || $EPNSYNCMODE == 1 ]]; then - [[ ${EPN_NODE_MI100:-0} == 0 ]] && GPU_CONFIG_KEY+="GPU_proc.RTCoverrideArchitecture=--offload-arch=gfx906;" - [[ ${EPN_NODE_MI100:-0} == 1 ]] && GPU_CONFIG_KEY+="GPU_proc.RTCoverrideArchitecture=--offload-arch=gfx908;" + [[ ${EPN_NODE_MI100:-0} == 0 ]] && GPU_CONFIG_KEY+="GPU_proc.RTCTECH.overrideArchitecture=--offload-arch=gfx906;" + [[ ${EPN_NODE_MI100:-0} == 1 ]] && GPU_CONFIG_KEY+="GPU_proc.RTCTECH.overrideArchitecture=--offload-arch=gfx908;" fi ( workflow_has_parameter AOD || [[ -z "$DISABLE_ROOT_OUTPUT" ]] || needs_root_output o2-emcal-cell-writer-workflow ) && has_detector EMC && RAW_EMC_SUBSPEC=" --subspecification 1 " diff --git a/run/CMakeLists.txt b/run/CMakeLists.txt index fd43207f92d1e..ee24844ce6723 100644 --- a/run/CMakeLists.txt +++ b/run/CMakeLists.txt @@ -46,6 +46,7 @@ target_link_libraries(allsim $<$:O2::IOTOFSimulation> $<$:O2::RICHSimulation> $<$:O2::ECalSimulation> + $<$:O2::FDSimulation> $<$:O2::MI3Simulation> O2::Generators) @@ -340,4 +341,4 @@ install(FILES o2-sim-client.py PERMISSIONS GROUP_READ GROUP_EXECUTE OWNER_EXECUT install(DIRECTORY SimExamples/ DESTINATION examples PATTERN * - PERMISSIONS GROUP_READ GROUP_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ WORLD_EXECUTE WORLD_READ) \ No newline at end of file + PERMISSIONS GROUP_READ GROUP_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ WORLD_EXECUTE WORLD_READ) diff --git a/run/O2HitMerger.h b/run/O2HitMerger.h index bd905548b58f3..68e709bc72140 100644 --- a/run/O2HitMerger.h +++ b/run/O2HitMerger.h @@ -78,6 +78,7 @@ #include #include #include +#include #endif #include @@ -1020,6 +1021,10 @@ void O2HitMerger::initDetInstances() mDetectorInstances[i] = std::move(std::make_unique(true)); counter++; } + if (i == DetID::FD) { + mDetectorInstances[i] = std::move(std::make_unique(true)); + counter++; + } #endif } if (counter != DetID::nDetectors) { diff --git a/run/SimExamples/Pythia8_HepMC_Wrapper/Pythia8HepMC3.macro b/run/SimExamples/Pythia8_HepMC_Wrapper/Pythia8HepMC3.macro new file mode 100644 index 0000000000000..9e60bc0a5d851 --- /dev/null +++ b/run/SimExamples/Pythia8_HepMC_Wrapper/Pythia8HepMC3.macro @@ -0,0 +1,44 @@ +/// \author Marco Giacalone - March 2025 + +// A simple wrapper and demonstrator around Pythia8 for extracting HepMC3 files. + +#include "Pythia8/Pythia.h" +#include "Pythia8Plugins/HepMC3.h" + +using namespace o2::eventgen; + +class HepMC3_Pythia8Wrapper : public GeneratorPythia8 +{ + public: + HepMC3_Pythia8Wrapper(std::string filename = "pythia8.hepmc") : GeneratorPythia8(), mFileName(filename) + { + // HepMC conversion object. + mToHepMC = std::make_unique(); + mToHepMC->setNewFile((filename == "" ? "pythia.hepmc" : filename)); + }; + ~HepMC3_Pythia8Wrapper() = default; + + bool importParticles() override + { + // events are written after the importParticles step + // since some filtering is happening there + auto ret = GeneratorPythia8::importParticles(); + if (ret) { + LOG(info) << "Writing event to HepMC3 format"; + mToHepMC->writeNextEvent(mPythia); + } + return ret; + }; + + private: + std::string mFileName = "pythia8.hepmc"; + std::unique_ptr mToHepMC; +}; + +FairGenerator* + hepmc_pythia8(std::string filename = "pythia8.hepmc") +{ + std::cout << "HepMC3_Pythia8Wrapper initialising with filename: " << filename << std::endl; + auto py8 = new HepMC3_Pythia8Wrapper(filename); + return py8; +} diff --git a/run/SimExamples/Pythia8_HepMC_Wrapper/README.md b/run/SimExamples/Pythia8_HepMC_Wrapper/README.md new file mode 100644 index 0000000000000..a334b7b3ef81e --- /dev/null +++ b/run/SimExamples/Pythia8_HepMC_Wrapper/README.md @@ -0,0 +1,16 @@ + + +This example demonstrates how we can extend GeneratorPythia8 in a user-defined macro (or external generator), +to achieve additional HepMC3 export of generated Pythia8 events. + +The example provides a small utility for poeple in need to obtain HepMC files from Pythia8. +Note that many other methods to achieve this are possible (See original Pythia8 example). + +The example provides: + +- The external generator implementation `Pythia8HepMC3.C` +- a `run.sh` script demonstrating it's usage and a check feeding back the generated hepmc into the simulation + + diff --git a/run/SimExamples/Pythia8_HepMC_Wrapper/run.sh b/run/SimExamples/Pythia8_HepMC_Wrapper/run.sh new file mode 100755 index 0000000000000..16ff80f76b1d4 --- /dev/null +++ b/run/SimExamples/Pythia8_HepMC_Wrapper/run.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# +# Script doing Pythia8 event generation and writing these events into HepMC3 files +# (next to generating the usual MCTrack kinematics output). +# +# The script also performs a second event generation based on the generated HepMC3 files. +# In principle it should yield identical kinematics files. +# + +NEVENTS=1000 +SEED=11 + +o2-sim -j 1 -g external --configKeyValues 'GeneratorExternal.fileName=Pythia8HepMC3.macro;GeneratorExternal.funcName=hepmc_pythia8("skimmed.hepmc");GeneratorPythia8.config=${O2_ROOT}/share/Generators/egconfig/pythia8_inel.cfg' --seed ${SEED} --noGeant -o pythia8_skimmed -n ${NEVENTS} +o2-sim -j 1 -g external --configKeyValues 'GeneratorExternal.fileName=Pythia8HepMC3.macro;GeneratorExternal.funcName=hepmc_pythia8("unskimmed.hepmc");GeneratorPythia8.config=${O2_ROOT}/share/Generators/egconfig/pythia8_inel.cfg;GeneratorPythia8.includePartonEvent=true' --seed ${SEED} --noGeant -o pythia8_unskimmed -n ${NEVENTS} + +# propagate generated hepmc file; it should produce the same kinematics as the original Pythia8 +o2-sim -j 1 -g hepmc --configKeyValues="GeneratorFileOrCmd.fileNames=skimmed.hepmc" --vertexMode kNoVertex --noGeant -o fromhepmc_skimmed -n ${NEVENTS} --seed ${SEED} +o2-sim -j 1 -g hepmc --configKeyValues="GeneratorFileOrCmd.fileNames=unskimmed.hepmc" --vertexMode kNoVertex --noGeant -o fromhepmc_unskimmed -n ${NEVENTS} --seed ${SEED} diff --git a/run/SimExamples/README.md b/run/SimExamples/README.md index 725d60c4854ca..3a54625acf413 100644 --- a/run/SimExamples/README.md +++ b/run/SimExamples/README.md @@ -6,6 +6,7 @@ -# ALICE 3 FORVARD DETECTOR +# ALICE 3 FORWARD DETECTOR This is top page for the FD detector documentation. diff --git a/Detectors/Upgrades/ALICE3/FD/base/README.md b/Detectors/Upgrades/ALICE3/FD/base/README.md deleted file mode 100644 index 1fba33c47b690..0000000000000 --- a/Detectors/Upgrades/ALICE3/FD/base/README.md +++ /dev/null @@ -1,17 +0,0 @@ - - -# FV0 Base - -## Geometry - -The `o2::fv0::Geometry` class represents the geometry of the FV0 detector as used in simulation. It also provides utility methods for retrieving the center locations of the detector cells. See the below example for how to use the `Geometry` class to query the FV0 cell locations. Note that these are the ideal locations, and that any misalignment is not considered. - -```cpp -o2::fv0::Geometry* fv0Geometry = o2::fv0::Geometry::instance(o2::fv0::Geometry::eUninitialized); -o2::fv0::Point3Dsimple cellPosition = fv0Geometry->getReadoutCenter(chId); -float x = cellPosition.x; -float y = cellPosition.y; -float z = cellPosition.z; -``` diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 4bc912b174df0..66fa8ec730eb4 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -76,7 +76,7 @@ Detector::Detector(bool active) mDzScint = baseParam.dzscint / 2; mDzPlate = baseParam.dzplate; - mPlateBehindA= baseParam.plateBehindA; + mPlateBehindA = baseParam.plateBehindA; mFullContainer = baseParam.fullContainer; mZA = baseParam.zmodA; @@ -288,7 +288,6 @@ void Detector::createMaterials() o2::base::Detector::Material(++matId, "Aluminium", aAlu, zAlu, dAlu, 8.9, 999); o2::base::Detector::Medium(Aluminium, "Aluminium", matId, unsens, fieldType, maxField, tmaxfd, stemax, deemax, epsil, stmin); - } void Detector::buildModules() @@ -343,11 +342,11 @@ TGeoVolumeAssembly* Detector::buildModuleA() auto pnod1 = new TGeoVolume("pnod1_FDA", pvol, pmed); double dpz = 2. + mDzPlate / 2; mod->AddNode(pnod1, 1, new TGeoTranslation(0, 0, dpz)); - + if (mFullContainer) { auto pnod2 = new TGeoVolume("pnod2_FDA", pvol, pmed); mod->AddNode(pnod2, 1, new TGeoTranslation(0, 0, -dpz)); - } + } } return mod; } @@ -389,7 +388,7 @@ TGeoVolumeAssembly* Detector::buildModuleC() double dpz = mDzScint / 2 + mDzPlate / 2; mod->AddNode(pnod1, 1, new TGeoTranslation(0, 0, dpz)); - mod->AddNode(pnod2, 1, new TGeoTranslation(0, 0, - dpz)); + mod->AddNode(pnod2, 1, new TGeoTranslation(0, 0, -dpz)); } return mod; From 2d1bd3b6fba4f48faeef1e46f7a6b4d7b7aea5b4 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sat, 19 Jul 2025 15:49:50 +0200 Subject: [PATCH 57/68] introduced FD hit data format --- .../Detectors/Upgrades/ALICE3/CMakeLists.txt | 12 ++ .../Upgrades/ALICE3/FD/CMakeLists.txt | 23 ++++ .../ALICE3/FD/include/DataFormatsFD/Hit.h | 125 ++++++++++++++++++ .../ALICE3/FD/src/DataFormatsFDLinkDef.h | 21 +++ .../Detectors/Upgrades/ALICE3/FD/src/Hit.cxx | 35 +++++ DataFormats/Detectors/Upgrades/CMakeLists.txt | 1 + Detectors/Upgrades/ALICE3/FD/CMakeLists.txt | 16 +-- .../FD/base/include/FDBase/FDBaseParam.h | 2 +- .../ALICE3/FD/simulation/CMakeLists.txt | 2 +- .../include/FDSimulation/Detector.h | 24 ++-- .../ALICE3/FD/simulation/src/Detector.cxx | 70 ++++------ 11 files changed, 264 insertions(+), 67 deletions(-) create mode 100644 DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt create mode 100644 DataFormats/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt create mode 100644 DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h create mode 100644 DataFormats/Detectors/Upgrades/ALICE3/FD/src/DataFormatsFDLinkDef.h create mode 100644 DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx diff --git a/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt b/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt new file mode 100644 index 0000000000000..0fb2f630b53fa --- /dev/null +++ b/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt @@ -0,0 +1,12 @@ +#Copyright 2019 - 2020 CERN and copyright holders of ALICE O2. +#See https: // alice-o2.web.cern.ch/copyright for details of the copyright holders. +#All rights not expressly granted are reserved. +# +#This software is distributed under the terms of the GNU General Public +#License v3(GPL Version 3), copied verbatim in the file "COPYING". +# +#In applying this license CERN does not waive the privileges and immunities +#granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +add_subdirectory(FD) diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt b/DataFormats/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt new file mode 100644 index 0000000000000..3b602dc0077c8 --- /dev/null +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +o2_add_library(DataFormatsFD + SOURCES src/Hit.cxx + PUBLIC_LINK_LIBRARIES O2::FDBase + O2::SimulationDataFormat + O2::CommonDataFormat + Microsoft.GSL::GSL + O2::DetectorsCommonDataFormats +) + +o2_target_root_dictionary(DataFormatsFD + HEADERS include/DataFormatsFD/Hit.h +) diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h b/DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h new file mode 100644 index 0000000000000..380018b2e490b --- /dev/null +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h @@ -0,0 +1,125 @@ +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file Hit.h +/// \brief Definition of the FD Hit class (based on ITSMFT and FV0) + +#ifndef ALICEO2_FVD_HIT_H_ +#define ALICEO2_FVD_HIT_H_ + +#include +#include "SimulationDataFormat/BaseHits.h" // for BasicXYZEHit +#include "Rtypes.h" // for Bool_t, Double_t, int, Double32_t, etc +#include "TVector3.h" // for TVector3 +#include "CommonUtils/ShmAllocator.h" + +namespace o2 +{ +namespace fd +{ + +class Hit : public o2::BasicXYZEHit +{ + public: + /// Default constructor + Hit() = default; + + /// Class Constructor + /// \param trackID Index of MCTrack + /// \param cellID Cell ID + /// \param startPos Coordinates at entrance to active volume [cm] + /// \param endPos Coordinates to active volume [cm] + /// \param startMom Momentum of track at entrance [GeV] + /// \param startE Energy of track at entrance [GeV] + /// \param endTime Final time [ns] + /// \param eLoss Energy deposit [GeV] + /// \param particlePdg PDG code of the partcile associated with the track + inline Hit(int trackID, + int cellID, + const math_utils::Point3D& startPos, + const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, + double startE, + double endTime, + double eLoss, + int particlePdg); + + // Entrance position getters + math_utils::Point3D const& GetPosStart() const { return mPositionStart; } + float GetStartX() const { return mPositionStart.X(); } + float GetStartY() const { return mPositionStart.Y(); } + float GetStartZ() const { return mPositionStart.Z(); } + template + void GetStartPosition(F& x, F& y, F& z) const + { + x = GetStartX(); + y = GetStartY(); + z = GetStartZ(); + } + + // Momentum getters + math_utils::Vector3D const& GetMomentum() const { return mMomentumStart; } + math_utils::Vector3D& GetMomentum() { return mMomentumStart; } + float GetPx() const { return mMomentumStart.X(); } + float GetPy() const { return mMomentumStart.Y(); } + float GetPz() const { return mMomentumStart.Z(); } + float GetE() const { return mEnergyStart; } + float GetTotalEnergyAtEntrance() const { return GetE(); } + int GetParticlePdg() const { return mParticlePdg; } + + void Print(const Option_t* opt) const; + + private: + math_utils::Vector3D mMomentumStart; ///< momentum at entrance + math_utils::Point3D mPositionStart; ///< position at entrance (base mPos give position on exit) + float mEnergyStart; ///< total energy at entrance + int mParticlePdg; ///< PDG code of the particle associated with this track + + ClassDefNV(Hit, 1); +}; + +Hit::Hit(int trackID, + int detID, + const math_utils::Point3D& startPos, + const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, + double startE, + double endTime, + double eLoss, + int particlePdg) + : BasicXYZEHit(endPos.X(), + endPos.Y(), + endPos.Z(), + endTime, + eLoss, + trackID, + detID), + mMomentumStart(startMom.X(), startMom.Y(), startMom.Z()), + mPositionStart(startPos.X(), startPos.Y(), startPos.Z()), + mEnergyStart(startE), + mParticlePdg(particlePdg) +{ +} + +} // namespace fd +} // namespace o2 + +#ifdef USESHM +namespace std +{ +template <> +class allocator : public o2::utils::ShmAllocator +{ +}; + +} // namespace std +#endif /* USESHM */ +#endif /* ALICEO2_FD_HIT_H_ */ diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/src/DataFormatsFDLinkDef.h b/DataFormats/Detectors/Upgrades/ALICE3/FD/src/DataFormatsFDLinkDef.h new file mode 100644 index 0000000000000..f8000bbffe606 --- /dev/null +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD/src/DataFormatsFDLinkDef.h @@ -0,0 +1,21 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::fd::Hit + ; +#pragma link C++ class vector < o2::fd::Hit> + ; + +#endif diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx b/DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx new file mode 100644 index 0000000000000..10bcddb2765ab --- /dev/null +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx @@ -0,0 +1,35 @@ +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file Hit.cxx +/// \brief Implementation of the Hit class + +#include "DataFormatsFD/Hit.h" +#include + +ClassImp(o2::fd::Hit); + +namespace o2 +{ +namespace fd +{ + +void Hit::Print(const Option_t* opt) const +{ + printf( + "Det: %5d Track: %6d E.loss: %.3e P: %+.3e %+.3e %+.3e\n" + "PosIn: %+.3e %+.3e %+.3e PosOut: %+.3e %+.3e %+.3e\n", + GetDetectorID(), GetTrackID(), GetEnergyLoss(), GetPx(), GetPy(), GetPz(), + GetStartX(), GetStartY(), GetStartZ(), GetX(), GetY(), GetZ()); +} + +} // namespace fd +} // namespace o2 diff --git a/DataFormats/Detectors/Upgrades/CMakeLists.txt b/DataFormats/Detectors/Upgrades/CMakeLists.txt index a2d470b8ff6d5..113e2c5ca7ace 100644 --- a/DataFormats/Detectors/Upgrades/CMakeLists.txt +++ b/DataFormats/Detectors/Upgrades/CMakeLists.txt @@ -10,3 +10,4 @@ # or submit itself to any jurisdiction. message(STATUS "Building dataformats for upgrades") +add_subdirectory(ALICE3) diff --git a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt index 3dde618f9d57a..19d7ed40827b2 100644 --- a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt @@ -1,13 +1,13 @@ -# Copyright 2019-2020 CERN and copyright holders of ALICE O2. -# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -# All rights not expressly granted are reserved. +#Copyright 2019 - 2020 CERN and copyright holders of ALICE O2. +#See https: // alice-o2.web.cern.ch/copyright for details of the copyright holders. +#All rights not expressly granted are reserved. # -# This software is distributed under the terms of the GNU General Public -# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +#This software is distributed under the terms of the GNU General Public +#License v3(GPL Version 3), copied verbatim in the file "COPYING". # -# In applying this license CERN does not waive the privileges and immunities -# granted to it by virtue of its status as an Intergovernmental Organization +#In applying this license CERN does not waive the privileges and immunities +#granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. add_subdirectory(base) -add_subdirectory(simulation) + add_subdirectory(simulation) diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h index 891386deaca18..f8f472fc2ea08 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h @@ -28,7 +28,7 @@ struct FDBaseParam : public o2::conf::ConfigurableParamHelper { bool withMG = false; // modified geometry with 3 rings on A side - bool plateBehindA = true; + bool plateBehindA = false; bool fullContainer = false; float dzplate = 1.0f; // Aluminium plate width diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt index c17b0244ae9e1..2d2793b64105d 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt @@ -12,7 +12,7 @@ o2_add_library(FDSimulation SOURCES src/Detector.cxx PUBLIC_LINK_LIBRARIES O2::FDBase - O2::ITSMFTSimulation + O2::DataFormatsFD ROOT::Physics) o2_target_root_dictionary(FDSimulation diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h index af074a3c0a6b6..a701ad4d985ca 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h @@ -19,11 +19,12 @@ #include "DetectorsBase/Detector.h" #include "FDBase/GeometryTGeo.h" #include "FDBase/FDBaseParam.h" -#include "ITSMFTSimulation/Hit.h" +#include "DataFormatsFD/Hit.h" #include "Rtypes.h" #include "TGeoManager.h" #include "TLorentzVector.h" #include "TVector3.h" +#include class FairVolume; class TGeoVolume; @@ -53,16 +54,15 @@ class Detector : public o2::base::DetImpl void ConstructGeometry() override; /// This method is an example of how to add your own point of type Hit to the clones array - o2::itsmft::Hit* addHit(int trackID, int detID, - const TVector3& startPos, - const TVector3& endPos, - const TVector3& startMom, - double startE, - double endTime, double eLoss, - unsigned int startStatus, - unsigned int endStatus); - - std::vector* getHits(Int_t iColl) + o2::fd::Hit* addHit(int trackId, unsigned int detId, + const math_utils::Point3D& startPos, + const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, double startE, + double endTime, double eLoss, int particlePdg); + // unsigned int startStatus, + // unsigned int endStatus); + + std::vector* getHits(Int_t iColl) { if (iColl == 0) { return mHits; @@ -93,7 +93,7 @@ class Detector : public o2::base::DetImpl Detector(const Detector&); Detector& operator=(const Detector&); - std::vector* mHits = nullptr; + std::vector* mHits = nullptr; GeometryTGeo* mGeometryTGeo = nullptr; TGeoVolumeAssembly* buildModuleA(); diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 66fa8ec730eb4..4168a1d75f6f3 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -12,7 +12,7 @@ /// \file Detector.cxx /// \brief Implementation of the Detector class -#include "ITSMFTSimulation/Hit.h" +#include "DataFormatsFD/Hit.h" #include "FDSimulation/Detector.h" #include "FDBase/GeometryTGeo.h" #include "FDBase/FDBaseParam.h" @@ -41,17 +41,18 @@ #include #include #include "TRandom.h" +#include class FairModule; class TGeoMedium; using namespace o2::fd; -using o2::itsmft::Hit; +using o2::fd::Hit; Detector::Detector(bool active) : o2::base::DetImpl("FD", true), - mHits(o2::utils::createSimVector()), + mHits(o2::utils::createSimVector()), mGeometryTGeo(nullptr), mTrackData() { @@ -98,7 +99,7 @@ Detector::Detector(bool active) Detector::Detector(const Detector& rhs) : o2::base::DetImpl(rhs), mTrackData(), - mHits(o2::utils::createSimVector()) + mHits(o2::utils::createSimVector()) { } @@ -140,34 +141,12 @@ bool Detector::ProcessHits(FairVolume* vol) auto stack = (o2::data::Stack*)fMC->GetStack(); - // int cellId = vol->getVolumeId(); - // Check track status to define when hit is started and when it is stopped + int particlePdg = fMC->TrackPid(); bool startHit = false, stopHit = false; - unsigned char status = 0; - if (fMC->IsTrackEntering()) { - status |= Hit::kTrackEntering; - } - if (fMC->IsTrackInside()) { - status |= Hit::kTrackInside; - } - if (fMC->IsTrackExiting()) { - status |= Hit::kTrackExiting; - } - if (fMC->IsTrackOut()) { - status |= Hit::kTrackOut; - } - if (fMC->IsTrackStop()) { - status |= Hit::kTrackStopped; - } - if (fMC->IsTrackAlive()) { - status |= Hit::kTrackAlive; - } - - // track is entering or created in the volume - if ((status & Hit::kTrackEntering) || (status & Hit::kTrackInside && !mTrackData.mHitStarted)) { + if ((fMC->IsTrackEntering()) || (fMC->IsTrackInside() && !mTrackData.mHitStarted)) { startHit = true; - } else if ((status & (Hit::kTrackExiting | Hit::kTrackOut | Hit::kTrackStopped))) { + } else if ((fMC->IsTrackExiting() || fMC->IsTrackOut() || fMC->IsTrackStop())) { stopHit = true; } @@ -191,12 +170,15 @@ bool Detector::ProcessHits(FairVolume* vol) TLorentzVector positionStop; fMC->TrackPosition(positionStop); int trackId = stack->GetCurrentTrackNumber(); - unsigned int chId = getChannelId(mTrackData.mPositionStart.Vect()); + unsigned int detId = getChannelId(mTrackData.mPositionStart.Vect()); - Hit* p = addHit(trackId, chId /*cellId*/, mTrackData.mPositionStart.Vect(), positionStop.Vect(), - mTrackData.mMomentumStart.Vect(), mTrackData.mMomentumStart.E(), - positionStop.T(), mTrackData.mEnergyLoss, mTrackData.mTrkStatusStart, - status); + math_utils::Point3D posStart(mTrackData.mPositionStart.X(), mTrackData.mPositionStart.Y(), mTrackData.mPositionStart.Z()); + math_utils::Point3D posStop(positionStop.X(), positionStop.Y(), positionStop.Z()); + math_utils::Vector3D momStart(mTrackData.mMomentumStart.Px(), mTrackData.mMomentumStart.Py(), mTrackData.mMomentumStart.Pz()); + + Hit* p = addHit(trackId, detId, posStart, posStop, + momStart, mTrackData.mMomentumStart.E(), + positionStop.T(), mTrackData.mEnergyLoss, particlePdg); stack->addHit(GetDetId()); } else { return false; // do nothing more @@ -204,18 +186,17 @@ bool Detector::ProcessHits(FairVolume* vol) return true; } -o2::itsmft::Hit* Detector::addHit(int trackId, int cellId, - const TVector3& startPos, - const TVector3& endPos, - const TVector3& startMom, - double startE, - double endTime, - double eLoss, - unsigned int startStatus, - unsigned int endStatus) +o2::fd::Hit* Detector::addHit(int trackId, unsigned int cellId, + const math_utils::Point3D& startPos, + const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, + double startE, + double endTime, + double eLoss, + int particlePdg) { mHits->emplace_back(trackId, cellId, startPos, - endPos, startMom, startE, endTime, eLoss, startStatus, endStatus); + endPos, startMom, startE, endTime, eLoss, particlePdg); return &(mHits->back()); } @@ -250,7 +231,6 @@ void Detector::Reset() void Detector::createMaterials() { - float density, as[11], zs[11], ws[11]; double radLength, absLength, a_ad, z_ad; int id; From e1b320eb5d2176b24082242855fc37318d3540bc Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sat, 19 Jul 2025 18:23:55 +0200 Subject: [PATCH 58/68] introduced FD hit data format --- .../Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h | 2 +- DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx | 2 +- Detectors/Upgrades/ALICE3/FD/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h b/DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h index 380018b2e490b..fc23ca71cbb9b 100644 --- a/DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h @@ -1,4 +1,4 @@ -// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. // All rights not expressly granted are reserved. // diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx b/DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx index 10bcddb2765ab..bfbf396393af7 100644 --- a/DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx @@ -1,4 +1,4 @@ -// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. // All rights not expressly granted are reserved. // diff --git a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt index 19d7ed40827b2..dc4fbb46c0461 100644 --- a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt @@ -10,4 +10,4 @@ # or submit itself to any jurisdiction. add_subdirectory(base) - add_subdirectory(simulation) +add_subdirectory(simulation) From af5699b7f56a0a329827e22fb6ea3e4106d1ef44 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sat, 19 Jul 2025 18:34:17 +0200 Subject: [PATCH 59/68] corrected copyright notice --- DataFormats/Detectors/Upgrades/CMakeLists.txt | 20 +++++++++--------- Detectors/Upgrades/ALICE3/FD/CMakeLists.txt | 21 ++++++++++--------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/DataFormats/Detectors/Upgrades/CMakeLists.txt b/DataFormats/Detectors/Upgrades/CMakeLists.txt index 113e2c5ca7ace..6a9d1dd6b8da8 100644 --- a/DataFormats/Detectors/Upgrades/CMakeLists.txt +++ b/DataFormats/Detectors/Upgrades/CMakeLists.txt @@ -1,13 +1,13 @@ -# Copyright 2019-2020 CERN and copyright holders of ALICE O2. -# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -# All rights not expressly granted are reserved. -# -# This software is distributed under the terms of the GNU General Public -# License v3 (GPL Version 3), copied verbatim in the file "COPYING". -# -# In applying this license CERN does not waive the privileges and immunities -# granted to it by virtue of its status as an Intergovernmental Organization -# or submit itself to any jurisdiction. +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. message(STATUS "Building dataformats for upgrades") add_subdirectory(ALICE3) diff --git a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt index dc4fbb46c0461..0994affd819df 100644 --- a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt @@ -1,13 +1,14 @@ -#Copyright 2019 - 2020 CERN and copyright holders of ALICE O2. -#See https: // alice-o2.web.cern.ch/copyright for details of the copyright holders. -#All rights not expressly granted are reserved. -# -#This software is distributed under the terms of the GNU General Public -#License v3(GPL Version 3), copied verbatim in the file "COPYING". -# -#In applying this license CERN does not waive the privileges and immunities -#granted to it by virtue of its status as an Intergovernmental Organization -# or submit itself to any jurisdiction. +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + add_subdirectory(base) add_subdirectory(simulation) From 691b39ff47e7a49b7e1124331d64b03bca8c8d30 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sat, 19 Jul 2025 19:01:59 +0200 Subject: [PATCH 60/68] corrected copyright notice --- .../Detectors/Upgrades/ALICE3/CMakeLists.txt | 14 ++++++------- Detectors/Upgrades/ALICE3/FD/CMakeLists.txt | 21 +++++++++---------- .../Upgrades/ALICE3/FD/base/CMakeLists.txt | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt b/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt index 0fb2f630b53fa..a38af9c52b8de 100644 --- a/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt +++ b/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt @@ -1,12 +1,12 @@ -#Copyright 2019 - 2020 CERN and copyright holders of ALICE O2. -#See https: // alice-o2.web.cern.ch/copyright for details of the copyright holders. -#All rights not expressly granted are reserved. +# Copyright 2019-2025 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. # -#This software is distributed under the terms of the GNU General Public -#License v3(GPL Version 3), copied verbatim in the file "COPYING". +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". # -#In applying this license CERN does not waive the privileges and immunities -#granted to it by virtue of its status as an Intergovernmental Organization +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. add_subdirectory(FD) diff --git a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt index 0994affd819df..d9ea4b632952c 100644 --- a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt @@ -1,14 +1,13 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - +# Copyright 2019-2025 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. add_subdirectory(base) add_subdirectory(simulation) diff --git a/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt index 65de538eb0ea1..f0f6f067f48d8 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# Copyright 2019-2025 CERN and copyright holders of ALICE O2. # See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. # All rights not expressly granted are reserved. # From 0638cac58724741632c7cfa03387f2d2d53f3b4a Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Sat, 19 Jul 2025 19:07:11 +0200 Subject: [PATCH 61/68] corrected copyright notice --- DataFormats/Detectors/Upgrades/CMakeLists.txt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DataFormats/Detectors/Upgrades/CMakeLists.txt b/DataFormats/Detectors/Upgrades/CMakeLists.txt index 6a9d1dd6b8da8..0dfe07dc2827d 100644 --- a/DataFormats/Detectors/Upgrades/CMakeLists.txt +++ b/DataFormats/Detectors/Upgrades/CMakeLists.txt @@ -1,13 +1,13 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. +# Copyright 2019-2025 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. message(STATUS "Building dataformats for upgrades") add_subdirectory(ALICE3) From c130e7600e4d69ff9420a7aab02873bb88e1208a Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 11 Aug 2025 20:54:16 +0200 Subject: [PATCH 62/68] Finding detId from fMC --- .../include/FDSimulation/Detector.h | 15 ++--- .../ALICE3/FD/simulation/src/Detector.cxx | 59 ++++++------------- 2 files changed, 21 insertions(+), 53 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h index a701ad4d985ca..f32b2b531017e 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h @@ -101,17 +101,12 @@ class Detector : public o2::base::DetImpl float ringSize(float zmod, float eta); - unsigned int mNumberOfSectors; - unsigned int mNumberOfRingsA; - unsigned int mNumberOfRingsC; - float mDzScint; - float mDzPlate; + unsigned int mNumberOfRingsA, mNumberOfRingsC, mNumberOfSectors; + float mDzScint, mDzPlate; - std::vector mRingSizesA = {}; - std::vector mRingSizesC = {}; + std::vector mRingSizesA = {}, mRingSizesC = {}; - float mEtaMaxA, mEtaMaxC; - float mEtaMinA, mEtaMinC; + float mEtaMaxA, mEtaMaxC, mEtaMinA, mEtaMinC; float mZA, mZC; bool mPlateBehindA, mFullContainer; @@ -119,8 +114,6 @@ class Detector : public o2::base::DetImpl void defineSensitiveVolumes(); void definePassiveVolumes(); - unsigned int getChannelId(TVector3 vec); - /// Transient data about track passing the sensor, needed by ProcessHits() struct TrackData { // this is transient bool mHitStarted; //! hit creation started diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 4168a1d75f6f3..7656c790bcfc4 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -127,7 +127,7 @@ Detector::~Detector() void Detector::InitializeO2Detector() { - LOG(info) << "Initialize FD detector"; + LOG(info) << "Initialize Forward Detector"; mGeometryTGeo = GeometryTGeo::Instance(); defineSensitiveVolumes(); } @@ -139,6 +139,9 @@ bool Detector::ProcessHits(FairVolume* vol) return kFALSE; } + int detId; + int volID = fMC->CurrentVolID(detId); + auto stack = (o2::data::Stack*)fMC->GetStack(); // Check track status to define when hit is started and when it is stopped @@ -170,7 +173,6 @@ bool Detector::ProcessHits(FairVolume* vol) TLorentzVector positionStop; fMC->TrackPosition(positionStop); int trackId = stack->GetCurrentTrackNumber(); - unsigned int detId = getChannelId(mTrackData.mPositionStart.Vect()); math_utils::Point3D posStart(mTrackData.mPositionStart.X(), mTrackData.mPositionStart.Y(), mTrackData.mPositionStart.Z()); math_utils::Point3D posStop(positionStop.X(), positionStop.Y(), positionStop.Z()); @@ -186,7 +188,7 @@ bool Detector::ProcessHits(FairVolume* vol) return true; } -o2::fd::Hit* Detector::addHit(int trackId, unsigned int cellId, +o2::fd::Hit* Detector::addHit(int trackId, unsigned int detId, const math_utils::Point3D& startPos, const math_utils::Point3D& endPos, const math_utils::Vector3D& startMom, @@ -195,7 +197,7 @@ o2::fd::Hit* Detector::addHit(int trackId, unsigned int cellId, double eLoss, int particlePdg) { - mHits->emplace_back(trackId, cellId, startPos, + mHits->emplace_back(trackId, detId, startPos, endPos, startMom, startE, endTime, eLoss, particlePdg); return &(mHits->back()); } @@ -277,14 +279,14 @@ void Detector::buildModules() TGeoVolume* vCave = gGeoManager->GetVolume("cave"); if (!vCave) { - LOG(fatal) << "Could not find the top volume (cave)!"; + LOG(fatal) << "Could not find the top volume!"; } TGeoVolumeAssembly* vFDA = buildModuleA(); TGeoVolumeAssembly* vFDC = buildModuleC(); vCave->AddNode(vFDA, 1, new TGeoTranslation(0., 0., mZA)); - vCave->AddNode(vFDC, 1, new TGeoTranslation(0., 0., mZC)); + vCave->AddNode(vFDC, 2, new TGeoTranslation(0., 0., mZC)); } TGeoVolumeAssembly* Detector::buildModuleA() @@ -311,7 +313,7 @@ TGeoVolumeAssembly* Detector::buildModuleA() nod->SetLineColor(kRed); ring->AddNode(nod, cellId); } - mod->AddNode(ring, 1); + mod->AddNode(ring, ir + 1); } // Aluminium plates on one or both sides of the A side module @@ -355,7 +357,7 @@ TGeoVolumeAssembly* Detector::buildModuleC() nod->SetLineColor(kBlue); ring->AddNode(nod, cellId); } - mod->AddNode(ring, 1); + mod->AddNode(ring, ir + 1); } // Aluminium plates on both sides of the C side module @@ -368,7 +370,7 @@ TGeoVolumeAssembly* Detector::buildModuleC() double dpz = mDzScint / 2 + mDzPlate / 2; mod->AddNode(pnod1, 1, new TGeoTranslation(0, 0, dpz)); - mod->AddNode(pnod2, 1, new TGeoTranslation(0, 0, -dpz)); + mod->AddNode(pnod2, 2, new TGeoTranslation(0, 0, -dpz)); } return mod; @@ -381,47 +383,20 @@ void Detector::defineSensitiveVolumes() TGeoVolume* v; TString volumeName; - int nCellA = mNumberOfRingsA * mNumberOfSectors; - int nCellC = mNumberOfRingsC * mNumberOfSectors; + int nCellsA = mNumberOfRingsA * mNumberOfSectors; + int nCellsC = mNumberOfRingsC * mNumberOfSectors; - LOG(info) << "number of A rings = " << mNumberOfRingsA << " number of cells = " << nCellA; + LOG(info) << "number of A rings = " << mNumberOfRingsA << " number of cells = " << nCellsA; + LOG(info) << "number of C rings = " << mNumberOfRingsC << " number of cells = " << nCellsC; - for (int iv = 0; iv < nCellA + nCellC; iv++) { + for (int iv = 0; iv < nCellsA + nCellsC; iv++) { volumeName = "fd_node" + std::to_string(iv); v = gGeoManager->GetVolume(volumeName); - LOG(info) << "Adding FD Sensitive Volume => " << v->GetName(); + LOG(info) << "Adding sensitive volume => " << v->GetName(); AddSensitiveVolume(v); } } -unsigned int Detector::getChannelId(TVector3 vec) -{ - float phi = vec.Phi(); - if (phi < 0) { - phi += TMath::TwoPi(); - } - - float r = vec.Perp(); - float z = vec.Z(); - - int isect = int(phi / (TMath::TwoPi() / mNumberOfSectors)); - - std::vector rd = z > 0 ? mRingSizesA : mRingSizesC; - int noff = z > 0 ? 0 : mNumberOfRingsA * mNumberOfSectors; - - int ir = 0; - - for (int i = 1; i < rd.size(); i++) { - if (r < rd[i]) { - break; - } else { - ir++; - } - } - - return ir * mNumberOfSectors + isect + noff; -} - float Detector::ringSize(float z, float eta) { return z * TMath::Tan(2 * TMath::ATan(TMath::Exp(-eta))); From c3553cb8a7adf86f44442952b29821d5933d7c3f Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Fri, 3 Oct 2025 05:50:40 +0200 Subject: [PATCH 63/68] colors --- .../Upgrades/ALICE3/FD/simulation/src/Detector.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx index 7656c790bcfc4..c9fc6c9f4e76b 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx @@ -310,7 +310,10 @@ TGeoVolumeAssembly* Detector::buildModuleA() float phimax = dphiDeg * (ic + 1); auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - nod->SetLineColor(kRed); + if ((ir + ic) % 2 == 0) + nod->SetLineColor(kRed); + else + nod->SetLineColor(kRed - 7); ring->AddNode(nod, cellId); } mod->AddNode(ring, ir + 1); @@ -354,7 +357,10 @@ TGeoVolumeAssembly* Detector::buildModuleC() float phimax = dphiDeg * (ic + 1); auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - nod->SetLineColor(kBlue); + if ((ir + ic) % 2 == 0) + nod->SetLineColor(kBlue); + else + nod->SetLineColor(kBlue - 7); ring->AddNode(nod, cellId); } mod->AddNode(ring, ir + 1); From ee96e8da4a9af6f2d86e6efd5d5ba247aadf5be8 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 9 Oct 2025 07:02:26 +0200 Subject: [PATCH 64/68] change detector name --- Common/SimConfig/src/SimConfig.cxx | 8 +- .../Detectors/Upgrades/ALICE3/CMakeLists.txt | 2 +- .../ALICE3/{FD => FD3}/CMakeLists.txt | 8 +- .../include/DataFormatsFD3}/Hit.h | 10 +- .../src/DataFormatsFD3LinkDef.h} | 4 +- .../Upgrades/ALICE3/{FD => FD3}/src/Hit.cxx | 8 +- Detectors/Upgrades/ALICE3/CMakeLists.txt | 2 +- .../ALICE3/{FD => FD3}/CMakeLists.txt | 0 .../Upgrades/ALICE3/{FD => FD3}/README.md | 2 +- .../ALICE3/{FD => FD3}/base/CMakeLists.txt | 12 +- .../base/include/FD3Base}/Constants.h | 8 +- .../base/include/FD3Base/FD3BaseParam.h} | 16 +-- .../base/include/FD3Base}/GeometryTGeo.h | 14 +- .../base/src/FD3BaseLinkDef.h} | 8 +- .../base/src/FD3BaseParam.cxx} | 4 +- .../{FD => FD3}/base/src/GeometryTGeo.cxx | 14 +- .../{FD => FD3}/simulation/CMakeLists.txt | 10 +- .../include/FD3Simulation}/Detector.h | 32 ++--- .../{FD => FD3}/simulation/src/Detector.cxx | 120 +++++++++--------- .../simulation/src/FD3SimulationLinkDef.h} | 4 +- macro/build_geometry.C | 8 +- run/CMakeLists.txt | 2 +- run/O2HitMerger.h | 6 +- run/o2simdefaultdetectorlist.json | 2 +- 24 files changed, 153 insertions(+), 151 deletions(-) rename DataFormats/Detectors/Upgrades/ALICE3/{FD => FD3}/CMakeLists.txt (83%) rename DataFormats/Detectors/Upgrades/ALICE3/{FD/include/DataFormatsFD => FD3/include/DataFormatsFD3}/Hit.h (94%) rename DataFormats/Detectors/Upgrades/ALICE3/{FD/src/DataFormatsFDLinkDef.h => FD3/src/DataFormatsFD3LinkDef.h} (88%) rename DataFormats/Detectors/Upgrades/ALICE3/{FD => FD3}/src/Hit.cxx (91%) rename Detectors/Upgrades/ALICE3/{FD => FD3}/CMakeLists.txt (100%) rename Detectors/Upgrades/ALICE3/{FD => FD3}/README.md (68%) rename Detectors/Upgrades/ALICE3/{FD => FD3}/base/CMakeLists.txt (73%) rename Detectors/Upgrades/ALICE3/{FD/base/include/FDBase => FD3/base/include/FD3Base}/Constants.h (91%) rename Detectors/Upgrades/ALICE3/{FD/base/include/FDBase/FDBaseParam.h => FD3/base/include/FD3Base/FD3BaseParam.h} (75%) rename Detectors/Upgrades/ALICE3/{FD/base/include/FDBase => FD3/base/include/FD3Base}/GeometryTGeo.h (85%) rename Detectors/Upgrades/ALICE3/{FD/base/src/FDBaseLinkDef.h => FD3/base/src/FD3BaseLinkDef.h} (81%) rename Detectors/Upgrades/ALICE3/{FD/base/src/FDBaseParam.cxx => FD3/base/src/FD3BaseParam.cxx} (88%) rename Detectors/Upgrades/ALICE3/{FD => FD3}/base/src/GeometryTGeo.cxx (81%) rename Detectors/Upgrades/ALICE3/{FD => FD3}/simulation/CMakeLists.txt (72%) rename Detectors/Upgrades/ALICE3/{FD/simulation/include/FDSimulation => FD3/simulation/include/FD3Simulation}/Detector.h (82%) rename Detectors/Upgrades/ALICE3/{FD => FD3}/simulation/src/Detector.cxx (74%) rename Detectors/Upgrades/ALICE3/{FD/simulation/src/FDSimulationLinkDef.h => FD3/simulation/src/FD3SimulationLinkDef.h} (85%) diff --git a/Common/SimConfig/src/SimConfig.cxx b/Common/SimConfig/src/SimConfig.cxx index 59c1e868987bd..2c28497fa4237 100644 --- a/Common/SimConfig/src/SimConfig.cxx +++ b/Common/SimConfig/src/SimConfig.cxx @@ -99,7 +99,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules[i] != "RCH" && activeModules[i] != "MI3" && activeModules[i] != "ECL" && - activeModules[i] != "FD") { + activeModules[i] != "FD3") { LOGP(fatal, "List of active modules contains {}, which is not a module from the upgrades.", activeModules[i]); } } @@ -114,7 +114,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules[i] == "RCH" || activeModules[i] == "MI3" || activeModules[i] == "ECL" || - activeModules[i] == "FD") { + activeModules[i] == "FD3") { LOGP(fatal, "List of active modules contains {}, which is not a run 3 module", activeModules[i]); } } @@ -132,7 +132,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs d == DetID::TF3 || d == DetID::RCH || d == DetID::ECL || - d == DetID::FD || + d == DetID::FD3 || d == DetID::MI3) { activeModules.emplace_back(DetID::getName(d)); } @@ -152,7 +152,7 @@ void SimConfig::determineActiveModules(std::vector const& inputargs activeModules.emplace_back("SHIL"); for (int d = DetID::First; d <= DetID::Last; ++d) { #ifdef ENABLE_UPGRADES - if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT && d != DetID::TF3 && d != DetID::RCH && d != DetID::ECL && d != DetID::FD && d != DetID::MI3) { + if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT && d != DetID::TF3 && d != DetID::RCH && d != DetID::ECL && d != DetID::FD3 && d != DetID::MI3) { activeModules.emplace_back(DetID::getName(d)); } } diff --git a/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt b/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt index a38af9c52b8de..b3944c2e502d8 100644 --- a/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt +++ b/DataFormats/Detectors/Upgrades/ALICE3/CMakeLists.txt @@ -9,4 +9,4 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -add_subdirectory(FD) +add_subdirectory(FD3) diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt b/DataFormats/Detectors/Upgrades/ALICE3/FD3/CMakeLists.txt similarity index 83% rename from DataFormats/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt rename to DataFormats/Detectors/Upgrades/ALICE3/FD3/CMakeLists.txt index 3b602dc0077c8..e2219bb893612 100644 --- a/DataFormats/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD3/CMakeLists.txt @@ -9,15 +9,15 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2_add_library(DataFormatsFD +o2_add_library(DataFormatsFD3 SOURCES src/Hit.cxx - PUBLIC_LINK_LIBRARIES O2::FDBase + PUBLIC_LINK_LIBRARIES O2::FD3Base O2::SimulationDataFormat O2::CommonDataFormat Microsoft.GSL::GSL O2::DetectorsCommonDataFormats ) -o2_target_root_dictionary(DataFormatsFD - HEADERS include/DataFormatsFD/Hit.h +o2_target_root_dictionary(DataFormatsFD3 + HEADERS include/DataFormatsFD3/Hit.h ) diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h b/DataFormats/Detectors/Upgrades/ALICE3/FD3/include/DataFormatsFD3/Hit.h similarity index 94% rename from DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h rename to DataFormats/Detectors/Upgrades/ALICE3/FD3/include/DataFormatsFD3/Hit.h index fc23ca71cbb9b..4fde2f6cde6b4 100644 --- a/DataFormats/Detectors/Upgrades/ALICE3/FD/include/DataFormatsFD/Hit.h +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD3/include/DataFormatsFD3/Hit.h @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. /// \file Hit.h -/// \brief Definition of the FD Hit class (based on ITSMFT and FV0) +/// \brief Definition of the FD3 Hit class (based on ITSMFT and FV0) #ifndef ALICEO2_FVD_HIT_H_ #define ALICEO2_FVD_HIT_H_ @@ -23,7 +23,7 @@ namespace o2 { -namespace fd +namespace fd3 { class Hit : public o2::BasicXYZEHit @@ -109,17 +109,17 @@ Hit::Hit(int trackID, { } -} // namespace fd +} // namespace fd3 } // namespace o2 #ifdef USESHM namespace std { template <> -class allocator : public o2::utils::ShmAllocator +class allocator : public o2::utils::ShmAllocator { }; } // namespace std #endif /* USESHM */ -#endif /* ALICEO2_FD_HIT_H_ */ +#endif /* ALICEO2_FD3_HIT_H_ */ diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/src/DataFormatsFDLinkDef.h b/DataFormats/Detectors/Upgrades/ALICE3/FD3/src/DataFormatsFD3LinkDef.h similarity index 88% rename from DataFormats/Detectors/Upgrades/ALICE3/FD/src/DataFormatsFDLinkDef.h rename to DataFormats/Detectors/Upgrades/ALICE3/FD3/src/DataFormatsFD3LinkDef.h index f8000bbffe606..1014b3d8c704e 100644 --- a/DataFormats/Detectors/Upgrades/ALICE3/FD/src/DataFormatsFDLinkDef.h +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD3/src/DataFormatsFD3LinkDef.h @@ -15,7 +15,7 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class o2::fd::Hit + ; -#pragma link C++ class vector < o2::fd::Hit> + ; +#pragma link C++ class o2::fd3::Hit + ; +#pragma link C++ class vector < o2::fd3::Hit> + ; #endif diff --git a/DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx b/DataFormats/Detectors/Upgrades/ALICE3/FD3/src/Hit.cxx similarity index 91% rename from DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx rename to DataFormats/Detectors/Upgrades/ALICE3/FD3/src/Hit.cxx index bfbf396393af7..403a3402bd30c 100644 --- a/DataFormats/Detectors/Upgrades/ALICE3/FD/src/Hit.cxx +++ b/DataFormats/Detectors/Upgrades/ALICE3/FD3/src/Hit.cxx @@ -12,14 +12,14 @@ /// \file Hit.cxx /// \brief Implementation of the Hit class -#include "DataFormatsFD/Hit.h" +#include "DataFormatsFD3/Hit.h" #include -ClassImp(o2::fd::Hit); +ClassImp(o2::fd3::Hit); namespace o2 { -namespace fd +namespace fd3 { void Hit::Print(const Option_t* opt) const @@ -31,5 +31,5 @@ void Hit::Print(const Option_t* opt) const GetStartX(), GetStartY(), GetStartZ(), GetX(), GetY(), GetZ()); } -} // namespace fd +} // namespace fd3 } // namespace o2 diff --git a/Detectors/Upgrades/ALICE3/CMakeLists.txt b/Detectors/Upgrades/ALICE3/CMakeLists.txt index 0cd027e9bf8e0..0335e85007c01 100644 --- a/Detectors/Upgrades/ALICE3/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/CMakeLists.txt @@ -12,7 +12,7 @@ add_subdirectory(Passive) add_subdirectory(TRK) add_subdirectory(ECal) -add_subdirectory(FD) +add_subdirectory(FD3) add_subdirectory(FT3) add_subdirectory(FCT) add_subdirectory(AOD) diff --git a/Detectors/Upgrades/ALICE3/FD/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD3/CMakeLists.txt similarity index 100% rename from Detectors/Upgrades/ALICE3/FD/CMakeLists.txt rename to Detectors/Upgrades/ALICE3/FD3/CMakeLists.txt diff --git a/Detectors/Upgrades/ALICE3/FD/README.md b/Detectors/Upgrades/ALICE3/FD3/README.md similarity index 68% rename from Detectors/Upgrades/ALICE3/FD/README.md rename to Detectors/Upgrades/ALICE3/FD3/README.md index fc0fff8b93a4a..54c1fd37b2590 100644 --- a/Detectors/Upgrades/ALICE3/FD/README.md +++ b/Detectors/Upgrades/ALICE3/FD3/README.md @@ -4,7 +4,7 @@ # ALICE 3 FORWARD DETECTOR -This is top page for the FD detector documentation. +This is top page for the FD3 detector documentation. diff --git a/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD3/base/CMakeLists.txt similarity index 73% rename from Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt rename to Detectors/Upgrades/ALICE3/FD3/base/CMakeLists.txt index f0f6f067f48d8..c76665da1344f 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD3/base/CMakeLists.txt @@ -9,12 +9,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2_add_library(FDBase +o2_add_library(FD3Base SOURCES src/GeometryTGeo.cxx - src/FDBaseParam.cxx + src/FD3BaseParam.cxx PUBLIC_LINK_LIBRARIES O2::DetectorsBase) -o2_target_root_dictionary(FDBase - HEADERS include/FDBase/GeometryTGeo.h - include/FDBase/Constants.h - include/FDBase/FDBaseParam.h) +o2_target_root_dictionary(FD3Base + HEADERS include/FD3Base/GeometryTGeo.h + include/FD3Base/Constants.h + include/FD3Base/FD3BaseParam.h) diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h b/Detectors/Upgrades/ALICE3/FD3/base/include/FD3Base/Constants.h similarity index 91% rename from Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h rename to Detectors/Upgrades/ALICE3/FD3/base/include/FD3Base/Constants.h index 687fa52143039..428a7a1f6d179 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/Constants.h +++ b/Detectors/Upgrades/ALICE3/FD3/base/include/FD3Base/Constants.h @@ -14,12 +14,12 @@ /// /// \author Maciej Slupecki, University of Jyvaskyla, Finland -#ifndef ALICEO2_FD_CONSTANTS_ -#define ALICEO2_FD_CONSTANTS_ +#ifndef ALICEO2_FD3_CONSTANTS_ +#define ALICEO2_FD3_CONSTANTS_ namespace o2 { -namespace fd +namespace fd3 { struct Constants { static constexpr unsigned int nsect = 8; @@ -33,6 +33,6 @@ struct Constants { static constexpr float etaMinA_withMG = 5.0f; }; -} // namespace fd +} // namespace fd3 } // namespace o2 #endif diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h b/Detectors/Upgrades/ALICE3/FD3/base/include/FD3Base/FD3BaseParam.h similarity index 75% rename from Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h rename to Detectors/Upgrades/ALICE3/FD3/base/include/FD3Base/FD3BaseParam.h index f8f472fc2ea08..9836cebbfa760 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/FDBaseParam.h +++ b/Detectors/Upgrades/ALICE3/FD3/base/include/FD3Base/FD3BaseParam.h @@ -9,18 +9,18 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#ifndef ALICEO2_FD_FDBASEPARAM_ -#define ALICEO2_FD_FDBASEPARAM_ +#ifndef ALICEO2_FD3_FD3BASEPARAM_ +#define ALICEO2_FD3_FD3BASEPARAM_ -#include "FDBase/GeometryTGeo.h" -#include "FDBase/Constants.h" +#include "FD3Base/GeometryTGeo.h" +#include "FD3Base/Constants.h" #include "CommonUtils/ConfigurableParamHelper.h" namespace o2 { -namespace fd +namespace fd3 { -struct FDBaseParam : public o2::conf::ConfigurableParamHelper { +struct FD3BaseParam : public o2::conf::ConfigurableParamHelper { float zmodA = 1700.0f; float zmodC = -1850.0f; @@ -32,10 +32,10 @@ struct FDBaseParam : public o2::conf::ConfigurableParamHelper { bool fullContainer = false; float dzplate = 1.0f; // Aluminium plate width - O2ParamDef(FDBaseParam, "FDBase"); + O2ParamDef(FD3BaseParam, "FD3Base"); }; -} // namespace fd +} // namespace fd3 } // namespace o2 #endif diff --git a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h b/Detectors/Upgrades/ALICE3/FD3/base/include/FD3Base/GeometryTGeo.h similarity index 85% rename from Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h rename to Detectors/Upgrades/ALICE3/FD3/base/include/FD3Base/GeometryTGeo.h index 1c39e01b43f2e..0e38bd4ccd21f 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/include/FDBase/GeometryTGeo.h +++ b/Detectors/Upgrades/ALICE3/FD3/base/include/FD3Base/GeometryTGeo.h @@ -8,8 +8,8 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#ifndef ALICEO2_FD_GEOMETRYTGEO_H_ -#define ALICEO2_FD_GEOMETRYTGEO_H_ +#ifndef ALICEO2_FD3_GEOMETRYTGEO_H_ +#define ALICEO2_FD3_GEOMETRYTGEO_H_ #include @@ -25,10 +25,10 @@ namespace o2 { -namespace fd +namespace fd3 { -/// FD Geometry type +/// FD3 Geometry type class GeometryTGeo : public o2::detectors::DetMatrixCache { public: @@ -42,13 +42,13 @@ class GeometryTGeo : public o2::detectors::DetMatrixCache void getGlobalPosition(float& x, float& y, float& z); - static constexpr o2::detectors::DetID::ID getDetID() { return o2::detectors::DetID::FD; } + static constexpr o2::detectors::DetID::ID getDetID() { return o2::detectors::DetID::FD3; } private: - static std::unique_ptr sInstance; + static std::unique_ptr sInstance; ClassDefNV(GeometryTGeo, 1); }; -} // namespace fd +} // namespace fd3 } // namespace o2 #endif diff --git a/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h b/Detectors/Upgrades/ALICE3/FD3/base/src/FD3BaseLinkDef.h similarity index 81% rename from Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h rename to Detectors/Upgrades/ALICE3/FD3/base/src/FD3BaseLinkDef.h index 208667adbf818..8475ef2c77313 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseLinkDef.h +++ b/Detectors/Upgrades/ALICE3/FD3/base/src/FD3BaseLinkDef.h @@ -15,9 +15,9 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class o2::fd::Constants + ; -#pragma link C++ class o2::fd::GeometryTGeo + ; -#pragma link C++ class o2::fd::FDBaseParam + ; -#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::fd::FDBaseParam> + ; +#pragma link C++ class o2::fd3::Constants + ; +#pragma link C++ class o2::fd3::GeometryTGeo + ; +#pragma link C++ class o2::fd3::FD3BaseParam + ; +#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::fd3::FD3BaseParam> + ; #endif diff --git a/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx b/Detectors/Upgrades/ALICE3/FD3/base/src/FD3BaseParam.cxx similarity index 88% rename from Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx rename to Detectors/Upgrades/ALICE3/FD3/base/src/FD3BaseParam.cxx index 576e76b7b796c..74b45962b3f39 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/src/FDBaseParam.cxx +++ b/Detectors/Upgrades/ALICE3/FD3/base/src/FD3BaseParam.cxx @@ -9,6 +9,6 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include "FDBase/FDBaseParam.h" +#include "FD3Base/FD3BaseParam.h" -O2ParamImpl(o2::fd::FDBaseParam); +O2ParamImpl(o2::fd3::FD3BaseParam); diff --git a/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx b/Detectors/Upgrades/ALICE3/FD3/base/src/GeometryTGeo.cxx similarity index 81% rename from Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx rename to Detectors/Upgrades/ALICE3/FD3/base/src/GeometryTGeo.cxx index 69c40fd42b876..16788cb8944e3 100644 --- a/Detectors/Upgrades/ALICE3/FD/base/src/GeometryTGeo.cxx +++ b/Detectors/Upgrades/ALICE3/FD3/base/src/GeometryTGeo.cxx @@ -9,25 +9,25 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include "FDBase/GeometryTGeo.h" -#include "FDBase/FDBaseParam.h" +#include "FD3Base/GeometryTGeo.h" +#include "FD3Base/FD3BaseParam.h" #include #include -using namespace o2::fd; +using namespace o2::fd3; namespace o2 { -namespace fd +namespace fd3 { -std::unique_ptr GeometryTGeo::sInstance; +std::unique_ptr GeometryTGeo::sInstance; GeometryTGeo::GeometryTGeo(bool build, int loadTrans) : DetMatrixCache() { if (sInstance) { - LOGP(fatal, "Invalid use of public constructor: o2::fd::GeometryTGeo instance exists"); + LOGP(fatal, "Invalid use of public constructor: o2::fd3::GeometryTGeo instance exists"); } if (build) { Build(loadTrans); @@ -62,5 +62,5 @@ void GeometryTGeo::fillMatrixCache(int mask) { } -} // namespace fd +} // namespace fd3 } // namespace o2 diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt b/Detectors/Upgrades/ALICE3/FD3/simulation/CMakeLists.txt similarity index 72% rename from Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt rename to Detectors/Upgrades/ALICE3/FD3/simulation/CMakeLists.txt index 2d2793b64105d..38886ec5fbe07 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/FD3/simulation/CMakeLists.txt @@ -9,11 +9,11 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2_add_library(FDSimulation +o2_add_library(FD3Simulation SOURCES src/Detector.cxx - PUBLIC_LINK_LIBRARIES O2::FDBase - O2::DataFormatsFD + PUBLIC_LINK_LIBRARIES O2::FD3Base + O2::DataFormatsFD3 ROOT::Physics) -o2_target_root_dictionary(FDSimulation - HEADERS include/FDSimulation/Detector.h) +o2_target_root_dictionary(FD3Simulation + HEADERS include/FD3Simulation/Detector.h) diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h b/Detectors/Upgrades/ALICE3/FD3/simulation/include/FD3Simulation/Detector.h similarity index 82% rename from Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h rename to Detectors/Upgrades/ALICE3/FD3/simulation/include/FD3Simulation/Detector.h index f32b2b531017e..2d17acbd4a0e8 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/include/FDSimulation/Detector.h +++ b/Detectors/Upgrades/ALICE3/FD3/simulation/include/FD3Simulation/Detector.h @@ -12,14 +12,14 @@ /// \file Detector.h /// \brief Definition of the Detector class -#ifndef ALICEO2_FD_DETECTOR_H_ -#define ALICEO2_FD_DETECTOR_H_ +#ifndef ALICEO2_FD3_DETECTOR_H_ +#define ALICEO2_FD3_DETECTOR_H_ #include "SimulationDataFormat/BaseHits.h" #include "DetectorsBase/Detector.h" -#include "FDBase/GeometryTGeo.h" -#include "FDBase/FDBaseParam.h" -#include "DataFormatsFD/Hit.h" +#include "FD3Base/GeometryTGeo.h" +#include "FD3Base/FD3BaseParam.h" +#include "DataFormatsFD3/Hit.h" #include "Rtypes.h" #include "TGeoManager.h" #include "TLorentzVector.h" @@ -31,7 +31,7 @@ class TGeoVolume; namespace o2 { -namespace fd +namespace fd3 { class GeometryTGeo; } @@ -39,7 +39,7 @@ class GeometryTGeo; namespace o2 { -namespace fd +namespace fd3 { class Detector : public o2::base::DetImpl @@ -54,15 +54,15 @@ class Detector : public o2::base::DetImpl void ConstructGeometry() override; /// This method is an example of how to add your own point of type Hit to the clones array - o2::fd::Hit* addHit(int trackId, unsigned int detId, - const math_utils::Point3D& startPos, - const math_utils::Point3D& endPos, - const math_utils::Vector3D& startMom, double startE, - double endTime, double eLoss, int particlePdg); + o2::fd3::Hit* addHit(int trackId, unsigned int detId, + const math_utils::Point3D& startPos, + const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, double startE, + double endTime, double eLoss, int particlePdg); // unsigned int startStatus, // unsigned int endStatus); - std::vector* getHits(Int_t iColl) + std::vector* getHits(Int_t iColl) { if (iColl == 0) { return mHits; @@ -93,7 +93,7 @@ class Detector : public o2::base::DetImpl Detector(const Detector&); Detector& operator=(const Detector&); - std::vector* mHits = nullptr; + std::vector* mHits = nullptr; GeometryTGeo* mGeometryTGeo = nullptr; TGeoVolumeAssembly* buildModuleA(); @@ -132,7 +132,7 @@ class Detector : public o2::base::DetImpl std::ostream& operator<<(std::ostream& os, Detector& source); std::istream& operator>>(std::istream& os, Detector& source); -} // namespace fd +} // namespace fd3 } // namespace o2 #ifdef USESHM @@ -141,7 +141,7 @@ namespace o2 namespace base { template <> -struct UseShm { +struct UseShm { static constexpr bool value = true; }; } // namespace base diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx b/Detectors/Upgrades/ALICE3/FD3/simulation/src/Detector.cxx similarity index 74% rename from Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx rename to Detectors/Upgrades/ALICE3/FD3/simulation/src/Detector.cxx index c9fc6c9f4e76b..bd79b1deaad80 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/Detector.cxx +++ b/Detectors/Upgrades/ALICE3/FD3/simulation/src/Detector.cxx @@ -12,11 +12,11 @@ /// \file Detector.cxx /// \brief Implementation of the Detector class -#include "DataFormatsFD/Hit.h" -#include "FDSimulation/Detector.h" -#include "FDBase/GeometryTGeo.h" -#include "FDBase/FDBaseParam.h" -#include "FDBase/Constants.h" +#include "DataFormatsFD3/Hit.h" +#include "FD3Simulation/Detector.h" +#include "FD3Base/GeometryTGeo.h" +#include "FD3Base/FD3BaseParam.h" +#include "FD3Base/Constants.h" #include "DetectorsBase/Stack.h" #include "SimulationDataFormat/TrackReference.h" @@ -47,12 +47,12 @@ class FairModule; class TGeoMedium; -using namespace o2::fd; -using o2::fd::Hit; +using namespace o2::fd3; +using o2::fd3::Hit; Detector::Detector(bool active) - : o2::base::DetImpl("FD", true), - mHits(o2::utils::createSimVector()), + : o2::base::DetImpl("FD3", true), + mHits(o2::utils::createSimVector()), mGeometryTGeo(nullptr), mTrackData() { @@ -64,7 +64,7 @@ Detector::Detector(bool active) mEtaMinC = -Constants::etaMax; mEtaMaxC = -Constants::etaMin; - auto& baseParam = FDBaseParam::Instance(); + auto& baseParam = FD3BaseParam::Instance(); if (baseParam.withMG) { mNumberOfRingsA = Constants::nringsA_withMG; @@ -99,7 +99,7 @@ Detector::Detector(bool active) Detector::Detector(const Detector& rhs) : o2::base::DetImpl(rhs), mTrackData(), - mHits(o2::utils::createSimVector()) + mHits(o2::utils::createSimVector()) { } @@ -188,14 +188,14 @@ bool Detector::ProcessHits(FairVolume* vol) return true; } -o2::fd::Hit* Detector::addHit(int trackId, unsigned int detId, - const math_utils::Point3D& startPos, - const math_utils::Point3D& endPos, - const math_utils::Vector3D& startMom, - double startE, - double endTime, - double eLoss, - int particlePdg) +o2::fd3::Hit* Detector::addHit(int trackId, unsigned int detId, + const math_utils::Point3D& startPos, + const math_utils::Point3D& endPos, + const math_utils::Vector3D& startMom, + double startE, + double endTime, + double eLoss, + int particlePdg) { mHits->emplace_back(trackId, detId, startPos, endPos, startMom, startE, endTime, eLoss, particlePdg); @@ -255,26 +255,26 @@ void Detector::createMaterials() int fieldType = 3; // Field type float maxField = 5.0; // Field max. - float tmaxfd = -10.0; // max deflection angle due to magnetic field in one step - float stemax = 0.1; // max step allowed [cm] - float deemax = 1.0; // maximum fractional energy loss in one step 0GetVolume("cave"); @@ -282,38 +282,39 @@ void Detector::buildModules() LOG(fatal) << "Could not find the top volume!"; } - TGeoVolumeAssembly* vFDA = buildModuleA(); - TGeoVolumeAssembly* vFDC = buildModuleC(); + TGeoVolumeAssembly* vFD3A = buildModuleA(); + TGeoVolumeAssembly* vFD3C = buildModuleC(); - vCave->AddNode(vFDA, 1, new TGeoTranslation(0., 0., mZA)); - vCave->AddNode(vFDC, 2, new TGeoTranslation(0., 0., mZC)); + vCave->AddNode(vFD3A, 1, new TGeoTranslation(0., 0., mZA)); + vCave->AddNode(vFD3C, 2, new TGeoTranslation(0., 0., mZC)); } TGeoVolumeAssembly* Detector::buildModuleA() { - TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FDA"); + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FD3A"); - const TGeoMedium* medium = gGeoManager->GetMedium("FD_Scintillator"); + const TGeoMedium* medium = gGeoManager->GetMedium("FD3_Scintillator"); float dphiDeg = 360. / mNumberOfSectors; for (int ir = 0; ir < mNumberOfRingsA; ir++) { - std::string rName = "fd_ring" + std::to_string(ir + 1); + std::string rName = "fd3_ring" + std::to_string(ir + 1); TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); float rmin = mRingSizesA[ir]; float rmax = mRingSizesA[ir + 1]; LOG(info) << "ring" << ir << ": from " << rmin << " to " << rmax; for (int ic = 0; ic < mNumberOfSectors; ic++) { int cellId = ic + mNumberOfSectors * ir; - std::string nodeName = "fd_node" + std::to_string(cellId); + std::string nodeName = "fd3_node" + std::to_string(cellId); float phimin = dphiDeg * ic; float phimax = dphiDeg * (ic + 1); auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - if ((ir + ic) % 2 == 0) - nod->SetLineColor(kRed); - else - nod->SetLineColor(kRed - 7); + if ((ir + ic) % 2 == 0) { + nod->SetLineColor(kRed); + } else { + nod->SetLineColor(kRed - 7); + } ring->AddNode(nod, cellId); } mod->AddNode(ring, ir + 1); @@ -322,14 +323,14 @@ TGeoVolumeAssembly* Detector::buildModuleA() // Aluminium plates on one or both sides of the A side module if (mPlateBehindA || mFullContainer) { LOG(info) << "adding container on A side"; - auto pmed = (TGeoMedium*)gGeoManager->GetMedium("FD_Aluminium"); - auto pvol = new TGeoTube("pvol_fda", mRingSizesA[0], mRingSizesA[mNumberOfRingsA], mDzPlate); - auto pnod1 = new TGeoVolume("pnod1_FDA", pvol, pmed); + auto pmed = (TGeoMedium*)gGeoManager->GetMedium("FD3_Aluminium"); + auto pvol = new TGeoTube("pvol_fd3a", mRingSizesA[0], mRingSizesA[mNumberOfRingsA], mDzPlate); + auto pnod1 = new TGeoVolume("pnod1_FD3A", pvol, pmed); double dpz = 2. + mDzPlate / 2; mod->AddNode(pnod1, 1, new TGeoTranslation(0, 0, dpz)); if (mFullContainer) { - auto pnod2 = new TGeoVolume("pnod2_FDA", pvol, pmed); + auto pnod2 = new TGeoVolume("pnod2_FD3A", pvol, pmed); mod->AddNode(pnod2, 1, new TGeoTranslation(0, 0, -dpz)); } } @@ -338,29 +339,30 @@ TGeoVolumeAssembly* Detector::buildModuleA() TGeoVolumeAssembly* Detector::buildModuleC() { - TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FDC"); + TGeoVolumeAssembly* mod = new TGeoVolumeAssembly("FD3C"); - const TGeoMedium* medium = gGeoManager->GetMedium("FD_Scintillator"); + const TGeoMedium* medium = gGeoManager->GetMedium("FD3_Scintillator"); float dphiDeg = 360. / mNumberOfSectors; for (int ir = 0; ir < mNumberOfRingsC; ir++) { - std::string rName = "fd_ring" + std::to_string(ir + 1 + mNumberOfRingsA); + std::string rName = "fd3_ring" + std::to_string(ir + 1 + mNumberOfRingsA); TGeoVolumeAssembly* ring = new TGeoVolumeAssembly(rName.c_str()); float rmin = mRingSizesC[ir]; float rmax = mRingSizesC[ir + 1]; LOG(info) << "ring" << ir + mNumberOfRingsA << ": from " << rmin << " to " << rmax; for (int ic = 0; ic < mNumberOfSectors; ic++) { int cellId = ic + mNumberOfSectors * (ir + mNumberOfRingsA); - std::string nodeName = "fd_node" + std::to_string(cellId); + std::string nodeName = "fd3_node" + std::to_string(cellId); float phimin = dphiDeg * ic; float phimax = dphiDeg * (ic + 1); auto tbs = new TGeoTubeSeg("tbs", rmin, rmax, mDzScint, phimin, phimax); auto nod = new TGeoVolume(nodeName.c_str(), tbs, medium); - if ((ir + ic) % 2 == 0) - nod->SetLineColor(kBlue); - else - nod->SetLineColor(kBlue - 7); + if ((ir + ic) % 2 == 0) { + nod->SetLineColor(kBlue); + } else { + nod->SetLineColor(kBlue - 7); + } ring->AddNode(nod, cellId); } mod->AddNode(ring, ir + 1); @@ -369,10 +371,10 @@ TGeoVolumeAssembly* Detector::buildModuleC() // Aluminium plates on both sides of the C side module if (mFullContainer) { LOG(info) << "adding container on C side"; - auto pmed = (TGeoMedium*)gGeoManager->GetMedium("FD_Aluminium"); - auto pvol = new TGeoTube("pvol_fdc", mRingSizesC[0], mRingSizesC[mNumberOfRingsC], mDzPlate); - auto pnod1 = new TGeoVolume("pnod1_FDC", pvol, pmed); - auto pnod2 = new TGeoVolume("pnod2_FDC", pvol, pmed); + auto pmed = (TGeoMedium*)gGeoManager->GetMedium("FD3_Aluminium"); + auto pvol = new TGeoTube("pvol_fd3c", mRingSizesC[0], mRingSizesC[mNumberOfRingsC], mDzPlate); + auto pnod1 = new TGeoVolume("pnod1_FD3C", pvol, pmed); + auto pnod2 = new TGeoVolume("pnod2_FD3C", pvol, pmed); double dpz = mDzScint / 2 + mDzPlate / 2; mod->AddNode(pnod1, 1, new TGeoTranslation(0, 0, dpz)); @@ -384,7 +386,7 @@ TGeoVolumeAssembly* Detector::buildModuleC() void Detector::defineSensitiveVolumes() { - LOG(info) << "Adding FD Sentitive Volumes"; + LOG(info) << "Adding FD3 Sentitive Volumes"; TGeoVolume* v; TString volumeName; @@ -396,7 +398,7 @@ void Detector::defineSensitiveVolumes() LOG(info) << "number of C rings = " << mNumberOfRingsC << " number of cells = " << nCellsC; for (int iv = 0; iv < nCellsA + nCellsC; iv++) { - volumeName = "fd_node" + std::to_string(iv); + volumeName = "fd3_node" + std::to_string(iv); v = gGeoManager->GetVolume(volumeName); LOG(info) << "Adding sensitive volume => " << v->GetName(); AddSensitiveVolume(v); @@ -408,4 +410,4 @@ float Detector::ringSize(float z, float eta) return z * TMath::Tan(2 * TMath::ATan(TMath::Exp(-eta))); } -ClassImp(o2::fd::Detector); +ClassImp(o2::fd3::Detector); diff --git a/Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h b/Detectors/Upgrades/ALICE3/FD3/simulation/src/FD3SimulationLinkDef.h similarity index 85% rename from Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h rename to Detectors/Upgrades/ALICE3/FD3/simulation/src/FD3SimulationLinkDef.h index 3071b7811b154..83df03490ebd7 100644 --- a/Detectors/Upgrades/ALICE3/FD/simulation/src/FDSimulationLinkDef.h +++ b/Detectors/Upgrades/ALICE3/FD3/simulation/src/FD3SimulationLinkDef.h @@ -15,7 +15,7 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class o2::fd::Detector + ; -#pragma link C++ class o2::base::DetImpl < o2::fd::Detector> + ; +#pragma link C++ class o2::fd3::Detector + ; +#pragma link C++ class o2::base::DetImpl < o2::fd3::Detector> + ; #endif diff --git a/macro/build_geometry.C b/macro/build_geometry.C index 626476630ea9a..6b13f2eac2766 100644 --- a/macro/build_geometry.C +++ b/macro/build_geometry.C @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include #include #include @@ -265,9 +265,9 @@ void build_geometry(FairRunSim* run = nullptr) addReadoutDetector(new o2::ecal::Detector(isReadout("ECL"))); } - if (isActivated("FD")) { - // ALICE3 FD - addReadoutDetector(new o2::fd::Detector(isReadout("FD"))); + if (isActivated("FD3")) { + // ALICE3 FD3 + addReadoutDetector(new o2::fd3::Detector(isReadout("FD3"))); } if (isActivated("MI3")) { diff --git a/run/CMakeLists.txt b/run/CMakeLists.txt index ee24844ce6723..de05192f92430 100644 --- a/run/CMakeLists.txt +++ b/run/CMakeLists.txt @@ -46,7 +46,7 @@ target_link_libraries(allsim $<$:O2::IOTOFSimulation> $<$:O2::RICHSimulation> $<$:O2::ECalSimulation> - $<$:O2::FDSimulation> + $<$:O2::FD3Simulation> $<$:O2::MI3Simulation> O2::Generators) diff --git a/run/O2HitMerger.h b/run/O2HitMerger.h index 217c852293137..d32f6370ca2db 100644 --- a/run/O2HitMerger.h +++ b/run/O2HitMerger.h @@ -78,7 +78,7 @@ #include #include #include -#include +#include #endif #include @@ -1010,8 +1010,8 @@ void O2HitMerger::initDetInstances() mDetectorInstances[i] = std::move(std::make_unique(true)); counter++; } - if (i == DetID::FD) { - mDetectorInstances[i] = std::move(std::make_unique(true)); + if (i == DetID::FD3) { + mDetectorInstances[i] = std::move(std::make_unique(true)); counter++; } #endif diff --git a/run/o2simdefaultdetectorlist.json b/run/o2simdefaultdetectorlist.json index e8f51a2211c5c..2a7e977be741d 100644 --- a/run/o2simdefaultdetectorlist.json +++ b/run/o2simdefaultdetectorlist.json @@ -58,7 +58,7 @@ "RCH", "MI3", "ECL", - "FD", + "FD3", "HALL", "MAG", "A3IP", From 5959ee96c96b4fb49c4a1ffc017d695885eabcea Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 9 Oct 2025 07:36:19 +0200 Subject: [PATCH 65/68] change detector name --- .../Common/include/DetectorsCommonDataFormats/DetID.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h index 25a1669942107..2d2383783cfc3 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h @@ -87,8 +87,8 @@ class DetID static constexpr ID RCH = 23; static constexpr ID MI3 = 24; static constexpr ID ECL = 25; - static constexpr ID FD = 26; - static constexpr ID Last = FD; + static constexpr ID FD3 = 26; + static constexpr ID Last = FD3; #else static constexpr ID Last = FOC; ///< if extra detectors added, update this !!! #endif @@ -182,7 +182,7 @@ class DetID // detector names, will be defined in DataSources static constexpr const char* sDetNames[nDetectors + 1] = ///< defined detector names #ifdef ENABLE_UPGRADES - {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD", nullptr}; + {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", "IT3", "TRK", "FT3", "FCT", "TF3", "RCH", "MI3", "ECL", "FD3", nullptr}; #else {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "TST", "CTP", "FOC", nullptr}; #endif @@ -196,7 +196,7 @@ class DetID #ifdef ENABLE_UPGRADES , o2h::gDataOriginIT3, o2h::gDataOriginTRK, o2h::gDataOriginFT3, o2h::gDataOriginFCT, o2h::gDataOriginTF3, - o2h::gDataOriginRCH, o2h::gDataOriginMI3, o2h::gDataOriginECL, o2h::gDataOriginFD + o2h::gDataOriginRCH, o2h::gDataOriginMI3, o2h::gDataOriginECL, o2h::gDataOriginFD3 #endif }; #endif // GPUCA_GPUCODE_DEVICE @@ -216,7 +216,7 @@ GPUconstexpr() DetID::mask_t sMasks[DetID::nDetectors] = ///< detectot masks #ifdef ENABLE_UPGRADES , DetID::mask_t(math_utils::bit2Mask(DetID::IT3)), DetID::mask_t(math_utils::bit2Mask(DetID::TRK)), DetID::mask_t(math_utils::bit2Mask(DetID::FT3)), DetID::mask_t(math_utils::bit2Mask(DetID::FCT)), DetID::mask_t(math_utils::bit2Mask(DetID::TF3)), - DetID::mask_t(math_utils::bit2Mask(DetID::RCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MI3)), DetID::mask_t(math_utils::bit2Mask(DetID::ECL)), DetID::mask_t(math_utils::bit2Mask(DetID::FD)) + DetID::mask_t(math_utils::bit2Mask(DetID::RCH)), DetID::mask_t(math_utils::bit2Mask(DetID::MI3)), DetID::mask_t(math_utils::bit2Mask(DetID::ECL)), DetID::mask_t(math_utils::bit2Mask(DetID::FD3)) #endif }; } // namespace detid_internal From c94250733a589428052ab4d348c1d3f17492c8a3 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 9 Oct 2025 16:52:46 +0200 Subject: [PATCH 66/68] change detector name --- DataFormats/Headers/include/Headers/DataHeader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/Headers/include/Headers/DataHeader.h b/DataFormats/Headers/include/Headers/DataHeader.h index a2cb772df422f..fbab21c3ccf6f 100644 --- a/DataFormats/Headers/include/Headers/DataHeader.h +++ b/DataFormats/Headers/include/Headers/DataHeader.h @@ -588,7 +588,7 @@ constexpr o2::header::DataOrigin gDataOriginTF3{"TF3"}; constexpr o2::header::DataOrigin gDataOriginRCH{"RCH"}; constexpr o2::header::DataOrigin gDataOriginMI3{"MI3"}; constexpr o2::header::DataOrigin gDataOriginECL{"ECL"}; // upgrades -constexpr o2::header::DataOrigin gDataOriginFD{"FD"}; // upgrades +constexpr o2::header::DataOrigin gDataOriginFD3{"FD3"}; // upgrades constexpr o2::header::DataOrigin gDataOriginGPU{"GPU"}; From 9fe5eff710f31e20ef43c77b6371f18feee72dd5 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 9 Oct 2025 17:56:20 +0200 Subject: [PATCH 67/68] change detector name --- DataFormats/Headers/include/Headers/DataHeader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/Headers/include/Headers/DataHeader.h b/DataFormats/Headers/include/Headers/DataHeader.h index fbab21c3ccf6f..b44f41c5d3cb3 100644 --- a/DataFormats/Headers/include/Headers/DataHeader.h +++ b/DataFormats/Headers/include/Headers/DataHeader.h @@ -588,7 +588,7 @@ constexpr o2::header::DataOrigin gDataOriginTF3{"TF3"}; constexpr o2::header::DataOrigin gDataOriginRCH{"RCH"}; constexpr o2::header::DataOrigin gDataOriginMI3{"MI3"}; constexpr o2::header::DataOrigin gDataOriginECL{"ECL"}; // upgrades -constexpr o2::header::DataOrigin gDataOriginFD3{"FD3"}; // upgrades +constexpr o2::header::DataOrigin gDataOriginFD3{"FD3"}; // upgrades constexpr o2::header::DataOrigin gDataOriginGPU{"GPU"}; From d893b69a6785ab72fb74766f9dd28f31e34b9c45 Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Thu, 16 Oct 2025 22:37:10 +0200 Subject: [PATCH 68/68] Fix formatting in CMakeLists.txt for FD3Simulation --- run/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/CMakeLists.txt b/run/CMakeLists.txt index de05192f92430..474aa7e41eb7c 100644 --- a/run/CMakeLists.txt +++ b/run/CMakeLists.txt @@ -46,7 +46,7 @@ target_link_libraries(allsim $<$:O2::IOTOFSimulation> $<$:O2::RICHSimulation> $<$:O2::ECalSimulation> - $<$:O2::FD3Simulation> + $<$:O2::FD3Simulation> $<$:O2::MI3Simulation> O2::Generators)