Skip to content

Commit

Permalink
Merge pull request next-exp#194 from paolafer/conf-pers
Browse files Browse the repository at this point in the history
Possibility of not specifying the persistency manager
  • Loading branch information
paolafer authored Jun 28, 2023
2 parents bc8a1d6 + 51a6865 commit 824237b
Show file tree
Hide file tree
Showing 43 changed files with 129 additions and 99 deletions.
2 changes: 1 addition & 1 deletion macros/DEMOPP_fullKr.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@


# PERSISTENCY
/nexus/persistency/outputFile out_Kr83.sim
/nexus/persistency/output_file out_Kr83.sim

/nexus/random_seed 14562
2 changes: 1 addition & 1 deletion macros/DEMOPP_grid.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


# PERSISTENCY
/nexus/persistency/outputFile DEMO_electron
/nexus/persistency/output_file DEMO_electron

/nexus/random_seed 14562

2 changes: 1 addition & 1 deletion macros/DEMOPP_plate.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@


# PERSISTENCY
/nexus/persistency/outputFile DEMO_electron
/nexus/persistency/output_file DEMO_electron

/nexus/random_seed 14562

2 changes: 1 addition & 1 deletion macros/DEMOPP_psf.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
/Geometry/NextDemo/el_gap_gen_disk_zmax 1.0

# PERSISTENCY
/nexus/persistency/outputFile demopp_psf_generation
/nexus/persistency/output_file demopp_psf_generation

/nexus/random_seed 12345
2 changes: 1 addition & 1 deletion macros/DEMO_muons.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
/PhysicsList/Nexus/electroluminescence false

# PERSISTENCY
/nexus/persistency/outputFile DEMO_muons.next
/nexus/persistency/output_file DEMO_muons.next
2 changes: 1 addition & 1 deletion macros/MagBox.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
/PhysicsList/Nexus/electroluminescence false

### PERSISTENCY
/nexus/persistency/outputFile output.next
/nexus/persistency/output_file output.next
4 changes: 2 additions & 2 deletions macros/NEW.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/PhysicsList/Nexus/electroluminescence false
/PhysicsList/Nexus/photoelectric false

/nexus/persistency/eventType background
/nexus/persistency/outputFile NextNew.Bi214.DICE_BOARD.next
/nexus/persistency/event_type background
/nexus/persistency/output_file NextNew.Bi214.DICE_BOARD.next

/process/em/verbose 0
2 changes: 1 addition & 1 deletion macros/NEW_2nuECEC.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@

/control/execute macros/physics/IonizationElectron.mac

/nexus/persistency/outputFile new_ecec.next
/nexus/persistency/output_file new_ecec.next

/nexus/random_seed 542862
2 changes: 1 addition & 1 deletion macros/NEW_S1_table.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
/control/execute macros/physics/IonizationElectron.mac

# PERSISTENCY
/nexus/persistency/outputFile S1_param.next
/nexus/persistency/output_file S1_param.next
2 changes: 1 addition & 1 deletion macros/NEW_S2_table.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@

/PhysicsList/Nexus/photoelectric false

/nexus/persistency/outputFile table.NEW.next
/nexus/persistency/output_file table.NEW.next
2 changes: 1 addition & 1 deletion macros/NEW_argon.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
/PhysicsList/Nexus/electroluminescence false
/PhysicsList/Nexus/photoelectric false

/nexus/persistency/outputFile New.Na22_Ar.next
/nexus/persistency/output_file New.Na22_Ar.next
2 changes: 1 addition & 1 deletion macros/NEW_elgap.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

/nexus/random_seed 1
/nexus/persistency/start_id 0
/nexus/persistency/outputFile new_elgap.nexus
/nexus/persistency/output_file new_elgap.nexus
2 changes: 1 addition & 1 deletion macros/NEW_fullKr.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
/Generator/Kr83mGenerator/region ACTIVE

# PERSISTENCY
/nexus/persistency/outputFile Kr83_full_nexus_ACTIVE_7bar.sim
/nexus/persistency/output_file Kr83_full_nexus_ACTIVE_7bar.sim
2 changes: 1 addition & 1 deletion macros/NEW_geantino.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
# GEOMETRY
/Geometry/NextNew/pressure 10. bar

