Geant4 11.1.1
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#include "G4UIdirectory.hh"
39#include "G4UImanager.hh"
40#include "globals.hh"
41#include "G4TrackingManager.hh"
42#include "G4SteppingManager.hh"
43#include "G4TrackStatus.hh"
44#include "G4ios.hh"
48
49///////////////////////////////////////////////////////////////////
51///////////////////////////////////////////////////////////////////
52 : trackingManager(trMan)
53{
54 steppingManager = trackingManager->GetSteppingManager();
55
56 TrackingDirectory = new G4UIdirectory("/tracking/");
57 TrackingDirectory->SetGuidance("TrackingManager and SteppingManager control commands.");
58
59 AbortCmd = new G4UIcmdWithoutParameter("/tracking/abort",this);
60 AbortCmd->SetGuidance("Abort current G4Track processing.");
61
62 ResumeCmd = new G4UIcmdWithoutParameter("/tracking/resume",this);
63 ResumeCmd->SetGuidance("Resume current G4Track processing.");
64
65 StoreTrajectoryCmd = new G4UIcmdWithAnInteger("/tracking/storeTrajectory",this);
66 StoreTrajectoryCmd->SetGuidance("Store trajectories or not.");
67 StoreTrajectoryCmd->SetGuidance(" 0 : Don't Store trajectories.");
68 StoreTrajectoryCmd->SetGuidance(" !=0 : Store trajectories.");
69 StoreTrajectoryCmd->SetGuidance(" 1 : Choose G4Trajectory as default.");
70 StoreTrajectoryCmd->SetGuidance(" 2 : Choose G4SmoothTrajectory as default.");
71 StoreTrajectoryCmd->SetGuidance(" 3 : Choose G4RichTrajectory as default.");
72 StoreTrajectoryCmd->SetGuidance(" 4 : Choose G4RichTrajectory with auxiliary points as default.");
73 StoreTrajectoryCmd->SetParameterName("Store",true);
74 StoreTrajectoryCmd->SetDefaultValue(0);
75 StoreTrajectoryCmd->SetRange("Store >=0 && Store <= 4");
76
77 VerboseCmd = new G4UIcmdWithAnInteger("/tracking/verbose",this);
78#ifdef G4VERBOSE
79 VerboseCmd->SetGuidance("Set Verbose level of tracking category.");
80 VerboseCmd->SetGuidance(" -1 : Silent.");
81 VerboseCmd->SetGuidance(" 0 : Silent.");
82 VerboseCmd->SetGuidance(" 1 : Minimum information of each Step.");
83 VerboseCmd->SetGuidance(" 2 : Addition to Level=1, info of secondary particles.");
84 VerboseCmd->SetGuidance(" 3 : Addition to Level=1, pre/postStepoint information");
85 VerboseCmd->SetGuidance(" after all AlongStep/PostStep process executions.");
86 VerboseCmd->SetGuidance(" 4 : Addition to Level=3, pre/postStepoint information");
87 VerboseCmd->SetGuidance(" at each AlongStepPostStep process execution.");
88 VerboseCmd->SetGuidance(" 5 : Addition to Level=4, proposed Step length information");
89 VerboseCmd->SetGuidance(" from each AlongStepPostStep process.");
90 VerboseCmd->SetParameterName("verbose_level",true);
91 VerboseCmd->SetDefaultValue(0);
92 VerboseCmd->SetRange("verbose_level >=-1 ");
93#else
94 VerboseCmd->SetGuidance("You need to recompile the tracking category defining G4VERBOSE ");
95#endif
96}
97
98////////////////////////////////////////////
100////////////////////////////////////////////
101{
102 delete TrackingDirectory;
103 delete AbortCmd;
104 delete ResumeCmd;
105 delete StoreTrajectoryCmd;
106 delete VerboseCmd;
107}
108
109///////////////////////////////////////////////////////////////////////////////
111///////////////////////////////////////////////////////////////////////////////
112{
113 if( command == VerboseCmd )
114 {
115 trackingManager->SetVerboseLevel(VerboseCmd->ConvertToInt(newValues));
116 }
117
118 if( command == AbortCmd )
119 {
120 steppingManager->GetTrack()->SetTrackStatus(fStopAndKill);
121 G4UImanager::GetUIpointer()->ApplyCommand("/control/exit");
122 }
123
124 if( command == ResumeCmd )
125 {
126 G4UImanager::GetUIpointer()->ApplyCommand("/control/exit");
127 }
128
129 static G4ThreadLocal
130 G4IdentityTrajectoryFilter* auxiliaryPointsFilter = nullptr;
131 if(auxiliaryPointsFilter == nullptr)
132 {
133 auxiliaryPointsFilter = new G4IdentityTrajectoryFilter;
134 }
135 if( command == StoreTrajectoryCmd )
136 {
137 G4int trajType = StoreTrajectoryCmd->ConvertToInt(newValues);
138 if(trajType==2||trajType==4)
139 {
141 ->GetPropagatorInField()->SetTrajectoryFilter(auxiliaryPointsFilter);
142 }
143 else
144 {
147 }
148 trackingManager->SetStoreTrajectory(trajType);
149 }
150}
151
152////////////////////////////////////////////////////////////////////
154////////////////////////////////////////////////////////////////////
155{
156 if( command == VerboseCmd )
157 {
158 return VerboseCmd->ConvertToString(trackingManager->GetVerboseLevel());
159 }
160 else if( command == StoreTrajectoryCmd )
161 {
162 return StoreTrajectoryCmd
163 ->ConvertToString(trackingManager->GetStoreTrajectory());
164 }
165 return G4String(1,'\0');
166}
@ 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)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValues)
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)
Definition: G4UIcommand.cc:446
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:157
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:561
void SetRange(const char *rs)
Definition: G4UIcommand.hh:121
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:495
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
#define G4ThreadLocal
Definition: tls.hh:77