Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TrackingMessenger.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4TrackingMessenger class implementation
27//
28// Contact:
29// Questions and comments to this code should be sent to
30// Katsuya Amako (e-mail: [email protected])
31// Makoto Asai (e-mail: [email protected])
32// Takashi Sasaki (e-mail: [email protected])
33// --------------------------------------------------------------------
34
36
39#include "G4SteppingManager.hh"
40#include "G4TrackStatus.hh"
41#include "G4TrackingManager.hh"
45#include "G4UIdirectory.hh"
46#include "G4UImanager.hh"
47#include "G4ios.hh"
48#include "globals.hh"
49
50///////////////////////////////////////////////////////////////////
52 ///////////////////////////////////////////////////////////////////
53 : trackingManager(trMan)
54{
55 steppingManager = trackingManager->GetSteppingManager();
56
57 TrackingDirectory = new G4UIdirectory("/tracking/");
58 TrackingDirectory->SetGuidance("TrackingManager and SteppingManager control commands.");
59
60 AbortCmd = new G4UIcmdWithoutParameter("/tracking/abort", this);
61 AbortCmd->SetGuidance("Abort current G4Track processing.");
62
63 ResumeCmd = new G4UIcmdWithoutParameter("/tracking/resume", this);
64 ResumeCmd->SetGuidance("Resume current G4Track processing.");
65
66 StoreTrajectoryCmd = new G4UIcmdWithAnInteger("/tracking/storeTrajectory", this);
67 StoreTrajectoryCmd->SetGuidance("Store trajectories or not.");
68 StoreTrajectoryCmd->SetGuidance(" 0 : Don't Store trajectories.");
69 StoreTrajectoryCmd->SetGuidance(" !=0 : Store trajectories.");
70 StoreTrajectoryCmd->SetGuidance(" 1 : Choose G4Trajectory as default.");
71 StoreTrajectoryCmd->SetGuidance(" 2 : Choose G4SmoothTrajectory as default.");
72 StoreTrajectoryCmd->SetGuidance(" 3 : Choose G4RichTrajectory as default.");
73 StoreTrajectoryCmd->SetGuidance(" 4 : Choose G4RichTrajectory with auxiliary points as default.");
74 StoreTrajectoryCmd->SetParameterName("Store", true);
75 StoreTrajectoryCmd->SetDefaultValue(0);
76 StoreTrajectoryCmd->SetRange("Store >=0 && Store <= 4");
77
78 VerboseCmd = new G4UIcmdWithAnInteger("/tracking/verbose", this);
79#ifdef G4VERBOSE
80 VerboseCmd->SetGuidance("Set Verbose level of tracking category.");
81 VerboseCmd->SetGuidance(" -1 : Silent.");
82 VerboseCmd->SetGuidance(" 0 : Silent.");
83 VerboseCmd->SetGuidance(" 1 : Minimum information of each Step.");
84 VerboseCmd->SetGuidance(" 2 : Addition to Level=1, info of secondary particles.");
85 VerboseCmd->SetGuidance(" 3 : Addition to Level=1, pre/postStepoint information");
86 VerboseCmd->SetGuidance(" after all AlongStep/PostStep process executions.");
87 VerboseCmd->SetGuidance(" 4 : Addition to Level=3, pre/postStepoint information");
88 VerboseCmd->SetGuidance(" at each AlongStepPostStep process execution.");
89 VerboseCmd->SetGuidance(" 5 : Addition to Level=4, proposed Step length information");
90 VerboseCmd->SetGuidance(" from each AlongStepPostStep process.");
91 VerboseCmd->SetParameterName("verbose_level", true);
92 VerboseCmd->SetDefaultValue(0);
93 VerboseCmd->SetRange("verbose_level >=-1 ");
94#else
95 VerboseCmd->SetGuidance("You need to recompile the tracking category defining G4VERBOSE ");
96#endif
97}
98
99////////////////////////////////////////////
101////////////////////////////////////////////
102{
103 delete TrackingDirectory;
104 delete AbortCmd;
105 delete ResumeCmd;
106 delete StoreTrajectoryCmd;
107 delete VerboseCmd;
108 delete auxiliaryPointsFilter;
109}
110
111///////////////////////////////////////////////////////////////////////////////
113///////////////////////////////////////////////////////////////////////////////
114{
115 if (command == VerboseCmd) {
116 trackingManager->SetVerboseLevel(VerboseCmd->ConvertToInt(newValues));
117 }
118
119 if (command == AbortCmd) {
120 steppingManager->GetTrack()->SetTrackStatus(fStopAndKill);
121 G4UImanager::GetUIpointer()->ApplyCommand("/control/exit");
122 }
123
124 if (command == ResumeCmd) {
125 G4UImanager::GetUIpointer()->ApplyCommand("/control/exit");
126 }
127
128 if (command == StoreTrajectoryCmd) {
129 G4int trajType = StoreTrajectoryCmd->ConvertToInt(newValues);
130 if (trajType == 2 || trajType == 4) {
131
132 if (nullptr == auxiliaryPointsFilter) {
133 auxiliaryPointsFilter = new G4IdentityTrajectoryFilter;
134 }
137 ->SetTrajectoryFilter(auxiliaryPointsFilter);
138 }
139 else {
142 ->SetTrajectoryFilter(nullptr);
143 }
144 trackingManager->SetStoreTrajectory(trajType);
145 }
146}
147
148////////////////////////////////////////////////////////////////////
150////////////////////////////////////////////////////////////////////
151{
152 if (command == VerboseCmd) {
153 return VerboseCmd->ConvertToString(trackingManager->GetVerboseLevel());
154 }
155 if (command == StoreTrajectoryCmd) {
156 return StoreTrajectoryCmd->ConvertToString(trackingManager->GetStoreTrajectory());
157 }
158 return G4String(1, '\0');
159}
@ fStopAndKill
int G4int
Definition G4Types.hh:85
void SetTrajectoryFilter(G4VCurvedTrajectoryFilter *filter)
G4Track * GetTrack() const
void SetTrackStatus(const G4TrackStatus aTrackStatus)
G4int GetVerboseLevel() const
void SetVerboseLevel(G4int vLevel)
G4SteppingManager * GetSteppingManager() const
void SetStoreTrajectory(G4int value)
G4int GetStoreTrajectory() const
G4TrackingMessenger(G4TrackingManager *trMan)
void SetNewValue(G4UIcommand *command, G4String newValues) override
G4String GetCurrentValue(G4UIcommand *command) override
static G4TransportationManager * GetTransportationManager()
G4PropagatorInField * GetPropagatorInField() const
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4int defVal)
static G4String ConvertToString(G4bool boolVal)
void SetGuidance(const char *aGuidance)
static G4int ConvertToInt(const char *st)
void SetRange(const char *rs)
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()