ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ParticlePropertyMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ParticlePropertyMessenger.cc
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 //
28 //
29 //---------------------------------------------------------------
30 //
31 // G4ParticlePropertyMessenger.cc
32 //
33 // Description:
34 // This is a messenger class to interface to exchange information
35 // between ParticleDefinition and UI.
36 //
37 // History:
38 // 13 June 1997, H. Kurashige : The 1st version created.
39 // 10 Nov. 1997 H. Kurashige : fixed bugs
40 // 08 jan. 1998 H. Kurashige : new UIcommnds
41 // 19 June 1998 H. Kurashige : adds UnitCategory
42 //---------------------------------------------------------------
43 
45 #include "G4UImanager.hh"
46 #include "G4UIdirectory.hh"
48 #include "G4UIcmdWithAnInteger.hh"
50 #include "G4UIcmdWithABool.hh"
51 #include "G4ParticleDefinition.hh"
52 #include "G4DecayTableMessenger.hh"
54 #include "G4ParticleTable.hh"
55 #include "G4ios.hh" // Include from 'system'
56 #include <iomanip> // Include from 'system'
57 
59  :theParticleTable(pTable),
60  currentParticle(0),
61  fDecayTableMessenger(0)
62 {
64  //Commnad /particle/property/
65  thisDirectory = new G4UIdirectory("/particle/property/");
66  thisDirectory->SetGuidance("Paricle Table control commands.");
67 
68  //Commnad /particle/property/dump
69  dumpCmd = new G4UIcmdWithoutParameter("/particle/property/dump",this);
70  dumpCmd->SetGuidance("dump particle properties.");
71 
72  //Command /particle/property/stable
73  stableCmd = new G4UIcmdWithABool("/particle/property/stable",this);
74  stableCmd->SetGuidance("Set stable flag.");
75  stableCmd->SetGuidance(" false: Unstable true: Stable");
76  stableCmd->SetParameterName("stable",false);
78 
79  //particle/property/lifetime
80  lifetimeCmd = new G4UIcmdWithADoubleAndUnit("/particle/property/lifetime",this);
81  lifetimeCmd->SetGuidance("Set life time.");
82  lifetimeCmd->SetGuidance("Unit of the time can be :");
83  lifetimeCmd->SetGuidance(" s, ms, ns (default)");
84  lifetimeCmd->SetParameterName("life",false);
86  lifetimeCmd->SetRange("life >0.0");
87  //lifetimeCmd->SetUnitCategory("Time");
88  //lifetimeCmd->SetUnitCandidates("s ms ns");
91 
92  // -- particle/property/Verbose ---
93  verboseCmd = new G4UIcmdWithAnInteger("/particle/property/verbose",this);
94  verboseCmd->SetGuidance("Set Verbose level of particle property.");
95  verboseCmd->SetGuidance(" 0 : Silent (default)");
96  verboseCmd->SetGuidance(" 1 : Display warning messages");
97  verboseCmd->SetGuidance(" 2 : Display more");
98  verboseCmd->SetParameterName("verbose_level",true);
100  verboseCmd->SetRange("verbose_level >=0");
101 
102  //UI messenger for Decay Table
104 
105 }
106 
108 {
111 
112  delete stableCmd;
113  delete verboseCmd;
114  delete lifetimeCmd;
115  delete dumpCmd;
116  delete thisDirectory;
117 }
118 
120 {
121  if (SetCurrentParticle()==0) {
122  G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
123  return;
124  }
125 
126  if( command == dumpCmd ){
127  //Commnad /particle/property/dump
129 
130  } else if (command == lifetimeCmd ) {
131  //Commnad /particle/property/lifetime
133 
134  } else if (command == stableCmd ) {
135  //Commnad /particle/property/stable
136  if (currentParticle->GetPDGLifeTime()<0.0) {
137  G4cout << "Life time is negative! Command ignored." << G4endl;
138  } else if (currentParticle->GetPDGMass()<=0.0) {
139  G4cout << "Zero Mass! Command ignored." << G4endl;
140  } else {
142  }
143 
144  } else if( command==verboseCmd ) {
145  //Commnad /particle/property/Verbose
147  }
148 }
149 
151 {
152  // set currentParticle pointer
153 
154  // get particle name by asking G4ParticleMessenger via UImanager
155 
156  G4String particleName = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
157 
158  if (currentParticle != 0 ){
159  // check whether selection is changed
160  if (currentParticle->GetParticleName() != particleName) {
162  }
163  } else {
165  }
166  return currentParticle;
167 }
168 
170 {
171  G4String returnValue('\0');
172 
173  if (SetCurrentParticle()==0) {
174  // no particle is selected. return null
175  return returnValue;
176  }
177 
178  if( command == stableCmd ){
179  //Commnad /particle/property/stable
181 
182  } else if( command == lifetimeCmd ){
183  //Commnad /particle/property/lifetime
184  returnValue = lifetimeCmd->ConvertToString( currentParticle->GetPDGLifeTime() , "ns" );
185 
186  } else if( command==verboseCmd ){
187  //Commnad /particle/property/Verbose
188  returnValue= verboseCmd->ConvertToString(currentParticle ->GetVerboseLevel());
189 
190  }
191 
192  return returnValue;
193 }
194 
195 
196 
197 
198 
199 
200 
201