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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 7.1)


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