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


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