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5 ] [ 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/G4ParticlePropertyMessenger.cc (Version 11.3.0) and /particles/management/src/G4ParticlePropertyMessenger.cc (Version 10.7.p3)


  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 // G4ParticlePropertyMessenger class implement     26 // G4ParticlePropertyMessenger class implementation
 27 //                                                 27 //
 28 // Author: H.Kurashige, 13 June 1997 - 1st ver     28 // Author: H.Kurashige, 13 June 1997 - 1st version created
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4ParticlePropertyMessenger.hh"          31 #include "G4ParticlePropertyMessenger.hh"
 32                                                <<  32 #include "G4UImanager.hh"
 33 #include "G4DecayTableMessenger.hh"            <<  33 #include "G4UIdirectory.hh"
                                                   >>  34 #include "G4UIcmdWithoutParameter.hh"
                                                   >>  35 #include "G4UIcmdWithAnInteger.hh"
                                                   >>  36 #include "G4UIcmdWithADoubleAndUnit.hh"
                                                   >>  37 #include "G4UIcmdWithABool.hh"
 34 #include "G4ParticleDefinition.hh"                 38 #include "G4ParticleDefinition.hh"
                                                   >>  39 #include "G4DecayTableMessenger.hh"
                                                   >>  40 #include "G4ParticlePropertyMessenger.hh"
 35 #include "G4ParticleTable.hh"                      41 #include "G4ParticleTable.hh"
 36 #include "G4UIcmdWithABool.hh"                 << 
 37 #include "G4UIcmdWithADoubleAndUnit.hh"        << 
 38 #include "G4UIcmdWithAnInteger.hh"             << 
 39 #include "G4UIcmdWithoutParameter.hh"          << 
 40 #include "G4UIdirectory.hh"                    << 
 41 #include "G4UImanager.hh"                      << 
 42 #include "G4ios.hh"                                42 #include "G4ios.hh"
 43                                                    43 
 44 #include <iomanip>  // Include from 'system'   <<  44 #include <iomanip>                  // Include from 'system'
 45                                                    45 
 46 G4ParticlePropertyMessenger::G4ParticlePropert <<  46 G4ParticlePropertyMessenger::
                                                   >>  47 G4ParticlePropertyMessenger(G4ParticleTable* pTable)
 47   : theParticleTable(pTable)                       48   : theParticleTable(pTable)
 48 {                                                  49 {
 49   if (theParticleTable == nullptr) theParticle <<  50   if ( theParticleTable == nullptr)
                                                   >>  51     theParticleTable = G4ParticleTable::GetParticleTable();
 50                                                    52 
 51   // Command   /particle/property/                 53   // Command   /particle/property/
 52   thisDirectory = new G4UIdirectory("/particle     54   thisDirectory = new G4UIdirectory("/particle/property/");
 53   thisDirectory->SetGuidance("Particle Table c     55   thisDirectory->SetGuidance("Particle Table control commands.");
 54                                                    56 
 55   // Command   /particle/property/dump             57   // Command   /particle/property/dump
 56   dumpCmd = new G4UIcmdWithoutParameter("/part <<  58   dumpCmd = new G4UIcmdWithoutParameter("/particle/property/dump",this);
 57   dumpCmd->SetGuidance("Dump particle properti     59   dumpCmd->SetGuidance("Dump particle properties.");
 58                                                    60 
 59   // Command   /particle/property/stable           61   // Command   /particle/property/stable
 60   stableCmd = new G4UIcmdWithABool("/particle/ <<  62   stableCmd = new G4UIcmdWithABool("/particle/property/stable",this);
 61   stableCmd->SetGuidance("Set stable flag.");      63   stableCmd->SetGuidance("Set stable flag.");
 62   stableCmd->SetGuidance("  false: Unstable        64   stableCmd->SetGuidance("  false: Unstable   true: Stable");
 63   stableCmd->SetParameterName("stable", false) <<  65   stableCmd->SetParameterName("stable",false);
 64   stableCmd->AvailableForStates(G4State_PreIni <<  66   stableCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
 65                                                    67 
 66   // Command   /particle/property/lifetime         68   // Command   /particle/property/lifetime
 67   lifetimeCmd = new G4UIcmdWithADoubleAndUnit( <<  69   lifetimeCmd = new G4UIcmdWithADoubleAndUnit("/particle/property/lifetime",this);
 68   lifetimeCmd->SetGuidance("Set life time.");      70   lifetimeCmd->SetGuidance("Set life time.");
 69   lifetimeCmd->SetGuidance("Unit of the time c     71   lifetimeCmd->SetGuidance("Unit of the time can be :");
 70   lifetimeCmd->SetGuidance(" s, ms, ns (defaul     72   lifetimeCmd->SetGuidance(" s, ms, ns (default)");
 71   lifetimeCmd->SetParameterName("life", false) <<  73   lifetimeCmd->SetParameterName("life",false);
 72   lifetimeCmd->SetDefaultValue(0.0);               74   lifetimeCmd->SetDefaultValue(0.0);
 73   lifetimeCmd->SetRange("life >0.0");              75   lifetimeCmd->SetRange("life >0.0");
 74   // lifetimeCmd->SetUnitCategory("Time");     <<  76   //lifetimeCmd->SetUnitCategory("Time");
 75   // lifetimeCmd->SetUnitCandidates("s ms ns") <<  77   //lifetimeCmd->SetUnitCandidates("s ms ns");
 76   lifetimeCmd->SetDefaultUnit("ns");               78   lifetimeCmd->SetDefaultUnit("ns");
 77   lifetimeCmd->AvailableForStates(G4State_PreI <<  79   lifetimeCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
 78                                                    80 
 79   // -- particle/property/Verbose ---              81   // -- particle/property/Verbose ---
 80   verboseCmd = new G4UIcmdWithAnInteger("/part <<  82   verboseCmd = new G4UIcmdWithAnInteger("/particle/property/verbose",this);
 81   verboseCmd->SetGuidance("Set Verbose level o     83   verboseCmd->SetGuidance("Set Verbose level of particle property.");
 82   verboseCmd->SetGuidance(" 0 : Silent (defaul     84   verboseCmd->SetGuidance(" 0 : Silent (default)");
 83   verboseCmd->SetGuidance(" 1 : Display warnin     85   verboseCmd->SetGuidance(" 1 : Display warning messages");
 84   verboseCmd->SetGuidance(" 2 : Display more")     86   verboseCmd->SetGuidance(" 2 : Display more");
 85   verboseCmd->SetParameterName("verbose_level" <<  87   verboseCmd->SetParameterName("verbose_level",true);
 86   verboseCmd->SetDefaultValue(0);                  88   verboseCmd->SetDefaultValue(0);
 87   verboseCmd->SetRange("verbose_level >=0");       89   verboseCmd->SetRange("verbose_level >=0");
 88                                                    90 
 89   // UI messenger for Decay Table                  91   // UI messenger for Decay Table
 90   fDecayTableMessenger = new G4DecayTableMesse     92   fDecayTableMessenger = new G4DecayTableMessenger(theParticleTable);
 91 }                                                  93 }
 92                                                    94 
 93 G4ParticlePropertyMessenger::~G4ParticleProper     95 G4ParticlePropertyMessenger::~G4ParticlePropertyMessenger()
 94 {                                                  96 {
 95   delete fDecayTableMessenger;                     97   delete fDecayTableMessenger;
 96   fDecayTableMessenger = nullptr;                  98   fDecayTableMessenger = nullptr;
 97                                                    99 
 98   delete stableCmd;                            << 100   delete stableCmd; 
 99   delete verboseCmd;                              101   delete verboseCmd;
100   delete lifetimeCmd;                             102   delete lifetimeCmd;
101   delete dumpCmd;                                 103   delete dumpCmd;
102   delete thisDirectory;                           104   delete thisDirectory;
103 }                                              << 105 } 
104                                                   106 
105 void G4ParticlePropertyMessenger::SetNewValue( << 107 void G4ParticlePropertyMessenger::
                                                   >> 108 SetNewValue(G4UIcommand* command, G4String newValue)
106 {                                                 109 {
107   auto currentParticle = const_cast<G4Particle << 110   if (SetCurrentParticle() == nullptr)
108                                                << 111   {
109   if (currentParticle == nullptr) {            << 
110     G4cout << "Particle is not selected yet !!    112     G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
111     return;                                       113     return;
112   }                                               114   }
113                                                   115 
114   if (command == dumpCmd) {                    << 116   if( command == dumpCmd )
                                                   >> 117   {
115     // Command   /particle/property/dump          118     // Command   /particle/property/dump
116     currentParticle->DumpTable();                 119     currentParticle->DumpTable();
                                                   >> 120 
117   }                                               121   }
118   else if (command == lifetimeCmd) {           << 122   else if (command == lifetimeCmd )
                                                   >> 123   {
119     // Command   /particle/property/lifetime      124     // Command   /particle/property/lifetime
120     currentParticle->SetPDGLifeTime(lifetimeCm << 125     currentParticle->SetPDGLifeTime(lifetimeCmd->GetNewDoubleValue(newValue)); 
                                                   >> 126 
121   }                                               127   }
122   else if (command == stableCmd) {             << 128   else if (command == stableCmd )
                                                   >> 129   {
123     // Command   /particle/property/stable        130     // Command   /particle/property/stable
124     if (currentParticle->GetPDGLifeTime() < 0. << 131     if (currentParticle->GetPDGLifeTime()<0.0)
125       G4cout << "Life time is negative! Comman << 132     {
                                                   >> 133       G4cout << "Life time is negative! Command ignored." << G4endl; 
126     }                                             134     }
127     else if (currentParticle->GetPDGMass() <=  << 135     else if (currentParticle->GetPDGMass()<=0.0)
128       G4cout << "Zero Mass! Command ignored."  << 136     {
                                                   >> 137       G4cout << "Zero Mass! Command ignored." << G4endl; 
129     }                                             138     }
130     else {                                     << 139     else
                                                   >> 140     {
131       currentParticle->SetPDGStable(stableCmd-    141       currentParticle->SetPDGStable(stableCmd->GetNewBoolValue(newValue));
132     }                                             142     }
                                                   >> 143   
133   }                                               144   }
134   else if (command == verboseCmd) {            << 145   else if( command==verboseCmd )
                                                   >> 146   {
135     // Command   /particle/property/Verbose       147     // Command   /particle/property/Verbose
136     currentParticle->SetVerboseLevel(verboseCm << 148     currentParticle->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue)); 
137   }                                               149   }
138 }                                                 150 }
139                                                   151 
                                                   >> 152 G4ParticleDefinition* G4ParticlePropertyMessenger::SetCurrentParticle()
                                                   >> 153 {
                                                   >> 154   // Set currentParticle pointer
                                                   >> 155   
                                                   >> 156   // Get particle name by asking G4ParticleMessenger via UImanager
                                                   >> 157   //
                                                   >> 158   G4String particleName
                                                   >> 159     = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
                                                   >> 160   
                                                   >> 161   if ( currentParticle != nullptr )
                                                   >> 162   {
                                                   >> 163     // check whether selection is changed 
                                                   >> 164     if (currentParticle->GetParticleName() != particleName)
                                                   >> 165     {
                                                   >> 166       currentParticle = theParticleTable->FindParticle(particleName);
                                                   >> 167     }
                                                   >> 168   }
                                                   >> 169   else
                                                   >> 170   {
                                                   >> 171     currentParticle = theParticleTable->FindParticle(particleName);
                                                   >> 172   }
                                                   >> 173   return currentParticle;
                                                   >> 174 }
                                                   >> 175 
140 G4String G4ParticlePropertyMessenger::GetCurre    176 G4String G4ParticlePropertyMessenger::GetCurrentValue(G4UIcommand* command)
141 {                                                 177 {
142   G4String returnValue(1, '\0');               << 178   G4String returnValue('\0');
143                                                   179 
144   const G4ParticleDefinition* currentParticle  << 180   if ( SetCurrentParticle() == nullptr )
145   if (currentParticle == nullptr) {            << 181   {
146     return returnValue;  // no particle is sel << 182     return returnValue;  // no particle is selected. return null 
147   }                                               183   }
148                                                   184 
149   if (command == stableCmd) {                  << 185   if( command == stableCmd )
                                                   >> 186   {
150     // Command   /particle/property/stable        187     // Command   /particle/property/stable
151     returnValue = stableCmd->ConvertToString(c << 188     returnValue = stableCmd->ConvertToString( currentParticle->GetPDGStable());
152   }                                               189   }
153   else if (command == lifetimeCmd) {           << 190   else if( command == lifetimeCmd )
                                                   >> 191   {
154     // Command   /particle/property/lifetime      192     // Command   /particle/property/lifetime
155     returnValue = lifetimeCmd->ConvertToString << 193     returnValue = lifetimeCmd->ConvertToString( currentParticle->GetPDGLifeTime(), "ns" );
156   }                                               194   }
157   else if (command == verboseCmd) {            << 195   else if( command==verboseCmd )
                                                   >> 196   {
158     // Command   /particle/property/Verbose       197     // Command   /particle/property/Verbose
159     returnValue = verboseCmd->ConvertToString( << 198     returnValue= verboseCmd->ConvertToString(currentParticle->GetVerboseLevel());
160   }                                            << 199   } 
161                                                << 200   
162   return returnValue;                             201   return returnValue;
163 }                                                 202 }
164                                                   203