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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /particles/management/src/G4DecayTableMessenger.cc (Version 11.3.0) and /particles/management/src/G4DecayTableMessenger.cc (Version 10.5.p1)


  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 //
 29 //-------------------------------------------- <<  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 //---------------------------------------------------------------
 30                                                    43 
 31 #include "G4DecayTableMessenger.hh"                44 #include "G4DecayTableMessenger.hh"
 32                                                <<  45 #include "G4UImanager.hh"
                                                   >>  46 #include "G4UIdirectory.hh"
                                                   >>  47 #include "G4UIcmdWithoutParameter.hh"
                                                   >>  48 #include "G4UIcmdWithAnInteger.hh"
                                                   >>  49 #include "G4UIcmdWithADouble.hh"
                                                   >>  50 #include "G4VDecayChannel.hh"
 33 #include "G4DecayTable.hh"                         51 #include "G4DecayTable.hh"
 34 #include "G4ParticleDefinition.hh"                 52 #include "G4ParticleDefinition.hh"
 35 #include "G4ParticleTable.hh"                      53 #include "G4ParticleTable.hh"
 36 #include "G4UIcmdWithADouble.hh"               <<  54 #include "G4ios.hh"                 // Include from 'system'
 37 #include "G4UIcmdWithAnInteger.hh"             <<  55 #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                                                    56 
 44 #include <iomanip>  // Include from 'system'   <<  57 G4DecayTableMessenger::G4DecayTableMessenger(G4ParticleTable* pTable)
 45                                                <<  58                       :theParticleTable(pTable),
 46 G4DecayTableMessenger::G4DecayTableMessenger(G <<  59            currentParticle(nullptr), 
                                                   >>  60            currentDecayTable(nullptr),
                                                   >>  61            idxCurrentChannel(-1), 
                                                   >>  62            currentChannel(nullptr),
                                                   >>  63            thisDirectory(nullptr),
                                                   >>  64            dumpCmd(nullptr),
                                                   >>  65            selectCmd(nullptr),
                                                   >>  66            brCmd(nullptr) 
 47 {                                                  67 {
 48   if (theParticleTable == nullptr) {           <<  68   if ( theParticleTable == nullptr ) {
 49     theParticleTable = G4ParticleTable::GetPar     69     theParticleTable = G4ParticleTable::GetParticleTable();
 50   }                                                70   }
 51   currentParticle = nullptr;                       71   currentParticle = nullptr;
 52                                                    72 
 53   // Command /particle/property/decay/         <<  73   //Commnad   /particle/property/decay/
 54   thisDirectory = new G4UIdirectory("/particle     74   thisDirectory = new G4UIdirectory("/particle/property/decay/");
 55   thisDirectory->SetGuidance("Decay Table cont     75   thisDirectory->SetGuidance("Decay Table control commands.");
 56                                                    76 
 57   // Command /particle/property/decay/select   <<  77   //Commnad   /particle/property/decay/select
 58   selectCmd = new G4UIcmdWithAnInteger("/parti <<  78   selectCmd = new G4UIcmdWithAnInteger("/particle/property/decay/select",this);
 59   selectCmd->SetGuidance("Enter index of decay     79   selectCmd->SetGuidance("Enter index of decay mode.");
 60   selectCmd->SetParameterName("mode", true);       80   selectCmd->SetParameterName("mode", true);
 61   selectCmd->SetDefaultValue(0);                   81   selectCmd->SetDefaultValue(0);
 62   selectCmd->SetRange("mode >=0");                 82   selectCmd->SetRange("mode >=0");
 63   currentChannel = nullptr;                        83   currentChannel = nullptr;
 64                                                    84 
 65   // Command /particle/property/decay/dump     <<  85   //Commnad   /particle/property/decay/dump
 66   dumpCmd = new G4UIcmdWithoutParameter("/part <<  86   dumpCmd = new G4UIcmdWithoutParameter("/particle/property/decay/dump",this);
 67   dumpCmd->SetGuidance("Dump decay mode inform     87   dumpCmd->SetGuidance("Dump decay mode information.");
 68                                                    88 
 69   // Command /particle/property/decay/br       <<  89   //Command   /particle/property/decay/br
 70   brCmd = new G4UIcmdWithADouble("/particle/pr <<  90   brCmd = new G4UIcmdWithADouble("/particle/property/decay/br",this);
 71   brCmd->SetGuidance("Set branching ratio. [0<     91   brCmd->SetGuidance("Set branching ratio. [0< BR <1.0]");
 72   brCmd->SetParameterName("br", false);        <<  92   brCmd->SetParameterName("br",false);
 73   brCmd->SetRange("(br >=0.0) && (br <=1.0)");     93   brCmd->SetRange("(br >=0.0) && (br <=1.0)");
                                                   >>  94 
 74 }                                                  95 }
 75                                                    96 
 76 G4DecayTableMessenger::~G4DecayTableMessenger(     97 G4DecayTableMessenger::~G4DecayTableMessenger()
 77 {                                                  98 {
 78   delete dumpCmd;                              <<  99   if (dumpCmd != nullptr) delete dumpCmd;
 79   delete selectCmd;                            << 100   if (selectCmd != nullptr) delete selectCmd;
 80   delete brCmd;                                << 101   if (brCmd != nullptr) delete brCmd;
 81   delete thisDirectory;                        << 102   if (thisDirectory != nullptr) delete thisDirectory;
 82 }                                                 103 }
 83                                                   104 
 84 void G4DecayTableMessenger::SetNewValue(G4UIco << 105 void G4DecayTableMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
 85 {                                                 106 {
 86   if (SetCurrentParticle() == nullptr) {       << 107   if (SetCurrentParticle()== nullptr) {
 87     G4cout << "Particle is not selected yet !!    108     G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
 88     return;                                       109     return;
 89   }                                               110   }
 90   if (currentDecayTable == nullptr) {          << 111   if (currentDecayTable== nullptr) {
 91     G4cout << "The particle has no decay table    112     G4cout << "The particle has no decay table !! Command ignored." << G4endl;
 92     return;                                       113     return;
 93   }                                               114   }
 94                                                   115 
 95   if (command == dumpCmd) {                    << 116   if( command == dumpCmd ){
 96     // Command /particle/property/decay/dump   << 117     //Commnad   /particle/property/decay/dump
 97     currentDecayTable->DumpInfo();                118     currentDecayTable->DumpInfo();
 98   }                                            << 119 
 99   else if (command == selectCmd) {             << 120   } else if ( command == selectCmd ){
100     // Command /particle/property/decay/select << 121     //Commnad   /particle/property/decay/select
101     G4int index = selectCmd->GetNewIntValue(ne << 122     G4int index = selectCmd->GetNewIntValue(newValue) ;
102     currentChannel = currentDecayTable->GetDec    123     currentChannel = currentDecayTable->GetDecayChannel(index);
103     if (currentChannel == nullptr) {           << 124     if ( currentChannel == nullptr ) {
104       G4cout << "Invalid index. Command ignore    125       G4cout << "Invalid index. Command ignored." << G4endl;
105     }                                          << 126     } else {
106     else {                                     << 
107       idxCurrentChannel = index;                  127       idxCurrentChannel = index;
108     }                                             128     }
109   }                                            << 129 
110   else {                                       << 130   } else {
111     if (currentChannel == nullptr) {           << 131     if ( currentChannel == nullptr ) {
112       G4cout << "Select a decay channel. Comma    132       G4cout << "Select a decay channel. Command ignored." << G4endl;
113       return;                                     133       return;
114     }                                             134     }
115     if (command == brCmd) {                       135     if (command == brCmd) {
116       // Command /particle/property/decay/br   << 136       //Commnad   /particle/property/decay/br
117       G4double br = brCmd->GetNewDoubleValue(n << 137       G4double  br = brCmd->GetNewDoubleValue(newValue);
118       if ((br < 0.0) || (br > 1.0)) {          << 138       if( (br<0.0) || (br>1.0) ) { 
119         G4cout << "Invalid brancing ratio. Com << 139   G4cout << "Invalid brancing ratio. Command ignored." << G4endl;
120       }                                        << 140       } else {
121       else {                                   << 141   currentChannel->SetBR(br);
122         currentChannel->SetBR(br);             << 
123       }                                           142       }
124     }                                             143     }
125   }                                               144   }
126 }                                                 145 }
127                                                   146 
                                                   >> 147 
128 G4ParticleDefinition* G4DecayTableMessenger::S    148 G4ParticleDefinition* G4DecayTableMessenger::SetCurrentParticle()
129 {                                                 149 {
130   // set currentParticle pointer               << 150   // set currentParticle pointer  
131   // get particle name by asking G4ParticleMes    151   // get particle name by asking G4ParticleMessenger via UImanager
132                                                   152 
133   G4String particleName = G4UImanager::GetUIpo    153   G4String particleName = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
134                                                   154 
135   if (currentParticle != nullptr) {            << 155   if (currentParticle != nullptr ){
136     // check whether selection is changed      << 156     // check whether selection is changed 
137     if (currentParticle->GetParticleName() !=     157     if (currentParticle->GetParticleName() != particleName) {
138       currentParticle = theParticleTable->Find    158       currentParticle = theParticleTable->FindParticle(particleName);
139       idxCurrentChannel = -1;                     159       idxCurrentChannel = -1;
140       currentDecayTable = nullptr;                160       currentDecayTable = nullptr;
141     }                                          << 161     } else {
142     else {                                     << 162       // no change 
143       // no change                             << 
144       return currentParticle;                     163       return currentParticle;
145     }                                             164     }
146   }                                            << 165 
147   else {                                       << 166   } else {
148     currentParticle = theParticleTable->FindPa    167     currentParticle = theParticleTable->FindParticle(particleName);
149     idxCurrentChannel = -1;                       168     idxCurrentChannel = -1;
150     currentDecayTable = nullptr;                  169     currentDecayTable = nullptr;
151   }                                            << 170     if (currentParticle != nullptr ){
152                                                << 171       currentDecayTable = currentParticle->GetDecayTable();
153   if (currentParticle != nullptr) {            << 172       if ((currentDecayTable != nullptr ) && (idxCurrentChannel >0) ) {
154     currentDecayTable = currentParticle->GetDe << 173   currentChannel = currentDecayTable->GetDecayChannel(idxCurrentChannel);
155     if ((currentDecayTable != nullptr) && (idx << 174       } else {
156       currentChannel = currentDecayTable->GetD << 175   idxCurrentChannel = -1;
157     }                                          << 176   currentChannel = nullptr;
158     else {                                     << 177       }
159       idxCurrentChannel = -1;                  << 
160       currentChannel = nullptr;                << 
161     }                                             178     }
162   }                                            << 
163                                                   179 
                                                   >> 180   }
164   return currentParticle;                         181   return currentParticle;
165 }                                                 182 }
166                                                   183 
167 G4String G4DecayTableMessenger::GetCurrentValu << 184 G4String G4DecayTableMessenger::GetCurrentValue(G4UIcommand * command)
168 {                                                 185 {
169   G4String returnValue(1, '\0');               << 186   G4String returnValue('\0');
170                                                   187 
171   if (SetCurrentParticle() == nullptr) {       << 188   if (SetCurrentParticle()==nullptr) {
172     // no particle is selected. return null    << 189     // no particle is selected. return null 
173     return returnValue;                           190     return returnValue;
174   }                                               191   }
175                                                   192 
176   if (command == selectCmd) {                  << 193   if( command == selectCmd ){
177     // Command /particle/property/decay/select << 194     //Commnad   /particle/property/decay/select
178     returnValue = selectCmd->ConvertToString(i    195     returnValue = selectCmd->ConvertToString(idxCurrentChannel);
179   }                                            << 196 
180   else if (command == brCmd) {                 << 197   } else if( command == brCmd ){
181     if (currentChannel != nullptr) {           << 198     if ( currentChannel != nullptr) {
182       returnValue = brCmd->ConvertToString(cur    199       returnValue = brCmd->ConvertToString(currentChannel->GetBR());
183     }                                          << 200     } 
184   }                                               201   }
185   return returnValue;                             202   return returnValue;
186 }                                                 203 }
                                                   >> 204 
                                                   >> 205 
                                                   >> 206 
                                                   >> 207 
                                                   >> 208 
                                                   >> 209 
                                                   >> 210 
                                                   >> 211 
187                                                   212