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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.6)


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