Changeset 1196 for trunk/source/run/src


Ignore:
Timestamp:
Nov 25, 2009, 5:13:58 PM (16 years ago)
Author:
garnier
Message:

update CVS release candidate geant4.9.3.01

Location:
trunk/source/run/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/run/src/G4RunManagerKernel.cc

    r1058 r1196  
    2525//
    2626//
    27 // $Id: G4RunManagerKernel.cc,v 1.43 2008/07/10 09:27:19 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4RunManagerKernel.cc,v 1.47 2009/11/13 23:13:40 asaim Exp $
     28// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2929//
    3030//
     
    8383  fRunManagerKernel = this;
    8484
     85  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
     86  if(particleTable->entries()>0)
     87  {
     88    // No particle should be registered beforehand
     89    G4cerr<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<G4endl;
     90    G4cerr<<" G4RunManagerKernel fatal exception"<<G4endl;
     91    G4cerr<<"  -- Following particles have already been registered"<<G4endl;
     92    G4cerr<<"     before G4RunManagerKernel is instantiated."<<G4endl;
     93    for(int i=0;i<particleTable->entries();i++)
     94    { G4cerr<<"     "<<particleTable->GetParticle(i)->GetParticleName()<<G4endl; }
     95    G4cerr<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<G4endl;
     96    G4Exception("G4RunManagerKernel::G4RunManagerKernel()","StaticParticleDefinition",
     97       FatalException,"Particles have already been instantiated before G4RunManagerKernel.");
     98  }
     99 
    85100  // construction of Geant4 kernel classes
    86101  eventManager = new G4EventManager();
     
    264279  physicsList->Construct();
    265280
     281  if(verboseLevel>1) G4cout << "physicsList->CheckParticleList() start." << G4endl;
     282  physicsList->CheckParticleList();
    266283  if(verboseLevel>1) G4cout << "physicsList->setCut() start." << G4endl;
    267284  physicsList->SetCuts();
     
    444461    std::vector<G4LogicalVolume*>::iterator lvItr = region->GetRootLogicalVolumeIterator();
    445462    for(size_t j=0;j<nRootLV;j++)
    446     { G4cout << (*lvItr)->GetName() << " "; }
     463    { G4cout << (*lvItr)->GetName() << " "; lvItr++; }
    447464    G4cout << G4endl;
    448465
     
    476493    }
    477494    G4cout << " Production cuts : "
    478            << " gamma " << G4BestUnit(cuts->GetProductionCut("gamma"),"Length")
    479            << "    e- " << G4BestUnit(cuts->GetProductionCut("e-"),"Length")
    480            << "    e+ " << G4BestUnit(cuts->GetProductionCut("e+"),"Length")
     495           << "  gamma " << G4BestUnit(cuts->GetProductionCut("gamma"),"Length")
     496           << "     e- " << G4BestUnit(cuts->GetProductionCut("e-"),"Length")
     497           << "     e+ " << G4BestUnit(cuts->GetProductionCut("e+"),"Length")
     498           << " proton " << G4BestUnit(cuts->GetProductionCut("proton"),"Length")
    481499           << G4endl;
    482500  }
  • trunk/source/run/src/G4UserPhysicsListMessenger.cc

    r1058 r1196  
    2525//
    2626//
    27 // $Id: G4UserPhysicsListMessenger.cc,v 1.28 2007/05/30 10:34:54 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4UserPhysicsListMessenger.cc,v 1.30 2009/10/20 07:07:51 kurasige Exp $
     28// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2929//
    3030//
     
    6868  verboseCmd->SetDefaultValue(0);
    6969  verboseCmd->SetRange("level >=0 && level <=3");
     70 
     71  // /run/setCut command
     72  setCutCmd = new G4UIcmdWithADoubleAndUnit("/run/setCut",this);
     73  setCutCmd->SetGuidance("Set default cut value ");
     74  setCutCmd->SetParameterName("cut",false);
     75  setCutCmd->SetDefaultValue(1.0);
     76  setCutCmd->SetRange("cut >0.0");
     77  setCutCmd->SetDefaultUnit("mm");
     78  setCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
    7079
    7180  // /run/particle/setCut command
     
    7988  setPCutCmd->SetDefaultUnit("mm");
    8089  setPCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
    81  
    82   // /run/setCut command
    83   setCutCmd = new G4UIcmdWithADoubleAndUnit("/run/setCut",this);
    84   setCutCmd->SetGuidance("Set default cut value ");
    85   setCutCmd->SetParameterName("cut",false);
    86   setCutCmd->SetDefaultValue(1.0);
    87   setCutCmd->SetRange("cut >0.0");
    88   setCutCmd->SetDefaultUnit("mm");
    89   setCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
     90
     91  // /run/setCutForAGivenParticle command
     92  setCutForAGivenParticleCmd = new G4UIcommand("/run/setCutForAGivenParticle",this) ;
     93  setCutForAGivenParticleCmd->SetGuidance("Set a cut value to a specific particle") ;
     94  setCutForAGivenParticleCmd->SetGuidance("Usage: /run/setCutForAGivenParticle  gamma  1. mm") ;
     95  param = new G4UIparameter("particleName",'s',false) ;
     96  param->SetParameterCandidates("e- e+ gamma proton");
     97  setCutForAGivenParticleCmd->SetParameter(param) ;
     98  param = new G4UIparameter("cut",'d',false) ;
     99  param->SetDefaultValue("1.") ;
     100  param->SetParameterRange("cut>0.0") ;
     101  setCutForAGivenParticleCmd->SetParameter(param) ;
     102  param = new G4UIparameter("unit",'s',false) ;
     103  param->SetDefaultValue("mm") ;
     104  setCutForAGivenParticleCmd->SetParameter(param) ;
     105  setCutForAGivenParticleCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
    90106
    91107  // /run/setCutForRegion command
     
    187203  delete setPCutCmd;
    188204  delete setCutCmd;
    189   delete setCutRCmd;
     205  delete setCutRCmd;
     206  delete setCutForAGivenParticleCmd;
    190207  delete verboseCmd;
    191208  delete dumpListCmd;
     
    202219void G4UserPhysicsListMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
    203220{
    204   if( command==setCutCmd || command==setPCutCmd ){
     221  if( command==setCutCmd ){
    205222    G4double newCut = setCutCmd->GetNewDoubleValue(newValue);
    206223    thePhysicsList->SetDefaultCutValue(newCut);
    207224    thePhysicsList->SetCutsWithDefault();
    208225
     226  } else if( command==setPCutCmd ){
     227    G4cout << "Please use /run/setCut command instead. This command will be removed" << G4endl;
     228    G4double newCut = setCutCmd->GetNewDoubleValue(newValue);
     229    thePhysicsList->SetDefaultCutValue(newCut);
     230    thePhysicsList->SetCutsWithDefault();
     231
     232  } else if( command==setCutForAGivenParticleCmd ){
     233    G4String particleName, unit ; G4double cut ;
     234    std::istringstream str (newValue) ;
     235    str >> particleName >> cut >> unit ;
     236    thePhysicsList->SetCutValue(cut*G4UIcommand::ValueOf(unit), particleName) ;
     237
    209238  } else if( command==setCutRCmd ){
    210     //G4Tokenizer next( newValue );
    211     //G4String rName = G4String(next());
    212     //G4String cValue = G4String(next())+" "+G4String(next());
    213     //G4double newCut = setCutCmd->GetNewDoubleValue(cValue);
    214     //thePhysicsList->SetCutsForRegion(newCut,rName);
    215239    std::istringstream is(newValue);
    216240    char regName[50];
     
    281305  G4ParticleTable::G4PTblDicIterator *piter = (G4ParticleTable::GetParticleTable())->GetIterator();
    282306 
    283   if( command==setCutCmd || command==setPCutCmd ){
     307  if( command==setCutCmd ) {
    284308    cv = setCutCmd->ConvertToString( thePhysicsList->GetDefaultCutValue(), "mm" );
    285309   
  • trunk/source/run/src/G4VUserPhysicsList.cc

    r1058 r1196  
    2525//
    2626//
    27 // $Id: G4VUserPhysicsList.cc,v 1.64 2008/05/09 13:00:42 kurasige Exp $
    28 // GEANT4 tag $Name: geant4-09-02-ref-02 $
     27// $Id: G4VUserPhysicsList.cc,v 1.71 2009/08/09 14:31:46 kurasige Exp $
     28// GEANT4 tag $Name: geant4-09-03-cand-01 $
    2929//
    3030//
     
    6868////////////////////////////////////////////////////////
    6969G4VUserPhysicsList::G4VUserPhysicsList()
    70                    :verboseLevel(1),
     70                 :  fDisableCheckParticleList(false),
     71                    verboseLevel(1),
    7172                    fRetrievePhysicsTable(false),
    7273                    fStoredInAscii(true),
     
    7576                    directoryPhysicsTable("."),
    7677                    fDisplayThreshold(0),
     78                    fIsPhysicsTableBuilt(false),
    7779                    useCoupledTransportation(false)
    7880{
     
    154156          // no process manager has been registered yet
    155157          newManager = new G4ProcessManager(newParticle);
     158          G4Exception("G4VUserPhysicsList::AddProcessManager","Error in GenericIon",
     159                RunMustBeAborted,"GenericIon has no ProcessMamanger"); 
    156160        }
    157161      } else {
    158162        // "GenericIon" does not exist
    159163        newManager = new G4ProcessManager(newParticle);
     164        G4Exception("G4VUserPhysicsList::AddProcessManager","No GenericIon",
     165                    RunMustBeAborted,"GenericIon does not exist");     
    160166      }
    161167
     
    180186  }
    181187#endif
    182   if (newParticle->GetParticleType() == "nucleus") {
     188  if ( fIsPhysicsTableBuilt
     189       && (newParticle->GetParticleType() == "nucleus")) {
    183190    PreparePhysicsTable(newParticle);
    184191    BuildPhysicsTable(newParticle);
     
    186193}
    187194
     195
     196////////////////////////////////////////////////////////
     197void G4VUserPhysicsList::CheckParticleList()
     198{
     199
     200  // skip if fDisableCheckParticleList is set 
     201  if (fDisableCheckParticleList) return;
     202
     203  bool isElectron = false;
     204  bool isPositron = false;
     205  bool isGamma    = false;
     206  bool isProton   = false;
     207  bool isGenericIon = false;
     208  bool isAnyIon   = false;
     209  bool isAnyChargedBaryon   = false;
     210  bool isEmProc   = false;
     211
     212  // loop over all particles in G4ParticleTable
     213  theParticleIterator->reset();
     214  while( (*theParticleIterator)() ){
     215    G4ParticleDefinition* particle = theParticleIterator->value();
     216    G4String name = particle->GetParticleName();
     217    // check if any EM process exists
     218    if (!isEmProc) {
     219      G4ProcessVector* list = particle->GetProcessManager()->GetProcessList();
     220      for (int idx=0; idx<list->size(); idx++){
     221        isEmProc = ((*list)[idx])->GetProcessType() == fElectromagnetic;
     222        if (isEmProc) break;
     223      }
     224    }
     225   
     226    if      ( name == "e-") isElectron = true;
     227    else if ( name == "e+") isPositron = true;
     228    else if ( name == "gamma") isGamma = true;
     229    else if ( name == "GenericIon") isGenericIon = true;
     230    else if ( name == "proton") isProton = true;
     231    else if ( particle->GetParticleType() == "nucleus") isAnyIon = true;
     232    else if ( particle->GetParticleType() == "baryon") {
     233       if ( particle->GetPDGCharge() != 0.0 ) isAnyChargedBaryon = true;
     234    }
     235  }
     236
     237  if (!isEmProc) return;
     238
     239  // RULE 1
     240  //  e+, e- and gamma should exist
     241  //   if one of them exist
     242  bool isEmBasic =  isElectron || isPositron || isGamma;
     243  bool isMissingEmBasic =  !isElectron || !isPositron || !isGamma;
     244  if (isEmBasic && isMissingEmBasic) {
     245    G4String missingName="";
     246    if (!isElectron) missingName += "e- ";
     247    if (!isPositron) missingName += "e+ ";
     248    if (!isGamma) missingName += "gamma ";
     249
     250#ifdef G4VERBOSE
     251    if (verboseLevel >0){
     252      G4cout << "G4VUserPhysicsList::CheckParticleList: ";
     253      G4cout << missingName << " do not exist " << G4endl;
     254      G4cout << " These particle are necessary for basic EM processes" << G4endl;
     255    }
     256#endif
     257    missingName += " should be created ";
     258    G4Exception("G4VUserPhysicsList::CheckParticleList","Missing EM basic particle",
     259                FatalException, missingName);   
     260  }
     261
     262  // RULE 2
     263  //  proton should exist
     264  //   if any other charged baryon  exist
     265  if (!isProton && isAnyChargedBaryon) {
     266    G4String missingName="proton ";
     267
     268#ifdef G4VERBOSE
     269    if (verboseLevel >0){
     270      G4cout << "G4VUserPhysicsList::CheckParticleList: ";
     271      G4cout << missingName << " does not exist "<< G4endl;
     272      G4cout << " Proton is necessary for EM baryon processes" << G4endl;
     273    }
     274#endif
     275    missingName += " should be created ";
     276    G4Exception("G4VUserPhysicsList::CheckParticleList","Missing Proton",
     277                FatalException, missingName);   
     278  }
     279   
     280  // RULE 3
     281  //  GenericIonn should exist
     282  //   if any other ion  exist
     283  if (!isGenericIon && isAnyIon) {
     284    G4String missingName="GenericIon ";
     285
     286#ifdef G4VERBOSE
     287    if (verboseLevel >0){
     288      G4cout << "G4VUserPhysicsList::CheckParticleList: ";
     289      G4cout << missingName << " does not exist "<< G4endl;
     290      G4cout << " GenericIon should be created if any ion is necessary" << G4endl;
     291    }
     292#endif
     293    missingName += " should be created ";
     294    G4Exception("G4VUserPhysicsList::CheckParticleList","Missing GenericIon",
     295                FatalException, missingName);   
     296  }
     297     
     298}
    188299
    189300////////////////////////////////////////////////////////
     
    203314}
    204315
    205 ////////////////////////////////////////////////////////
     316/////////////////////////////////////////////////////////
    206317void G4VUserPhysicsList::RemoveProcessManager()
    207318{
     
    263374        G4String particleName = particle->GetParticleName();
    264375        G4Exception("G4VUserPhysicsList::AddTransportation","No process manager",
    265                     RunMustBeAborted, particleName );
     376                    FatalException, particleName );
    266377      } else {
    267378        // add transportation with ordering = ( -1, "first", "first" )
     
    277388        G4String particleName = particle->GetParticleName();
    278389        G4Exception("G4VUserPhysicsList::AddTransportation","No process manager",
    279                     RunMustBeAborted, particleName );
     390                    FatalException, particleName );
    280391      } else {
    281392        // add transportation with ordering = ( -1, "first", "first" )
     
    359470  SetCutValue(cut, "e-");
    360471  SetCutValue(cut, "e+");
     472  SetCutValue(cut, "proton");
    361473
    362474  // dump Cut values if verboseLevel==3
     
    374486  SetCutValue(aCut, "e-", rname);
    375487  SetCutValue(aCut, "e+", rname);
     488  SetCutValue(aCut, "proton", rname);
    376489}
    377490
     
    450563    }
    451564  }
     565
     566  // Set flag
     567  fIsPhysicsTableBuilt = true;
     568
    452569}
    453570///////////////////////////////////////////////////////////////
     
    487604  // if particle is not ShortLived
    488605  if(!particle->IsShortLived()) {
    489     G4ProcessVector* pVector = particle->GetProcessManager()->GetProcessList();
     606    G4ProcessManager* pManager =  particle->GetProcessManager();
     607    if (!pManager) {
     608      G4cerr << "G4VUserPhysicsList::BuildPhysicsTable  : No Process Manager for "
     609             << particle->GetParticleName() <<G4endl;
     610      G4cerr << particle->GetParticleName() << " should be created in your PhysicsList" <<G4endl;
     611      G4Exception("G4VUserPhysicsList::BuildPhysicsTable","No process manager",
     612                    FatalException,  particle->GetParticleName() );
     613    }
     614    G4ProcessVector* pVector = pManager->GetProcessList();
     615    if (!pVector) {
     616      G4cerr << "G4VUserPhysicsList::BuildPhysicsTable  : No Process Vector for "
     617             << particle->GetParticleName() <<G4endl;
     618      G4cerr << particle->GetParticleName() << " should be created in your PhysicsList" <<G4endl;
     619      G4Exception("G4VUserPhysicsList::BuildPhysicsTable","No process Vector",
     620                    FatalException,  particle->GetParticleName() );
     621    }
    490622    for (G4int j=0; j < pVector->size(); ++j) {
    491623      (*pVector)[j]->BuildPhysicsTable(*particle);
     
    506638      G4cerr << particle->GetParticleName() << " should be created in your PhysicsList" <<G4endl;
    507639      G4Exception("G4VUserPhysicsList::PreparePhysicsTable","No process manager",
    508                     RunMustBeAborted,  particle->GetParticleName() );
     640                    FatalException,  particle->GetParticleName() );
    509641    }
    510642
    511643    G4ProcessVector* pVector = pManager->GetProcessList();
     644    if (!pVector) {
     645      G4cerr << "G4VUserPhysicsList::PreparePhysicsTable  : No Process Vector for "
     646             << particle->GetParticleName() <<G4endl;
     647      G4cerr << particle->GetParticleName() << " should be created in your PhysicsList" <<G4endl;
     648      G4Exception("G4VUserPhysicsList::PreparePhysicsTable","No process Vector",
     649                    FatalException,  particle->GetParticleName() );
     650    }
    512651    for (G4int j=0; j < pVector->size(); ++j) {
    513652      (*pVector)[j]->PreparePhysicsTable(*particle);
     
    690829    theParticleTable->FindParticle("e-")->SetApplyCutsFlag(value);
    691830    theParticleTable->FindParticle("e+")->SetApplyCutsFlag(value);
     831    theParticleTable->FindParticle("proton")->SetApplyCutsFlag(value);
    692832  } else {
    693833    theParticleTable->FindParticle(name)->SetApplyCutsFlag(value);
Note: See TracChangeset for help on using the changeset viewer.