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" 49 G4VParticleChange* pChange = pRegProcess->PostStepDoIt( track, step );
50 pChange->SetVerboseLevel(0);
51 pChange->SetSecondaryWeightByProcess(
true);
53 G4double secWeight = 1.0;
55 std::vector<G4Track*> secondaries;
61 G4double
s = step.GetStepLength();
62 G4double
x = pRegProcess->GetCurrentInteractionLength();
63 nw = pChange->GetParentWeight();
68 if (
wc < 1.0
e-10)
wc = 1.0;
69 nw *= 1/
wc * (1. - exp(-s/x))/(1 - exp(-
eFactor*s/x)) ;
70 G4cout <<
" MNSPXSB.PostStepDoit(): original wt = " << pChange->GetParentWeight() <<
" eF = " <<
eFactor << G4endl;
71 G4cout <<
" MNSPXSB.PostStepDoit(): New weight = " << nw <<
" wc = " <<
wc <<
" s= " << s <<
" x = " << x << G4endl;
72 ((G4ParticleChange*)pChange)->ProposeParentWeight(nw) ;
77 ((G4ParticleChange*)pChange)->ProposeParentWeight(nw) ;
84 pChange->SetNumberOfSecondaries(pChange->GetNumberOfSecondaries()+1);
85 G4ThreeVector mDirection = track.GetDynamicParticle()->GetMomentumDirection();
86 G4DynamicParticle* aD =
new G4DynamicParticle((track.GetDynamicParticle())->GetDefinition(),
87 G4LorentzVector(mDirection,
88 (track.GetDynamicParticle())->GetKineticEnergy()+step.GetTotalEnergyDeposit()));
89 G4Track* secTrk =
new G4Track(aD,step.GetDeltaTime(),step.GetDeltaPosition());
90 pChange->AddSecondary(secTrk);
91 pChange->GetSecondary(pChange->GetNumberOfSecondaries()-1)->
96 nw = track.GetWeight();
97 pChange->ProposeParentWeight(nw);
101 secWeight = secWeight*nw;
107 G4VParticleChange* particleChange =
new G4VParticleChange();
109 for (
unsigned int ii=0; ii<(
unsigned int)
fNSplit; ii++) {
110 particleChange = pRegProcess->PostStepDoIt(track, step);
112 throw std::runtime_error(
"MuNuclearSplittingProcessXSecBias::PostStepDoIt(): no particle change");
114 G4int numSec(particleChange->GetNumberOfSecondaries());
116 for (j=0; j<numSec; j++)
118 G4Track* newSec =
new G4Track(*(particleChange->GetSecondary(j)));
119 G4String pdgstr = newSec->GetParticleDefinition()->GetParticleName();
121 G4int pdg = newSec->GetParticleDefinition()->GetPDGEncoding();
122 if (abs(pdg)==310 ||abs(pdg)==311 || abs(pdg)==3122 || abs(pdg)==2112)
126 if (pdg==G4KaonZeroShort::KaonZeroShort()->GetPDGEncoding()&&G4UniformRand()<0.50)
128 pdg = G4KaonZeroLong::KaonZeroLong()->GetPDGEncoding();
129 pdgstr = G4KaonZeroLong::KaonZeroLong()->GetParticleName();
130 G4LorentzVector pK0L(newSec->GetMomentum(),TMath::Sqrt(TMath::Power(G4KaonZeroLong::KaonZeroLong()->GetPDGMass(),2)+TMath::Power(newSec->GetMomentum().mag(),2)));
131 G4DynamicParticle *newK0L =
new G4DynamicParticle(G4KaonZeroLong::KaonZeroLong(),pK0L);
133 G4Track* newSecK0L =
new G4Track(newK0L,track.GetGlobalTime(),track.GetPosition());
134 secondaries.push_back(newSecK0L);
138 secondaries.push_back(newSec);
144 pChange->SetNumberOfSecondaries(secondaries.size());
145 pChange->SetSecondaryWeightByProcess(
true);
150 while (iter != secondaries.end()) {
151 G4Track* myTrack = *iter;
152 G4String pdgstr = myTrack->GetParticleDefinition()->GetParticleName();
153 G4double ke = myTrack->GetKineticEnergy()/CLHEP::GeV;
154 G4int pdg = myTrack->GetParticleDefinition()->GetPDGEncoding();
155 if (abs(pdg)==130 ||abs(pdg)==310 ||abs(pdg)==311 || abs(pdg)==3122 || abs(pdg)==2112)
158 std::cout <<
"MuNuclSplXSB(): Adding " << pdgstr <<
" of Kinetic Energy and weight " << ke <<
" GeV and " << secWeight <<
"." << std::endl;
160 myTrack->SetWeight(secWeight);
161 pChange->AddSecondary(myTrack);
170 const G4Track&
track,
184 G4VParticleChange* pC =
new G4VParticleChange();
185 pC->Initialize(track);
189 pC->ProposeParentWeight(nw) ;
190 for (G4int i = 0; i < pC->GetNumberOfSecondaries(); i++)
191 pC->GetSecondary(i)->SetWeight(nw);
195 pC->SetNumberOfSecondaries(pC->GetNumberOfSecondaries()+1);
196 G4ThreeVector mDirection = track.GetDynamicParticle()->GetMomentumDirection();
197 G4DynamicParticle* aD =
new G4DynamicParticle((track.GetDynamicParticle())->GetDefinition(),
198 G4LorentzVector(mDirection,
199 (track.GetDynamicParticle())->GetKineticEnergy()+step.GetTotalEnergyDeposit()));
200 G4Track* secTrk =
new G4Track(aD,track.GetGlobalTime(),track.GetPosition());
201 secTrk->SetGoodForTrackingFlag(
true);
202 pC->AddSecondary(secTrk);
212 G4double
s = step.GetStepLength();
213 G4double
x = pRegProcess->GetCurrentInteractionLength();
230 <<
"Set XBiasMode to 0 or 1. " <<
xBiasMode <<
" not allowed!\n";
241 G4double biasedProbability = 1.-std::exp(-nLTraversed);
242 G4double realProbability = 1-std::exp(-nLTraversed/
eFactor);
243 result = (biasedProbability-realProbability)/biasedProbability;
259 -G4VProcess::theNumberOfInteractionLengthLeft;
264 G4double previousStepSize,
265 G4ForceCondition* condition )
272 G4double psgPIL = (1./
eFactor) * pRegProcess->PostStepGetPhysicalInteractionLength(
279 return pRegProcess->PostStepGetPhysicalInteractionLength(
288 G4double previousStepSize,
289 G4double currentMinimumStep,
290 G4double& proposedSafety,
291 G4GPILSelection* selection )
300 pRegProcess->AlongStepGetPhysicalInteractionLength( track,previousStepSize,
301 currentMinimumStep,proposedSafety,selection);
302 if (intLen<0)
return currentMinimumStep;
G4VParticleChange fParticleChange
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
Check of Geant4 to run the LArSoft detector simulation.
G4double GetTotalNumberOfInteractionLengthTraversed()
G4double XBiasSurvivalProbability()
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
G4double XBiasSecondaryWeight()
G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &step)
G4double theInitialNumberOfInteractionLength
G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &step)
cet::coded_exception< error, detail::translate > exception