ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4DecayTableMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4DecayTableMessenger.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 // G4DecayTableMessenger.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 //
42 //---------------------------------------------------------------
43 
44 #include "G4DecayTableMessenger.hh"
45 #include "G4UImanager.hh"
46 #include "G4UIdirectory.hh"
48 #include "G4UIcmdWithAnInteger.hh"
49 #include "G4UIcmdWithADouble.hh"
50 #include "G4VDecayChannel.hh"
51 #include "G4DecayTable.hh"
52 #include "G4ParticleDefinition.hh"
53 #include "G4ParticleTable.hh"
54 #include "G4ios.hh" // Include from 'system'
55 #include <iomanip> // Include from 'system'
56 
58  :theParticleTable(pTable),
59  currentParticle(nullptr),
60  currentDecayTable(nullptr),
61  idxCurrentChannel(-1),
62  currentChannel(nullptr),
63  thisDirectory(nullptr),
64  dumpCmd(nullptr),
65  selectCmd(nullptr),
66  brCmd(nullptr)
67 {
68  if ( theParticleTable == nullptr ) {
70  }
71  currentParticle = nullptr;
72 
73  //Commnad /particle/property/decay/
74  thisDirectory = new G4UIdirectory("/particle/property/decay/");
75  thisDirectory->SetGuidance("Decay Table control commands.");
76 
77  //Commnad /particle/property/decay/select
78  selectCmd = new G4UIcmdWithAnInteger("/particle/property/decay/select",this);
79  selectCmd->SetGuidance("Enter index of decay mode.");
80  selectCmd->SetParameterName("mode", true);
82  selectCmd->SetRange("mode >=0");
83  currentChannel = nullptr;
84 
85  //Commnad /particle/property/decay/dump
86  dumpCmd = new G4UIcmdWithoutParameter("/particle/property/decay/dump",this);
87  dumpCmd->SetGuidance("Dump decay mode information.");
88 
89  //Command /particle/property/decay/br
90  brCmd = new G4UIcmdWithADouble("/particle/property/decay/br",this);
91  brCmd->SetGuidance("Set branching ratio. [0< BR <1.0]");
92  brCmd->SetParameterName("br",false);
93  brCmd->SetRange("(br >=0.0) && (br <=1.0)");
94 
95 }
96 
98 {
99  if (dumpCmd != nullptr) delete dumpCmd;
100  if (selectCmd != nullptr) delete selectCmd;
101  if (brCmd != nullptr) delete brCmd;
102  if (thisDirectory != nullptr) delete thisDirectory;
103 }
104 
106 {
107  if (SetCurrentParticle()== nullptr) {
108  G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
109  return;
110  }
111  if (currentDecayTable== nullptr) {
112  G4cout << "The particle has no decay table !! Command ignored." << G4endl;
113  return;
114  }
115 
116  if( command == dumpCmd ){
117  //Commnad /particle/property/decay/dump
119 
120  } else if ( command == selectCmd ){
121  //Commnad /particle/property/decay/select
122  G4int index = selectCmd->GetNewIntValue(newValue) ;
124  if ( currentChannel == nullptr ) {
125  G4cout << "Invalid index. Command ignored." << G4endl;
126  } else {
127  idxCurrentChannel = index;
128  }
129 
130  } else {
131  if ( currentChannel == nullptr ) {
132  G4cout << "Select a decay channel. Command ignored." << G4endl;
133  return;
134  }
135  if (command == brCmd) {
136  //Commnad /particle/property/decay/br
137  G4double br = brCmd->GetNewDoubleValue(newValue);
138  if( (br<0.0) || (br>1.0) ) {
139  G4cout << "Invalid brancing ratio. Command ignored." << G4endl;
140  } else {
141  currentChannel->SetBR(br);
142  }
143  }
144  }
145 }
146 
147 
149 {
150  // set currentParticle pointer
151  // get particle name by asking G4ParticleMessenger via UImanager
152 
153  G4String particleName = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
154 
155  if (currentParticle != nullptr ){
156  // check whether selection is changed
157  if (currentParticle->GetParticleName() != particleName) {
159  idxCurrentChannel = -1;
160  currentDecayTable = nullptr;
161  } else {
162  // no change
163  return currentParticle;
164  }
165 
166  } else {
168  idxCurrentChannel = -1;
169  currentDecayTable = nullptr;
170  }
171 
172  if (currentParticle != nullptr ){
174  if ((currentDecayTable != nullptr ) && (idxCurrentChannel >0) ) {
176  } else {
177  idxCurrentChannel = -1;
178  currentChannel = nullptr;
179  }
180  }
181 
182  return currentParticle;
183 }
184 
186 {
187  G4String returnValue('\0');
188 
189  if (SetCurrentParticle()==nullptr) {
190  // no particle is selected. return null
191  return returnValue;
192  }
193 
194  if( command == selectCmd ){
195  //Commnad /particle/property/decay/select
197 
198  } else if( command == brCmd ){
199  if ( currentChannel != nullptr) {
200  returnValue = brCmd->ConvertToString(currentChannel->GetBR());
201  }
202  }
203  return returnValue;
204 }
205 
206 
207 
208 
209 
210 
211 
212