Changeset 962 for trunk/source/processes/hadronic/management/src
- Timestamp:
- Apr 6, 2009, 12:30:29 PM (17 years ago)
- Location:
- trunk/source/processes/hadronic/management/src
- Files:
-
- 3 edited
-
G4EnergyRangeManager.cc (modified) (1 diff)
-
G4HadronInelasticProcess.cc (modified) (2 diffs)
-
G4HadronicProcess.cc (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/management/src/G4EnergyRangeManager.cc
r819 r962 26 26 // 27 27 // $Id: G4EnergyRangeManager.cc,v 1.15 2006/06/29 19:58:21 gunter Exp $ 28 // GEANT4 tag $Name: $28 // GEANT4 tag $Name: geant4-09-02-ref-02 $ 29 29 // 30 30 // Hadronic Process: Energy Range Manager -
trunk/source/processes/hadronic/management/src/G4HadronInelasticProcess.cc
r819 r962 25 25 // 26 26 // 27 // 28 // Hadronic Inelastic Process Class 29 // J.L. Chuma, TRIUMF, 24-Mar-1997 30 // Last modified: 27-Mar-1997 31 // J.P. Wellisch: Bug hunting, 23-Apr-97 32 // Modified by J.L.Chuma 8-Jul-97 to eliminate possible division by zero for sigma 27 // Hadronic Inelastic Process Class 28 // J.L. Chuma, TRIUMF, 24-Mar-1997 29 // Last modified: 27-Mar-1997 30 // J.P. Wellisch: Bug hunting, 23-Apr-97 31 // Modified by J.L.Chuma 8-Jul-97 to eliminate possible division by zero for sigma 33 32 // 34 33 // 14-APR-98 F.W.Jones: variant G4HadronInelastic process for … … 36 35 // 37 36 // 17-JUN-98 F.W.Jones: removed extraneous code causing core dump. 37 // 01-SEP-2008 V.Ivanchenko: use methods from the base class 38 38 // 39 39 40 40 #include "G4HadronInelasticProcess.hh" 41 #include "G4HadronInelasticDataSet.hh" 41 42 #include "G4GenericIon.hh" 42 #include "G4ProcessManager.hh" 43 #include "G4ProcessVector.hh" 44 #include "G4HadronicException.hh" 43 #include "G4ParticleDefinition.hh" 45 44 46 void G4HadronInelasticProcess::BuildThePhysicsTable() 47 { 48 if (!G4HadronicProcess::GetCrossSectionDataStore()) { 49 return; 50 } 51 G4HadronicProcess::GetCrossSectionDataStore()->BuildPhysicsTable(*theParticle); 52 } 53 54 G4HadronInelasticProcess::G4HadronInelasticProcess( 55 const G4String &processName, 56 G4ParticleDefinition *aParticle ) : 57 G4HadronicProcess( processName ) 58 { 59 G4HadronicProcess::AddDataSet(new G4HadronInelasticDataSet); 60 theParticle = aParticle; 61 } 45 G4HadronInelasticProcess::G4HadronInelasticProcess(const G4String& processName, 46 G4ParticleDefinition* aParticle): 47 G4HadronicProcess(processName) 48 { 49 SetProcessSubType(fHadronInelastic); 50 AddDataSet(new G4HadronInelasticDataSet()); 51 theParticle = aParticle; 52 } 62 53 63 G4HadronInelasticProcess::~G4HadronInelasticProcess() { } 54 G4HadronInelasticProcess::~G4HadronInelasticProcess() 55 {} 64 56 65 G4VParticleChange *G4HadronInelasticProcess:: 66 PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) 67 { 68 if(0==GetLastCrossSection()&&!getenv("DebugNeutronHP")) 69 { 70 G4cerr << "G4HadronInelasticProcess: called for final state, while cross-section was zero"<<G4endl; 71 G4cerr << " Returning empty particle change...."<<G4endl; 72 G4double dummy=0; 73 G4ForceCondition condition; 74 G4double it = GetMeanFreePath(aTrack, dummy, &condition); 75 G4cerr << " current MeanFreePath is "<<it<<G4endl; 76 theParticleChange.Initialize(aTrack); 77 return &theParticleChange; 78 } 79 SetDispatch( this ); 80 return G4HadronicProcess::GeneralPostStepDoIt( aTrack, aStep ); 81 } 82 83 G4bool G4HadronInelasticProcess:: 84 IsApplicable(const G4ParticleDefinition& aP) 85 { 86 return theParticle == &aP || theParticle == G4GenericIon::GenericIon(); 87 } 88 89 G4double G4HadronInelasticProcess::GetMicroscopicCrossSection( 90 const G4DynamicParticle *aParticle, 91 const G4Element *anElement, 92 G4double aTemp) 93 { 94 // returns the microscopic cross section in GEANT4 internal units 95 96 if (!G4HadronicProcess::GetCrossSectionDataStore()) 97 { 98 throw G4HadronicException(__FILE__, __LINE__, 99 "G4HadronInelasticProcess::GetMicroscopicCrossSection: " 100 "no CrossSectionDataStore"); 101 return DBL_MIN; 102 } 103 return G4HadronicProcess::GetCrossSectionDataStore()->GetCrossSection(aParticle, anElement, aTemp); 104 105 } 106 107 /* end of file */ 57 G4bool G4HadronInelasticProcess::IsApplicable(const G4ParticleDefinition& aP) 58 { 59 return theParticle == &aP || theParticle == G4GenericIon::GenericIon(); 60 } -
trunk/source/processes/hadronic/management/src/G4HadronicProcess.cc
r819 r962 28 28 #include "G4Types.hh" 29 29 30 #include <fstream>31 #include <sstream>32 #include <stdlib.h>30 //#include <fstream> 31 //#include <sstream> 32 //#include <stdlib.h> 33 33 #include "G4HadronicProcess.hh" 34 // #include "G4EffectiveCharge.hh" 34 35 35 #include "G4HadProjectile.hh" 36 36 #include "G4ElementVector.hh" … … 49 49 #include "G4HadronicException.hh" 50 50 #include "G4HadReentrentException.hh" 51 #include "G4HadronicInteractionWrapper.hh" 51 52 #include "G4HadronicWhiteBoard.hh" 52 53 53 54 #include "G4HadSignalHandler.hh" 55 56 #include "G4HadronicProcessStore.hh" 54 57 55 58 #include <typeinfo> … … 72 75 void G4HadronicProcess:: 73 76 DisableIsotopeProductionGlobally() {isoIsEnabled = false;} 77 78 ////////////////////////////////////////////////////////////////// 74 79 75 80 G4HadronicProcess::G4HadronicProcess( const G4String &processName, … … 81 86 theTotalResult = new G4ParticleChange(); 82 87 theCrossSectionDataStore = new G4CrossSectionDataStore(); 88 G4HadronicProcessStore::Instance()->Register(this); 83 89 aScaleFactor = 1; 84 90 xBiasOn = false; 91 G4HadronicProcess_debug_flag = false; 85 92 if(getenv("SwitchLeadBiasOn")) theBias.push_back(new G4HadLeadBias()); 86 93 } … … 88 95 G4HadronicProcess::~G4HadronicProcess() 89 96 { 97 G4HadronicProcessStore::Instance()->DeRegister(this); 90 98 delete theTotalResult; 91 99 … … 94 102 std::for_each(theBias.begin(), theBias.end(), G4Delete()); 95 103 96 delete theOldIsoResult; delete theIsoResult; 104 delete theOldIsoResult; 105 delete theIsoResult; 97 106 delete theCrossSectionDataStore; 98 107 } … … 107 116 "Could not register G4HadronicInteraction"); 108 117 } 118 G4HadronicProcessStore::Instance()->RegisterInteraction(this, a); 119 } 120 121 void G4HadronicProcess::PreparePhysicsTable(const G4ParticleDefinition& p) 122 { 123 if(getenv("G4HadronicProcess_debug")) G4HadronicProcess_debug_flag = true; 124 G4HadronicProcessStore::Instance()->RegisterParticle(this, &p); 125 } 126 127 void G4HadronicProcess::BuildPhysicsTable(const G4ParticleDefinition& p) 128 { 129 theCrossSectionDataStore->BuildPhysicsTable(p); 130 G4HadronicProcessStore::Instance()->PrintInfo(&p); 109 131 } 110 132 … … 112 134 GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) 113 135 { 114 G4double sigma = 0.0;115 136 try 116 137 { 117 const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle(); 118 if( !IsApplicable(*aParticle->GetDefinition())) 119 { 120 G4cout << "Unrecoverable error: "<<G4endl; 121 G4ProcessManager * it = aParticle->GetDefinition()->GetProcessManager(); 122 G4ProcessVector * itv = it->GetProcessList(); 123 G4cout <<aParticle->GetDefinition()->GetParticleName()<< 124 " has the following processes:"<<G4endl; 125 for(G4int i=0; i<itv->size(); i++) 126 { 127 G4cout <<" "<<(*itv)[i]->GetProcessName()<<G4endl; 128 } 129 G4cout << "for kinetic energy "<<aParticle->GetKineticEnergy()<<G4endl; 130 G4cout << "and material "<<aTrack.GetMaterial()->GetName()<<G4endl; 131 G4Exception("G4HadronicProcess", "007", FatalException, 132 std::string(this->GetProcessName()+ 133 " was called for "+ 134 aParticle->GetDefinition()->GetParticleName()).c_str() ); 135 } 136 G4Material *aMaterial = aTrack.GetMaterial(); 137 ModelingState = 1; 138 139 sigma = theCrossSectionDataStore->GetCrossSection(aParticle, aMaterial); 140 141 sigma *= aScaleFactor; 142 theLastCrossSection = sigma; 138 ModelingState = 1; 139 theLastCrossSection = aScaleFactor* 140 theCrossSectionDataStore->GetCrossSection(aTrack.GetDynamicParticle(), 141 aTrack.GetMaterial()); 143 142 } 144 143 catch(G4HadronicException aR) … … 148 147 "G4HadronicProcess::GetMeanFreePath failed"); 149 148 } 150 if( sigma > 0.0 ) 151 return 1.0/sigma; 152 else 153 return DBL_MAX; 154 } 155 156 157 G4Element* G4HadronicProcess::ChooseAandZ( 158 const G4DynamicParticle *aParticle, const G4Material *aMaterial ) 159 { 160 std::pair<G4double, G4double> ZA = 161 theCrossSectionDataStore->SelectRandomIsotope(aParticle, aMaterial); 162 G4double ZZ = ZA.first; 163 G4double AA = ZA.second; 164 165 targetNucleus.SetParameters(AA, ZZ); 166 167 const G4int numberOfElements = aMaterial->GetNumberOfElements(); 168 const G4ElementVector* theElementVector = aMaterial->GetElementVector(); 169 G4Element* chosen = 0; 170 for (G4int i = 0; i < numberOfElements; i++) { 171 chosen = (*theElementVector)[i]; 172 if (chosen->GetZ() == ZZ) break; 173 } 174 return chosen; 175 } 176 177 178 struct G4Nancheck{ bool operator()(G4double aV){return (!(aV<1))&&(!(aV>-1));}}; 179 180 G4VParticleChange *G4HadronicProcess::GeneralPostStepDoIt( 181 const G4Track &aTrack, const G4Step &) 149 G4double res = DBL_MAX; 150 if( theLastCrossSection > 0.0 ) res = 1.0/theLastCrossSection; 151 return res; 152 } 153 154 G4double G4HadronicProcess:: 155 GetMicroscopicCrossSection(const G4DynamicParticle *aParticle, 156 const G4Element *anElement, 157 G4double aTemp ) 158 { 159 return 160 theCrossSectionDataStore->GetCrossSection(aParticle, anElement, aTemp); 161 } 162 163 G4VParticleChange *G4HadronicProcess::PostStepDoIt( 164 const G4Track &aTrack, const G4Step &) 182 165 { 183 166 // Debugging stuff 184 185 bool G4HadronicProcess_debug_flag = false;186 if(getenv("G4HadronicProcess_debug")) G4HadronicProcess_debug_flag = true;187 167 if(G4HadronicProcess_debug_flag) 188 168 std::cout << "@@@@ hadronic process start "<< std::endl; 189 169 // G4cout << theNumberOfInteractionLengthLeft<<G4endl; 190 #ifndef G4HadSignalHandler_off170 #ifndef G4HadSignalHandler_off 191 171 G4HadSignalHandler aHandler(G4HadronicProcess_local::G4HadronicProcessHandler_1); 192 #endif 193 194 if(aTrack.GetTrackStatus() != fAlive && aTrack.GetTrackStatus() != fSuspend) 195 { 196 G4cerr << "G4HadronicProcess: track in unusable state - " 197 <<aTrack.GetTrackStatus()<<G4endl; 198 G4cerr << "G4HadronicProcess: returning unchanged track "<<G4endl; 199 G4Exception("G4HadronicProcess", "001", JustWarning, "bailing out"); 172 #endif 173 174 if(aTrack.GetTrackStatus() != fAlive && aTrack.GetTrackStatus() != fSuspend) { 175 if (aTrack.GetTrackStatus() == fStopAndKill || 176 aTrack.GetTrackStatus() == fKillTrackAndSecondaries || 177 aTrack.GetTrackStatus() == fPostponeToNextEvent) { 178 G4cerr << "G4HadronicProcess: track in unusable state - " 179 << aTrack.GetTrackStatus() << G4endl; 180 G4cerr << "G4HadronicProcess: returning unchanged track " << G4endl; 181 G4Exception("G4HadronicProcess", "001", JustWarning, "bailing out"); 182 } 183 // No warning for fStopButAlive which is a legal status here 200 184 theTotalResult->Clear(); 201 185 theTotalResult->Initialize(aTrack); … … 203 187 } 204 188 205 const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();206 G4Material *aMaterial = aTrack.GetMaterial();189 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); 190 G4Material* aMaterial = aTrack.GetMaterial(); 207 191 G4double originalEnergy = aParticle->GetKineticEnergy(); 208 192 G4double kineticEnergy = originalEnergy; 209 193 210 // More debugging 211 194 /* 195 // It is not needed with standard NaN check 196 // More debugging 212 197 G4Nancheck go_wild; 213 198 if(go_wild(originalEnergy) || … … 223 208 return theTotalResult; 224 209 } 210 */ 225 211 226 212 // Get kinetic energy per nucleon for ions 227 228 213 if(aParticle->GetDefinition()->GetBaryonNumber() > 1.5) 229 214 kineticEnergy/=aParticle->GetDefinition()->GetBaryonNumber(); … … 232 217 try 233 218 { 234 anElement = ChooseAandZ( aParticle, aMaterial ); 219 // anElement = ChooseAandZ( aParticle, aMaterial ); 220 anElement = theCrossSectionDataStore->SampleZandA(aParticle, 221 aMaterial, 222 targetNucleus); 235 223 } 236 224 catch(G4HadronicException & aR) … … 243 231 <<aParticle->GetDefinition()->GetParticleName()<<G4endl; 244 232 G4Exception("G4HadronicProcess", "007", FatalException, 245 " GeneralPostStepDoIt failed on element selection.");233 "PostStepDoIt failed on element selection."); 246 234 } 247 235 … … 275 263 { 276 264 // Call the interaction 277 278 G4HadronicInteractionWrapper aW; 279 result = aW.ApplyInteraction(thePro, targetNucleus, theInteraction, 280 GetProcessName(), 281 theInteraction->GetModelName()); 265 result = theInteraction->ApplyYourself( thePro, targetNucleus); 282 266 } 283 267 catch(G4HadReentrentException aR) 284 268 { 269 G4HadronicWhiteBoard & theBoard = G4HadronicWhiteBoard::Instance(); 270 theBoard.SetProjectile(thePro); 271 theBoard.SetTargetNucleus(targetNucleus); 272 theBoard.SetProcessName(GetProcessName()); 273 theBoard.SetModelName(theInteraction->GetModelName()); 274 285 275 aR.Report(G4cout); 286 276 G4cout << " G4HadronicProcess re-entering the ApplyYourself call for " … … 294 284 { 295 285 G4Exception("G4HadronicProcess", "007", FatalException, 296 "GetHadronicProcess: Reentering ApplyYourself too often - GeneralPostStepDoIt failed.");286 "GetHadronicProcess: Reentering ApplyYourself too often - PostStepDoIt failed."); 297 287 } 298 288 G4Exception("G4HadronicProcess", "007", FatalException, 299 "GetHadronicProcess: GeneralPostStepDoIt failed (Reentering ApplyYourself not yet supported.)");289 "GetHadronicProcess: PostStepDoIt failed (Reentering ApplyYourself not yet supported.)"); 300 290 } 301 291 catch(G4HadronicException aR) 302 292 { 293 G4HadronicWhiteBoard & theBoard = G4HadronicWhiteBoard::Instance(); 294 theBoard.SetProjectile(thePro); 295 theBoard.SetTargetNucleus(targetNucleus); 296 theBoard.SetProcessName(GetProcessName()); 297 theBoard.SetModelName(theInteraction->GetModelName()); 298 303 299 aR.Report(G4cout); 304 300 G4cout << " G4HadronicProcess failed in ApplyYourself call for" … … 309 305 << aParticle->GetDefinition()->GetParticleName() << G4endl; 310 306 G4Exception("G4HadronicProcess", "007", FatalException, 311 " GeneralPostStepDoIt failed.");307 "PostStepDoIt failed."); 312 308 } 313 309 } … … 331 327 result->SetTrafoToLab(thePro.GetTrafoToLab()); 332 328 333 /*334 // Loop over charged ion secondaries335 336 for(G4int i=0; i<result->GetNumberOfSecondaries(); i++)337 {338 G4DynamicParticle* aSecTrack = result->GetSecondary(i)->GetParticle();339 if(aSecTrack->GetDefinition()->GetPDGCharge()>1.5)340 {341 G4EffectiveCharge aCalculator;342 G4double charge =343 aCalculator.GetCharge(aMaterial, aSecTrack->GetKineticEnergy(),344 aSecTrack->GetDefinition()->GetPDGMass(),345 aSecTrack->GetDefinition()->GetPDGCharge());346 if(getenv("GHADChargeDebug"))347 {348 std::cout << "Recoil fractional charge is "349 << charge/aSecTrack->GetDefinition()->GetPDGCharge()<<" "350 << charge <<" "<<aSecTrack->GetDefinition()->GetPDGCharge()<<std::endl;351 }352 aSecTrack->SetCharge(charge);353 }354 }355 */356 357 329 if(getenv("HadronicDoitLogging") ) 358 330 { 359 331 G4cout << "HadronicDoitLogging " 360 << GetProcessName() <<" "361 << aParticle->GetDefinition()->GetPDGEncoding()<<" "362 << originalEnergy<<" "363 << aParticle->GetMomentum()<<" "364 << targetNucleus.GetN()<<" "365 << targetNucleus.GetZ()<<" "366 << G4endl;332 << GetProcessName() <<" " 333 << aParticle->GetDefinition()->GetPDGEncoding()<<" " 334 << originalEnergy<<" " 335 << aParticle->GetMomentum()<<" " 336 << targetNucleus.GetN()<<" " 337 << targetNucleus.GetZ()<<" " 338 << G4endl; 367 339 } 368 340 … … 509 481 G4HadronicProcess::FillTotalResult(G4HadFinalState * aR, const G4Track & aT) 510 482 { 511 G4Nancheck go_wild;483 // G4Nancheck go_wild; 512 484 theTotalResult->Clear(); 513 485 theTotalResult->ProposeLocalEnergyDeposit(0.); … … 559 531 theTotalResult->ProposeParentWeight( XBiasSurvivalProbability()*aT.GetWeight() ); 560 532 G4double newWeight = aR->GetWeightChange()*aT.GetWeight(); 533 /* 561 534 if(go_wild(aR->GetEnergyChange())) 562 535 { … … 571 544 "surviving track received NaN momentum."); 572 545 } 546 */ 573 547 G4double newM=aT.GetDefinition()->GetPDGMass(); 574 548 G4double newE=aR->GetEnergyChange() + newM; … … 585 559 if(aR->GetEnergyChange()>-.5) 586 560 { 561 /* 587 562 if(go_wild(aR->GetEnergyChange())) 588 563 { … … 590 565 "track received NaN energy."); 591 566 } 567 */ 592 568 theTotalResult->ProposeEnergy(aR->GetEnergyChange()); 593 569 } … … 606 582 if(GetProcessName() != "hElastic" && GetProcessName() != "HadronElastic" 607 583 && theTotalResult->GetTrackStatus()==fAlive 608 && aR->GetStatusChange()==isAlive 609 ) 610 { 584 && aR->GetStatusChange()==isAlive) 585 { 611 586 // Use for debugging: G4double newWeight = theTotalResult->GetParentWeight(); 612 587 … … 643 618 theM.rotate(rotation, it); 644 619 theM*=aR->GetTrafoToLab(); 645 620 /* 646 621 if(go_wild(theM.e())) 647 622 { … … 656 631 "secondary track received NaN momentum."); 657 632 } 658 633 */ 659 634 aR->GetSecondary(i)->GetParticle()->Set4Momentum(theM); 660 635 G4double time = aR->GetSecondary(i)->GetTime(); … … 662 637 663 638 G4Track* track = new G4Track(aR->GetSecondary(i)->GetParticle(), 664 time,665 aT.GetPosition());639 time, 640 aT.GetPosition()); 666 641 667 642 G4double newWeight = aT.GetWeight()*aR->GetSecondary(i)->GetWeight(); … … 679 654 // <<G4endl; 680 655 track->SetWeight(newWeight); 656 /* 681 657 G4double trackDeb = track->GetKineticEnergy(); 682 658 if( ( trackDeb<0 … … 689 665 <<G4endl; 690 666 } 691 track->SetTouchableHandle(aT.GetTouchableHandle()); 692 theTotalResult->AddSecondary(track); 667 */ 668 track->SetTouchableHandle(aT.GetTouchableHandle()); 669 theTotalResult->AddSecondary(track); 693 670 } 694 671 … … 696 673 return; 697 674 } 675 676 G4IsoParticleChange* G4HadronicProcess::GetIsotopeProductionInfo() 677 { 678 G4IsoParticleChange * anIsoResult = theIsoResult; 679 if(theIsoResult) theOldIsoResult = theIsoResult; 680 theIsoResult = 0; 681 return anIsoResult; 682 } 683 684 void G4HadronicProcess::BiasCrossSectionByFactor(G4double aScale) 685 { 686 xBiasOn = true; 687 aScaleFactor = aScale; 688 G4String it = GetProcessName(); 689 if( (it != "PhotonInelastic") && 690 (it != "ElectroNuclear") && 691 (it != "PositronNuclear") ) 692 { 693 G4Exception("G4HadronicProcess", "007", FatalException, 694 "Cross-section biasing available only for gamma and electro nuclear reactions."); 695 } 696 if(aScale<100) 697 { 698 G4Exception("G4HadronicProcess", "001", JustWarning, 699 "Cross-section bias readjusted to be above safe limit. New value is 100"); 700 aScaleFactor = 100.; 701 } 702 } 698 703 /* end of file */
Note:
See TracChangeset
for help on using the changeset viewer.
