Loading code/MongoOutput_XYZ.cc +34 −10 Original line number Diff line number Diff line Loading @@ -69,6 +69,24 @@ MongoOutput_XYZ::~MongoOutput_XYZ() { } bool MongoOutput_XYZ::init() { gm.config->readInto(writeToMongoDB, "IO.FILETYPE.MONGODB.WriteToServer"); auto now = chrono::system_clock::now(); auto t = chrono::system_clock::to_time_t(now); stringstream ss; ss << "bson_output_" << hash<std::thread::id>{}(this_thread::get_id()) << "_" << put_time(localtime(&t), "%Y%m%d%H%M%S") << ".bson"; local_bson_filename = ss.str(); if (!writeToMongoDB) { bson_local_file.open(local_bson_filename, ios::binary); if (!bson_local_file) { cerr << "Failed to open BSON output file: " << local_bson_filename << endl; return false; } } cout << "MongoDB init end" << endl; return true; } Loading Loading @@ -181,16 +199,7 @@ void MongoOutput_XYZ::writeData(CXYZHit* hitting, G4int i) { gtime_exit = time; //18 // Construct MongoDB document from data //auto client = pool.acquire(); // Get thread-safe client //auto database = (*client)[database_name]; outputXYZCollectionNameMongoDB_base = (char*)gm.GetOutputMongoXYZCollectionName().data(); //collection = database[outputXYZCollectionNameMongoDB_base]; //auto client = pool.acquire(); //auto database = client[database_name]; auto client = pool.acquire(); // Get thread-safe client auto database = (*client)[database_name]; auto collection = database[outputXYZCollectionNameMongoDB_base]; bsoncxx::builder::basic::document doc{}; doc.append(kvp("EVT_ID", std::to_string(evtid))); Loading Loading @@ -222,16 +231,31 @@ void MongoOutput_XYZ::writeData(CXYZHit* hitting, G4int i) { doc.append(kvp("PROCESS_NAME", tprocname)); if (!doc.view().empty()) { if (writeToMongoDB) { auto client = pool.acquire(); // Get thread-safe client auto database = (*client)[database_name]; auto collection = database[outputXYZCollectionNameMongoDB_base]; collection.insert_one(doc.view()); } else { if (bson_local_file.is_open()) { auto view = doc.view(); bson_local_file.write(reinterpret_cast<const char*>(view.data()), view.length()); } } } else { cerr << "Error: Empty BSON document" << endl; } nrows_file++; } } bool MongoOutput_XYZ::close() { if (!writeToMongoDB && bson_local_file.is_open()) { bson_local_file.close(); cout << "Local BSON file written: " << local_bson_filename << endl; } cout << "MongoDB: closing connection" << endl; return true; } Loading code/MongoOutput_XYZ.hh +4 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,10 @@ public: mongocxx::pool pool{uri}; bool writeToMongoDB; // true = upload, false = write local file only ofstream bson_local_file; string local_bson_filename; protected: long lastevent; Loading code/bogemms.cc +15 −2 Original line number Diff line number Diff line Loading @@ -106,7 +106,14 @@ int main( int argc, char** argv ) { visManager->Initialize(); //Initialize G4 kernel G4bool initialize_in_run = 0; gm.config->readInto(initialize_in_run, "RUN.INITIALIZE.IN.RUN"); cout << "RUN.INITIALIZE.IN.RUN: " << initialize_in_run << endl; if (!initialize_in_run) { runManager->Initialize(); } cout << argc << endl; } Loading Loading @@ -142,7 +149,13 @@ int main( int argc, char** argv ) { visManager->Initialize(); //Initialize G4 kernel G4bool initialize_in_run = 0; gm.config->readInto(initialize_in_run, "RUN.INITIALIZE.IN.RUN"); cout << "RUN.INITIALIZE.IN.RUN: " << initialize_in_run << endl; if (!initialize_in_run) { runManager->Initialize(); } //cout << argc << endl; } Loading phys/AREMBESPhys.cc +7 −5 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ #include "G4OpticalParameters.hh" #include "G4OpticalPhysics.hh" #include "G4EmModelActivator.hh" AREMBESPhys::AREMBESPhys() : fMessenger(nullptr), emAREMBESPhys(nullptr), decAREMBESPhys(nullptr) { Loading Loading @@ -116,10 +118,9 @@ AREMBESPhys::AREMBESPhys() : fMessenger(nullptr), emAREMBESPhys(nullptr), decARE AddPhysicsList(hadronname); gm.config->readInto(SS_physics, "SPL.SSPHYS.ACTIVATE"); G4cout << "SPL.SSPHYS.ACTIVATE: " << SS_physics << G4endl; // activating specific parameters for the SS physics list gm.config->readInto(SS_physics, "AREMBESPhys.SSPHYS.ACTIVATE"); G4cout << "AREMBESPhys.SSPHYS.ACTIVATE: " << SS_physics << G4endl; } Loading Loading @@ -150,6 +151,7 @@ void AREMBESPhys::ConstructParticle() void AREMBESPhys::ConstructProcess() { AddTransportation(); emAREMBESPhys->ConstructProcess(); decAREMBESPhys->ConstructProcess(); Loading @@ -162,7 +164,6 @@ void AREMBESPhys::ConstructProcess() hadronAREMBESPhys[i]->ConstructProcess(); } G4EmParameters* param = G4EmParameters::Instance(); if (SS_physics) { Loading @@ -179,6 +180,7 @@ void AREMBESPhys::ConstructProcess() param->SetMuHadLateralDisplacement(false); // v11 update param->SetBremsstrahlungTh(10*TeV); // v11 update //param->SetDeexActiveRegion("InnerRegion", true, true, true); } Loading phys/PhysicsListMessenger.cc +0 −14 Original line number Diff line number Diff line Loading @@ -22,20 +22,6 @@ // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // Copyright 2025 Valentina Fioretti // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ********************************************************************** // /// \file electromagnetic/TestEm9/src/PhysicsListMessenger.cc /// \brief Implementation of the PhysicsListMessenger class Loading Loading
code/MongoOutput_XYZ.cc +34 −10 Original line number Diff line number Diff line Loading @@ -69,6 +69,24 @@ MongoOutput_XYZ::~MongoOutput_XYZ() { } bool MongoOutput_XYZ::init() { gm.config->readInto(writeToMongoDB, "IO.FILETYPE.MONGODB.WriteToServer"); auto now = chrono::system_clock::now(); auto t = chrono::system_clock::to_time_t(now); stringstream ss; ss << "bson_output_" << hash<std::thread::id>{}(this_thread::get_id()) << "_" << put_time(localtime(&t), "%Y%m%d%H%M%S") << ".bson"; local_bson_filename = ss.str(); if (!writeToMongoDB) { bson_local_file.open(local_bson_filename, ios::binary); if (!bson_local_file) { cerr << "Failed to open BSON output file: " << local_bson_filename << endl; return false; } } cout << "MongoDB init end" << endl; return true; } Loading Loading @@ -181,16 +199,7 @@ void MongoOutput_XYZ::writeData(CXYZHit* hitting, G4int i) { gtime_exit = time; //18 // Construct MongoDB document from data //auto client = pool.acquire(); // Get thread-safe client //auto database = (*client)[database_name]; outputXYZCollectionNameMongoDB_base = (char*)gm.GetOutputMongoXYZCollectionName().data(); //collection = database[outputXYZCollectionNameMongoDB_base]; //auto client = pool.acquire(); //auto database = client[database_name]; auto client = pool.acquire(); // Get thread-safe client auto database = (*client)[database_name]; auto collection = database[outputXYZCollectionNameMongoDB_base]; bsoncxx::builder::basic::document doc{}; doc.append(kvp("EVT_ID", std::to_string(evtid))); Loading Loading @@ -222,16 +231,31 @@ void MongoOutput_XYZ::writeData(CXYZHit* hitting, G4int i) { doc.append(kvp("PROCESS_NAME", tprocname)); if (!doc.view().empty()) { if (writeToMongoDB) { auto client = pool.acquire(); // Get thread-safe client auto database = (*client)[database_name]; auto collection = database[outputXYZCollectionNameMongoDB_base]; collection.insert_one(doc.view()); } else { if (bson_local_file.is_open()) { auto view = doc.view(); bson_local_file.write(reinterpret_cast<const char*>(view.data()), view.length()); } } } else { cerr << "Error: Empty BSON document" << endl; } nrows_file++; } } bool MongoOutput_XYZ::close() { if (!writeToMongoDB && bson_local_file.is_open()) { bson_local_file.close(); cout << "Local BSON file written: " << local_bson_filename << endl; } cout << "MongoDB: closing connection" << endl; return true; } Loading
code/MongoOutput_XYZ.hh +4 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,10 @@ public: mongocxx::pool pool{uri}; bool writeToMongoDB; // true = upload, false = write local file only ofstream bson_local_file; string local_bson_filename; protected: long lastevent; Loading
code/bogemms.cc +15 −2 Original line number Diff line number Diff line Loading @@ -106,7 +106,14 @@ int main( int argc, char** argv ) { visManager->Initialize(); //Initialize G4 kernel G4bool initialize_in_run = 0; gm.config->readInto(initialize_in_run, "RUN.INITIALIZE.IN.RUN"); cout << "RUN.INITIALIZE.IN.RUN: " << initialize_in_run << endl; if (!initialize_in_run) { runManager->Initialize(); } cout << argc << endl; } Loading Loading @@ -142,7 +149,13 @@ int main( int argc, char** argv ) { visManager->Initialize(); //Initialize G4 kernel G4bool initialize_in_run = 0; gm.config->readInto(initialize_in_run, "RUN.INITIALIZE.IN.RUN"); cout << "RUN.INITIALIZE.IN.RUN: " << initialize_in_run << endl; if (!initialize_in_run) { runManager->Initialize(); } //cout << argc << endl; } Loading
phys/AREMBESPhys.cc +7 −5 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ #include "G4OpticalParameters.hh" #include "G4OpticalPhysics.hh" #include "G4EmModelActivator.hh" AREMBESPhys::AREMBESPhys() : fMessenger(nullptr), emAREMBESPhys(nullptr), decAREMBESPhys(nullptr) { Loading Loading @@ -116,10 +118,9 @@ AREMBESPhys::AREMBESPhys() : fMessenger(nullptr), emAREMBESPhys(nullptr), decARE AddPhysicsList(hadronname); gm.config->readInto(SS_physics, "SPL.SSPHYS.ACTIVATE"); G4cout << "SPL.SSPHYS.ACTIVATE: " << SS_physics << G4endl; // activating specific parameters for the SS physics list gm.config->readInto(SS_physics, "AREMBESPhys.SSPHYS.ACTIVATE"); G4cout << "AREMBESPhys.SSPHYS.ACTIVATE: " << SS_physics << G4endl; } Loading Loading @@ -150,6 +151,7 @@ void AREMBESPhys::ConstructParticle() void AREMBESPhys::ConstructProcess() { AddTransportation(); emAREMBESPhys->ConstructProcess(); decAREMBESPhys->ConstructProcess(); Loading @@ -162,7 +164,6 @@ void AREMBESPhys::ConstructProcess() hadronAREMBESPhys[i]->ConstructProcess(); } G4EmParameters* param = G4EmParameters::Instance(); if (SS_physics) { Loading @@ -179,6 +180,7 @@ void AREMBESPhys::ConstructProcess() param->SetMuHadLateralDisplacement(false); // v11 update param->SetBremsstrahlungTh(10*TeV); // v11 update //param->SetDeexActiveRegion("InnerRegion", true, true, true); } Loading
phys/PhysicsListMessenger.cc +0 −14 Original line number Diff line number Diff line Loading @@ -22,20 +22,6 @@ // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // Copyright 2025 Valentina Fioretti // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ********************************************************************** // /// \file electromagnetic/TestEm9/src/PhysicsListMessenger.cc /// \brief Implementation of the PhysicsListMessenger class Loading