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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/G4ParticleMessenger.cc (Version 11.3.0) and /particles/management/src/G4ParticleMessenger.cc (Version 9.2.p4)


  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 // G4ParticleMessenger class implementation    << 
 27 //                                                 26 //
 28 // Author: H. Kurashige, 13 June 1997 - 1st ve <<  27 // $Id: G4ParticleMessenger.cc,v 1.10 2008/06/08 12:43:19 kurasige Exp $
 29 // ------------------------------------------- <<  28 // GEANT4 tag $Name: geant4-09-02-patch-04 $
                                                   >>  29 //
                                                   >>  30 //
                                                   >>  31 //---------------------------------------------------------------
                                                   >>  32 //
                                                   >>  33 //  G4ParticleMessenger.cc
                                                   >>  34 //
                                                   >>  35 //  Description:
                                                   >>  36 //    This is a messenger class to interface to exchange information
                                                   >>  37 //    between Particle related classes and UI.
                                                   >>  38 //
                                                   >>  39 //  History:
                                                   >>  40 //    13 June 1997, H. Kurashige   : The 1st version created.
                                                   >>  41 //    10 Nov. 1997  H. Kurashige   : fixed bugs 
                                                   >>  42 //    08 Jan. 1998  H. Kurashige   : new UIcommnds 
                                                   >>  43 //    08 June 1998, H. Kurashige   : remove fProcessManagerMessenger
                                                   >>  44 //    25 Nov. 1998, H. Kurashige   : add /particle/find
                                                   >>  45 //---------------------------------------------------------------
 30                                                    46 
 31 #include "G4ParticleMessenger.hh"              <<  47 #include "G4ios.hh"                 // Include from 'system'
                                                   >>  48 #include <iomanip>                  // Include from 'system'
 32                                                    49 
 33 #include "G4IonTable.hh"                       <<  50 #include "G4ParticleMessenger.hh"
 34 #include "G4ParticleDefinition.hh"             <<  51 #include "G4UImanager.hh"
 35 #include "G4ParticlePropertyMessenger.hh"      <<  52 #include "G4UIdirectory.hh"
 36 #include "G4ParticleTable.hh"                  << 
 37 #include "G4UIcmdWithAString.hh"                   53 #include "G4UIcmdWithAString.hh"
 38 #include "G4UIcmdWithAnInteger.hh"                 54 #include "G4UIcmdWithAnInteger.hh"
 39 #include "G4UIcmdWithoutParameter.hh"          <<  55 #include "G4ParticleTable.hh"
 40 #include "G4UIdirectory.hh"                    <<  56 #include "G4ParticleDefinition.hh"
 41 #include "G4UImanager.hh"                      <<  57 #include "G4ParticlePropertyMessenger.hh"
 42 #include "G4ios.hh"                            << 
 43                                                << 
 44 #include <iomanip>  // Include from 'system'   << 
 45                                                    58 
 46 G4ParticleMessenger::G4ParticleMessenger(G4Par     59 G4ParticleMessenger::G4ParticleMessenger(G4ParticleTable* pTable)
 47 {                                                  60 {
 48   // get the pointer to ParticleTable              61   // get the pointer to ParticleTable
 49   if (pTable == nullptr) {                     <<  62   if ( pTable == 0) {
 50     theParticleTable = G4ParticleTable::GetPar     63     theParticleTable = G4ParticleTable::GetParticleTable();
 51   }                                            <<  64   } else {
 52   else {                                       << 
 53     theParticleTable = pTable;                     65     theParticleTable = pTable;
 54   }                                                66   }
 55                                                <<  67  
 56   // Directory   /particle/                    <<  68   //Directory   /particle/
 57   thisDirectory = new G4UIdirectory("/particle     69   thisDirectory = new G4UIdirectory("/particle/");
 58   thisDirectory->SetGuidance("Particle control     70   thisDirectory->SetGuidance("Particle control commands.");
 59                                                    71 
 60   // Command   /particle/select                <<  72   //Commnad   /particle/select
 61   selectCmd = new G4UIcmdWithAString("/particl <<  73   selectCmd = new G4UIcmdWithAString("/particle/select",this);
 62   selectCmd->SetGuidance("Select particle ");      74   selectCmd->SetGuidance("Select particle ");
 63   selectCmd->SetDefaultValue("none");              75   selectCmd->SetDefaultValue("none");
 64   selectCmd->SetParameterName("particle name",     76   selectCmd->SetParameterName("particle name", false);
 65   selectCmd->AvailableForStates(G4State_PreIni << 
 66                                                    77 
 67   // Command   /particle/list                  <<  78   //Commnad   /particle/list
 68   listCmd = new G4UIcmdWithAString("/particle/ <<  79   listCmd = new G4UIcmdWithAString("/particle/list",this);
 69   listCmd->SetGuidance("List name of particles     80   listCmd->SetGuidance("List name of particles.");
 70   listCmd->SetGuidance(" all(default)/lepton/b     81   listCmd->SetGuidance(" all(default)/lepton/baryon/meson/nucleus/quarks");
 71   listCmd->SetParameterName("particle type", t     82   listCmd->SetParameterName("particle type", true);
 72   listCmd->SetDefaultValue("all");                 83   listCmd->SetDefaultValue("all");
 73   listCmd->SetCandidates("all lepton baryon me     84   listCmd->SetCandidates("all lepton baryon meson nucleus quarks");
 74   listCmd->AvailableForStates(G4State_PreInit, << 
 75                                                    85 
 76   // Command   /particle/find                  <<  86   //Commnad   /particle/find 
 77   findCmd = new G4UIcmdWithAnInteger("/particl <<  87   findCmd = new G4UIcmdWithAnInteger("/particle/find",this);
 78   findCmd->SetGuidance("Find particle by encod     88   findCmd->SetGuidance("Find particle by encoding");
 79   findCmd->SetDefaultValue(0);                     89   findCmd->SetDefaultValue(0);
 80   findCmd->SetParameterName("encoding", false)     90   findCmd->SetParameterName("encoding", false);
 81   findCmd->AvailableForStates(G4State_PreInit, << 
 82                                                << 
 83   // Command   /particle/createAllIon          << 
 84   createAllIonCmd = new G4UIcmdWithoutParamete << 
 85   createAllIonCmd->SetGuidance("Create All ion << 
 86   createAllIonCmd->AvailableForStates(G4State_ << 
 87   createAllIonCmd->SetToBeBroadcasted(false);  << 
 88                                                << 
 89   // Command   /particle/createAllIsomer       << 
 90   createAllIsomerCmd = new G4UIcmdWithoutParam << 
 91   createAllIsomerCmd->SetGuidance("Create All  << 
 92   createAllIsomerCmd->AvailableForStates(G4Sta << 
 93   createAllIsomerCmd->SetToBeBroadcasted(false << 
 94                                                    91 
 95   // -- particle/property/Verbose ---              92   // -- particle/property/Verbose ---
 96   verboseCmd = new G4UIcmdWithAnInteger("/part <<  93   verboseCmd = new G4UIcmdWithAnInteger("/particle/verbose",this);
 97   verboseCmd->SetGuidance("Set Verbose level o     94   verboseCmd->SetGuidance("Set Verbose level of particle table.");
 98   verboseCmd->SetGuidance(" 0 : Silent (defaul     95   verboseCmd->SetGuidance(" 0 : Silent (default)");
 99   verboseCmd->SetGuidance(" 1 : Display warnin     96   verboseCmd->SetGuidance(" 1 : Display warning messages");
100   verboseCmd->SetGuidance(" 2 : Display more")     97   verboseCmd->SetGuidance(" 2 : Display more");
101   verboseCmd->SetParameterName("verbose_level" <<  98   verboseCmd->SetParameterName("verbose_level",true);
102   verboseCmd->SetDefaultValue(0);                  99   verboseCmd->SetDefaultValue(0);
103   verboseCmd->SetRange("verbose_level >=0");      100   verboseCmd->SetRange("verbose_level >=0");
104                                                   101 
105   // UI messenger for Particle Properties      << 102   currentParticle = 0;
                                                   >> 103 
                                                   >> 104   //UI messenger for Particle Properties
106   fParticlePropertyMessenger = new G4ParticleP    105   fParticlePropertyMessenger = new G4ParticlePropertyMessenger(theParticleTable);
                                                   >> 106 
107 }                                                 107 }
108                                                   108 
109 G4ParticleMessenger::~G4ParticleMessenger()       109 G4ParticleMessenger::~G4ParticleMessenger()
110 {                                                 110 {
111   delete fParticlePropertyMessenger;              111   delete fParticlePropertyMessenger;
112                                                   112 
113   delete listCmd;                              << 113   delete listCmd; 
114   delete selectCmd;                               114   delete selectCmd;
115   delete findCmd;                                 115   delete findCmd;
116   delete createAllIonCmd;                      << 
117   delete createAllIsomerCmd;                   << 
118   delete verboseCmd;                              116   delete verboseCmd;
119                                                   117 
120   delete thisDirectory;                           118   delete thisDirectory;
121 }                                                 119 }
122                                                   120 
123 void G4ParticleMessenger::SetNewValue(G4UIcomm << 121 
                                                   >> 122 void G4ParticleMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
124 {                                                 123 {
125   if (command == listCmd) {                    << 124   if( command==listCmd ){
126     // Command   /particle/List                << 125     //Commnad   /particle/List
127     G4int counter = 0;                            126     G4int counter = 0;
128     G4ParticleTable::G4PTblDicIterator* piter  << 127     G4ParticleTable::G4PTblDicIterator *piter = theParticleTable->GetIterator();
129     piter->reset();                            << 128     piter -> reset();
130                                                << 129   
131     while ((*piter)())  // Loop checking, 09.0 << 130     while( (*piter)() ){
132     {                                          << 131       G4ParticleDefinition *particle = piter->value();
133       G4ParticleDefinition* particle = piter-> << 132       if ((newValues=="all") || (newValues==particle->GetParticleType())) {
134       if ((newValues == "all") || (newValues = << 
135         G4cout << std::setw(19) << particle->G    133         G4cout << std::setw(19) << particle->GetParticleName();
136         if ((counter++) % 4 == 3) {            << 134   if ((counter++)%4 == 3) {
137           G4cout << G4endl;                    << 135     G4cout << G4endl;
138         }                                      << 136   } else {
139         else {                                 << 137     G4cout << ",";
140           G4cout << ",";                       << 138   }
141         }                                      << 
142       }                                           139       }
143     }                                             140     }
144     G4cout << G4endl;                             141     G4cout << G4endl;
145     if (counter == 0) {                        << 142     if (counter == 0) G4cout << newValues << " is not found " << G4endl;
146       G4cout << newValues << " is not found "  << 143     
147     }                                          << 144    //Command  /particle/select
148                                                << 
149     // Command  /particle/select               << 
150     // set candidate List                         145     // set candidate List
151     G4String candidates("none");                  146     G4String candidates("none");
152     piter->reset();                            << 147     piter -> reset();
153     while ((*piter)())  // Loop checking, 09.0 << 148     while( (*piter)() ){
154     {                                          << 149       G4ParticleDefinition *particle = piter->value();
155       G4ParticleDefinition* particle = piter-> << 
156       candidates += " " + particle->GetParticl    150       candidates += " " + particle->GetParticleName();
157     }                                             151     }
158     selectCmd->SetCandidates((const char*)(can << 152     selectCmd->SetCandidates((const char *)(candidates));   
159   }                                            << 153  
160   else if (command == selectCmd) {             << 154   } else if( command==selectCmd ){
161     // Command   /particle/select              << 155     //Commnad   /particle/select
162     theParticleTable->SelectParticle(newValues << 156     currentParticle = theParticleTable->FindParticle(newValues);
163   }                                            << 157     if(currentParticle == 0) {
164   else if (command == findCmd) {               << 
165     // Command   /particle/find                << 
166     G4ParticleDefinition* tmp = theParticleTab << 
167     if (tmp == nullptr) {                      << 
168       G4cout << "Unknown particle [" << newVal    158       G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
169     }                                          << 159     }   
170     else {                                     << 160   } else if( command==findCmd ){
                                                   >> 161     //Commnad   /particle/find
                                                   >> 162     G4ParticleDefinition* tmp = theParticleTable->FindParticle( findCmd->GetNewIntValue(newValues));
                                                   >> 163     if(tmp == 0) {
                                                   >> 164       G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
                                                   >> 165     } else {
171       G4cout << tmp->GetParticleName() << G4en    166       G4cout << tmp->GetParticleName() << G4endl;
172       tmp->DumpTable();                           167       tmp->DumpTable();
173     }                                             168     }
174   }                                            << 169   } else if( command==verboseCmd ) {
175   else if (command == createAllIonCmd) {       << 170     //Commnad   /particle/verbose
176     // Command   /particle/createAllIon        << 
177     theParticleTable->GetIonTable()->CreateAll << 
178   }                                            << 
179   else if (command == createAllIsomerCmd) {    << 
180     // Command   /particle/createAllIsomer     << 
181     theParticleTable->GetIonTable()->CreateAll << 
182   }                                            << 
183   else if (command == verboseCmd) {            << 
184     // Command   /particle/verbose             << 
185     theParticleTable->SetVerboseLevel(verboseC    171     theParticleTable->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues));
186   }                                            << 172   }    
187 }                                                 173 }
188                                                   174 
189 G4String G4ParticleMessenger::GetCurrentValue( << 175 G4String G4ParticleMessenger::GetCurrentValue(G4UIcommand * command)
190 {                                                 176 {
191   if (command == selectCmd) {                  << 177   if( command==selectCmd ){
192     // Command  /particle/select               << 178     //Command  /particle/select
193     // set candidate List                         179     // set candidate List
194     G4String candidates("none");                  180     G4String candidates("none");
195     G4ParticleTable::G4PTblDicIterator* piter  << 181     G4ParticleTable::G4PTblDicIterator *piter = theParticleTable->GetIterator();
196     piter->reset();                            << 182     piter -> reset();
197     while ((*piter)())  // Loop checking, 09.0 << 183     while( (*piter)() ){
198     {                                          << 184       G4ParticleDefinition *particle = piter->value();
199       G4ParticleDefinition* particle = piter-> << 
200       candidates += " " + particle->GetParticl    185       candidates += " " + particle->GetParticleName();
201     }                                             186     }
202     selectCmd->SetCandidates((const char*)(can << 187     selectCmd->SetCandidates((const char *)(candidates));   
203                                                   188 
204     const G4ParticleDefinition* currentParticl << 189     static G4String noName("none");
205     return (currentParticle == nullptr) ? G4St << 190     // current value
206   }                                            << 191     if(currentParticle == 0) {
207   if (command == verboseCmd) {                 << 192       // no particle is selected. return null 
208     // Command   /particle/verbose             << 193       return noName;
                                                   >> 194     } else {
                                                   >> 195       return currentParticle->GetParticleName();
                                                   >> 196     }
                                                   >> 197   } else if( command==verboseCmd ){
                                                   >> 198     //Commnad   /particle/verbose
209     return verboseCmd->ConvertToString(thePart    199     return verboseCmd->ConvertToString(theParticleTable->GetVerboseLevel());
210   }                                               200   }
211   return "";                                      201   return "";
212 }                                                 202 }
                                                   >> 203 
                                                   >> 204 
                                                   >> 205 
                                                   >> 206 
                                                   >> 207 
                                                   >> 208 
213                                                   209