/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSXSBias.cc

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

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7