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 | // |
---|
27 | // $Id: G4TrackingMessenger.cc,v 1.15 2006/11/03 11:13:38 allison Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
29 | // |
---|
30 | //--------------------------------------------------------------- |
---|
31 | // |
---|
32 | // G4TrackingMessenger.cc |
---|
33 | // |
---|
34 | // Description: |
---|
35 | // This is a messenger class to interface to exchange information |
---|
36 | // between tracking and stepping managers and UI. |
---|
37 | // |
---|
38 | // Contact: |
---|
39 | // Questions and comments to this code should be sent to |
---|
40 | // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) |
---|
41 | // Makoto Asai (e-mail: asai@kekvax.kek.jp) |
---|
42 | // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) |
---|
43 | // |
---|
44 | //--------------------------------------------------------------- |
---|
45 | |
---|
46 | #include "G4TrackingMessenger.hh" |
---|
47 | #include "G4UIdirectory.hh" |
---|
48 | #include "G4UIcmdWithoutParameter.hh" |
---|
49 | #include "G4UIcmdWithAnInteger.hh" |
---|
50 | #include "G4UImanager.hh" |
---|
51 | #include "globals.hh" |
---|
52 | #include "G4TrackingManager.hh" |
---|
53 | #include "G4SteppingManager.hh" |
---|
54 | #include "G4TrackStatus.hh" |
---|
55 | #include "G4ios.hh" |
---|
56 | |
---|
57 | /////////////////////////////////////////////////////////////////// |
---|
58 | G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager * trMan) |
---|
59 | /////////////////////////////////////////////////////////////////// |
---|
60 | : trackingManager(trMan) |
---|
61 | { |
---|
62 | steppingManager = trackingManager->GetSteppingManager(); |
---|
63 | |
---|
64 | TrackingDirectory = new G4UIdirectory("/tracking/"); |
---|
65 | TrackingDirectory->SetGuidance("TrackingManager and SteppingManager control commands."); |
---|
66 | |
---|
67 | AbortCmd = new G4UIcmdWithoutParameter("/tracking/abort",this); |
---|
68 | AbortCmd->SetGuidance("Abort current G4Track processing."); |
---|
69 | |
---|
70 | |
---|
71 | ResumeCmd = new G4UIcmdWithoutParameter("/tracking/resume",this); |
---|
72 | ResumeCmd->SetGuidance("Resume current G4Track processing."); |
---|
73 | |
---|
74 | StoreTrajectoryCmd = new G4UIcmdWithAnInteger("/tracking/storeTrajectory",this); |
---|
75 | StoreTrajectoryCmd->SetGuidance("Store trajectories or not."); |
---|
76 | StoreTrajectoryCmd->SetGuidance(" 0 : Don't Store trajectories."); |
---|
77 | StoreTrajectoryCmd->SetGuidance(" !=0 : Store trajectories."); |
---|
78 | StoreTrajectoryCmd->SetGuidance(" 1 : Choose G4Trajectory as default."); |
---|
79 | StoreTrajectoryCmd->SetGuidance(" 2 : Choose G4SmoothTrajectory as default."); |
---|
80 | StoreTrajectoryCmd->SetGuidance(" 3 : Choose G4RichTrajectory as default."); |
---|
81 | StoreTrajectoryCmd->SetParameterName("Store",true); |
---|
82 | StoreTrajectoryCmd->SetDefaultValue(0); |
---|
83 | StoreTrajectoryCmd->SetRange("Store >=0 && Store <= 3"); |
---|
84 | |
---|
85 | |
---|
86 | VerboseCmd = new G4UIcmdWithAnInteger("/tracking/verbose",this); |
---|
87 | #ifdef G4VERBOSE |
---|
88 | VerboseCmd->SetGuidance("Set Verbose level of tracking category."); |
---|
89 | VerboseCmd->SetGuidance(" -1 : Silent."); |
---|
90 | VerboseCmd->SetGuidance(" 0 : Silent."); |
---|
91 | VerboseCmd->SetGuidance(" 1 : Minium information of each Step."); |
---|
92 | VerboseCmd->SetGuidance(" 2 : Addition to Level=1, info of secondary particles."); |
---|
93 | VerboseCmd->SetGuidance(" 3 : Addition to Level=1, pre/postStepoint information"); |
---|
94 | VerboseCmd->SetGuidance(" after all AlongStep/PostStep process executions."); |
---|
95 | VerboseCmd->SetGuidance(" 4 : Addition to Level=3, pre/postStepoint information"); |
---|
96 | VerboseCmd->SetGuidance(" at each AlongStepPostStep process execuation."); |
---|
97 | VerboseCmd->SetGuidance(" 5 : Addition to Level=4, proposed Step length information"); |
---|
98 | VerboseCmd->SetGuidance(" from each AlongStepPostStep process."); |
---|
99 | VerboseCmd->SetParameterName("verbose_level",true); |
---|
100 | VerboseCmd->SetDefaultValue(0); |
---|
101 | VerboseCmd->SetRange("verbose_level >=-1 "); |
---|
102 | #else |
---|
103 | VerboseCmd->SetGuidance("You need to recompile the tracking category defining G4VERBOSE "); |
---|
104 | #endif |
---|
105 | } |
---|
106 | |
---|
107 | //////////////////////////////////////////// |
---|
108 | G4TrackingMessenger::~G4TrackingMessenger() |
---|
109 | //////////////////////////////////////////// |
---|
110 | { |
---|
111 | delete TrackingDirectory; |
---|
112 | delete AbortCmd; |
---|
113 | delete ResumeCmd; |
---|
114 | delete StoreTrajectoryCmd; |
---|
115 | delete VerboseCmd; |
---|
116 | } |
---|
117 | |
---|
118 | /////////////////////////////////////////////////////////////////////////////// |
---|
119 | void G4TrackingMessenger::SetNewValue(G4UIcommand * command,G4String newValues) |
---|
120 | /////////////////////////////////////////////////////////////////////////////// |
---|
121 | { |
---|
122 | if( command == VerboseCmd ){ |
---|
123 | trackingManager->SetVerboseLevel(VerboseCmd->ConvertToInt(newValues)); |
---|
124 | } |
---|
125 | |
---|
126 | if( command == AbortCmd ){ |
---|
127 | steppingManager->GetTrack()->SetTrackStatus(fStopAndKill); |
---|
128 | G4UImanager::GetUIpointer()->ApplyCommand("/control/exit"); |
---|
129 | } |
---|
130 | |
---|
131 | if( command == ResumeCmd ){ |
---|
132 | G4UImanager::GetUIpointer()->ApplyCommand("/control/exit"); |
---|
133 | } |
---|
134 | |
---|
135 | if( command == StoreTrajectoryCmd ){ |
---|
136 | trackingManager->SetStoreTrajectory(StoreTrajectoryCmd->ConvertToInt(newValues)); |
---|
137 | } |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | //////////////////////////////////////////////////////////////////// |
---|
142 | G4String G4TrackingMessenger::GetCurrentValue(G4UIcommand * command) |
---|
143 | //////////////////////////////////////////////////////////////////// |
---|
144 | { |
---|
145 | if( command == VerboseCmd ){ |
---|
146 | return VerboseCmd->ConvertToString(trackingManager->GetVerboseLevel()); |
---|
147 | } |
---|
148 | else if( command == StoreTrajectoryCmd ){ |
---|
149 | return StoreTrajectoryCmd->ConvertToString(trackingManager->GetStoreTrajectory()); |
---|
150 | } |
---|
151 | return G4String('\0'); |
---|
152 | } |
---|
153 | |
---|
154 | |
---|
155 | |
---|
156 | |
---|
157 | |
---|
158 | |
---|
159 | |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | |
---|
164 | |
---|
165 | |
---|