Commit 84d0f7a5 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'rhadron' into 'master'

Rhadrons: initial thread-checker fixes

See merge request atlas/athena!54672
parents ed74a922 4b098246
......@@ -20,7 +20,7 @@ if( NOT GENERATIONBASE )
OBJECT
NO_PUBLIC_HEADERS
PRIVATE_INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${PYTHIA8_INCLUDE_DIRS}
PRIVATE_LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} ${PYTHIA8_LIBRARIES} GaudiKernel AthenaBaseComps G4AtlasInterfaces G4AtlasToolsLib G4ExternalDecay SimHelpers Pythia8_iLib )
PRIVATE_LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} ${PYTHIA8_LIBRARIES} GaudiKernel AthenaBaseComps CxxUtils G4AtlasInterfaces G4AtlasToolsLib G4ExternalDecay SimHelpers Pythia8_iLib )
endif()
# Install files from the package:
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include <fstream>
......@@ -17,18 +17,22 @@
#include "G4DecayTable.hh"
#include "G4PhaseSpaceDecayChannel.hh"
bool CustomParticleFactory::loaded = false;
std::set<G4ParticleDefinition *> CustomParticleFactory::m_particles;
bool CustomParticleFactory::isCustomParticle(G4ParticleDefinition *particle)
{
return (m_particles.find(particle)!=m_particles.end());
static const std::set<G4ParticleDefinition *> particles = load();
return (particle!=nullptr && particles.find(particle)!=particles.end());
}
void CustomParticleFactory::loadCustomParticles()
{
if(loaded) return;
loaded = true;
// tickle the loading of the particles if it wasn't done yet
isCustomParticle(nullptr);
}
std::set<G4ParticleDefinition *> CustomParticleFactory::load()
{
std::set<G4ParticleDefinition *> particles;
std::ifstream configFile("particles.txt");
G4String pType="custom";
G4String pSubType="";
......@@ -117,7 +121,7 @@ void CustomParticleFactory::loadCustomParticles()
<<G4endl;
}
m_particles.insert(particle);
particles.insert(particle);
}
configFile.close();
......@@ -132,7 +136,7 @@ void CustomParticleFactory::loadCustomParticles()
decayFile.close();
// Looping over custom particles to add decays
for (std::set<G4ParticleDefinition *>::iterator part=m_particles.begin();part!=m_particles.end();part++) {
for (std::set<G4ParticleDefinition *>::iterator part=particles.begin();part!=particles.end();part++) {
name=(*part)->GetParticleName();
std::vector<std::vector<std::string> > mydecays;
for (unsigned int i = 0; i!= decays.size(); i++){
......@@ -163,5 +167,5 @@ void CustomParticleFactory::loadCustomParticles()
(*part)->SetDecayTable(table);
}
}
return;
return particles;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CustomParticleFactory_h
......@@ -15,15 +15,13 @@
class CustomParticleFactory
{
private:
static bool loaded;
static std::set<G4ParticleDefinition *> m_particles;
public:
static void loadCustomParticles();
static bool isCustomParticle(G4ParticleDefinition *particle);
private:
static std::set<G4ParticleDefinition *> load();
};
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "FullModelHadronicProcess.hh"
......@@ -82,7 +82,7 @@ G4VParticleChange* FullModelHadronicProcess::PostStepDoIt(const G4Track& aTrack,
// A little setting up
aParticleChange.Initialize(aTrack);
// G4DynamicParticle* OrgPart = const_cast<G4DynamicParticle*>(aTrack.GetDynamicParticle());
G4DynamicParticle* IncidentRhadron = const_cast<G4DynamicParticle*>(aTrack.GetDynamicParticle());
const G4DynamicParticle* IncidentRhadron = aTrack.GetDynamicParticle();
CustomParticle* CustomIncident = static_cast<CustomParticle*>(IncidentRhadron->GetDefinition());
const G4ThreeVector& aPosition = aTrack.GetPosition();
const G4int theIncidentPDG = IncidentRhadron->GetDefinition()->GetPDGEncoding();
......
......@@ -1021,7 +1021,8 @@ G4bool FullModelReactionDynamics::GenerateXandPt(
G4cerr << "currentParticle side = " << currentParticle.GetSide() << G4endl;
for( i=0; i<vecLen; ++i )
G4cerr << "particle #" << i << " side = " << vec[i]->GetSide() << G4endl;
exit( EXIT_FAILURE );
throw std::runtime_error("FullModelReactionDynamics::GenerateXandPt: "
"tempLen is not the same as backwardNucleonCount");
}
constantCrossSection = true;
// DEBUGGING --> DumpFrames::DumpFrame(vec, vecLen);
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "G4ProcessHelper.hh"
......@@ -13,6 +13,8 @@
#include <fstream>
#include <stdexcept>
#include "CxxUtils/checker_macros.h"
G4ProcessHelper::G4ProcessHelper()
: theTarget(0)
, theRmesoncloud(0)
......@@ -160,25 +162,23 @@ G4ProcessHelper::G4ProcessHelper()
return;
}
G4ProcessHelper* G4ProcessHelper::pinstance = 0;
G4ProcessHelper* G4ProcessHelper::Instance()
{
if (pinstance == 0)
{
pinstance = new G4ProcessHelper();
}
return pinstance;
static G4ProcessHelper instance;
return &instance;
}
G4bool G4ProcessHelper::ApplicabilityTester(const G4ParticleDefinition& aPart){
const G4ParticleDefinition* aP = &aPart;
if (known_particles[aP]) return true;
return false;
G4bool G4ProcessHelper::ApplicabilityTester(const G4ParticleDefinition& aPart) const {
try {
return known_particles.at(&aPart);
}
catch (const std::out_of_range& e) {
return false;
}
}
G4double G4ProcessHelper::GetInclusiveCrossSection(const G4DynamicParticle *aParticle,
const G4Element *anElement){
const G4Element *anElement) const {
//We really do need a dedicated class to handle the cross sections. They might not always be constant
//Disassemble the PDG-code
......@@ -484,7 +484,8 @@ G4double G4ProcessHelper::ReactionProductMass(const ReactionProduct& aReaction,c
G4double M_after = 0;
for (ReactionProduct::const_iterator r_it = aReaction.begin(); r_it !=aReaction.end(); r_it++){
//G4cout<<"Mass contrib: "<<(particleTable->FindParticle(*r_it)->GetPDGMass())/CLHEP::MeV<<" MeV"<<G4endl;
M_after += particleTable->FindParticle(*r_it)->GetPDGMass();
auto table ATLAS_THREAD_SAFE = particleTable; // safe because table has been loaded by now
M_after += table->FindParticle(*r_it)->GetPDGMass();
}
//G4cout<<"Intending to return this ReactionProductMass: " << sqrts << " - " << M_after << " MeV"<<G4endl;
return sqrts - M_after;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#ifndef RHADRONS_G4PROCESSHELPER_HH
......@@ -25,10 +25,10 @@ class G4ProcessHelper {
public:
static G4ProcessHelper* Instance();
G4bool ApplicabilityTester(const G4ParticleDefinition& aPart);
G4bool ApplicabilityTester(const G4ParticleDefinition& aPart) const;
G4double GetInclusiveCrossSection(const G4DynamicParticle *aParticle,
const G4Element *anElement);
const G4Element *anElement) const;
//Make sure the element is known (for n/p-decision)
ReactionProduct GetFinalState(const G4Track& aTrack,G4ParticleDefinition*& aTarget);
......@@ -52,8 +52,6 @@ private:
ReactionMap* theReactionMap;
static G4ProcessHelper* pinstance;
// Version where we know if we baryonize already
ReactionProduct GetFinalStateInternal(const G4Track& aTrack,G4ParticleDefinition*& aTarget, const bool baryonize_failed);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment