Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -14,6 +14,17 @@ code and to keep track of all tags.
|
||||
* Please list in reverse chronological order (last date on top)
|
||||
---------------------------------------------------------------
|
||||
|
||||
19 November 2019 - Vladimir Ivanchenko (hadr-modman-V10-05-02)
|
||||
-----------------------------------------------------------
|
||||
- G4VHighEnergyGenerator - use inheritance from G4HadronicInteraction
|
||||
this reducing memory leak at exit in several times
|
||||
|
||||
13 July 2019 - Vladimir Ivanchenko (hadr-modman-V10-05-01)
|
||||
-----------------------------------------------------------
|
||||
- G4HadronicInteractionRegistry - use C++11 paterns
|
||||
- G4HadronicInteraction - fixed definition of model per element and
|
||||
material; use C++11 patterns
|
||||
|
||||
30 May 2019 - Vladimir Ivanchenko (hadr-modman-V10-05-00)
|
||||
-----------------------------------------------------------
|
||||
- G4HadronicInteractionRegistry - fixed typo in comments, remove unused
|
||||
|
||||
+1
-3
@@ -75,9 +75,7 @@ private:
|
||||
|
||||
static G4ThreadLocal G4HadronicInteractionRegistry* instance;
|
||||
|
||||
std::vector <G4HadronicInteraction*> allModels;
|
||||
G4bool isInitialized;
|
||||
|
||||
std::vector<G4HadronicInteraction*> allModels;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,17 +37,21 @@
|
||||
// generation of complete final states for inelastic scattering.
|
||||
// Class Description - End
|
||||
|
||||
#include "G4HadronicInteraction.hh"
|
||||
#include "G4Nucleus.hh"
|
||||
#include "G4HadProjectile.hh"
|
||||
class G4KineticTrackVector;
|
||||
#include "G4ReactionProduct.hh"
|
||||
#include "G4V3DNucleus.hh"
|
||||
|
||||
class G4VHighEnergyGenerator
|
||||
class G4KineticTrackVector;
|
||||
|
||||
class G4VHighEnergyGenerator : public G4HadronicInteraction
|
||||
{
|
||||
public:
|
||||
G4VHighEnergyGenerator(const G4String& modelName = "High Energy Generator");
|
||||
virtual ~G4VHighEnergyGenerator();
|
||||
~G4VHighEnergyGenerator() override;
|
||||
|
||||
G4HadFinalState *ApplyYourself(const G4HadProjectile&, G4Nucleus&) final;
|
||||
|
||||
private:
|
||||
G4VHighEnergyGenerator(const G4VHighEnergyGenerator &right);
|
||||
@@ -60,16 +64,7 @@ class G4VHighEnergyGenerator
|
||||
virtual G4V3DNucleus * GetProjectileNucleus() const; // Uzhi Nov. 2012
|
||||
virtual G4KineticTrackVector * Scatter(const G4Nucleus &theNucleus,
|
||||
const G4DynamicParticle &thePrimary) = 0;
|
||||
std::pair<G4double, G4double> GetEnergyMomentumCheckLevels() const;
|
||||
void SetEnergyMomentumCheckLevels(G4double relativeLevel, G4double AbsoluteLevel);
|
||||
virtual void ModelDescription(std::ostream&) const;
|
||||
virtual G4String GetModelName() const;
|
||||
|
||||
private:
|
||||
std::pair<G4double, G4double> epCheckLevels;
|
||||
|
||||
private:
|
||||
G4String theGeneratorModelName;
|
||||
void ModelDescription(std::ostream&) const override;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -36,13 +36,14 @@
|
||||
#include "G4HadronicInteraction.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4HadronicInteractionRegistry.hh"
|
||||
#include "G4HadronicException.hh"
|
||||
#include "G4HadronicParameters.hh"
|
||||
|
||||
G4HadronicInteraction::G4HadronicInteraction(const G4String& modelName) :
|
||||
verboseLevel(0), theMinEnergy(0.0), theMaxEnergy(25.0*GeV),
|
||||
verboseLevel(0), theMinEnergy(0.0),
|
||||
isBlocked(false), recoilEnergyThreshold(0.0), theModelName(modelName),
|
||||
epCheckLevels(DBL_MAX, DBL_MAX)
|
||||
{
|
||||
theMaxEnergy = G4HadronicParameters::Instance()->GetMaxEnergy();
|
||||
registry = G4HadronicInteractionRegistry::Instance();
|
||||
registry->RegisterMe(this);
|
||||
}
|
||||
@@ -71,51 +72,36 @@ G4bool G4HadronicInteraction::IsApplicable(const G4HadProjectile&,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
G4double G4HadronicInteraction::GetMinEnergy(
|
||||
const G4Material *aMaterial, const G4Element *anElement ) const
|
||||
{
|
||||
if( IsBlocked(aMaterial) ) { return 0.0; }
|
||||
if( IsBlocked(anElement) ) { return 0.0; }
|
||||
size_t length = theMinEnergyListElements.size();
|
||||
if(0 < length) {
|
||||
for(size_t i=0; i<length; ++i ) {
|
||||
if( anElement == theMinEnergyListElements[i].second )
|
||||
{ return theMinEnergyListElements[i].first; }
|
||||
if(!IsBlocked()) { return theMinEnergy; }
|
||||
if( IsBlocked(aMaterial) || IsBlocked(anElement) ) { return DBL_MAX; }
|
||||
if(!theMinEnergyListElements.empty()) {
|
||||
for(auto const& elmlist : theMinEnergyListElements) {
|
||||
if( anElement == elmlist.second )
|
||||
{ return elmlist.first; }
|
||||
}
|
||||
}
|
||||
length = theMinEnergyList.size();
|
||||
if(0 < length) {
|
||||
for(size_t i=0; i<length; ++i ) {
|
||||
if( aMaterial == theMinEnergyList[i].second )
|
||||
{ return theMinEnergyList[i].first; }
|
||||
if(!theMinEnergyList.empty()) {
|
||||
for(auto const & matlist : theMinEnergyList) {
|
||||
if( aMaterial == matlist.second )
|
||||
{ return matlist.first; }
|
||||
}
|
||||
}
|
||||
if(IsBlocked()) { return 0.0; }
|
||||
if( verboseLevel > 1 ) {
|
||||
G4cout << "*** Warning from HadronicInteraction::GetMinEnergy" << G4endl
|
||||
<< " material " << aMaterial->GetName()
|
||||
<< " not found in min energy List" << G4endl;
|
||||
}
|
||||
return theMinEnergy;
|
||||
}
|
||||
|
||||
void G4HadronicInteraction::SetMinEnergy(G4double anEnergy,
|
||||
const G4Element *anElement )
|
||||
{
|
||||
if( IsBlocked(anElement) ) {
|
||||
G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl
|
||||
<< " The model is not active for the Element "
|
||||
<< anElement->GetName() << "." << G4endl;
|
||||
}
|
||||
size_t length = theMinEnergyListElements.size();
|
||||
if(0 < length) {
|
||||
for(size_t i=0; i<length; ++i ) {
|
||||
if( anElement == theMinEnergyListElements[i].second )
|
||||
{
|
||||
theMinEnergyListElements[i].first = anEnergy;
|
||||
return;
|
||||
}
|
||||
Block();
|
||||
if(!theMinEnergyListElements.empty()) {
|
||||
for(auto & elmlist : theMinEnergyListElements) {
|
||||
if( anElement == elmlist.second ) {
|
||||
elmlist.first = anEnergy;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
theMinEnergyListElements.push_back(std::pair<G4double, const G4Element *>(anEnergy, anElement));
|
||||
@@ -124,19 +110,13 @@ void G4HadronicInteraction::SetMinEnergy(G4double anEnergy,
|
||||
void G4HadronicInteraction::SetMinEnergy(G4double anEnergy,
|
||||
const G4Material *aMaterial )
|
||||
{
|
||||
if( IsBlocked(aMaterial) ) {
|
||||
G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl
|
||||
<< " The model is not active for the Material "
|
||||
<< aMaterial->GetName() << "." << G4endl;
|
||||
}
|
||||
size_t length = theMinEnergyList.size();
|
||||
if(0 < length) {
|
||||
for(size_t i=0; i<length; ++i ) {
|
||||
if( aMaterial == theMinEnergyList[i].second )
|
||||
{
|
||||
theMinEnergyList[i].first = anEnergy;
|
||||
return;
|
||||
}
|
||||
Block();
|
||||
if(!theMinEnergyList.empty()) {
|
||||
for(auto & matlist : theMinEnergyList) {
|
||||
if( aMaterial == matlist.second ) {
|
||||
matlist.first = anEnergy;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
theMinEnergyList.push_back(std::pair<G4double, const G4Material *>(anEnergy, aMaterial));
|
||||
@@ -145,45 +125,31 @@ void G4HadronicInteraction::SetMinEnergy(G4double anEnergy,
|
||||
G4double G4HadronicInteraction::GetMaxEnergy(const G4Material *aMaterial,
|
||||
const G4Element *anElement ) const
|
||||
{
|
||||
if( IsBlocked(aMaterial) ) { return 0.0; }
|
||||
if( IsBlocked(anElement) ) { return 0.0; }
|
||||
size_t length = theMaxEnergyListElements.size();
|
||||
if(0 < length) {
|
||||
for(size_t i=0; i<length; ++i ) {
|
||||
if( anElement == theMaxEnergyListElements[i].second )
|
||||
{ return theMaxEnergyListElements[i].first; }
|
||||
if(!IsBlocked()) { return theMaxEnergy; }
|
||||
if( IsBlocked(aMaterial) || IsBlocked(anElement) ) { return 0.0; }
|
||||
if(!theMaxEnergyListElements.empty()) {
|
||||
for(auto const& elmlist : theMaxEnergyListElements) {
|
||||
if( anElement == elmlist.second )
|
||||
{ return elmlist.first; }
|
||||
}
|
||||
}
|
||||
length = theMaxEnergyList.size();
|
||||
if(0 < length) {
|
||||
for(size_t i=0; i<length; ++i ) {
|
||||
if( aMaterial == theMaxEnergyList[i].second )
|
||||
{ return theMaxEnergyList[i].first; }
|
||||
if(!theMaxEnergyList.empty()) {
|
||||
for(auto const& matlist : theMaxEnergyList) {
|
||||
if( aMaterial == matlist.second )
|
||||
{ return matlist.first; }
|
||||
}
|
||||
}
|
||||
if(IsBlocked()) { return 0.0; }
|
||||
if( verboseLevel > 1 ) {
|
||||
G4cout << "*** Warning from HadronicInteraction::GetMaxEnergy" << G4endl
|
||||
<< " material " << aMaterial->GetName()
|
||||
<< " not found in min energy List" << G4endl;
|
||||
}
|
||||
return theMaxEnergy;
|
||||
}
|
||||
|
||||
void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy,
|
||||
const G4Element *anElement )
|
||||
{
|
||||
if( IsBlocked(anElement) ) {
|
||||
G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl
|
||||
<< "Warning: The model is not active for the Element "
|
||||
<< anElement->GetName() << "." << G4endl;
|
||||
}
|
||||
size_t length = theMaxEnergyListElements.size();
|
||||
if(0 < length) {
|
||||
for(size_t i=0; i<length; ++i ) {
|
||||
if( anElement == theMaxEnergyListElements[i].second )
|
||||
{
|
||||
theMaxEnergyListElements[i].first = anEnergy;
|
||||
Block();
|
||||
if(!theMaxEnergyListElements.empty()) {
|
||||
for(auto & elmlist : theMaxEnergyListElements) {
|
||||
if( anElement == elmlist.second ) {
|
||||
elmlist.first = anEnergy;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -191,22 +157,15 @@ void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy,
|
||||
theMaxEnergyListElements.push_back(std::pair<G4double, const G4Element *>(anEnergy, anElement));
|
||||
}
|
||||
|
||||
void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy,
|
||||
const G4Material *aMaterial )
|
||||
void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy, const G4Material *aMaterial )
|
||||
{
|
||||
if( IsBlocked(aMaterial) ) {
|
||||
G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl
|
||||
<< "Warning: The model is not active for the Material "
|
||||
<< aMaterial->GetName() << "." << G4endl;
|
||||
}
|
||||
size_t length = theMaxEnergyList.size();
|
||||
if(0 < length) {
|
||||
for(size_t i=0; i<length; ++i ) {
|
||||
if( aMaterial == theMaxEnergyList[i].second )
|
||||
{
|
||||
theMaxEnergyList[i].first = anEnergy;
|
||||
return;
|
||||
}
|
||||
Block();
|
||||
if(!theMaxEnergyList.empty()) {
|
||||
for(auto & matlist: theMaxEnergyList) {
|
||||
if( aMaterial == matlist.second ) {
|
||||
matlist.first = anEnergy;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
theMaxEnergyList.push_back(std::pair<G4double, const G4Material *>(anEnergy, aMaterial));
|
||||
@@ -214,19 +173,21 @@ void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy,
|
||||
|
||||
void G4HadronicInteraction::DeActivateFor( const G4Material *aMaterial )
|
||||
{
|
||||
Block();
|
||||
theBlockedList.push_back(aMaterial);
|
||||
}
|
||||
|
||||
void G4HadronicInteraction::DeActivateFor( const G4Element *anElement )
|
||||
{
|
||||
Block();
|
||||
theBlockedListElements.push_back(anElement);
|
||||
}
|
||||
|
||||
|
||||
G4bool G4HadronicInteraction::IsBlocked(const G4Material* aMaterial) const
|
||||
{
|
||||
for (size_t i=0; i<theBlockedList.size(); ++i) {
|
||||
if (aMaterial == theBlockedList[i]) return true;
|
||||
for (auto const& mat : theBlockedList) {
|
||||
if (aMaterial == mat) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -234,16 +195,16 @@ G4bool G4HadronicInteraction::IsBlocked(const G4Material* aMaterial) const
|
||||
|
||||
G4bool G4HadronicInteraction::IsBlocked(const G4Element* anElement) const
|
||||
{
|
||||
for (size_t i=0; i<theBlockedListElements.size(); ++i) {
|
||||
if (anElement == theBlockedListElements[i]) return true;
|
||||
for (auto const& elm : theBlockedListElements) {
|
||||
if (anElement == elm) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::pair<G4double, G4double> G4HadronicInteraction::GetFatalEnergyCheckLevels() const
|
||||
{
|
||||
// default level of Check
|
||||
return std::pair<G4double, G4double>(2.*perCent, 1. * GeV);
|
||||
// default level of Check
|
||||
return std::pair<G4double, G4double>(2.*perCent, 1. * GeV);
|
||||
}
|
||||
|
||||
std::pair<G4double, G4double>
|
||||
@@ -252,25 +213,8 @@ G4HadronicInteraction::GetEnergyMomentumCheckLevels() const
|
||||
return epCheckLevels;
|
||||
}
|
||||
|
||||
|
||||
void G4HadronicInteraction::ModelDescription(std::ostream& outFile) const
|
||||
{
|
||||
outFile << "The description for this model has not been written yet.\n";
|
||||
}
|
||||
|
||||
/*
|
||||
G4HadronicInteraction::G4HadronicInteraction(const G4HadronicInteraction &right )
|
||||
{
|
||||
*this = right;
|
||||
}
|
||||
|
||||
const G4HadronicInteraction&
|
||||
G4HadronicInteraction::operator=(const G4HadronicInteraction &right )
|
||||
{
|
||||
G4String text = "unintended use of G4HadronicInteraction::operator=";
|
||||
throw G4HadronicException(__FILE__, __LINE__, text);
|
||||
return right;
|
||||
}
|
||||
*/
|
||||
/* end of file */
|
||||
|
||||
|
||||
@@ -76,9 +76,8 @@ void G4HadronicInteractionRegistry::Clean()
|
||||
|
||||
void G4HadronicInteractionRegistry::InitialiseModels()
|
||||
{
|
||||
size_t nModels = allModels.size();
|
||||
for (size_t i=0; i<nModels; ++i) {
|
||||
if( allModels[i] ) { allModels[i]->InitialiseModel(); }
|
||||
for (auto & mod : allModels) {
|
||||
if( mod ) { mod->InitialiseModel(); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,9 +85,8 @@ void
|
||||
G4HadronicInteractionRegistry::RegisterMe(G4HadronicInteraction * aModel)
|
||||
{
|
||||
if(!aModel) { return; }
|
||||
size_t nModels = allModels.size();
|
||||
for (size_t i=0; i<nModels; ++i) {
|
||||
if( aModel == allModels[i] ) { return; }
|
||||
for (auto & mod : allModels) {
|
||||
if( aModel == mod ) { return; }
|
||||
}
|
||||
//G4cout << "Register model <" << aModel->GetModelName()
|
||||
// << "> " << nModels+1 << " " << aModel << G4endl;
|
||||
@@ -99,12 +97,11 @@ void
|
||||
G4HadronicInteractionRegistry::RemoveMe(G4HadronicInteraction * aModel)
|
||||
{
|
||||
if(!aModel) { return; }
|
||||
size_t nModels = allModels.size();
|
||||
for (size_t i=0; i<nModels; ++i) {
|
||||
for (size_t i=0; i<allModels.size(); ++i) {
|
||||
if( aModel == allModels[i] ) {
|
||||
//G4cout << "DeRegister model <" << aModel
|
||||
// << "> " << i << G4endl;
|
||||
allModels[i] = 0;
|
||||
allModels[i] = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -113,16 +110,11 @@ G4HadronicInteractionRegistry::RemoveMe(G4HadronicInteraction * aModel)
|
||||
G4HadronicInteraction*
|
||||
G4HadronicInteractionRegistry::FindModel(const G4String& name)
|
||||
{
|
||||
G4HadronicInteraction* model = 0;
|
||||
|
||||
size_t nModels = allModels.size();
|
||||
for (size_t i=0; i<nModels; ++i) {
|
||||
G4HadronicInteraction* p = allModels[i];
|
||||
if(p) {
|
||||
if (p->GetModelName() == name) {
|
||||
model = p;
|
||||
break;
|
||||
}
|
||||
G4HadronicInteraction* model = nullptr;
|
||||
for (auto & mod : allModels) {
|
||||
if(mod && mod->GetModelName() == name) {
|
||||
model = mod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return model;
|
||||
@@ -132,14 +124,9 @@ std::vector<G4HadronicInteraction*>
|
||||
G4HadronicInteractionRegistry::FindAllModels(const G4String& name)
|
||||
{
|
||||
std::vector<G4HadronicInteraction*> models;
|
||||
|
||||
size_t nModels = allModels.size();
|
||||
for (size_t i=0; i<nModels; ++i) {
|
||||
G4HadronicInteraction* p = allModels[i];
|
||||
if(p) {
|
||||
if (p->GetModelName() == name) {
|
||||
models.push_back(p);
|
||||
}
|
||||
for (auto & mod : allModels) {
|
||||
if(mod && mod->GetModelName() == name) {
|
||||
models.push_back(mod);
|
||||
}
|
||||
}
|
||||
return models;
|
||||
|
||||
@@ -29,29 +29,20 @@
|
||||
//
|
||||
// G4VHighEnergyGenerator
|
||||
#include "G4VHighEnergyGenerator.hh"
|
||||
#include "G4HadronicException.hh"
|
||||
|
||||
G4VHighEnergyGenerator::G4VHighEnergyGenerator(const G4String& modelName)
|
||||
: epCheckLevels(DBL_MAX,DBL_MAX)
|
||||
: G4HadronicInteraction(modelName)
|
||||
{
|
||||
theGeneratorModelName=modelName;
|
||||
}
|
||||
|
||||
|
||||
G4VHighEnergyGenerator::~G4VHighEnergyGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<G4double, G4double> G4VHighEnergyGenerator::GetEnergyMomentumCheckLevels() const
|
||||
G4HadFinalState*
|
||||
G4VHighEnergyGenerator::ApplyYourself(const G4HadProjectile&, G4Nucleus&)
|
||||
{
|
||||
return epCheckLevels;
|
||||
}
|
||||
|
||||
void G4VHighEnergyGenerator::SetEnergyMomentumCheckLevels(
|
||||
G4double relativeLevel, G4double absoluteLevel)
|
||||
{
|
||||
epCheckLevels.first=relativeLevel;
|
||||
epCheckLevels.second=absoluteLevel;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void G4VHighEnergyGenerator::ModelDescription(std::ostream& outFile) const
|
||||
@@ -59,15 +50,10 @@ void G4VHighEnergyGenerator::ModelDescription(std::ostream& outFile) const
|
||||
outFile << " Parton-string models description not written yet \n";
|
||||
}
|
||||
|
||||
G4String G4VHighEnergyGenerator::GetModelName() const
|
||||
{
|
||||
return theGeneratorModelName;
|
||||
}
|
||||
|
||||
G4V3DNucleus * G4VHighEnergyGenerator::GetProjectileNucleus() const // Uzhi Nov. 2012
|
||||
{ // Uzhi Nov. 2012
|
||||
G4ExceptionDescription ed;
|
||||
ed << "The used HighEnergyGenerator "<<GetModelName()<<" cannot manage with a residual projectile nucleus" << G4endl;
|
||||
ed << "The used HighEnergyGenerator "<<GetModelName()<<" cannot manage with a residual projectile nucleus";
|
||||
G4Exception("G4VHighEnergyGenerator::GetProjectileNucleus ", "G4had_mod_man",
|
||||
FatalException, ed);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user