/nexus/persistency/outputFile geantinos.next
/nexus/persistency/output_file geantinos.next
4 changes: 2 additions & 2 deletions macros/NEW_hallA.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
/PhysicsList/Nexus/drift false
/PhysicsList/Nexus/electroluminescence false

/nexus/persistency/eventType background
/nexus/persistency/outputFile NextNew.HALLA_INNER.next
/nexus/persistency/event_type background
/nexus/persistency/output_file NextNew.HALLA_INNER.next
2 changes: 1 addition & 1 deletion macros/NEW_optical.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

/control/execute macros/physics/IonizationElectron.mac

/nexus/persistency/outputFile myoutput.next
/nexus/persistency/output_file myoutput.next
2 changes: 1 addition & 1 deletion macros/NEW_pair.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@

/control/execute macros/physics/IonizationElectron.mac

/nexus/persistency/outputFile myoutput.next
/nexus/persistency/output_file myoutput.next
2 changes: 1 addition & 1 deletion macros/NEW_translated_bb0nu.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@

/control/execute macros/physics/IonizationElectron.mac

/nexus/persistency/outputFile bb0_GS_mode1_S1L1f.next
/nexus/persistency/output_file bb0_GS_mode1_S1L1f.next
4 changes: 2 additions & 2 deletions macros/NEXT100.Neutron.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
/PhysicsList/Nexus/electroluminescence false

##### PERSISTENCY #####
/nexus/persistency/eventType background
/nexus/persistency/outputFile Next100.Neutron.next
/nexus/persistency/event_type background
/nexus/persistency/output_file Next100.Neutron.next
4 changes: 2 additions & 2 deletions macros/NEXT100.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
/PhysicsList/Nexus/electroluminescence false

##### PERSISTENCY #####
/nexus/persistency/outputFile Next100.next
/nexus/persistency/output_file Next100.next
## eventType options: bb0nu, bb2nu, background
/nexus/persistency/eventType background
/nexus/persistency/event_type background
2 changes: 1 addition & 1 deletion macros/NEXT100_S1_table.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@

# PHYSICS
/control/execute macros/physics/IonizationElectron.mac
/nexus/persistency/outputFile S1_param.next
/nexus/persistency/output_file S1_param.next
2 changes: 1 addition & 1 deletion macros/NEXT100_S2_table.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
/Generator/ScintGenerator/region AD_HOC

#### PERSISTENCY ####
/nexus/persistency/outputFile Next100_X_0_Y_0_Z_0.next
/nexus/persistency/output_file Next100_X_0_Y_0_Z_0.next
25 changes: 25 additions & 0 deletions macros/NEXT100_debug.config.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## ----------------------------------------------------------------------------
## nexus | NEXT100_debug.config.mac
##
## Initialization macro to simulate geantinos crossing the NEXT-100 detector.
## It is useful to debug the geometry.
##
## The NEXT Collaboration
## ----------------------------------------------------------------------------

##### VERBOSITY #####
/run/verbose 0
/event/verbose 0
/tracking/verbose 0

/process/em/verbose 0

##### GEOMETRY #####
/Geometry/Next100/specific_vertex 5 5 0 mm

##### GENERATOR #####
/Generator/SingleParticle/particle e-
/Generator/SingleParticle/min_energy 100 keV
/Generator/SingleParticle/max_energy 100 keV
/Generator/SingleParticle/region AD_HOC
/Generator/SingleParticle/momentum 0 0 1
20 changes: 20 additions & 0 deletions macros/NEXT100_debug.init.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## ----------------------------------------------------------------------------
## nexus | NEXT100_debug.init.mac
##
## Initialization macro to simulate geantinos crossing the NEXT-100 detector.
## It is useful to debug the geometry.
##
## The NEXT Collaboration
## ----------------------------------------------------------------------------

/PhysicsList/RegisterPhysics G4EmStandardPhysics_option4
/PhysicsList/RegisterPhysics G4DecayPhysics
/PhysicsList/RegisterPhysics G4RadioactiveDecayPhysics
/PhysicsList/RegisterPhysics NexusPhysics
/PhysicsList/RegisterPhysics G4StepLimiterPhysics

