From 6a9d16b9e50545f614dd5d73b567095202a92ee5 Mon Sep 17 00:00:00 2001 From: Lorenzo Pezzotti Date: Mon, 4 Sep 2023 11:54:58 +0200 Subject: [PATCH 1/2] Use IsMaster() in BeginOfRunAction Do not use it in constructor as IsMaster() does not return a correct value until that RunAction object is set to a RunManager. --- src/ATLTileCalTBRunAction.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ATLTileCalTBRunAction.cc b/src/ATLTileCalTBRunAction.cc index ba59125..50f820c 100644 --- a/src/ATLTileCalTBRunAction.cc +++ b/src/ATLTileCalTBRunAction.cc @@ -45,18 +45,6 @@ ATLTileCalTBRunAction::ATLTileCalTBRunAction( ATLTileCalTBEventAction* eventActi // auto analysisManager = G4AnalysisManager::Instance(); - //Print useful information - // - if (IsMaster()) { - G4cout << "Using " << analysisManager->GetType() << G4endl; - #ifdef ATLTileCalTB_PulseOutput - G4cout << "Creating pulse plots" << G4endl; - #endif - #ifdef ATLTileCalTB_NoNoise - G4cout << "Electronic noise disabled" << G4endl; - #endif - } - analysisManager->SetVerboseLevel(1); analysisManager->SetNtupleMerging(true); @@ -98,6 +86,18 @@ void ATLTileCalTBRunAction::BeginOfRunAction(const G4Run* run) { auto analysisManager = G4AnalysisManager::Instance(); + //Print useful information + // + if (IsMaster()) { + G4cout << "Using " << analysisManager->GetType() << G4endl; + #ifdef ATLTileCalTB_PulseOutput + G4cout << "Creating pulse plots" << G4endl; + #endif + #ifdef ATLTileCalTB_NoNoise + G4cout << "Electronic noise disabled" << G4endl; + #endif + } + std::string runnumber = std::to_string( run->GetRunID() ); G4String fileName = "ATLTileCalTBout_Run" + runnumber + ".root"; analysisManager->OpenFile(fileName); From 293d98a39c6170289798f367f71695720bbc24e3 Mon Sep 17 00:00:00 2001 From: Lorenzo Pezzotti Date: Mon, 4 Sep 2023 14:03:47 +0200 Subject: [PATCH 2/2] Move AnalysisManager::GetType() after name setting Move GetType() call after having set the file output name. However, this does not fix the empty string returned problem. --- src/ATLTileCalTBRunAction.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ATLTileCalTBRunAction.cc b/src/ATLTileCalTBRunAction.cc index 50f820c..f9f3f74 100644 --- a/src/ATLTileCalTBRunAction.cc +++ b/src/ATLTileCalTBRunAction.cc @@ -86,6 +86,10 @@ void ATLTileCalTBRunAction::BeginOfRunAction(const G4Run* run) { auto analysisManager = G4AnalysisManager::Instance(); + std::string runnumber = std::to_string( run->GetRunID() ); + G4String fileName = "ATLTileCalTBout_Run" + runnumber + ".root"; + analysisManager->OpenFile(fileName); + //Print useful information // if (IsMaster()) { @@ -98,10 +102,6 @@ void ATLTileCalTBRunAction::BeginOfRunAction(const G4Run* run) { #endif } - std::string runnumber = std::to_string( run->GetRunID() ); - G4String fileName = "ATLTileCalTBout_Run" + runnumber + ".root"; - analysisManager->OpenFile(fileName); - auto pulse_run_path = std::filesystem::path("ATLTileCalTBpulse_Run" + runnumber); std::filesystem::remove_all(pulse_run_path); #ifdef ATLTileCalTB_PulseOutput