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