From 739e4943237ea5f9ccbc376838afe9441f30455f Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Thu, 10 Aug 2023 17:32:37 +0200 Subject: [PATCH 01/19] Add Parallel world in ITS aligner --- .../Detectors/Common/src/AlignParam.cxx | 18 +++++++++++++++++- .../include/DetectorsBase/GeometryManager.h | 8 ++++---- Detectors/Base/src/Aligner.cxx | 5 +++++ Detectors/Base/src/GeometryManager.cxx | 11 ++++++----- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/DataFormats/Detectors/Common/src/AlignParam.cxx b/DataFormats/Detectors/Common/src/AlignParam.cxx index 90f2a349607a1..3124ac0833e6e 100644 --- a/DataFormats/Detectors/Common/src/AlignParam.cxx +++ b/DataFormats/Detectors/Common/src/AlignParam.cxx @@ -17,11 +17,21 @@ #include #include #include +#include #include "DetectorsCommonDataFormats/AlignParam.h" using namespace o2::detectors; +std::string getDetFromSymName(const std::string& input) +{ + size_t pos = input.find("/"); // Detector name is before the first slash + if (pos != std::string::npos) { + return input.substr(0, pos); + } + return input; +} + //___________________________________________________ AlignParam::AlignParam(const char* symname, int algID, // volume symbolic name and its alignable ID double x, double y, double z, // delta translation @@ -277,6 +287,10 @@ bool AlignParam::applyToGeometry() const const char* symname = getSymName().c_str(); const char* path; TGeoPhysicalNode* node; + TGeoParallelWorld* pw = nullptr; + if (getDetFromSymName(getSymName()) == "ITS") { + pw = gGeoManager->GetParallelWorld(); + } TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname); if (pne) { path = pne->GetTitle(); @@ -314,7 +328,9 @@ bool AlignParam::applyToGeometry() const LOG(debug) << "Aligning volume " << symname; node->Align(ginv); - + if (getDetFromSymName(getSymName()) == "ITS") { + pw->AddNode(path); + } return true; } diff --git a/Detectors/Base/include/DetectorsBase/GeometryManager.h b/Detectors/Base/include/DetectorsBase/GeometryManager.h index 96998187cca63..e2d0f56ef2658 100644 --- a/Detectors/Base/include/DetectorsBase/GeometryManager.h +++ b/Detectors/Base/include/DetectorsBase/GeometryManager.h @@ -15,7 +15,7 @@ #ifndef ALICEO2_BASE_GEOMETRYMANAGER_H_ #define ALICEO2_BASE_GEOMETRYMANAGER_H_ -#include // for TGeoManager +#include // for TGeoManager #include #include // for TGeoPNEntry #include @@ -86,8 +86,7 @@ class GeometryManager : public TObject double meanZ = 0.; // mean Z: sum(x_i*Z_i)/sum(x_i) [adimensional] double meanZ2A = 0.; // Z/A mean: sum(x_i*Z_i/A_i)/sum(x_i) [adimensional] double length = -1.; // length: sum(x_i) [cm] - int nCross = 0; - ; // number of boundary crosses + int nCross = 0; // number of boundary crosses MatBudgetExt() = default; ~MatBudgetExt() = default; @@ -132,11 +131,12 @@ class GeometryManager : public TObject /// detector geometry. The output global matrix is stored in 'm'. /// Returns kFALSE in case TGeo has not been initialized or the volume path is not valid. static Bool_t getOriginalMatrixFromPath(const char* path, TGeoHMatrix& m); + private: /// sensitive volume identifier composed from (det_ID< +#include O2ParamImpl(o2::base::Aligner); @@ -48,6 +49,7 @@ void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const ccdbmgr.setTimestamp(timestamp); DetID::mask_t done, skipped; DetID::mask_t detGeoMask(gGeoManager->GetUniqueID()); + TGeoParallelWorld* pw = gGeoManager->CreateParallelWorld("priority_its_sensor"); for (auto id = DetID::First; id <= DetID::Last; id++) { if (!msk[id] || (detGeoMask.any() && !detGeoMask[id])) { continue; @@ -64,6 +66,9 @@ void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const skipped.set(id); } } + // pw->AddOverlap(gGeoManager->GetVolume("ITSUWrapVol0")); + pw->CloseGeometry(); + gGeoManager->SetUseParallelWorldNav(true); std::string log = fmt::format("Alignment from {} for timestamp {}: ", o2::base::NameConf::getCCDBServer(), timestamp); if (done.any()) { log += fmt::format("applied to [{}]", DetID::getNames(done)); diff --git a/Detectors/Base/src/GeometryManager.cxx b/Detectors/Base/src/GeometryManager.cxx index 885cff7a73588..250d86b3c1340 100644 --- a/Detectors/Base/src/GeometryManager.cxx +++ b/Detectors/Base/src/GeometryManager.cxx @@ -12,12 +12,13 @@ /// \file GeometryManager.cxx /// \brief Implementation of the GeometryManager class -#include // for LOG -#include // for TIter +#include // for LOG +#include // for TIter #include -#include // for TGeoHMatrix -#include // for TGeoNode -#include // for TGeoPhysicalNode, TGeoPNEntry +#include // for TGeoHMatrix +#include // for TGeoNode +#include // for TGeoPhysicalNode, TGeoPNEntry +#include #include #include #include // for NULL From 70a4c6a605e25d0ba6b1fa856bc2d59696402547 Mon Sep 17 00:00:00 2001 From: Mario Ciacco Date: Thu, 4 Apr 2024 00:02:30 +0200 Subject: [PATCH 02/19] toggle parallel world (#82) --- .../DetectorsCommonDataFormats/AlignParam.h | 6 ++-- .../Detectors/Common/src/AlignParam.cxx | 6 ++-- Detectors/Base/CMakeLists.txt | 2 ++ .../DetectorsBase/GeometryManagerParam.h | 29 +++++++++++++++++++ Detectors/Base/src/Aligner.cxx | 15 +++++++--- Detectors/Base/src/DetectorsBaseLinkDef.h | 1 + Detectors/Base/src/GeometryManager.cxx | 11 +++---- Detectors/Base/src/GeometryManagerParam.cxx | 13 +++++++++ .../ITSMFT/ITS/simulation/src/Detector.cxx | 1 + 9 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 Detectors/Base/include/DetectorsBase/GeometryManagerParam.h create mode 100644 Detectors/Base/src/GeometryManagerParam.cxx diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h index 74610264336be..521122d6d762b 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h @@ -52,7 +52,7 @@ class AlignParam double getZ() const { return mZ; } /// apply object to geoemetry - bool applyToGeometry() const; + bool applyToGeometry(bool usePW = false) const; /// extract global delta matrix TGeoHMatrix createMatrix() const; @@ -136,7 +136,7 @@ class AlignParam ClassDefNV(AlignParam, 1); }; -} -} +} // namespace detectors +} // namespace o2 #endif diff --git a/DataFormats/Detectors/Common/src/AlignParam.cxx b/DataFormats/Detectors/Common/src/AlignParam.cxx index 3124ac0833e6e..b31f1c33d8acd 100644 --- a/DataFormats/Detectors/Common/src/AlignParam.cxx +++ b/DataFormats/Detectors/Common/src/AlignParam.cxx @@ -268,7 +268,7 @@ bool AlignParam::createLocalMatrix(TGeoHMatrix& m) const } //_____________________________________________________________________________ -bool AlignParam::applyToGeometry() const +bool AlignParam::applyToGeometry(bool usePW) const { /// Apply the current alignment object to the TGeo geometry /// This method returns FALSE if the symname of the object was not @@ -288,7 +288,7 @@ bool AlignParam::applyToGeometry() const const char* path; TGeoPhysicalNode* node; TGeoParallelWorld* pw = nullptr; - if (getDetFromSymName(getSymName()) == "ITS") { + if (getDetFromSymName(getSymName()) == "ITS" && usePW) { pw = gGeoManager->GetParallelWorld(); } TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname); @@ -328,7 +328,7 @@ bool AlignParam::applyToGeometry() const LOG(debug) << "Aligning volume " << symname; node->Align(ginv); - if (getDetFromSymName(getSymName()) == "ITS") { + if (getDetFromSymName(getSymName()) == "ITS" && usePW) { pw->AddNode(path); } return true; diff --git a/Detectors/Base/CMakeLists.txt b/Detectors/Base/CMakeLists.txt index 491a281325ba8..fe69793c5e144 100644 --- a/Detectors/Base/CMakeLists.txt +++ b/Detectors/Base/CMakeLists.txt @@ -14,6 +14,7 @@ o2_add_library(DetectorsBase src/GeometryManager.cxx src/MaterialManager.cxx src/MaterialManagerParam.cxx + src/GeometryManagerParam.cxx src/Propagator.cxx src/MatLayerCyl.cxx src/MatLayerCylSet.cxx @@ -50,6 +51,7 @@ o2_target_root_dictionary(DetectorsBase include/DetectorsBase/GeometryManager.h include/DetectorsBase/MaterialManager.h include/DetectorsBase/MaterialManagerParam.h + include/DetectorsBase/GeometryManagerParam.h include/DetectorsBase/Propagator.h include/DetectorsBase/Ray.h include/DetectorsBase/MatCell.h diff --git a/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h b/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h new file mode 100644 index 0000000000000..323089983fb4a --- /dev/null +++ b/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h @@ -0,0 +1,29 @@ +// 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 DETECTORS_BASE_INCLUDE_GEOMETRYMANAGERPARAM_H_ +#define DETECTORS_BASE_INCLUDE_GEOMETRYMANAGERPARAM_H_ + +#include "CommonUtils/ConfigurableParam.h" +#include "CommonUtils/ConfigurableParamHelper.h" + +namespace o2 +{ + +struct GeometryManagerParam : public o2::conf::ConfigurableParamHelper { + bool useParallelWorld = false; + + O2ParamDef(GeometryManagerParam, "GeometryManagerParam"); +}; + +} // namespace o2 + +#endif /* DETECTORS_BASE_INCLUDE_GEOMETRYMANAGERPARAM_H_ */ diff --git a/Detectors/Base/src/Aligner.cxx b/Detectors/Base/src/Aligner.cxx index 40b5bf05b6676..b4a255d4f8c6c 100644 --- a/Detectors/Base/src/Aligner.cxx +++ b/Detectors/Base/src/Aligner.cxx @@ -12,6 +12,7 @@ #include "DetectorsBase/Aligner.h" #include "CCDB/BasicCCDBManager.h" #include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/GeometryManagerParam.h" #include "DetectorsCommonDataFormats/AlignParam.h" #include "DetectorsCommonDataFormats/DetectorNameConf.h" #include @@ -49,7 +50,11 @@ void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const ccdbmgr.setTimestamp(timestamp); DetID::mask_t done, skipped; DetID::mask_t detGeoMask(gGeoManager->GetUniqueID()); - TGeoParallelWorld* pw = gGeoManager->CreateParallelWorld("priority_its_sensor"); + auto& pars = GeometryManagerParam::Instance(); + TGeoParallelWorld* pw = nullptr; + if (pars.useParallelWorld) { + pw = gGeoManager->CreateParallelWorld("priority_its_sensor"); + } for (auto id = DetID::First; id <= DetID::Last; id++) { if (!msk[id] || (detGeoMask.any() && !detGeoMask[id])) { continue; @@ -66,9 +71,11 @@ void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const skipped.set(id); } } - // pw->AddOverlap(gGeoManager->GetVolume("ITSUWrapVol0")); - pw->CloseGeometry(); - gGeoManager->SetUseParallelWorldNav(true); + if (pars.useParallelWorld) { + // pw->AddOverlap(gGeoManager->GetVolume("ITSUWrapVol0")); + pw->CloseGeometry(); + gGeoManager->SetUseParallelWorldNav(true); + } std::string log = fmt::format("Alignment from {} for timestamp {}: ", o2::base::NameConf::getCCDBServer(), timestamp); if (done.any()) { log += fmt::format("applied to [{}]", DetID::getNames(done)); diff --git a/Detectors/Base/src/DetectorsBaseLinkDef.h b/Detectors/Base/src/DetectorsBaseLinkDef.h index f12f07321dcab..f06cb806fc620 100644 --- a/Detectors/Base/src/DetectorsBaseLinkDef.h +++ b/Detectors/Base/src/DetectorsBaseLinkDef.h @@ -26,6 +26,7 @@ #pragma link C++ class o2::base::GeometryManager::MatBudgetExt + ; #pragma link C++ class o2::base::MaterialManager + ; #pragma link C++ class o2::MaterialManagerParam + ; +#pragma link C++ class o2::GeometryManagerParam + ; #pragma link C++ class o2::base::SimFieldUtils + ; #pragma link C++ class o2::base::Ray + ; diff --git a/Detectors/Base/src/GeometryManager.cxx b/Detectors/Base/src/GeometryManager.cxx index 250d86b3c1340..64753ac3f3c4b 100644 --- a/Detectors/Base/src/GeometryManager.cxx +++ b/Detectors/Base/src/GeometryManager.cxx @@ -15,9 +15,9 @@ #include // for LOG #include // for TIter #include -#include // for TGeoHMatrix -#include // for TGeoNode -#include // for TGeoPhysicalNode, TGeoPNEntry +#include // for TGeoHMatrix +#include // for TGeoNode +#include // for TGeoPhysicalNode, TGeoPNEntry #include #include #include @@ -25,6 +25,7 @@ #include #include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/GeometryManagerParam.h" #include "DetectorsCommonDataFormats/AlignParam.h" #include "CommonUtils/NameConf.h" #include "DetectorsBase/Aligner.h" @@ -254,10 +255,10 @@ bool GeometryManager::applyAlignment(const std::vector ord(nvols); std::iota(std::begin(ord), std::end(ord), 0); // sort to apply alignment in correct hierarchy std::sort(std::begin(ord), std::end(ord), [&algPars](int a, int b) { return algPars[a].getLevel() < algPars[b].getLevel(); }); - + auto& pars = o2::GeometryManagerParam::Instance(); bool res = true; for (int i = 0; i < nvols; i++) { - if (!algPars[ord[i]].applyToGeometry()) { + if (!algPars[ord[i]].applyToGeometry(pars.useParallelWorld)) { res = false; LOG(error) << "Error applying alignment object for volume" << algPars[ord[i]].getSymName(); } diff --git a/Detectors/Base/src/GeometryManagerParam.cxx b/Detectors/Base/src/GeometryManagerParam.cxx new file mode 100644 index 0000000000000..e3c3ff3d687a7 --- /dev/null +++ b/Detectors/Base/src/GeometryManagerParam.cxx @@ -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. + +#include "DetectorsBase/GeometryManagerParam.h" +O2ParamImpl(o2::GeometryManagerParam); diff --git a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx index c40355f0f34d8..35a85c1a0db49 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx +++ b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx @@ -314,6 +314,7 @@ void Detector::InitializeO2Detector() Bool_t Detector::ProcessHits(FairVolume* vol) { + LOGP(info, "======> QUI 1 <======"); // This method is called from the MC stepping if (!(fMC->TrackCharge())) { return kFALSE; From 3241cf0a81cce9ba6683d8b203bff2bc72c7478c Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Fri, 5 Apr 2024 16:52:05 +0200 Subject: [PATCH 03/19] Don't close geomeitry here --- Detectors/Base/src/Aligner.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/Base/src/Aligner.cxx b/Detectors/Base/src/Aligner.cxx index b4a255d4f8c6c..653908311d626 100644 --- a/Detectors/Base/src/Aligner.cxx +++ b/Detectors/Base/src/Aligner.cxx @@ -73,7 +73,7 @@ void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const } if (pars.useParallelWorld) { // pw->AddOverlap(gGeoManager->GetVolume("ITSUWrapVol0")); - pw->CloseGeometry(); + // pw->CloseGeometry(); gGeoManager->SetUseParallelWorldNav(true); } std::string log = fmt::format("Alignment from {} for timestamp {}: ", o2::base::NameConf::getCCDBServer(), timestamp); From 92fc6f9ebc3d29a9da5c489f2df42c357b8347f2 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Mon, 8 Apr 2024 13:27:06 +0200 Subject: [PATCH 04/19] qwer --- Detectors/gconfig/g4config.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/gconfig/g4config.in b/Detectors/gconfig/g4config.in index cf7c1129cc148..05c5cb0acc933 100644 --- a/Detectors/gconfig/g4config.in +++ b/Detectors/gconfig/g4config.in @@ -7,7 +7,7 @@ /mcTracking/loopVerbose 1 /mcVerbose/composedPhysicsList 2 /mcVerbose/runAction 2 # For looping thresholds control -#/tracking/verbose 1 +/tracking/verbose 1 #//control/cout/ignoreThreadsExcept 0 /mcPhysics/rangeCuts 0.001 mm From 50a4e6170f09c553da630485c1518855804dfe6b Mon Sep 17 00:00:00 2001 From: maciacco Date: Mon, 27 May 2024 15:36:11 +0200 Subject: [PATCH 05/19] add ITS sensors to PW --- DataFormats/Detectors/Common/src/AlignParam.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/DataFormats/Detectors/Common/src/AlignParam.cxx b/DataFormats/Detectors/Common/src/AlignParam.cxx index b31f1c33d8acd..15f7d2d5fd236 100644 --- a/DataFormats/Detectors/Common/src/AlignParam.cxx +++ b/DataFormats/Detectors/Common/src/AlignParam.cxx @@ -328,8 +328,15 @@ bool AlignParam::applyToGeometry(bool usePW) const LOG(debug) << "Aligning volume " << symname; node->Align(ginv); - if (getDetFromSymName(getSymName()) == "ITS" && usePW) { - pw->AddNode(path); + std::string pathStr; + if (path) { + pathStr.append(path); + if (getDetFromSymName(getSymName()) == "ITS" && (pathStr.find("ITSUChip") != std::string::npos) && usePW) { + auto sensor = node->GetNode()->GetDaughter(1); + LOG(debug) << "adding " << path << "/" << sensor->GetName() << " volume to the PW"; + gGeoManager->MakePhysicalNode(Form("%s/%s", path, sensor->GetName())); + pw->AddNode(Form("%s/%s", path, sensor->GetName())); + } } return true; } From 3ba9e9c4d113bd216334fceedc76c371b3faea5a Mon Sep 17 00:00:00 2001 From: maciacco Date: Mon, 27 May 2024 15:36:34 +0200 Subject: [PATCH 06/19] remove debug print --- Detectors/ITSMFT/ITS/simulation/src/Detector.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx index 35a85c1a0db49..c40355f0f34d8 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx +++ b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx @@ -314,7 +314,6 @@ void Detector::InitializeO2Detector() Bool_t Detector::ProcessHits(FairVolume* vol) { - LOGP(info, "======> QUI 1 <======"); // This method is called from the MC stepping if (!(fMC->TrackCharge())) { return kFALSE; From 2bf26f4a455b3942239421dcd55f6ff8bd18d11a Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 27 May 2024 13:44:09 +0000 Subject: [PATCH 07/19] Please consider the following formatting changes --- DataFormats/Detectors/Common/src/AlignParam.cxx | 2 +- Detectors/Base/include/DetectorsBase/GeometryManager.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DataFormats/Detectors/Common/src/AlignParam.cxx b/DataFormats/Detectors/Common/src/AlignParam.cxx index 15f7d2d5fd236..d35aaaa39c3fc 100644 --- a/DataFormats/Detectors/Common/src/AlignParam.cxx +++ b/DataFormats/Detectors/Common/src/AlignParam.cxx @@ -333,7 +333,7 @@ bool AlignParam::applyToGeometry(bool usePW) const pathStr.append(path); if (getDetFromSymName(getSymName()) == "ITS" && (pathStr.find("ITSUChip") != std::string::npos) && usePW) { auto sensor = node->GetNode()->GetDaughter(1); - LOG(debug) << "adding " << path << "/" << sensor->GetName() << " volume to the PW"; + LOG(debug) << "adding " << path << "/" << sensor->GetName() << " volume to the PW"; gGeoManager->MakePhysicalNode(Form("%s/%s", path, sensor->GetName())); pw->AddNode(Form("%s/%s", path, sensor->GetName())); } diff --git a/Detectors/Base/include/DetectorsBase/GeometryManager.h b/Detectors/Base/include/DetectorsBase/GeometryManager.h index e2d0f56ef2658..ad1d77b10f49a 100644 --- a/Detectors/Base/include/DetectorsBase/GeometryManager.h +++ b/Detectors/Base/include/DetectorsBase/GeometryManager.h @@ -15,7 +15,7 @@ #ifndef ALICEO2_BASE_GEOMETRYMANAGER_H_ #define ALICEO2_BASE_GEOMETRYMANAGER_H_ -#include // for TGeoManager +#include // for TGeoManager #include #include // for TGeoPNEntry #include @@ -136,7 +136,7 @@ class GeometryManager : public TObject /// sensitive volume identifier composed from (det_ID< Date: Mon, 27 May 2024 15:46:23 +0200 Subject: [PATCH 08/19] Update Detectors/gconfig/g4config.in Co-authored-by: Matteo Concas --- Detectors/gconfig/g4config.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/gconfig/g4config.in b/Detectors/gconfig/g4config.in index 05c5cb0acc933..cf7c1129cc148 100644 --- a/Detectors/gconfig/g4config.in +++ b/Detectors/gconfig/g4config.in @@ -7,7 +7,7 @@ /mcTracking/loopVerbose 1 /mcVerbose/composedPhysicsList 2 /mcVerbose/runAction 2 # For looping thresholds control -/tracking/verbose 1 +#/tracking/verbose 1 #//control/cout/ignoreThreadsExcept 0 /mcPhysics/rangeCuts 0.001 mm From 1b3d7e0f5d253a3e1bbefcd9d28ba3c20fe44b6e Mon Sep 17 00:00:00 2001 From: maciacco Date: Mon, 12 Aug 2024 17:53:06 +0200 Subject: [PATCH 09/19] disable geometry saving w/ pw + fill pw w/ full list of vols --- .../DetectorsCommonDataFormats/AlignParam.h | 2 +- .../Detectors/Common/src/AlignParam.cxx | 18 ++++++++++++++---- .../DetectorsBase/GeometryManagerParam.h | 3 +++ Detectors/Base/src/GeometryManager.cxx | 2 +- Steer/src/O2MCApplication.cxx | 8 +++++--- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h index 521122d6d762b..45a08067b38e6 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h @@ -52,7 +52,7 @@ class AlignParam double getZ() const { return mZ; } /// apply object to geoemetry - bool applyToGeometry(bool usePW = false) const; + bool applyToGeometry(bool usePW = false, bool addSensorPW = false, bool addMetalPW = false, bool addChipPW = false) const; /// extract global delta matrix TGeoHMatrix createMatrix() const; diff --git a/DataFormats/Detectors/Common/src/AlignParam.cxx b/DataFormats/Detectors/Common/src/AlignParam.cxx index d35aaaa39c3fc..ee60a1ca659ef 100644 --- a/DataFormats/Detectors/Common/src/AlignParam.cxx +++ b/DataFormats/Detectors/Common/src/AlignParam.cxx @@ -268,7 +268,7 @@ bool AlignParam::createLocalMatrix(TGeoHMatrix& m) const } //_____________________________________________________________________________ -bool AlignParam::applyToGeometry(bool usePW) const +bool AlignParam::applyToGeometry(bool usePW, bool addSensorPW, bool addMetalPW, bool addChipPW) const { /// Apply the current alignment object to the TGeo geometry /// This method returns FALSE if the symname of the object was not @@ -332,10 +332,20 @@ bool AlignParam::applyToGeometry(bool usePW) const if (path) { pathStr.append(path); if (getDetFromSymName(getSymName()) == "ITS" && (pathStr.find("ITSUChip") != std::string::npos) && usePW) { + auto metallay = node->GetNode()->GetDaughter(0); auto sensor = node->GetNode()->GetDaughter(1); - LOG(debug) << "adding " << path << "/" << sensor->GetName() << " volume to the PW"; - gGeoManager->MakePhysicalNode(Form("%s/%s", path, sensor->GetName())); - pw->AddNode(Form("%s/%s", path, sensor->GetName())); + if (addSensorPW) { + gGeoManager->MakePhysicalNode(Form("%s/%s", path, sensor->GetName())); + pw->AddNode(Form("%s/%s", path, sensor->GetName())); + } + if (addMetalPW) { + gGeoManager->MakePhysicalNode(Form("%s/%s", path, metallay->GetName())); + pw->AddNode(Form("%s/%s", path, metallay->GetName())); + } + if (addChipPW) { + gGeoManager->MakePhysicalNode(path); + pw->AddNode(path); + } } } return true; diff --git a/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h b/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h index 323089983fb4a..6eaa0336c16d7 100644 --- a/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h +++ b/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h @@ -20,6 +20,9 @@ namespace o2 struct GeometryManagerParam : public o2::conf::ConfigurableParamHelper { bool useParallelWorld = false; + bool addSensorToPW = false; + bool addMetalToPW = false; + bool addChipToPW = false; O2ParamDef(GeometryManagerParam, "GeometryManagerParam"); }; diff --git a/Detectors/Base/src/GeometryManager.cxx b/Detectors/Base/src/GeometryManager.cxx index 64753ac3f3c4b..f03e77e0820e7 100644 --- a/Detectors/Base/src/GeometryManager.cxx +++ b/Detectors/Base/src/GeometryManager.cxx @@ -258,7 +258,7 @@ bool GeometryManager::applyAlignment(const std::vectorExport(alignedgeomfile.c_str()); + // export aligned geometry into different file (only w/o PW) + if (gGeoManager->GetParallelWorld() == nullptr) { + auto alignedgeomfile = o2::base::NameConf::getAlignedGeomFileName(confref.getOutPrefix()); + gGeoManager->Export(alignedgeomfile.c_str()); + } // return original return value of misalignment procedure return true; From 3d38760bd830eeec5dbc407f44d9c2cb33847bb0 Mon Sep 17 00:00:00 2001 From: maciacco Date: Tue, 3 Sep 2024 17:55:20 +0200 Subject: [PATCH 10/19] make pw filling detector specific (todo: configuration) --- .../DetectorsCommonDataFormats/AlignParam.h | 2 +- .../Detectors/Common/src/AlignParam.cxx | 28 +---------- .../Base/include/DetectorsBase/Detector.h | 3 ++ Detectors/Base/src/Aligner.cxx | 12 ----- Detectors/Base/src/Detector.cxx | 5 ++ Detectors/Base/src/GeometryManager.cxx | 2 +- .../include/ITSSimulation/Detector.h | 3 ++ .../ITSMFT/ITS/simulation/src/Detector.cxx | 46 +++++++++++++++++++ Steer/src/O2MCApplication.cxx | 18 ++++++-- 9 files changed, 75 insertions(+), 44 deletions(-) diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h index 45a08067b38e6..c4e702c6ae27e 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/AlignParam.h @@ -52,7 +52,7 @@ class AlignParam double getZ() const { return mZ; } /// apply object to geoemetry - bool applyToGeometry(bool usePW = false, bool addSensorPW = false, bool addMetalPW = false, bool addChipPW = false) const; + bool applyToGeometry() const; /// extract global delta matrix TGeoHMatrix createMatrix() const; diff --git a/DataFormats/Detectors/Common/src/AlignParam.cxx b/DataFormats/Detectors/Common/src/AlignParam.cxx index ee60a1ca659ef..a9f56a9b113ab 100644 --- a/DataFormats/Detectors/Common/src/AlignParam.cxx +++ b/DataFormats/Detectors/Common/src/AlignParam.cxx @@ -17,7 +17,6 @@ #include #include #include -#include #include "DetectorsCommonDataFormats/AlignParam.h" @@ -268,7 +267,7 @@ bool AlignParam::createLocalMatrix(TGeoHMatrix& m) const } //_____________________________________________________________________________ -bool AlignParam::applyToGeometry(bool usePW, bool addSensorPW, bool addMetalPW, bool addChipPW) const +bool AlignParam::applyToGeometry() const { /// Apply the current alignment object to the TGeo geometry /// This method returns FALSE if the symname of the object was not @@ -287,10 +286,6 @@ bool AlignParam::applyToGeometry(bool usePW, bool addSensorPW, bool addMetalPW, const char* symname = getSymName().c_str(); const char* path; TGeoPhysicalNode* node; - TGeoParallelWorld* pw = nullptr; - if (getDetFromSymName(getSymName()) == "ITS" && usePW) { - pw = gGeoManager->GetParallelWorld(); - } TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname); if (pne) { path = pne->GetTitle(); @@ -328,26 +323,7 @@ bool AlignParam::applyToGeometry(bool usePW, bool addSensorPW, bool addMetalPW, LOG(debug) << "Aligning volume " << symname; node->Align(ginv); - std::string pathStr; - if (path) { - pathStr.append(path); - if (getDetFromSymName(getSymName()) == "ITS" && (pathStr.find("ITSUChip") != std::string::npos) && usePW) { - auto metallay = node->GetNode()->GetDaughter(0); - auto sensor = node->GetNode()->GetDaughter(1); - if (addSensorPW) { - gGeoManager->MakePhysicalNode(Form("%s/%s", path, sensor->GetName())); - pw->AddNode(Form("%s/%s", path, sensor->GetName())); - } - if (addMetalPW) { - gGeoManager->MakePhysicalNode(Form("%s/%s", path, metallay->GetName())); - pw->AddNode(Form("%s/%s", path, metallay->GetName())); - } - if (addChipPW) { - gGeoManager->MakePhysicalNode(path); - pw->AddNode(path); - } - } - } + return true; } diff --git a/Detectors/Base/include/DetectorsBase/Detector.h b/Detectors/Base/include/DetectorsBase/Detector.h index 1432d93c53821..f1744086d6a05 100644 --- a/Detectors/Base/include/DetectorsBase/Detector.h +++ b/Detectors/Base/include/DetectorsBase/Detector.h @@ -106,6 +106,9 @@ class Detector : public FairDetector /// declare alignable volumes of detector virtual void addAlignableVolumes() const; + /// fill parallel geometry with sensitive volumes of detector + virtual void fillParallelWorld() const; + /// Sets per wrapper volume parameters virtual void defineWrapperVolume(Int_t id, Double_t rmin, Double_t rmax, Double_t zspan); diff --git a/Detectors/Base/src/Aligner.cxx b/Detectors/Base/src/Aligner.cxx index 653908311d626..a82f48942d2be 100644 --- a/Detectors/Base/src/Aligner.cxx +++ b/Detectors/Base/src/Aligner.cxx @@ -12,11 +12,9 @@ #include "DetectorsBase/Aligner.h" #include "CCDB/BasicCCDBManager.h" #include "DetectorsBase/GeometryManager.h" -#include "DetectorsBase/GeometryManagerParam.h" #include "DetectorsCommonDataFormats/AlignParam.h" #include "DetectorsCommonDataFormats/DetectorNameConf.h" #include -#include O2ParamImpl(o2::base::Aligner); @@ -50,11 +48,6 @@ void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const ccdbmgr.setTimestamp(timestamp); DetID::mask_t done, skipped; DetID::mask_t detGeoMask(gGeoManager->GetUniqueID()); - auto& pars = GeometryManagerParam::Instance(); - TGeoParallelWorld* pw = nullptr; - if (pars.useParallelWorld) { - pw = gGeoManager->CreateParallelWorld("priority_its_sensor"); - } for (auto id = DetID::First; id <= DetID::Last; id++) { if (!msk[id] || (detGeoMask.any() && !detGeoMask[id])) { continue; @@ -71,11 +64,6 @@ void Aligner::applyAlignment(long timestamp, DetID::mask_t addMask) const skipped.set(id); } } - if (pars.useParallelWorld) { - // pw->AddOverlap(gGeoManager->GetVolume("ITSUWrapVol0")); - // pw->CloseGeometry(); - gGeoManager->SetUseParallelWorldNav(true); - } std::string log = fmt::format("Alignment from {} for timestamp {}: ", o2::base::NameConf::getCCDBServer(), timestamp); if (done.any()) { log += fmt::format("applied to [{}]", DetID::getNames(done)); diff --git a/Detectors/Base/src/Detector.cxx b/Detectors/Base/src/Detector.cxx index f2b790ffccd5b..c3b57cceb78ff 100644 --- a/Detectors/Base/src/Detector.cxx +++ b/Detectors/Base/src/Detector.cxx @@ -171,6 +171,11 @@ void Detector::addAlignableVolumes() const LOG(warning) << "Alignable volumes are not yet defined for " << GetName(); } +void Detector::fillParallelWorld() const +{ + LOG(warning) << "Parallel world is not filled for " << GetName(); +} + int Detector::registerSensitiveVolumeAndGetVolID(TGeoVolume const* vol) { // register this volume with FairRoot diff --git a/Detectors/Base/src/GeometryManager.cxx b/Detectors/Base/src/GeometryManager.cxx index f03e77e0820e7..ce2ee125402c4 100644 --- a/Detectors/Base/src/GeometryManager.cxx +++ b/Detectors/Base/src/GeometryManager.cxx @@ -258,7 +258,7 @@ bool GeometryManager::applyAlignment(const std::vector /// Add alignable top volumes void addAlignableVolumes() const override; + /// Add ITS chip volumes to parallel world geometry + void fillParallelWorld() const override; + /// Add alignable Layer volumes /// \param lr layer number /// \param parent path of the parent volume diff --git a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx index d005c9ea9858a..f24321b1767af 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx +++ b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx @@ -41,6 +41,7 @@ #include "TVirtualMC.h" // for gMC, TVirtualMC #include "TVirtualMCStack.h" // for TVirtualMCStack #include "TFile.h" // for TVirtualMCStack +#include "TGeoParallelWorld.h" #include // for NULL, snprintf #include @@ -1308,6 +1309,51 @@ void Detector::defineSensitiveVolumes() } } +void Detector::fillParallelWorld() const // TODO: make this configurable to handle different volume lists +{ + TGeoParallelWorld *pw = gGeoManager->GetParallelWorld(); + + for (int iL{0}; iL < mNumberLayers; ++iL) { + auto const layer = mGeometry[iL]; + TString path_0 = Form("/cave_1/barrel_1/%s_2", GeometryTGeo::getITSVolPattern()); + TString wrpV = mWrapperLayerId[iL] != -1 ? Form("%s%d_1", GeometryTGeo::getITSWrapVolPattern(), mWrapperLayerId[iL]) : ""; + int nhbarrels = layer->getNumberOfHalfBarrelsPerParent(); + int nstaves = layer->getNumberOfStavesPerParent(); + int nhstaves = layer->getNumberOfHalfStavesPerParent(); + int nmodules = layer->getNumberOfModulesPerParent(); + int nchips = layer->getNumberOfChipsPerParent(); + + int nall = nhbarrels * nstaves * nchips; + if (nhstaves > 0) nall *= nhstaves; + if (nmodules > 0) nall *= nmodules; + for (int iC{0}; iC < nall; ++iC) { + TString path = Form("%s/%s/%s%d_1", path_0.Data(), wrpV.Data(), GeometryTGeo::getITSLayerPattern(), iL); + path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSHalfBarrelPattern(), iL, iC % nhbarrels); + path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSStavePattern(), iL, iC % nstaves); + if (nhstaves > 0) { + path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSHalfStavePattern(), iL, iC % nhstaves); + } + if (nmodules > 0) { + path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSModulePattern(), iL, iC % nmodules); + } + path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSChipPattern(), iL, iC % nchips); + + TGeoPhysicalNode* node = (TGeoPhysicalNode*)gGeoManager->GetListOfPhysicalNodes()->FindObject(path); + + auto metallay = node->GetNode()->GetDaughter(0); + gGeoManager->MakePhysicalNode(Form("%s/%s", path.Data(), metallay->GetName())); + pw->AddNode(Form("%s/%s", path.Data(), metallay->GetName())); + + auto sensor = node->GetNode()->GetDaughter(1); + gGeoManager->MakePhysicalNode(Form("%s/%s", path.Data(), sensor->GetName())); + pw->AddNode(Form("%s/%s", path.Data(), sensor->GetName())); + + pw->AddNode(path.Data()); + } + } + return; +} + Hit* Detector::addHit(int trackID, int detID, const TVector3& startPos, const TVector3& endPos, const TVector3& startMom, double startE, double endTime, double eLoss, unsigned char startStatus, unsigned char endStatus) diff --git a/Steer/src/O2MCApplication.cxx b/Steer/src/O2MCApplication.cxx index fccc138fb05ab..7e5a7561d6faa 100644 --- a/Steer/src/O2MCApplication.cxx +++ b/Steer/src/O2MCApplication.cxx @@ -33,6 +33,7 @@ #include #include #include "SimConfig/GlobalProcessCutSimParam.h" +#include namespace o2 { @@ -163,6 +164,9 @@ void O2MCApplicationBase::InitGeometry() bool O2MCApplicationBase::MisalignGeometry() { + TGeoParallelWorld* pw = nullptr; + pw = gGeoManager->CreateParallelWorld("sensors"); + for (auto det : listDetectors) { if (dynamic_cast(det)) { ((o2::base::Detector*)det)->addAlignableVolumes(); @@ -182,11 +186,17 @@ bool O2MCApplicationBase::MisalignGeometry() auto& aligner = o2::base::Aligner::Instance(); aligner.applyAlignment(confref.getTimestamp()); - // export aligned geometry into different file (only w/o PW) - if (gGeoManager->GetParallelWorld() == nullptr) { - auto alignedgeomfile = o2::base::NameConf::getAlignedGeomFileName(confref.getOutPrefix()); - gGeoManager->Export(alignedgeomfile.c_str()); + // export aligned geometry into different file + auto alignedgeomfile = o2::base::NameConf::getAlignedGeomFileName(confref.getOutPrefix()); + gGeoManager->Export(alignedgeomfile.c_str()); + + // fill parallel world geometry + for (auto det : listDetectors) { + if (dynamic_cast(det)) { + ((o2::base::Detector*)det)->fillParallelWorld(); + } } + gGeoManager->SetUseParallelWorldNav(kTRUE); // return original return value of misalignment procedure return true; From 9494c0cbf0590e42af3c2592db4767a2579db9fc Mon Sep 17 00:00:00 2001 From: maciacco Date: Wed, 4 Sep 2024 19:25:43 +0200 Subject: [PATCH 11/19] fix filling order + add configurables --- .../Detectors/Common/src/AlignParam.cxx | 11 +--- .../DetectorsBase/GeometryManagerParam.h | 3 - .../ITSMFT/ITS/simulation/CMakeLists.txt | 4 +- .../include/ITSSimulation/ITSSimParam.h | 34 +++++++++++ .../ITSMFT/ITS/simulation/src/Detector.cxx | 56 +++++++++---------- .../ITSMFT/ITS/simulation/src/ITSSimParam.cxx | 13 +++++ Steer/src/O2MCApplication.cxx | 17 +++--- 7 files changed, 88 insertions(+), 50 deletions(-) create mode 100644 Detectors/ITSMFT/ITS/simulation/include/ITSSimulation/ITSSimParam.h create mode 100644 Detectors/ITSMFT/ITS/simulation/src/ITSSimParam.cxx diff --git a/DataFormats/Detectors/Common/src/AlignParam.cxx b/DataFormats/Detectors/Common/src/AlignParam.cxx index a9f56a9b113ab..30b110ac76e82 100644 --- a/DataFormats/Detectors/Common/src/AlignParam.cxx +++ b/DataFormats/Detectors/Common/src/AlignParam.cxx @@ -22,15 +22,6 @@ using namespace o2::detectors; -std::string getDetFromSymName(const std::string& input) -{ - size_t pos = input.find("/"); // Detector name is before the first slash - if (pos != std::string::npos) { - return input.substr(0, pos); - } - return input; -} - //___________________________________________________ AlignParam::AlignParam(const char* symname, int algID, // volume symbolic name and its alignable ID double x, double y, double z, // delta translation @@ -291,7 +282,7 @@ bool AlignParam::applyToGeometry() const path = pne->GetTitle(); node = gGeoManager->MakeAlignablePN(pne); } else { - LOG(debug) << "The symbolic volume name " << symname + LOG(info) << "The symbolic volume name " << symname << " does not correspond to a physical entry. Using it as a volume path!"; path = symname; if (!gGeoManager->CheckPath(path)) { diff --git a/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h b/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h index 6eaa0336c16d7..323089983fb4a 100644 --- a/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h +++ b/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h @@ -20,9 +20,6 @@ namespace o2 struct GeometryManagerParam : public o2::conf::ConfigurableParamHelper { bool useParallelWorld = false; - bool addSensorToPW = false; - bool addMetalToPW = false; - bool addChipToPW = false; O2ParamDef(GeometryManagerParam, "GeometryManagerParam"); }; diff --git a/Detectors/ITSMFT/ITS/simulation/CMakeLists.txt b/Detectors/ITSMFT/ITS/simulation/CMakeLists.txt index 78a93bdc7232d..51ade8bab6bcc 100644 --- a/Detectors/ITSMFT/ITS/simulation/CMakeLists.txt +++ b/Detectors/ITSMFT/ITS/simulation/CMakeLists.txt @@ -13,6 +13,7 @@ o2_add_library(ITSSimulation SOURCES src/V11Geometry.cxx src/V1Layer.cxx src/V3Layer.cxx src/Detector.cxx src/V3Services.cxx src/V3Cage.cxx src/DescriptorInnerBarrelITS2.cxx src/ITSDataSimulator.cxx + src/ITSSimParam.cxx PUBLIC_LINK_LIBRARIES O2::ITSBase O2::ITSMFTSimulation ROOT::Physics $<$:O2::ITS3Base> $<$:O2::ITS3Simulation>) @@ -24,7 +25,8 @@ o2_target_root_dictionary(ITSSimulation include/ITSSimulation/V3Cage.h include/ITSSimulation/V11Geometry.h include/ITSSimulation/V3Services.h - include/ITSSimulation/DescriptorInnerBarrelITS2.h) + include/ITSSimulation/DescriptorInnerBarrelITS2.h + include/ITSSimulation/ITSSimParam.h) o2_data_file(COPY data DESTINATION Detectors/ITS/simulation) diff --git a/Detectors/ITSMFT/ITS/simulation/include/ITSSimulation/ITSSimParam.h b/Detectors/ITSMFT/ITS/simulation/include/ITSSimulation/ITSSimParam.h new file mode 100644 index 0000000000000..231b9294136b0 --- /dev/null +++ b/Detectors/ITSMFT/ITS/simulation/include/ITSSimulation/ITSSimParam.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. + +#ifndef DETECTORS_BASE_INCLUDE_ITSSIMPARAM_H_ +#define DETECTORS_BASE_INCLUDE_ITSSIMPARAM_H_ + +#include "CommonUtils/ConfigurableParam.h" +#include "CommonUtils/ConfigurableParamHelper.h" + +namespace o2 +{ +namespace its +{ + +struct ITSSimParam : public o2::conf::ConfigurableParamHelper { + bool addMetalToPW = true; + bool addSensorToPW = true; + bool addChipToPW = true; + + O2ParamDef(ITSSimParam, "ITSSimParam"); +}; + +} // namespace its +} // namespace o2 + +#endif /* DETECTORS_BASE_INCLUDE_ITSSIMPARAM_H_ */ diff --git a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx index f24321b1767af..87c5db9a39189 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx +++ b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx @@ -20,6 +20,7 @@ #include "ITSSimulation/V3Layer.h" #include "ITSSimulation/V3Services.h" #include "ITSSimulation/V3Cage.h" +#include "ITSSimulation/ITSSimParam.h" #include "DetectorsBase/Stack.h" #include "SimulationDataFormat/TrackReference.h" @@ -1312,46 +1313,45 @@ void Detector::defineSensitiveVolumes() void Detector::fillParallelWorld() const // TODO: make this configurable to handle different volume lists { TGeoParallelWorld *pw = gGeoManager->GetParallelWorld(); + if (pw == nullptr) { + LOG(error) << "Parallel world was not created"; + return; + } for (int iL{0}; iL < mNumberLayers; ++iL) { auto const layer = mGeometry[iL]; - TString path_0 = Form("/cave_1/barrel_1/%s_2", GeometryTGeo::getITSVolPattern()); - TString wrpV = mWrapperLayerId[iL] != -1 ? Form("%s%d_1", GeometryTGeo::getITSWrapVolPattern(), mWrapperLayerId[iL]) : ""; int nhbarrels = layer->getNumberOfHalfBarrelsPerParent(); int nstaves = layer->getNumberOfStavesPerParent(); int nhstaves = layer->getNumberOfHalfStavesPerParent(); int nmodules = layer->getNumberOfModulesPerParent(); int nchips = layer->getNumberOfChipsPerParent(); - int nall = nhbarrels * nstaves * nchips; - if (nhstaves > 0) nall *= nhstaves; - if (nmodules > 0) nall *= nmodules; - for (int iC{0}; iC < nall; ++iC) { - TString path = Form("%s/%s/%s%d_1", path_0.Data(), wrpV.Data(), GeometryTGeo::getITSLayerPattern(), iL); - path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSHalfBarrelPattern(), iL, iC % nhbarrels); - path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSStavePattern(), iL, iC % nstaves); - if (nhstaves > 0) { - path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSHalfStavePattern(), iL, iC % nhstaves); - } - if (nmodules > 0) { - path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSModulePattern(), iL, iC % nmodules); + for (int iHB{0}; iHB < nhbarrels; ++iHB) { + for (int iS{0}; iS < nstaves; ++iS) { + for (int iHS{nhstaves > 0 ? 0 : -1}; iHS < nhstaves; ++iHS) { + for (int iM{nmodules > 0 ? 0 : -1}; iM < nmodules; ++iM) { + for (int iC{0}; iC < nchips; ++iC) { + TString sname = GeometryTGeo::composeSymNameChip(iL, iHB, iS, iHS, iM, iC); + TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(sname); + auto path = pne->GetTitle(); + + if (ITSSimParam::Instance().addMetalToPW) { + gGeoManager->MakePhysicalNode(Form("%s/MetalStack_1", path)); + pw->AddNode(Form("%s/MetalStack_1", path)); + } + if (ITSSimParam::Instance().addSensorToPW) { + gGeoManager->MakePhysicalNode(Form("%s/ITSUSensor%d_1", path, iL)); + pw->AddNode(Form("%s/ITSUSensor%d_1", path, iL)); + } + if (ITSSimParam::Instance().addChipToPW) { + pw->AddNode(path); + } + } + } + } } - path = Form("%s/%s%d_%d", path.Data(), GeometryTGeo::getITSChipPattern(), iL, iC % nchips); - - TGeoPhysicalNode* node = (TGeoPhysicalNode*)gGeoManager->GetListOfPhysicalNodes()->FindObject(path); - - auto metallay = node->GetNode()->GetDaughter(0); - gGeoManager->MakePhysicalNode(Form("%s/%s", path.Data(), metallay->GetName())); - pw->AddNode(Form("%s/%s", path.Data(), metallay->GetName())); - - auto sensor = node->GetNode()->GetDaughter(1); - gGeoManager->MakePhysicalNode(Form("%s/%s", path.Data(), sensor->GetName())); - pw->AddNode(Form("%s/%s", path.Data(), sensor->GetName())); - - pw->AddNode(path.Data()); } } - return; } Hit* Detector::addHit(int trackID, int detID, const TVector3& startPos, const TVector3& endPos, diff --git a/Detectors/ITSMFT/ITS/simulation/src/ITSSimParam.cxx b/Detectors/ITSMFT/ITS/simulation/src/ITSSimParam.cxx new file mode 100644 index 0000000000000..564e9942a26d5 --- /dev/null +++ b/Detectors/ITSMFT/ITS/simulation/src/ITSSimParam.cxx @@ -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. + +#include "ITSSimulation/ITSSimParam.h" +O2ParamImpl(o2::its::ITSSimParam); diff --git a/Steer/src/O2MCApplication.cxx b/Steer/src/O2MCApplication.cxx index 7e5a7561d6faa..42ea162c54cac 100644 --- a/Steer/src/O2MCApplication.cxx +++ b/Steer/src/O2MCApplication.cxx @@ -33,6 +33,7 @@ #include #include #include "SimConfig/GlobalProcessCutSimParam.h" +#include "DetectorsBase/GeometryManagerParam.h" #include namespace o2 @@ -164,9 +165,6 @@ void O2MCApplicationBase::InitGeometry() bool O2MCApplicationBase::MisalignGeometry() { - TGeoParallelWorld* pw = nullptr; - pw = gGeoManager->CreateParallelWorld("sensors"); - for (auto det : listDetectors) { if (dynamic_cast(det)) { ((o2::base::Detector*)det)->addAlignableVolumes(); @@ -190,13 +188,16 @@ bool O2MCApplicationBase::MisalignGeometry() auto alignedgeomfile = o2::base::NameConf::getAlignedGeomFileName(confref.getOutPrefix()); gGeoManager->Export(alignedgeomfile.c_str()); - // fill parallel world geometry - for (auto det : listDetectors) { - if (dynamic_cast(det)) { - ((o2::base::Detector*)det)->fillParallelWorld(); + // fill parallel world geometry if activated + if (o2::GeometryManagerParam::Instance().useParallelWorld) { + TGeoParallelWorld *pw = gGeoManager->CreateParallelWorld("priority_sensors"); + for (auto det : listDetectors) { + if (dynamic_cast(det)) { + ((o2::base::Detector*)det)->fillParallelWorld(); + } } + gGeoManager->SetUseParallelWorldNav(true); } - gGeoManager->SetUseParallelWorldNav(kTRUE); // return original return value of misalignment procedure return true; From bcaddf46a9ca777c7e1e80ed0fcb7de1613c4930 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Wed, 4 Sep 2024 17:27:00 +0000 Subject: [PATCH 12/19] Please consider the following formatting changes --- DataFormats/Detectors/Common/src/AlignParam.cxx | 2 +- Detectors/ITSMFT/ITS/simulation/src/Detector.cxx | 2 +- Steer/src/O2MCApplication.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DataFormats/Detectors/Common/src/AlignParam.cxx b/DataFormats/Detectors/Common/src/AlignParam.cxx index 30b110ac76e82..092e18e53378a 100644 --- a/DataFormats/Detectors/Common/src/AlignParam.cxx +++ b/DataFormats/Detectors/Common/src/AlignParam.cxx @@ -283,7 +283,7 @@ bool AlignParam::applyToGeometry() const node = gGeoManager->MakeAlignablePN(pne); } else { LOG(info) << "The symbolic volume name " << symname - << " does not correspond to a physical entry. Using it as a volume path!"; + << " does not correspond to a physical entry. Using it as a volume path!"; path = symname; if (!gGeoManager->CheckPath(path)) { LOG(error) << "Volume path " << path << " is not valid"; diff --git a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx index 87c5db9a39189..542f11dce6221 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx +++ b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx @@ -1312,7 +1312,7 @@ void Detector::defineSensitiveVolumes() void Detector::fillParallelWorld() const // TODO: make this configurable to handle different volume lists { - TGeoParallelWorld *pw = gGeoManager->GetParallelWorld(); + TGeoParallelWorld* pw = gGeoManager->GetParallelWorld(); if (pw == nullptr) { LOG(error) << "Parallel world was not created"; return; diff --git a/Steer/src/O2MCApplication.cxx b/Steer/src/O2MCApplication.cxx index 42ea162c54cac..37c42b6ad06ca 100644 --- a/Steer/src/O2MCApplication.cxx +++ b/Steer/src/O2MCApplication.cxx @@ -190,7 +190,7 @@ bool O2MCApplicationBase::MisalignGeometry() // fill parallel world geometry if activated if (o2::GeometryManagerParam::Instance().useParallelWorld) { - TGeoParallelWorld *pw = gGeoManager->CreateParallelWorld("priority_sensors"); + TGeoParallelWorld* pw = gGeoManager->CreateParallelWorld("priority_sensors"); for (auto det : listDetectors) { if (dynamic_cast(det)) { ((o2::base::Detector*)det)->fillParallelWorld(); From 6aa192db08e27b510095dc05ea76454d335abb20 Mon Sep 17 00:00:00 2001 From: maciacco Date: Wed, 4 Sep 2024 19:37:52 +0200 Subject: [PATCH 13/19] remove unused params --- Detectors/Base/src/GeometryManager.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Detectors/Base/src/GeometryManager.cxx b/Detectors/Base/src/GeometryManager.cxx index ce2ee125402c4..2e25e236836ad 100644 --- a/Detectors/Base/src/GeometryManager.cxx +++ b/Detectors/Base/src/GeometryManager.cxx @@ -25,7 +25,6 @@ #include #include "DetectorsBase/GeometryManager.h" -#include "DetectorsBase/GeometryManagerParam.h" #include "DetectorsCommonDataFormats/AlignParam.h" #include "CommonUtils/NameConf.h" #include "DetectorsBase/Aligner.h" @@ -255,7 +254,7 @@ bool GeometryManager::applyAlignment(const std::vector ord(nvols); std::iota(std::begin(ord), std::end(ord), 0); // sort to apply alignment in correct hierarchy std::sort(std::begin(ord), std::end(ord), [&algPars](int a, int b) { return algPars[a].getLevel() < algPars[b].getLevel(); }); - auto& pars = o2::GeometryManagerParam::Instance(); + bool res = true; for (int i = 0; i < nvols; i++) { if (!algPars[ord[i]].applyToGeometry()) { From 1cb77fff4fb952ac94cda511527b03aa0f27a147 Mon Sep 17 00:00:00 2001 From: maciacco Date: Wed, 4 Sep 2024 19:41:59 +0200 Subject: [PATCH 14/19] remove unused include + add new class to linkdef --- Detectors/Base/src/GeometryManager.cxx | 1 - Detectors/ITSMFT/ITS/simulation/src/ITSSimulationLinkDef.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/Base/src/GeometryManager.cxx b/Detectors/Base/src/GeometryManager.cxx index 2e25e236836ad..c5e7e8e47e731 100644 --- a/Detectors/Base/src/GeometryManager.cxx +++ b/Detectors/Base/src/GeometryManager.cxx @@ -18,7 +18,6 @@ #include // for TGeoHMatrix #include // for TGeoNode #include // for TGeoPhysicalNode, TGeoPNEntry -#include #include #include #include // for NULL diff --git a/Detectors/ITSMFT/ITS/simulation/src/ITSSimulationLinkDef.h b/Detectors/ITSMFT/ITS/simulation/src/ITSSimulationLinkDef.h index 92e10577b6abf..bd4ce228deb1b 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/ITSSimulationLinkDef.h +++ b/Detectors/ITSMFT/ITS/simulation/src/ITSSimulationLinkDef.h @@ -23,5 +23,6 @@ #pragma link C++ class o2::its::Detector + ; #pragma link C++ class o2::its::DescriptorInnerBarrelITS2 + ; #pragma link C++ class o2::base::DetImpl < o2::its::Detector> + ; +#pragma link C++ class o2::its::ITSSimParam + ; #endif From e764530a48893d9b265368a87119d3bd83f8e79c Mon Sep 17 00:00:00 2001 From: maciacco Date: Fri, 6 Sep 2024 10:36:58 +0200 Subject: [PATCH 15/19] remove print + format string only once --- DataFormats/Detectors/Common/src/AlignParam.cxx | 4 ++-- .../ITSMFT/ITS/simulation/src/Detector.cxx | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/DataFormats/Detectors/Common/src/AlignParam.cxx b/DataFormats/Detectors/Common/src/AlignParam.cxx index 092e18e53378a..90f2a349607a1 100644 --- a/DataFormats/Detectors/Common/src/AlignParam.cxx +++ b/DataFormats/Detectors/Common/src/AlignParam.cxx @@ -282,8 +282,8 @@ bool AlignParam::applyToGeometry() const path = pne->GetTitle(); node = gGeoManager->MakeAlignablePN(pne); } else { - LOG(info) << "The symbolic volume name " << symname - << " does not correspond to a physical entry. Using it as a volume path!"; + LOG(debug) << "The symbolic volume name " << symname + << " does not correspond to a physical entry. Using it as a volume path!"; path = symname; if (!gGeoManager->CheckPath(path)) { LOG(error) << "Volume path " << path << " is not valid"; diff --git a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx index 545265e15ed1f..1ee130d87f437 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx +++ b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx @@ -1319,6 +1319,7 @@ void Detector::fillParallelWorld() const // TODO: make this configurable to hand } for (int iL{0}; iL < mNumberLayers; ++iL) { + auto& param = ITSSimParam::Instance(); auto const layer = mGeometry[iL]; int nhbarrels = layer->getNumberOfHalfBarrelsPerParent(); int nstaves = layer->getNumberOfStavesPerParent(); @@ -1335,15 +1336,17 @@ void Detector::fillParallelWorld() const // TODO: make this configurable to hand TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(sname); auto path = pne->GetTitle(); - if (ITSSimParam::Instance().addMetalToPW) { - gGeoManager->MakePhysicalNode(Form("%s/MetalStack_1", path)); - pw->AddNode(Form("%s/MetalStack_1", path)); + if (param.addMetalToPW) { + TString metalPath = Form("%s/MetalStack_1", path); + gGeoManager->MakePhysicalNode(metalPath); + pw->AddNode(metalPath); } - if (ITSSimParam::Instance().addSensorToPW) { - gGeoManager->MakePhysicalNode(Form("%s/ITSUSensor%d_1", path, iL)); - pw->AddNode(Form("%s/ITSUSensor%d_1", path, iL)); + if (param.addSensorToPW) { + TString sensorPath = Form("%s/ITSUSensor%d_1", path, iL); + gGeoManager->MakePhysicalNode(sensorPath); + pw->AddNode(sensorPath); } - if (ITSSimParam::Instance().addChipToPW) { + if (param.addChipToPW) { pw->AddNode(path); } } From d2a9e9f64c2ac8e86d6be07d6c13989b877b2066 Mon Sep 17 00:00:00 2001 From: maciacco Date: Fri, 6 Sep 2024 10:42:13 +0200 Subject: [PATCH 16/19] get param only once --- Detectors/ITSMFT/ITS/simulation/src/Detector.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx index 1ee130d87f437..c3ba1038b23bf 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx +++ b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx @@ -1317,9 +1317,9 @@ void Detector::fillParallelWorld() const // TODO: make this configurable to hand LOG(error) << "Parallel world was not created"; return; } + auto& param = ITSSimParam::Instance(); for (int iL{0}; iL < mNumberLayers; ++iL) { - auto& param = ITSSimParam::Instance(); auto const layer = mGeometry[iL]; int nhbarrels = layer->getNumberOfHalfBarrelsPerParent(); int nstaves = layer->getNumberOfStavesPerParent(); From ca0a0242d1f3b3a1c7bd872f16b80598c2b1e11b Mon Sep 17 00:00:00 2001 From: Mario Ciacco Date: Mon, 9 Sep 2024 12:10:44 +0200 Subject: [PATCH 17/19] remove useless comment --- Detectors/ITSMFT/ITS/simulation/src/Detector.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx index c3ba1038b23bf..bf2e997794ee4 100644 --- a/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx +++ b/Detectors/ITSMFT/ITS/simulation/src/Detector.cxx @@ -1310,7 +1310,7 @@ void Detector::defineSensitiveVolumes() } } -void Detector::fillParallelWorld() const // TODO: make this configurable to handle different volume lists +void Detector::fillParallelWorld() const { TGeoParallelWorld* pw = gGeoManager->GetParallelWorld(); if (pw == nullptr) { From a9fcf2b818c013716874754220f499f0539f8acb Mon Sep 17 00:00:00 2001 From: maciacco Date: Tue, 1 Oct 2024 10:45:06 +0200 Subject: [PATCH 18/19] enable pw optimisation --- .../include/DetectorsBase/GeometryManagerParam.h | 2 ++ Steer/src/O2MCApplication.cxx | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h b/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h index 323089983fb4a..c41d41e25e233 100644 --- a/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h +++ b/Detectors/Base/include/DetectorsBase/GeometryManagerParam.h @@ -20,6 +20,8 @@ namespace o2 struct GeometryManagerParam : public o2::conf::ConfigurableParamHelper { bool useParallelWorld = false; + bool usePwGeoBVH = false; + bool usePwCaching = false; O2ParamDef(GeometryManagerParam, "GeometryManagerParam"); }; diff --git a/Steer/src/O2MCApplication.cxx b/Steer/src/O2MCApplication.cxx index 37c42b6ad06ca..ed4735b21b46a 100644 --- a/Steer/src/O2MCApplication.cxx +++ b/Steer/src/O2MCApplication.cxx @@ -9,6 +9,8 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#include + #include #include #include @@ -188,9 +190,17 @@ bool O2MCApplicationBase::MisalignGeometry() auto alignedgeomfile = o2::base::NameConf::getAlignedGeomFileName(confref.getOutPrefix()); gGeoManager->Export(alignedgeomfile.c_str()); + auto& param = o2::GeometryManagerParam::Instance(); + // fill parallel world geometry if activated - if (o2::GeometryManagerParam::Instance().useParallelWorld) { + if (param.useParallelWorld) { TGeoParallelWorld* pw = gGeoManager->CreateParallelWorld("priority_sensors"); + if (param.usePwGeoBVH) { + pw->SetAccelerationMode(TGeoParallelWorld::AccelerationMode::kBVH); + } + if (param.usePwCaching) { + TGeoNavigator::SetPWSafetyCaching(true); + } for (auto det : listDetectors) { if (dynamic_cast(det)) { ((o2::base::Detector*)det)->fillParallelWorld(); From ef32328778dd74e4f2a99db23307cab801418278 Mon Sep 17 00:00:00 2001 From: Mario Ciacco Date: Fri, 11 Oct 2024 11:55:22 +0200 Subject: [PATCH 19/19] add empty implementation for generic pw method --- Detectors/Base/src/Detector.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Detectors/Base/src/Detector.cxx b/Detectors/Base/src/Detector.cxx index c3b57cceb78ff..d2be9237f6f13 100644 --- a/Detectors/Base/src/Detector.cxx +++ b/Detectors/Base/src/Detector.cxx @@ -173,7 +173,6 @@ void Detector::addAlignableVolumes() const void Detector::fillParallelWorld() const { - LOG(warning) << "Parallel world is not filled for " << GetName(); } int Detector::registerSensitiveVolumeAndGetVolID(TGeoVolume const* vol)