00001
00002
00003 #include "BDSXSBias.hh"
00004 #include "BDSGlobalConstants.hh"
00005 #include "G4SteppingManager.hh"
00006
00007
00008 BDSXSBias::BDSXSBias(const G4String& aName,
00009 G4ProcessType aType)
00010 : G4WrapperProcess(aName, aType), eFactor(1.0)
00011 {
00012 }
00013
00014 BDSXSBias::BDSXSBias(const BDSXSBias& right)
00015 : G4WrapperProcess(right), eFactor(right.eFactor)
00016 {
00017 }
00018
00019 BDSXSBias::~BDSXSBias()
00020 {
00021 }
00022
00023
00024
00025 G4VParticleChange* BDSXSBias::PostStepDoIt(
00026 const G4Track& track,
00027 const G4Step& stepData
00028 )
00029 {
00030 #ifdef DEBUG
00031 G4cout <<" ###PostStepDoIt " << G4endl;
00032 G4cout << "BDSXSBias::PostStepDoit Getting pChange" << G4endl;
00033 #endif
00034 G4VParticleChange* pChange = pRegProcess->PostStepDoIt( track, stepData );
00035 pChange->SetVerboseLevel(0);
00036 #ifdef DEBUG
00037 G4cout << "BDSXSBias::PostStepDoit Choosing setsecondaryweightbyprocess" << G4endl;
00038 #endif
00039 pChange->SetSecondaryWeightByProcess(true);
00040 pChange->SetParentWeightByProcess(true);
00041 #ifdef DEBUG
00042 G4cout << "BDSXSBias::PostStepDoit Getting parent weight" << G4endl;
00043 #endif
00044 G4double w = pChange->GetParentWeight();
00045 G4double ws = w / eFactor;
00046 G4double survivalProb = w - ws;
00047
00048 #ifdef DEBUG
00049 G4cout << "BDSXSBias::PostStepDoit Getting number of secondaries" << G4endl;
00050 #endif
00051 G4int iNSec = pChange->GetNumberOfSecondaries();
00052
00053 #ifdef DEBUG
00054 G4cout << "BDSXSBias::PostStepDoit Setting secondary weights" << G4endl;
00055 #endif
00056
00057 G4bool pionEvent = false;
00058 G4bool gammaInPionEvent= false;
00059 for (G4int i = 0; i < iNSec; i++) {
00060 pChange->GetSecondary(i)->SetWeight(ws);
00061 if(std::abs(pChange->GetSecondary(i)->GetDefinition()->GetPDGEncoding())==211) {
00062 pionEvent=true;
00063 }
00064 if(std::abs(pChange->GetSecondary(i)->GetDefinition()->GetPDGEncoding())==22){
00065 if (pionEvent==true){
00066 gammaInPionEvent = true;
00067 }
00068 }
00069 }
00070
00071 if(pionEvent){
00072 G4cout << "Pion event" << G4endl;
00073 if(gammaInPionEvent){
00074 #ifdef DEBUG
00075 G4cout << "gammaInPionEvent" << G4endl;
00076 #endif
00077 }
00078 else {
00079 #ifdef DEBUG
00080 G4cout << "NO gammaInPionEvent" << G4endl;
00081 #endif
00082 }
00083 }
00084
00085 if (pionEvent){
00086 G4Track* secTrack[100];
00087 for (G4int i = 0; i < iNSec; i++) {
00088 #ifdef DEBUG
00089 G4cout << "BDSXSBias::PostStepDoIt Correcting kinetic energy of pion" << G4endl;
00090 #endif
00091 secTrack[i] = pChange->GetSecondary(i);
00092 G4double EkCorrected = secTrack[i]->GetDynamicParticle()->GetKineticEnergy()/1000;
00093 secTrack[i]->SetKineticEnergy(EkCorrected);
00094 secTrack[i]->SetWeight(ws);
00095
00096 }
00097 pChange->Clear();
00098 pChange->SetNumberOfSecondaries(iNSec);
00099 for(G4int i=0; i<iNSec; i++){
00100 pChange->AddSecondary(secTrack[i]);
00101 }
00102 }
00103
00104 #ifdef DEBUG
00105 G4cout << "BDSXSBias::PostStepDoit Testing for primary survival" << G4endl;
00106 #endif
00107 if(G4UniformRand()<survivalProb){
00108 pChange->ProposeParentWeight(survivalProb);
00109 pChange->ProposeTrackStatus(fAlive);
00110 }
00111
00112 #ifdef DEBUG
00113 G4cout << "BDSXSBias::PostStepDoIt number of secondaries: " << pChange->GetNumberOfSecondaries() << G4endl;
00114 #endif
00115 return pChange;
00116 }
00117