/nexus/RegisterGeometry Next100

/nexus/RegisterGenerator SingleParticleGenerator

/nexus/RegisterMacro macros/NEXT100_debug.config.mac
2 changes: 1 addition & 1 deletion macros/NEXT100_full.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
/Generator/Kr83mGenerator/region ACTIVE

##### PERSISTENCY #####
/nexus/persistency/outputFile Next100_full.next
/nexus/persistency/output_file Next100_full.next
2 changes: 1 addition & 1 deletion macros/NEXT100_muons.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@

### PERSISTENCY
/nexus/persistency/start_id 0
/nexus/persistency/outputFile Next100Muons_example.next
/nexus/persistency/output_file Next100Muons_example.next
4 changes: 2 additions & 2 deletions macros/NEXT_options.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@

##### PERSISTENCY #####
/nexus/persistency/start_id 1000
/nexus/persistency/outputFile Next100.next
/nexus/persistency/eventType background # bb0nu, bb2nu...
/nexus/persistency/output_file Next100.next
/nexus/persistency/event_type background # bb0nu, bb2nu...
2 changes: 1 addition & 1 deletion macros/NextFlex_fullKr.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@
### CONTROL
/nexus/random_seed -1
/nexus/persistency/start_id 0
/nexus/persistency/outputFile NextFlex.next
/nexus/persistency/output_file NextFlex.next
2 changes: 1 addition & 1 deletion macros/NextTonScale.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@

### PERSISTENCY
/nexus/persistency/start_id 0
/nexus/persistency/outputFile NextTon.next
/nexus/persistency/output_file NextTon.next
2 changes: 1 addition & 1 deletion macros/black_box.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
### JOB CONTROL
/nexus/random_seed -1
/nexus/persistency/start_id 0
/nexus/persistency/outputFile black_box.next
/nexus/persistency/output_file black_box.next
2 changes: 1 addition & 1 deletion macros/calibration/NEW_disk_source.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@
/PhysicsList/Nexus/electroluminescence false

# Persistency
/nexus/persistency/outputFile New.source.next
/nexus/persistency/output_file New.source.next
2 changes: 1 addition & 1 deletion macros/calibration/NEW_external_source.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
/PhysicsList/Nexus/electroluminescence false

# Persistency
/nexus/persistency/outputFile New.source.next
/nexus/persistency/output_file New.source.next
2 changes: 1 addition & 1 deletion macros/calibration/NEW_internal_source.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
/PhysicsList/Nexus/electroluminescence false

# Persistency
/nexus/persistency/outputFile New.source.next
/nexus/persistency/output_file New.source.next
2 changes: 1 addition & 1 deletion macros/nexus_example1.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

/control/execute macros/physics/IonizationElectron.mac

/nexus/persistency/outputFile nexus.next
/nexus/persistency/output_file nexus.next
2 changes: 1 addition & 1 deletion macros/nexus_example3.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@

/control/execute macros/physics/IonizationElectron.mac

/nexus/persistency/outputFile nexus.next
/nexus/persistency/output_file nexus.next
2 changes: 1 addition & 1 deletion macros/ton_muons_vertical.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@

### PERSISTENCY
/nexus/persistency/start_id 0
/nexus/persistency/outputFile TonMuons_vertical_example.next
/nexus/persistency/output_file TonMuons_vertical_example.next
4 changes: 2 additions & 2 deletions macros/validation/NEW_valid_isotope.config.mac
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@
/Actions/ValidationTrackingAction/valid_file NEW_valid.isotope.DICE_BOARD.csv

