23 #include "Geant4/G4WrapperProcess.hh" 24 #include "Geant4/G4VParticleChange.hh" 25 #include "Geant4/G4SDManager.hh" 26 #include "Geant4/G4RunManager.hh" 27 #include "Geant4/G4Event.hh" 28 #include "Geant4/G4HCofThisEvent.hh" 29 #include "Geant4/G4Track.hh" 30 #include "Geant4/G4Step.hh" 31 #include "Geant4/G4TrackStatus.hh" 32 #include "Geant4/G4ParticleDefinition.hh" 33 #include "Geant4/G4ParticleTypes.hh" 34 #include "Geant4/Randomize.hh" 35 #include "Geant4/G4KaonZeroLong.hh" 36 #include "Geant4/G4ios.hh" 38 #include "cetlib_except/exception.h" 50 G4VParticleChange* pChange = pRegProcess->PostStepDoIt( track, step );
51 pChange->SetVerboseLevel(0);
52 pChange->SetSecondaryWeightByProcess(
true);
54 G4double secWeight = 1.0;
56 std::vector<G4Track*> secondaries;
62 G4double
s = step.GetStepLength();
63 G4double
x = pRegProcess->GetCurrentInteractionLength();
64 nw = pChange->GetParentWeight();
69 if (
wc < 1.0
e-10)
wc = 1.0;
70 nw *= 1/
wc * (1. - exp(-s/x))/(1 - exp(-
eFactor*s/x)) ;
71 G4cout <<
" MNSPXSB.PostStepDoit(): original wt = " << pChange->GetParentWeight() <<
" eF = " <<
eFactor << G4endl;
72 G4cout <<
" MNSPXSB.PostStepDoit(): New weight = " << nw <<
" wc = " <<
wc <<
" s= " << s <<
" x = " << x << G4endl;
73 ((G4ParticleChange*)pChange)->ProposeParentWeight(nw) ;
78 ((G4ParticleChange*)pChange)->ProposeParentWeight(nw) ;
85 pChange->SetNumberOfSecondaries(pChange->GetNumberOfSecondaries()+1);
86 G4ThreeVector mDirection = track.GetDynamicParticle()->GetMomentumDirection();
87 G4DynamicParticle* aD =
new G4DynamicParticle((track.GetDynamicParticle())->GetDefinition(),
88 G4LorentzVector(mDirection,
89 (track.GetDynamicParticle())->GetKineticEnergy()+step.GetTotalEnergyDeposit()));
90 G4Track* secTrk =
new G4Track(aD,step.GetDeltaTime(),step.GetDeltaPosition());
91 pChange->AddSecondary(secTrk);
92 pChange->GetSecondary(pChange->GetNumberOfSecondaries()-1)->
97 nw = track.GetWeight();
98 pChange->ProposeParentWeight(nw);
102 secWeight = secWeight*nw;
108 G4VParticleChange* particleChange =
new G4VParticleChange();
110 for (
unsigned int ii=0; ii<(
unsigned int)
fNSplit; ii++) {
111 particleChange = pRegProcess->PostStepDoIt(track, step);
113 throw std::runtime_error(
"MuNuclearSplittingProcessXSecBias::PostStepDoIt(): no particle change");
115 G4int numSec(particleChange->GetNumberOfSecondaries());
117 for (j=0; j<numSec; j++)
119 G4Track* newSec =
new G4Track(*(particleChange->GetSecondary(j)));
120 G4String pdgstr = newSec->GetParticleDefinition()->GetParticleName();
122 G4int
pdg = newSec->GetParticleDefinition()->GetPDGEncoding();
123 if (
abs(pdg)==310 ||
abs(pdg)==311 ||
abs(pdg)==3122 ||
abs(pdg)==2112)
127 if (pdg==G4KaonZeroShort::KaonZeroShort()->GetPDGEncoding()&&G4UniformRand()<0.50)
129 pdg = G4KaonZeroLong::KaonZeroLong()->GetPDGEncoding();
130 pdgstr = G4KaonZeroLong::KaonZeroLong()->GetParticleName();
131 G4LorentzVector pK0L(newSec->GetMomentum(),TMath::Sqrt(TMath::Power(G4KaonZeroLong::KaonZeroLong()->GetPDGMass(),2)+TMath::Power(newSec->GetMomentum().mag(),2)));
132 G4DynamicParticle *newK0L =
new G4DynamicParticle(G4KaonZeroLong::KaonZeroLong(),pK0L);
134 G4Track* newSecK0L =
new G4Track(newK0L,track.GetGlobalTime(),track.GetPosition());
135 secondaries.push_back(newSecK0L);
139 secondaries.push_back(newSec);
145 pChange->SetNumberOfSecondaries(secondaries.size());
146 pChange->SetSecondaryWeightByProcess(
true);
151 while (iter != secondaries.end()) {
152 G4Track* myTrack = *iter;
153 G4String pdgstr = myTrack->GetParticleDefinition()->GetParticleName();
154 G4double ke = myTrack->GetKineticEnergy()/
CLHEP::GeV;
155 G4int
pdg = myTrack->GetParticleDefinition()->GetPDGEncoding();
156 if (
abs(pdg)==130 ||
abs(pdg)==310 ||
abs(pdg)==311 ||
abs(pdg)==3122 ||
abs(pdg)==2112)
159 std::cout <<
"MuNuclSplXSB(): Adding " << pdgstr <<
" of Kinetic Energy and weight " << ke <<
" GeV and " << secWeight <<
"." <<
std::endl;
161 myTrack->SetWeight(secWeight);
162 pChange->AddSecondary(myTrack);
171 const G4Track& track,
185 G4VParticleChange* pC =
new G4VParticleChange();
186 pC->Initialize(track);
190 pC->ProposeParentWeight(nw) ;
191 for (G4int i = 0; i < pC->GetNumberOfSecondaries(); i++)
192 pC->GetSecondary(i)->SetWeight(nw);
196 pC->SetNumberOfSecondaries(pC->GetNumberOfSecondaries()+1);
197 G4ThreeVector mDirection = track.GetDynamicParticle()->GetMomentumDirection();
198 G4DynamicParticle* aD =
new G4DynamicParticle((track.GetDynamicParticle())->GetDefinition(),
199 G4LorentzVector(mDirection,
200 (track.GetDynamicParticle())->GetKineticEnergy()+step.GetTotalEnergyDeposit()));
201 G4Track* secTrk =
new G4Track(aD,track.GetGlobalTime(),track.GetPosition());
202 secTrk->SetGoodForTrackingFlag(
true);
203 pC->AddSecondary(secTrk);
213 G4double
s = step.GetStepLength();
214 G4double
x = pRegProcess->GetCurrentInteractionLength();
231 <<
"Set XBiasMode to 0 or 1. " <<
xBiasMode <<
" not allowed!\n";
242 G4double biasedProbability = 1.-std::exp(-nLTraversed);
243 G4double realProbability = 1-std::exp(-nLTraversed/
eFactor);
244 result = (biasedProbability-realProbability)/biasedProbability;
260 -G4VProcess::theNumberOfInteractionLengthLeft;
265 G4double previousStepSize,
266 G4ForceCondition* condition )
273 G4double psgPIL = (1./
eFactor) * pRegProcess->PostStepGetPhysicalInteractionLength(
280 return pRegProcess->PostStepGetPhysicalInteractionLength(
289 G4double previousStepSize,
290 G4double currentMinimumStep,
291 G4double& proposedSafety,
292 G4GPILSelection* selection )
301 pRegProcess->AlongStepGetPhysicalInteractionLength( track,previousStepSize,
302 currentMinimumStep,proposedSafety,selection);
303 if (intLen<0)
return currentMinimumStep;
G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &step)
G4double GetTotalNumberOfInteractionLengthTraversed()
G4VParticleChange fParticleChange
G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &step)
static constexpr double GeV
G4double XBiasSurvivalProbability()
G4double theInitialNumberOfInteractionLength
General GArSoft Utilities.
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
G4double XBiasSecondaryWeight()
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)