Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
civanch committed Jan 28, 2020
1 parent 99d5d53 commit de44446
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 49 deletions.
1 change: 0 additions & 1 deletion SimG4Core/CustomPhysics/interface/CMSQGSPSIMPBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class CMSQGSPSIMPBuilder {
void Build(CMSSIMPInelasticProcess* aP);

private:

G4QGSModel<G4QGSParticipants>* theStringModel;
G4ExcitedStringDecay* theStringDecay;
G4QGSMFragmentation* theQGSM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class CMSSIMPInelasticProcess : public G4HadronicProcess {
G4VParticleChange* PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) override;

private:

// hide assignment operator as private
CMSSIMPInelasticProcess& operator=(const CMSSIMPInelasticProcess& right);
CMSSIMPInelasticProcess(const CMSSIMPInelasticProcess&);
Expand Down
4 changes: 1 addition & 3 deletions SimG4Core/CustomPhysics/src/CMSQGSPSIMPBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ CMSQGSPSIMPBuilder::~CMSQGSPSIMPBuilder() {
}

void CMSQGSPSIMPBuilder::Build(CMSSIMPInelasticProcess* aP) {

G4GeneratorPrecompoundInterface* theCascade =
new G4GeneratorPrecompoundInterface;
G4GeneratorPrecompoundInterface* theCascade = new G4GeneratorPrecompoundInterface;
G4PreCompoundModel* thePreEquilib = new G4PreCompoundModel();
theCascade->SetDeExcitation(thePreEquilib);

Expand Down
51 changes: 22 additions & 29 deletions SimG4Core/CustomPhysics/src/CMSSIMPInelasticProcess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,20 @@
#include "G4HadronInelasticDataSet.hh"
#include "G4ParticleDefinition.hh"


//////////////////////////////////////////////////////////////////
CMSSIMPInelasticProcess::CMSSIMPInelasticProcess(const G4String& processName)
: G4HadronicProcess(processName, fHadronic) {

AddDataSet(new CMSSIMPInelasticXS());
theParticle = CMSSIMP::SIMP();
}

CMSSIMPInelasticProcess::~CMSSIMPInelasticProcess() {
}
CMSSIMPInelasticProcess::~CMSSIMPInelasticProcess() {}

G4bool CMSSIMPInelasticProcess::IsApplicable(const G4ParticleDefinition& aP) {
return theParticle->GetParticleType() == aP.GetParticleType();
}

G4VParticleChange*
CMSSIMPInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&) {
G4VParticleChange* CMSSIMPInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&) {
// if primary is not Alive then do nothing
theTotalResult->Clear();
theTotalResult->Initialize(aTrack);
Expand All @@ -49,17 +45,15 @@ CMSSIMPInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&) {

// Find cross section at end of step and check if <= 0
//
G4DynamicParticle* aParticle =
const_cast<G4DynamicParticle*>(aTrack.GetDynamicParticle());
G4DynamicParticle* aParticle = const_cast<G4DynamicParticle*>(aTrack.GetDynamicParticle());

// change this SIMP particle in a neutron
aParticle->SetPDGcode(2112);
aParticle->SetDefinition(G4Neutron::Neutron());

G4Nucleus* target = GetTargetNucleusPointer();
G4Material* aMaterial = aTrack.GetMaterial();
G4Element* anElement =
GetCrossSectionDataStore()->SampleZandA(aParticle,aMaterial,*target);
G4Element* anElement = GetCrossSectionDataStore()->SampleZandA(aParticle, aMaterial, *target);

// Next check for illegal track status
//
Expand All @@ -78,8 +72,7 @@ CMSSIMPInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&) {

// Initialize the hadronic projectile from the track
thePro.Initialise(aTrack);
G4HadronicInteraction* anInteraction =
ChooseHadronicInteraction(thePro, *target, aMaterial, anElement);
G4HadronicInteraction* anInteraction = ChooseHadronicInteraction(thePro, *target, aMaterial, anElement);

G4HadFinalState* result = nullptr;
G4int reentryCount = 0;
Expand All @@ -93,8 +86,8 @@ CMSSIMPInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&) {
G4ExceptionDescription ed;
aR.Report(ed);
ed << "Call for " << anInteraction->GetModelName() << G4endl;
ed << "Target element " << anElement->GetName() << " Z= "
<< target->GetZ_asInt() << " A= " << target->GetA_asInt() << G4endl;
ed << "Target element " << anElement->GetName() << " Z= " << target->GetZ_asInt()
<< " A= " << target->GetA_asInt() << G4endl;
DumpState(aTrack, "ApplyYourself", ed);
ed << " ApplyYourself failed" << G4endl;
G4Exception("CMSSIMPInelasticProcess::PostStepDoIt", "had006", FatalException, ed);
Expand All @@ -105,35 +98,36 @@ CMSSIMPInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&) {
if (reentryCount > 100) {
G4ExceptionDescription ed;
ed << "Call for " << anInteraction->GetModelName() << G4endl;
ed << "Target element " << anElement->GetName() << " Z= "
<< target->GetZ_asInt() << " A= " << target->GetA_asInt() << G4endl;
ed << "Target element " << anElement->GetName() << " Z= " << target->GetZ_asInt()
<< " A= " << target->GetA_asInt() << G4endl;
DumpState(aTrack, "ApplyYourself", ed);
ed << " ApplyYourself does not completed after 100 attempts" << G4endl;
G4Exception("CMSSIMPInelasticProcess::PostStepDoIt", "had006", FatalException, ed);
}
} while (!result);
// Check whether kaon0 or anti_kaon0 are present between the secondaries:
// Check whether kaon0 or anti_kaon0 are present between the secondaries:
// if this is the case, transform them into either kaon0S or kaon0L,
// with equal, 50% probability, keeping their dynamical masses (and
// the other kinematical properties).
// the other kinematical properties).
// When this happens - very rarely - a "JustWarning" exception is thrown.
G4int nSec = result->GetNumberOfSecondaries();
if ( nSec > 0 ) {
for ( G4int i = 0; i < nSec; ++i ) {
if (nSec > 0) {
for (G4int i = 0; i < nSec; ++i) {
G4DynamicParticle* dynamicParticle = result->GetSecondary(i)->GetParticle();
const G4ParticleDefinition* particleDefinition =
dynamicParticle->GetParticleDefinition();
if ( particleDefinition == G4KaonZero::Definition() ||
particleDefinition == G4AntiKaonZero::Definition() ) {
const G4ParticleDefinition* particleDefinition = dynamicParticle->GetParticleDefinition();
if (particleDefinition == G4KaonZero::Definition() || particleDefinition == G4AntiKaonZero::Definition()) {
G4ParticleDefinition* newPart;
if( G4UniformRand() > 0.5 ) { newPart = G4KaonZeroShort::Definition(); }
else { newPart = G4KaonZeroLong::Definition(); }
dynamicParticle->SetDefinition( newPart );
if (G4UniformRand() > 0.5) {
newPart = G4KaonZeroShort::Definition();
} else {
newPart = G4KaonZeroLong::Definition();
}
dynamicParticle->SetDefinition(newPart);
G4ExceptionDescription ed;
ed << " Hadronic model " << anInteraction->GetModelName() << G4endl;
ed << " created " << particleDefinition->GetParticleName() << G4endl;
ed << " -> forced to be " << newPart->GetParticleName() << G4endl;
G4Exception( "G4HadronicProcess::PostStepDoIt", "had007", JustWarning, ed );
G4Exception("G4HadronicProcess::PostStepDoIt", "had007", JustWarning, ed);
}
}
}
Expand All @@ -146,4 +140,3 @@ CMSSIMPInelasticProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&) {

return theTotalResult;
}

28 changes: 14 additions & 14 deletions SimG4Core/CustomPhysics/src/CMSSIMPInelasticXS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,33 @@
#include "G4Proton.hh"
#include "G4Neutron.hh"

CMSSIMPInelasticXS::CMSSIMPInelasticXS() :
G4VCrossSectionDataSet("CMSSIMPInelasticXS"), neutron(G4Neutron::Neutron()) {
CMSSIMPInelasticXS::CMSSIMPInelasticXS() : G4VCrossSectionDataSet("CMSSIMPInelasticXS"), neutron(G4Neutron::Neutron()) {
verboseLevel = 1;
nXsection = new G4NeutronInelasticXS();
isInitialized = false;
}

CMSSIMPInelasticXS::~CMSSIMPInelasticXS() {}

G4bool CMSSIMPInelasticXS::IsElementApplicable(const G4DynamicParticle*, G4int, const G4Material*) {
return true;
}
G4bool CMSSIMPInelasticXS::IsElementApplicable(const G4DynamicParticle*, G4int, const G4Material*) { return true; }

G4bool CMSSIMPInelasticXS::IsIsoApplicable(
const G4DynamicParticle*, G4int, G4int, const G4Element*, const G4Material*) {
G4bool CMSSIMPInelasticXS::IsIsoApplicable(const G4DynamicParticle*, G4int, G4int, const G4Element*, const G4Material*) {
return true;
}

G4double CMSSIMPInelasticXS::GetElementCrossSection(const G4DynamicParticle* aParticle, G4int Z, const G4Material* mat) {
return nXsection->GetElementCrossSection(aParticle, Z, mat);
G4double CMSSIMPInelasticXS::GetElementCrossSection(const G4DynamicParticle* aParticle,
G4int Z,
const G4Material* mat) {
return nXsection->GetElementCrossSection(aParticle, Z, mat);
}

G4double CMSSIMPInelasticXS::GetIsoCrossSection(
const G4DynamicParticle* aParticle, G4int Z, G4int A, const G4Isotope* iso,
const G4Element* elm, const G4Material* mat) {
return nXsection->GetIsoCrossSection(aParticle, Z, A, iso, elm, mat);
G4double CMSSIMPInelasticXS::GetIsoCrossSection(const G4DynamicParticle* aParticle,
G4int Z,
G4int A,
const G4Isotope* iso,
const G4Element* elm,
const G4Material* mat) {
return nXsection->GetIsoCrossSection(aParticle, Z, A, iso, elm, mat);
}

G4Isotope* CMSSIMPInelasticXS::SelectIsotope(const G4Element* anElement, G4double kinEnergy) {
Expand All @@ -59,4 +60,3 @@ void CMSSIMPInelasticXS::BuildPhysicsTable(const G4ParticleDefinition& p) {
}
isInitialized = true;
}

2 changes: 1 addition & 1 deletion SimG4Core/CustomPhysics/src/CustomPhysicsList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void CustomPhysicsList::ConstructProcess() {
G4ProcessManager* pmanager = particle->GetProcessManager();
if (pmanager) {
CMSSIMPInelasticProcess* simpInelPr = new CMSSIMPInelasticProcess();
CMSQGSPSIMPBuilder* theQGSPSIMPB = new CMSQGSPSIMPBuilder();
CMSQGSPSIMPBuilder* theQGSPSIMPB = new CMSQGSPSIMPBuilder();
theQGSPSIMPB->Build(simpInelPr);
pmanager->AddDiscreteProcess(simpInelPr);
} else
Expand Down

0 comments on commit de44446

Please sign in to comment.