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