From f66ff9e17f8b9ebae4e07c59c1d395d06c8118c9 Mon Sep 17 00:00:00 2001 From: Tamas Vami Date: Tue, 27 Aug 2024 14:00:03 -0700 Subject: [PATCH] Move cout msg to logging in DetectorConstruction, ParallelWorld, TS DQM --- DQM/src/DQM/TrigScintDQM.cxx | 6 +++--- DQM/src/DQM/TrigScintHitDQM.cxx | 6 +++--- SimCore/include/SimCore/DetectorConstruction.h | 3 +++ SimCore/include/SimCore/ParallelWorld.h | 3 +++ SimCore/src/SimCore/DetectorConstruction.cxx | 12 +++++------- SimCore/src/SimCore/ParallelWorld.cxx | 4 ++-- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/DQM/src/DQM/TrigScintDQM.cxx b/DQM/src/DQM/TrigScintDQM.cxx index a22d51a8a..95a56f667 100644 --- a/DQM/src/DQM/TrigScintDQM.cxx +++ b/DQM/src/DQM/TrigScintDQM.cxx @@ -11,7 +11,7 @@ TrigScintDQM::TrigScintDQM(const std::string &name, framework::Process &process) TrigScintDQM::~TrigScintDQM() {} void TrigScintDQM::onProcessStart() { - std::cout << "Process starts!" << std::endl; + ldmx_log(debug) << "Process starts!"; getHistoDirectory(); @@ -42,8 +42,8 @@ void TrigScintDQM::configure(framework::config::Parameters &ps) { hitCollectionName_ = ps.getParameter("hit_collection"); padName_ = ps.getParameter("pad"); - std::cout << "In TrigScintDQM::configure, got parameters " - << hitCollectionName_ << " and " << padName_ << std::endl; + ldmx_log(debug) << "In TrigScintDQM::configure, got parameters " + << hitCollectionName_ << " and " << padName_; } void TrigScintDQM::analyze(const framework::Event &event) { diff --git a/DQM/src/DQM/TrigScintHitDQM.cxx b/DQM/src/DQM/TrigScintHitDQM.cxx index 6c32b65e7..9548ad0ca 100644 --- a/DQM/src/DQM/TrigScintHitDQM.cxx +++ b/DQM/src/DQM/TrigScintHitDQM.cxx @@ -9,7 +9,7 @@ TrigScintHitDQM::TrigScintHitDQM(const std::string &name, TrigScintHitDQM::~TrigScintHitDQM() {} void TrigScintHitDQM::onProcessStart() { - std::cout << "Process starts!" << std::endl; + ldmx_log(debug) << "Process starts!"; getHistoDirectory(); @@ -49,8 +49,8 @@ void TrigScintHitDQM::configure(framework::config::Parameters &ps) { hitCollectionName_ = ps.getParameter("hit_collection"); padName_ = ps.getParameter("pad").c_str(); - std::cout << "In TrigScintHitDQM::configure, got parameters " - << hitCollectionName_ << " and " << padName_ << std::endl; + ldmx_log(debug) << "In TrigScintHitDQM::configure, got parameters " + << hitCollectionName_ << " and " << padName_; } void TrigScintHitDQM::analyze(const framework::Event &event) { diff --git a/SimCore/include/SimCore/DetectorConstruction.h b/SimCore/include/SimCore/DetectorConstruction.h index 642e1f53f..72dbf72f4 100644 --- a/SimCore/include/SimCore/DetectorConstruction.h +++ b/SimCore/include/SimCore/DetectorConstruction.h @@ -73,6 +73,9 @@ class DetectorConstruction : public G4VUserDetectorConstruction { /// interface to conditions to be passed to SDs simcore::ConditionsInterface &conditions_interface_; + + /// Enable logging + enableLogging("DetectorConstruction") }; // DetectorConstruction } // namespace simcore diff --git a/SimCore/include/SimCore/ParallelWorld.h b/SimCore/include/SimCore/ParallelWorld.h index 55c7ad8b9..2ead9122b 100644 --- a/SimCore/include/SimCore/ParallelWorld.h +++ b/SimCore/include/SimCore/ParallelWorld.h @@ -45,6 +45,9 @@ class ParallelWorld : public G4VUserParallelWorld { /** The auxiliary GDML info reader. */ geo::AuxInfoReader* auxInfoReader_{nullptr}; + /// Enable logging + enableLogging("ParallelWorld") + }; // ParallelWorld } // namespace simcore diff --git a/SimCore/src/SimCore/DetectorConstruction.cxx b/SimCore/src/SimCore/DetectorConstruction.cxx index a40e08761..4742a48c1 100644 --- a/SimCore/src/SimCore/DetectorConstruction.cxx +++ b/SimCore/src/SimCore/DetectorConstruction.cxx @@ -138,9 +138,8 @@ void DetectorConstruction::ConstructSDandField() { // attach to volumes for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) { if (sd->isSensDet(volume)) { - std::cout << "[ DetectorConstruction ] : " - << "Attaching " << sd->GetName() << " to " - << volume->GetName() << std::endl; + ldmx_log(debug) << "Attaching " << sd->GetName() << " to " + << volume->GetName(); volume->SetSensitiveDetector(sd); } } @@ -149,7 +148,7 @@ void DetectorConstruction::ConstructSDandField() { // Biasing operators were created in RunManager::setupPhysics // which is called before G4RunManager::Initialize // which is where this method ends up being called. - simcore::XsecBiasingOperator::Factory::get().apply([](auto bop) { + simcore::XsecBiasingOperator::Factory::get().apply([&](auto bop) { logical_volume_tests::Test includeVolumeTest{nullptr}; if (bop->getVolumeToBias().compare("ecal") == 0) { includeVolumeTest = &logical_volume_tests::isInEcal; @@ -173,9 +172,8 @@ void DetectorConstruction::ConstructSDandField() { auto volume_name = volume->GetName(); if (includeVolumeTest(volume, bop->getVolumeToBias())) { bop->AttachTo(volume); - std::cout << "[ DetectorConstruction ]: " - << "Attaching biasing operator " << bop->GetName() - << " to volume " << volume->GetName() << std::endl; + ldmx_log(debug) << "Attaching biasing operator " << bop->GetName() + << " to volume " << volume->GetName(); } // BOP attached to target or ecal } // loop over volumes }); // loop over biasing operators diff --git a/SimCore/src/SimCore/ParallelWorld.cxx b/SimCore/src/SimCore/ParallelWorld.cxx index 7e03e8f95..1ed58a4d6 100644 --- a/SimCore/src/SimCore/ParallelWorld.cxx +++ b/SimCore/src/SimCore/ParallelWorld.cxx @@ -24,8 +24,8 @@ void ParallelWorld::ConstructSD() { for (int index = 0; index < parallelWorldLogical->GetNoDaughters(); index++) { G4VPhysicalVolume *physicalVol = parallelWorldLogical->GetDaughter(index); - std::cout << "[ ParallelWorld ]: Adding : " << physicalVol->GetName() - << " to parallel world." << std::endl; + ldmx_log(debug) << "Adding : " << physicalVol->GetName() + << " to parallel world."; worldLogical->AddDaughter(physicalVol); }