Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 #include <algorithm> << 27 #include <vector> << 28 #include <cmath> << 29 #include <numeric> << 30 << 31 #include "G4BinaryLightIonReaction.hh" 26 #include "G4BinaryLightIonReaction.hh" 32 #include "G4PhysicalConstants.hh" << 33 #include "G4SystemOfUnits.hh" << 34 #include "G4LorentzVector.hh" 27 #include "G4LorentzVector.hh" 35 #include "G4LorentzRotation.hh" 28 #include "G4LorentzRotation.hh" >> 29 #include <algorithm> 36 #include "G4ReactionProductVector.hh" 30 #include "G4ReactionProductVector.hh" >> 31 #include <vector> 37 #include "G4ping.hh" 32 #include "G4ping.hh" 38 #include "G4Delete.hh" 33 #include "G4Delete.hh" 39 #include "G4Neutron.hh" 34 #include "G4Neutron.hh" 40 #include "G4VNuclearDensity.hh" 35 #include "G4VNuclearDensity.hh" 41 #include "G4FermiMomentum.hh" 36 #include "G4FermiMomentum.hh" 42 #include "G4HadTmpUtil.hh" 37 #include "G4HadTmpUtil.hh" 43 #include "G4PreCompoundModel.hh" << 38 #include <cmath> 44 #include "G4HadronicInteractionRegistry.hh" << 39 45 #include "G4Log.hh" << 40 G4BinaryLightIonReaction::G4BinaryLightIonReaction() 46 #include "G4PhysicsModelCatalog.hh" << 41 : theModel(), theHandler(), theProjectileFragmentation(&theHandler) {} 47 #include "G4HadronicParameters.hh" << 42 48 << 43 G4HadFinalState *G4BinaryLightIonReaction:: 49 G4int G4BinaryLightIonReaction::theBLIR_ID = - << 44 ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus & targetNucleus ) 50 << 45 { 51 //#define debug_G4BinaryLightIonReaction << 46 static G4int eventcounter=0; 52 //#define debug_BLIR_finalstate << 47 eventcounter++; 53 //#define debug_BLIR_result << 48 if(getenv("BLICDEBUG") ) G4cerr << " ######### Binary Light Ion Reaction number starts ######### "<<eventcounter<<G4endl; 54 << 49 G4ping debug("debug_G4BinaryLightIonReaction"); 55 G4BinaryLightIonReaction::G4BinaryLightIonReac << 50 G4double a1=aTrack.GetDefinition()->GetBaryonNumber(); 56 : G4HadronicInteraction("Binary Light Ion Casc << 51 G4double z1=aTrack.GetDefinition()->GetPDGCharge(); 57 theProjectileFragmentation(ptr), << 52 G4double a2=targetNucleus.GetN(); 58 pA(0),pZ(0), tA(0),tZ(0),spectatorA(0),spect << 53 G4double z2=targetNucleus.GetZ(); 59 projectile3dNucleus(0),target3dNucleus(0) << 54 debug.push_back(a1); 60 { << 55 debug.push_back(z1); 61 if(!ptr) { << 56 debug.push_back(a2); 62 G4HadronicInteraction* p = << 57 debug.push_back(z2); 63 G4HadronicInteractionRegistry::Instance( << 58 // debug.push_back(m2); 64 G4VPreCompoundModel* pre = static_cast<G4V << 59 G4LorentzVector mom(aTrack.Get4Momentum()); 65 if(!pre) { pre = new G4PreCompoundModel(); << 60 debug.push_back(mom); 66 theProjectileFragmentation = pre; << 61 debug.dump(); 67 } << 62 G4LorentzRotation toBreit(mom.boostVector()); 68 theModel = new G4BinaryCascade(theProjectile << 63 69 theHandler = theProjectileFragmentation->Get << 64 G4bool swapped = false; 70 theBLIR_ID = G4PhysicsModelCatalog::GetM << 65 if(a2<a1) 71 debug_G4BinaryLightIonReactionResults = G4Ha << 66 { 72 } << 67 debug.push_back("swapping...."); 73 << 68 swapped = true; 74 G4BinaryLightIonReaction::~G4BinaryLightIonRea << 69 G4double tmp(0); 75 {} << 70 tmp = a2; a2=a1; a1=tmp; 76 << 71 tmp = z2; z2=z1; z1=tmp; 77 void G4BinaryLightIonReaction::ModelDescriptio << 72 G4double m1=G4ParticleTable::GetParticleTable()->GetIonTable()->GetIonMass(G4lrint(z1),G4lrint(a1)); 78 { << 73 G4LorentzVector it(m1, G4ThreeVector(0,0,0)); 79 outFile << "G4Binary Light Ion Cascade is an << 74 mom = toBreit*it; 80 << "using G4BinaryCasacde to model the i << 75 } 81 << "nucleus with a nucleus.\n" << 76 debug.push_back("After swap"); 82 << "The lighter of the two nuclei is tre << 77 debug.push_back(a1); 83 << "which are transported simultaneously << 78 debug.push_back(z1); 84 } << 79 debug.push_back(a2); 85 << 80 debug.push_back(z2); 86 //-------------------------------------------- << 81 debug.push_back(mom); 87 struct ReactionProduct4Mom << 82 debug.dump(); 88 { << 83 89 G4LorentzVector operator()(G4LorentzVector << 84 G4ReactionProductVector * result = NULL; 90 }; << 85 G4ReactionProductVector * cascaders= new G4ReactionProductVector; 91 << 86 G4double m_nucl(0); // to check energy balance 92 G4HadFinalState *G4BinaryLightIonReaction:: << 87 93 ApplyYourself(const G4HadProjectile &aTrack, G << 88 94 { << 89 // G4double m1=G4ParticleTable::GetParticleTable()->GetIonTable()->GetIonMass(G4lrint(z1),G4lrint(a1)); 95 if(debug_G4BinaryLightIonReactionResults) G4 << 90 // G4cout << "Entering the decision point " 96 G4ping debug("debug_G4BinaryLightIonReaction << 91 // << (mom.t()-mom.mag())/a1 << " " 97 pA=aTrack.GetDefinition()->GetBaryonNumber() << 92 // << a1<<" "<< z1<<" " 98 pZ=G4lrint(aTrack.GetDefinition()->GetPDGCha << 93 // << a2<<" "<< z2<<G4endl 99 tA=targetNucleus.GetA_asInt(); << 94 // << " "<<mom.t()-mom.mag()<<" " 100 tZ=targetNucleus.GetZ_asInt(); << 95 // << mom.t()- m1<<G4endl; 101 G4double timePrimary = aTrack.GetGlobalTime( << 96 if( (mom.t()-mom.mag())/a1 < 50*MeV ) 102 G4LorentzVector mom(aTrack.Get4Momentum()); << 97 { 103 //G4cout << "proj mom : " << mom << G4endl; << 98 // G4cout << "Using pre-compound only, E= "<<mom.t()-mom.mag()<<G4endl; 104 G4LorentzRotation toBreit(mom.boostVector()) << 99 // m_nucl = mom.mag(); 105 << 100 delete cascaders; 106 G4bool swapped=SetLighterAsProjectile(mom, t << 101 G4Fragment aPreFrag; 107 //G4cout << "after swap, swapped? / mom " < << 102 aPreFrag.SetA(a1+a2); 108 G4ReactionProductVector * result = 0; << 103 aPreFrag.SetZ(z1+z2); 109 G4ReactionProductVector * cascaders=0; //new << 104 aPreFrag.SetNumberOfParticles(G4lrint(a1)); 110 // G4double m_nucl(0); // to check energ << 105 aPreFrag.SetNumberOfCharged(G4lrint(z1)); 111 << 106 aPreFrag.SetNumberOfHoles(0); 112 << 107 G4ThreeVector plop(0.,0., mom.vect().mag()); 113 // G4double m1=G4ParticleTable::GetPartic << 108 G4double m2=G4ParticleTable::GetParticleTable()->GetIonTable()->GetIonMass(G4lrint(z2),G4lrint(a2)); 114 // G4cout << "Entering the decision point << 109 m_nucl=m2; 115 // << (mom.t()-mom.mag())/pA << " << 110 G4LorentzVector aL(mom.t()+m2, plop); 116 // << pA<<" "<< pZ<<" " << 111 aPreFrag.SetMomentum(aL); 117 // << tA<<" "<< tZ<<G4endl << 112 G4ParticleDefinition * preFragDef; 118 // << " "<<mom.t()-mom.mag()<<" " << 113 preFragDef = G4ParticleTable::GetParticleTable() 119 // << mom.t()- m1<<G4endl; << 114 ->FindIon(G4lrint(z1+z2),G4lrint(a1+a2),0,G4lrint(z1+z2)); 120 if( (mom.t()-mom.mag())/pA < 50*MeV ) << 115 aPreFrag.SetParticleDefinition(preFragDef); 121 { << 116 122 // G4cout << "Using pre-compound only << 117 // G4cout << "Fragment INFO "<< a1+a2 <<" "<<z1+z2<<" " 123 // m_nucl = mom.mag(); << 118 // << aL <<" "<<preFragDef->GetParticleName()<<G4endl; 124 cascaders=FuseNucleiAndPrompound(mom); << 119 cascaders = theProjectileFragmentation.DeExcite(aPreFrag); 125 if( !cascaders ) << 120 G4double tSum = 0; 126 { << 121 for(size_t count = 0; count<cascaders->size(); count++) 127 << 122 { 128 // abort!! happens for too low e << 123 cascaders->operator[](count)->SetNewlyAdded(true); >> 124 tSum += cascaders->operator[](count)->GetKineticEnergy(); >> 125 } >> 126 // G4cout << "Exiting pre-compound only, E= "<<tSum<<G4endl; >> 127 } >> 128 else >> 129 { >> 130 >> 131 >> 132 G4V3DNucleus * fancyNucleus = NULL; >> 133 G4Fancy3DNucleus * projectile = NULL; >> 134 G4double m1(0) ,m2(0); >> 135 G4LorentzVector it; 129 136 130 theResult.Clear(); << 137 G4FermiMomentum theFermi; 131 theResult.SetStatusChange(isAliv << 138 G4int tryCount(0); 132 theResult.SetEnergyChange(aTrack << 139 while(!result) 133 theResult.SetMomentumChange(aTra << 140 { 134 return &theResult; << 141 projectile = new G4Fancy3DNucleus; 135 } << 142 projectile->Init(a1, z1); 136 } << 143 projectile->CenterNucleons(); 137 else << 144 m1=G4ParticleTable::GetParticleTable()->GetIonTable()->GetIonMass( >> 145 projectile->GetCharge(),projectile->GetMassNumber()); >> 146 it=toBreit * G4LorentzVector(m1,G4ThreeVector(0,0,0)); >> 147 fancyNucleus = new G4Fancy3DNucleus; >> 148 fancyNucleus->Init(a2, z2); >> 149 m2=G4ParticleTable::GetParticleTable()->GetIonTable()->GetIonMass( >> 150 fancyNucleus->GetCharge(),fancyNucleus->GetMassNumber()); >> 151 m_nucl = ( swapped ) ? m1 : m2; >> 152 // G4cout << " mass table, nucleus, delta : " << m2 <<" "<< fancyNucleus->GetMass() >> 153 // <<" "<<m2-fancyNucleus->GetMass() << G4endl; >> 154 G4double impactMax = fancyNucleus->GetOuterRadius()+projectile->GetOuterRadius(); >> 155 // G4cout << "out radius - nucleus - projectile " << fancyNucleus->GetOuterRadius()/fermi << " - " << projectile->GetOuterRadius()/fermi << G4endl; >> 156 G4double aX=(2.*G4UniformRand()-1.)*impactMax; >> 157 G4double aY=(2.*G4UniformRand()-1.)*impactMax; >> 158 G4ThreeVector pos(aX, aY, -2.*impactMax-5.*fermi); >> 159 debug.push_back("Impact parameter"); >> 160 debug.push_back(aX); >> 161 debug.push_back(aY); >> 162 debug.push_back(-2.*impactMax); >> 163 debug.dump(); >> 164 >> 165 G4KineticTrackVector * initalState = new G4KineticTrackVector; >> 166 projectile->StartLoop(); >> 167 G4Nucleon * aNuc; >> 168 G4LorentzVector tmpV(0,0,0,0); >> 169 G4LorentzVector nucleonMom(1./a1*mom); >> 170 nucleonMom.setZ(nucleonMom.vect().mag()); >> 171 nucleonMom.setX(0); >> 172 nucleonMom.setY(0); >> 173 debug.push_back(" projectile nucleon momentum"); >> 174 debug.push_back(nucleonMom); >> 175 debug.dump(); >> 176 theFermi.Init(a1,z1); >> 177 while( (aNuc=projectile->GetNextNucleon()) ) 138 { 178 { 139 result=Interact(mom,toBreit); << 179 G4LorentzVector p4 = aNuc->GetMomentum(); 140 << 180 tmpV+=p4; 141 if(! result ) << 181 G4ThreeVector nucleonPosition(aNuc->GetPosition()); 142 { << 182 G4double density=(projectile->GetNuclearDensity())->GetDensity(nucleonPosition); 143 // abort!! << 183 nucleonPosition += pos; 144 << 184 G4KineticTrack * it = new G4KineticTrack(aNuc, nucleonPosition, nucleonMom ); 145 G4cerr << "G4BinaryLightIonReaction << 185 it->SetState(G4KineticTrack::outside); 146 G4cerr << " Primary " << aTrack.Get << 186 G4double pfermi= theFermi.GetFermiMomentum(density); 147 << ", (A,Z)=(" << aTrack.GetDefi << 187 G4double mass = aNuc->GetDefinition()->GetPDGMass(); 148 << "," << aTrack.GetDefinition() << 188 G4double Efermi= std::sqrt( sqr(mass) + sqr(pfermi)) - mass; 149 << ", kinetic energy " << aTrack << 189 it->SetProjectilePotential(-Efermi); 150 << G4endl; << 190 initalState->push_back(it); 151 G4cerr << " Target nucleus (A,Z)=(" << 152 << (swapped?pA:tA) << "," << 153 << (swapped?pZ:tZ) << ")" << << 154 G4cerr << " if frequent, please sub << 155 << G4endl << G4endl; << 156 << 157 theResult.Clear(); << 158 theResult.SetStatusChange(isAlive); << 159 theResult.SetEnergyChange(aTrack.Ge << 160 theResult.SetMomentumChange(aTrack. << 161 return &theResult; << 162 } << 163 << 164 // Calculate excitation energy, << 165 G4double theStatisticalExEnergy = GetProj << 166 << 167 << 168 pInitialState = mom; << 169 //G4cout << "BLIC: pInitialState from << 170 pInitialState.setT(pInitialState.getT() + << 171 G4ParticleTable::GetParticleTable()->GetIo << 172 //G4cout << "BLIC: target nucleus added << 173 << 174 delete target3dNucleus;target3dNucleus=0; << 175 delete projectile3dNucleus;projectile3dNu << 176 << 177 G4ReactionProductVector * spectators= new << 178 << 179 cascaders = new G4ReactionProductVector; << 180 << 181 G4LorentzVector pspectators=SortResult(re << 182 // this also sets spectatorA and << 183 << 184 // pFinalState=std::accumulate(casca << 185 << 186 std::vector<G4ReactionProduct *>::iterato << 187 << 188 // G4cout << "pInitialState, pFin << 189 // if ( spectA-spectatorA !=0 || spec << 190 // { << 191 // G4cout << "spect Nucl != spect << 192 // spectatorA <<" "<< spectatorZ << << 193 // } << 194 delete result; << 195 result=0; << 196 G4LorentzVector momentum(pInitialState-pF << 197 G4int loopcount(0); << 198 //G4cout << "BLIC: momentum, pspectato << 199 while (std::abs(momentum.e()-pspectators. << 200 << 201 { << 202 G4LorentzVector pCorrect(pInitialState- << 203 //G4cout << "BLIC:: BIC nonconservatio << 204 // Correct outgoing casacde particles.. << 205 G4bool EnergyIsCorrect=EnergyAndMomentu << 206 if ( ! EnergyIsCorrect && debug_G4Binar << 207 { << 208 G4cout << "Warning - G4BinaryLightIon << 209 } << 210 pFinalState=G4LorentzVector(0,0,0,0); << 211 for(iter=cascaders->begin(); iter!=casc << 212 { << 213 pFinalState += G4LorentzVector( (*ite << 214 } << 215 momentum=pInitialState-pFinalState; << 216 if (++loopcount > 10 ) << 217 { << 218 break; << 219 } << 220 } << 221 << 222 // Check if Energy/Momemtum is now ok, if << 223 if ( std::abs(momentum.e()-pspectators.e( << 224 { << 225 for (iter=spectators->begin();iter!=specta << 226 { << 227 delete *iter; << 228 } << 229 delete spectators; << 230 for(iter=cascaders->begin(); iter!=cascad << 231 { << 232 delete *iter; << 233 } << 234 delete cascaders; << 235 << 236 G4cout << "G4BinaryLightIonReaction.cc: m << 237 << " initial - final " << momentum << 238 << " .. pInitialState/pFinalState/s << 239 << pInitialState << G4endl << 240 << pFinalState << G4endl << 241 << pspectators << G4endl << 242 << " .. A,Z " << spectatorA <<" "<< << 243 G4cout << "G4BinaryLightIonReaction inval << 244 G4cout << " Primary " << aTrack.GetDefini << 245 << ", (A,Z)=(" << aTrack.GetDefin << 246 << "," << aTrack.GetDefinition()- << 247 << ", kinetic energy " << aTrack. << 248 << G4endl; << 249 G4cout << " Target nucleus (A,Z)=(" << t << 250 << "," << targetNucleus.GetZ_ << 251 G4cout << " if frequent, please submit ab << 252 << G4endl << G4endl; << 253 #ifdef debug_G4BinaryLightIonReaction << 254 G4ExceptionDescription ed; << 255 ed << "G4BinaryLightIonreaction: Ter << 256 G4Exception("G4BinaryLightIonreactio << 257 ed); << 258 << 259 #endif << 260 theResult.Clear(); << 261 theResult.SetStatusChange(isAlive); << 262 theResult.SetEnergyChange(aTrack.GetKinet << 263 theResult.SetMomentumChange(aTrack.Get4Mo << 264 return &theResult; << 265 << 266 } << 267 if (spectatorA > 0 ) << 268 { << 269 // DeExciteSpectatorNucleus() also << 270 DeExciteSpectatorNucleus(specta << 271 } else { // no spectators << 272 delete spectators; << 273 } << 274 } 191 } 275 // Rotate to lab << 192 debug.push_back(" Sum of proj. nucleon momentum"); 276 G4LorentzRotation toZ; << 193 debug.push_back(tmpV); 277 toZ.rotateZ(-1*mom.phi()); << 194 debug.dump(); 278 toZ.rotateY(-1*mom.theta()); << 195 279 G4LorentzRotation toLab(toZ.inverse()); << 196 result=theModel.Propagate(initalState, fancyNucleus); 280 << 197 debug.push_back("################# Result size"); 281 // Fill the particle change, while rotating. << 198 debug.push_back(result->size()); 282 // theResult.Clear(); << 199 debug.dump(); 283 theResult.Clear(); << 200 std::for_each(initalState->begin(), initalState->end(), Delete<G4KineticTrack>()); 284 theResult.SetStatusChange(stopAndKill); << 201 delete initalState; 285 G4LorentzVector ptot(0); << 286 #ifdef debug_BLIR_result << 287 G4LorentzVector p_raw; << 288 #endif << 289 //G4int i=0; << 290 202 291 G4ReactionProductVector::iterator iter << 203 if(result->size()==0) 292 for(iter=cascaders->begin(); iter!=cascaders << 293 { 204 { 294 if((*iter)->GetNewlyAdded()) << 205 delete result; result=0; 295 { << 206 delete fancyNucleus; 296 G4DynamicParticle * aNewDP = << 207 delete projectile; 297 new G4DynamicParticle((*iter)->GetDe << 208 if (++tryCount > 200) 298 (*iter)->GetTotalEnergy(), << 209 { 299 (*iter)->GetMomentum() ); << 210 // abort!! 300 G4LorentzVector tmp = aNewDP->Get4Moment << 211 301 #ifdef debug_BLIR_result << 212 G4cerr << "G4BinaryLightIonReaction no final state for: " << G4endl; 302 p_raw+= tmp; << 213 G4cerr << " Primary " << aTrack.GetDefinition() 303 #endif << 214 << ", (A,Z)=(" << aTrack.GetDefinition()->GetBaryonNumber() 304 if(swapped) << 215 << "," << aTrack.GetDefinition()->GetPDGCharge() << ") " 305 { << 216 << ", kinetic energy " << aTrack.GetKineticEnergy() 306 tmp*=toBreit.inverse(); << 217 << G4endl; 307 tmp.setVect(-tmp.vect()); << 218 G4cerr << " Target nucleus (A,Z)=(" << targetNucleus.GetN() 308 } << 219 << "," << targetNucleus.GetZ() << G4endl; 309 tmp *= toLab; << 220 G4cerr << " if frequent, please submit above information as bug report" 310 aNewDP->Set4Momentum(tmp); << 221 << G4endl << G4endl; 311 G4HadSecondary aNew = G4HadSecondary(aNe << 222 312 G4double time = 0; << 223 theResult.Clear(); 313 //if(time < 0.0) { time = 0.0; } << 224 theResult.SetStatusChange(isAlive); 314 aNew.SetTime(timePrimary + time); << 225 theResult.SetEnergyChange(aTrack.GetKineticEnergy()); 315 //aNew.SetCreatorModelID((*iter)-> << 226 theResult.SetMomentumChange(aTrack.Get4Momentum().vect().unit()); 316 aNew.SetCreatorModelID(theBLIR_ID) << 227 return &theResult; 317 << 318 theResult.AddSecondary(aNew); << 319 ptot += tmp; << 320 //G4cout << "BLIC: Secondary " < << 321 // <<" "<< aNew->GetMomen << 322 } << 323 delete *iter; << 324 } << 325 delete cascaders; << 326 << 327 #ifdef debug_BLIR_result << 328 //G4cout << "Result analysis, secondaries " << 329 //G4cout << "p_tot_raw " << p_raw << " sum p << 330 G4double m_nucl= G4ParticleTable::GetPartic << 331 GetIonMass(targetNucleus.GetZ_asInt( << 332 // delete? tZ=targetNucleus.GetZ_asInt(); << 333 << 334 //G4cout << "BLIC Energy conservation initia << 335 // << aTrack.GetTotalEnergy() + m_nuc << 336 // <<" "<< aTrack.GetTotalEnergy() + m_ << 337 G4cout << "BLIC momentum conservation " << a << 338 << " ptot " << ptot << " delta " << aTra << 339 << " 3mom.mag() " << (aTrack.Get4 << 340 #endif << 341 << 342 if(debug_G4BinaryLightIonReactionResults) G4 << 343 << 344 return &theResult; << 345 } << 346 228 347 //-------------------------------------------- << 229 } 348 << 230 } 349 //******************************************** << 231 else 350 G4bool G4BinaryLightIonReaction::EnergyAndMome << 351 G4ReactionProductVector* Output, G4Lorentz << 352 //******************************************** << 353 { << 354 const int nAttemptScale = 2500; << 355 const double ErrLimit = 1.E-6; << 356 if (Output->empty()) << 357 return TRUE; << 358 G4LorentzVector SumMom(0,0,0,0); << 359 G4double SumMass = 0; << 360 G4double TotalCollisionMass = TotalCo << 361 size_t i = 0; << 362 // Calculate sum hadron 4-momenta and summin << 363 for(i = 0; i < Output->size(); i++) << 364 { 232 { 365 SumMom += G4LorentzVector((*Output)[i]->G << 233 break; 366 SumMass += (*Output)[i]->GetDefinition()-> << 234 } 367 } << 235 } 368 // G4cout << " E/P corrector, SumMass, Sum << 236 debug.push_back(" Attempts to create final state"); 369 // << SumMass <<" "<< SumMom.m2() << << 237 debug.push_back(tryCount); 370 if (SumMass > TotalCollisionMass) return FAL << 238 debug.dump(); 371 SumMass = SumMom.m2(); << 239 debug.push_back("################# Through the loop ? "); debug.dump(); 372 if (SumMass < 0) return FALSE; << 240 //inverse transformation in case we swapped. 373 SumMass = std::sqrt(SumMass); << 241 G4int resA(0), resZ(0); 374 << 242 G4Nucleon * aNuc; 375 // Compute c.m.s. hadron velocity and boost << 243 // fancyNucleus->StartLoop(); 376 G4ThreeVector Beta = -SumMom.boostVector(); << 244 // while( (aNuc=fancyNucleus->GetNextNucleon()) ) 377 //G4cout << " == pre boost 2 "<< SumMo << 245 // { 378 //--old Output->Boost(Beta); << 246 // G4cout << " tgt Nucleon : " << aNuc->GetDefinition()->GetParticleName() <<" "<< aNuc->AreYouHit() <<" "<<aNuc->GetMomentum()<<G4endl; 379 for(i = 0; i < Output->size(); i++) << 247 // } >> 248 G4ReactionProductVector * spectators= new G4ReactionProductVector; >> 249 debug.push_back("getting at the hits"); debug.dump(); >> 250 // the projectile excitation energy estimate... >> 251 G4double theStatisticalExEnergy = 0; >> 252 projectile->StartLoop(); >> 253 while( (aNuc=projectile->GetNextNucleon()) ) >> 254 { >> 255 // G4cout << " Nucleon : " << aNuc->GetDefinition()->GetParticleName() <<" "<< aNuc->AreYouHit() <<" "<<aNuc->GetMomentum()<<G4endl; >> 256 debug.push_back("getting the hits"); debug.dump(); >> 257 if(!aNuc->AreYouHit()) 380 { 258 { 381 G4LorentzVector mom = G4LorentzVector((*Ou << 259 resA++; 382 mom *= Beta; << 260 resZ+=G4lrint(aNuc->GetDefinition()->GetPDGCharge()); 383 (*Output)[i]->SetMomentum(mom.vect()); << 384 (*Output)[i]->SetTotalEnergy(mom.e()); << 385 } 261 } 386 << 262 else 387 // Scale total c.m.s. hadron energy (hadron << 388 // It should be equal interaction mass << 389 G4double Scale = 0,OldScale=0; << 390 G4double factor = 1.; << 391 G4int cAttempt = 0; << 392 G4double Sum = 0; << 393 G4bool success = false; << 394 for(cAttempt = 0; cAttempt < nAttemptScale; << 395 { 263 { 396 Sum = 0; << 264 debug.push_back(" ##### a hit ##### "); debug.dump(); 397 for(i = 0; i < Output->size(); i++) << 265 G4ThreeVector aPosition(aNuc->GetPosition()); 398 { << 266 G4double localDensity = projectile->GetNuclearDensity()->GetDensity(aPosition); 399 G4LorentzVector HadronMom = G4LorentzVec << 267 G4double localPfermi = theFermi.GetFermiMomentum(localDensity); 400 HadronMom.setVect(HadronMom.vect()+ fact << 268 G4double nucMass = aNuc->GetDefinition()->GetPDGMass(); 401 G4double E = std::sqrt(HadronMom.vect(). << 269 G4double localFermiEnergy = std::sqrt(nucMass*nucMass + localPfermi*localPfermi) - nucMass; 402 HadronMom.setE(E); << 270 G4double deltaE = localFermiEnergy - (aNuc->GetMomentum().t()-aNuc->GetMomentum().mag()); 403 (*Output)[i]->SetMomentum(HadronMom.vect << 271 theStatisticalExEnergy += deltaE; 404 (*Output)[i]->SetTotalEnergy(HadronMom.e << 405 Sum += E; << 406 } << 407 OldScale=Scale; << 408 Scale = TotalCollisionMass/Sum - 1; << 409 // G4cout << "E/P corr - " << cAttempt << << 410 if (std::abs(Scale) <= ErrLimit << 411 || OldScale == Scale) // protect ' << 412 { << 413 if (debug_G4BinaryLightIonReactionResult << 414 success = true; << 415 break; << 416 } << 417 if ( cAttempt > 10 ) << 418 { << 419 // G4cout << " speed it up? " << << 420 factor=std::max(1.,G4Log(std::abs(OldSca << 421 // G4cout << " ? factor ? " << factor << 422 } << 423 } 272 } 424 << 273 debug.push_back("collected a hit"); 425 if( (!success) && debug_G4BinaryLightIonRea << 274 debug.push_back(aNuc->GetMomentum()); >> 275 debug.dump(); >> 276 } >> 277 delete fancyNucleus; >> 278 delete projectile; >> 279 G4ping debug("debug_G4BinaryLightIonReaction_1"); >> 280 debug.push_back("have the hits. A,Z, excitE"); >> 281 debug.push_back(resA); >> 282 debug.push_back(resZ); >> 283 debug.push_back(theStatisticalExEnergy); >> 284 debug.dump(); >> 285 // Calculate excitation energy >> 286 G4LorentzVector iState = mom; >> 287 iState.setT(iState.getT()+m2); >> 288 >> 289 G4LorentzVector fState(0,0,0,0); >> 290 G4LorentzVector pspectators(0,0,0,0); >> 291 unsigned int i(0); >> 292 // G4int spectA(0),spectZ(0); >> 293 for(i=0; i<result->size(); i++) >> 294 { >> 295 if( (*result)[i]->GetNewlyAdded() ) 426 { 296 { 427 G4cout << "G4G4BinaryLightIonReaction::Ene << 297 fState += G4LorentzVector( (*result)[i]->GetMomentum(), (*result)[i]->GetTotalEnergy() ); 428 G4cout << " Scale not unity at end of it << 298 cascaders->push_back((*result)[i]); 429 G4cout << " Increase number of attempts << 299 // G4cout <<" secondary ... "; >> 300 debug.push_back("secondary "); >> 301 debug.push_back((*result)[i]->GetDefinition()->GetParticleName()); >> 302 debug.push_back(G4LorentzVector((*result)[i]->GetMomentum(),(*result)[i]->GetTotalEnergy())); >> 303 debug.dump(); 430 } 304 } 431 << 305 else { 432 // Compute c.m.s. interaction velocity and K << 306 // G4cout <<" spectator ... "; 433 Beta = TotalCollisionMom.boostVector(); << 307 pspectators += G4LorentzVector( (*result)[i]->GetMomentum(), (*result)[i]->GetTotalEnergy() ); 434 //--old Output->Boost(Beta); << 308 spectators->push_back((*result)[i]); 435 for(i = 0; i < Output->size(); i++) << 309 debug.push_back("spectator "); 436 { << 310 debug.push_back((*result)[i]->GetDefinition()->GetParticleName()); 437 G4LorentzVector mom = G4LorentzVector((*Ou << 311 debug.push_back(G4LorentzVector((*result)[i]->GetMomentum(),(*result)[i]->GetTotalEnergy())); 438 mom *= Beta; << 312 debug.dump(); 439 (*Output)[i]->SetMomentum(mom.vect()); << 313 // spectA++; 440 (*Output)[i]->SetTotalEnergy(mom.e()); << 314 // spectZ+= G4lrint((*result)[i]->GetDefinition()->GetPDGCharge()); 441 } 315 } 442 return TRUE; << 443 } << 444 G4bool G4BinaryLightIonReaction::SetLighterAsP << 445 { << 446 G4bool swapped = false; << 447 if(tA<pA) << 448 { << 449 swapped = true; << 450 G4int tmp(0); << 451 tmp = tA; tA=pA; pA=tmp; << 452 tmp = tZ; tZ=pZ; pZ=tmp; << 453 G4double m1=G4ParticleTable::GetParticle << 454 G4LorentzVector it(m1, G4ThreeVector(0,0 << 455 mom = toBreit*it; << 456 } << 457 return swapped; << 458 } << 459 G4ReactionProductVector * G4BinaryLightIonReac << 460 { << 461 // Check if kinematically nuclei can fuse. << 462 G4double mFused=G4ParticleTable::GetParticl << 463 G4double mTarget=G4ParticleTable::GetPartic << 464 G4LorentzVector pCompound(mom.e()+mTarget,m << 465 G4double m2Compound=pCompound.m2(); << 466 if (m2Compound < sqr(mFused) ) { << 467 //G4cout << "G4BLIC: projectile p, mTarge << 468 // << " " << sqrt(m2Compound)<< " " << 469 return 0; << 470 } << 471 316 472 G4Fragment aPreFrag; << 317 // G4cout << (*result)[i]<< " " 473 aPreFrag.SetZandA_asInt(pZ+tZ, pA+tA); << 318 // << (*result)[i]->GetDefinition()->GetParticleName() << " " 474 aPreFrag.SetNumberOfParticles(pA); << 319 // << (*result)[i]->GetMomentum()<< " " 475 aPreFrag.SetNumberOfCharged(pZ); << 320 // << (*result)[i]->GetTotalEnergy() << G4endl; 476 aPreFrag.SetNumberOfHoles(0); << 321 } 477 //GF FIXME: whyusing plop in z direction? t << 322 // if ( spectA-resA !=0 || spectZ-resZ !=0) 478 //G4ThreeVector plop(0.,0., mom.vect().mag( << 323 // { 479 //G4LorentzVector aL(mom.t()+mTarget, plop) << 324 // G4cout << "spect Nucl != spectators: nucl a,z; spect a,z" << 480 G4LorentzVector aL(mom.t()+mTarget,mom.vect << 325 // resA <<" "<< resZ <<" ; " << spectA <<" "<< spectZ << G4endl; 481 aPreFrag.SetMomentum(aL); << 326 // } 482 << 327 delete result; 483 << 328 debug.push_back(" iState - (fState+pspectators) "); 484 //G4cout << "Fragment INFO "<< pA+tA << 329 debug.push_back(iState-fState-pspectators); 485 // << aL <<" "<<G4endl << aPreF << 330 debug.dump(); 486 G4ReactionProductVector * cascaders = thePr << 331 G4LorentzVector momentum(iState-fState); 487 //G4double tSum = 0; << 332 G4int loopcount(0); 488 for(size_t count = 0; count<cascaders->size << 333 while (std::abs(momentum.e()-pspectators.e()) > 10*MeV) 489 { << 490 cascaders->operator[](count)->SetNewlyAd << 491 //tSum += cascaders->operator[](count)-> << 492 } << 493 // G4cout << "Exiting pre-compound on << 494 return cascaders; << 495 } << 496 G4ReactionProductVector * G4BinaryLightIonReac << 497 { << 498 G4ReactionProductVector * result = 0; << 499 G4double projectileMass(0); << 500 G4LorentzVector it; << 501 << 502 G4int tryCount(0); << 503 do << 504 { 334 { 505 ++tryCount; << 335 debug.push_back("the momentum balance"); 506 projectile3dNucleus = new G4Fancy3DNu << 336 debug.push_back(iState); 507 projectile3dNucleus->Init(pA, pZ); << 337 debug.push_back(fState); 508 projectile3dNucleus->CenterNucleons() << 338 debug.push_back(momentum-pspectators); 509 projectileMass=G4ParticleTable::GetPa << 339 debug.push_back(momentum); 510 projectile3dNucleus->GetCharge( << 340 debug.dump(); 511 it=toBreit * G4LorentzVector(projecti << 341 G4LorentzVector pCorrect(iState-pspectators); 512 << 342 G4bool EnergyIsCorrect=EnergyAndMomentumCorrector(cascaders, pCorrect); 513 target3dNucleus = new G4Fancy3DNucleu << 343 if ( ! EnergyIsCorrect && getenv("debug_G4BinaryLightIonReactionResults")) 514 target3dNucleus->Init(tA, tZ); << 515 G4double impactMax = target3dNucleus- << 516 // G4cout << "out radius - nuc << 517 G4double aX=(2.*G4UniformRand()-1.)*i << 518 G4double aY=(2.*G4UniformRand()-1.)*i << 519 G4ThreeVector pos(aX, aY, -2.*impactM << 520 << 521 G4KineticTrackVector * initalState = << 522 projectile3dNucleus->StartLoop(); << 523 G4Nucleon * aNuc; << 524 G4LorentzVector tmpV(0,0,0,0); << 525 #ifdef debug_BLIR_finalstate << 526 G4LorentzVector pinitial; << 527 #endif << 528 G4LorentzVector nucleonMom(1./pA*mom) << 529 nucleonMom.setZ(nucleonMom.vect().mag << 530 nucleonMom.setX(0); << 531 nucleonMom.setY(0); << 532 theFermi.Init(pA,pZ); << 533 while( (aNuc=projectile3dNucleus->Get << 534 { 344 { 535 G4LorentzVector p4 = aNuc->GetMome << 345 G4cout << "Warning - G4BinaryLightIonReaction E/P correction for cascaders failed" << G4endl; 536 tmpV+=p4; << 537 G4ThreeVector nucleonPosition(aNuc << 538 G4double density=(projectile3dNucl << 539 nucleonPosition += pos; << 540 G4KineticTrack * it1 = new G4Kinet << 541 it1->SetState(G4KineticTrack::outs << 542 G4double pfermi= theFermi.GetFermi << 543 G4double mass = aNuc->GetDefinitio << 544 G4double Efermi= std::sqrt( sqr(ma << 545 it1->SetProjectilePotential(-Eferm << 546 initalState->push_back(it1); << 547 #ifdef debug_BLIR_finalstate << 548 pinitial += it1->Get4Momentum() << 549 #endif << 550 } 346 } 551 << 347 fState=G4LorentzVector(); 552 result=theModel->Propagate(initalStat << 348 for(i=0; i<cascaders->size(); i++) 553 #ifdef debug_BLIR_finalstate << 554 if( result && result->size()>0) << 555 { << 556 G4cout << " Cascade result " << G4endl; << 557 G4LorentzVector presult; << 558 G4ReactionProductVector::iterator << 559 G4ReactionProduct xp; << 560 for (iter=result->begin(); iter ! << 561 { << 562 presult += G4LorentzVector((*ite << 563 G4cout << (*iter)->GetDefinition()->Ge << 564 << "("<< (*iter)->GetMomentum().x()<<" << 565 << (*iter)->GetMomentum().y()<<"," << 566 << (*iter)->GetMomentum().z()<<";" << 567 << (*iter)->GetTotalEnergy() <<")"< << 568 } << 569 << 570 G4cout << "BLIC check result : in << 571 << " final " << presult << 572 << " IF - FF " << pinitial +G << 573 << 574 } << 575 #endif << 576 if( result && result->size()==0) << 577 { 349 { 578 delete result; << 350 fState += G4LorentzVector( (*cascaders)[i]->GetMomentum(), (*cascaders)[i]->GetTotalEnergy() ); 579 result=0; << 351 } 580 } << 352 momentum=iState-fState; 581 if ( ! result ) << 353 debug.push_back("the momentum balance after correction"); 582 { << 354 debug.push_back(iState); 583 delete target3dNucleus; << 355 debug.push_back(fState); 584 delete projectile3dNucleus; << 356 debug.push_back(momentum-pspectators); 585 } << 357 debug.push_back(momentum); >> 358 debug.dump(); >> 359 if (++loopcount > 10 ) >> 360 { >> 361 if ( momentum.vect().mag() > momentum.e() ) >> 362 { >> 363 G4cerr << "G4BinaryLightIonReaction.cc: Cannot correct 4-momentum of cascade particles" << G4endl; >> 364 throw G4HadronicException(__FILE__, __LINE__, "G4BinaryCasacde::ApplyCollision()"); >> 365 } else { >> 366 break; >> 367 } >> 368 >> 369 } >> 370 } 586 371 587 // std::for_each(initalState->begin() << 588 // delete initalState; << 589 372 590 } while (! result && tryCount< 150); / << 591 return result; << 592 } << 593 G4double G4BinaryLightIonReaction::GetProjecti << 594 { << 595 373 596 G4Nucleon * aNuc; << 374 597 // the projectileNucleus excitation ener << 375 // call precompound model 598 G4double theStatisticalExEnergy = 0; << 376 G4ReactionProductVector * proFrag = NULL; 599 projectile3dNucleus->StartLoop(); << 377 G4LorentzVector pFragment; 600 while( (aNuc=projectile3dNucleus->GetNex << 378 // G4cout << " == pre boost 1 "<< momentum.e()<< " "<< momentum.mag()<<G4endl; >> 379 G4LorentzRotation boost_fragments; >> 380 // G4cout << " == post boost 1 "<< momentum.e()<< " "<< momentum.mag()<<G4endl; >> 381 // G4LorentzRotation boost_spectator_mom(-momentum.boostVector()); >> 382 // G4cout << "- momentum " << boost_spectator_mom * momentum << G4endl; >> 383 G4LorentzVector pFragments(0); >> 384 if(resZ>0 && resA>1) 601 { 385 { 602 //G4cout << " Nucleon : " << a << 386 // Make the fragment 603 if(aNuc->AreYouHit()) { << 387 G4Fragment aProRes; 604 G4ThreeVector aPosition(aNuc->GetP << 388 aProRes.SetA(resA); 605 G4double localDensity = projectile << 389 aProRes.SetZ(resZ); 606 G4double localPfermi = theFermi.Ge << 390 aProRes.SetNumberOfParticles(0); 607 G4double nucMass = aNuc->GetDefini << 391 aProRes.SetNumberOfCharged(0); 608 G4double localFermiEnergy = std::s << 392 aProRes.SetNumberOfHoles(G4lrint(a1)-resA); 609 G4double deltaE = localFermiEnergy << 393 G4double mFragment=G4ParticleTable::GetParticleTable()->GetIonTable()->GetIonMass(resZ,resA); 610 theStatisticalExEnergy += deltaE; << 394 G4LorentzVector pFragment(0,0,0,mFragment+std::max(0.,theStatisticalExEnergy) ); 611 } << 395 aProRes.SetMomentum(pFragment); >> 396 G4ParticleDefinition * resDef; >> 397 resDef = G4ParticleTable::GetParticleTable()->FindIon(resZ,resA,0,resZ); >> 398 aProRes.SetParticleDefinition(resDef); >> 399 proFrag = theHandler.BreakItUp(aProRes); >> 400 if ( momentum.vect().mag() > momentum.e() ) >> 401 { >> 402 G4cerr << "mom check: " << momentum >> 403 << " 3.mag "<< momentum.vect().mag() << G4endl >> 404 << " .. iState/fState/spectators " << iState <<" " >> 405 << fState << " " << pspectators << G4endl >> 406 << " .. A,Z " << resA <<" "<< resZ << G4endl; >> 407 G4cerr << "G4BinaryLightIonReaction no final state for: " << G4endl; >> 408 G4cerr << " Primary " << aTrack.GetDefinition() >> 409 << ", (A,Z)=(" << aTrack.GetDefinition()->GetBaryonNumber() >> 410 << "," << aTrack.GetDefinition()->GetPDGCharge() << ") " >> 411 << ", kinetic energy " << aTrack.GetKineticEnergy() >> 412 << G4endl; >> 413 G4cerr << " Target nucleus (A,Z)=(" << targetNucleus.GetN() >> 414 << "," << targetNucleus.GetZ() << G4endl; >> 415 G4cerr << " if frequent, please submit above information as bug report" >> 416 << G4endl << G4endl; >> 417 >> 418 theResult.Clear(); >> 419 theResult.SetStatusChange(isAlive); >> 420 theResult.SetEnergyChange(aTrack.GetKineticEnergy()); >> 421 theResult.SetMomentumChange(aTrack.Get4Momentum().vect().unit()); >> 422 return &theResult; 612 } 423 } 613 return theStatisticalExEnergy; << 424 614 } << 425 G4LorentzRotation boost_fragments_here(momentum.boostVector()); 615 << 426 boost_fragments = boost_fragments_here; 616 G4LorentzVector G4BinaryLightIonReaction::Sort << 427 617 { << 428 // G4cout << " Fragment a,z, Mass Fragment, mass spect-mom, exitationE " 618 unsigned int i(0); << 429 // << resA <<" "<< resZ <<" "<< mFragment <<" " 619 spectatorA=spectatorZ=0; << 430 // << momentum.mag() <<" "<< momentum.mag() - mFragment 620 G4LorentzVector pspectators(0,0,0,0); << 431 // << " "<<theStatisticalExEnergy 621 pFinalState=G4LorentzVector(0,0,0,0); << 432 // << " "<< boost_fragments*pFragment<< G4endl; 622 for(i=0; i<result->size(); i++) << 433 G4ReactionProductVector::iterator ispectator; 623 { << 434 for (ispectator=spectators->begin();ispectator!=spectators->end();ispectator++) 624 if( (*result)[i]->GetNewlyAdded() ) << 435 { 625 { << 436 delete *ispectator; 626 pFinalState += G4LorentzVector( (*res << 437 } 627 cascaders->push_back((*result)[i]); << 438 } 628 } << 439 else if(resA!=0) 629 else { << 630 // G4cout <<" spectator ... << 631 pspectators += G4LorentzVector( (*res << 632 spectators->push_back((*result)[i]); << 633 spectatorA++; << 634 spectatorZ+= G4lrint((*result)[i]->Ge << 635 } << 636 << 637 // G4cout << (*result)[i]<< " " << 638 // << (*result)[i]->GetDefinition << 639 // << (*result)[i]->GetMomentum() << 640 // << (*result)[i]->GetTotalEnerg << 641 } << 642 //G4cout << "pFinalState / pspectators, << 643 // << " (" << spectatorA << ", "<< sp << 644 << 645 return pspectators; << 646 } << 647 << 648 void G4BinaryLightIonReaction::DeExciteSpectat << 649 << 650 { << 651 // call precompound model << 652 G4ReactionProductVector * proFrag = 0; << 653 G4LorentzVector pFragment(0.,0.,0.,0.); << 654 // G4cout << " == pre boost 1 "<< mome << 655 G4LorentzRotation boost_fragments; << 656 // G4cout << " == post boost 1 "<< mom << 657 // G4LorentzRotation boost_spectator_mom << 658 // G4cout << "- momentum " << boost_spe << 659 G4LorentzVector pFragments(0,0,0,0); << 660 << 661 if(spectatorZ>0 && spectatorA>1) << 662 { << 663 // Make the fragment << 664 G4Fragment aProRes; << 665 aProRes.SetZandA_asInt(spectatorZ, spect << 666 aProRes.SetNumberOfParticles(0); << 667 aProRes.SetNumberOfCharged(0); << 668 aProRes.SetNumberOfHoles(pA-spectatorA); << 669 G4double mFragment=G4ParticleTable::GetP << 670 pFragment=G4LorentzVector(0,0,0,mFragmen << 671 aProRes.SetMomentum(pFragment); << 672 << 673 proFrag = theHandler->BreakItUp(aProRes) << 674 << 675 boost_fragments = G4LorentzRotation(pSpe << 676 << 677 // G4cout << " Fragment a,z, Mass Fr << 678 // << spectatorA <<" "<< spectator << 679 // << momentum.mag() <<" "<< momen << 680 // << " "<<theStatisticalExEnergy << 681 // << " "<< boost_fragments*pFragm << 682 G4ReactionProductVector::iterator ispect << 683 for (ispectator=spectators->begin();ispe << 684 { 440 { 685 delete *ispectator; << 441 G4ReactionProductVector::iterator ispectator; >> 442 for (ispectator=spectators->begin();ispectator!=spectators->end();ispectator++) >> 443 { >> 444 (*ispectator)->SetNewlyAdded(true); >> 445 cascaders->push_back(*ispectator); >> 446 pFragments+=G4LorentzVector((*ispectator)->GetMomentum(),(*ispectator)->GetTotalEnergy()); >> 447 // G4cout << "from spectator " >> 448 // << (*ispectator)->GetDefinition()->GetParticleName() << " " >> 449 // << (*ispectator)->GetMomentum()<< " " >> 450 // << (*ispectator)->GetTotalEnergy() << G4endl; >> 451 } 686 } 452 } 687 } << 453 if (spectators) delete spectators; 688 else if(spectatorA!=0) << 454 689 { << 455 // collect the evaporation part 690 G4ReactionProductVector::iterator ispecta << 456 debug.push_back("the nucleon count balance"); 691 for (ispectator=spectators->begin();ispec << 457 debug.push_back(resA); 692 { << 458 debug.push_back(resZ); 693 (*ispectator)->SetNewlyAdded(true); << 459 if(proFrag) debug.push_back(proFrag->size()); 694 cascaders->push_back(*ispectator); << 460 debug.dump(); 695 pFinalState+=G4LorentzVector((*ispect << 461 G4ReactionProductVector::iterator ii; 696 //G4cout << "BLIC: spectator << 462 if(proFrag) for(ii=proFrag->begin(); ii!=proFrag->end(); ii++) 697 // << (*ispectator)->GetDefi << 463 { 698 // << (*ispectator)->GetMome << 464 (*ii)->SetNewlyAdded(true); 699 // << (*ispectator)->GetTota << 465 G4LorentzVector tmp((*ii)->GetMomentum(),(*ii)->GetTotalEnergy()); >> 466 tmp *= boost_fragments; >> 467 (*ii)->SetMomentum(tmp.vect()); >> 468 (*ii)->SetTotalEnergy(tmp.e()); >> 469 // result->push_back(*ii); >> 470 pFragments += tmp; 700 } 471 } 701 472 702 } << 473 // G4cout << "Fragmented p, momentum, delta " << pFragments <<" "<<momentum 703 // / if (spectators) << 474 // <<" "<< pFragments-momentum << G4endl; 704 delete spectators; << 475 debug.push_back("################# done with evaporation"); debug.dump(); >> 476 >> 477 // correct p/E of Cascade secondaries >> 478 G4LorentzVector pCas=iState - pFragments; >> 479 // G4cout <<" Going to correct from " << fState << " to " << pCas << G4endl; >> 480 G4bool EnergyIsCorrect=EnergyAndMomentumCorrector(cascaders, pCas); >> 481 if ( ! EnergyIsCorrect ) >> 482 { >> 483 if(getenv("debug_G4BinaryLightIonReactionResults")) >> 484 G4cout << "G4BinaryLightIonReaction E/P correction for nucleus failed, will try to correct overall" << G4endl; >> 485 } 705 486 706 // collect the evaporation part and boost t << 487 // Add deexcitation secondaries 707 G4ReactionProductVector::iterator ii; << 488 if(proFrag) for(ii=proFrag->begin(); ii!=proFrag->end(); ii++) 708 if(proFrag) << 489 { 709 { << 490 cascaders->push_back(*ii); 710 for(ii=proFrag->begin(); ii!=proFrag->en << 711 { << 712 (*ii)->SetNewlyAdded(true); << 713 G4LorentzVector tmp((*ii)->GetMomentu << 714 tmp *= boost_fragments; << 715 (*ii)->SetMomentum(tmp.vect()); << 716 (*ii)->SetTotalEnergy(tmp.e()); << 717 // result->push_back(*ii); << 718 pFragments += tmp; << 719 } 491 } 720 } << 492 if (proFrag) delete proFrag; 721 493 722 // G4cout << "Fragmented p, momentum, de << 494 if ( ! EnergyIsCorrect ) 723 // <<" "<< pFragments-momentum < << 495 { >> 496 if (! EnergyAndMomentumCorrector(cascaders,iState)) >> 497 { >> 498 if(getenv("debug_G4BinaryLightIonReactionResults")) >> 499 G4cout << "G4BinaryLightIonReaction E/P corrections failed" << G4endl; >> 500 } >> 501 } >> 502 >> 503 } >> 504 >> 505 // Rotate to lab >> 506 G4LorentzRotation toZ; >> 507 toZ.rotateZ(-1*mom.phi()); >> 508 toZ.rotateY(-1*mom.theta()); >> 509 G4LorentzRotation toLab(toZ.inverse()); >> 510 >> 511 // Fill the particle change, while rotating. Boost from projectile breit-frame in case we swapped. >> 512 // theResult.Clear(); >> 513 theResult.Clear(); >> 514 theResult.SetStatusChange(stopAndKill); >> 515 G4double Etot(0); >> 516 size_t i=0; >> 517 for(i=0; i<cascaders->size(); i++) >> 518 { >> 519 if((*cascaders)[i]->GetNewlyAdded()) >> 520 { >> 521 G4DynamicParticle * aNew = >> 522 new G4DynamicParticle((*cascaders)[i]->GetDefinition(), >> 523 (*cascaders)[i]->GetTotalEnergy(), >> 524 (*cascaders)[i]->GetMomentum() ); >> 525 G4LorentzVector tmp = aNew->Get4Momentum(); >> 526 if(swapped) >> 527 { >> 528 tmp*=toBreit.inverse(); >> 529 tmp.setVect(-tmp.vect()); >> 530 } >> 531 tmp *= toLab; >> 532 aNew->Set4Momentum(tmp); >> 533 theResult.AddSecondary(aNew); >> 534 Etot += tmp.e(); >> 535 // G4cout << "LIBIC: Secondary " << aNew->GetDefinition()->GetParticleName() >> 536 // <<" "<< aNew->GetMomentum() >> 537 // <<" "<< aNew->GetTotalEnergy() >> 538 // << G4endl; >> 539 } >> 540 delete (*cascaders)[i]; >> 541 } >> 542 if(cascaders) delete cascaders; >> 543 >> 544 G4ping debug1("debug_G4BinaryLightIonReactionResults"); >> 545 debug1.push_back("Result analysis, secondaries"); >> 546 debug1.push_back(theResult.GetNumberOfSecondaries()); >> 547 debug1.dump(); >> 548 debug1.push_back(" Energy conservation initial/final/delta(init-final) "); >> 549 debug1.push_back(aTrack.GetTotalEnergy() + m_nucl); >> 550 debug1.push_back(aTrack.GetTotalEnergy()); >> 551 debug1.push_back(m_nucl); >> 552 debug1.push_back(Etot); >> 553 debug1.push_back(aTrack.GetTotalEnergy() + m_nucl - Etot); >> 554 debug1.dump(); 724 555 725 // correct p/E of Cascade secondaries << 556 if(getenv("BLICDEBUG") ) G4cerr << " ######### Binary Light Ion Reaction number ends ######### "<<eventcounter<<G4endl; 726 G4LorentzVector pCas=pInitialState - pFragm << 727 557 728 //G4cout <<"BLIC: Going to correct from << 558 return &theResult; 729 // the creation of excited fragment did vi << 559 } 730 G4bool EnergyIsCorrect=EnergyAndMomentumCor << 731 if ( ! EnergyIsCorrect && debug_G4BinaryLig << 732 { << 733 G4cout << "G4BinaryLightIonReaction E/P << 734 } << 735 560 736 // Add deexcitation secondaries << 561 //**************************************************************************** 737 if(proFrag) << 562 G4bool G4BinaryLightIonReaction::EnergyAndMomentumCorrector( 738 { << 563 G4ReactionProductVector* Output, G4LorentzVector& TotalCollisionMom) 739 for(ii=proFrag->begin(); ii!=proFrag->en << 564 //**************************************************************************** >> 565 { >> 566 const int nAttemptScale = 2500; >> 567 const double ErrLimit = 1.E-6; >> 568 if (Output->empty()) >> 569 return TRUE; >> 570 G4LorentzVector SumMom(0); >> 571 G4double SumMass = 0; >> 572 G4double TotalCollisionMass = TotalCollisionMom.m(); >> 573 size_t i = 0; >> 574 // Calculate sum hadron 4-momenta and summing hadron mass >> 575 for(i = 0; i < Output->size(); i++) >> 576 { >> 577 SumMom += G4LorentzVector((*Output)[i]->GetMomentum(),(*Output)[i]->GetTotalEnergy()); >> 578 SumMass += (*Output)[i]->GetDefinition()->GetPDGMass(); >> 579 } >> 580 // G4cout << " E/P corrector, SumMass, SumMom.m2, TotalMass " >> 581 // << SumMass <<" "<< SumMom.m2() <<" "<<TotalCollisionMass<< G4endl; >> 582 if (SumMass > TotalCollisionMass) return FALSE; >> 583 SumMass = SumMom.m2(); >> 584 if (SumMass < 0) return FALSE; >> 585 SumMass = std::sqrt(SumMass); >> 586 >> 587 // Compute c.m.s. hadron velocity and boost KTV to hadron c.m.s. >> 588 G4ThreeVector Beta = -SumMom.boostVector(); >> 589 // G4cout << " == pre boost 2 "<< SumMom.e()<< " "<< SumMom.mag()<<" "<< Beta <<G4endl; >> 590 //--old Output->Boost(Beta); >> 591 for(i = 0; i < Output->size(); i++) >> 592 { >> 593 G4LorentzVector mom = G4LorentzVector((*Output)[i]->GetMomentum(),(*Output)[i]->GetTotalEnergy()); >> 594 mom *= Beta; >> 595 (*Output)[i]->SetMomentum(mom.vect()); >> 596 (*Output)[i]->SetTotalEnergy(mom.e()); >> 597 } >> 598 >> 599 // Scale total c.m.s. hadron energy (hadron system mass). >> 600 // It should be equal interaction mass >> 601 G4double Scale = 0,OldScale=0; >> 602 G4double factor = 1.; >> 603 G4int cAttempt = 0; >> 604 G4double Sum = 0; >> 605 G4bool success = false; >> 606 for(cAttempt = 0; cAttempt < nAttemptScale; cAttempt++) >> 607 { >> 608 Sum = 0; >> 609 for(i = 0; i < Output->size(); i++) 740 { 610 { 741 cascaders->push_back(*ii); << 611 G4LorentzVector HadronMom = G4LorentzVector((*Output)[i]->GetMomentum(),(*Output)[i]->GetTotalEnergy()); >> 612 HadronMom.setVect(HadronMom.vect()+ factor*Scale*HadronMom.vect()); >> 613 G4double E = std::sqrt(HadronMom.vect().mag2() + sqr((*Output)[i]->GetDefinition()->GetPDGMass())); >> 614 HadronMom.setE(E); >> 615 (*Output)[i]->SetMomentum(HadronMom.vect()); >> 616 (*Output)[i]->SetTotalEnergy(HadronMom.e()); >> 617 Sum += E; 742 } 618 } 743 delete proFrag; << 619 OldScale=Scale; 744 } << 620 Scale = TotalCollisionMass/Sum - 1; 745 //G4cout << "EnergyIsCorrect? " << Energ << 621 // G4cout << "E/P corr - " << cAttempt << " " << Scale << G4endl; 746 if ( ! EnergyIsCorrect ) << 622 if (std::abs(Scale) <= ErrLimit 747 { << 623 || OldScale == Scale) // protect 'frozen' situation and divide by 0 in calculating new factor below 748 // G4cout <<" ! EnergyIsCorrect " << << 749 if (! EnergyAndMomentumCorrector(cascade << 750 { 624 { 751 if(debug_G4BinaryLightIonReactionResu << 625 if (getenv("debug_G4BinaryLightIonReactionResults")) G4cout << "E/p corrector: " << cAttempt << G4endl; 752 G4cout << "G4BinaryLightIonReactio << 626 success = true; >> 627 break; 753 } 628 } 754 } << 629 if ( cAttempt > 10 ) 755 << 630 { 756 } << 631 // G4cout << " speed it up? " << std::abs(OldScale/(OldScale-Scale)) << G4endl; 757 << 632 factor=std::max(1.,std::log(std::abs(OldScale/(OldScale-Scale)))); >> 633 // G4cout << " ? factor ? " << factor << G4endl; >> 634 } >> 635 } >> 636 >> 637 if( (!success) && getenv("debug_G4BinaryLightIonReactionResults")) >> 638 { >> 639 G4cout << "G4G4BinaryLightIonReaction::EnergyAndMomentumCorrector - Warning"<<G4endl; >> 640 G4cout << " Scale not unity at end of iteration loop: "<<TotalCollisionMass<<" "<<Sum<<" "<<Scale<<G4endl; >> 641 G4cout << " Increase number of attempts or increase ERRLIMIT"<<G4endl; >> 642 } >> 643 >> 644 // Compute c.m.s. interaction velocity and KTV back boost >> 645 Beta = TotalCollisionMom.boostVector(); >> 646 //--old Output->Boost(Beta); >> 647 for(i = 0; i < Output->size(); i++) >> 648 { >> 649 G4LorentzVector mom = G4LorentzVector((*Output)[i]->GetMomentum(),(*Output)[i]->GetTotalEnergy()); >> 650 mom *= Beta; >> 651 (*Output)[i]->SetMomentum(mom.vect()); >> 652 (*Output)[i]->SetTotalEnergy(mom.e()); >> 653 } >> 654 return TRUE; >> 655 } 758 656