Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -80,9 +80,7 @@
#include "Randomize.hh"
#include "G4StateManager.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4RunManagerFactory.hh"
#include "G4Run.hh"
#include "G4Transform3D.hh"
#include "G4AttHolder.hh"
@@ -657,23 +655,24 @@ void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid)
}
}
void G4VSceneHandler::ProcessScene () {
void G4VSceneHandler::ProcessScene()
{
// Assumes graphics database store has already been cleared if
// relevant for the particular scene handler.
if (!fpScene) return;
if(!fpScene)
return;
if (fpScene->GetExtent() == G4VisExtent::GetNullExtent()) {
G4Exception
("G4VSceneHandler::ProcessScene",
"visman0106", JustWarning,
"The scene has no extent.");
if(fpScene->GetExtent() == G4VisExtent::GetNullExtent())
{
G4Exception("G4VSceneHandler::ProcessScene", "visman0106", JustWarning,
"The scene has no extent.");
}
G4VisManager* visManager = G4VisManager::GetInstance();
if (!visManager->GetConcreteInstance()) return;
if(!visManager->GetConcreteInstance())
return;
G4VisManager::Verbosity verbosity = visManager->GetVerbosity();
@@ -683,40 +682,44 @@ void G4VSceneHandler::ProcessScene () {
// fMarkForClearingTransientStore true causes problems with
// recomputing transients below.) Restore it again at end...
G4bool tmpMarkForClearingTransientStore = fMarkForClearingTransientStore;
fMarkForClearingTransientStore = false;
fMarkForClearingTransientStore = false;
// Traverse geometry tree and send drawing primitives to window(s).
const std::vector<G4Scene::Model>& runDurationModelList =
fpScene -> GetRunDurationModelList ();
fpScene->GetRunDurationModelList();
if (runDurationModelList.size ()) {
if (verbosity >= G4VisManager::confirmations) {
if(runDurationModelList.size())
{
if(verbosity >= G4VisManager::confirmations)
{
G4cout << "Traversing scene data..." << G4endl;
}
BeginModeling ();
BeginModeling();
// Create modeling parameters from view parameters...
G4ModelingParameters* pMP = CreateModelingParameters ();
G4ModelingParameters* pMP = CreateModelingParameters();
for (size_t i = 0; i < runDurationModelList.size (); i++) {
if (runDurationModelList[i].fActive) {
for(size_t i = 0; i < runDurationModelList.size(); i++)
{
if(runDurationModelList[i].fActive)
{
fpModel = runDurationModelList[i].fpModel;
// Note: this is not the place to take action on
// pModel->GetTransformation(). The model must take care of
// this in pModel->DescribeYourselfTo(*this). See, for example,
// G4PhysicalVolumeModel and /vis/scene/add/logo.
fpModel -> SetModelingParameters (pMP);
fpModel -> DescribeYourselfTo (*this);
fpModel -> SetModelingParameters (0);
// Note: this is not the place to take action on
// pModel->GetTransformation(). The model must take care of
// this in pModel->DescribeYourselfTo(*this). See, for example,
// G4PhysicalVolumeModel and /vis/scene/add/logo.
fpModel->SetModelingParameters(pMP);
fpModel->DescribeYourselfTo(*this);
fpModel->SetModelingParameters(0);
}
}
fpModel = 0;
delete pMP;
EndModeling ();
EndModeling();
}
fReadyForTransients = true;
@@ -724,57 +727,64 @@ void G4VSceneHandler::ProcessScene () {
// Refresh event from end-of-event model list.
// Allow only in Idle or GeomClosed state...
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState state = stateManager->GetCurrentState();
if (state == G4State_Idle || state == G4State_GeomClosed) {
G4ApplicationState state = stateManager->GetCurrentState();
if(state == G4State_Idle || state == G4State_GeomClosed)
{
visManager->SetEventRefreshing(true);
if (visManager->GetRequestedEvent()) {
if(visManager->GetRequestedEvent())
{
DrawEvent(visManager->GetRequestedEvent());
} else {
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if(G4Threading::IsMultithreadedApplication())
{ runManager = G4MTRunManager::GetMasterRunManager(); }
#endif
if (runManager) {
const G4Run* run = runManager->GetCurrentRun();
}
else
{
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
if(runManager)
{
const G4Run* run = runManager->GetCurrentRun();
const std::vector<const G4Event*>* events =
run? run->GetEventVector(): 0;
size_t nKeptEvents = 0;
if (events) nKeptEvents = events->size();
if (nKeptEvents) {
run ? run->GetEventVector() : 0;
size_t nKeptEvents = 0;
if(events)
nKeptEvents = events->size();
if(nKeptEvents)
{
if(fpScene->GetRefreshAtEndOfEvent())
{
if(verbosity >= G4VisManager::confirmations)
{
G4cout << "Refreshing event..." << G4endl;
}
const G4Event* event = 0;
if(events && events->size())
event = events->back();
if(event)
DrawEvent(event);
}
else
{ // Accumulating events.
if (fpScene->GetRefreshAtEndOfEvent()) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Refreshing event..." << G4endl;
}
const G4Event* event = 0;
if (events && events->size()) event = events->back();
if (event) DrawEvent(event);
} else { // Accumulating events.
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Refreshing events in run..." << G4endl;
}
for (const auto& event: *events) {
if (event) DrawEvent(event);
if(verbosity >= G4VisManager::confirmations)
{
G4cout << "Refreshing events in run..." << G4endl;
}
for(const auto& event : *events)
{
if(event)
DrawEvent(event);
}
if (!fpScene->GetRefreshAtEndOfRun()) {
if (verbosity >= G4VisManager::warnings) {
G4cout <<
"WARNING: Cannot refresh events accumulated over more"
"\n than one runs. Refreshed just the last run."
<< G4endl;
}
}
}
}
if(!fpScene->GetRefreshAtEndOfRun())
{
if(verbosity >= G4VisManager::warnings)
{
G4cout << "WARNING: Cannot refresh events accumulated over more"
"\n than one runs. Refreshed just the last run."
<< G4endl;
}
}
}
}
}
}
visManager->SetEventRefreshing(false);
@@ -782,7 +792,8 @@ void G4VSceneHandler::ProcessScene () {
// Refresh end-of-run model list.
// Allow only in Idle or GeomClosed state...
if (state == G4State_Idle || state == G4State_GeomClosed) {
if(state == G4State_Idle || state == G4State_GeomClosed)
{
DrawEndOfRunModels();
}
@@ -1147,7 +1158,7 @@ G4int G4VSceneHandler::GetNoOfSides(const G4VisAttributes* pVisAttribs)
lineSegmentsPerCircle = pVisAttribs->GetMinLineSegmentsPerCircle();
G4cout <<
"G4VSceneHandler::GetNoOfSides: attempt to set the"
"\nnumber of line segements per circle < " << lineSegmentsPerCircle
"\nnumber of line segments per circle < " << lineSegmentsPerCircle
<< "; forced to " << pVisAttribs->GetMinLineSegmentsPerCircle() << G4endl;
}
}
@@ -36,8 +36,6 @@
#include <sstream>
#include <cctype>
G4int G4VVisCommand::fErrorCode = 0;
G4int G4VVisCommand::fCurrentArrow3DLineSegmentsPerCircle = 6;
G4Colour G4VVisCommand::fCurrentColour = G4Colour::White();
G4Colour G4VVisCommand::fCurrentTextColour = G4Colour::Blue();
@@ -291,10 +289,8 @@ void G4VVisCommand::InterpolateViews
}
// File-writing viewers need to close the file
currentViewer->ShowView();
#ifdef G4VIS_USE_STD11
if (waitTimePerPointmilliseconds > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
#endif
} while (safetyCount++ < safety); // Loop checking, 16.02.2016, J.Allison
}
@@ -35,9 +35,7 @@
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4RunManagerFactory.hh"
#include "G4Run.hh"
#include "G4UIsession.hh"
#include "G4Trajectory.hh"
@@ -286,14 +284,11 @@ void G4VisCommandReviewKeptEvents::SetNewValue (G4UIcommand*, G4String newValue)
G4String& macroFileName = newValue;
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if(G4Threading::IsMultithreadedApplication())
{ runManager = G4MTRunManager::GetMasterRunManager(); }
#endif
const G4Run* run = runManager? runManager->GetCurrentRun(): 0;
const std::vector<const G4Event*>* events = run? run->GetEventVector(): 0;
size_t nKeptEvents = events? events->size(): 0;
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
const G4Run* run = runManager ? runManager->GetCurrentRun() : nullptr;
const std::vector<const G4Event*>* events =
run ? run->GetEventVector() : nullptr;
size_t nKeptEvents = events ? events->size() : 0;
if (!nKeptEvents) {
if (verbosity >= G4VisManager::errors) {
@@ -96,8 +96,8 @@ void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
G4bool keepAbleness = fpVisManager->GetConcreteInstance()? true: false;
UImanager->ApplyCommand(G4String("/vis/open " + system));
if (fErrorCode == 0) {
auto errorCode = UImanager->ApplyCommand(G4String("/vis/open " + system));
if (errorCode == 0) {
if (!keepAbleness) { // Enable temporarily
fpVisManager->SetVerboseLevel("Quiet");
UImanager->ApplyCommand("/vis/enable");
@@ -360,7 +360,7 @@ G4VisCommandOpen::~G4VisCommandOpen() {
delete fpCommand;
}
void G4VisCommandOpen::SetNewValue (G4UIcommand*, G4String newValue) {
void G4VisCommandOpen::SetNewValue (G4UIcommand* command, G4String newValue) {
G4String systemName, windowSizeHint;
std::istringstream is(newValue);
is >> systemName >> windowSizeHint;
@@ -371,8 +371,8 @@ void G4VisCommandOpen::SetNewValue (G4UIcommand*, G4String newValue) {
fpVisManager->GetVerbosity() >= G4VisManager::confirmations)
newVerbose = 2;
UImanager->SetVerboseLevel(newVerbose);
fErrorCode = UImanager->ApplyCommand(G4String("/vis/sceneHandler/create " + systemName));
if (fErrorCode == 0) {
auto errorCode = UImanager->ApplyCommand(G4String("/vis/sceneHandler/create " + systemName));
if (errorCode == 0) {
UImanager->ApplyCommand(G4String("/vis/viewer/create ! ! " + windowSizeHint));
} else {
// Use set to get alphabetical order
@@ -385,11 +385,13 @@ void G4VisCommandOpen::SetNewValue (G4UIcommand*, G4String newValue) {
}
}
}
G4cerr << "Candidates are:";
std::ostringstream oss;
oss << "Candidates are:";
for (const auto& candidate: candidates) {
G4cerr << ' ' << candidate;
}
G4cerr << G4endl;
oss << ' ' << candidate;
};
G4cerr << oss.str() << G4endl;
command->CommandFailed(oss);
}
UImanager->SetVerboseLevel(keepVerbose);
}
@@ -32,9 +32,7 @@
#include "G4VisManager.hh"
#include "G4TransportationManager.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4RunManagerFactory.hh"
#include "G4Run.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4ApplicationState.hh"
@@ -339,18 +337,16 @@ void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
fpVisManager->ResetTransientsDrawnFlags();
// Are there any events currently kept...
size_t nCurrentlyKept = 0;
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if(G4Threading::IsMultithreadedApplication())
{ runManager = G4MTRunManager::GetMasterRunManager(); }
#endif
if (runManager) {
size_t nCurrentlyKept = 0;
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
if(runManager)
{
const G4Run* currentRun = runManager->GetCurrentRun();
if (currentRun) {
const std::vector<const G4Event*>* events =
currentRun->GetEventVector();
if (events) nCurrentlyKept = events->size();
if(currentRun)
{
const std::vector<const G4Event*>* events = currentRun->GetEventVector();
if(events)
nCurrentlyKept = events->size();
}
}
@@ -768,9 +764,10 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
const G4int nViewers = viewerList.size ();
if (nViewers) {
pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
pCurrentViewer -> SetView ();
}
// JA: I don't think we need this. SetView will be called when needed.
// if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
// pCurrentViewer -> SetView ();
// }
}
}
}
@@ -61,9 +61,7 @@
#include "G4UIcmdWithAnInteger.hh"
#include "G4Tokenizer.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4RunManagerFactory.hh"
#include "G4StateManager.hh"
#include "G4Run.hh"
#include "G4Event.hh"
@@ -717,13 +715,9 @@ void G4VisCommandSceneAddEventID::SetNewValue (G4UIcommand*, G4String newValue)
void G4VisCommandSceneAddEventID::EventID::operator()
(G4VGraphicsScene& sceneHandler, const G4Transform3D&, const G4ModelingParameters* mp)
{
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
if (!runManager) return;
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
if(!runManager)
return;
const G4Run* currentRun = runManager->GetCurrentRun();
if (!currentRun) return;
@@ -197,7 +197,7 @@ G4String G4VisCommandSceneHandlerCreate::GetCurrentValue(G4UIcommand*) {
return graphicsSystemName + " " + NextName ();
}
void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
@@ -276,14 +276,15 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
}
}
if (iGS < 0 || iGS >= nSystems || loopCounter >=3) {
std::ostringstream oss;
oss << "\"" << gsl[iGSBeingTested]->GetNickname()
<< "\" is not compatible with your chosen session,"
" and no fallback system found.";
if (verbosity >= G4VisManager::errors) {
G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue: \""
<< gsl[iGSBeingTested]->GetNickname()
<< "\" is not compatible with your chosen session,"
" and no fallback system found."
<< G4endl;
G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue: "
<< oss.str() << G4endl;
}
command->CommandFailed(oss);
return;
}
// A fallback system found...but go back and check this too.
@@ -45,10 +45,8 @@
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "G4ios.hh"
#ifdef G4VIS_USE_STD11
#include <chrono>
#include <thread>
#endif
#include <sstream>
#include <fstream>
#include <sstream>
@@ -1062,7 +1062,7 @@ void G4VisCommandsViewerSet::SetNewValue
nSides = vp.SetNoOfSides(nSides);
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"Number of line segements per circle in polygon approximation is "
"Number of line segments per circle in polygon approximation is "
<< nSides << G4endl;
}
}
@@ -70,6 +70,7 @@
#include "G4TrajectoryDrawByCharge.hh"
#include "Randomize.hh"
#include "G4RunManager.hh"
#include "G4RunManagerFactory.hh"
#include "G4EventManager.hh"
#include "G4Run.hh"
#include "G4Event.hh"
@@ -79,17 +80,14 @@
#include <sstream>
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#include "G4Threading.hh"
#include "G4AutoLock.hh"
#include "G4GeometryWorkspace.hh"
#include "G4SolidsWorkspace.hh"
#include <deque>
#include <typeinfo>
#ifdef G4VIS_USE_STD11
#include <chrono>
#include <thread>
#endif
# include "G4Threading.hh"
# include "G4AutoLock.hh"
# include "G4GeometryWorkspace.hh"
# include "G4SolidsWorkspace.hh"
# include <deque>
# include <typeinfo>
# include <chrono>
# include <thread>
#endif
G4VisManager* G4VisManager::fpInstance = 0;
@@ -110,7 +108,6 @@ G4VisManager::G4VisManager (const G4String& verbosityString):
fNoOfEventsDrawnThisRun (0),
fNKeepRequests (0),
fEventKeepingSuspended (false),
fKeptLastEvent (false),
fDrawEventOnlyIfToBeKept (false),
fpRequestedEvent (0),
fReviewingKeptEvents (false),
@@ -183,12 +180,10 @@ G4VisManager::G4VisManager (const G4String& verbosityString):
// (c) invoke the Initialise() method of the subclass.
// For example:
// ...
// #ifdef G4VIS_USE
// // Instantiate and initialise Visualization Manager.
// G4VisManager* visManager = new G4VisExecutive;
// visManager -> SetVerboseLevel (Verbose);
// visManager -> Initialise ();
// #endif
// // (Don't forget to delete visManager;)
// ...
@@ -271,11 +266,9 @@ void G4VisManager::Initialise () {
"\n Also you should implement RegisterModelFactories()."
"\n See visualization/management/include/G4VisExecutive.hh/icc, for example."
"\n In your main() you will have something like:"
"\n #ifdef G4VIS_USE"
"\n G4VisManager* visManager = new G4VisExecutive;"
"\n visManager -> SetVerboseLevel (Verbose);"
"\n visManager -> Initialize ();"
"\n #endif"
"\n (Don't forget to delete visManager;)"
"\n"
<< G4endl;
@@ -1047,13 +1040,8 @@ void G4VisManager::Draw (const G4VTrajectory& traj) {
// A trajectory needs a trajectories model to provide G4Atts, etc.
static G4TrajectoriesModel trajectoriesModel;
trajectoriesModel.SetCurrentTrajectory(&traj);
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
const G4Run* currentRun = runManager->GetCurrentRun();
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
const G4Run* currentRun = runManager->GetCurrentRun();
if (currentRun) {
trajectoriesModel.SetRunID(currentRun->GetRunID());
}
@@ -1329,35 +1317,38 @@ void G4VisManager::NotifyHandlers () {
G4cout << "G4VisManager::NotifyHandler() called." << G4endl;
}
// Check scenes.
G4SceneList& sceneList = fSceneList;
G4int iScene, nScenes = sceneList.size ();
for (iScene = 0; iScene < nScenes; iScene++) {
G4Scene* pScene = sceneList [iScene];
std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
if (modelList.size ()) {
pScene->CalculateExtent();
G4UImanager::GetUIpointer () ->
ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName()));
}
}
if (IsValidView()) {
// Check the manager's current scene...
if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) {
if (fVerbosity >= warnings) {
G4cout << "WARNING: The current scene \""
<< fpScene -> GetName ()
<< "\" has no run duration models."
<< "\n Use \"/vis/scene/add/volume\" or create a new scene."
<< G4endl;
// Check scenes.
G4SceneList& sceneList = fSceneList;
G4int iScene, nScenes = sceneList.size ();
for (iScene = 0; iScene < nScenes; iScene++) {
G4Scene* pScene = sceneList [iScene];
std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
if (modelList.size ()) {
pScene->CalculateExtent();
G4UImanager::GetUIpointer () ->
ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName()));
}
}
// Check the manager's current scene...
if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) {
if (fVerbosity >= warnings) {
G4cout << "WARNING: The current scene \""
<< fpScene -> GetName ()
<< "\" has no run duration models."
<< "\n Use \"/vis/scene/add/volume\" or create a new scene."
<< G4endl;
}
fpSceneHandler->ClearTransientStore();
fpSceneHandler->ClearStore();
fpViewer->NeedKernelVisit();
fpViewer->SetView();
fpViewer->ClearView();
fpViewer->FinishView();
}
fpSceneHandler->ClearTransientStore();
fpSceneHandler->ClearStore();
fpViewer->NeedKernelVisit();
fpViewer->SetView();
fpViewer->ClearView();
fpViewer->FinishView();
}
}
@@ -1600,7 +1591,8 @@ void G4VisManager::SetCurrentViewer (G4VViewer* pViewer) {
}
return;
}
fpViewer->SetView();
// JA: I don't think we need this. Setview will be called when needed.
// fpViewer->SetView();
fpSceneHandler -> SetCurrentViewer (pViewer);
fpScene = fpSceneHandler -> GetScene ();
fpGraphicsSystem = fpSceneHandler -> GetGraphicsSystem ();
@@ -1796,16 +1788,16 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
G4UImanager::GetUIpointer()->SetUpForSpecialThread("G4VIS");
// G4cout << "G4VisManager::G4VisSubThread: thread: "
// << G4Threading::G4GetThreadId() << std::endl;
// G4cout << "G4VisManager::G4VisSubThread: thread: "
// << G4Threading::G4GetThreadId() << std::endl;
// Set up geometry and navigation for a thread
G4GeometryWorkspace::GetPool()->CreateAndUseWorkspace();
G4SolidsWorkspace::GetPool()->CreateAndUseWorkspace();
G4Navigator* navigator =
G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
navigator->SetWorldVolume
(G4MTRunManager::GetMasterRunManagerKernel()->GetCurrentWorld());
G4Navigator* navigator = G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking();
navigator->SetWorldVolume(
G4RunManagerFactory::GetMasterRunManagerKernel()->GetCurrentWorld());
pViewer->SwitchToVisSubThread();
@@ -1814,17 +1806,18 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
G4MUTEXLOCK(&mtVisSubThreadMutex);
G4int eventQueueSize = mtVisEventQueue.size();
G4MUTEXUNLOCK(&mtVisSubThreadMutex);
// G4cout << "Event queue size (A): " << eventQueueSize << G4endl;
// G4cout << "Event queue size (A): " << eventQueueSize << G4endl;
while (eventQueueSize) {
G4MUTEXLOCK(&mtVisSubThreadMutex);
const G4Event* event = mtVisEventQueue.front();
G4MUTEXUNLOCK(&mtVisSubThreadMutex);
// G4int eventID = event->GetEventID();
// G4cout <<
// "G4VisManager::G4VisSubThread: Vis sub-thread: Dealing with event: "
// << eventID << G4endl;
// G4int eventID = event->GetEventID();
// G4cout
// << "G4VisManager::G4VisSubThread: Vis sub-thread: Dealing with event:
// "
// << eventID << G4endl;
// Here comes the event drawing
pVisManager->SetTransientsDrawnThisEvent(false);
@@ -1855,7 +1848,7 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
}
// Testing.
// std::this_thread::sleep_for(std::chrono::seconds(5));
// std::this_thread::sleep_for(std::chrono::seconds(5));
// Then pop and release event
G4MUTEXLOCK(&mtVisSubThreadMutex);
@@ -1863,7 +1856,7 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
event->PostProcessingFinished();
eventQueueSize = mtVisEventQueue.size();
G4MUTEXUNLOCK(&mtVisSubThreadMutex);
// G4cout << "Event queue size (B): " << eventQueueSize << G4endl;
// G4cout << "Event queue size (B): " << eventQueueSize << G4endl;
}
G4MUTEXLOCK(&mtVisSubThreadMutex);
@@ -1876,18 +1869,14 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
}
// Run still in progress but nothing to draw, so wait a while.
#ifdef G4VIS_USE_STD11
std::this_thread::sleep_for(std::chrono::milliseconds(100));
#else
G4THREADSLEEP(1);
#endif
}
// Inform viewer that we have finished all sub-thread drawing
pViewer->DoneWithVisSubThread();
pViewer->MovingToMasterThread();
// G4cout << "G4VisManager::G4VisSubThread: Vis sub-thread: ending" << G4endl;
return /*(G4ThreadFunReturnType)*/0;
// G4cout << "G4VisManager::G4VisSubThread: Vis sub-thread: ending" << G4endl;
return nullptr;
}
namespace {
@@ -1906,22 +1895,16 @@ void G4VisManager::BeginOfRun ()
#ifdef G4MULTITHREADED
if (G4Threading::IsWorkerThread()) return;
#endif
// G4cout << "G4VisManager::BeginOfRun: thread: "
// << G4Threading::G4GetThreadId() << G4endl;
// G4cout << "G4VisManager::BeginOfRun: thread: "
// << G4Threading::G4GetThreadId() << G4endl;
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
// For a fake run...
G4int nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
if (nEventsToBeProcessed == 0) return;
fNKeepRequests = 0;
fKeptLastEvent = false;
fEventKeepingSuspended = false;
fTransientsDrawnThisRun = false;
if (fpSceneHandler) fpSceneHandler->SetTransientsDrawnThisRun(false);
@@ -2001,12 +1984,7 @@ void G4VisManager::EndOfEvent ()
// std::this_thread::sleep_for(std::chrono::seconds(5));
#endif
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
const G4Run* currentRun = runManager->GetCurrentRun();
if (!currentRun) return;
@@ -2058,11 +2036,7 @@ void G4VisManager::EndOfEvent ()
}
// G4cout << "Event queue size (3): " << eventQueueSize << G4endl;
// Wait a while to give event drawing time to reduce the queue...
#ifdef G4VIS_USE_STD11
std::this_thread::sleep_for(std::chrono::milliseconds(100));
#else
G4THREADSLEEP(1);
#endif
// G4cout << "Event queue size (4): " << eventQueueSize << G4endl;
} else {
static G4bool warned = false;
@@ -2091,6 +2065,13 @@ void G4VisManager::EndOfEvent ()
G4MUTEXLOCK(&mtVisSubThreadMutex);
// Keep event for processing and put event on vis event queue
currentEvent->KeepForPostProcessing();
if (fpScene->GetRefreshAtEndOfEvent()) {
// Keep one event (cannot know which is last so any will do)
if (fNKeepRequests == 0) {
eventManager->KeepTheCurrentEvent();
fNKeepRequests++;
}
}
mtVisEventQueue.push_back(currentEvent);
G4MUTEXUNLOCK(&mtVisSubThreadMutex);
}
@@ -2143,7 +2124,6 @@ void G4VisManager::EndOfEvent ()
if (nKeptEvents == 0) {
eventManager->KeepTheCurrentEvent();
fNKeepRequests++;
fKeptLastEvent = true;
}
}
fpSceneHandler->SetMarkForClearingTransientStore(true);
@@ -2199,15 +2179,10 @@ void G4VisManager::EndOfRun ()
if (G4Threading::IsWorkerThread()) return;
#endif
// G4cout << "G4VisManager::EndOfRun: thread: "
// << G4Threading::G4GetThreadId() << G4endl;
// G4cout << "G4VisManager::EndOfRun: thread: "
// << G4Threading::G4GetThreadId() << G4endl;
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
// For a fake run...
G4int nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
@@ -2253,28 +2228,36 @@ void G4VisManager::EndOfRun ()
G4int nKeptEvents = 0;
const std::vector<const G4Event*>* events = currentRun->GetEventVector();
if (events) nKeptEvents = events->size();
if (nKeptEvents && !fKeptLastEvent) {
if (fVerbosity >= warnings) {
G4cout << nKeptEvents;
if (nKeptEvents == 1) G4cout << " event has";
else G4cout << " events have";
G4cout << " been kept for refreshing and/or reviewing." << G4endl;
if (nKeptEvents != fNKeepRequests) {
G4cout << " (Note: ";
if (fNKeepRequests == 0) {
G4cout << "No keep requests were";
} else if (fNKeepRequests == 1) {
G4cout << "Only 1 keep request was";
} else {
G4cout << "Only " << fNKeepRequests << " keep requests were";
}
G4cout << " made by the vis manager.)" << G4endl;
if (fVerbosity >= warnings) {
G4cout << nKeptEvents;
if (nKeptEvents == 1) G4cout << " event has";
else G4cout << " events have";
G4cout << " been kept for refreshing and/or reviewing." << G4endl;
if (nKeptEvents != fNKeepRequests) {
G4cout << " (Note: ";
if (fNKeepRequests == 0) {
G4cout << "No keep requests were";
} else if (fNKeepRequests == 1) {
G4cout << "1 keep request was";
} else {
G4cout << fNKeepRequests << " keep requests were";
}
G4cout <<
"\n \"/vis/reviewKeptEvents\" to review them one by one."
"\n \"/vis/enable\", then \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
<< G4endl;
G4cout << " made by the vis manager.";
if (fNKeepRequests == 0) {
G4cout <<
"\n The kept events are those you have asked to be kept in your user action(s).)";
} else {
G4cout <<
"\n The same or further events may have been kept by you in your user action(s).)";
}
G4cout << G4endl;
}
G4cout <<
" \"/vis/reviewKeptEvents\" to review them one by one."
"\n \"/vis/enable\", then \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
<< G4endl;
}
// static G4bool warned = false;
// if (!valid && fVerbosity >= warnings && !warned) {
// G4cout <<
@@ -2291,7 +2274,6 @@ void G4VisManager::EndOfRun ()
// << G4endl;
// warned = true;
// }
}
if (fEventKeepingSuspended && fVerbosity >= warnings) {
G4cout <<