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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 9.3.p2)


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