# PERSISTENCY
/nexus/persistency/eventType background
/nexus/persistency/outputFile NEW_valid.isotope.DICE_BOARD.next
/nexus/persistency/event_type background
/nexus/persistency/output_file NEW_valid.isotope.DICE_BOARD.next
36 changes: 21 additions & 15 deletions source/base/NexusApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ NexusApp::NexusApp(G4String init_macro): G4RunManager(), gen_name_(""),
geo_name_(""), pm_name_(""),
runact_name_(""), evtact_name_(""),
stepact_name_(""), trkact_name_(""),
stkact_name_("")
stkact_name_(""), pman_(false)
{
// Create and configure a generic messenger for the app
msg_ = make_unique<G4GenericMessenger>(this, "/nexus/", "Nexus control commands.");
Expand Down Expand Up @@ -91,50 +91,50 @@ NexusApp::NexusApp(G4String init_macro): G4RunManager(), gen_name_(""),

// Set the detector construction instance in the run manager
auto dc = make_unique<DetectorConstruction>();
if (geo_name_ == "") {
if (geo_name_.empty()) {
G4Exception("[NexusApp]", "NexusApp()", FatalException, "A geometry must be specified.");
}
dc->SetGeometry(ObjFactory<GeometryBase>::Instance().CreateObject(geo_name_));
this->SetUserInitialization(dc.release());

// Set the primary generation instance in the run manager
auto pg = make_unique<PrimaryGeneration>();
if (gen_name_ == "") {
if (gen_name_.empty()) {
G4Exception("[NexusApp]", "NexusApp()", FatalException, "A generator must be specified.");
}
pg->SetGenerator(ObjFactory<G4VPrimaryGenerator>::Instance().CreateObject(gen_name_));
this->SetUserAction(pg.release());

if (pm_name_ == "") {
G4Exception("[NexusApp]", "NexusApp()", FatalException, "A persistency manager must be specified.");
}
pm_ = ObjFactory<PersistencyManagerBase>::Instance().CreateObject(pm_name_);
pm_->SetMacros(init_macro, macros_, delayed_);

// PersistencyManager::Initialize(init_macro, macros_, delayed_);
// Set the persistency manager, if needed
if (!pm_name_.empty()) {
pm_ = ObjFactory<PersistencyManagerBase>::Instance().CreateObject(pm_name_);
pm_->SetMacros(init_macro, macros_, delayed_);
pman_ = true;
}

// Set the user action instances, if any, in the run manager
if (runact_name_ != "") {
if (!runact_name_.empty()) {
auto runact = ObjFactory<G4UserRunAction>::Instance().CreateObject(runact_name_);
this->SetUserAction(runact.release());
}

if (evtact_name_ != "") {
if (!evtact_name_.empty()) {
auto evtact = ObjFactory<G4UserEventAction>::Instance().CreateObject(evtact_name_);
this->SetUserAction(evtact.release());
}

if (stkact_name_ != "") {
if (!stkact_name_.empty()) {
auto stkact = ObjFactory<G4UserStackingAction>::Instance().CreateObject(stkact_name_);
this->SetUserAction(stkact.release());
}

if (trkact_name_ != "") {
if (!trkact_name_.empty()) {
auto trkact = ObjFactory<G4UserTrackingAction>::Instance().CreateObject(trkact_name_);
this->SetUserAction(trkact.release());
}

if (stepact_name_ != "") {
if (!stepact_name_.empty()) {
auto stepact = ObjFactory<G4UserSteppingAction>::Instance().CreateObject(stepact_name_);
this->SetUserAction(stepact.release());
}
Expand All @@ -153,7 +153,9 @@ NexusApp::NexusApp(G4String init_macro): G4RunManager(), gen_name_(""),
NexusApp::~NexusApp()
{
// Close output file before finishing
pm_->CloseFile();
if (pman_) {
pm_->CloseFile();
}
}


Expand Down Expand Up @@ -186,6 +188,10 @@ void NexusApp::Initialize()

G4RunManager::Initialize();

if (pman_) {
pm_->OpenFile();
}

for (unsigned int j=0; j<delayed_.size(); j++) {
ExecuteMacroFile(delayed_[j].data());
}
Expand Down
2 changes: 2 additions & 0 deletions source/base/NexusApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ namespace nexus {
G4String trkact_name_; ///< Name of the chosen tracking action
G4String stkact_name_; ///< Name of the chosen stacking action

G4bool pman_; ///< True if the persistency manager is set

std::vector<G4String> macros_;
std::vector<G4String> delayed_;

Expand Down
Loading

0 comments on commit 824237b

Please sign in to comment.