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