Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4DecayTableMessenger class implementation << 27 // 26 // 28 // Author: H.Kurashige, 13 June 1997 << 27 // $Id: G4DecayTableMessenger.cc 81373 2014-05-27 13:06:32Z gcosmo $ 29 //-------------------------------------------- << 28 // >> 29 // >> 30 //--------------------------------------------------------------- >> 31 // >> 32 // G4DecayTableMessenger.cc >> 33 // >> 34 // Description: >> 35 // This is a messenger class to interface to exchange information >> 36 // between ParticleDefinition and UI. >> 37 // >> 38 // History: >> 39 // 13 June 1997, H. Kurashige : The 1st version created. >> 40 // 10 Nov. 1997 H. Kurashige : fixed bugs >> 41 // 08 jan. 1998 H. Kurashige : new UIcommnds >> 42 // >> 43 //--------------------------------------------------------------- 30 44 31 #include "G4DecayTableMessenger.hh" 45 #include "G4DecayTableMessenger.hh" 32 << 46 #include "G4UImanager.hh" >> 47 #include "G4UIdirectory.hh" >> 48 #include "G4UIcmdWithoutParameter.hh" >> 49 #include "G4UIcmdWithAnInteger.hh" >> 50 #include "G4UIcmdWithADouble.hh" >> 51 #include "G4VDecayChannel.hh" 33 #include "G4DecayTable.hh" 52 #include "G4DecayTable.hh" 34 #include "G4ParticleDefinition.hh" 53 #include "G4ParticleDefinition.hh" 35 #include "G4ParticleTable.hh" 54 #include "G4ParticleTable.hh" 36 #include "G4UIcmdWithADouble.hh" << 55 #include "G4ios.hh" // Include from 'system' 37 #include "G4UIcmdWithAnInteger.hh" << 56 #include <iomanip> // Include from 'system' 38 #include "G4UIcmdWithoutParameter.hh" << 39 #include "G4UIdirectory.hh" << 40 #include "G4UImanager.hh" << 41 #include "G4VDecayChannel.hh" << 42 #include "G4ios.hh" // Include from 'system' << 43 << 44 #include <iomanip> // Include from 'system' << 45 57 46 G4DecayTableMessenger::G4DecayTableMessenger(G << 58 G4DecayTableMessenger::G4DecayTableMessenger(G4ParticleTable* pTable) >> 59 :theParticleTable(pTable), >> 60 currentParticle(0), currentDecayTable(0), >> 61 idxCurrentChannel(-1), currentChannel(0), >> 62 thisDirectory(0),dumpCmd(0),selectCmd(0),brCmd(0) 47 { 63 { 48 if (theParticleTable == nullptr) { << 64 if ( theParticleTable == 0) theParticleTable = G4ParticleTable::GetParticleTable(); 49 theParticleTable = G4ParticleTable::GetPar << 50 } << 51 currentParticle = nullptr; << 52 65 53 // Command /particle/property/decay/ << 66 currentParticle = 0; >> 67 >> 68 //Commnad /particle/property/decay/ 54 thisDirectory = new G4UIdirectory("/particle 69 thisDirectory = new G4UIdirectory("/particle/property/decay/"); 55 thisDirectory->SetGuidance("Decay Table cont 70 thisDirectory->SetGuidance("Decay Table control commands."); 56 71 57 // Command /particle/property/decay/select << 72 //Commnad /particle/property/decay/select 58 selectCmd = new G4UIcmdWithAnInteger("/parti << 73 selectCmd = new G4UIcmdWithAnInteger("/particle/property/decay/select",this); 59 selectCmd->SetGuidance("Enter index of decay 74 selectCmd->SetGuidance("Enter index of decay mode."); 60 selectCmd->SetParameterName("mode", true); 75 selectCmd->SetParameterName("mode", true); 61 selectCmd->SetDefaultValue(0); 76 selectCmd->SetDefaultValue(0); 62 selectCmd->SetRange("mode >=0"); 77 selectCmd->SetRange("mode >=0"); 63 currentChannel = nullptr; << 78 currentChannel = 0; 64 79 65 // Command /particle/property/decay/dump << 80 //Commnad /particle/property/decay/dump 66 dumpCmd = new G4UIcmdWithoutParameter("/part << 81 dumpCmd = new G4UIcmdWithoutParameter("/particle/property/decay/dump",this); 67 dumpCmd->SetGuidance("Dump decay mode inform 82 dumpCmd->SetGuidance("Dump decay mode information."); 68 83 69 // Command /particle/property/decay/br << 84 //Command /particle/property/decay/br 70 brCmd = new G4UIcmdWithADouble("/particle/pr << 85 brCmd = new G4UIcmdWithADouble("/particle/property/decay/br",this); 71 brCmd->SetGuidance("Set branching ratio. [0< 86 brCmd->SetGuidance("Set branching ratio. [0< BR <1.0]"); 72 brCmd->SetParameterName("br", false); << 87 brCmd->SetParameterName("br",false); 73 brCmd->SetRange("(br >=0.0) && (br <=1.0)"); 88 brCmd->SetRange("(br >=0.0) && (br <=1.0)"); >> 89 74 } 90 } 75 91 76 G4DecayTableMessenger::~G4DecayTableMessenger( 92 G4DecayTableMessenger::~G4DecayTableMessenger() 77 { 93 { 78 delete dumpCmd; 94 delete dumpCmd; 79 delete selectCmd; 95 delete selectCmd; 80 delete brCmd; 96 delete brCmd; 81 delete thisDirectory; 97 delete thisDirectory; 82 } 98 } 83 99 84 void G4DecayTableMessenger::SetNewValue(G4UIco << 100 void G4DecayTableMessenger::SetNewValue(G4UIcommand * command,G4String newValue) 85 { 101 { 86 if (SetCurrentParticle() == nullptr) { << 102 if (SetCurrentParticle()==0) { 87 G4cout << "Particle is not selected yet !! 103 G4cout << "Particle is not selected yet !! Command ignored." << G4endl; 88 return; 104 return; 89 } 105 } 90 if (currentDecayTable == nullptr) { << 106 if (currentDecayTable==0) { 91 G4cout << "The particle has no decay table 107 G4cout << "The particle has no decay table !! Command ignored." << G4endl; 92 return; 108 return; 93 } 109 } 94 110 95 if (command == dumpCmd) { << 111 if( command == dumpCmd ){ 96 // Command /particle/property/decay/dump << 112 //Commnad /particle/property/decay/dump 97 currentDecayTable->DumpInfo(); 113 currentDecayTable->DumpInfo(); 98 } << 114 99 else if (command == selectCmd) { << 115 } else if ( command == selectCmd ){ 100 // Command /particle/property/decay/select << 116 //Commnad /particle/property/decay/select 101 G4int index = selectCmd->GetNewIntValue(ne << 117 G4int index = selectCmd->GetNewIntValue(newValue) ; 102 currentChannel = currentDecayTable->GetDec 118 currentChannel = currentDecayTable->GetDecayChannel(index); 103 if (currentChannel == nullptr) { << 119 if ( currentChannel == 0 ) { 104 G4cout << "Invalid index. Command ignore 120 G4cout << "Invalid index. Command ignored." << G4endl; 105 } << 121 } else { 106 else { << 107 idxCurrentChannel = index; 122 idxCurrentChannel = index; 108 } 123 } 109 } << 124 110 else { << 125 } else { 111 if (currentChannel == nullptr) { << 126 if ( currentChannel == 0 ) { 112 G4cout << "Select a decay channel. Comma 127 G4cout << "Select a decay channel. Command ignored." << G4endl; 113 return; 128 return; 114 } 129 } 115 if (command == brCmd) { 130 if (command == brCmd) { 116 // Command /particle/property/decay/br << 131 //Commnad /particle/property/decay/br 117 G4double br = brCmd->GetNewDoubleValue(n << 132 G4double br = brCmd->GetNewDoubleValue(newValue); 118 if ((br < 0.0) || (br > 1.0)) { << 133 if( (br<0.0) || (br>1.0) ) { 119 G4cout << "Invalid brancing ratio. Com << 134 G4cout << "Invalid brancing ratio. Command ignored." << G4endl; 120 } << 135 } else { 121 else { << 136 currentChannel->SetBR(br); 122 currentChannel->SetBR(br); << 123 } 137 } 124 } 138 } 125 } 139 } 126 } 140 } 127 141 >> 142 128 G4ParticleDefinition* G4DecayTableMessenger::S 143 G4ParticleDefinition* G4DecayTableMessenger::SetCurrentParticle() 129 { 144 { 130 // set currentParticle pointer 145 // set currentParticle pointer >> 146 131 // get particle name by asking G4ParticleMes 147 // get particle name by asking G4ParticleMessenger via UImanager 132 148 133 G4String particleName = G4UImanager::GetUIpo 149 G4String particleName = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select"); 134 150 135 if (currentParticle != nullptr) { << 151 if (currentParticle != 0 ){ 136 // check whether selection is changed << 152 // check whether selection is changed 137 if (currentParticle->GetParticleName() != 153 if (currentParticle->GetParticleName() != particleName) { 138 currentParticle = theParticleTable->Find 154 currentParticle = theParticleTable->FindParticle(particleName); 139 idxCurrentChannel = -1; 155 idxCurrentChannel = -1; 140 currentDecayTable = nullptr; << 156 currentDecayTable = 0; 141 } << 157 } else { 142 else { << 158 // no change 143 // no change << 144 return currentParticle; 159 return currentParticle; 145 } 160 } 146 } << 161 } else { 147 else { << 148 currentParticle = theParticleTable->FindPa 162 currentParticle = theParticleTable->FindParticle(particleName); 149 idxCurrentChannel = -1; 163 idxCurrentChannel = -1; 150 currentDecayTable = nullptr; << 164 currentDecayTable = 0; 151 } 165 } 152 166 153 if (currentParticle != nullptr) { << 167 if (currentParticle != 0 ){ 154 currentDecayTable = currentParticle->GetDe 168 currentDecayTable = currentParticle->GetDecayTable(); 155 if ((currentDecayTable != nullptr) && (idx << 169 if ((currentDecayTable != 0 ) && (idxCurrentChannel >0) ) { 156 currentChannel = currentDecayTable->GetD 170 currentChannel = currentDecayTable->GetDecayChannel(idxCurrentChannel); 157 } << 171 } else { 158 else { << 159 idxCurrentChannel = -1; 172 idxCurrentChannel = -1; 160 currentChannel = nullptr; << 173 currentChannel = 0; 161 } 174 } 162 } 175 } 163 << 164 return currentParticle; 176 return currentParticle; 165 } 177 } 166 178 167 G4String G4DecayTableMessenger::GetCurrentValu << 179 G4String G4DecayTableMessenger::GetCurrentValue(G4UIcommand * command) 168 { 180 { 169 G4String returnValue(1, '\0'); << 181 G4String returnValue('\0'); 170 182 171 if (SetCurrentParticle() == nullptr) { << 183 if (SetCurrentParticle()==0) { 172 // no particle is selected. return null << 184 // no particle is selected. return null 173 return returnValue; 185 return returnValue; 174 } 186 } 175 187 176 if (command == selectCmd) { << 188 if( command == selectCmd ){ 177 // Command /particle/property/decay/select << 189 //Commnad /particle/property/decay/select 178 returnValue = selectCmd->ConvertToString(i 190 returnValue = selectCmd->ConvertToString(idxCurrentChannel); 179 } << 191 180 else if (command == brCmd) { << 192 } else if( command == brCmd ){ 181 if (currentChannel != nullptr) { << 193 if ( currentChannel != 0) { 182 returnValue = brCmd->ConvertToString(cur 194 returnValue = brCmd->ConvertToString(currentChannel->GetBR()); 183 } << 195 } 184 } 196 } 185 return returnValue; 197 return returnValue; 186 } 198 } >> 199 >> 200 >> 201 >> 202 >> 203 >> 204 >> 205 >> 206 187 207