source: trunk/source/physics_lists/builders/src/G4OpticalPhysicsMessenger.cc @ 1340

Last change on this file since 1340 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 12.1 KB
Line 
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#include "G4OpticalPhysicsMessenger.hh"
27#include "G4OpticalPhysics.hh"
28
29#include "G4UIcommand.hh"
30#include "G4UIdirectory.hh"
31
32#include "G4UIcommand.hh"
33#include "G4UIdirectory.hh"
34#include "G4UIcmdWithABool.hh"
35#include "G4UIcmdWithAString.hh"
36#include "G4UIcmdWithADouble.hh"
37#include "G4UIcmdWithAnInteger.hh"
38#include "G4UIcmdWithADoubleAndUnit.hh"
39
40#include "G4ParticleTable.hh"
41#include "G4ProcessVector.hh"
42#include "G4ProcessManager.hh"
43#include "G4ParticleDefinition.hh"
44
45//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
46G4OpticalPhysicsMessenger::G4OpticalPhysicsMessenger(
47                                            G4OpticalPhysics* opticalPhysics)
48  : G4UImessenger(),
49    fOpticalPhysics(opticalPhysics),
50    fSelectedProcess(0),
51    fSelectOpProcessCmd(0),
52    fSetOpProcessActivationCmd(0),
53    fSetOpProcessVerboseCmd(0),
54    fSetCerenkovMaxPhotonsCmd(0),
55    fSetCerenkovMaxBetaChangeCmd(0),
56    fSetScintillationYieldFactorCmd(0),
57    fSetScintillationByParticleTypeCmd(0),
58    fSetOpticalSurfaceModelCmd(0),
59    fSetWLSTimeProfileCmd(0),
60    fSetTrackSecondariesFirstCmd(0)
61{
62/// Standard constructor
63
64  fDir = new G4UIdirectory("/optics_engine/");
65  fDir->SetGuidance("Commands related to the optical physics simulation engine.");
66 
67  fSelectOpProcessCmd
68   = new G4UIcmdWithAString("/optics_engine/selectOpProcess", this);
69  fSelectOpProcessCmd
70   ->SetGuidance("Select optical process for applying verbose/activation/trackfirst commands");
71  fSelectOpProcessCmd->SetParameterName("OpProcess", false);
72  fSelectOpProcessCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc);
73
74  fSetOpProcessActivationCmd
75   = new G4UIcmdWithABool("/optics_engine/setOpProcessActivation", this);
76  fSetOpProcessActivationCmd->SetGuidance("Activate/Inactivate selected optical process");
77  fSetOpProcessActivationCmd->SetParameterName("OpProcessActivation", false);
78  fSetOpProcessActivationCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc);
79
80  fSetOpProcessVerboseCmd
81    = new G4UIcmdWithAnInteger("/optics_engine/setOpProcessVerbose", this); 
82  fSetOpProcessVerboseCmd->SetGuidance("Set verbosity level for selected optical process");
83  fSetOpProcessVerboseCmd->SetParameterName("OpProcessVerbose", false);
84  fSetOpProcessVerboseCmd->SetRange("OpProcessVerbose>=0");
85  fSetOpProcessVerboseCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); 
86
87  fSetCerenkovMaxPhotonsCmd
88    = new G4UIcmdWithAnInteger("/optics_engine/setCerenkovMaxPhotons", this); 
89  fSetCerenkovMaxPhotonsCmd->SetGuidance("Set maximum number of photons per step");
90  fSetCerenkovMaxPhotonsCmd->SetParameterName("CerenkovMaxPhotons", false);
91  fSetCerenkovMaxPhotonsCmd->SetRange("CerenkovMaxPhotons>=0");
92  fSetCerenkovMaxPhotonsCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); 
93
94  fSetCerenkovMaxBetaChangeCmd
95    = new G4UIcmdWithADouble("/optics_engine/setCerenkovMaxBetaChange", this); 
96  fSetCerenkovMaxBetaChangeCmd
97    ->SetGuidance("Set maximum change of beta of parent particle per step");
98  fSetCerenkovMaxBetaChangeCmd->SetParameterName("CerenkovMaxBetaChange", false);
99  fSetCerenkovMaxBetaChangeCmd->SetRange("CerenkovMaxBetaChange>=0");
100  fSetCerenkovMaxBetaChangeCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc);
101
102  fSetScintillationYieldFactorCmd
103    = new G4UIcmdWithADouble("/optics_engine/setScintillationYieldFactor", this); 
104  fSetScintillationYieldFactorCmd->SetGuidance("Set scintillation yield factor");
105  fSetScintillationYieldFactorCmd->SetParameterName("ScintillationYieldFactor", false);
106  fSetScintillationYieldFactorCmd->SetRange("ScintillationYieldFactor>=0");
107  fSetScintillationYieldFactorCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc);
108
109  fSetScintillationByParticleTypeCmd
110   = new G4UIcmdWithABool("/optics_engine/setScintillationByParticleType", this);
111  fSetScintillationByParticleTypeCmd->SetGuidance("Activate/Inactivate scintillation process by particle type");
112  fSetScintillationByParticleTypeCmd->SetParameterName("ScintillationByParticleTypeActivation", false);
113  fSetScintillationByParticleTypeCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc);
114
115  fSetOpticalSurfaceModelCmd
116    = new G4UIcmdWithAString("/optics_engine/setOpticalSurfaceModel", this); 
117  fSetOpticalSurfaceModelCmd
118    ->SetGuidance("Set optical surface model (glisur or unified)");
119  fSetOpticalSurfaceModelCmd->SetParameterName("OpticalSurfaceModel", false);
120  fSetOpticalSurfaceModelCmd->SetCandidates("glisur unified");
121  fSetOpticalSurfaceModelCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc);
122
123  fSetWLSTimeProfileCmd
124    = new G4UIcmdWithAString("/optics_engine/setWLSTimeProfile", this);
125  fSetWLSTimeProfileCmd
126    ->SetGuidance("Set the WLS time profile (delta or exponential)");
127  fSetWLSTimeProfileCmd->SetParameterName("WLSTimeProfile", false);
128  fSetWLSTimeProfileCmd->SetCandidates("delta exponential");
129  fSetWLSTimeProfileCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc);
130
131  fSetTrackSecondariesFirstCmd
132    = new G4UIcmdWithABool("/optics_engine/setTrackSecondariesFirst", this); 
133  fSetTrackSecondariesFirstCmd
134    ->SetGuidance("Set option to track secondaries before finishing their parent track");
135  fSetTrackSecondariesFirstCmd->SetParameterName("TrackSecondariesFirst", false);
136  fSetTrackSecondariesFirstCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc);
137}
138
139//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
140G4OpticalPhysicsMessenger::~G4OpticalPhysicsMessenger()
141{
142/// Destructor
143  delete fDir;
144  delete fSelectOpProcessCmd; 
145  delete fSetOpProcessActivationCmd; 
146  delete fSetOpProcessVerboseCmd;
147  delete fSetCerenkovMaxPhotonsCmd;
148  delete fSetCerenkovMaxBetaChangeCmd;
149  delete fSetScintillationYieldFactorCmd;
150  delete fSetScintillationByParticleTypeCmd;
151  delete fSetOpticalSurfaceModelCmd;
152  delete fSetWLSTimeProfileCmd;
153  delete fSetTrackSecondariesFirstCmd;
154}
155
156//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
157void G4OpticalPhysicsMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
158{
159/// Apply command to the associated object.
160
161  if (command == fSelectOpProcessCmd) {
162    if      ( newValue == "Cerenkov" )      fSelectedProcess = fOpticalPhysics->
163                                            GetCerenkovProcess();
164    else if ( newValue == "Scintillation" ) fSelectedProcess = fOpticalPhysics->
165                                            GetScintillationProcess();
166    else if ( newValue == "OpAbsorption" )  fSelectedProcess = fOpticalPhysics->
167                                            GetOpAbsorptionProcess();
168    else if ( newValue == "OpRayleigh" )    fSelectedProcess = fOpticalPhysics->
169                                            GetOpRayleighProcess();
170    else if ( newValue == "OpMieHG" )       fSelectedProcess = fOpticalPhysics->
171                                            GetOpMieHGProcess();
172    else if ( newValue == "OpBoundary" )    fSelectedProcess = fOpticalPhysics->
173                                            GetOpBoundaryProcess();
174    else if ( newValue == "OpWLS" )         fSelectedProcess = fOpticalPhysics->
175                                            GetOpWLSProcess();
176  }
177  else if (command == fSetOpProcessActivationCmd) {
178    G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
179    G4ParticleTable::G4PTblDicIterator* theParticleIterator = 
180                                             theParticleTable->GetIterator();
181    if ( fSelectedProcess ) {
182       theParticleIterator->reset();
183       while( (*theParticleIterator)() ) {
184         G4ParticleDefinition* particle = theParticleIterator->value();
185         G4ProcessManager* processManager = particle->GetProcessManager();
186         G4ProcessVector* processVector = processManager->GetProcessList();
187
188         // activate or inactivate processes according to
189         for (G4int i=0; i<processVector->length(); i++) {
190             if ( (*processVector)[i] != fSelectedProcess ) continue;
191             G4cout << "Setting process activation: "
192                    << fSelectedProcess->GetProcessName() << "  "
193                    << fSetOpProcessActivationCmd->GetNewBoolValue(newValue)
194                    << G4endl;
195             processManager->SetProcessActivation(fSelectedProcess,
196                       fSetOpProcessActivationCmd->GetNewBoolValue(newValue));
197         }
198       }
199    }
200  } 
201  else if (command == fSetOpProcessVerboseCmd) {
202    if ( fSelectedProcess )
203    fSelectedProcess->SetVerboseLevel
204                           (fSetOpProcessVerboseCmd->GetNewIntValue(newValue));
205  }
206  else if (command == fSetCerenkovMaxPhotonsCmd) {
207    fOpticalPhysics
208      ->SetMaxNumPhotonsPerStep(
209          fSetCerenkovMaxPhotonsCmd->GetNewIntValue(newValue));
210  } 
211  else if (command == fSetCerenkovMaxBetaChangeCmd) {
212    fOpticalPhysics
213      ->SetMaxBetaChangePerStep(
214          fSetCerenkovMaxBetaChangeCmd->GetNewDoubleValue(newValue));
215  }
216  else if (command == fSetScintillationYieldFactorCmd) {
217    fOpticalPhysics
218      ->SetScintillationYieldFactor(
219          fSetScintillationYieldFactorCmd->GetNewDoubleValue(newValue));
220  }
221  else if (command == fSetScintillationByParticleTypeCmd) {
222    fOpticalPhysics
223      ->SetScintillationByParticleType(
224         fSetScintillationByParticleTypeCmd->GetNewBoolValue(newValue));
225  }
226  else if (command == fSetOpticalSurfaceModelCmd) {
227    if ( newValue == "glisur" ) {
228      fOpticalPhysics
229        ->SetOpticalSurfaceModel(glisur);
230    }   
231    if ( newValue == "unified" ) {
232      fOpticalPhysics
233        ->SetOpticalSurfaceModel(unified);
234    } 
235  }
236  else if (command == fSetWLSTimeProfileCmd) {
237    if ( newValue == "delta" ) {
238      fOpticalPhysics
239        ->SetWLSTimeProfile("delta");     }
240    if ( newValue == "exponential" ) {
241      fOpticalPhysics
242        ->SetWLSTimeProfile("exponential");
243    }
244  } 
245  else if (command == fSetTrackSecondariesFirstCmd) {
246    if ( fSelectedProcess ) {
247       G4Scintillation* scintillation =
248                     static_cast<G4Scintillation*>(fSelectedProcess);
249       if (scintillation) scintillation ->
250          SetTrackSecondariesFirst(
251                      fSetTrackSecondariesFirstCmd->GetNewBoolValue(newValue));
252       G4Cerenkov* cerenkov =
253                   static_cast<G4Cerenkov*>(fSelectedProcess);
254       if (cerenkov) cerenkov ->
255          SetTrackSecondariesFirst(
256                      fSetTrackSecondariesFirstCmd->GetNewBoolValue(newValue));
257    }
258  }
259}
Note: See TracBrowser for help on using the repository browser.