From 14819229bf8963b3eb9d77ebe3fd4d8d45fe880a Mon Sep 17 00:00:00 2001 From: Podist Kurashvili Date: Mon, 2 Sep 2024 21:25:53 +0200 Subject: [PATCH 01/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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.