Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 20110906 M. Kelsey -- Use reference to G4H << 27 << 28 #include "G4HadLeadBias.hh" 23 #include "G4HadLeadBias.hh" 29 #include "G4Gamma.hh" 24 #include "G4Gamma.hh" 30 #include "G4PionZero.hh" 25 #include "G4PionZero.hh" 31 #include "Randomize.hh" 26 #include "Randomize.hh" 32 #include "G4HadFinalState.hh" 27 #include "G4HadFinalState.hh" 33 28 34 G4HadFinalState * G4HadLeadBias::Bias(G4HadF 29 G4HadFinalState * G4HadLeadBias::Bias(G4HadFinalState * result) 35 { 30 { 36 // G4cerr << "bias enter"<<G4endl; 31 // G4cerr << "bias enter"<<G4endl; 37 G4int nMeson(0), nBaryon(0), npi0(0), ngam 32 G4int nMeson(0), nBaryon(0), npi0(0), ngamma(0), nLepton(0); 38 G4int i(0); 33 G4int i(0); 39 G4int maxE = -1; 34 G4int maxE = -1; 40 G4double emax = 0; 35 G4double emax = 0; 41 if(result->GetStatusChange()==isAlive) 36 if(result->GetStatusChange()==isAlive) 42 { 37 { 43 emax = result->GetEnergyChange(); 38 emax = result->GetEnergyChange(); 44 } 39 } 45 //G4cout << "max energy "<<G4endl; 40 //G4cout << "max energy "<<G4endl; 46 for(i=0;i<static_cast<G4int>(result->GetNu << 41 for(i=0;i<result->GetNumberOfSecondaries();i++) 47 { 42 { 48 if(result->GetSecondary(i)->GetParticle( 43 if(result->GetSecondary(i)->GetParticle()->GetKineticEnergy()>emax) 49 { 44 { 50 maxE = i; 45 maxE = i; 51 emax = result->GetSecondary(i)->GetParticle( 46 emax = result->GetSecondary(i)->GetParticle()->GetKineticEnergy(); 52 } 47 } 53 } 48 } 54 //G4cout <<"loop1"<<G4endl; 49 //G4cout <<"loop1"<<G4endl; 55 for(i=0; i<static_cast<G4int>(result->GetN << 50 for(i=0; i<result->GetNumberOfSecondaries(); i++) 56 { 51 { 57 const G4DynamicParticle* aSecTrack = res 52 const G4DynamicParticle* aSecTrack = result->GetSecondary(i)->GetParticle(); 58 if(i==maxE) 53 if(i==maxE) 59 { 54 { 60 } 55 } 61 else if(aSecTrack->GetDefinition()->GetB 56 else if(aSecTrack->GetDefinition()->GetBaryonNumber()!=0) 62 { 57 { 63 nBaryon++; 58 nBaryon++; 64 } 59 } 65 else if(aSecTrack->GetDefinition()->GetL 60 else if(aSecTrack->GetDefinition()->GetLeptonNumber()!=0) 66 { 61 { 67 nLepton++; 62 nLepton++; 68 } 63 } 69 else if(aSecTrack->GetDefinition()==G4Ga 64 else if(aSecTrack->GetDefinition()==G4Gamma::Gamma()) 70 { 65 { 71 ngamma++; 66 ngamma++; 72 } 67 } 73 else if(aSecTrack->GetDefinition()==G4Pi 68 else if(aSecTrack->GetDefinition()==G4PionZero::PionZero()) 74 { 69 { 75 npi0++; 70 npi0++; 76 } 71 } 77 else 72 else 78 { 73 { 79 nMeson++; 74 nMeson++; 80 } 75 } 81 } 76 } 82 //G4cout << "BiasDebug 1 = "<<result->Get 77 //G4cout << "BiasDebug 1 = "<<result->GetNumberOfSecondaries()<<" " 83 // <<nMeson<<" "<< nBaryon<<" "<< n 78 // <<nMeson<<" "<< nBaryon<<" "<< npi0<<" "<< ngamma<<" "<< nLepton<<G4endl; 84 G4double mesonWeight = nMeson; 79 G4double mesonWeight = nMeson; 85 G4double baryonWeight = nBaryon; 80 G4double baryonWeight = nBaryon; 86 G4double gammaWeight = ngamma; 81 G4double gammaWeight = ngamma; 87 G4double npi0Weight = npi0; 82 G4double npi0Weight = npi0; 88 G4double leptonWeight = nLepton; 83 G4double leptonWeight = nLepton; 89 G4int randomMeson = static_cast<G4int>((nM 84 G4int randomMeson = static_cast<G4int>((nMeson+1)*G4UniformRand()); 90 G4int randomBaryon = static_cast<G4int>((n 85 G4int randomBaryon = static_cast<G4int>((nBaryon+1)*G4UniformRand()); 91 G4int randomGamma = static_cast<G4int>((ng 86 G4int randomGamma = static_cast<G4int>((ngamma+1)*G4UniformRand()); 92 G4int randomPi0 = static_cast<G4int>((npi0 87 G4int randomPi0 = static_cast<G4int>((npi0+1)*G4UniformRand()); 93 G4int randomLepton = static_cast<G4int>((n 88 G4int randomLepton = static_cast<G4int>((nLepton+1)*G4UniformRand()); 94 89 95 std::vector<G4HadSecondary> buffer; << 90 std::vector<G4HadSecondary *> buffer; 96 G4int cMeson(0), cBaryon(0), cpi0(0), cgam 91 G4int cMeson(0), cBaryon(0), cpi0(0), cgamma(0), cLepton(0); 97 for(i=0; i<static_cast<G4int>(result->GetN << 92 for(i=0; i<result->GetNumberOfSecondaries(); i++) 98 { 93 { 99 G4bool aCatch = false; 94 G4bool aCatch = false; 100 G4double weight = 1; 95 G4double weight = 1; 101 const G4HadSecondary* aSecTrack = result << 96 G4HadSecondary * aSecTrack = result->GetSecondary(i); 102 G4ParticleDefinition* aSecDef = aSecTrac << 103 if(i==maxE) 97 if(i==maxE) 104 { 98 { 105 aCatch = true; 99 aCatch = true; 106 weight = 1; 100 weight = 1; 107 } 101 } 108 else if(aSecDef->GetBaryonNumber()!=0) << 102 else if(aSecTrack->GetParticle()->GetDefinition()->GetBaryonNumber()!=0) 109 { 103 { 110 if(++cBaryon==randomBaryon) 104 if(++cBaryon==randomBaryon) 111 { 105 { 112 aCatch = true; 106 aCatch = true; 113 weight = baryonWeight; 107 weight = baryonWeight; 114 } 108 } 115 } 109 } 116 else if(aSecDef->GetLeptonNumber()!=0) << 110 else if(aSecTrack->GetParticle()->GetDefinition()->GetLeptonNumber()!=0) 117 { 111 { 118 if(++cLepton==randomLepton) 112 if(++cLepton==randomLepton) 119 { 113 { 120 aCatch = true; 114 aCatch = true; 121 weight = leptonWeight; 115 weight = leptonWeight; 122 } 116 } 123 } 117 } 124 else if(aSecDef==G4Gamma::Gamma()) << 118 else if(aSecTrack->GetParticle()->GetDefinition()==G4Gamma::Gamma()) 125 { 119 { 126 if(++cgamma==randomGamma) 120 if(++cgamma==randomGamma) 127 { 121 { 128 aCatch = true; 122 aCatch = true; 129 weight = gammaWeight; 123 weight = gammaWeight; 130 } 124 } 131 } 125 } 132 else if(aSecDef==G4PionZero::PionZero()) << 126 else if(aSecTrack->GetParticle()->GetDefinition()==G4PionZero::PionZero()) 133 { 127 { 134 if(++cpi0==randomPi0) 128 if(++cpi0==randomPi0) 135 { 129 { 136 aCatch = true; 130 aCatch = true; 137 weight = npi0Weight; 131 weight = npi0Weight; 138 } 132 } 139 } 133 } 140 else 134 else 141 { 135 { 142 if(++cMeson==randomMeson) 136 if(++cMeson==randomMeson) 143 { 137 { 144 aCatch = true; 138 aCatch = true; 145 weight = mesonWeight; 139 weight = mesonWeight; 146 } 140 } 147 } 141 } 148 if(aCatch) 142 if(aCatch) 149 { 143 { 150 buffer.push_back(*aSecTrack); << 144 buffer.push_back(aSecTrack); 151 buffer.back().SetWeight(aSecTrack->GetWeight << 145 aSecTrack->SetWeight(aSecTrack->GetWeight()*weight); 152 } 146 } 153 else 147 else 154 { 148 { 155 delete aSecTrack; 149 delete aSecTrack; 156 } 150 } 157 } 151 } 158 result->ClearSecondaries(); 152 result->ClearSecondaries(); 159 // G4cerr << "pre"<<G4endl; 153 // G4cerr << "pre"<<G4endl; 160 result->AddSecondaries(buffer); << 154 for(i=0;i<static_cast<G4int>(buffer.size());i++) >> 155 { >> 156 result->AddSecondary(buffer[i]); >> 157 } 161 // G4cerr << "bias exit"<<G4endl; 158 // G4cerr << "bias exit"<<G4endl; 162 159 163 return result; 160 return result; 164 } 161 } 165 162