Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4QEnvironment.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // 1 2 3 4 5 6 7
27 //34567890123456789012345678901234567890123456789012345678901234567890123456789
28 //
29 //
30 // $Id$
31 //
32 // ---------------- G4QEnvironment ----------------
33 // by Mikhail Kossov, August 2000.
34 // class for Multy Quasmon Environment used by the CHIPS Model
35 // ------------------------------------------------------------
36 // Short description: The G4QEnvironment class corresponds to the nuclear
37 // environment, containing excited nucleons or nuclear clusters
38 // (G4Quasmons). In the constructer the nucleus (G4QNucleus) is clusterized
39 // and then the projectile hadron (or hadrons) can create one (or a few)
40 // Quasmons, which are fragmented by the Fragment member function. As a
41 // result a vector of G4QHadrons is created, which can include the residual
42 // nucleus in the ground state.
43 //---------------------------------------------------------------------
44 
45 //#define debug
46 //#define pdebug
47 //#define qdebug
48 //#define chdebug
49 //#define sdebug
50 //#define ppdebug
51 //#define cdebug
52 //#define cldebug
53 //#define edebug
54 //#define rdebug
55 //#define fdebug
56 //#define ffdebug
57 //#define pcdebug
58 //#define mudebug
59 
60 #include <cmath>
61 #include <cstdlib>
62 
63 #include "G4QEnvironment.hh"
64 #include "G4PhysicalConstants.hh"
65 #include "G4SystemOfUnits.hh"
66 
67 using namespace std;
68 
70  : theEnvironment(theEnv)
71 {
72  theQFScat = G4QFreeScattering::GetPointer();
73  G4int envPDG = theEnv.GetPDG();
74  G4QPDGCode envQPDG(envPDG);
75  G4int envA = envQPDG.GetBaryNum();
76  G4double envM = envQPDG.GetMass();
77  theWorld = 0;
78  nBarClust = 0;
79  f2all = 0;
80  totCharge = envQPDG.GetCharge();
81  totBaryoN = envA;
82  tot4Mom = G4LorentzVector(0.,0.,0.,envM);
83  theTargetPDG = 0;
84 #ifdef debug
85  G4cout << "G4QEnviron::Const: t4M=" << tot4Mom << ",tC=" << totCharge
86  << ",tB=" << totBaryoN << G4endl;
87 #endif
88 }
89 
90 
92  const G4int targPDG)
93  : theEnvironment(90000000) // User is responsible for projHadrons(Vector)
94 {
95  //static const G4double mNeut= G4QPDGCode(2112).GetMass();
96  //static const G4QContent neutQC(2,1,0,0,0,0);
97  static const G4QPDGCode pimQPDG(-211);
98  theQFScat = G4QFreeScattering::GetPointer();
99  theWorld = G4QCHIPSWorld::Get(); // Get a pointer to the CHIPS World
100  nBarClust = 0;
101  totCharge = 0;
102  totBaryoN = 0;
103  f2all = 0;
104  G4bool fake=false; // At present only fake pi-
105  theTargetPDG=targPDG; // Remenber it for error message
106  G4int nHadrons=projHadrons.size(); // A#of hadrons in the input Vector
107 
108 #ifdef debug
109  G4cout<<"--->>G4QE::Const: Called targPDG="<<targPDG<<", nInpHadr="<<nHadrons<<G4endl;
110 #endif
111  if(nHadrons<1 || targPDG==90000000) // No projectile Hadrons or no target Nucleus
112  {
113  G4cout << "---Warning---G4QEnv::Const:a#ofINPHadr=" << nHadrons
114  << ",tPDG=" << targPDG << G4endl;
115  //throw G4QException("***G4QEnvironment: There is no one projectile or vacuum target");
116  if(nHadrons) // The projectiles are copied to the output
117  {
118  for (G4int ih=0; ih<nHadrons; ih++)
119  {
120  G4QHadron* curQH = new G4QHadron(projHadrons[ih]);
121 #ifdef debug
122  G4cout << "*G4QE::Const:iH#" << ih << "," << curQH->GetQC()
123  << curQH->Get4Momentum() << G4endl;
124 #endif
125 
126  if (curQH->GetPDGCode() == 10) {
127  // Chipolino is found in the input -> Decay
128 
129  G4QContent chQC=curQH->GetQC();
130  // Quark content of the Hadron-Chipolino
131  G4QChipolino QCh(chQC);
132  // Define a Chipolino instance for the Hadron
133 
134  G4LorentzVector ch4M=curQH->Get4Momentum(); // 4Mom of the Hadron-Chipolino
135  G4QPDGCode h1QPDG=QCh.GetQPDG1(); // QPDG of the first hadron
136  G4double h1M =h1QPDG.GetMass();// Mass of the first hadron
137  G4QPDGCode h2QPDG=QCh.GetQPDG2(); // QPDG of the second hadron
138  G4double h2M =h2QPDG.GetMass();// Mass of the second hadron
139  G4double chM2 =ch4M.m2(); // Squared Mass of the Chipolino
140  if( sqr(h1M+h2M) < chM2 ) // Decay is possible
141  {
142  G4LorentzVector h14M(0.,0.,0.,h1M);
143  G4LorentzVector h24M(0.,0.,0.,h2M);
144  if(!G4QHadron(ch4M).DecayIn2(h14M,h24M))
145  {
147  ed << "QChip DecIn2 error: CM=" << std::sqrt(chM2) << " -> h1="
148  << h1QPDG << "(" << h1M << ") + h2=" << h1QPDG << "(" << h2M
149  << ") = " << h1M+h2M << " **Failed**" << G4endl;
150  G4Exception("G4QEnvironment::G4QEnvironment()", "HAD_CHPS_0000",
151  FatalException, ed);
152  }
153  delete curQH; // Kill the primary Chipolino
154  G4QHadron* h1H = new G4QHadron(h1QPDG.GetPDGCode(),h14M);
155  theQHadrons.push_back(h1H); // (delete equivalent)
156  curQH = new G4QHadron(h1H); // ... just to remember independently
157  theProjectiles.push_back(curQH); // Remember it for the error message
158 
159 #ifdef debug
160  G4cout<<"G4QE::Constr: QChipolino -> H1="<<h1QPDG<<h14M<<G4endl;
161 #endif
162  curQH = new G4QHadron(h2QPDG.GetPDGCode(),h24M);
163  theQHadrons.push_back(curQH); // (delete equivalent)
164 #ifdef debug
165  G4cout<<"G4QE::Constr: QChipolino -> H2="<<h2QPDG<<h24M<<G4endl;
166 #endif
167  }
168  else
169  {
171  ed << "LowMassChipolino in Input: " << ih << "," << curQH->GetQC()
172  << curQH->Get4Momentum() << ", chipoM=" << std::sqrt(chM2) << " < m1="
173  << h1M << "(" << h1QPDG << ") + m2=" << h2M << "(" << h2QPDG << ") = "
174  << h1M+h2M << G4endl;
175  G4Exception("G4QEnvironment::G4QEnvironment()", "HAD_CHPS_0001",
176  FatalException, ed);
177  }
178  }
179  theQHadrons.push_back(curQH); // (delete equivalent)
180  curQH = new G4QHadron(curQH); // ... just to remember independently
181  theProjectiles.push_back(curQH); // Remenber it for the error message
182  }
183  }
184  else if(targPDG!=90000000) // No projHadrons,fill targetNucleus to output
185  {
186  G4QHadron* curQH = new G4QHadron(targPDG);
187 #ifdef debug
188  G4cout<<"**G4QE::Const:No iHad,eH="<<curQH->GetQC()<<curQH->Get4Momentum()<<G4endl;
189 #endif
190  theQHadrons.push_back(curQH); // (delete equivalent)
191  }
192  if (nHadrons<0) G4cout<<"***Warning****G4QE::Const:NH="<<nHadrons<<" < 0 !"<<G4endl;
193  return;
194  }
195  G4QPDGCode targQPDG(targPDG);
196 #ifdef debug
197  G4cout<<"G4QE::C:targQPDG="<<targQPDG<<G4endl;
198 #endif
199  G4int targA=targQPDG.GetBaryNum();
200  G4double targM=targQPDG.GetMass();
201  totCharge=targQPDG.GetCharge();
202  totBaryoN=targA;
203  tot4Mom=G4LorentzVector(0.,0.,0.,targM);
204  // === Print out of the input information at Creation time & tot 4-mom Calculation ===
205 #ifdef debug
206  G4cout<<"G4QE::C:PDG="<<targPDG<<",C="<<totCharge<<",M="<<targM<<",n="<<nHadrons<<G4endl;
207 #endif
208  for(G4int ipr=0; ipr<nHadrons; ipr++)// LOOP is used for the tot4Mom calc. & for printing
209  {
210  G4QHadron* prHadr = projHadrons[ipr];
211  G4QHadron* curQH = new G4QHadron(prHadr);// Remenber it for _
212  theProjectiles.push_back(curQH); // the error message
213  G4LorentzVector h4Mom = prHadr->Get4Momentum();
214  tot4Mom += h4Mom;
215  totCharge += prHadr->GetCharge();
216  totBaryoN += prHadr->GetBaryonNumber();
217 #ifdef debug
218  G4int hPDG = prHadr->GetPDGCode();
219  G4int hNFrag= prHadr->GetNFragments();
220  G4QContent hQC = prHadr->GetQC();
221  G4cout<<"G4QE::C:#"<<ipr<<",PDG="<<hPDG<<hQC<<",4M="<<h4Mom<<",hNFr="<<hNFrag<<G4endl;
222 #endif
223  }
224 #ifdef debug
225  G4cout<<"G4QEnv::Const:tC="<<totCharge<<",tB="<<totBaryoN<<",tot4M="<<tot4Mom<<G4endl;
226 #endif
227 #ifdef debug
228  G4cout<<"G4QEnv::Const: --> tC="<<totCharge<<",tB="<<totBaryoN<<G4endl;
229 #endif
230  G4int nP=theWorld->GetQPEntries(); // A#of init'ed particles in CHIPS World
231  //G4int nCl=nP-90; // A#of init'ed clusters in CHIPS World
232  G4int nCl=nP-53; // @@ A#ofClusters in CHIPSWorld (53=nQHM in G4QPDGCode.hh)
233 #ifdef debug
234  G4cout<<"G4QEnv:Const:Before NCI:n="<<nP<<",F="<<projHadrons[0]->GetNFragments()<<",tC="
235  <<totCharge<<",tB="<<totBaryoN<<", nCl="<<nCl<<G4endl;
236 #endif
237  InitClustersVector(nCl,targA); // Init Clusters as Particles (to interact)
238 #ifdef debug
239  G4cout<<"G4QEnv::Const:NucClust,n="<<nCl<<",F="<<projHadrons[0]->GetNFragments()<<",tC="
240  <<totCharge<<",tB="<<totBaryoN<<G4endl;
241 #endif
242  if(targPDG>80000000) // ==> Nuclear target (including NUCPDG)
243  {
244  theEnvironment.InitByPDG(targPDG); // Create nuclear environment
245 #ifdef debug
246  G4cout<<"G4QEnv::Const:nH="<<nHadrons<<",PDG="<<projHadrons[0]->GetPDGCode()<<",tC="
247  <<totCharge<<",tB="<<totBaryoN<<G4endl;
248 #endif
249  if(nHadrons==1)
250  {
251  G4QHadron* opHad=projHadrons[0];
252  G4int opPDG=opHad->GetPDGCode();
253 #ifdef debug
254  G4cout<<"G4QEnviron::Constructor: *** Only one input hadron*** PDG="<<opPDG<<G4endl;
255 #endif
256  if(opPDG==22) // *** Check photon's NuclearSplitThreshold
257  {
258  G4double exMass=tot4Mom.m();
259 #ifdef debug
260  G4cout<<"G4QEnvironment::Const: exM="<<exMass-targM<<" > mPi0 ?"<<G4endl;
261 #endif
262  if(exMass<targM+135.977) // Nucleus is below the pion production threshold
263  {
264  G4QNucleus exEnviron(tot4Mom,targPDG);
265  // @@ One can put here the pbpt= (M.K.) @@ What about d,t,alpha splitting?
266  if(targM>999.&&!exEnviron.SplitBaryon())//Nucleus is below SplitFragmentThreshold
267  {
268 #ifdef debug
269  G4cout<<"G4QEnv::Const:Photon's added to Output, Env="<<theEnvironment<<G4endl;
270 #endif
271  G4QHadron* photon = new G4QHadron(opHad); // Fill projPhoton to Output
272 #ifdef debug
273  G4cout<<"**G4QE::Const:Phot="<<photon->GetQC()<<photon->Get4Momentum()<<G4endl;
274 #endif
275  theQHadrons.push_back(photon); // (delete equivalent)
276  return;
277  }
278  else if(targM<=999.) // Target is a nucleon
279  {
280  G4LorentzVector prot4m(0.,0.,0.,targM); // Prototype of secondary proton 4mom
281  G4LorentzVector gam4m(0.,0.,0.,0.); // Prototype for secondary gamma 4mom
282  if(!G4QHadron(tot4Mom).DecayIn2(prot4m,gam4m))
283  {
284 #ifdef debug
285  G4cout<<"*War*G4QEnv::Const:(P)Photon->Output, Env="<<theEnvironment<<G4endl;
286 #endif
287  G4QHadron* photon = new G4QHadron(opHad); // Fill projPhoton to Output
288 #ifdef debug
289  G4cout<<"**G4QE::Const:Ph="<<photon->GetQC()<<photon->Get4Momentum()<<G4endl;
290 #endif
291  theQHadrons.push_back(photon); // (delete equivalent)
292  return;
293  }
294  G4QHadron* proton = new G4QHadron(targPDG,prot4m); // Fill tgProton to Output
295  theQHadrons.push_back(proton); // (delete equivalent)
296  G4QHadron* photon = new G4QHadron(22,gam4m); // Fill prPhoton to Output
297  theQHadrons.push_back(photon); // (delete equivalent)
298  theEnvironment.InitByPDG(90000000); // Create nuclear environment
299 #ifdef debug
300  G4cout<<"G4QEnv::Const:Fill gamma and N from gam+N"<<targPDG<<prot4m<<G4endl;
301 #endif
302  return;
303  }
304  }
305  }
306  else if(opPDG==13 || opPDG==15)
307  {
308  G4int nuPDG=14;
309  if(opPDG==15) nuPDG=16;
310  G4LorentzVector mu4m=opHad->Get4Momentum();
311  //G4double qpen=-180.*log(G4UniformRand()); // Energy of target-quark-parton(T=180)
312  G4double qpen=465.*sqrt(sqrt(G4UniformRand())); // UniformDistr for 3-q nucleon
313  G4double qpct=2*G4UniformRand()-1.; // Cos(thet) of target-quark-parton
314  G4double qpst=sqrt(1.-qpct*qpct); // Sin(theta) of target-quark-parton
315  G4double qppt=qpen*qpst; // PT of target-quark-parton
316  G4double qphi=twopi*G4UniformRand(); // Phi of target-quark-parton
317  G4LorentzVector qi4m(qppt*sin(qphi),qppt*cos(qphi),qpen*qpct,qpen); // quark-parton
318  G4LorentzVector qt4m=mu4m+qi4m; // Total 4mom (iniQP+lepton)
319  G4LorentzVector nu4m(0.,0.,0.,0.); // Prototype of secondary neutrino 4mom
320  G4LorentzVector qf4m(0.,0.,0.,0.); // Prototype for secondary quark-parton
321  G4QContent targQC=targQPDG.GetQuarkContent(); // QC of the target nucleus (local!)
322  targQC+=G4QContent(1,0,0,0,1,0); // Make iso-shift with fake pi- is added
323  G4LorentzVector fn4m=G4LorentzVector(0.,0.,0.,0.); // Prototype of the residual 4M
324  G4QNucleus fnN(targQC,fn4m); // Define the final state nucleus
325  G4double fnm=fnN.GetMZNS(); // GS Mass of the final state nucleus
326  //G4QContent resiQC=targQC-neutQC; // QC of resid nucleus (-neutron)
327  //G4QNucleus rsN(resiQC,fn4m); // Define the final state nucleus
328  //G4double rsm=rsN.GetMZNS()+mNeut; // GS Mass of residual nucleus w/o neutron
329  G4double tm=0.; // Prototype of RealMass of the final nucleus
330  G4LorentzVector tg4m=G4LorentzVector(0.,0.,0.,targM); // 4mom of all target nucleus
331  G4LorentzVector fd4m=tg4m-qi4m; // 4mom of the residual coloured nuclear sys.
332 #ifdef debug
333  //G4cout<<"-->>G4QEnv::Const:rM="<<rsm<<",fM="<<fnm<<",tM="<<targM<<G4endl;
334  G4cout<<"G4QEnvironment::Const:mu4M="<<mu4m<<",t4M="<<qt4m<<",tgQP="<<qi4m<<G4endl;
335 #endif
336  while (tm<=fnm)
337  {
338  if(!G4QHadron(qt4m).DecayIn2(nu4m,qf4m))
339  {
340  G4cout<<"***G4QE::Constr:Muon error (1) 4M="<<mu4m<<". Fill as it is."<<G4endl;
341  G4QHadron* lepton = new G4QHadron(opHad); // Fill projMuon to Output
342  theQHadrons.push_back(lepton); // (delete equivalent)
343  return;
344  }
345 #ifdef mudebug
346  G4cout<<"G4QEnv::Const:i="<<qi4m<<",t="<<qt4m<<"->n="<<nu4m<<"+q="<<qf4m<<G4endl;
347 #endif
348  fn4m=fd4m+qf4m;
349  tm=fn4m.m(); // Real mass of the final nucleus
350 #ifdef mudebug
351  G4cout<<"--G4QEnv::Const:M="<<tm<<",GSM=="<<fnm<<G4endl;
352 #endif
353  }
354  fnN.Set4Momentum(fn4m);
355  // (mu,q->nu,q) reaction succeded and Neutrino can be pushed to Output
356  G4QHadron* neutrino = 0; // NeutrinoPrototype to be filled to Output
357 #ifdef mudebug
358  G4cout<<"G4QEnv::Const:fM="<<tm<<fn4m<<",GSM="<<fnm<<G4endl;
359 #endif
360  if(tm<fnm) // Final Nucleus is below the GS threshold
361  {
362  qf4m=G4LorentzVector(0.,0.,0.,fnm); // Final nucleus 4M for the final decay
363  qt4m=tg4m+mu4m;
364  if(!G4QHadron(qt4m).DecayIn2(nu4m,qf4m)) // Decay in Nucleus+nu_mu
365  {
366  G4cout<<"***G4QE::Constr:Muon error (2) 4M="<<mu4m<<". Fill as it is."<<G4endl;
367  G4QHadron* muon = new G4QHadron(opHad); // Fill projMuon to Output
368  theQHadrons.push_back(muon); // (delete equivalent)
369  return;
370  }
371  G4QHadron* fnuc = new G4QHadron(targQC,qf4m); // Fill Final Nucleus to Output
372  //theQHadrons.push_back(fnuc); // (delete equivalent)
373  EvaporateResidual(fnuc); // Try to evaporate residual (del. equiv.)
374  neutrino = new G4QHadron(nuPDG,nu4m);// Fill Neutrino to Output
375  theEnvironment.InitByPDG(90000000); // Create nuclear environment
376 #ifdef debug
377  G4cout<<"G4QEnv::Const:Fill neutrino (1) "<<nuPDG<<nu4m<<G4endl;
378 #endif
379  theQHadrons.push_back(neutrino); // (delete equivalent)
380  return;
381  }
382  neutrino = new G4QHadron(nuPDG,nu4m); // Fill Neutrino to Output
383 #ifdef debug
384  G4cout<<"G4QEnv::Const:Fill neutrino (2) "<<nuPDG<<nu4m<<G4endl;
385 #endif
386  theQHadrons.push_back(neutrino); // (delete equivalent)
387  if(tm<fnm+135.98) // FinalNucleus is below thePionThreshold(HE)
388  {
389  if(!fnN.SplitBaryon()) // Final Nucleus is below the splittingFragmentThreshold
390  {
391 #ifdef mudebug
392  G4cout<<"G4QEnv::Const: impossible to split nucleon after mu->nu"<<G4endl;
393 #endif
394  G4LorentzVector ga4m(0.,0.,0.,0.);
395  qf4m=G4LorentzVector(0.,0.,0.,fnm);// Final nucleus 4M for the final decay
396  if(!G4QHadron(fn4m).DecayIn2(ga4m,qf4m)) // Decay in Nucleus+photon
397  {
398  G4cout<<"***G4QE::Constr:LepCapError(3),M="<<fn4m.m()<<"<"<<fnm<<G4endl;
399  G4QHadron* resid = new G4QHadron(targQC,qt4m); // Fill ResidNucleus to Output
400  theQHadrons.push_back(resid); // (delete equivalent)
401  theEnvironment.InitByPDG(90000000);// Create nuclear environment
402  return;
403  }
404  G4QHadron* photon = new G4QHadron(22,ga4m); // Fill projPhoton to Output
405 #ifdef debug
406  G4cout<<"G4QEnv::Const:Fill photon "<<ga4m<<G4endl;
407 #endif
408  theQHadrons.push_back(photon); // (delete equivalent)
409  G4QHadron* fnuc = new G4QHadron(targQC,qf4m); // Fill Final Nucleus to Output
410 #ifdef debug
411  G4cout<<"G4QEnv::Const:Fill target "<<targQC<<qf4m<<" in any form"<<G4endl;
412 #endif
413  EvaporateResidual(fnuc); // Try to evaporate residual (del. equiv.)
414  theEnvironment.InitByPDG(90000000);// Create nuclear environment
415  return;
416  }
417  }
418  // At this poin it is possible to convert mu- to pi-
419  fn4m=qf4m-qi4m;
420  opHad->SetQPDG(pimQPDG); //Convert (mu-)u->d to (virt pi-)u->d capture
421  fake=false; // normal pi- for q-muon scattering
422  //fake=true; // fake pi- for q-muon scattering *****
423  //if(G4UniformRand()>.5) fake=false; // normal pi- for q-muon scattering *****
424  opHad->Set4Momentum(fn4m);
425  }
426  }
427  for(G4int ih=0; ih<nHadrons; ih++) // ==> The main LOOP over projQHadrons
428  {
429  G4QHadron* curHadr=projHadrons[ih]; // Pointer to current projectile Hadron
430  G4int hNFrag = curHadr->GetNFragments();// #0 means intermediate (skip)
431  G4LorentzVector ch4M=curHadr->Get4Momentum(); // 4-momenyum of the current projectile
432 #ifdef debug
433  G4cout<<"G4QE:C:"<<ih<<",F="<<hNFrag<<",0="<<projHadrons[0]->GetNFragments()<<G4endl;
434 #endif
435  if(!hNFrag&&ch4M.e()>0.) // => "Final hadron" case
436  {
437  G4int envPDG=theEnvironment.GetPDG();
438  if(envPDG==90000000||(theEnvironment.Get4Momentum().m2())<1.) // ==>"Vacuum"
439  {
440  G4int hPDG = curHadr->GetPDGCode();// A PDG Code of the projQHadron
441  //if(!hPDG||hPDG==10) // Check for the validity of the QHadron (@@ 10 OK?)
442  if(!hPDG) // Check for the validity of the QHadron
443  {
444  //G4cerr<<"--Warning--G4QEnvironment::Constructor: wrong PDG("<<ih<<")="<<hPDG
445  // <<", HQC="<<curHadr->GetQC()<<", HM="<<curHadr->GetMass()<<G4endl;
446  //throw G4QException("***G4QEnvironment::Constructor: theInputHadron is Chip");
447  }
448  else
449  {
450  G4int hQ = curHadr->GetQCode(); // One more check for valid of the QHadron
451  if(hQ<0)
452  {
453  //G4cerr<<"--Warning--G4QEnv::Constructor:Q<0, PDG=("<<ih<<")"<<hPDG<<G4endl;
454  //throw G4QException("***G4QEnvironment::Constructor:theInputHadron is bad");
455  }
456  else
457  {
458  G4QHadron* newHadr = new G4QHadron(curHadr);
459 #ifdef debug
460  G4cout<<"*G4QE::Const:H="<<newHadr->GetQC()<<newHadr->Get4Momentum()<<G4endl;
461 #endif
462  theQHadrons.push_back(newHadr); // Fill existing hadron (delete equivalent)
463 #ifdef debug
464  G4cout<<"G4QEnviron::Constructor: Fill h="<<hPDG<<ch4M<<G4endl;
465  for(unsigned ipo=0; ipo<theQHadrons.size(); ipo++) // LOOP just for printing
466  {
467  G4int hPDG = theQHadrons[ipo]->GetPDGCode();
468  G4LorentzVector h4Mom = theQHadrons[ipo]->Get4Momentum();
469  G4int hNFrag= theQHadrons[ipo]->GetNFragments();
470  G4QContent hQC = theQHadrons[ipo]->GetQC();
471  G4cout<<"h#"<<ipo<<": "<<hPDG<<hQC<<",4M="<<h4Mom<<",nFr="<<hNFrag<<G4endl;
472  }
473 #endif
474  } // End of Q-Code check
475  } // End of proper PDG for i-th Hadron
476  }
477  else // Nuclear Environment still exists
478  {
479  G4QContent hQC = curHadr->GetQC();
480 #ifdef debug
481  G4cout<<"G4QE::Const:CreateQuasm, 4M="<<ch4M<<",QC="<<hQC<<",E="<<envPDG<<",tC="
482  <<totCharge<<",tB="<<totBaryoN<<G4endl;
483 #endif
484  CreateQuasmon(hQC, ch4M, fake);
485  } // End of Existing Nuclear Environment case
486  } // End of final hadron case
487  } // End of the LOOP over input hadrons
488  } // End of nuclear target case (including neutron=90000001 & proton=90001000)
489  else // => "Unique hadron" case
490  {
491  // the nuclEnviron is already init'ed as vacuum + get the first hadron for interaction
492  G4QHadron* curHadr=projHadrons[0]; // Pointer to the firstProjecHadron (checked)
493  G4int hPDG = curHadr->GetPDGCode(); // A PDG Code of the projQHadron
494  if(!hPDG||hPDG==10) // Check for the validity of the QHadron
495  {
496  G4cout<<"---Warning---G4QEnvironment::Constructor:Vacuum,1st Hadron wrong PDG="<<hPDG
497  <<", HQC="<<curHadr->GetQC()<<", HM="<<curHadr->GetMass()<<G4endl;
498  //throw G4QException("***G4QEnvironment::Constructor: Fiest input Hadron is wrong");
499  }
500  else
501  {
502  G4int hQ = curHadr->GetQCode(); // One more check for valid of the QHadron
503  if(hQ<0)
504  {
505  G4cout<<"---Warning---G4QEnviron::Constructor:Vacuum,Q<0, 1st HPDG="<<hPDG<<G4endl;
506  //throw G4QException("***G4QEnvironment::Constructor:theFirstInputHadron's wrong");
507  }
508  else // Now we can get 4Mom & QC of incedent particle
509  {
510  G4LorentzVector h4Mom = curHadr->Get4Momentum();
511  G4QContent hQC = curHadr->GetQC();
512  if(!targPDG||targPDG==10) G4cout<<"G4QEnv::CreateQ; (1) PDG="<<targPDG<<G4endl;
513  G4QPDGCode tQPDG(targPDG);
514  G4int tQ = tQPDG.GetQCode();
515  if(tQ<0||targPDG==10)
516  {
517  G4cout<<"---Warning---G4QEnv::Constructor:TrgQC<0, Chipo?,PDG="<<targPDG<<G4endl;
518  //throw G4QException("***G4QEnvironment::Constructor: Target is wrong");
519  }
520  else // Now we can create a unique Quasmon
521  {
522  h4Mom+=G4LorentzVector(0.,0.,0.,tQPDG.GetMass()); //Projectile + TargetHadron
523  hQC+=tQPDG.GetQuarkContent();
524 #ifdef debug
525  G4cout<<"G4QEnv::Const:VacHadrTarg="<<h4Mom<<hQC<<",E="<<theEnvironment<<G4endl;
526 #endif
527  G4Quasmon* curQuasmon = new G4Quasmon(hQC, h4Mom);
528  theQuasmons.push_back(curQuasmon); // Insert Quasmon or hadron/gamma (del. eq.)
529  }
530  } // End of Q-Code check
531  } // End of proper PDG for i-th Hadron
532  if(nHadrons>1) for(G4int ih=0; ih<nHadrons; ih++) // fill other Hadrons to Output
533  {
534  G4QHadron* newHadr = new G4QHadron(curHadr);
535 #ifdef debug
536  G4cout<<"*G4QE::Const:#"<<ih<<","<<curHadr->GetQC()<<curHadr->Get4Momentum()<<G4endl;
537 #endif
538  theQHadrons.push_back(newHadr); // Fill existing hadron (delete equivalent)
539  }
540  } // End of Unique Hadron target treatment
541 #ifdef chdebug
542  G4int finCharge=theEnvironment.GetCharge();
543  G4int finBaryoN=theEnvironment.GetA();
544  G4int nHad=theQHadrons.size();
545  if(nHad) for(G4int ih=0; ih<nHad; ih++)
546  {
547  finCharge+=theQHadrons[ih]->GetCharge();
548  finBaryoN+=theQHadrons[ih]->GetBaryonNumber();
549  }
550  G4int nQuas=theQuasmons.size();
551  if(nQuas) for(G4int iq=0; iq<nQuas; iq++)
552  {
553  finCharge+=theQuasmons[iq]->GetCharge();
554  finBaryoN+=theQuasmons[iq]->GetBaryonNumber();
555  }
556  if(finCharge!=totCharge || finBaryoN!=totBaryoN)
557  {
558  G4cout<<"*::*G4QEnv::C:(0) tC="<<totCharge<<",C="<<finCharge<<",tB="<<totBaryoN
559  <<",B="<<finBaryoN<<",E="<<theEnvironment<<G4endl;
560  if(nHad) for(G4int h=0; h<nHad; h++)
561  {
562  G4QHadron* cH = theQHadrons[h];
563  G4cout<<"*:*G4QE::C:h#"<<h<<",QC="<<cH->GetQC()<<",PDG="<<cH->GetPDGCode()<<G4endl;
564  }
565  if(nQuas) for(G4int q=0; q<nQuas; q++)
566  {
567  G4Quasmon* cQ = theQuasmons[q];
568  G4cout<<"::G4QE::C:q#"<<q<<",C="<<cQ->GetCharge()<<",QuarkCon="<<cQ->GetQC()<<G4endl;
569  }
570  }
571 #endif
572 } // End of the G4QEnvironment constructor
573 
574 
576 {
577  // theQHadrons (Vector)
578  theQFScat = G4QFreeScattering::GetPointer();
579  G4int nQH = right.theQHadrons.size();
580  if(nQH) for(G4int ih=0; ih<nQH; ih++)
581  {
582  G4QHadron* curQH = new G4QHadron(right.theQHadrons[ih]);
583 #ifdef debug
584  G4cout<<"G4QE::CopyByVal:cH#"<<ih<<","<<curQH->GetQC()<<curQH->Get4Momentum()<<G4endl;
585 #endif
586  theQHadrons.push_back(curQH); // (delete equivalent)
587  }
588  // theProjectiles (Vector)
589  G4int nP = right.theProjectiles.size();
590  if(nP) for(G4int ip=0; ip<nP; ip++)
591  {
592  G4QHadron* curP = new G4QHadron(right.theProjectiles[ip]);
593  theProjectiles.push_back(curP); // (delete equivalent)
594  }
595  theTargetPDG = right.theTargetPDG;
596  theWorld = right.theWorld;
597  nBarClust = right.nBarClust;
598  f2all = right.f2all;
599  tot4Mom = right.tot4Mom;
600  totCharge = right.totCharge;
601  totBaryoN = right.totBaryoN;
602 
603  // theQuasmons (Vector)
604  G4int nQ = right.theQuasmons.size();
605  if(nQ) for(G4int iq=0; iq<nQ; iq++)
606  {
607  G4Quasmon* curQ = new G4Quasmon(right.theQuasmons[iq]);
608  theQuasmons.push_back(curQ); // (delete equivalent)
609  }
610 
611  // theQCandidates (Vector)
612  G4int nQC = right.theQCandidates.size();
613  if(nQC) for(G4int ic=0; ic<nQC; ic++)
614  {
615  G4QCandidate* curQC = new G4QCandidate(right.theQCandidates[ic]);
616  theQCandidates.push_back(curQC); // (delete equivalent)
617  }
618 
619  theEnvironment = right.theEnvironment;
620 }
621 
623 {
624  // theQHadrons (Vector)
625  theQFScat = G4QFreeScattering::GetPointer();
626  G4int nQH = right->theQHadrons.size();
627  if(nQH) for(G4int ih=0; ih<nQH; ih++)
628  {
629  G4QHadron* curQH = new G4QHadron(right->theQHadrons[ih]);
630 #ifdef debug
631  G4cout<<"G4QE::CopyByPtr:cH#"<<ih<<","<<curQH->GetQC()<<curQH->Get4Momentum()<<G4endl;
632 #endif
633  theQHadrons.push_back(curQH); // (delete equivalent)
634  }
635 
636  // theProjectiles (Vector)
637  G4int nP = right->theProjectiles.size();
638  if(nP) for(G4int ip=0; ip<nP; ip++)
639  {
640  G4QHadron* curP = new G4QHadron(right->theProjectiles[ip]);
641  theProjectiles.push_back(curP); // (delete equivalent)
642  }
643  theTargetPDG = right->theTargetPDG;
644  theWorld = right->theWorld;
645  nBarClust = right->nBarClust;
646  f2all = right->f2all;
647  tot4Mom = right->tot4Mom;
648  totCharge = right->totCharge;
649  totBaryoN = right->totBaryoN;
650 
651  // theQuasmons (Vector)
652  G4int nQ = right->theQuasmons.size();
653  if(nQ) for(G4int iq=0; iq<nQ; iq++)
654  {
655  G4Quasmon* curQ = new G4Quasmon(right->theQuasmons[iq]);
656  theQuasmons.push_back(curQ); // (delete equivalent)
657  }
658 
659  // theQCandidates (Vector)
660  G4int nQC = right->theQCandidates.size();
661  if(nQC) for(G4int ic=0; ic<nQC; ic++)
662  {
663  G4QCandidate* curQC = new G4QCandidate(right->theQCandidates[ic]);
664  theQCandidates.push_back(curQC); // (delete equivalent)
665  }
666 
667  theEnvironment = right->theEnvironment;
668 }
669 
671 {
672 #ifdef debug
673  G4cout<<"~G4QEnvironment: before theQCandidates nC="<<theQCandidates.size()<<G4endl;
674 #endif
675  for_each(theQCandidates.begin(), theQCandidates.end(), DeleteQCandidate());
676 #ifdef debug
677  G4cout<<"~G4QEnvironment: before theQuasmons nQ="<<theQuasmons.size()<<G4endl;
678 #endif
679  for_each(theQuasmons.begin(), theQuasmons.end(), DeleteQuasmon());
680 #ifdef debug
681  G4cout<<"~G4QEnvironment: before theQHadrons nH="<<theQHadrons.size()<<G4endl;
682 #endif
683  for_each(theQHadrons.begin(), theQHadrons.end(), DeleteQHadron());
684 #ifdef debug
685  G4cout<<"~G4QEnvironment: before theProjectiles nP="<<theProjectiles.size()<<G4endl;
686 #endif
687  for_each(theProjectiles.begin(), theProjectiles.end(), DeleteQHadron());
688 #ifdef debug
689  G4cout<<"~G4QEnvironment: === DONE ==="<<G4endl;
690 #endif
691 }
692 
693 G4double G4QEnvironment::SolidAngle=0.8; // Part of Solid Angle to capture (@@A-dep.)
694 G4bool G4QEnvironment::EnergyFlux=false; // Flag for Energy Flux use (not MultyQuasmon)
695 G4bool G4QEnvironment::WeakDecays=false; // Flag for WeakDecays(notUsed hadwaredClosed)
696 G4bool G4QEnvironment::ElMaDecays=true; // Flag for Electromagnetic decays of hadrons
697 G4double G4QEnvironment::PiPrThresh=141.4; // Pion Production Threshold for gammas
698 G4double G4QEnvironment::M2ShiftVir=20000.; // Shift for M2=-Q2=m_pi^2 of the virtualGamma
699 G4double G4QEnvironment::DiNuclMass=1880.; // DoubleNucleon Mass for VirtualNormalization
700 
701 // Open decay of particles with possible electromagnetic channels of decay (gammas)
703 
704 // Close decay of particles with possible electromagnetic channels of decay (gammas)
706 
707 // Fill the private static parameters
709  G4double mpisq, G4double dinum)
710 {
711  EnergyFlux=efFlag; // Flag for Energy Flux use instead of Multy Quasmon
712  SolidAngle=solAn; // Part of Solid Angle to capture secondaries (@@A-dep)
713  PiPrThresh=piThresh; // Pion Production Threshold for gammas
714  M2ShiftVir=mpisq; // Shift for M2=-Q2=m_pi^2 of the virtual gamma
715  DiNuclMass=dinum; // Double Nucleon Mass for virtual normalization
716 }
717 
719 {
720  if(this != &right) // Beware of self assignment
721  {
722  // theQHadrons (Vector)
723  theQFScat = G4QFreeScattering::GetPointer();
724  G4int iQH = theQHadrons.size();
725  if(iQH) for(G4int ii=0; ii<iQH; ii++) delete theQHadrons[ii];
726  theQHadrons.clear();
727  G4int nQH = right.theQHadrons.size();
728  if(nQH) for(G4int ih=0; ih<nQH; ih++)
729  {
730  G4QHadron* curQH = new G4QHadron(right.theQHadrons[ih]);
731 #ifdef debug
732  G4cout<<"G4QE::Operator=:c#"<<ih<<","<<curQH->GetQC()<<curQH->Get4Momentum()<<G4endl;
733 #endif
734  theQHadrons.push_back(curQH); // (delete equivalent)
735  }
736 
737  theWorld = right.theWorld;
738  nBarClust = right.nBarClust;
739  f2all = right.f2all;
740 
741  // theQuasmons (Vector)
742  G4int iQ = theQuasmons.size();
743  if(iQ) for(G4int jq=0; jq<iQ; jq++) delete theQuasmons[jq];
744  theQuasmons.clear();
745  G4int nQ = right.theQuasmons.size();
746  if(nQ) for(G4int iq=0; iq<nQ; iq++)
747  {
748  G4Quasmon* curQ = new G4Quasmon(right.theQuasmons[iq]);
749  theQuasmons.push_back(curQ); // (delete equivalent)
750  }
751 
752  // theQCandidates (Vector)
753  G4int iQC = theQCandidates.size();
754  if(iQC) for(G4int jc=0; jc<iQC; jc++) delete theQCandidates[jc];
755  theQCandidates.clear();
756  G4int nQC = right.theQCandidates.size();
757  if(nQC) for(G4int ic=0; ic<nQC; ic++)
758  {
759  G4QCandidate* curQC = new G4QCandidate(right.theQCandidates[ic]);
760  theQCandidates.push_back(curQC); // (delete equivalent)
761  }
762 
763  theEnvironment = right.theEnvironment;
764  }
765  return *this;
766 }
767 
768 // Member function for Quasmon Creation & Environment nucleus modification
769 void G4QEnvironment::CreateQuasmon(const G4QContent& projQC, const G4LorentzVector& pro4M,
770  G4bool fake)
771 {
772  //static const G4double third=1./3.;
773  static const G4double mNeut= G4QPDGCode(2112).GetMass();
774  static const G4double mNeu2 = mNeut*mNeut;
775  static const G4double mProt= G4QPDGCode(2212).GetMass();
776  static const G4double mPro2 = mProt*mProt;
777  //static const G4double mLamb= G4QPDGCode(3122).GetMass();
778  static const G4double mPi = G4QPDGCode(211).GetMass();
779  static const G4double mPi2 = mPi*mPi;
780  //static const G4double mMu = G4QPDGCode(13).GetMass();
781  //static const G4double mMu2 = mMu*mMu;
782  //static const G4QContent gamQC(0,0,0,0,0,0);
783  //static const G4QContent pimQC(1,0,0,0,1,0);
784  //static const G4QContent pipQC(0,1,0,1,0,0);
785  static const G4QContent neutQC(2,1,0,0,0,0);
786  static const G4QContent protQC(1,2,0,0,0,0);
787  static const G4QContent deutQC(3,3,0,0,0,0);
788  static const G4QContent lambQC(1,1,1,0,0,0);
789  static const G4QNucleus vacuum(90000000);
790  G4QContent valQ(0,0,0,0,0,0); // Prototype of the Quasmon's Quark Content
791  G4LorentzVector q4Mom(0.,0.,0.,0.); // Prototype of the Quasmon's 4-momentum
792  nBarClust = 1; // By default only quasi-free nucleons
793  G4LorentzVector proj4M=pro4M; // Fake equivalence to avoid & const
794  G4double projE=proj4M.e(); // energy of the projectile
795  G4int projPDG=projQC.GetSPDGCode(); // Minimum hadron for the projectile QC
796  if(projE<0.)
797  {
798  G4cout<<"*Warning*G4QEnvironment::CreateQuasmon:Epr="<<projE<<"<0,QC="<<projQC<<G4endl;
799  projE=0.;
800  proj4M=G4LorentzVector(0.,0.,0.,0.);
801  }
802  G4double projM2=proj4M.m2(); // projectile's squared mass (print & v.gamma)
803  G4bool Pr1 = theProjectiles.size() == 1; // A#ofHadronsInTheInputVector = 1 condition
804  if(Pr1 && std::fabs(G4QPDGCode(projPDG).GetMass2()-projM2) > .1 ) Pr1=false; // MassShell
805  G4int targPDG=theEnvironment.GetPDG();// PDG Code of the target nucleus
806  if(targPDG>80000000&&targPDG!=90000000&&(theEnvironment.Get4Momentum().m2())>1000.)//Nucl
807  {
808  G4double tgMass=theEnvironment.GetMass();// mass of the target (QEnvironment) nucleus
809 #ifdef debug
810  G4cout<<"G4QEnvironment::CreateQ:Interact "<<projQC<<proj4M<<"(m2="<<projM2<<") + A="
811  <<targPDG<<",M="<<tgMass<<",tC="<<totCharge<<",tB="<<totBaryoN<<G4endl;
812 #endif
813  G4int envZ=theEnvironment.GetZ(); // A#of protons in the target nucleus
814  G4int envN=theEnvironment.GetN(); // A#of neutrons in the target nucleus
815  G4int envS=theEnvironment.GetS(); // A#of lambdas in the target nucleus
816  G4int envBN=envZ+envN+envS; // A baryon number of the target nucleus
817  G4int nP =theWorld->GetQPEntries(); // A#of initialized particles in CHIPS World
818  //G4int nCl =nP-90; // A#of initialized clusters in CHIPS World
819  G4int nCl =nP-53; // @@ A#ofClusters in CHIPSWorld (53=nQHM in G4QPDGCode.hh)
820  if(nCl<0) G4cout<<"---Warning---G4QEnv::CreaQ:nP="<<nP<<" for Targ="<<targPDG<<G4endl;
821  if (nCl<3) nBarClust=1; // Fix the maximum Baryon Number for clusters
822  else if(nCl<9) nBarClust=2;
823  else
824  {
825  G4int v=nCl-9;
826  G4int d=v/15;
827  G4int r=v%15;
828  if(r<7) nBarClust=3+d+d;
829  else nBarClust=4+d+d;
830  }
831 #ifdef debug
832  G4cout<<"G4QE::CrQ:TNuc:Z="<<envZ<<",N="<<envN<<",nC="<<nBarClust<<",tC="
833  <<totCharge<<", tB="<<totBaryoN<<G4endl;
834 #endif
835  G4bool pbpt=projE<PiPrThresh+(M2ShiftVir+projM2)/DiNuclMass;// PhotonBelowPionThreshold
836  G4bool din=false;
837  G4bool piF=false;
838  G4bool gaF=false;
839  if((projM2-mPi2<.00001||projE-mPi<2.7)&&projPDG==-211&&!fake) piF=true;//PiAtRestCase
840  //if(pbpt&&projPDG==22) din=true; // InCaseOf GammaBelowPiThresh needs DiNucl (?)
841  if(pbpt&&projPDG==22) gaF=true; // InCaseOf GammaBelowPiThresh needs DiNucl (?)
842  theEnvironment.SetMaxClust(nBarClust);
843  nBarClust=theEnvironment.UpdateClusters(din); // Cluster Probabilities upto maxClust
844 #ifdef debug
845  G4cout<<"G4QEnv::CreateQ: Nucleus("<<targPDG<<") is created ("<<nBarClust<<" clast's)";
846  for(G4int ic=0;ic<nBarClust;ic++)
847  G4cout<<" #"<<ic<<"("<<theEnvironment.GetProbability(ic)<<")";
848  G4cout<<G4endl;
849 #endif
850  theEnvironment.PrepareCandidates(theQCandidates,piF,gaF,proj4M);//Calc.Clust's probab's
851  G4QNucleus memEnviron=theEnvironment;
852 #ifdef debug
853  G4cout<<"G4QE::CrQ:ClusterProbabCalculation tC="<<totCharge<<",tB="<<totBaryoN<<G4endl;
854 #endif
855 
856  G4bool efFlag = false; // EnergyFlowFlag=FALSE (@@=DEFOLT=@@ make par)
857  // ***** Change if necessary to compare Energy Flux & Multy Quasmon ******
858 
859  G4int efCounter=0; // Counter of Energy Flux particles
860  G4QContent EnFlQC(0,0,0,0,0,0); // Quark Content of Energy Flux
861  G4LorentzVector ef4Mom(0.,0.,0.,0.); // Summed 4-momentum of Energy Flux
862  G4double proj3M=proj4M.rho();
863  // --- P-antibar --- N-antibar -- LAMBDA-antibar - SIGMA-antibar - SIGMA0-antibar
864  if((projPDG==-2212||projPDG==-2112||projPDG==-3122||projPDG==-3112||projPDG==-3212||
865  projPDG==-3222) && envBN>1 && proj3M<10.) // OnlyForAtRestReactions(@@to Interface)
866  // ^ SIGMA+ antibar
867  {
868  // @@ Annihilation on one baryon is implemented (no annihilation on clusters! @@?) @@
869 #ifdef debug
870  G4cout<<"G4QE::CreQ:Annihilation on a perif. nucleon, Z="<<envZ<<",N="<<envN<<G4endl;
871 #endif
872  G4double zpn=envZ+envN; // a#of nucleons in the nucleus
873  G4double rnd=zpn*G4UniformRand(); // Random number to find a nucleon
874  //G4double envD=.1*envZ*envN/zpn; // a#of possible quasifree deuterons (@@Param.)
875  //G4double rnd=(zpn+envD)*G4UniformRand(); // Random number to find a baryon
876  //G4double rnd=(zpn+envS)*G4UniformRand(); // Random number to find a baryon
877  G4int targNPDG = 90000000; // Nucl-Prototype of PDG of Periferal Target
878  G4QContent targQC(0,0,0,0,0,0); // Quark Content of Periferal Target
879  if (rnd<envN) // Neutron is a Periferal Target
880  {
881  targNPDG = 90000001;
882  targQC = neutQC;
883  }
884  else
885  // if(rnd<=zpn) // Proton is a Periferal Target
886  {
887  targNPDG = 90001000;
888  targQC = protQC;
889  }
890  //else // Deuteron as a Periferal Target
891  //{
892  // targNPDG = 90001001;
893  // targQC = deutQC;
894  //}
895  //else // Lambda is a Periferal Target (?)
896  //{
897  // targNPDG = 91000000;
898  // targQC = lambQC;
899  //}
900  theEnvironment.Reduce(targNPDG); // Subtract periferal baryon from Nucleus
901  G4double resMass=theEnvironment.GetGSMass(); // Nuclear mass after baryon subtraction
902  G4double barMass=tgMass-resMass; // Mass of the bound baryon for annihilation
903  tgMass=resMass; // New mass of theEnvironment
904  q4Mom=G4LorentzVector(0,0,0,barMass)+proj4M;// 4-mom of the intermediate B-Bbar Quasm
905  valQ=targQC+projQC; // Quark Content of intermediate B-Bbar Quasmon
906 #ifdef debug
907  G4cout<<"G4QEnviron::CQ:"<<targNPDG<<" + Env="<<theEnvironment<<",QC="<<valQ<<G4endl;
908 #endif
909  // Remember the Quasmon parameters, defined by user for recovery after annihilation
910  G4Quasmon fakeQ; // fake Quasmon to get and restore parameters
911  G4double QTemper=fakeQ.GetTemper(); // Temperature defined by user for Quasmons
912  G4double QSOverU=fakeQ.GetSOverU(); // S/U defined by user for Quasmons
913  G4double QEtaSup=fakeQ.GetEtaSup(); // Eta Suppresion defined by user in Quasmons
914  G4Quasmon::SetParameters(180.,QSOverU,.3); // Parameters for N-barN Annihilation
915  G4Quasmon::CloseElectromagneticDecays(); // Parameters for N-barN Annihilation
916  G4Quasmon* pan = new G4Quasmon(valQ,q4Mom);// N-Nbar Quasm creation (del.at 9th line)
917  G4QNucleus vE(90000000); // Annihilation in vacuum (in NuclMatter?)
918 #ifdef debug
919  G4cout<<"G4QE::CreQ: before Fragment, vE="<<vE<<",vP="<<vE.GetProbability()<<",QQC="
920  <<valQ<<",Q4M="<<q4Mom<<G4endl;
921 #endif
922  G4QHadronVector* output=pan->Fragment(vE,1);//Output of inVacAnnihilation*DESTROY*<-+
923 #ifdef debug
924  G4cout<<"G4QE::CrQ:NucleonAntinucleonAnnihilation's done,N="<<output->size()<<G4endl;
925 #endif
926  G4Quasmon::OpenElectromagneticDecays(); // Parameter for multihadronFragmentatation^
927 #ifdef debug
928  G4cout<<"G4QE::CrQ:>>AnnihilationIsDone,C="<<totCharge<<",B="<<totBaryoN<<G4endl;// ^
929 #endif
930  delete pan; // The N-NbarQuasmon is deleted A.S.A.P. ^
931  G4QHadronVector input; // Input for MultyQuasmon **DESTROY**<---+ ^
932  //G4int trgPDG = theEnvironment.GetPDG();// New PDG Code for the Residual Nucleus ^ ^
933  G4LorentzVector trg4M(0.,0.,0.,resMass); // New 4-momentum for the ResidualNucleus^ ^
934  G4int tNH = output->size(); // For the selection LOOP ^ ^
935  G4ThreeVector dir = G4RandomDirection(); // For the selection in LOOP (@@ at rest)^ ^
936  //G4double ra=std::pow(G4double(totBaryoN),third); // ^ ^
937  G4double ra=G4QThd(totBaryoN); // ^ ^
938 #ifdef debug
939  G4cout<<"G4QE::CQ:N="<<tNH<<",T="<<totCharge<<","<<totBaryoN<<",A="<<ra<<G4endl;//^ ^
940 #endif
941  for (G4int ind=0; ind<tNH; ind++) // Loop over annihilation QHadrons ^ ^
942  {
943  //G4QHadron* curHadr = output->operator[](ind); // Pointer to theCurrentHadron ^ ^
944  G4QHadron* curHadr = (*output)[ind]; // Pointer to theCurrentHadron ^ ^
945  G4int shDFL= curHadr->GetNFragments();// A#of decFragments for proj. ^ ^
946  G4LorentzVector sh4m = curHadr->Get4Momentum(); // 4Mom for the projectile ^ ^
947  G4ThreeVector shDIR= sh4m.vect().unit(); // unitVector in projMomDirect ^ ^
948  G4int shPDG= curHadr->GetPDGCode(); // PDG Code of the projectile ^ ^
949  G4int shCHG= curHadr->GetCharge(); // Charge of the projectile ^ ^
950  G4double shMOM= sh4m.rho(); // Momentum of the projectile ^ ^
951 #ifdef debug
952  G4cout<<"G4QE::CrQ:"<<ind<<","<<shDFL<<",PDG="<<shPDG<<",4M="<<sh4m<<G4endl; // ^ ^
953 #endif
954  G4double solAnCut=SolidAngle; // Proto ChargeDependantSolAngle^ ^
955  if(fabs(ra)<.1) solAnCut=3.; // No Nucleus -> no absorption ^ ^
956  else if(shMOM<.1) // Meson at rest ^ ^
957  { // ^ ^
958  if(shCHG<=0.) solAnCut=-3.; // Always totally absorbed ^ ^
959  else solAnCut= 3.; // Positive are repelled from A ^ ^
960  } // ^ ^
961  else solAnCut+=1000*shCHG/shMOM/ra; // ChargeDepSolAngle(Normal) ^ ^
962  //G4double solAnCut=SolidAngle+20*shCHG*sqrt(1.*envZ)/shMOM;//ChargeDepSolAngle ^ ^
963 #ifdef debug
964  G4cout<<"G4QE::CrQ: PDG="<<shPDG<<", p="<<shMOM<<", r="<<ra<<G4endl; // ^ ^
965 #endif
966  if(!shDFL) // Final(notDecayed) hadrons ^ ^
967  {
968 #ifdef debug
969  G4cout<<"G4QE::CQ:>H="<<shPDG<<":"<<dir.dot(shDIR)<<">"<<solAnCut<<G4endl; // ^ ^
970 #endif
971  //if((dir.dot(shDIR)>solAnCut||shMOM<120.) && abs(shPDG)>99) // Absorb mesons ^ ^
972  if(dir.dot(shDIR)>solAnCut && abs(shPDG)>99) // Absorb mesons ^ ^
973  {
974 #ifdef debug
975  G4cout<<"G4QE::CQ:>H="<<shPDG<<":"<<dir.dot(shDIR)<<">"<<solAnCut<<", P="// ^ ^
976  << shMOM <<" < 120" << G4endl; // ^ ^
977 #endif
978  //if (efFlag)
979  //{ // => Case of "Energy Flux approach" *** is temporary closed *** ^ ^
980  // G4QContent shQC = curHadr->GetQC(); // ^ ^
981  // // QuarkContent of the Current Hadron ^ ^
982  // ef4Mom+=sh4m; // ^ ^
983  // EnFlQC+=shQC; // ^ ^
984  // efCounter++; // ^ ^
985 #ifdef debug
986  // G4int hPDG=curHadr->GetPDGCode(); // Only for gebug printing ^ ^
987  // G4LorentzVector h4M = curHadr->Get4Momentum(); // For debug printing ^ ^
988  // G4cout<<"G4QE::CrQ:#"<<efCounter<<",PDG="<<hPDG<<",h4M="<<h4M<<G4endl;//^ ^
989 #endif
990  //} // ^ ^
991  // else //=>"MultyQuasFragmentation"(!efFlag)^ ^
992  {
993  G4QHadron* mqHadron = new G4QHadron(curHadr);
994  input.push_back(mqHadron); // Fill hadron-copy (del equiv)
995 #ifdef debug
996  G4int hPDG=curHadr->GetPDGCode(); // Only for debug printing ^ ^
997  G4LorentzVector h4M = curHadr->Get4Momentum(); // Only for gebug printing ^ ^
998  G4cout<<"G4QE::CrQ:Absorb#"<<ind<<", PDG="<<hPDG<<", h4M="<<h4M<<G4endl;//^ ^
999 #endif
1000  } // ^ ^
1001  } // ^ ^
1002  else // DirectFilling of the output vector^ ^
1003  { // ^ ^
1004 #ifdef debug
1005  G4int hPDG=curHadr->GetPDGCode(); // Only for gebug printing ^ ^
1006  G4LorentzVector h4M = curHadr->Get4Momentum(); // Only for gebug printing ^ ^
1007  G4cout<<"G4QE::CrQ: Fill OUT #"<<ind<<",PDG="<<hPDG<<",h4M="<<h4M<<G4endl;//^ ^
1008 #endif
1009  // Just fill a hadron to the output stack (Make EM decays elsewhere) ^ ^
1010  G4QHadron* curHadron = new G4QHadron(curHadr); // ^ ^
1011  theQHadrons.push_back(curHadron); // TheQHadrs are filled as new Hadrs ^ ^
1012  }
1013  } // End of the IF over projectiles ^ ^
1014  } // End of LOOP over "output" of annihilation ^ ^
1015  for_each(output->begin(), output->end(), DeleteQHadron()); //DESTRUCT output>-^-^
1016  output->clear(); // ^ ^
1017  delete output; // ----------------------------------^-*
1018  if(!efFlag) // =>NotEnergyFlux=MultyQuasmon Case ^
1019  {
1020  G4int noh = theQHadrons.size(); // a#oh hadrons in Output UpToNow ^
1021  if(noh) for(G4int kh=0; kh<noh; kh++) // One can escape it but... ^
1022  { // ^
1023 #ifdef debug
1024  G4cout<<"G4QE::CreateQ:H#"<<kh<<", QC="<<theQHadrons[kh]->GetQC() // ^
1025  <<", 4M="<<theQHadrons[kh]->Get4Momentum()<<G4endl; // ^
1026 #endif
1027  G4QHadronVector* tmpQHadVec=G4Quasmon().DecayQHadron(theQHadrons[kh]);//d.e<^ ^
1028  G4int tmpS=tmpQHadVec->size(); // ^ ^
1029  intQHadrons.resize(tmpS+intQHadrons.size()); // Resize theQHadrons length ^ ^
1030  copy(tmpQHadVec->begin(), tmpQHadVec->end(), intQHadrons.end()-tmpS); // ^ ^
1031  tmpQHadVec->clear(); // ^ ^
1032  delete tmpQHadVec; // who calls DecayQHadron must clear & delete ^ ^
1033  } // ^ ^
1034  theQHadrons.clear(); // deletedWhenDecayed // Now theQHadrons is EmptyVector->^ ^
1035 #ifdef debug
1036  G4int nInH=intQHadrons.size(); // Resulting #of hadrons after decay ^
1037  G4cout<<"G4QE::CrQ:nH="<<nInH<<",C="<<totCharge<<",B="<<totBaryoN<<G4endl;// ^
1038 #endif
1039  if(!(input.size())) // *RETURN* Without Quasmon creation-^
1040  { // ^
1041 #ifdef debug
1042  G4cout<<"*G4QEnv::CrQ:AnnihStack tC="<<totCharge<<",tB="<<totBaryoN<<G4endl;//^
1043 #endif
1044  return; // Do not clear and delete objects --^
1045  } // ^
1046 #ifdef debug
1047  G4cout<<"G4QE::CrQ:fakeQ, restPars tC="<<totCharge<<",tB="<<totBaryoN<<G4endl;//^
1048 #endif
1049  G4Quasmon::SetParameters(QTemper,QSOverU,QEtaSup);//RecoverQParam's after anihil^
1050  G4Quasmon::OpenElectromagneticDecays(); // Parameter for multihadron fragmentat.^
1051  // From this point the new temporary environment is created (multiQuasmon) ^
1052  G4QEnvironment* muq = new G4QEnvironment(input,theEnvironment.GetPDG());//<--+ ^
1053 #ifdef debug
1054  G4cout<<"G4QE::CrQ:befCl&Dest tC="<<totCharge<<", tB="<<totBaryoN<<G4endl; //^ ^
1055 #endif
1056  for_each(input.begin(), input.end(), DeleteQHadron()); //DESTROING inp >-^--^
1057  input.clear(); // =Clearing=>---------->---------^==+
1058  theEnvironment = muq->GetEnvironment(); // RestoreResidEnv after interact.^
1059  G4QHadronVector* outH = muq->GetQHadrons();// Copy of QHadrons *DESTROY* <---^-<--+
1060  G4QuasmonVector* outQ = muq->GetQuasmons();// Copy of Quasmons *DESTROY* <---^--+ ^
1061  delete muq; //----->----------->--------------^ ^ ^
1062  noh = outH->size(); // a#of Not Interacting(Q) Hadrons ^ ^
1063 #ifdef debug
1064  G4cout<<"G4QEnv::CreateQ:*** #ofNotInterQH="<<noh<<" is found ***"<<G4endl; // ^ ^
1065 #endif
1066  if(noh) for(G4int nh=0; nh<noh; nh++) // One can escape it but... ^ ^
1067  { // ^ ^
1068 #ifdef debug
1069  G4cout<<"G4QE::CreateQ: NotIntQH#"<<nh<<", QC="<<(*outH)[nh]->GetQC() // ^ ^
1070  <<", 4M="<<(*outH)[nh]->Get4Momentum()<<G4endl; // ^ ^
1071 #endif
1072  G4QHadronVector* tmpQHadVec=G4Quasmon().DecayQHadron((*outH)[nh]);//del.eq<-+ ^ ^
1073  G4int tmpS=tmpQHadVec->size(); // ^ ^ ^
1074  intQHadrons.resize(tmpS+intQHadrons.size()); // Resize theQHadrons length ^ ^ ^
1075  copy(tmpQHadVec->begin(), tmpQHadVec->end(), intQHadrons.end()-tmpS); // ^ ^ ^
1076  tmpQHadVec->clear(); // ^ ^ ^
1077  delete tmpQHadVec; // who calls DecayQHadron must clear & delete->+ ^ ^
1078  } // ^ ^
1079  outH->clear(); // ^ ^
1080  delete outH; // >---->---->---->---->---->---->---^-+
1081  G4int nMQ = outQ->size(); // A#ofQuasmons in MultyQuasmonOutput^
1082 #ifdef debug
1083  G4LorentzVector eLorV=theEnvironment.Get4Momentum(); // ^
1084  G4cout<<"G4QE::CrQ:nMQ="<<nMQ<<",tC="<<totCharge<<", tB="<<totBaryoN<<G4endl;// ^
1085  G4cout<<"G4QE::CrQ:Env4M="<<eLorV<<G4endl; // ^
1086  G4LorentzVector contr4M=eLorV; // ^
1087 #endif
1088  if(nMQ) for(G4int mh=0; mh<nMQ; mh++) // Can escape CreationDistruct but...^
1089  { // ^
1090  G4Quasmon* curQ = new G4Quasmon((*outQ)[mh]);// Copy to destroy TMP(?) ^
1091 #ifdef debug
1092  G4LorentzVector qLorV=curQ->Get4Momentum(); // ^
1093  G4cout<<"G4QE::CrQ:Q#"<<mh<<",4M="<<qLorV<<curQ->GetQC()<<G4endl; // ^
1094  contr4M+=qLorV; // ^
1095 #endif
1096  theQuasmons.push_back(curQ); // Fill QuasmonCopies in theQuasmons ^
1097  } // ^
1098  for_each(outQ->begin(), outQ->end(), DeleteQuasmon()); // >-------------------->+
1099  outQ->clear(); // ^
1100  delete outQ; // >------------>------------------->+
1101 #ifdef debug
1102  G4int nsHadr = theQHadrons.size(); // Update the value of OUTPUT entries
1103  G4cout<<"G4QEnvironment::CreateQ: before return nH="<<nsHadr<<G4endl;
1104  if(nsHadr) for(G4int jso=0; jso<nsHadr; jso++)// LOOP over output hadrons
1105  {
1106  G4int hsNF = theQHadrons[jso]->GetNFragments(); // A#of secondary fragments
1107  if(!hsNF) // Add only final hadrons
1108  {
1109  G4LorentzVector hLorV=theQHadrons[jso]->Get4Momentum();
1110  G4int hPDGC=theQHadrons[jso]->GetPDGCode();
1111  G4cout<<"G4QE::CrQ: H#"<<jso<<",4M="<<hLorV<<hPDGC<<G4endl;
1112  contr4M+=hLorV;
1113  }
1114  else
1115  G4cout<<"G4Q::CrQ:"<<jso<<"NF=0,4M="<<theQHadrons[jso]->Get4Momentum()<<G4endl;
1116  }
1117  G4cout<<"G4QEnvironment::CreateQ: before return tot4M="<<contr4M<<G4endl;
1118 #endif
1119  return; // *** RETURN ***
1120  }
1121  else // ==> Energy Flux case
1122  {
1123  if (!efCounter) return; // ***RETURN*** Without Quasmon creation
1124  }
1125  } // End of Hyperon annihilation case
1126  else EnFlQC=projQC; // For notAntiBar, don't use EnergyFlux
1127  G4double EnFlP=ef4Mom.rho(); // Mom. of EnergyFlow forClusterCreation
1128  PrepareInteractionProbabilities(EnFlQC,EnFlP); // InteractionProbabilities for clusters
1129  G4int nCandid = theQCandidates.size();
1130 #ifdef debug
1131  G4cout<<"G4QEnvironment::CrQ: InteractionProbabilities are done, nC="<<nCandid<<G4endl;
1132 #endif
1133  if(nCandid<=0)
1134  {
1135  // G4cout<< "---Warning---G4QEnv::CreaQ:nC=" <<nCandid<< ",E=" <<theEnvironment<<G4endl;
1136  // throw G4QException("G4QEnvironment::CreateQ: Can not select a cluster");
1138  ed << "Cannot select a cluster: nC=" << nCandid << ",E="
1139  << theEnvironment << G4endl;
1140  G4Exception("G4QEnvironment::CreateQuasmon()", "HAD_CHPS_0000",
1141  FatalException, ed);
1142  }
1143  G4double maxP = theQCandidates[nCandid-1]->GetIntegProbability();
1144  G4int i=0;
1145  G4QContent curQC; // Quark Content of the selected cluster
1146  if(nCandid==1||maxP==0.)
1147  {
1148 #ifdef debug
1149  G4cout<<"***G4QEnv::CrQ:MaxP=0||nCand=1: Use all Env., Env="<<theEnvironment<<G4endl;
1150 #endif
1151  curQC=theEnvironment.GetQCZNS();
1152  theEnvironment=vacuum;
1153  }
1154  else
1155  {
1156  G4double totP = maxP * G4UniformRand();
1157 #ifdef debug
1158  G4cout<<"G4QEnvironment::CrQ:nC="<<nCandid<<", maxP="<<maxP<<", totP="<<totP<<G4endl;
1159 #endif
1160  while(theQCandidates[i]->GetIntegProbability()<totP) i++;
1161  G4QCandidate* curCand = theQCandidates[i];// Pointer to selected cluster to interact
1162  curQC = curCand->GetQC(); // Get QuarkContent of the selected cluster
1163  G4QNucleus targClust(curQC.GetP(),curQC.GetN(),curQC.GetL());//Define Clust as a QNuc
1164  G4double clMass=targClust.GetGSMass(); // Mass of residual nuclear environment
1165 #ifdef cldebug
1166  G4cout<<"G4QEnv::CrQ:Cl#"<<i<<"(of "<<nCandid<<"),QC="<<curQC<<",M="<<clMass<<G4endl;
1167 #endif
1168  G4LorentzVector pq4M=proj4M+G4LorentzVector(0.,0.,0.,clMass);
1169  if(pq4M.m()>=clMass)
1170  {
1171 #ifdef debug
1172  G4cout<<"G4QEnv::CQ:#"<<i<<"("<<targClust<<curQC<<") Env="<<theEnvironment<<G4endl;
1173 #endif
1174  theEnvironment.Reduce(targClust.GetPDG());// Subtract selected cluster from Nucleus
1175  }
1176  else
1177  {
1178  G4double teMass=theEnvironment.GetGSMass(); //Mass of theResidualNuclearEnvironment
1179  G4LorentzVector te4M=proj4M+G4LorentzVector(0.,0.,0.,teMass);
1180  if(te4M.m()>=teMass)
1181  {
1182 #ifdef debug
1183  G4cout<<"***G4QEnv::CrQ: Deep virtual, use all Env,Env="<<theEnvironment<<G4endl;
1184 #endif
1185  curQC=theEnvironment.GetQCZNS();
1186  theEnvironment=vacuum;
1187  }
1188  else
1189  {
1190  G4QHadron* projH = new G4QHadron(projQC,proj4M);
1191  theQHadrons.push_back(projH);
1192  G4cout<<"---Warning---G4QE::CrQ:Fill Proj asItIs QC/4m="<<projQC<<proj4M<<G4endl;
1193  return;
1194  }
1195  }
1196  }
1197  G4double envMass=theEnvironment.GetGSMass(); // Mass of residual nuclear environment
1198  // @@ Pr1 condition (individual particle) can be taken out of brackets for all if's
1199  if(Pr1&&projPDG==22&&projE<PiPrThresh+(M2ShiftVir+projM2)/DiNuclMass) // ==> Gamma+q
1200  //if(2>3) //@@ TMP:PhotoAbsorbtion by q is closed
1201  {
1202  q4Mom=G4LorentzVector(0.,0.,0.,tgMass-envMass);// PhotoInteracts with BoundedCluster
1203  valQ=curQC;
1204 #ifdef debug
1205  G4cout<<"G4QE::CrQ:Q="<<q4Mom<<valQ<<"+vg="<<proj4M<<",Env="<<theEnvironment<<G4endl;
1206 #endif
1207  G4Quasmon* curQuasmon = new G4Quasmon(valQ, q4Mom, proj4M);//Interaction gam+q inside
1208  theQuasmons.push_back(curQuasmon); // Insert Quasmon without incid. gamma (del.eq.)
1209  }
1210  else if(Pr1&&(std::fabs(projM2-mPi2)<.00001 && projE-mPi<0.1) && projPDG==-211 &&!fake)
1211  //if(2>3) //@@ ***TMP*** PionAbsorbAtRest by q is closed
1212  {
1213  q4Mom=proj4M+G4LorentzVector(0.,0.,0.,tgMass-envMass);// PION + BoundCluster
1214  valQ=EnFlQC+curQC;
1215 #ifdef debug
1216  if(projE<mPi)G4cout<<"*VirtualPiM*G4QE::CrQ:Ener(pi-)="<<projE<<"<mPi="<<mPi<<G4endl;
1217  G4cout<<"G4QEnv::CrQ:Q="<<q4Mom<<valQ<<"+pi="<<proj4M<<",E="<<theEnvironment<<G4endl;
1218 #endif
1219  G4Quasmon* curQuasmon = new G4Quasmon(valQ, q4Mom, -proj4M);//Interact gam+q inside
1220  theQuasmons.push_back(curQuasmon); // Insert Quasmon without incid. gamma (del.eq.)
1221  }
1222  //else if(Pr1&&projPDG==2212&&G4UniformRand()<.6+.4*std::exp(-envMass/8192))// keepProj
1223  else if(2>3) // free flying projectile is closed
1224  {
1225  q4Mom=proj4M; // 4M: QUASMON=Projectile
1226  valQ=EnFlQC; // qc: QUASMON=Projectile
1227  theEnvironment=memEnviron;
1228 #ifdef debug
1229  G4cout<<"G4QEnv::CreQAll: Q="<<q4Mom<<valQ<<", QEnv="<<theEnvironment<<G4endl;
1230 #endif
1231  G4Quasmon* curQuasmon = new G4Quasmon(valQ, q4Mom);
1232  theQuasmons.push_back(curQuasmon); // Insert Quasmon (even hadron/gamma) (del.eq.)
1233  }
1234  else if(Pr1&&projPDG==2212&&G4UniformRand()>15./(proj4M.e()-mProt))//ExcitatedCluster
1235  //else if(2>3) // No excitation of a cluster by projScattering
1236  {
1237  G4double prM=mProt; // mass of the projectile (M) (for future gener.)
1238  G4double prM2=mPro2; // squared mass of the projectile (M^2)
1239  G4double scM=mProt; // mass of the scattered projectile (M')
1240  G4double scM2=mPro2; // squared mass of the scatteredProjectile (M'^2)
1241  G4QContent scQC=projQC; // QC of the scattered projectile
1242  G4QContent chQC(0,0,0,0,0,0); // Change of the Quasmon QC
1243  if(G4UniformRand()<.5*envN/envBN) // (u->u,d, d->d)? in future make it universal
1244  {
1245  scM=mNeut; // Charge exchange reaction
1246  scM2=mNeu2;
1247  scQC=neutQC;
1248  chQC=projQC-scQC; // Charge of the created Quasmon must be changed
1249  }
1250  G4double tnM=tgMass-envMass; // minimal mass of the target cluster (m)
1251  G4double tnM2=tnM*tnM; // squared mass of the target cluster (m^2)
1252  G4double dtnM=tnM+tnM; // doubled mass of the target cluster (2*m)
1253  G4double prE=proj4M.e(); // enrgy of the projectile (E)
1254  G4double mu2=tnM2+dtnM*(prE-scM); // max squared mass of the excited cluster (mu^2)
1255  //G4double mu=std::sqrt(mu2); // max mass of the excited cluster (mu)
1256  G4double B=.00001; // (parameter) slope of the diffraction cone
1257  G4double rmu2=0.; // Chosen sqMass of excitedClust (Prototype)
1258  G4double tmax=0.; // max -t for scattering (Prototype)
1259  G4double rt=0.; // Chosen -t (Prototype)
1260  G4double om=0.; // Energy of the excited cluster (Prototype)
1261  G4double ep=0.; // Energy of the scattered projectile (eps Proto)
1262  if (prE<prM)G4cout<<"-Warn-G4QEnv::CreQAll:(scat w ex)E="<<prE<<" < M="<<prM<<G4endl;
1263  G4double Pi=std::sqrt(prE*prE-prM2); // Proj momentum (P)
1264  G4double po=0.; // Scat momentum (p) (Prototype)
1265  G4double cost=2.; // cos(theta) for the scattered proj (Prototype)
1266  G4int cct=0; // Counter of cost attempts (@@ can be limited)
1267  while ( std::fabs(cost) > 1. )
1268  {
1269  cct++;
1270 #ifdef debug
1271  G4cout<<"-Warning-G4QEnv::CreQAll: c="<<cct<<" (scat w ex) cost="<<cost<<G4endl;
1272 #endif
1273  rmu2=tnM2*pow(mu2/tnM2,G4UniformRand()); // Chosen SqMass of excitedClust (MMA)
1274  tmax=mu2-rmu2; // max -t for scattering
1275  rt=-std::log(1.-G4UniformRand()*(1.-std::exp(-B*tmax)))/B; // Chosem -t
1276  om=(tnM2+rmu2+rt)/dtnM; // Energy of the excited cluster
1277  ep=prE+tnM-om; // Energy of the scattered projectile (epsilon)
1278 #ifdef debug
1279  G4cout<<"G4QEnv::CreQAll: m2="<<tnM2<<" < mu2="<<rmu2<<" < "<<mu2<<"=Max2"<<G4endl;
1280  G4cout<<"G4QEnv::CreQAll: -t="<<rt<<" < "<<tmax<<"=tmax"<<G4endl;
1281  G4cout<<"G4QEnv::CreQAl: om="<<om<<" > m="<<tnM<<", ep="<<ep<<" > M="<<prM<<G4endl;
1282 #endif
1283  if(ep<scM)G4cout<<"+Warn-G4QEnv::CreQAl:(scat w ex)Eo="<<prE<<" < M="<<prM<<G4endl;
1284  po=std::sqrt(ep*ep-scM2); // Scat momentum (p)
1285  cost=(prE*ep-0.5*(rt+prM2+scM2))/Pi/po; // cos(theta) for the scattered
1286  }
1287  G4double om2=om*om;
1288  if(om2<rmu2)G4cout<<"-Warn-G4QEnv::CreQA:(scat w ex)e2="<<om<<" < mu2="<<tnM<<G4endl;
1289 #ifdef debug
1290  G4cout<<"G4QEnv::CreQAll: ct="<<cost<<",pio="<<Pi*po<<",()="<<cost*Pi*po<<G4endl;
1291  G4double ps=std::sqrt(om2-rmu2); // Momentum of the excited cluster (p)
1292 #endif
1293  G4double pfc=po*cost; // Longitudinal projection of the scattered proj
1294  G4double pfs=po*std::sqrt(1.-cost*cost); // Transversal projection of scattered proj
1295  // ---- @@ From here can be a MF for QF nucleon extraction (if used by others)
1296  G4ThreeVector vdir = proj4M.vect(); // 3-Vector in the projectile direction
1297  G4ThreeVector vx(0.,0.,1.); // ProtoOrt in the direction of the projectile
1298  G4ThreeVector vy(0.,1.,0.); // First ProtoOrt orthogonal to the direction
1299  G4ThreeVector vz(1.,0.,0.); // Second ProtoOrt orthoganal to the direction
1300  if(vdir.mag2() > 0.) // the projectile isn't at rest
1301  {
1302  vx = vdir.unit(); // Ort in the direction of the projectile
1303  G4ThreeVector vv= vx.orthogonal();// Not normed orthogonal vector (!)
1304  vy = vv.unit(); // First ort orthogonal to the proj. direction
1305  vz = vx.cross(vy); // Second ort orthoganal to the proj. direction
1306  }
1307  // ---- @@ End of possible MF (Similar is in G4QCollision)
1308  G4double phi=twopi*G4UniformRand(); // Phi of the Fermi-Mom
1309  G4ThreeVector fp=pfc*vx+pfs*(std::sin(phi)*vy+std::cos(phi)*vz);
1310  G4LorentzVector s4M(fp,ep);
1311 #ifdef debug
1312  G4cout<<"G4QEnv::CreQA:ps="<<po<<"="<<fp.mag()<<",sM="<<prM<<"="<<s4M.m()<<G4endl;
1313  G4cout<<"G4QEnv::CreQA:Ee="<<prE*ep<<" =? "<<(prM2+rt/2-Pi*po*cost)<<G4endl;
1314 #endif
1315  if(std::fabs(s4M.m()-scM)>.001)G4cout<<"-W-G4QE::CQA:M="<<prM<<"#"<<s4M.m()<<G4endl;
1316  G4LorentzVector c4M=proj4M+G4LorentzVector(0.,0.,0.,tnM)-s4M;
1317 #ifdef debug
1318  G4cout<<"G4QEnv::CreQA: ec="<<om<<" = "<<c4M.e()<<", pc="<<ps<<" = "
1319  <<c4M.rho()<<", mc2="<<rmu2<<" = "<<c4M.m2()<<G4endl;
1320  G4cout<<"G4QEnv::CQA:ht="<<(tnM2+rmu2)/2-tnM*om<<"="<<prM2-prE*ep+Pi*po*cost<<G4endl;
1321 #endif
1322  if(std::fabs(c4M.m2()-rmu2)>.1)
1323  G4cout<<"-W-G4QE::CrQ:m2="<<rmu2<<"#"<<c4M.m2()<<",P="<<proj4M<<",M="<<tnM<<G4endl;
1324  G4QHadron* projH = new G4QHadron(scQC,s4M); // Create scattered Projectile Hadron
1325  theQHadrons.push_back(projH); // Fill it to the output vector
1326  G4Quasmon* curQuasmon = new G4Quasmon(curQC+chQC, c4M); // Q=ExcitedCluster
1327  theQuasmons.push_back(curQuasmon); // Insert Quasmon (even hadron/gamma) (del.eq.)
1328  }
1329  else
1330  {
1331  q4Mom=proj4M+G4LorentzVector(0.,0.,0.,tgMass-envMass); // Projectile + BoundCluster
1332  valQ=EnFlQC+curQC;
1333 #ifdef debug
1334  G4cout<<"G4QEnv::CreQAll: Q="<<q4Mom<<valQ<<", QEnv="<<theEnvironment<<G4endl;
1335 #endif
1336  G4Quasmon* curQuasmon = new G4Quasmon(valQ, q4Mom);
1337  theQuasmons.push_back(curQuasmon); // Insert Quasmon (even hadron/gamma) (del.eq.)
1338  }
1339  }
1340  else
1341  {
1342  G4cout<<"---Warning---G4QEnvironment::CreateQuasmon:Strange targPDG="<<targPDG<<G4endl;
1343  //throw G4QException("***G4QEnvironment::CreateQuasmon: Impossible target");
1344  }
1345 }
1346 
1347 // Calculate a probability to interact with clusters for the givven PDG of the projectile
1348 void G4QEnvironment::PrepareInteractionProbabilities(const G4QContent& projQC, G4double AP)
1349 {
1350  G4double sum = 0.; // Sum of probabilities of interaction
1351  G4double probab = 0.; // Interaction probability
1352  G4double denseB = 0.; // A#of*prob baryons in dense part
1353  G4double allB = 0.; // A#of*prob baryons in the nucleus
1354  G4int pPDG = projQC.GetSPDGCode(); // PDG code of the projectile particle
1355  if(2>3) {allB=AP; allB=pPDG;} // A trick to use not used AP(3M) & pPDG
1356  for (unsigned index=0; index<theQCandidates.size(); index++)
1357  {
1358  G4QCandidate* curCand=theQCandidates[index]; // Intermediate pointer
1359  G4int cPDG = curCand->GetPDGCode(); // PDG Code of the Candidate
1360  G4int cST = curCand->GetStrangeness(); // Strangeness of the candidate
1361  G4int cBN = curCand->GetBaryonNumber(); // Baryon Number of the candidate
1362  G4int cCH = curCand->GetCharge(); // Charge of the candidate
1363 #ifdef sdebug
1364  G4cout<<"G4QE::PIP:=---=> #"<<index<<", cPDG="<<cPDG<<",S="<<cST<<G4endl;
1365 #endif
1366  if(cPDG>80000000&&cPDG!=90000000&&!cST&&cCH>0&&cBN>0&&cCH<=cBN) // ===> Nuclear cluster
1367  {
1368  G4int zc = cCH; // "Z" of the cluster
1369  G4int nc = cBN-cCH; // "N" of the cluster
1370  G4double nOfCl=curCand->GetPreProbability(); // A number of clusters of the type
1371  G4double dOfCl=curCand->GetDenseProbability();// A number of clusters in dense region
1372 #ifdef sdebug
1373  G4cout<<"G4QE::PIP:Z="<<zc<<",N="<<nc<<",nC="<<nOfCl<<",dC="<<dOfCl<<G4endl;
1374 #endif
1375  if(cPDG==91000000||cPDG==90001000||cPDG==90000001)
1376  {
1377  allB+=nOfCl;
1378  denseB+=dOfCl;
1379  }
1380  G4QContent pQC=curCand->GetQC(); // Quark Content of the candidate
1382  G4QContent qQC=pQC+projQC; // Total Quark content of the Compound
1383  G4QPDGCode qQPDG(qQC);
1384  G4int qC = qQPDG.GetQCode();
1385  G4double d = abs(zc-nc);
1386  G4double fact=1./pow(2.,d);
1387  if (qC<-1) probab=0.;
1388  //else if(pPDG==-211&&AP<152.&&cBN<2) probab=0.; // PionCaptureByCluster
1389  //else if(pPDG==22&&AP<152. || pPDG>90000000)
1390  else if(pPDG==22 && AP<152.)
1391  {
1392  if(cBN<2) probab=nOfCl*cBN*fact; //Gamma Under Pi Threshold (QuarkCapture)
1393  else probab=0.;
1394  }
1395  else if(pPDG==2212)
1396  {
1397  //if(cBN<2)probab=nOfCl*cBN*fact; // Moving nucleons hits only nucleons
1398  //else probab=0.;
1399  probab=nOfCl*cBN*fact; // Moving nucleons hits composed clusters
1400  //probab=nOfCl*fact; // Moving nucleons hits compact clusters
1401  }
1403  //else if((pPDG==-211||pPDG==-13)&&AP<27.)probab=dOfCl*cBN*fact;//Pi/Mu-CaptureAtRest
1404  //else if(pPDG==-211&&AP<10.) probab=nOfCl*fact;// special PiCaptureAtRest
1405  //else if(pPDG==-211&&AP<10.) probab=nOfCl*cBN*(cBN-1)*fact;
1406  //else probab=nOfCl*fact;
1407  else probab=nOfCl*cBN*fact;
1408  //else probab=dOfCl*cBN*fact;
1409  //if(cBN>1) probab=0.; // Suppress clusters
1410  //if(cBN>2) probab=0.; // Suppress heavy clusters
1411 #ifdef sdebug
1412  G4int pPDG = projQC.GetSPDGCode(); // PDG code of the projectile particle
1413  G4int rPDG = qQC.GetSPDGCode();
1414  G4double baryn = qQC.GetBaryonNumber();
1415  G4double charge= qQC.GetCharge();
1416  G4double dq= abs(baryn-charge-charge);
1417  G4cout<<"G4QE::PIP:P="<<probab<<",ac="<<cBN<<",dq="<<dq<<",f="<<fact<<",qC="
1418  <<qC<<",rPDG="<<rPDG<<",pPDG="<<pPDG<<",nCP="<<nOfCl<<",dCP="<<dOfCl<<G4endl;
1419 #endif
1420  }
1421  else probab=0.;
1422  sum+=probab;
1423  curCand->SetIntegProbability(sum);
1424  }
1425  if(allB>0.)f2all=(allB-denseB)/allB;
1426  else f2all=0.;
1427 } // End of PrepareInteractionProbabilities
1428 
1429 //Initialize a Clusters Vector for the Nucleus of the QEnvironment
1430 void G4QEnvironment::InitClustersVector(G4int maxClust, G4int maxA)
1431 {
1432 #ifdef debug
1433  G4cout<<"G4QEnvironment::InitClustersVector called with nC="<<maxClust<<G4endl;
1434 #endif
1435  if(maxClust>=0) for (G4int i=0; i<maxClust; i++)
1436  {
1437  //G4int clustQCode = i+90; // Q-code of the cluster in the CHIPS World "IsoNuclei"
1438  G4int clustQCode = i+53; // @@ cluster Q-code in CHIPS World (53=nQHM in G4QPDGCode.hh)
1439 #ifdef sdebug
1440  G4cout<<"G4QEnvironment::InitClustersVector: Before Init Q ="<<clustQCode<<G4endl;
1441 #endif
1442  G4QPDGCode clustQPDG(true,clustQCode);
1443  //clustQPDG.InitByQCode(clustQCode);
1444  G4int clusterPDG=clustQPDG.GetPDGCode();
1445  G4int clustB=clustQPDG.GetBaryNum();
1446 #ifdef sdebug
1447  G4cout<<"G4QEnvironment::InitClustersVector: Before insert ="<<clusterPDG<<G4endl;
1448 #endif
1449  //theQCandidates.push_back(new G4QCandidate(clusterPDG)); // (delete equivalent)
1450  if(clustB<=maxA) theQCandidates.push_back(new G4QCandidate(clusterPDG)); // (del.eq.)
1451 #ifdef sdebug
1452  G4cout<<"G4QEnvironment::InitClustersVector: Cluster # "<<i<<" with code = "
1453  <<clusterPDG<<", QC="<<clustQPDG.GetQuarkContent()<<G4endl;
1454 #endif
1455  }
1456 } // End of InitClastersVector
1457 
1458 // Fragmentation of the QEnvironment with MultyQuasmon (the main internal member function)
1459 G4QHadronVector G4QEnvironment::HadronizeQEnvironment()
1460 {
1461  static const G4int NUCPDG = 90000000;
1462  static const G4QNucleus vacuum(NUCPDG);
1463  static const G4LorentzVector zeroLV(0.,0.,0.,0.);
1464  //static const G4QContent zeroQC(0,0,0,0,0,0);
1465  static const G4QContent PiQC(0,1,0,1,0,0);
1466  static const G4QContent K0QC(1,0,0,0,0,1);
1467  static const G4QContent KpQC(0,1,0,0,0,1);
1468  static const G4QContent SiPQC(0,2,1,0,0,0);
1469  static const G4QContent SiMQC(2,0,1,0,0,0);
1470  static const G4QContent protQC(1,2,0,0,0,0);
1471  static const G4QContent neutQC(2,1,0,0,0,0);
1472  //static const G4QContent alQC(6,6,0,0,0,0);
1473  static const G4QPDGCode nQPDG(2112);
1474  static const G4QPDGCode pQPDG(2212);
1475  static const G4QPDGCode lQPDG(3122);
1476  static const G4QPDGCode s0QPDG(3122);
1477  static const G4double mPi0 = G4QPDGCode(111).GetMass();
1478  //static const G4double dPi0 = mPi0+mPi0;
1479  static const G4double fPi0 = 4*mPi0;
1480  static const G4double mPi = G4QPDGCode(211).GetMass();
1481  static const G4double mK = G4QPDGCode(321).GetMass();
1482  static const G4double mK0 = G4QPDGCode(311).GetMass();
1483  static const G4double mNeut= G4QPDGCode(2112).GetMass();
1484  static const G4double mProt= G4QPDGCode(2212).GetMass();
1485  static const G4double mLamb= G4QPDGCode(3122).GetMass();
1486  static const G4double mSigZ= G4QPDGCode(3212).GetMass();
1487  static const G4double mSigM= G4QPDGCode(3112).GetMass();
1488  static const G4double mSigP= G4QPDGCode(3222).GetMass();
1489  //static const G4double mAlph = G4QPDGCode(2112).GetNuclMass(2,2,0);
1490  static const G4double eps=.003;
1491  G4int nQuasmons = theQuasmons.size();
1492 #ifdef chdebug
1493  G4int finCharge=theEnvironment.GetCharge();
1494  G4int finBaryoN=theEnvironment.GetA();
1495  G4int nHad=theQHadrons.size();
1496  if(nHad) for(G4int ih=0; ih<nHad; ih++)
1497  {
1498  finCharge+=theQHadrons[ih]->GetCharge();
1499  finBaryoN+=theQHadrons[ih]->GetBaryonNumber();
1500  }
1501  //G4int nQuas=theQuasmons.size();
1502  if(nQuasmons)for(G4int iq=0; iq<nQuasmons; iq++)
1503  {
1504  finCharge+=theQuasmons[iq]->GetCharge();
1505  finBaryoN+=theQuasmons[iq]->GetBaryonNumber();
1506  }
1507  if(finCharge!=totCharge || finBaryoN!=totBaryoN)
1508  {
1509  G4cout<<"*::*G4QE::HQ:T(1) tC="<<totCharge<<",C="<<finCharge<<",tB="<<totBaryoN
1510  <<",B="<<finBaryoN<<",E="<<theEnvironment<<G4endl;
1511  if(nHad) for(G4int h=0; h<nHad; h++)
1512  {
1513  G4QHadron* cH = theQHadrons[h];
1514  G4cout<<"*::*G4QE::HQ:h#"<<h<<",QC="<<cH->GetQC()<<",PDG="<<cH->GetPDGCode()<<G4endl;
1515  }
1516  if(nQuasmons) for(G4int q=0; q<nQuasmons; q++)
1517  {
1518  G4Quasmon* cQ = theQuasmons[q];
1519  G4cout<<"*::*G4QE::HQ:q#"<<q<<",C="<<cQ->GetCharge()<<",QCont="<<cQ->GetQC()<<G4endl;
1520  }
1521  }
1522 #endif
1523 #ifdef debug
1524  G4cout<<"G4QE::HQE:*HADRONIZE Q-ENVIRONMENT="<<theEnvironment<<",nQ="<<nQuasmons<<G4endl;
1525 #endif
1526  if(nQuasmons<1) // "No Quasmons" case -> Fill QEnviron
1527  {
1528  G4int nPDG = theEnvironment.GetPDG(); // PDG code of the residual Nucl.Environ.
1529 #ifdef debug
1530  G4cout<<"G4QE::HQE:***NO QUASMONS***Env="<<nPDG<<theEnvironment.Get4Momentum()<<G4endl;
1531 #endif
1532  if(nPDG==90000000) return theQHadrons;
1533  if(nPDG>80000000)
1534  {
1535  G4QHadron* rNucleus = new G4QHadron(theEnvironment); // Create HadronEnvironment
1536  theQHadrons.push_back(rNucleus); // Fill GS - no further decay (del. equiv.)
1537 #ifdef fdebug
1538  G4cout<<"G4QEnv::HadrQE: ---->> Fill Environment="<<theEnvironment<<G4endl;
1539 #endif
1540  }
1541  return theQHadrons;
1542  }
1543  if(theEnvironment.GetPDG()==NUCPDG) // ==> "Environment is Vacuum" case
1544  {
1545 #ifdef rdebug
1546  G4cout<<"G4QEnv::HadrQE: ***Vacuum*** #ofQ="<<nQuasmons<<G4endl;
1547  G4int totInC=0;
1548  G4LorentzVector totIn4M(0.,0.,0.,0.);
1549  for (G4int is=0; is<nQuasmons; is++) // Sum4mom's of Quasmons for the comparison
1550  {
1551  G4Quasmon* pQ = theQuasmons[is];
1552  G4LorentzVector Q4M= pQ->Get4Momentum();
1553  totIn4M += Q4M;
1554  totInC += pQ->GetQC().GetCharge();
1555  } // End of TotInitial4Momentum summation LOOP over Quasmons
1556  G4int nsHadr = theQHadrons.size(); // Update the value of OUTPUT entries
1557  if(nsHadr) for(G4int jso=0; jso<nsHadr; jso++)// LOOP over output hadrons
1558  {
1559  G4int hsNF = theQHadrons[jso]->GetNFragments(); // A#of secondary fragments
1560  if(!hsNF) // Add only final hadrons
1561  {
1562  G4LorentzVector hs4Mom = theQHadrons[jso]->Get4Momentum();
1563  totIn4M += hs4Mom;
1564  totInC += theQHadrons[jso]->GetCharge();
1565  }
1566  }
1567 #endif
1568  G4QNucleus vE(90000000);
1569  G4int nlq = 0; // Prototype of a#of Living Quasmons
1570  if(nQuasmons) for(G4int lq=0; lq<nQuasmons; lq++)if(theQuasmons[lq]->GetStatus())nlq++;
1571  if(nQuasmons) for(G4int iq=0; iq<nQuasmons; iq++)
1572  {
1573 #ifdef chdebug
1574  G4int f1Charge=theEnvironment.GetCharge();
1575  G4int f1BaryoN=theEnvironment.GetA();
1576  G4int nHad=theQHadrons.size();
1577  if(nHad) for(G4int ih=0; ih<nHad; ih++)
1578  {
1579  f1Charge+=theQHadrons[ih]->GetCharge();
1580  f1BaryoN+=theQHadrons[ih]->GetBaryonNumber();
1581  }
1582  G4int nQuas=theQuasmons.size();
1583  if(nQuas)for(G4int iqs=0; iqs<nQuas; iqs++)
1584  {
1585  f1Charge+=theQuasmons[iqs]->GetCharge();
1586  f1BaryoN+=theQuasmons[iqs]->GetBaryonNumber();
1587  }
1588  if(f1Charge!=totCharge || f1BaryoN!=totBaryoN)
1589  {
1590  G4cout<<"*::*G4QE::HQ:(2)q#"<<iq<<",tC="<<totCharge<<",C="<<f1Charge<<",tB="
1591  <<totBaryoN<<",B="<<f1BaryoN<<",E="<<theEnvironment<<G4endl;
1592  if(nHad) for(G4int h=0; h<nHad; h++)
1593  {
1594  G4QHadron* cH = theQHadrons[h];
1595  G4cout<<"*:*G4QE::HQ:#"<<h<<",QC="<<cH->GetQC()<<",P="<<cH->GetPDGCode()<<G4endl;
1596  }
1597  if(nQuas) for(G4int q=0; q<nQuas; q++)
1598  {
1599  G4Quasmon* cQ = theQuasmons[q];
1600  G4cout<<"*:*G4QE::HQ:q#"<<q<<",C="<<cQ->GetCharge()<<",QC="<<cQ->GetQC()<<G4endl;
1601  }
1602  }
1603 #endif
1604  G4int ist=theQuasmons[iq]->GetStatus();// Status of the Quasmon before fragmentation
1605  if(ist)
1606  {
1607  G4QHadronVector* output=theQuasmons[iq]->Fragment(vE,1);
1608  G4int ast=theQuasmons[iq]->GetStatus(); // Quasmon's Status after fragmentation ^
1609  if(!ast) nlq--; // Reduce nlq if Quasmon decayed ^
1610  G4int nHadrons = output->size(); // A#of output Hadrons in the Quasmon ^
1611 #ifdef debug
1612  G4cout<<"G4QEnv::HadrQE: ***Vacuum*** Q#"<<iq<<", nHadr="<<nHadrons<<G4endl; // ^
1613 #endif
1614  if(nHadrons>0) // Copy QHadrons-Quasmon to Output ^
1615  {
1616  for (G4int ih=0; ih<nHadrons; ih++) // LOOP over QHadrons of the Quasmon ^
1617  {
1618  //G4QHadron* curH=new G4QHadron(output->operator[](ih));// (Del 7 lines below)^
1619  G4QHadron* curH = new G4QHadron((*output)[ih]); // (Deleted 7 lines below) ^
1620 #ifdef debug
1621  G4cout<<"G4QEnv::HadrQE:Vacuum, H#"<<ih<<", QPDG="<<curH->GetQPDG() // ^
1622  <<",4M="<<curH->Get4Momentum()<<G4endl; // ^
1623 #endif
1624  theQHadrons.push_back(curH); // Fill hadron-copy (delete equivalent) ^
1625  }
1626  } // ^
1627  else // => "Quasmon can't decay" case ^
1628  { // ^
1629  G4QContent totQC=theQuasmons[iq]->GetQC();// ^
1630  G4int tQBN=totQC.GetBaryonNumber();// Baryon Number of not decayed Quasmon ^
1631  G4QNucleus tqN(totQC); // Define the quasmon as a nucleus ^
1632  G4double gsM=tqN.GetMZNS(); // GS Mass ^
1633  G4LorentzVector tot4M=theQuasmons[iq]->Get4Momentum();
1634  G4double totQM=tot4M.m(); // Real Mass of Quasmon ^
1635  if(tQBN>0&&totQM>gsM) // => "Try Quasmon evaporation" case ^
1636  { // ^
1637  G4QHadron* nuclQ = new G4QHadron(totQC,tot4M); // ^
1638 #ifdef fdebug
1639  G4cout<<"G4QEnv::HadrQE:Vac,tQC"<<totQC<<",t4M="<<tot4M<<G4endl; // ^
1640 #endif
1641  EvaporateResidual(nuclQ); // Evaporate ResNuc (del.equiv) ^
1642  theQuasmons[iq]->KillQuasmon(); // Kill evaporated Quasmon ^
1643  nlq--; // ^
1644  }
1645  else if(iq+1<nQuasmons&&nlq>1) // => "Try to merge with next" case ^
1646  {
1647  G4int s_value=theQuasmons[iq+1]->GetStatus();//Status of the next Quasmon ^
1648  theQuasmons[iq+1]->IncreaseBy(theQuasmons[iq]);// Merge with the next Quasmon ^
1649  theQuasmons[iq]->KillQuasmon(); // Kill the week Quasmon ^
1650  if(s_value) nlq--; // Reduce a number of "living Quasmons" ^
1651  }
1652  else if(iq+1==nQuasmons&&iq&&nlq>1) // => "Quasmon stack is exhosted" case ^
1653  {
1654  G4int s_value=theQuasmons[0]->GetStatus(); // Status of the first Quasmon ^
1655  theQuasmons[0]->IncreaseBy(theQuasmons[iq]);// Merge with the first Quasmon ^
1656  theQuasmons[iq]->KillQuasmon(); // Kill the week Quasmon ^
1657  if(s_value) nlq--; // Reduce a number of "living Quasmons" ^
1658  }
1659  else // "Have a chance to recover" case ^
1660  { // ^
1661 #ifdef debug
1662  G4cout<<"***G4QE::HQE:"<<iq<<",n="<<nHadrons<<",Tot="<<totQC<<totQM<<G4endl;//^
1663  for (G4int kq=0; kq<nQuasmons; kq++) // LOOP over Quasmons for DEBUG PRINTING ^
1664  G4cout<<kq<<",St/QC="<<theQuasmons[kq]->GetStatus()<<theQuasmons[kq] // ^
1665  ->GetQC()<<",M="<<theQuasmons[kq]->Get4Momentum().m()<<G4endl; // ^
1666 #endif
1667  G4int nOfOUT = theQHadrons.size(); // Total #of QHadrons at this point ^
1668  G4double dM = totQM-gsM; // Excitation of the Quasmon ^
1669  G4bool corrf = true; // False when corrected & needs to quit ^
1670  while(nOfOUT && corrf) // LOOP over all existing QHadrons ^
1671  { // ^
1672  G4QHadron* theLast = theQHadrons[nOfOUT-1]; // Remember ^
1673  G4LorentzVector last4M = theLast->Get4Momentum(); // all ^
1674  G4QContent lastQC = theLast->GetQC(); // content ^
1675  G4int lastS = lastQC.GetStrangeness(); // of // Only ^
1676  G4int totS = totQC.GetStrangeness(); // the // for ^
1677  G4int nFr = theLast->GetNFragments(); // Last // if() ^
1678  G4int gam = theLast->GetPDGCode(); // // ^
1679  if(gam!=22&&!nFr&&lastS<0&&lastS+totS<0&&nOfOUT>1)//=> Skip K,gam & decayed ^
1680  { // ^
1681  G4QHadron* thePrev = theQHadrons[nOfOUT-2];// Kill Prev & make Last->Prev ^
1682  theQHadrons.pop_back(); // theLastQHadron is excluded from OUTPUT^
1683  theQHadrons.pop_back(); // thePrevQHadron is excluded from OUTPUT^
1684  theQHadrons.push_back(thePrev); // thePrev becomes theLast as an object ^
1685  delete theLast; // the Last QHadron is destructed ^
1686  theLast = thePrev; // Update parameters (thePrev*->theLast*)^
1687  last4M = theLast->Get4Momentum();// 4Mom of the previouse Quasmon ^
1688  lastQC = theLast->GetQC(); // Quark Content of the previouse Quasmon^
1689  } // ^
1690  else // Just Clear and destroy theLast ^
1691  { // ^
1692  theQHadrons.pop_back(); // theLastQHadron is excluded from OUTPUT^
1693  delete theLast; // theLastQHadron is deleated as instance^
1694  } // ^
1695  totQC+=lastQC; // Update (increase) the total QC ^
1696  tot4M+=last4M; // Update (increase) the total 4-momentum^
1697  totQM=tot4M.m(); // Calculate new real total mass ^
1698  G4QNucleus nN(totQC); // Define the Quasmon as a nucleus ^
1699  gsM=nN.GetMZNS(); // Calculate the new GS Mass ^
1700  dM = totQM-gsM; // Escitation energy for the Quasmon ^
1701  if(dM>0) // "Mass of Q is big enough" case ^
1702  { // ^
1703  theQuasmons[iq]->InitQuasmon(totQC,tot4M);// Update the week Quasmon ^
1704  G4QHadronVector* curout=theQuasmons[iq]->Fragment(vE,1);
1705  ast=theQuasmons[iq]->GetStatus();// Status of the Quasmon ^ ^
1706  if(!ast) nlq--; // Reduce nlq if Quasmon decayed ^ ^
1707  nHadrons=curout->size(); // A#of outputQHadrons in theDecayedQ ^ ^
1708 #ifdef debug
1709  G4cout<<"G4QEnv::HadrQE:VacuumRecoverQ#"<<iq<<",n="<<nHadrons<<G4endl;//^ ^
1710 #endif
1711  if(nHadrons>0) // => "QHadrons from Quasmon to Output"^ ^
1712  { // ^ ^
1713  for (G4int ih=0; ih<nHadrons; ih++) // LOOP over Hadrons of theQuasmon^ ^
1714  { // ^ ^
1715  //G4QHadron* curH = new G4QHadron(curout->operator[](ih)); // ^ ^
1716  G4QHadron* curH = new G4QHadron((*curout)[ih]); // ^ ^
1717 #ifdef debug
1718  G4cout<<"G4QEnv::HadrQE:Recovered, H#"<<ih<<", QPDG=" // ^ ^
1719  <<curH->GetQPDG()<<",4M="<<curH->Get4Momentum()<<G4endl; // ^ ^
1720 #endif
1721  totQC-=curH->GetQC(); // totQC recalculation ^ ^
1722  tot4M-=curH->Get4Momentum(); // tot4M recalculation ^ ^
1723  theQHadrons.push_back(curH); // Fill hadron-copy (delete equivalent)^ ^
1724  //delete curout->operator[](ih);//>-Necessary to delete instances*>-^ ^
1725  delete (*curout)[ih]; // >-*Necessary to delete instances*>--^ ^
1726  } // End of LOOP over Hadrons of the Quasmon ^ ^
1727  curout->clear(); // ^ ^
1728  delete curout; //>*Necessary to delete VectPointers*>=^ ^
1729  corrf = false; // Corrected: go out of the while loop ^ ^
1730  //break; // @@ ?? ^ ^
1731  } // End of check for existing output Hadrons in the Quasmon ^ ^
1732  else // ^ ^
1733  { // ^ ^
1734  for_each(curout->begin(), curout->end(), DeleteQHadron()); // >-------^ ^
1735  curout->clear(); // ^ ^
1736  delete curout; //>*Necessary to delete VectPointers>--^ ^
1737  } // ^
1738  } // ^
1739  nOfOUT = theQHadrons.size(); // Update the value of OUTPUT entries ^
1740 #ifdef rdebug
1741  G4int tC=totInC; // Vacuum: No ResidualEnvironCharge ^
1742  G4LorentzVector t4M=totIn4M; // Vacuum: No ResidualEnvironment 4-Mom ^
1743  for (G4int js=0; js<nQuasmons; js++) // Subtract 4mom's of Quasmons from dif^
1744  { // ^
1745  G4Quasmon* pQ = theQuasmons[js]; // ^
1746  if(pQ->GetStatus()) // Subtract only if Quasmon is alive ^
1747  { // ^
1748  G4LorentzVector Q4M= pQ->Get4Momentum(); // ^
1749  t4M -= Q4M; // ^
1750  tC -= pQ->GetQC().GetCharge(); // ^
1751  } // ^
1752  else G4cout<<"G4QE::HQ:SUM-4-Mom s("<<js<<")="<<pQ->GetStatus()<<G4endl;//^
1753  } // End of Quasmons4Momentum subtractions ^
1754  if(nOfOUT) for(G4int jpo=0; jpo<nOfOUT; jpo++)// LOOP over output hadrons ^
1755  { // ^
1756  G4int hsNF = theQHadrons[jpo]->GetNFragments();//A#of secondary fragments^
1757  if(!hsNF) // Subtract only final hadrons^
1758  {
1759  G4LorentzVector hs4Mom = theQHadrons[jpo]->Get4Momentum(); // ^
1760  t4M -= hs4Mom; // ^
1761  tC -= theQHadrons[jpo]->GetCharge(); // ^
1762  } // ^
1763  } // ^
1764  G4cout<<"G4QE::HQ:|||Vacuum|||4-MomCHECK|||d4M="<<t4M<<",dC="<<tC<<G4endl;//^
1765 #endif
1766  } // End of the WHILE LOOP ^
1767  //if(!nOfOUT&&nQuasmons==1) // TRY TO EVAPORATE THE TOTAL SYSTEM ^
1768  if((!nOfOUT&&nQuasmons==1)||theEnvironment.GetPDGCode()==NUCPDG)//EvaporTotal ^
1769  { // ^
1770  G4int totS=totQC.GetStrangeness(); // Total Strangeness ^
1771  //G4int totBN=totQC.GetBaryonNumber();// Total Baryon Number ^
1772  G4int totPDG=totQC.GetZNSPDGCode();// Convert QC to PDGCOde for the nucleus ^
1773  if(totS) totPDG-=totS*999999; // @@ ?? ^
1774 #ifdef fdebug
1775  G4cout<<"G4QE::HQE: totPDG="<<totPDG<<",totM="<<totQM<<G4endl; // ^
1776 #endif
1777  G4QHadron* evH = new G4QHadron(totQC,tot4M); // Create a Hadron-ResidualNucl^
1778  CleanUp(); // ^
1779  EvaporateResidual(evH); // Evaporate ResNuc (del.equiv) ^
1780  for_each(output->begin(), output->end(), DeleteQHadron());// >------------->+
1781  output->clear(); // ^
1782  delete output; // >--------------->-------------------->+
1783  return theQHadrons; // ^
1784  } // ^
1785  else if(!nOfOUT) // Still remain not used Quasmons ^
1786  { // ^
1787  G4ExceptionDescription ed; // ^
1788  ed <<"Can't decay Quasmon: T="<< tot4M << totQC << ",M=" << totQM // ^
1789  <<" < gsM="<< gsM <<", d="<< dM <<",Env="<< theEnvironment << G4endl; // ^
1790  G4Exception("G4QEnvironment::HadronizeQEnvironment()", "HAD_CHPS_0000", // ^
1791  FatalException, ed); // ^
1792  } // ^
1793  } // End of PANIC treatment ^
1794  } // End of trouble handling with Quasmon decay in Vacuum ^
1795  for_each(output->begin(), output->end(), DeleteQHadron()); // >----------------->+
1796  output->clear(); // ^
1797  delete output; // >----------------->------------------>+
1798  } // End of check for the already decayed Quasmon
1799  } // End of the LOOP over Quasmons
1800  }
1801  else // ==> "Nuclear environment" case
1802  {
1803 #ifdef rdebug
1804  G4cout<<"G4QEnv::HadrQE:FRAGMENTATION IN NUCLEAR ENVIRONMENT nQ="<<nQuasmons<<G4endl;
1805  G4int totInC=theEnvironment.GetZ();
1806  G4LorentzVector totIn4M=theEnvironment.Get4Momentum();
1807  for (G4int is=0; is<nQuasmons; is++) // Sum 4mom's of Quasmons for comparison
1808  {
1809  G4Quasmon* pQ = theQuasmons[is];
1810  G4LorentzVector Q4M= pQ->Get4Momentum();
1811  totIn4M += Q4M;
1812  totInC += pQ->GetQC().GetCharge();
1813  } // End of TotInitial4Momentum summation LOOP over Quasmons
1814  G4int nsHadr = theQHadrons.size(); // Update the value of #of OUTPUT entries
1815  if(nsHadr) for(G4int jso=0; jso<nsHadr; jso++)// LOOP over output hadrons
1816  {
1817  G4int hsNF = theQHadrons[jso]->GetNFragments(); // A#of secondary fragments
1818  if(!hsNF) // Add only final hadrons
1819  {
1820  G4LorentzVector hs4Mom = theQHadrons[jso]->Get4Momentum();
1821  totIn4M += hs4Mom;
1822  totInC += theQHadrons[jso]->GetCharge();
1823  }
1824  }
1825 #endif
1826  // @@ Experimental calculations
1827  G4QContent totInQC=theEnvironment.GetQCZNS();
1828  G4LorentzVector totIn4M=theEnvironment.Get4Momentum();
1829  for (G4int is=0; is<nQuasmons; is++) // Sum 4mom's of Quasmons for comparison
1830  {
1831  G4Quasmon* pQ = theQuasmons[is];
1832  totIn4M += pQ->Get4Momentum();
1833  totInQC += pQ->GetQC();
1834  } // End of TotInitial4Momentum/QC summation LOOP over Quasmons
1835  G4double totMass=totIn4M.m();
1836  G4QNucleus totN(totInQC);
1837  G4double totM=totN.GetMZNS();
1838  G4double excE = totMass-totM;
1839  // @@ End of experimental calculations
1840  G4int envA=theEnvironment.GetA();
1841  //G4int c3Max = 27; // Big number (and any #0) slowes dow a lot
1842  //G4int c3Max = 9; // Max#of "no hadrons" steps (reduced below?)
1844  G4int c3Max = 1;
1845  if(excE > fPi0) c3Max=(G4int)(excE/mPi0); // Try more for big excess
1846  //G4int c3Max = 1;
1847  //if(excE > dPi0) c3Max=(G4int)(excE/mPi0); // Try more for big excess
1848  //G4int c3Max = 0;
1849  //if(excE > mPi0) c3Max=(G4int)(excE/mPi0); // Try more for big excess
1850  //G4int c3Max = 0; // It closes the force decay of Quasmon at all!
1851  //
1852  //G4int premC = 27;
1853  //G4int premC = 3;
1854  G4int premC = 1;
1855  //if(envA>1&&envA<13) premC = 24/envA;
1856  if(envA>1&&envA<19) premC = 36/envA;
1857  //if(envA>1&&envA<31) premC = 60/envA;
1858  //if(envA>1&&envA<61) premC = 120/envA;
1859  G4int sumstat= 2; // Sum of statuses of all Quasmons
1860  G4bool force = false; // Prototype of the Force Major Flag
1861  G4int cbR =0; // Counter of the "Stoped by Coulomb Barrier"
1862  //
1863  //G4int cbRM =0; // * MaxCounter of "StopedByCoulombBarrier" *
1864  //G4int cbRM =1; // MaxCounter of the "StopedByCoulombBarrier"
1865  //G4int cbRM =3; // MaxCounter of the "StopedByCoulombBarrier"
1866  //G4int cbRM =9; // MaxCounter of the "Stoped byCoulombBarrier"
1867  G4int cbRM = c3Max; // MaxCounter of the "StopedByCoulombBarrier"
1868  G4int totC = 0; // Counter to break the "infinit" loop
1869  //G4int totCM = 227; // Limit for the "infinit" loop counter
1870  G4int totCM = envA; // Limit for the "infinit" loop counter
1871  //G4int totCM = 27; // Limit for this counter
1872  //G4int nCnMax = 1; // MaxCounterOfHadrFolts for shortCutSolutions
1873  //G4int nCnMax = 3; // MaxCounterOfHadrFolts for shortCutSolutions
1874  //G4int nCnMax = 9; // MaxCounterOfHadrFolts for shortCutSolutions
1875  G4int nCnMax = c3Max; // MaxCounterOfHadrFolts for shortCutSolutions
1876  G4bool first=true; // Flag of the first interaction (only NucMedia)
1877  G4int cAN=0; // Counter of the nucleon absorptions
1878  //G4int mcAN=27; // Max for the counter of nucleon absorptions
1880  //G4int mcAN=3; // Max for the counter of nucleon absorptions
1881  G4int mcAN=1; // Max for the counter of nucleon absorptions
1882  G4double proNorm=.001; // Rescattering parameter mb^-1
1883  //G4double proNorm=.0027; // Rescattering parameter mb^-1
1884  while (sumstat||totC<totCM) // ===***=== The MAIN "FOREVER" LOOP ===***===
1885  {
1886 #ifdef chdebug
1887  G4int f2Charge=0;
1888  G4int f2BaryoN=0;
1889  if(theEnvironment.GetMass()>0.)
1890  {
1891  f2Charge=theEnvironment.GetCharge();
1892  f2BaryoN=theEnvironment.GetA();
1893  }
1894  G4int nHad=theQHadrons.size();
1895  if(nHad) for(G4int ih=0; ih<nHad; ih++)
1896  {
1897  f2Charge+=theQHadrons[ih]->GetCharge();
1898  f2BaryoN+=theQHadrons[ih]->GetBaryonNumber();
1899  }
1900  G4int nQuas=theQuasmons.size();
1901  if(nQuas)for(G4int iqs=0; iqs<nQuas; iqs++)
1902  {
1903  f2Charge+=theQuasmons[iqs]->GetCharge();
1904  f2BaryoN+=theQuasmons[iqs]->GetBaryonNumber();
1905  }
1906  if(f2Charge!=totCharge || f2BaryoN!=totBaryoN)
1907  {
1908  G4cout<<"*::*G4QE::HQ:(3)(NucEnv)i#"<<totC<<",tC="<<totCharge<<",C="<<f2Charge
1909  <<",tB="<<totBaryoN<<",B="<<f2BaryoN<<",E="<<theEnvironment<<G4endl;
1910  if(nHad) for(G4int h=0; h<nHad; h++)
1911  {
1912  G4QHadron* cH = theQHadrons[h];
1913  G4cout<<"*:*G4QE::HQ:#"<<h<<",QC="<<cH->GetQC()<<",P="<<cH->GetPDGCode()<<G4endl;
1914  }
1915  if(nQuas) for(G4int q=0; q<nQuas; q++)
1916  {
1917  G4Quasmon* cQ = theQuasmons[q];
1918  G4cout<<"*:*G4QE::HQ:q#"<<q<<",C="<<cQ->GetCharge()<<",QC="<<cQ->GetQC()<<G4endl;
1919  }
1920  }
1921 #endif
1922  totC++;
1923  if( nQuasmons==1 && sumstat==3 ) cbR++; // Counter of dead solutions for nQ=1
1924  else cbR=0;
1925  G4QContent envQC=theEnvironment.GetQCZNS();// QuarkCont of current NuclearEnvironment
1926  G4QContent totQC=envQC; // Total QuarkContent in the system
1927  G4double envM =theEnvironment.GetMass(); // mass of NuclEnvironment (@@GetMZNS())
1928  G4double sumM =envM; // Sum of all residual masses in theSystem
1929  G4LorentzVector env4M=theEnvironment.Get4Momentum();
1930  G4LorentzVector tot4M=env4M; // 4-momentum of the Total System
1931  sumstat =0;
1932  G4int nCount=0; // Counter of notsuccessful fragmentations
1933  G4int fCount=0; // Counter of successful(notFinal) fragm's
1934  G4int eCount=0; // Counter of not yet decayed Quasmons
1935  for (G4int iq=0; iq<nQuasmons; iq++) // Sum up Quasmons for making a decision
1936  {
1937  G4Quasmon* pQ = theQuasmons[iq];
1938  G4QContent QQC= pQ->GetQC();
1939  totQC += QQC;
1940  G4LorentzVector Q4M= pQ->Get4Momentum();
1941  tot4M += Q4M;
1942  G4double QM = Q4M.m();
1943  sumM += QM;
1944  G4int Qst= pQ->GetStatus();
1945  sumstat += Qst;
1946 #ifdef debug
1947  G4cout<<"G4QEnv::HadrQE:#"<<iq<<", Qst="<<Qst<<", Q="<<Q4M<<Q4M.m()<<QQC<<", Env="
1948  <<theEnvironment<<",nQ="<<nQuasmons<<G4endl;
1949 #endif
1950  if(nQuasmons>1 && iq+1==nQuasmons && !Qst && Q4M==zeroLV)
1951  {
1952  theQuasmons.pop_back(); // Exclude the zero-Quasmon
1953  delete pQ; // and delet it
1954  nQuasmons--;
1955  }
1956  if(Qst==1||Qst==3||Qst==4)
1957  {
1958  fCount++; // Incr. counterSuccessfulFragmentations
1959  nCount=0; // SetCounterNotSuccessfulFragmentations
1960  }
1961  if(Qst>0) eCount++; // Incr. counter of existing Quasmons
1962  } // End of summation LOOP over Quasmons
1963  G4int totS =totQC.GetStrangeness(); // Total Strangeness of the Total System
1964  G4int totBN =totQC.GetBaryonNumber(); // Total Baryon Number of the Total System
1965  G4int totPDG=0; // Total PDG Code for the Current compound
1966  totM =0.; // min(GroundSt)Mass of theResidualSystem
1967  if(totBN < 2) // Solution for the light nucleus
1968  {
1969  totPDG=totQC.GetSPDGCode(); // Min totPDGCode for theCurrentCompound
1970  if(totPDG) totM=G4QPDGCode(totPDG).GetMass(); // min Mass of the Residual System
1971  else
1972  {
1973  // throw G4QException("G4QEnv::HadrQEnv: Impossible PDG for B=1");
1974  G4Exception("G4QEnvironment::HadronizeQEnvironment()", "HAD_CHPS_0001",
1975  FatalException, "Impossible PDG for B=1");
1976  }
1977  }
1978  else
1979  {
1980  G4QNucleus totN_temporary(totQC,tot4M); // Excited nucleus for theResidualSystem
1981  totN=totN_temporary;
1982  totM=totN.GetMZNS(); // min(GroundSt)Mass of theResidualSystem
1983  totPDG=totN.GetPDG(); // Total PDG Code for the Current compound
1984  }
1985 #ifdef fdebug
1986  G4cout<<"G4QEnv::HadrQE:totC="<<totC<<"<totCM="<<totCM<<",ss="<<sumstat<<G4endl;
1987 #endif
1988  if ( totC >= totCM || cbR > cbRM)
1989  {
1990  CleanUp();
1991  G4QHadron* evH = new G4QHadron(totQC,tot4M);// Create a Hadron for ResidualNucl
1992  EvaporateResidual(evH); // Try to evaporate residual (del. equiv.)
1993  return theQHadrons;
1994  }
1995  // === Now we should be prepared for evaporation ===
1996  G4int totChg=totQC.GetCharge(); // Total Electric Charge of the Total System
1997 #ifdef debug
1998  if(totPDG==90999999||totPDG==90999000||totPDG==90000999||totPDG==89999001)
1999  G4cout<<"***G4QEnv::HadrQEnv: Meson (1) PDG="<<totPDG<<", M="<<tot4M.m()<<G4endl;
2000  G4int nOH=theQHadrons.size(); // A#of output hadrons
2001  G4LorentzVector s4M=tot4M; // Total 4-momentum (@@ only for checking)
2002  if(nOH) for(G4int ih=0; ih<nOH; ih++) s4M+=theQHadrons[ih]->Get4Momentum();
2003  G4cout<<"G4QEnv::HadrQE:tBN="<<totBN<<",s="<<sumstat<<",fC="<<fCount<<",eC="<<eCount
2004  <<",En="<<theEnvironment<<",nH="<<nOH<<",tLV="<<s4M<<totQC<<nCount<<G4endl;
2005 #endif
2006  if(totBN<2) // => "Baryons or Mesons" case (@@antiBaryon)
2007  {
2008  totPDG =totQC.GetSPDGCode();
2009  if(totPDG && totPDG!=10 && totPDG!=1114 && totPDG!=2224)
2010  totM=G4QPDGCode(totPDG).GetMass();
2011  else if(totPDG==1114) totM=mNeut+mPi;
2012  else if(totPDG==2224) totM=mProt+mPi;
2013  else if(totPDG==10)
2014  {
2015  G4QChipolino totChip(totQC); // define the residual as a Chipolino
2016  totM =totChip.GetQPDG1().GetMass()+totChip.GetQPDG2().GetMass();
2017  }
2018  else
2019  {
2021  ed << "Impossible Hadron in CHIPS: totPDG=" << totPDG << ", totQC="
2022  << totQC << G4endl;
2023  G4Exception("G4QEnvironment::HadronizeQEnvironment()", "HAD_CHPS_0002",
2024  FatalException, ed);
2025  }
2026  }
2027  totMass = tot4M.m(); // Total effective Mass
2028  G4bool Premium = eCount && premC && envM; // Premium condition
2029  G4int count3 = 0;
2030  if(sumstat && (fCount||Premium) && !force && count3<c3Max)//=>"Force Quasmons decay"
2031  {
2032  if(!fCount) premC--; // Reduce premium efforts counter
2033  if(nQuasmons) for (G4int jq=0; jq<nQuasmons; jq++)//FragmentationLOOP over Quasmons
2034  {
2035  G4Quasmon* pQ = theQuasmons[jq];// Pointer to the CurrentQuasmon <--<--<--+
2036  G4int status = pQ->GetStatus();// Old status of the Quasmon ^
2037 #ifdef debug
2038  G4cout<<"G4QE::HQE:Status of Q#"<<jq<<" (before Fragment)="<<status<<G4endl;//^
2039 #endif
2040  if(status) // Skip dead Quasmons ^
2041  { // ^
2042  G4int nQuas=eCount; // ^
2043  if(nQuas==1&&first) nQuas=-nQuas; // ^
2044  G4QHadronVector* output=pQ->Fragment(theEnvironment,nQuas);//<DESTRUCT<--<--^-+
2045 #ifdef debug
2046  G4cout<<"G4QE::HQE:Q#"<<jq<<",*afterFragm* Env="<<theEnvironment<<G4endl;// ^ ^
2047 #endif
2048  envM =theEnvironment.GetMass(); // new mass of Nuclear Environment ^ ^
2049  status = pQ->GetStatus(); // NewStatus after FragmentationAttempt ^ ^
2050  if(!status) eCount--; // Dec. ExistingQuasmonsCounter for Q=0 ^ ^
2051  G4int nHadrons = output->size(); // ^ ^
2052 #ifdef rdebug
2053  G4cout<<"G4QE::HQE:**AfterFragmAttempt**#"<<jq<<",stat="<<status<<", Q4M="//^ ^
2054  <<pQ->Get4Momentum()<<", Env="<<theEnvironment<<",nH="<<nHadrons // ^ ^
2055  <<",c3="<<count3<<" < "<<c3Max<<",eC="<<eCount<<G4endl; // ^ ^
2056  G4int tC=totInC-theEnvironment.GetZ(); // Subtract theResidualEnvironCharge ^ ^
2057  G4LorentzVector t4M=totIn4M; // Compare with the total ^ ^
2058  G4LorentzVector theEnv4m=theEnvironment.Get4Momentum(); // Environment 4Mom ^ ^
2059  t4M-=theEnv4m; // Subtract the Environment 4-momentum ^ ^
2060  G4cout<<"G4QEnv::HadrQE:SUM-4Mom e4M="<<theEnv4m<<theEnvironment<<G4endl;// ^ ^
2061  for (G4int js=0; js<nQuasmons; ++js)// Subtract 4mom's of Quasmons (compare)^ ^
2062  { // ^ ^
2063  G4Quasmon* prQ = theQuasmons[js];// ^ ^
2064  if(prQ->GetStatus()) // Subtract only if Quasmon is alive ^ ^
2065  { // ^ ^
2066  G4LorentzVector Q4M= prQ->Get4Momentum(); // ^ ^
2067  G4QContent qQC= prQ->GetQC(); // ^ ^
2068  G4cout<<"G4QE::HQE:SUM-4Mom q("<<js<<")4M="<<Q4M<<",QC="<<qQC<<G4endl;//^ ^
2069  t4M -= Q4M; // ^ ^
2070  tC -= prQ->GetQC().GetCharge(); // ^ ^
2071  } // ^ ^
2072  else G4cout<<"G4QE::HQE:SUM-4M,st("<<js<<")="<<prQ->GetStatus()<<G4endl;//^ ^
2073  } // End of Quasmons4Momentum subtractions ^ ^
2074  G4int nsbHadr=theQHadrons.size(); // Update the value of OUTPUT entries ^ ^
2075  if(nsbHadr) for(G4int jpo=0; jpo<nsbHadr; jpo++)// LOOP over output hadrons ^ ^
2076  { // ^ ^
2077  G4int hsNF = theQHadrons[jpo]->GetNFragments();// A#of out fragments ^ ^
2078  if(!hsNF) // Subtract only final hadrons ^ ^
2079  { // ^ ^
2080  G4LorentzVector hs4Mom = theQHadrons[jpo]->Get4Momentum(); // ^ ^
2081  G4int hPDG = theQHadrons[jpo]->GetPDGCode(); // ^ ^
2082  G4cout<<"G4QE::HQE:SUM-4-Mom eh("<<jpo<<")4M="<<hs4Mom<<hPDG<<G4endl;// ^ ^
2083  t4M -= hs4Mom; // ^ ^
2084  tC -= theQHadrons[jpo]->GetCharge(); // ^ ^
2085  } // End of the "FinalHadron" IF ^ ^
2086  } // End of the LOOP over output hadrons ^ ^
2087  if(nHadrons) for(G4int kpo=0; kpo<nHadrons; ++kpo)//LOOP over out QHadrons ^ ^
2088  { // ^ ^
2089  //G4QHadron* insH =output->operator[](kpo);// Pointer to theOutputQHadron ^ ^
2090  G4QHadron* insH = (*output)[kpo];// Pointer to the Output QHadron ^ ^
2091  G4int qhsNF = insH->GetNFragments(); // A#of secondary fragments ^ ^
2092  if(!qhsNF) // Should never be here // Subtract -> only final hadrons ^ ^
2093  { // ^ ^
2094  G4LorentzVector qhs4Mom = insH->Get4Momentum();// 4M of theOutputHadron ^ ^
2095  G4int hPDG = insH->GetPDGCode(); // PDG Code of the Q-output Hadron ^ ^
2096  G4cout<<"G4QE::HQE:SUM-4-Mom qh("<<kpo<<")4M="<<qhs4Mom<<hPDG<<G4endl;//^ ^
2097  t4M -= qhs4Mom; // ^ ^
2098  tC -= insH->GetCharge(); // ^ ^
2099  } // ^ ^
2100  } // End of the LOOP over output QHadrons ^ ^
2101  G4cout<<"G4QEnv::HadrQE:|||||4-MomCHECK||||d4M="<<t4M<<",dC="<<tC<<G4endl;//^ ^
2102 #endif
2103  if(!status||status==1||nHadrons) //OutHadronVector was filled in G4Q::Frag ^ ^
2104  { // ^ ^
2105  nCount=0; // Reset the NotSuccessfulFragmCounter ^ ^
2106  if(nHadrons>0) // Transfer QHadrons from Quasm to Output ^ ^
2107  { // ^ ^
2108  for (G4int ih=0; ih<nHadrons; ++ih) // LOOP over Q-output QHadrons ^ ^
2109  { // ^ ^
2110  G4QHadron* inpH = (*output)[ih]; // ^ ^
2111  G4int hC=inpH->GetCharge(); // Charge of the Hadron ^ ^
2112  G4int hF=inpH->GetNFragments();// Number of fragments ^ ^
2113  G4double hCB=0.; // Coulomb Barrier prototype ^ ^
2114  G4double hKE=0.; // Kinetic Energy of the Hadron prototype ^ ^
2115  G4LorentzVector hLV=inpH->Get4Momentum(); // ^ ^
2116 #ifdef debug
2117  G4cout<<"->G4QEnv::HadrQE:H#"<<ih<<", hC="<<hC<<",hF="<<hF<<",4M=" // ^ ^
2118  <<hLV<<inpH->GetPDGCode()<<G4endl; // ^ ^
2119 #endif
2120  G4bool can = hC && !hF; // Charged and not yet decayed hadron ^ ^
2121  if(can) // ^ ^
2122  { // ^ ^
2123  G4int hB=inpH->GetBaryonNumber(); // ^ ^
2124  hCB=theEnvironment.CoulombBarrier(hC,hB); // Coulomb barrier ^ ^
2125  hKE=hLV.e()-hLV.m(); // Kinetic energy of the QHadron ^ ^
2126  } // ^ ^
2127  if(can && hKE < hCB) // => "Suck Hadron into Quas or Env" case ^ ^
2128  { // ^ ^
2129  if(status) // => "Suck into existing Quasmon" case ^ ^
2130  { // ^ ^
2131  G4QContent tQC=inpH->GetQC()+pQ->GetQC(); // ^ ^
2132  G4LorentzVector tLV=hLV+pQ->Get4Momentum();// ^ ^
2133  pQ->InitQuasmon(tQC,tLV); // Reinitialize the current Quasmon ^ ^
2134 #ifdef debug
2135  G4cout<<"G4QE::HQE:Medium, H#"<<ih<<", QPDG="<<inpH->GetQPDG() // ^ ^
2136  <<",4M="<<inpH->Get4Momentum()<<" is suckedInQ"<<G4endl; // ^ ^
2137 #endif
2138  } // ^ ^
2139  else // => "Suck in the Environment" case ^ ^
2140  { // ^ ^
2141  G4QContent tQC=inpH->GetQC()+theEnvironment.GetQCZNS();// ^ ^
2142  G4LorentzVector tLV=hLV+theEnvironment.Get4Momentum(); // ^ ^
2143  theEnvironment=G4QNucleus(tQC,tLV); // Reinit currentEnvironment ^ ^
2144 #ifdef debug
2145  G4cout<<"G4QE::HQE:Med,H#"<<ih<<",PDG="<<inpH->GetQPDG()<<",4M="//^ ^
2146  <<inpH->Get4Momentum()<<" is suckedInEnvironment"<<G4endl;//^ ^
2147 #endif
2148  } // End of the STATUS IF ^ ^
2149  } // End of the E/Q suck Hdron IF ^ ^
2150  else if(!hF) // => "Hadron can go out" case, skip dec ^ ^
2151  { // ^ ^
2152  G4QHadron* curH = new G4QHadron(inpH); // ^ ^
2153 #ifdef debug
2154  G4LorentzVector ph4M=curH->Get4Momentum(); // 4-mom of the hadron ^ ^
2155  G4double phX=ph4M.x(); // p_x of the hadron ^ ^
2156  G4double phY=ph4M.y(); // p_y of the hadron ^ ^
2157  G4double phZ=ph4M.z(); // p_x of the hadron ^ ^
2158  G4double phCost=phZ/sqrt(phX*phX+phY*phY+phZ*phZ);// Hadr cos(theta)^ ^
2159  G4cout<<"G4QEnv::HadrQE:Medium, H#"<<ih<<",QPDG="<<curH->GetQPDG()//^ ^
2160  <<", 4M="<<ph4M<<", ct="<<phCost<<G4endl; // ^ ^
2161 #endif
2162  G4QContent qhdQC=curH->GetQC(); // QuarkCont of current QHadron ^ ^
2163  G4LorentzVector qhd4M=curH->Get4Momentum(); // 4Mom of currQHadron ^ ^
2164  // ... Here the rescattering starts ... ^ ^
2165  G4int qhdBN=curH->GetBaryonNumber();// Baryon number of the hadron ^ ^
2166  G4bool scat= false; // Scattering happened Flag ^ ^
2167  G4int EnvZ = theEnvironment.GetZ(); // Z of the ResidualEnvironment ^ ^
2168  G4int EnvN = theEnvironment.GetN(); // N of the ResidualEnvironment ^ ^
2169  G4int EnvS = theEnvironment.GetS(); // S of the ResidualEnvironment ^ ^
2170  G4int EnvA = EnvZ + EnvN + EnvS; // A of the ResidualEnvironment ^ ^
2171  G4double EnvM = theEnvironment.GetMZNS(); // ResidualEnvironmentMass ^ ^
2172  G4LorentzVector Env4M= theEnvironment.Get4Momentum(); // ^ ^
2173 #ifdef debug
2174  G4cout<<"=*=>G4QE::HQEnv: Env4M="<<Env4M<<",Z="<<EnvZ<<",N="<<EnvN//^ ^
2175  <<",S="<<EnvS<<G4endl; // ^ ^
2176 #endif
2177  G4int hPDG = curH->GetPDGCode(); // ^ ^
2178  G4LorentzVector h4M = curH->Get4Momentum(); // ^ ^
2179  if(EnvA>1 && qhdBN>-1 && qhdBN<2 && h4M.vect().mag() > 0.000001 && hPDG>111 && //^ ^
2180  hPDG!=222 && hPDG!=333)//** Quasi-free interaction is possible **^ ^
2181  { // ^ ^
2182  --EnvA; // ^ ^
2183  G4double hM2 = h4M.m2(); // ^ ^
2184  G4double hP = h4M.rho(); // ^ ^
2185  G4int pi0F=0; // Pi0 flag ^ ^
2186  if(hPDG==111 || hPDG==222 || hPDG==333) pi0F=hPDG; // ^ ^
2187  if(pi0F) hPDG=211; // ^ ^
2188  pair<G4double,G4double> Xp=theQFScat->FetchElTot(hP,hPDG,false);//^ ^
2189  if(pi0F) // Get Pi+ and make the mean//^ ^
2190  { // ^ ^
2191  hPDG=-211; // ^ ^
2192  pair<G4double,G4double>Y=theQFScat->FetchElTot(hP,hPDG,false);//^ ^
2193  G4double fst=(Xp.first+Y.first)/2;// ^ ^
2194  G4double snd=(Xp.second+Y.second)/2;// ^ ^
2195  Xp.first = fst; // ^ ^
2196  Xp.second = snd; // ^ ^
2197  hPDG=211; // ^ ^
2198  } // ^ ^
2199  G4double XSp = Xp.second; // TotXS hp ^ ^
2200  pair<G4double,G4double> Xn=theQFScat->FetchElTot(hP,hPDG,true);// ^ ^
2201  if(pi0F) // Get Pi+ and make the mean//^ ^
2202  { // ^ ^
2203  hPDG=-211; // ^ ^
2204  pair<G4double,G4double> Y=theQFScat->FetchElTot(hP,hPDG,true);//^ ^
2205  G4double fst=(Xn.first+Y.first)/2;// ^ ^
2206  G4double snd=(Xn.second+Y.second)/2;// ^ ^
2207  Xn.first = fst; // ^ ^
2208  Xn.second = snd; // ^ ^
2209  hPDG=pi0F; // ^ ^
2210  pi0F=0; // ^ ^
2211  } // ^ ^
2212  G4double XSn = Xn.second; // TotXS hn ^ ^
2213  G4double XSZ = XSp * EnvZ; // ^ ^
2214  G4double XSN = XSn * EnvN; // ^ ^
2215  G4double XSA = XSZ + XSN; // ^ ^
2216  if(hM2 > 10000. && XSA > 0.) // One can try to scatter ^ ^
2217  { // ^ ^
2218  G4double Prob=XSA*sqrt(hM2)*G4QThd(EnvA)*proNorm/h4M.e()/EnvA;//^ ^
2219  if(G4UniformRand() < Prob) // Scattering ^ ^
2220  { // ^ ^
2221  G4double XEp = Xp.first; // ElXS hp ^ ^
2222  G4double XEn = Xn.first; // ElXS hn ^ ^
2223  G4double XEZ = XEp * EnvZ; // ^ ^
2224  G4double XEN = XEn * EnvN; // ^ ^
2225  G4double XEA = XEZ + XEN; // ^ ^
2226  G4int NPDG=2112; // Quasi-Elastic on Neutron ^ ^
2227  G4bool flN=true; // ^ ^
2228  G4QNucleus newE(1,0); // Fake Proto ^ ^
2229  G4LorentzVector N4M(0.,0.,0.,0.); // Fake Proto ^ ^
2230  if(G4UniformRand() < XEA/XSA) // Quasi-Elastic ^ ^
2231  { // ^ ^
2232  if(G4UniformRand() < XEZ/XEA) // Quasi-Elastic on Proton ^ ^
2233  { // ^ ^
2234  NPDG= 2212; // ^ ^
2235  flN = false; // ^ ^
2236  } // ^ ^
2237  if(flN) newE=G4QNucleus(EnvZ, EnvN-1, EnvS); // QF n ^ ^
2238  else newE=G4QNucleus(EnvZ-1, EnvN, EnvS); // QF p ^ ^
2239  G4double mT=EnvM - newE.GetMZNS(); // Virtual mass ^ ^
2240  N4M = (mT/EnvM)*Env4M; // ^ ^
2241  newE.Set4Momentum(Env4M-N4M); // ^ ^
2242 #ifdef debug
2243  G4cout<<"==>G4QE::HQE:QEl,NPDG=="<<NPDG<<",N4M="<<N4M // ^ ^
2244  <<",hPDG="<<hPDG<<",h4M="<<h4M<<G4endl; // ^ ^
2245 #endif
2246  pair<G4LorentzVector,G4LorentzVector> RS = // ^ ^
2247  theQFScat->Scatter(NPDG, N4M, hPDG, h4M); // ^ ^
2248 #ifdef debug
2249  G4cout<<"**>G4QE::HQE:QEl,N4M="<<RS.first<<",h4M=" // ^ ^
2250  <<RS.second<<",d="<<N4M+h4M-RS.first-RS.second<<G4endl;//^ ^
2251 #endif
2252  if((RS.first).e() > 0.) // The Elastic Scattering is made //^ ^
2253  { // ^ ^
2254  curH->Set4Momentum(RS.second);// justUpdate, NO scat=true ^ ^
2255  G4QHadron* qfN = new G4QHadron(NPDG, RS.first); // ^ ^
2256  theQHadrons.push_back(qfN);// Fill QFN(delete equivalent) ^ ^
2257  theEnvironment=newE; // *** change Environment *** ^ ^
2258 #ifdef debug
2259  G4cout<<"*>G4QE::HQE:QE,PDG="<<NPDG<<",4M=" // ^ ^
2260  <<RS.first<<",***newEnv***: "<<newE<<G4endl;// ^ ^
2261 #endif
2262  // The totQC & tot4M must be reduced by the qfN ^ ^
2263  tot4M-=RS.first; // current tot4M is reduced ^ ^
2264  if (NPDG==2212) totQC-=protQC; // sub n ^ ^
2265  else if(NPDG==2112) totQC-=neutQC; // sub p ^ ^
2266  else G4cout<<"*W*>G4QE::HQE:QE,Bad PDG="<<NPDG<<G4endl;// ^ ^
2267  } // ^ ^
2268  } // ^ ^
2269  else // Quasi-Inelastic ^ ^
2270  { // ^ ^
2271  if(G4UniformRand() < (XSZ-XEZ)/(XSA-XEA))// QInEl on Proton ^ ^
2272  { // ^ ^
2273  NPDG= 2212; // ^ ^
2274  flN = false; // ^ ^
2275  } // ^ ^
2276  if(flN) newE=G4QNucleus(EnvZ, EnvN-1, EnvS); // QF n ^ ^
2277  else newE=G4QNucleus(EnvZ-1, EnvN, EnvS); // QF p ^ ^
2278  G4double mT=EnvM - newE.GetMZNS(); // Virtual mass ^ ^
2279  N4M = (mT/EnvM)*Env4M; // ^ ^
2280  newE.Set4Momentum(Env4M-N4M); // ^ ^
2281 #ifdef debug
2282  G4cout<<"==>G4QE::HQE:QInEl,NPDG=="<<NPDG<<",N4M="<<N4M // ^ ^
2283  <<",hPDG="<<hPDG<<",h4M="<<h4M<<G4endl; // ^ ^
2284 #endif
2285  G4QHadronVector* Q=theQFScat->InElF(NPDG, N4M, hPDG, h4M);//^ ^
2286  if(Q) // Inelastic reaction succeeded ^ ^
2287  { // ^ ^
2288  theQHadrons.push_back((*Q)[0]); // Fill 1st (del. equiv.) ^ ^
2289  theQHadrons.push_back((*Q)[1]); // Fill 2nd (del. equiv.) ^ ^
2290  theQHadrons.push_back((*Q)[2]); // Fill 3d (del. equiv.) ^ ^
2291  theEnvironment=newE; // *** change Environ *** ^ ^
2292 #ifdef debug
2293  G4cout<<"*>G4QE::HQE:QIE,PDG1="<<(*Q)[0]->GetPDGCode() // ^ ^
2294  <<",4M1="<<(*Q)[0]->Get4Momentum()<<G4endl; // ^ ^
2295  G4cout<<"*>G4QE::HQE:QIE,PDG2="<<(*Q)[1]->GetPDGCode() // ^ ^
2296  <<",4M1="<<(*Q)[1]->Get4Momentum()<<G4endl; // ^ ^
2297  G4cout<<"*>G4QE::HQE:QIE,PDG3="<<(*Q)[2]->GetPDGCode() // ^ ^
2298  <<",4M1="<<(*Q)[2]->Get4Momentum()<<G4endl; // ^ ^
2299  G4cout<<"*>G4QE::HQE:QIE,***NewEnv***: "<<newE<<G4endl;// ^ ^
2300 #endif
2301  scat=true; // Don't fill the Primary ^ ^
2302  delete Q;
2303  } // ^ ^
2304  } // ^ ^
2305  } // ^ ^
2306  } // ^ ^
2307  } // ^ ^
2308  if(!scat) // ^ ^
2309  // ... Rescattering END ........................ ^ ^
2310  theQHadrons.push_back(curH); // Fill hadronCopy (delete equivalent) ^ ^
2311  totQC-=qhdQC; // Update QC of Env + Quasmons ^ ^
2312  tot4M-=qhd4M; // Update 4Mom of Env + Quasmons ^ ^
2313  } // ^ ^
2314  } // ==> End of the LOOP over outQHadrons ^ ^
2315  pQ->ClearOutput(); // Hadrons are filled, Clear Frag-out <-<-^ ^
2316  count3=0; // Reset counter of empty hadronizations ^
2317  //c3Max=1; // Reduce repetition Max to accelerate ^
2318  first=false; // First hadronization is for sure is over ^
2319  } // ^
2320  else count3++; // Increment counter of empty hadronizations^
2321  } // ^
2322  else if(status<0||status==2) // => "PANIC or NOTHING was done" case ^
2323  { // ^
2324 #ifdef debug
2325  G4cout<<"G4QE::HQE:***PANIC***,status="<<status<<",nC="<<nCount<<G4endl; // ^
2326 #endif
2327  ++nCount; // ^
2328  if(eCount==1 && status<0 && CheckGroundState(pQ,true))// Correct & Finish ^
2329  { // ^
2330  for_each(output->begin(), output->end(), DeleteQHadron()); // ->->->----->^
2331  output->clear(); // ^
2332  delete output; // >----------------->--------------------->^
2333  pQ->KillQuasmon(); // If BackFusion succeeded, kill the Quasmon^
2334  delete pQ;
2335  eCount--; // Reduce the number of the living Quasmons ^
2336  return theQHadrons; // ^
2337  } // ^
2338  else if(status<0&&nHadrons) // This is just a confusion in the status...^
2339  { // ^
2340  G4cerr<<"***G4QEnv::HadrQE: nH="<<nHadrons<<"< status="<<status<<G4endl;//^
2341  for_each(output->begin(), output->end(), DeleteQHadron()); // -->-->-->---^
2342  output->clear(); // ^
2343  delete output; // >------------------->------------------->^
2344  G4Exception("G4QEnvironment::HadronizeQEnvironment()", // ^
2345  "HAD_CHPS_0003", JustWarning, "Do Nothing Er"); // ^
2346  } // ^
2347  else if(status==2 && eCount==1 && cAN<mcAN && envM>500.)// Add N from E to Q^
2348  { // ^
2349 #ifdef debug
2350  G4cout<<"G4QE::HQE:E="<<theEnvironment<<",M="<<envM<<",c="<<cAN<<G4endl;//^
2351 #endif
2352  cAN++; // Increment the counter of absorptions ^
2353  G4int envPDG = theEnvironment.GetPDG(); // PDGCode of the NuclQEnvironment^
2354  env4M=theEnvironment.Get4Momentum(); // 4mom of the NucEnv ^
2355  G4int envN=theEnvironment.GetN(); // N of Env ^
2356  G4int envZ=theEnvironment.GetZ(); // Z of Env ^
2357  G4int resPDG=envPDG-1; // Residual for the neutron (prototype) ^
2358  G4QContent nucQC=neutQC; // Nucleon Quark Content ^
2359  if ( envN && (envN+envZ)*G4UniformRand() > envZ ) // Change to a proton ^
2360  { // ^
2361  resPDG=envPDG-1000; // new PDG for the Environment ^
2362  nucQC=protQC; // proton QContent ^
2363  } // ^
2364 #ifdef debug
2365  G4cout<<"G4QE::HQE:P,eZ="<<envZ<<",eN="<<envN<<",rPDG="<<resPDG<<G4endl;//^
2366 #endif
2367  G4QNucleus resNuc(resPDG); // Create the residual nucleus (future Env) ^
2368  G4double resM=resNuc.GetGSMass(); // Mass of the residual nucleus ^
2369  G4double eM=theEnvironment.GetGSMass(); // Mass of the current environment^
2370  G4double nucM=eM-resM; // Effective mass of theNucleon ^
2371  G4LorentzVector res4M(0.,0.,0.,resM); // Prototype of newEnv4M (at rest)^
2372  G4LorentzVector nuc4M(0.,0.,0.,nucM); // Prototype of newEnv4M (at rest)^
2373  if(std::fabs(env4M.e()-eM) > 0.001) // the Environment is not at rest ^
2374  { // ^
2375  res4M=(resM/eM)*env4M; // Proportional 4M for residEnv ^
2376  nuc4M=(nucM/eM)*env4M; // Proportional 4M for effNucleon ^
2377  } // ^
2378  theEnvironment=G4QNucleus(res4M,resPDG);// Update the Environment ^
2379  theQuasmons[0]->IncreaseBy(nucQC,nuc4M);// Update the Only Quasmon ^
2380 #ifdef debug
2381  G4cout<<"G4QE::HQE:P,Q="<<nucQC<<nuc4M<<",env="<<theEnvironment<<G4endl;//^
2382 #endif
2383  } // ^
2384  else if(status==2&&nCount>nCnMax)// Treat PANIC for stat=2 (NothingWasDone) ^
2385  { // ^
2386 #ifdef debug
2387  G4cout<<"G4QE::HQE:PANIC,nC="<<nCount<<">"<<nCnMax<<G4endl; // ^
2388 #endif
2389  G4QContent qQC=pQ->GetQC(); // QuarkContent of the Quasmon ^
2390  G4int pqC=qQC.GetCharge(); // Charge (nP) of the Current Quasmon ^
2391  G4int pqS=qQC.GetStrangeness(); // Strangeness (nL) of theCurrQuasmon^
2392  G4int pqB=qQC.GetBaryonNumber(); // BaryNumber of the CurrentQuasmon ^
2393  G4LorentzVector cq4M=pQ->Get4Momentum(); // 4Mom of the Current Quasmon ^
2394  G4double cqMass=cq4M.m(); // Real Mass of the current Quasmon ^
2395  G4double fqMass=G4QPDGCode(22).GetNuclMass(pqC,pqB-pqC-pqS,pqS);//CQ FreeM^
2396 #ifdef edebug
2397  G4cout<<"G4QEnv::HQE:M="<<cqMass<<">fM="<<fqMass<<",S="<<pqS<<",C="<<pqC//^
2398  <<",ePDG="<<theEnvironment.GetPDG()<<",qQC="<<qQC<<",eC="<<eCount //^
2399  <<G4endl; // ^
2400 #endif
2401  if(pqB>0&&pqS<0&&cqMass>fqMass)// "AntiStrangeNucleus-Chipolino" case ^
2402  { // ^
2403  G4QHadron* nuclQ = new G4QHadron(qQC,cq4M);// Hadron for AntiStrangeNuc.^
2404  theEnvironment.DecayAntiStrange(nuclQ,&theQHadrons);// AntiStrange(D.E.)^
2405  pQ->KillQuasmon(); // If BackFusion succeeded, kill theQuasmon ^
2406 #ifdef edebug
2407  G4cout<<"G4QEnv::HQE:Status after kill (#"<<jq<<")="<<pQ->GetStatus()// ^
2408  <<", nH="<<theQHadrons.size()<<G4endl; // ^
2409 #endif
2410  tot4M-=cq4M; // Update TotalResidNucleus for hadronizPro.^
2411  totQC-=qQC; // Update total QC for the HadronizationPro.^
2412  eCount--; // Reduce the number of the living Quasmons ^
2413  } // ^
2414  else if(theEnvironment.GetPDG()!=NUCPDG) // ==> "NuclearEnvironment" case ^
2415  { // ^
2416  if(eCount>1) // ^
2417  { // ^
2418 #ifdef fdebug
2419  G4cout<<"G4QE::HQE:TOTEVAP tPDG="<<totPDG<<",t4M="<<tot4M<<G4endl; // ^
2420 #endif
2421  G4QHadron* evH = new G4QHadron(totQC,tot4M); // Create Hadron-ResidNuc^
2422  CleanUp(); // ^
2423  EvaporateResidual(evH); // Evaporate ResNuc (delete equivalemt) ^
2424  for_each(output->begin(), output->end(), DeleteQHadron());// >--------^
2425  output->clear(); // ^
2426  delete output; // >---------->----------->---------------->^
2427  return theQHadrons; // ^
2428  } // ^
2429  G4LorentzVector t4M=cq4M+theEnvironment.Get4Momentum(); // Q+E tot4Mom ^
2430  G4double tM=t4M.m(); // Real total (Quasmon+Environment) mass ^
2431  envQC=theEnvironment.GetQCZNS(); // QuarkCont of NucEnviron ^
2432  G4QContent curQC=envQC+qQC; // Total Quark Content ^
2433  G4QNucleus curE(curQC); // Pseudo nucleus for the Total System ^
2434  G4double curM=curE.GetGSMass();// min mass of the Total System ^
2435 #ifdef edebug
2436  G4cout<<"G4QEnv::HQE:Q#"<<jq<<",tM="<<tM<<">gsM="<<curM<<curE<<G4endl;//^
2437 #endif
2438  if(tM<curM) // ^
2439  {
2440  G4int qPDG=qQC.GetZNSPDGCode();// PDG Code of the Quasmon ^
2441  G4double qMass=G4QPDGCode(qPDG).GetMass(); // GroundStM of theQuasmon ^
2442 #ifdef edebug
2443  G4cout<<"G4QE::HQE:nQ="<<nQuasmons<<",eC="<<eCount<<",qPDG="<<qPDG // ^
2444  <<",qM="<<qMass<<",eM="<<envM<<",tM="<<tM<<",Q+E="<<qMass+envM//^
2445  <<G4endl; // ^
2446 #endif
2447  if(eCount==1&&qPDG&&qMass&&tM>qMass+envM)//==> Q+E decay for one Quasm^
2448  //if(nQuasmons==1 && qPDG && qMass && tM>qMass+envM) // ==> Q+E decay ^
2449  { // ^
2450  G4int envPDG = theEnvironment.GetPDG(); // PDGCode of the NuclQEnv. ^
2451 #ifdef edebug
2452  G4cout<<"G4QEnv::HadrQEnv: Q+E decay, nQ=1, qPDG=="<<qPDG<<G4endl;//^
2453 #endif
2454  // => "Quasmon-Chipolino or Environment-Dibaryon" case ^
2455  if(qPDG==10 || qPDG==92000000 || qPDG==90002000 || qPDG==90000002)//^
2456  { // ^
2457  G4QPDGCode h1QPDG=nQPDG; // QPDG of the first hadron ^
2458  G4double h1M =mNeut; // Mass of the first hadron ^
2459  G4QPDGCode h2QPDG=h1QPDG;// QPDG of the second hadron ^
2460  G4double h2M =mNeut; // Mass of the second hadron ^
2461  if(qPDG==10) // CHIPOLINO decay case ^
2462  { // ^
2463  G4QChipolino QChip(qQC);// define the Quasmon as a Chipolino ^
2464  h1QPDG=QChip.GetQPDG1();// QPDG of the first hadron ^
2465  h1M =h1QPDG.GetMass();// Mass of the first hadron ^
2466  h2QPDG=QChip.GetQPDG2();// QPDG of the second hadron ^
2467  h2M =h2QPDG.GetMass();// Mass of the second hadron ^
2468  } // ^
2469  else if(qPDG==90002000) // DiProton decay case ^
2470  { // ^
2471  h1QPDG=pQPDG; // QPDG of the first hadron ^
2472  h1M =mProt; // Mass of the first hadron ^
2473  h2QPDG=h1QPDG; // QPDG of the second hadron ^
2474  h2M =mProt; // Mass of the second hadron ^
2475  } // ^
2476  else if(qPDG==92000000) // Two lambdas case ^
2477  { // ^
2478  h1QPDG=lQPDG; // QPDG of the first hadron ^
2479  h1M =mLamb; // Mass of the first hadron ^
2480  h2QPDG=h1QPDG; // QPDG of the second hadron ^
2481  h2M =mLamb; // Mass of the second hadron ^
2482  G4double ddMass=totMass-envM; // Free CM energy ^
2483  if(ddMass>mSigZ+mSigZ) // Sigma0+Sigma0 is possible ^
2484  { // @@ Only two particles PS is used ^
2485  G4double dd2=ddMass*ddMass; // Squared free energy ^
2486  G4double sma=mLamb+mLamb; // Lambda+Lambda sum ^
2487  G4double pr1=0.; // Prototype to avoid sqrt(-) ^
2488  if(ddMass>sma) pr1=sqrt((dd2-sma*sma)*dd2); // Lamb+Lamb PS ^
2489  sma=mLamb+mSigZ; // Lambda+Sigma0 sum ^
2490  G4double smi=mSigZ-mLamb; // Sigma0-Lambda difference ^
2491  G4double pr2=pr1; // Prototype of +L+S0 PS ^
2492  if(ddMass>sma&&ddMass>smi) // ^
2493  pr2+=sqrt((dd2-sma*sma)*(dd2-smi*smi)); // ^
2494  sma=mSigZ+mSigZ; // Sigma0+Sigma0 sum ^
2495  G4double pr3=pr2; // Prototype of +Sigma0+Sigma0 PS ^
2496  if(ddMass>sma) pr3+=sqrt((dd2-sma*sma)*dd2); // ^
2497  G4double hhRND=pr3*G4UniformRand(); // Randomize PS ^
2498  if(hhRND>pr2) // --> "ENnv+Sigma0+Sigma0" case ^
2499  { // ^
2500  h1QPDG=s0QPDG; // QPDG of the first hadron ^
2501  h1M =mSigZ; // Mass of the first hadron ^
2502  h2QPDG=h1QPDG; // QPDG of the second hadron ^
2503  h2M =mSigZ; // Mass of the second hadron ^
2504  } // ^
2505  else if(hhRND>pr1)// --> "ENnv+Sigma0+Lambda" case ^
2506  { // ^
2507  h1QPDG=s0QPDG; // QPDG of the first hadron ^
2508  h1M =mSigZ; // Mass of the first hadron ^
2509  } // ^
2510  } // ^
2511  else if(ddMass>mSigZ+mLamb) // Lambda+Sigma0 is possible ^
2512  { // @@ Only two particles PS is used ^
2513  G4double dd2=ddMass*ddMass; // Squared free energy ^
2514  G4double sma=mLamb+mLamb; // Lambda+Lambda sum ^
2515  G4double pr1=0.; // Prototype to avoid sqrt(-) ^
2516  if(ddMass>sma) pr1=sqrt((dd2-sma*sma)*dd2); // Lamb+Lamb PS ^
2517  sma=mLamb+mSigZ; // Lambda+Sigma0 sum ^
2518  G4double smi=mSigZ-mLamb; // Sigma0-Lambda difference ^
2519  G4double pr2=pr1; //+L+S0 PS ^
2520  if(ddMass>sma && ddMass>smi) // ^
2521  pr2+=sqrt((dd2-sma*sma)*(dd2-smi*smi)); // ^
2522  if(pr2*G4UniformRand()>pr1) // --> "ENnv+Sigma0+Lambda" case ^
2523  { // ^
2524  h1QPDG=s0QPDG; // QPDG of the first hadron ^
2525  h1M =mSigZ; // Mass of the first hadron ^
2526  } // ^
2527  } // ^
2528  } // ^
2529  if(h1M+h2M+envM<totMass) // => "Three particles decay" case ^
2530  { // ^
2531  G4LorentzVector h14M(0.,0.,0.,h1M); // ^
2532  G4LorentzVector h24M(0.,0.,0.,h2M); // ^
2533  G4LorentzVector e4M(0.,0.,0.,envM); // ^
2534  if(!G4QHadron(tot4M).DecayIn3(h14M,h24M,e4M)) // ^
2535  { // ^
2536  G4ExceptionDescription ed; // ^
2537  ed << "QChip+E DecIn3 error: (0)tM=" << tot4M.m() // ^
2538  << "->h1=" << h1QPDG << "(" << h1M << ")+h2=" // ^
2539  << h1QPDG << "(" << h2M << ")+envM=" << envM // ^
2540  << "==" << h1M+h2M+envM << G4endl; // ^
2541  G4Exception("G4QEnvironment::HadronizeQEnvironment()", // ^
2542  "HAD_CHPS_0004", FatalException, ed); // ^
2543  } // ^
2544  G4QHadron* h1H = new G4QHadron(h1QPDG.GetPDGCode(),h14M); // ^
2545  theQHadrons.push_back(h1H); // (delete equivalent) ^
2546 #ifdef debug
2547  G4cout<<"G4QE::HQE:(1) H1="<<h1QPDG<<h14M<<G4endl; // ^
2548 #endif
2549  G4QHadron* h2H = new G4QHadron(h2QPDG.GetPDGCode(),h24M); // ^
2550  theQHadrons.push_back(h2H); // (delete equivalent) ^
2551 #ifdef debug
2552  G4cout<<"G4QE::HQE:(1) H2="<<h2QPDG<<h24M<<G4endl; // ^
2553 #endif
2554  G4QHadron* qeH = new G4QHadron(envPDG,e4M); // ^
2555  theQHadrons.push_back(qeH); // (delete equivalent) ^
2556 #ifdef debug
2557  G4cout<<"G4QE::HQE:(1) QEnv="<<envPDG<<e4M<<G4endl; // ^
2558 #endif
2559  } // ^
2560  else // Try to recover ^
2561  { // ^
2562  //if(eCount==1&&CheckGroundState(pQ,true)) // @@ BackFusion ^
2563  if(eCount==1&&CheckGroundState(pQ))// BackFusion attempt ^
2564  { // ^
2565  pQ->KillQuasmon();// ?? ^
2566  eCount--; // Reduce a#of theLivingQuasmons ^
2567  for_each(output->begin(),output->end(),DeleteQHadron()); // ^
2568  output->clear(); // -->-->-->-->-->-->-->-->-->-->-->-->-->--+
2569  delete output; // >---------------->---------------------->+
2570  return theQHadrons; // ^
2571  } // ^
2572  for_each(output->begin(),output->end(),DeleteQHadron()); //-->--+
2573  output->clear(); // -->-->-->-->-->-->-->-->-->-->-->-->-->--+
2574  delete output; // >---------------->------------->-------->+
2575 #ifdef fdebug
2576  G4cout<<"--Warning--G4QE::HQE:tM="<<tot4M.m()<<"< h1="<<h1QPDG//^
2577  <<"(M="<<h1M<<")+h2="<<h1QPDG<<"(M="<<h2M<<")+EM="<<envM//^
2578  <<"="<<h1M+h2M+envM<<G4endl; // ^
2579  //throw G4QException("G4QEnv::HQE:(0)Chi+Env mass > totMass");//^
2580 #endif
2581  CleanUp(); // ^
2582  G4QHadron* evH = new G4QHadron(totQC,tot4M);// ResidualNuclHadr ^
2583  EvaporateResidual(evH); // Evaporate residual (del. equiv.) ^
2584  return theQHadrons; // ^
2585  } // ^
2586  } // ^
2587  else // => "Two particles decay" case ^
2588  { // ^
2589  G4LorentzVector fq4M(0.,0.,0.,qMass); // ^
2590  G4LorentzVector qe4M(0.,0.,0.,envM); // ^
2591  if(!G4QHadron(tot4M).RelDecayIn2(fq4M,qe4M,cq4M,1.,1.))//Q ch.dir.^
2592  { // ^
2593  G4cerr<<"***G4QEnv::HadQE:(0)tM="<<tot4M.m()<<"-> qPDG="<<qPDG//^
2594  <<"(M="<<qMass<<") + envM="<<envM<<")"<<G4endl; //^
2595  for_each(output->begin(),output->end(),DeleteQHadron()); //-->->+
2596  output->clear(); // -->-->-->-->-->-->-->-->-->-->-->-->-->->+
2597  delete output; // >----------------->--------------------->+
2598  // throw G4QException("***G4QEnv::HadrQEnv: Q+Env DecIn2 error");//^
2599  G4Exception("G4QEnvironment::HadronizeQEnvironment()",
2600  "HAD_CHPS_0005", FatalException,
2601  "Q+Env DecIn2 error");
2602  } // ^
2603  G4QHadron* qH = new G4QHadron(qPDG,fq4M);// the out going Quasmon ^
2604  theQHadrons.push_back(qH); // (delete equivalent) ^
2605 #ifdef debug
2606  G4cout<<"G4QE::HQE:QuasmH="<<qPDG<<fq4M<<G4endl; // ^
2607 #endif
2608  G4QHadron* qeH = new G4QHadron(envPDG,qe4M);//theRecoilEnvironment^
2609 #ifdef debug
2610  G4cout<<"G4QE::HQE:EnvironH="<<envPDG<<qe4M<<G4endl; // ^
2611 #endif
2612  if(envPDG==92000000||envPDG==90002000||envPDG==90000002) // ^
2613  theEnvironment.DecayDibaryon(qeH,&theQHadrons); // ^
2614  else theQHadrons.push_back(qeH);// (del.equiv.) *** this too *** ^
2615  } // ^
2616  for_each(output->begin(),output->end(),DeleteQHadron());//--->-->-->+
2617  output->clear(); // ^
2618  delete output; // >--------------->----------------->----->+
2619  CleanUp(); // Clean up Environ and Quasmon ^
2620  return theQHadrons; // Finish the hadronization process ^
2621  } // ^
2622  else status=-1; // Q+E && totM below MassShell - PANIC ^
2623  } // ^
2624  else if(eCount>1&&(nCount>nCnMax||theEnvironment.GetA()<2))// 2Quasmons ^
2625  { // ^
2626  theEnvironment.InitByPDG(NUCPDG);// KillEnvironment(@@ Q's? CleanUp)) ^
2627 #ifdef fdebug
2628  G4cout<<"G4QEnv::HQE:Evaporate Env+Quasm Env="<<curE<<G4endl;// ^
2629 #endif
2630  G4QHadron* nucQE = new G4QHadron(curQC,t4M);// Hadron for Quasm+Envir.^
2631  EvaporateResidual(nucQE); // Evaporate residual Quasm+Env(del.equiv.) ^
2632  pQ->KillQuasmon(); // If BackFusion succeeded, kill theQuasmon ^
2633 #ifdef edebug
2634  G4cout<<"G4QEnv::HQE:StatusAfterKill (#"<<jq<<")="<<pQ->GetStatus()// ^
2635  <<", nH="<<theQHadrons.size()<<G4endl; // ^
2636 #endif
2637  tot4M-=t4M; // Update TotalResidNucleus for hadronizPro.^
2638  totQC-=curQC; // Update total QC for the HadronizationPro.^
2639  eCount--; // Reduce the number of the living Quasmons ^
2640  } // ^
2641  if(eCount==1 && tM>=curM) //==>for one Quasmon evaporate ResTotN ^
2642  { // ^
2643  theEnvironment.InitByPDG(NUCPDG);// Cancele the Environment ^
2644  G4int ttPDG=totQC.GetSPDGCode(); // Total PDG Code (10 - Chipolino) ^
2645 #ifdef pcdebug
2646  G4cout<<"G4QE::HQE:BefEv 4M="<<tot4M<<",QC="<<totQC<<ttPDG<<G4endl;// ^
2647 #endif
2648  for_each(output->begin(),output->end(),DeleteQHadron()); //-->-->-->->+
2649  output->clear(); // ^
2650  delete output; // >------------>-------------------------->+
2651  CleanUp(); // Clean up the Environ and Quasmons ^
2652  G4int ttBN=totQC.GetBaryonNumber(); // ^
2653  if(ttPDG==10&&ttBN<2) // Chipolino case ^
2654  { // ^
2655  G4QChipolino QCh(totQC);// define the TotalResidual as a Chipolino ^
2656  G4QPDGCode h1QPDG=QCh.GetQPDG1(); // QPDG of the first hadron ^
2657  G4double h1M =h1QPDG.GetMass();// Mass of the first hadron ^
2658  G4QPDGCode h2QPDG=QCh.GetQPDG2(); // QPDG of the second hadron ^
2659  G4double h2M =h2QPDG.GetMass();// Mass of the second hadron ^
2660  G4double ttM=tot4M.m(); // Mass of the Chipolino ^
2661  if(h1M+h2M<ttM) // Two particles decay of Chipolino is pos. ^
2662  { // ^
2663  G4LorentzVector h14M(0.,0.,0.,h1M); // ^
2664  G4LorentzVector h24M(0.,0.,0.,h2M); // ^
2665  if(!G4QHadron(tot4M).DecayIn2(h14M,h24M)) // ^
2666  { // ^
2667  G4ExceptionDescription ed; // ^
2668  ed << "QChip (1) DecIn2 error: tM=" << ttM << "->h1=" // ^
2669  << h1QPDG << "(" << h1M << ")+h2=" << h1QPDG // ^
2670  << "(" << h2M << ")=" << h1M+h2M << G4endl; // ^
2671  G4Exception("G4QEnvironment::HadronizeQEnvironment()", // ^
2672  "HAD_CHPS_0006", FatalException, ed); // ^
2673  } // ^
2674  G4QHadron* h1H = new G4QHadron(h1QPDG.GetPDGCode(),h14M); // ^
2675  theQHadrons.push_back(h1H); // (delete equivalent) ^
2676 #ifdef debug
2677  G4cout<<"G4QE::HQE: QCip-> H1="<<h1QPDG<<h14M<<G4endl; // ^
2678 #endif
2679  G4QHadron* h2H = new G4QHadron(h2QPDG.GetPDGCode(),h24M); // ^
2680  theQHadrons.push_back(h2H); // (delete equivalent) ^
2681 #ifdef debug
2682  G4cout<<"G4QE::HQE: QChip->H2="<<h2QPDG<<h24M<<G4endl; // ^
2683 #endif
2684  } // ^
2685  else // ^
2686  { // ^
2687  G4ExceptionDescription ed; // ^
2688  ed << " QChip (2) DecIn2 error: tM=" << ttM << totQC << "->h1=" //^
2689  << h1QPDG << "(" << h2M << "=" << h1M+h2M << G4endl; // ^
2690  G4Exception("G4QEnvironment::HadronizeQEnvironment()", // ^
2691  "HAD_CHPS_0007", FatalException, ed); // ^
2692  } // ^
2693  } // ^
2694  else // ^
2695  { // ^
2696 #ifdef edebug
2697  if(ttPDG<80000000&&ttBN<1) // ^
2698  G4cout<<"---Warning---G4QE::HQE: NotNuc, tPDG="<<ttPDG<<G4endl;// ^
2699 #endif
2700  G4QHadron* evH = new G4QHadron(totQC,tot4M);// Hadron for ResidNucl ^
2701  EvaporateResidual(evH); // Evaporate residual (del.equiv.) ^
2702  } // ^
2703  return theQHadrons; // ^
2704  } // ^
2705  else if(eCount==1 && CheckGroundState(pQ,true)) // Correct and Finish ^
2706  { // ^
2707  for_each(output->begin(), output->end(), DeleteQHadron()); // -->-->->+
2708  output->clear(); // ^
2709  delete output; // >------------------->---------------->-->+
2710  pQ->KillQuasmon(); // If BackFusion succeeded, kill Quasm ^
2711  delete pQ;
2712  eCount--; // Reduce a#of the living Quasmons ^
2713  return theQHadrons; // ^
2714  } // ^
2715  } // ^
2716  else // "Vacuum" case ^
2717  { // ^
2718  G4QPDGCode QPDGQ=pQ->GetQPDG(); // QPDG Code for the Quasmon ^
2719  G4int PDGQ=QPDGQ.GetPDGCode(); // PDG Code of the QUASMON ^
2720 #ifdef edebug
2721  G4cout<<"G4QEnv::HadrQEnv: vacuum PDGQ="<<PDGQ<<G4endl; // ^
2722 #endif
2723  if(!PDGQ) status=-1; // Unknown Quasmon in Vaquum - PANIC ^
2724  // @@ There still can be a case for 2pSigma+ or 2nSigma- (PDGCode?) ^
2725  else if(PDGQ==3112||PDGQ==3222||PDGQ==90999001||PDGQ==91000999)// S+/S- ^
2726  { // ^
2727 #ifdef edebug
2728  G4cout<<"G4QEnv::HadrQEnv:Sigma Mass="<<cqMass<<G4endl; // ^
2729 #endif
2730  G4double hyM=mNeut; // Prototype of the hyperon mass ^
2731  G4int hyPDG=2112; // Prototype of the hyperon PDG Code ^
2732  G4double pigM=mPi; // Prototype of the gamma/pion mass ^
2733  G4int pigPDG=-211; // Prototype of the gamma/pion PDG Code ^
2734  if(PDGQ==3112||PDGQ==90999001) // --> "Sigma-" case ^
2735  { // ^
2736  if(cqMass>mPi+mLamb) // "Lambda + Pi- is possible" case ^
2737  { // ^
2738  hyM = mLamb; // Lambda mass ^
2739  hyPDG = 3122; // Lambda PDG Code ^
2740  } // ^
2741  else if(cqMass>mSigM) // "Sigma- gamma decay" case ^
2742  { // ^
2743  hyM=mSigM; // Sigma- mass ^
2744  hyPDG=3112; // Sigma- PDG Code ^
2745  pigM=0.; // Gamma mass ^
2746  pigPDG=22; // Gamma PDG Code ^
2747  } // ^
2748  } // ^
2749  else if(PDGQ==3222||PDGQ==91000999) // --> "Sigma+" case ^
2750  { // ^
2751  pigPDG= 211; // Pi+ PDG Code ^
2752  if(cqMass>mPi+mLamb) // --- "Lambda + Pi+ is possible" case ^
2753  { // ^
2754  hyM = mLamb; // Lambda mass ^
2755  hyPDG = 3122; // Lambda PDG Code ^
2756  pigM = mPi; // Pi+ mass ^
2757  pigPDG= 211; // Pi+ PDG Code ^
2758  } // ^
2759  else if(cqMass>mSigP) // "Sigma- gamma decay" case ^
2760  { // ^
2761  hyM=mSigP; // Sigma+ mass ^
2762  hyPDG=3222; // Sigma+ PDG Code ^
2763  pigM=0.; // Gamma mass ^
2764  pigPDG=22; // Gamma PDG Code ^
2765  } // ^
2766  else if(cqMass>mPi0+mProt&&G4UniformRand()>.5) // "P + Pi0" case ^
2767  { // ^
2768  hyM = mProt; // Proton mass ^
2769  hyPDG = 2212; // Proton PDG Code ^
2770  pigM = mPi0; // Pi0 mass ^
2771  pigPDG= 111; // Pi0 PDG Code ^
2772  } // ^
2773  else if(cqMass<mPi+mNeut)// "P+gamma" case as "N+Pi+" is impossible ^
2774  { // ^
2775  hyM = mProt; // Proton mass ^
2776  hyPDG = 2212; // Proton PDG Code ^
2777  pigM=0.; // Gamma mass ^
2778  pigPDG=22; // Gamma PDG Code ^
2779  } // ^
2780  // othing should be done for "N + P+" case ^
2781  } // ^
2782  G4LorentzVector b4Mom(0.,0.,0.,hyM); // Hyperon mass ^
2783  G4LorentzVector m4Mom(0.,0.,0.,pigM);// pion/gamma mass ^
2784  if(!G4QHadron(cq4M).DecayIn2(b4Mom, m4Mom)) // "DecayIn2 failed" case ^
2785  { // ^
2786  G4cout<<"---Warning---G4QE::HQE:H="<<hyPDG<<"(m="<<hyM<<")+G/Pi=" //^
2787  <<pigPDG<<"(m="<<pigM<<")="<<hyM+pigM<<">"<<cqMass<<G4endl; //^
2788  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC ^
2789  CleanUp(); // ^
2790  if(!CheckGroundState(quasH,true)) // Last posibility to correct ^
2791  { // ^
2792  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // ^
2793  theQHadrons.push_back(hadr); // Cor or fill as It Is ^
2794 #ifdef debug
2795  G4cout<<"-Warn-G4QE::HQE:Sig,QC="<<totQC<<",4M="<<tot4M<<G4endl;//^
2796 #endif
2797  //throw G4QException("G4QEnvironment::HadronizeQEnv:Sig error");//^
2798  } // ^
2799  delete quasH; // Delete the temporary fake Quasmon ^
2800  return theQHadrons; // ^
2801  } // ^
2802 #ifdef debug
2803  G4cout<<"G4QEnv::HadronizeQEnv: Sigma="<<PDGQ<<cq4M<<" -> Hyperon="// ^
2804  <<hyPDG<<b4Mom<<" + Gamma/Pi="<<pigPDG<<m4Mom<<G4endl; // ^
2805 #endif
2806  G4QHadron* curBar = new G4QHadron(hyPDG,b4Mom); // ^
2807  theQHadrons.push_back(curBar); // Fill the Hyperon (delete equivalent)^
2808  G4QHadron* curMes = new G4QHadron(pigPDG,m4Mom); // ^
2809  theQHadrons.push_back(curMes); // Fill the gam/pi (delete equivalent) ^
2810  pQ->KillQuasmon(); // Make done the current Quasmon ^
2811  tot4M-=cq4M; // Update theTotalResidNucl of HadrPr. ^
2812  totQC-=qQC; // Update total residual QC of HadrPr. ^
2813  eCount--; // Reduce a#of the living Quasmons ^
2814  } // ^
2815  else if(PDGQ==90999002||PDGQ==91001999) // pS+/nS- ^
2816  { // ^
2817 #ifdef edebug
2818  G4cout<<"G4QEnv::HadrQEnv: Nucleon+Sigma Mass="<<cqMass<<G4endl; // ^
2819 #endif
2820  G4bool dinFlag = false; // Di-nucleon flag ^
2821  G4double hyM=mSigM; // Prototype of the hyperon mass (n+Sigma-) ^
2822  G4int hyPDG=3112; // Prototype of the hyperon PDG Code ^
2823  G4double pigM=mNeut; // Prototype of the nucleon mass ^
2824  G4int pigPDG=2112; // Prototype of the nucleon PDG Code ^
2825  if (PDGQ==90999002) // --> "n+Sigma-" case ^
2826  { // ^
2827  if(cqMass<mNeut+mSigM) // ----> "DiNeutron+Pi-" case ^
2828  { // ^
2829  dinFlag = true; // For the final decay ^
2830  hyM=mNeut+mNeut; // Di-neutron ^
2831  hyPDG=2112; // Neutron PDG Code ^
2832  pigM=mPi; // Pi- mass ^
2833  pigPDG=-211; // Pi- PDG Code ^
2834  } // ^
2835  } // ^
2836  else if(PDGQ==91001999) // --> "p+Sigma+" case ^
2837  { // ^
2838  hyM=mSigP; // Sigma+ ^
2839  hyPDG=3222; // PDG Code of Sigma+ ^
2840  pigM=mProt; // Proton mass ^
2841  pigPDG=2212; // PDG Code of proton ^
2842  if(cqMass<mProt+mSigP) // ----> "Proton+Proton" case ^
2843  { // ^
2844  hyM=mProt; // Proton mass ^
2845  hyPDG=2212; // Proton PDG Code ^
2846  pigM=mProt; // Proton mass ^
2847  pigPDG=2212; // Proton PDG Code ^
2848  } // ^
2849  } // ^
2850  G4LorentzVector b4Mom(0.,0.,0.,hyM); // Hyperon (di-nucleon) mass ^
2851  G4LorentzVector m4Mom(0.,0.,0.,pigM);// Nucleon (pion) mass ^
2852  if(!G4QHadron(cq4M).DecayIn2(b4Mom, m4Mom)) // "DecayIn2 failed" case ^
2853  { // ^
2854  G4cout<<"--Warning--G4QE::HQE:S/D="<<hyPDG<<"(m="<<hyM<<")+N/Pi=" //^
2855  <<pigPDG<<"(m="<<pigM<<")="<<hyM+pigM<<">"<<cqMass<<G4endl; //^
2856  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC ^
2857  CleanUp(); // ^
2858  if(!CheckGroundState(quasH,true)) // Last posibility to correct ^
2859  { // ^
2860  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // ^
2861  theQHadrons.push_back(hadr); // Cor or fill as It Is ^
2862 #ifdef debug
2863  G4cout<<"-Warn-G4QE::HQE:Sig,QC="<<totQC<<",4M="<<tot4M<<G4endl;//^
2864 #endif
2865  //throw G4QException("G4QEnvironment::HadronizeQEnv:Sig error");//^
2866  } // ^
2867  delete quasH; // Delete the temporary fake Quasmon ^
2868  return theQHadrons; // ^
2869  } // ^
2870 #ifdef debug
2871  G4cout<<"G4QEnv::HadronizeQEnv: NSigma="<<PDGQ<<cq4M<<"-> Sigma/dN="//^
2872  <<hyPDG<<b4Mom<<" + N/Pi="<<pigPDG<<m4Mom<<G4endl; // ^
2873 #endif
2874  if(dinFlag) b4Mom/=2.; // Split the 4-mom for the dinucleon ^
2875  G4QHadron* curBar = new G4QHadron(hyPDG,b4Mom); // ^
2876  theQHadrons.push_back(curBar); // Fill the Hyperon (delete equivalent)^
2877  if(dinFlag) // ^
2878  { // ^
2879  G4QHadron* secBar = new G4QHadron(hyPDG,b4Mom);// Cre. 2-nd nucleon ^
2880  theQHadrons.push_back(secBar);// Fill 2-nd nucleon (delete equiv.) ^
2881  } // ^
2882  G4QHadron* curMes = new G4QHadron(pigPDG,m4Mom); // ^
2883  theQHadrons.push_back(curMes); // Fill the gam/pi (delete equivalent) ^
2884  pQ->KillQuasmon(); // Make done the current Quasmon ^
2885  tot4M-=cq4M; // Update theTotalResidNucl of HadrPr. ^
2886  totQC-=qQC; // Update total residual QC of HadrPr. ^
2887  eCount--; // Reduce a#of the living Quasmons ^
2888  } // ^
2889  else if(PDGQ==90999003||PDGQ==91002999) // ppS+/nnS- ^
2890  { // ^
2891 #ifdef edebug
2892  G4cout<<"G4QEnv::HadrQEnv: DiNucleon+Sigma Mass="<<cqMass<<G4endl; // ^
2893 #endif
2894  G4bool dinFlag = false; // Di-nucleon flag ^
2895  G4double hyM=mSigM; // Prototype of the hyperon mass (n+Sigma-) ^
2896  G4int hyPDG=3112; // Prototype of the hyperon PDG Code ^
2897  G4double pigM=mNeut+mNeut;// Prototype of the di-nucleon mass ^
2898  G4int pigPDG=2112; // Prototype of the nucleon PDG Code ^
2899  if (PDGQ==90999003) // --> "n+Sigma-" case ^
2900  { // ^
2901  if(cqMass<pigM+mSigM) // ----> "DiNeutron+Pi-" case ^
2902  { // ^
2903  dinFlag = true; // For the final decay ^
2904  pigM=mNeut+mNeut+mNeut;// Tri-neutron ^
2905  pigPDG=2112; // Neutron PDG Code ^
2906  hyM=mPi; // Pi- mass ^
2907  hyPDG=-211; // Pi- PDG Code ^
2908  } // ^
2909  } // ^
2910  else if(PDGQ==91002999) // --> "p+Sigma+" case ^
2911  { // ^
2912  hyM=mSigP; // Sigma+ ^
2913  hyPDG=3222; // PDG Code of Sigma+ ^
2914  pigM=mProt+mProt; // Di-Proton mass ^
2915  pigPDG=2212; // PDG Code of proton ^
2916  if(cqMass<pigM+mSigP) // ----> "DiProton+Pi+" case ^
2917  { // ^
2918  dinFlag = true; // For the final decay ^
2919  pigM=mProt+mProt+mProt;// Tri-proton ^
2920  pigPDG=2212; // Neutron PDG Code ^
2921  hyM=mPi; // Pi+ mass ^
2922  hyPDG=211; // Pi+ PDG Code ^
2923  } // ^
2924  } // ^
2925  G4LorentzVector b4Mom(0.,0.,0.,hyM); // Hyperon (di-nucleon) mass ^
2926  G4LorentzVector m4Mom(0.,0.,0.,pigM);// Nucleon (pion) mass ^
2927  if(!G4QHadron(cq4M).DecayIn2(b4Mom, m4Mom)) // "DecayIn2 failed" case ^
2928  { // ^
2929  G4cout<<"--Warning--G4QE::HQE:S/Pi="<<hyPDG<<"(m="<<hyM<<")+D/T=" //^
2930  <<pigPDG<<"(m="<<pigM<<")="<<hyM+pigM<<">"<<cqMass<<G4endl; //^
2931  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC ^
2932  CleanUp(); // ^
2933  if(!CheckGroundState(quasH,true)) // Last posibility to correct ^
2934  { // ^
2935  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // ^
2936  theQHadrons.push_back(hadr); // Cor or fill as It Is ^
2937 #ifdef debug
2938  G4cout<<"-Warn-G4QE::HQE:Sig,QC="<<totQC<<",4M="<<tot4M<<G4endl;//^
2939 #endif
2940  //throw G4QException("G4QEnvironment::HadronizeQEnv:Sig error");//^
2941  } // ^
2942  delete quasH; // Delete the temporary fake Quasmon ^
2943  return theQHadrons; // ^
2944  } // ^
2945 #ifdef debug
2946  G4cout<<"G4QEnv::HadronizeQEnv:2NSigma="<<PDGQ<<cq4M<<"-> Sigma/Pi="//^
2947  <<hyPDG<<b4Mom<<" + 2N/3N="<<pigPDG<<m4Mom<<dinFlag<<G4endl; // ^
2948 #endif
2949  G4QHadron* curBar = new G4QHadron(hyPDG,b4Mom); // ^
2950  theQHadrons.push_back(curBar); // Fill the Hyperon (delete equivalent)^
2951  if(dinFlag) m4Mom/=3.; // Split the 4-mom for the dinucleon in 3 ^
2952  else m4Mom/=2.; // Split the 4-mom for the dinucleon in 2 ^
2953  G4QHadron* curMes = new G4QHadron(pigPDG,m4Mom); // ^
2954  theQHadrons.push_back(curMes); // Fill the gam/pi (delete equivalent) ^
2955  G4QHadron* secBar = new G4QHadron(pigPDG,m4Mom); // ^
2956  theQHadrons.push_back(secBar); // Fill the gam/pi (delete equivalent) ^
2957  if(dinFlag) // ^
2958  { // ^
2959  G4QHadron* triBar = new G4QHadron(pigPDG,m4Mom);// Cre. 3-d nucleon ^
2960  theQHadrons.push_back(triBar);// Fill 3-d nucleon (delete equival.) ^
2961  } // ^
2962  pQ->KillQuasmon(); // Make done the current Quasmon ^
2963  tot4M-=cq4M; // Update theTotalResidNucl of HadrPr. ^
2964  totQC-=qQC; // Update total residual QC of HadrPr. ^
2965  eCount--; // Reduce a#of the living Quasmons ^
2966  } // ^
2967  else if (PDGQ!=10) // @@ Chipolino can wait @@ ^
2968  { // ^
2969  G4double qM =cq4M.m(); // Real mass of the Quasmon ^
2970  G4double gsM=QPDGQ.GetMass(); // GSmass of the Quasmon ^
2971 #ifdef edebug
2972  G4cout<<"G4QEnv::HadrQEnv:#"<<jq<<",qM="<<qM<<">gsM="<<gsM<<G4endl;// ^
2973 #endif
2974  if(fabs(qM-gsM)<0.0001) // "Fill & Kill" Case ^
2975  { // ^
2976  G4QHadron* resQ = new G4QHadron(PDGQ,cq4M); // GSM hadron for CurQ ^
2977 #ifdef debug
2978  G4cout<<"G4QEnv::HadrQEnv:ResQ="<<PDGQ<<cq4M<<G4endl; // ^
2979 #endif
2980  theQHadrons.push_back(resQ); // @@ Check Dibarions @@ (del.equiv.) ^
2981  pQ->KillQuasmon(); // Make done the current Quasmon ^
2982  tot4M-=cq4M; // Update theTotalResidNucl of HadrPr. ^
2983  totQC-=qQC; // Update total residual QC of HadrPr. ^
2984  eCount--; // Reduce a#of the living Quasmons ^
2985  } // ^
2986  else if(eCount==1 && qM<gsM && CheckGroundState(pQ,true))// Cor.& Fin.^
2987  { // ^
2988 #ifdef edebug
2989  G4cout<<"G4QEnv::HadrQEnv:**>>** CGS Correction **>>**"<<G4endl; // ^
2990 #endif
2991  for_each(output->begin(), output->end(), DeleteQHadron()); //-->-->-^
2992  output->clear(); // ^
2993  delete output; // >--------------->--------------->------->+
2994  pQ->KillQuasmon(); // If BackFusion -> kill theQuasmon ^
2995  eCount--; // Reduce a#of the living Quasmons ^
2996  return theQHadrons; // ^
2997  } // ^
2998  else if(qM<gsM&&(pQ->GetQC().GetSPDGCode()==1114 // ^
2999  || pQ->GetQC().GetSPDGCode()==2224) // ^
3000  &&qM>theWorld->GetQParticle(QPDGQ)->MinMassOfFragm())//Del&Kill ^
3001  { // ^
3002 #ifdef edebug
3003  G4cout<<"G4QEnv::HadrQEnv:**||** Copy&Decay **||**"<<G4endl; // ^
3004 #endif
3005  G4QHadronVector* decHV=pQ->DecayQuasmon();//Dec.Quasm & fill decHV=*^
3006  CopyAndDeleteHadronVector(decHV);// Copy output to QHadrV of G4Env ^
3007  tot4M-=pQ->Get4Momentum(); // tot4M recalculation ^
3008  totQC-=pQ->GetQC(); // totQC recalculation ^
3009  pQ->KillQuasmon(); // Make done the current Quasmon ^
3010  eCount--; // Reduce a#of the living Quasmons ^
3011  } // ^
3012  } // ^
3013  } // End of the Medium/Vacuum IF ^
3014  } // End of the status ELSE IF ^
3015  else if(status==3) count3++; // ^
3016  if(status<0) // Panic: Quasmon is below theMassShell ^
3017  { // ^
3018  //if(eCount==1 && DecayInEnvQ(pQ)) // ^
3019  //{ // ^
3020  // for_each(output->begin(), output->end(), DeleteQHadron());//--->-->-->+
3021  // output->clear(); // ^
3022  // delete output; // >----------------->---------------->-->+
3023  // eCount--; // Reduce a#of the living Quasmons ^
3024  // pQ->KillQuasmon(); // ^
3025  // return theQHadrons; // ^
3026  //} // ^
3027  G4int ppm=jq; // Initialized by PANIC Quasmon pointer ^
3028  G4int nRQ=0; // Prot. of a#of additionalRealQuasmons ^
3029 #ifdef edebug
3030  G4cout<<"G4QEnv::HadrQEnv: ***PANIC*** for jq="<<jq<<G4endl; // ^
3031 #endif
3032  G4ThreeVector vp= pQ->Get4Momentum().vect(); // PANICQuasmon momentum ^
3033  G4double dpm=1.e+30; // Big number (dot product of momenta) ^
3034  if(nQuasmons>1) for(G4int ir=0; ir<nQuasmons; ir++)// Search for partner ^
3035  { // ^
3036  if(ir!=jq) // Skip the current (PANIC) Quasmon itself^
3037  { // ^
3038  G4Quasmon* rQ = theQuasmons[ir]; // ^
3039  G4int Qst = rQ->GetStatus();// Status of a Quasmon ^
3040 #ifdef edebug
3041  G4cout<<"G4QEnv::HadrQEnv: ir="<<ir<<",Qstatus="<<Qst<<G4endl; // ^
3042 #endif
3043  if(Qst>0) // Skip the dead Quasmon ^
3044  {
3045  nRQ++; // Increment real-Quasmon-counter ^
3046  G4double dp=vp.dot(rQ->Get4Momentum().vect()); // ^
3047  if(dp<dpm) // Search for the "moving in thesameDir" ^
3048  { // ^
3049  ppm=ir; // Remember the index of MinProj Quasmon ^
3050  dpm=dp; // Remember the value of theMinProjection ^
3051  } // ^
3052  } // ^
3053  } // End of the Quasmon LOOP
3054  } // End of the partner-search-for-the-PANIC-Quasmon LOOP ^
3055  if(nRQ) // Merge with theBestPartnerQuasmonCandid ^
3056  { // ^
3057  G4Quasmon* rQ = theQuasmons[ppm]; // ^
3058  G4QContent rQC= rQ->GetQC(); // ^
3059  G4LorentzVector r4M= rQ->Get4Momentum(); // ^
3060  rQC += pQ->GetQC(); // ^
3061  r4M += pQ->Get4Momentum(); // ^
3062  rQ->InitQuasmon(rQC, r4M); // Make new Quasmon ^
3063 #ifdef edebug
3064  G4cout<<"G4QE::HQE:"<<pQ->GetQC()<<"+"<<rQ->GetQC()<<"="<<rQC<<G4endl;//^
3065 #endif
3066  pQ->KillQuasmon(); // Delete old Quasmon ^
3067  eCount--; // Decrement counter of living Quasmons ^
3068  } // ^
3069  else // No candidate to resolve PANIC was found ^
3070  { // ^
3071 #ifdef edebug
3072  G4cout<<"G4QEnv::HQE: No Q-cand. nRQ="<<nRQ<<",eC="<<eCount<<G4endl; // ^
3073 #endif
3074  //if(eCount==1 && CheckGroundState(pQ,true)) // BackFusion attempt ^
3075  if(CheckGroundState(pQ,true)) // The only Q: BackFusion attempt ^
3076  {
3077  for_each(output->begin(), output->end(), DeleteQHadron()); //-->-->-->+
3078  output->clear(); // ^
3079  delete output; // >-------------->---------------->----->+
3080  pQ->KillQuasmon(); // ^
3081  eCount--; // Reduce a#of the living Quasmons ^
3082  return theQHadrons; // ^
3083  } // ^
3084 #ifdef fdebug
3085  G4cout<<"G4QEnv::HadrQEnv:NO PANICsolution,t="<<tot4M<<totQC<<G4endl;// ^
3086 #endif
3087  totQC=theEnvironment.GetQC(); // ^
3088  tot4M=theEnvironment.Get4Momentum(); // ^
3089  if(nQuasmons) for(G4int jr=0; jr<nQuasmons; jr++) // Search for partner ^
3090  { // ^
3091  G4Quasmon* rQ = theQuasmons[jr]; // Pointer to the Quasmon ^
3092  G4int Qst = rQ->GetStatus();// Status of a Quasmon ^
3093  if(jr==jq) // ^
3094  { // ^
3095  totQC+=rQ->GetQC(); // QuarkContent of the Quasmon ^
3096  tot4M+=rQ->Get4Momentum();// QuarkContent of the Quasmon ^
3097  } // ^
3098  else if(Qst) // Skip dead Quasmons ^
3099  { // ^
3100  totQC+=rQ->GetQC(); // QuarkContent of the Quasmon ^
3101  tot4M+=rQ->Get4Momentum();// QuarkContent of the Quasmon ^
3102  } // ^
3103  } // End of the "No candidate to resolve PANIC" ELSE ^
3104  pQ->KillQuasmon(); // Kill the only Quasmon ^
3105  eCount--; // Reduce a#of the living Quasmons ^
3106  CleanUp(); // Clean up THIS Quasmon and Environment ^
3107  G4QHadron* evH = new G4QHadron(totQC,tot4M); // Create ResidNuclHadron ^
3108  EvaporateResidual(evH); // Try to evaporate residual (del.equiv.) ^
3109  for_each(output->begin(), output->end(), DeleteQHadron()); //-->-->-->->+
3110  output->clear(); // ^
3111  delete output; // >------------------>--------------->-->+
3112  force=true; // Make the force decision ^
3113  break; // Out of the fragmentation loop >->+ ^
3114  } // | ^
3115  } // | ^
3116  } // | ^
3117  for_each(output->begin(), output->end(), DeleteQHadron()); // ->-->-->--|---->+
3118  output->clear(); // | ^
3119  delete output; // >----------------->--------------|-->->+
3120  } // End of skip of the dead Quasmons |
3121 #ifdef debug
3122  G4cout<<"G4QE::HQE:QStat("<<jq<<"="<<status<<pQ->Get4Momentum()<<G4endl;//|
3123 #endif
3124  } // End of fragmentation LOOP over Quasmons (jq) <--------<----------<-----+
3125  cAN=0;
3126  }
3127  else if(totMass>totM+.001) // ==> "Try Evaporate or decay" case
3128  {
3129 #ifdef edebug
3130  G4cout<<"G4QEnv::HadrQE: NQ="<<nQuasmons<<",tM="<<totMass<<",tPDG="<<totPDG<<",tB="
3131  <<totBN<<",GSM="<<totM<<",dM="<<totMass-totM<<",totQC="<<totQC<<G4endl;
3132 #endif
3133  //if(nQuasmons==1)
3134  if(2>3) // ** closed, because doesn't make a diff
3135  {
3136  G4QContent quasQC=totQC-envQC; // Total QuarkContent of the Only Quasmon
3137  G4int resQPDG=quasQC.GetSPDGCode(); // GS mass for the Only Quasmon-hadron
3138  G4int resQB=quasQC.GetBaryonNumber(); // Baryon number of the Only Quasmon
3139  G4int resQCh=quasQC.GetCharge(); // Charge of the Only Quasmon
3140  //G4int resQS=quasQC.GetStrangeness(); // Strangeness of the Only Quasmon
3141  if((resQPDG==0 || resQPDG==10) && resQB>0) resQPDG=quasQC.GetZNSPDGCode();
3142  G4double resQM=G4QPDGCode(resQPDG).GetMass();// GS Mass of the Only Quasmon
3143  G4double qCB=theEnvironment.CoulombBarrier(resQCh,resQB); // CoulombBarrier
3144  G4double de=totMass-envM-resQM-qCB;
3145 #ifdef debug
3146  G4cout<<"G4QEnv::HadrQE:NQ==1,tM="<<totMass<<",qM="<<resQM<<",eM="<<envM<<",CB="
3147  <<qCB<<",dE="<<totMass-envM-resQM-qCB<<G4endl;
3148 #endif
3149  if(de>0.) // Make DecayIn2 conserving Q-direction
3150  {
3151  G4LorentzVector fq4M=G4LorentzVector(0.,0.,0.,resQM); // Prot. for outQuasmon
3152  G4LorentzVector fe4M=env4M; // Prototype for outEnvironment
3153  G4LorentzVector dir4M=tot4M-env4M; // Internall quasmon 4-momentum
3154  if(!G4QHadron(tot4M).RelDecayIn2(fe4M,fq4M,dir4M,1.,1.))
3155  {
3157  ed << "Can't decay Q+E: t4M=" << tot4M << ",d=" << de << G4endl;
3158  G4Exception("G4QEnvironment::HadronizeQEnvironment()", "HAD_CHPS_0008",
3159  FatalException, ed);
3160  }
3161  G4QHadron* hQua = new G4QHadron(resQPDG,fq4M);
3162  theQHadrons.push_back(hQua); // Fill the hadron-quasmon (delete equiv.)
3163  G4int envPDG=theEnvironment.GetPDGCode();
3164  G4QHadron* hEnv = new G4QHadron(envPDG,fe4M);
3165  theQHadrons.push_back(hEnv); // Fill the hadron-environ (delete equiv.)
3166 #ifdef debug
3167  G4cout<<"G4QEnv::HadrQEnv:fQ="<<resQPDG<<fq4M<<", fE="<<envPDG<<fe4M<<G4endl;
3168 #endif
3169  return theQHadrons;
3170  }
3171  }
3172 #ifdef debug
3173  G4cout<<"G4QEnv::HadrQE: M="<<totMass<<",PDG="<<totPDG<<",B="<<totBN<<",GSM="<<totM
3174  <<",dM="<<totMass-totM<<",totQC="<<totQC<<G4endl;
3175 #endif
3176  if(totBN<2) // ==> "Baryon/Meson residual Quasmon" case
3177  {
3178  if(totPDG==90999999||totPDG==90999000||totPDG==90000999||totPDG==89999001)//"M"ca
3179  {
3180  G4cout<<"---Warning---G4QE::HQE:Meson(2) PDG="<<totPDG<<",M="<<totMass<<G4endl;
3181  }
3182  else if(totPDG==1114||totPDG==2224) //==> "DELTA- or DELTA++" case (?antiDELTA)
3183  {
3184  G4double mBar=mProt;
3185  G4int bPDG=2212;
3186  G4double mMes=mPi;
3187  G4int mPDG=211;
3188  if(totPDG==1114) // "DELTA-" case
3189  {
3190  mBar=mNeut;
3191  bPDG=2112;
3192  mPDG=-211;
3193  }
3194  if(totMass<mBar+mMes)
3195  {
3196  G4cout<<"--Warning--G4QE::HQE:tM="<<totMass<<"<GSM+mPi0="<<totM+mPi0<<G4endl;
3197  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3198  CleanUp();
3199  if(!CheckGroundState(quasH,true))
3200  {
3201  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3202  theQHadrons.push_back(hadr); // Cor or fill as It Is
3203 #ifdef debug
3204  G4cout<<"***G4QE::HQE:FillAsIs(-4),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3205 #endif
3206  //throw G4QException("G4QEnvironment::HadronizeQEnvironment:(1)DecayQEnv");
3207  }
3208  delete quasH;
3209  return theQHadrons;
3210  }
3211  else
3212  {
3213  //G4QHadron* delta = new G4QHadron(totQC,tot4M);
3214  //delta->SetNFragments(2); // Put a#of Fragments=2
3215  //theQHadrons.push_back(delta); // Fill the residual DELTA (del.Eq.)
3216  // Instead
3217  //delete delta;
3218  //
3219  G4LorentzVector b4Mom(0.,0.,0.,mBar);
3220  G4LorentzVector m4Mom(0.,0.,0.,mMes);
3221  if(!G4QHadron(tot4M).DecayIn2(b4Mom, m4Mom))
3222  {
3223  G4cout<<"---Warning---G4QEnv::HadronizeQE:B="<<bPDG<<"(m="<<mBar<<") + M="
3224  <<mPDG<<"(m="<<mMes<<")="<<mBar+mMes<<" > mDel="<<totMass<<G4endl;
3225  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3226  CleanUp();
3227  if(!CheckGroundState(quasH,true))
3228  {
3229  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3230  theQHadrons.push_back(hadr); // Cor or fill as It Is
3231 #ifdef debug
3232  G4cout<<"***G4QE::HQE:FillAsIs(-3),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3233 #endif
3234  //throw G4QException("G4QEnvironment::HadronizeQEnv:Del->Bar+Mes error");
3235  }
3236  delete quasH;
3237  return theQHadrons;
3238  }
3239 #ifdef debug
3240  G4cout<<"G4QEnv::HadronizeQEnv: DELTA="<<totPDG<<tot4M<<" -> Bar="
3241  <<bPDG<<b4Mom<<" + Mes="<<mPDG<<m4Mom<<G4endl;
3242 #endif
3243  G4QHadron* curBar = new G4QHadron(bPDG,b4Mom);
3244  theQHadrons.push_back(curBar); // Fill the baryon (delete equivalent)
3245 #ifdef edebug
3246  G4cout<<"G4QEnv::HadrQEnv:BaryonH="<<bPDG<<b4Mom<<G4endl;
3247 #endif
3248  G4QHadron* curMes = new G4QHadron(mPDG,m4Mom);
3249  theQHadrons.push_back(curMes); // Fill the meson (delete equivalent)
3250 #ifdef edebug
3251  G4cout<<"G4QEnv::HadrQEnv:MesonH="<<mPDG<<m4Mom<<G4endl;
3252 #endif
3253  return theQHadrons;
3254  }
3255  }
3256  else if(totPDG==10) // ==> "Chipolino" case
3257  {
3258  G4QChipolino resChip(totQC); // define Residual as Chipolino
3259  G4QPDGCode h1QPDG=resChip.GetQPDG1();// QPDG of the first hadron
3260  G4int h1PDG=h1QPDG.GetPDGCode();// PDG code of the first hadron
3261  G4double h1M =h1QPDG.GetMass(); // Mass of the first hadron
3262  G4QPDGCode h2QPDG=resChip.GetQPDG2();// QPDG of the second hadron
3263  G4int h2PDG=h2QPDG.GetPDGCode();// PDG code of the second hadron
3264  G4double h2M =h2QPDG.GetMass(); // Mass of the second hadron
3265  G4LorentzVector h14Mom(0.,0.,0.,h1M);
3266  G4LorentzVector h24Mom(0.,0.,0.,h2M);
3267  if(!G4QHadron(tot4M).DecayIn2(h14Mom, h24Mom))
3268  {
3269  G4cout<<"---Warning---G4QEnv::HadronizeQE:h1="<<h1PDG<<"(m="<<h1M<<") + h2="
3270  <<h2PDG<<"(m="<<h2M<<")="<<h1M+h2M<<" > mChipo="<<totMass<<G4endl;
3271  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3272  CleanUp();
3273  if(!CheckGroundState(quasH,true))
3274  {
3275  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3276  theQHadrons.push_back(hadr); // Cor or fill as It Is
3277 #ifdef debug
3278  G4cout<<"***G4QE::HQE:FillAsIs(-2),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3279 #endif
3280  //throw G4QException("G4QEnvironment::HadrQEnv: Chipo->1+2 decay failed");
3281  }
3282  delete quasH;
3283  return theQHadrons;
3284  }
3285 #ifdef debug
3286  G4cout<<"G4QEnv::HadronizeQEnv: Chipo="<<tot4M<<" -> h1="
3287  <<h1PDG<<h14Mom<<" + Mes="<<h2PDG<<h24Mom<<G4endl;
3288 #endif
3289  G4QHadron* curH1 = new G4QHadron(h1PDG,h14Mom);
3290  theQHadrons.push_back(curH1); // Fill the curH1 (delete equivalent)
3291 #ifdef edebug
3292  G4cout<<"G4QEnv::HadrQEnv:HadronH="<<h1PDG<<h14Mom<<G4endl;
3293 #endif
3294  G4QHadron* curH2 = new G4QHadron(h2PDG,h24Mom);
3295  theQHadrons.push_back(curH2); // Fill the curH2 (delete equivalent)
3296 #ifdef edebug
3297  G4cout<<"G4QEnv::HadrQEnv:MesAsHadrPartnerH="<<h2PDG<<h24Mom<<G4endl;
3298 #endif
3299  return theQHadrons;
3300  }
3301  else if(totBN<2&&totPDG&&totMass<totM+mPi0+.001)// ==> "Meson/Baryon+gamma" case
3302  {
3303  G4LorentzVector h4Mom(0.,0.,0.,totM);
3304  G4LorentzVector g4Mom(0.,0.,0.,0.);
3305  if(!G4QHadron(tot4M).DecayIn2(h4Mom, g4Mom))
3306  {
3307  G4cout<<"---Warning---G4QEnv::HadronizeQEnv: h="<<totPDG<<"(m="<<totM
3308  <<") + gamma > mTot="<<totMass<<G4endl;
3309  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3310  CleanUp();
3311  if(!CheckGroundState(quasH,true))
3312  {
3313  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3314  theQHadrons.push_back(hadr); // Cor or fill as It Is
3315 #ifdef debug
3316  G4cout<<"***G4QE::HQE:FillAsIs(-1),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3317 #endif
3318  //throw G4QException("G4QEnvironment::HadronizeQEnv:Gamma Decay failed");
3319  }
3320  delete quasH;
3321  return theQHadrons;
3322  }
3323 #ifdef debug
3324  G4cout<<"G4QE::HQE:"<<tot4M<<"->h="<<totPDG<<h4Mom<<" + gamma="<<g4Mom<<G4endl;
3325 #endif
3326  G4QHadron* curG = new G4QHadron(22,g4Mom);
3327  theQHadrons.push_back(curG); // Fill the gamma (delete equivalent)
3328 #ifdef edebug
3329  G4cout<<"G4QEnv::HadrQEnv:PhotonH="<<g4Mom<<G4endl;
3330 #endif
3331  G4QHadron* curH = new G4QHadron(totPDG,h4Mom);
3332 #ifdef edebug
3333  G4cout<<"G4QEnv::HadrQEnv:GamPartnerH="<<totPDG<<h4Mom<<G4endl;
3334 #endif
3335  if(totPDG==92000000||totPDG==90002000||totPDG==90000002)
3336  theEnvironment.DecayDibaryon(curH,&theQHadrons);
3337  else theQHadrons.push_back(curH); // Fill the baryon (delete equivalent)
3338  return theQHadrons;
3339  }
3340  else if(totBN<2&&totPDG) // ==> "Meson/Baryon+pi" case
3341  {
3342  G4int piPDG=111;
3343  G4double mpi=mPi0;
3344  G4int mbPDG=totPDG;
3345  G4double mbm=totM;
3346  if(totPDG==1114)
3347  {
3348  piPDG=-211;
3349  mpi=mPi;
3350  mbPDG=2112;
3351  mbm=mNeut;
3352  }
3353  else if(totPDG==2224)
3354  {
3355  piPDG=211;
3356  mpi=mPi;
3357  mbPDG=2212;
3358  mbm=mProt;
3359  }
3360  else if(totPDG==113)
3361  {
3362  piPDG=-211;
3363  mpi=mPi;
3364  mbPDG=211;
3365  mbm=mPi;
3366  }
3367  G4LorentzVector h4Mom(0.,0.,0.,mbm);
3368  G4LorentzVector g4Mom(0.,0.,0.,mpi);
3369  if(!G4QHadron(tot4M).DecayIn2(h4Mom, g4Mom))
3370  {
3371  G4cout<<"---Warning---G4QEnv::HadronizeQEnv: h="<<mbPDG<<"(m="<<mbm
3372  <<") + pi(m="<<mpi<<")="<<mbm+mpi<<" > mTot="<<totMass<<G4endl;
3373  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3374  CleanUp();
3375  if(!CheckGroundState(quasH,true))
3376  {
3377  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3378  theQHadrons.push_back(hadr); // Cor or fill as It Is
3379 #ifdef debug
3380  G4cout<<"***G4QE::HQE:FillAsIs(0),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3381 #endif
3382  //throw G4QException("G4QEnvironment::HadronizeQE: DecIn2 mB+nPi failed");
3383  }
3384  delete quasH;
3385  return theQHadrons;
3386  }
3387 #ifdef debug
3388  G4cout<<"G4QE::HQE:"<<tot4M<<"->h="<<mbPDG<<h4Mom<<"+p="<<piPDG<<g4Mom<<G4endl;
3389 #endif
3390  G4QHadron* curH = new G4QHadron(mbPDG,h4Mom);
3391  if(totPDG==92000000||totPDG==90002000||totPDG==90000002)
3392  theEnvironment.DecayDibaryon(curH,&theQHadrons);
3393  else theQHadrons.push_back(curH); // Fill the baryon (delete equivalent)
3394  G4QHadron* curG = new G4QHadron(piPDG,g4Mom);
3395 #ifdef edebug
3396  G4cout<<"G4QEnv::HadrQEnv:Gamma/Pi0H="<<piPDG<<g4Mom<<G4endl;
3397 #endif
3398  theQHadrons.push_back(curG); // Fill the pi0 (delete equivalent)
3399  return theQHadrons;
3400  }
3401  else // ==> "|B|<2 new Quasmon" case
3402  {
3403  G4Quasmon* resid = new G4Quasmon(totQC,tot4M); // delete is 3 lines below <-+
3404  G4QNucleus vacuum_value(90000000); // ^
3405  G4QHadronVector* curout=resid->Fragment(vacuum_value,1);// **!!DESTROY!!**<-<-+ ^
3406  G4int rest = resid->GetStatus(); // New status after fragm attempt ^ ^
3407  if(!rest) eCount--; // Dec ExistingQuasmonsCounter ^ ^
3408  delete resid; //_________________________________^___^
3409  G4int nHadrons = curout->size(); // a#of Hadrons in the outHV ^
3410  if(nHadrons>0) // Transfer QHadrons to Output ^
3411  {
3412  for (G4int ih=0; ih<nHadrons; ih++)// LOOP over output QHadrons ^
3413  { // ^
3414 #ifdef debug
3415  G4cout<<"G4QEnv::HadrQE:NewB<2, H#"<<ih // ^
3416  <<", QPDG="<<(*curout)[ih]->GetQPDG() // ^
3417  <<", 4M="<<(*curout)[ih]->Get4Momentum()<<G4endl; // ^
3418 #endif
3419  //theQHadrons.push_back(curout->operator[](ih));//(delete equ.) <-<-^
3420  theQHadrons.push_back((*curout)[ih]); // (delete equ.) <-<-^
3421  } // ^
3422  } // ^
3423  else // ^
3424  { // ^
3425  G4ExceptionDescription ed; // ^
3426  ed << " Quasmon decay? : MQ=" << tot4M.m() << ",QC=" << totQC // ^
3427  << G4endl;
3428  G4Exception("G4QEnvironment::HadronizeQEnvironment()", "HAD_CHPS_0009",
3429  FatalException, ed);
3430  } // *** Do not destroy instances ***^
3431  curout->clear(); // The instances are filled above ^
3432  delete curout; // >-------------->--------------->+
3433  return theQHadrons;
3434  }
3435  }
3436  else
3437  {
3438  G4QContent tQC =totQC; // Not subtracted copy for error prints
3439  G4int NSi =0; // a#of additional Sigma
3440  G4int SiPDG =0; // PDG of additional Sigma
3441  G4double MSi =0.; // TotalMass of additional Sigma
3442  G4int NaK =0; // a#of additional Kaons/anti-Kaons
3443  G4int aKPDG =0; // PDG of additional Kaons/anti-Kaons
3444  G4double MaK =0.; // TotalMass of additionalKaons/anti-Kaons
3445  G4int NPi =0; // a#of additional pions
3446  G4int PiPDG =0; // PDG of additional pions
3447  G4double MPi =0.; // Total Mass of additional pions
3448  if (totBN>0&&totS<0&&totChg+totChg>=totBN)// => "additional K+" case
3449  {
3450  aKPDG=321;
3451  NaK=-totS;
3452  MaK=mK*NaK;
3453  tQC+=totS*KpQC;
3454  totChg+=totS; // Charge reduction (totS<0!)
3455  totS=0; // Anti-strangness goes to anti-Kaons
3456  }
3457  else if (totBN>0&&totS<0) // => "additional aK0" case
3458  {
3459  aKPDG=311;
3460  NaK=-totS;
3461  MaK=mK0*NaK;
3462  tQC+=totS*K0QC;
3463  totS=0; // Anti-strangness goes to anti-Kaons
3464  }
3465  else if (totBN>1&&totS>0&&(totChg<0||totChg>totBN-totS))//=>"additional Sigma"
3466  {
3467  NSi=totS; // Prototype of a#of Sigmas
3468  if(totChg<0) // Negative Sigmas
3469  {
3470  SiPDG=3112;
3471  if(-totChg<NSi) NSi=-totChg; // A#of Sigma- is restricted by charge
3472  MSi=mSigM*NSi; // Total mass of Sigma-'s
3473  tQC-=NSi*SiMQC; // Subtract QC of Sigma-'s from totQC
3474  totChg+=NSi; // Increase the TotalResidualCharge
3475  }
3476  else
3477  {
3478  SiPDG=3222; // Positive Sigmas
3479  G4int exChg=totChg-totBN+totS; // Excesive positive charge
3480  if(exChg<NSi) NSi=exChg; // A#of Sigma+ is restricted by charge
3481  MSi=mSigP*NSi; // Total mass of Sigma+'s
3482  tQC-=NSi*SiPQC; // Subtract QC of Sigma-'s from totQC
3483  totChg-=NSi; // Reduce the TotalResidualCharge
3484  }
3485  totS-=NSi; // Reduce the TotalResidualStrangeness
3486  totBN-=NSi; // A#of excessive pions is added below
3487  }
3488  else if (totBN>0&&totS>totBN&&totBN<totS+totChg)// => "additional K0" case
3489  {// @@ Here Ksi0 check should be added totS=2>totBN=1&&totBN=1<totS=2+totChg=0
3490  aKPDG=-311;
3491  NaK=totS-totBN;
3492  MaK=mK0*NaK;
3493  tQC+=NaK*K0QC;
3494  totS-=NaK; // Reduce residualstrangeness
3495  }
3496  else if (totBN>0&&totS>totBN&&totChg<0)// => "additional K-" case
3497  {// @@ Here Ksi- check should be added totS=2>totBN=1&&totChg=-1<0
3498  aKPDG=-321;
3499  NaK=totS-totBN;
3500  MaK=mK0*NaK;
3501  tQC+=NaK*KpQC;
3502  totChg+=NaK; // Increase residual charge
3503  totS-=NaK; // Reduce residual strangeness
3504  }
3505  // === Now residual DELTAS should be subtracted ===
3506  if (totBN>0&&totChg>totBN-totS) // => "additional PI+" case
3507  {// @@ Here Sigma+ check should be added totChg=1>totBn=1-totS=1
3508  PiPDG=211;
3509  NPi=totChg-totBN+totS;
3510  MPi=mPi*NPi;
3511  tQC-=NPi*PiQC;
3512  totChg-=NPi;
3513  }
3514  else if (totBN>0&&totChg<0) // => "additional PI-" case
3515  {// @@ Here Sigma- check should be added totChg<0
3516  PiPDG=-211;
3517  NPi=-totChg;
3518  MPi=mPi*NPi;
3519  tQC+=NPi*PiQC; // Now anti-Pions must be subtracted
3520  totChg+=NPi;
3521  }
3522  else if (!totBN&&totChg>1-totS) // => "additional PI+" case
3523  {// @@ Here Sigma+ check should be added totChg=1>totBn=1-totS=1
3524  PiPDG=211;
3525  NPi=totChg+totS-1;
3526  MPi=mPi*NPi;
3527  tQC-=NPi*PiQC;
3528  totChg-=NPi;
3529  }
3530  else if (!totBN&&totChg<-1-totS) // => "additional PI-" case
3531  {// @@ Here Sigma- check should be added totChg<0
3532  PiPDG=-211;
3533  NPi-=totChg+totS+1;
3534  MPi=mPi*NPi;
3535  tQC+=NPi*PiQC; // Now anti-Pions must be subtracted
3536  totChg+=NPi;
3537  }
3538  G4double totRM=0.; // min (GS) Mass of the Residual System
3539  if(totBN<2) // Calculate totPDG & totRM
3540  {
3541  totPDG=tQC.GetSPDGCode(); // MinPDGCode for the Residual compound
3542  if(totPDG==10&&tQC.GetBaryonNumber()>0) totPDG=tQC.GetZNSPDGCode();
3543  if(totPDG) totRM=G4QPDGCode(totPDG).GetMass(); // minMass of theResidualSystem
3544  else
3545  {
3546  // G4cerr<<"***G4QEnvironment::HadronizeQEnv: totPDG=0"<<G4endl;
3547  // throw G4QException("G4QEnv::HadrQEnv: Impossible PDG for B=1");
3549  ed << "Impossible PDG for B=1: totPDG=0" << G4endl;
3550  G4Exception("G4QEnvironment::HadronizeQEnvironment()",
3551  "HAD_CHPS_0010", FatalException, ed);
3552  }
3553  }
3554  else
3555  {
3556  G4QNucleus totN_temporary(tQC,tot4M);// Excited nucleus for the Residual System
3557  totN=totN_temporary;
3558  totRM=totN.GetMZNS(); // min (GS) Mass of the Residual System
3559  totPDG=totN.GetPDG(); // Total PDG Code for the Current compound
3560  }
3561  if(NaK) // ==> "Decay in K0 or K+ + NPi" case
3562  {//@@ Can (must) be moved to EvaporateResidual ??
3563  if(!NPi) // ==> "Only anti-strange K" case
3564  {
3565  G4LorentzVector m4Mom(0.,0.,0.,MaK);
3566  G4LorentzVector n4Mom(0.,0.,0.,totRM);
3567  G4double sum=MaK+totRM;
3568  if(fabs(totMass-sum)<eps)
3569  {
3570  m4Mom=tot4M*(MaK/sum);
3571  n4Mom=tot4M*(totRM/sum);
3572  }
3573  else if(totMass<sum || !G4QHadron(tot4M).DecayIn2(m4Mom, n4Mom))
3574  {
3575 #ifdef edebug
3576  G4cout<<"***G4QE::HadronizeQE:M="<<aKPDG<<"(m="<<MaK<<")+N="<<totPDG<<"(m="
3577  <<totRM<<")="<<sum<<" > mSN="<<totMass<<",d="<<sum-totMass<<G4endl;
3578 #endif
3579  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3580  CleanUp();
3581  if(!CheckGroundState(quasH,true))
3582  {
3583  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3584  theQHadrons.push_back(hadr); // Cor or fill as It Is
3585 #ifdef debug
3586  G4cout<<"***G4QEnv::HQE:FillAsItIs(1),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3587 #endif
3588  //throw G4QException("G4QEnvironment::HadronizeQEnv:AntiS-Nuc error");
3589  }
3590  delete quasH;
3591  return theQHadrons;
3592  }
3593 #ifdef debug
3594  G4cout<<"G4QEnv::HadronizeQEnv: SN="<<tot4M<<" -> M="
3595  <<aKPDG<<m4Mom<<" + N="<<totPDG<<n4Mom<<totQC<<G4endl;
3596 #endif
3597  G4LorentzVector oneK=m4Mom; // 4-mom of only kaon
3598  if(NaK>1) oneK = m4Mom/NaK; // 4-mom of one kaon
3599  for (G4int jp=0; jp<NaK; jp++)
3600  {
3601  G4QHadron* curK = new G4QHadron(aKPDG,oneK);
3602  theQHadrons.push_back(curK); // Fill the curK (delete equivalent)
3603  }
3604  G4QHadron* curN = new G4QHadron(totPDG,n4Mom); // @@ Use DecayDib then Evap
3605  EvaporateResidual(curN); // Try to evaporate residual (del.eq.)
3606  }
3607  else // ==> "Anti-strange K's + DELTA's" case
3608  {
3609  G4LorentzVector m4Mom(0.,0.,0.,MPi);
3610  G4LorentzVector k4Mom(0.,0.,0.,MaK);
3611  G4LorentzVector n4Mom(0.,0.,0.,totRM);
3612  if(!G4QHadron(tot4M).DecayIn3(m4Mom, k4Mom, n4Mom))
3613  {
3614  G4cout<<"---Warning---G4QE::HadronQE:K="<<aKPDG<<"(m="<<MaK<<")+PI="<<PiPDG
3615  <<"(m="<<MPi<<")+N="<<totPDG<<"(m="<<totRM<<")>tM="<<totMass<<G4endl;
3616  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3617  CleanUp();
3618  if(!CheckGroundState(quasH,true))
3619  {
3620  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3621  theQHadrons.push_back(hadr); // Cor or fill as It Is
3622 #ifdef debug
3623  G4cout<<"***G4QEnv::HQE:FillAsItIs(2),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3624 #endif
3625  //throw G4QException("G4QEnvironment::HadronizeQE:2AntiS-Nucl(1) error");
3626  }
3627  delete quasH;
3628  return theQHadrons;
3629  }
3630 #ifdef fdebug
3631  G4cout<<"G4QEnv::HadronizeQEnv: SN="<<tot4M<<" -> nK="<<aKPDG<<k4Mom
3632  <<" + nPi="<<PiPDG<<m4Mom<<" + N="<<totPDG<<n4Mom<<G4endl;
3633 #endif
3634  G4LorentzVector onePi=m4Mom; // 4-mom of only pion
3635  if(NPi>1) onePi = m4Mom/NPi; // 4-mom of one pion
3636  for (G4int ip=0; ip<NPi; ip++)
3637  {
3638  G4QHadron* curP = new G4QHadron(PiPDG,onePi);
3639 #ifdef debug
3640  G4cout<<"G4QEnv::HadrQEnv:SPion#"<<ip<<",H="<<PiPDG<<onePi<<G4endl;
3641 #endif
3642  theQHadrons.push_back(curP); // Fill the curM (delete equivalent)
3643  }
3644  G4LorentzVector oneK=k4Mom; // 4-mom of one kaon
3645  if(NaK>1) oneK = k4Mom/NaK; // 4-mom of one kaon
3646  for (G4int jp=0; jp<NaK; jp++)
3647  {
3648  G4QHadron* curP = new G4QHadron(aKPDG,oneK);
3649 #ifdef debug
3650  G4cout<<"G4QEnv::HadrQEnv:Kaon#"<<jp<<",H="<<aKPDG<<oneK<<G4endl;
3651 #endif
3652  theQHadrons.push_back(curP); // Fill the curM (delete equivalent)
3653  }
3654  G4QHadron* curN = new G4QHadron(totPDG,n4Mom);
3655  EvaporateResidual(curN); // Try to evaporate residual (del.equiv.)
3656  }
3657  return theQHadrons;
3658  }
3659  else if(NSi) // ==> "Decay in Sig+ or Sig- + NPi" case
3660  {//@@ Can (must) be moved to EvaporateResidual ??
3661  if(!NPi) // ==> "Only Sigma's" case
3662  {
3663  G4LorentzVector m4Mom(0.,0.,0.,MSi);
3664  G4LorentzVector n4Mom(0.,0.,0.,totRM);
3665  G4double sum=MSi+totRM;
3666  if(fabs(totMass-sum)<eps)
3667  {
3668  m4Mom=tot4M*(MSi/sum);
3669  n4Mom=tot4M*(totRM/sum);
3670  }
3671  else if(totMass<sum || !G4QHadron(tot4M).DecayIn2(m4Mom, n4Mom))
3672  {
3673 #ifdef edebug
3674  G4cout<<"***G4QE::HadronizeQE:M="<<aKPDG<<"(s="<<MSi<<")+N="<<totPDG<<"(m="
3675  <<totRM<<")="<<sum<<" > mSN="<<totMass<<",d="<<sum-totMass<<G4endl;
3676 #endif
3677  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3678  CleanUp();
3679  if(!CheckGroundState(quasH,true))
3680  {
3681  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3682  theQHadrons.push_back(hadr); // Cor or fill as It Is
3683 #ifdef debug
3684  G4cout<<"***G4QEnv::HQE:FillAsItIs(2),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3685 #endif
3686  //throw G4QException("G4QEnvironment::HadronizeQEnv:Sigma-Nuc error");
3687  }
3688  delete quasH;
3689  return theQHadrons;
3690  }
3691 #ifdef debug
3692  G4cout<<"G4QEnv::HadronizeQEnv: SN="<<tot4M<<" -> Sig="
3693  <<SiPDG<<m4Mom<<" + N="<<totPDG<<n4Mom<<totQC<<G4endl;
3694 #endif
3695  G4LorentzVector oneS=m4Mom; // 4-mom of the only sigma
3696  if(NSi>1) oneS = m4Mom/NSi; // 4-mom of one sigma
3697  for (G4int jp=0; jp<NSi; jp++)
3698  {
3699  G4QHadron* curS = new G4QHadron(SiPDG,oneS);
3700  theQHadrons.push_back(curS); // Fill the curS (delete equivalent)
3701  }
3702  G4QHadron* curN = new G4QHadron(totPDG,n4Mom); // @@ Use DecayDib then Evap
3703  EvaporateResidual(curN); // Try to evaporate residual (del.eq.)
3704  }
3705  else // ==> "Sigma's + DELTA's" case
3706  {
3707  G4LorentzVector m4Mom(0.,0.,0.,MPi);
3708  G4LorentzVector k4Mom(0.,0.,0.,MSi);
3709  G4LorentzVector n4Mom(0.,0.,0.,totRM);
3710  if(!G4QHadron(tot4M).DecayIn3(m4Mom, k4Mom, n4Mom))
3711  {
3712  G4cout<<"---Warning---G4QE::HadronQE:S="<<SiPDG<<"(m="<<MSi<<")+PI="<<PiPDG
3713  <<"(m="<<MPi<<")+N="<<totPDG<<"(m="<<totRM<<")>tM="<<totMass<<G4endl;
3714  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3715  CleanUp();
3716  if(!CheckGroundState(quasH,true))
3717  {
3718  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3719  theQHadrons.push_back(hadr); // Cor or fill as It Is
3720 #ifdef debug
3721  G4cout<<"***G4QEnv::HQE:FillAsItIs(3),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3722 #endif
3723  //throw G4QException("G4QEnvironment::HadronizeQE:2Sigma-Nucl(1) error");
3724  }
3725  delete quasH;
3726  return theQHadrons;
3727  }
3728 #ifdef fdebug
3729  G4cout<<"G4QEnv::HadronizeQEnv: SN="<<tot4M<<" -> nS="<<SiPDG<<k4Mom
3730  <<" + nPi="<<PiPDG<<m4Mom<<" + N="<<totPDG<<n4Mom<<G4endl;
3731 #endif
3732  G4LorentzVector onePi=m4Mom; // 4-mom of the only pion
3733  if(NPi>1) onePi = m4Mom/NPi; // 4-mom of one pion
3734  for (G4int ip=0; ip<NPi; ip++)
3735  {
3736  G4QHadron* curP = new G4QHadron(PiPDG,onePi);
3737 #ifdef debug
3738  G4cout<<"G4QEnv::HadrQEnv:SPion#"<<ip<<",H="<<PiPDG<<onePi<<G4endl;
3739 #endif
3740  theQHadrons.push_back(curP); // Fill the curM (delete equivalent)
3741  }
3742  G4LorentzVector oneS=k4Mom; // 4-mom of the only kaon
3743  if(NSi>1) oneS = k4Mom/NSi; // 4-mom of one kaon
3744  for (G4int jp=0; jp<NSi; jp++)
3745  {
3746  G4QHadron* curP = new G4QHadron(SiPDG,oneS);
3747 #ifdef debug
3748  G4cout<<"G4QEnv::HadrQEnv:Sigma#"<<jp<<",H="<<SiPDG<<oneS<<G4endl;
3749 #endif
3750  theQHadrons.push_back(curP); // Fill the curM (delete equivalent)
3751  }
3752  G4QHadron* curN = new G4QHadron(totPDG,n4Mom);
3753  EvaporateResidual(curN); // Try to evaporate residual (del.equiv.)
3754  }
3755  return theQHadrons;
3756  }
3757  else if(NPi) // ==> "Decay in Pi+ or Pi-" case
3758  {
3759  if(NPi==1) // ==> "One isobar" case
3760  {
3761  G4LorentzVector m4Mom(0.,0.,0.,MPi);
3762  G4LorentzVector n4Mom(0.,0.,0.,totRM);
3763  if(!G4QHadron(tot4M).DecayIn2(m4Mom, n4Mom))
3764  {
3765  G4cout<<"---Warning---G4QEnv::HadronizeQEnv:M="<<PiPDG<<"(m="<<MPi<<")+N="
3766  <<totPDG<<"(m="<<totRM<<")="<<MPi+totRM<<" > mSN="<<totMass<<G4endl;
3767  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3768  CleanUp();
3769  if(!CheckGroundState(quasH,true))
3770  {
3771  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3772  theQHadrons.push_back(hadr); // Cor or fill as It Is
3773 #ifdef debug
3774  G4cout<<"***G4QEnv::HQE:FillAsItIs(5),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3775 #endif
3776  //throw G4QException("G4QEnvironment::HadronizeQEnv:Iso-Nucleus error");
3777  }
3778  delete quasH;
3779  return theQHadrons;
3780  }
3781 #ifdef debug
3782  G4cout<<"G4QEnv::HadronizeQEnv: SN="<<tot4M<<" -> M="<<PiPDG<<m4Mom<<" + N="
3783  <<totPDG<<n4Mom<<totQC<<G4endl;
3784 #endif
3785  G4QHadron* curK = new G4QHadron(PiPDG,m4Mom);
3786  theQHadrons.push_back(curK); // Fill the curK (delete equivalent)
3787  G4QHadron* curN = new G4QHadron(totPDG,n4Mom);
3788  EvaporateResidual(curN); // Evaporate residual (delete equivalent)
3789  }
3790  else // ==> "Many Isobars" case
3791  {
3792  G4int N1Pi = NPi/2; // First pion cluster
3793  G4int N2Pi = NPi-N1Pi; // Second pion cluster
3794  G4double mM = MPi/NPi; // Mass of Pi
3795  G4double m1M = mM*N1Pi; // Mass of the first Pi-cluster
3796  G4double m2M = mM*N2Pi; // Mass of the second Pi-cluster
3797  G4LorentzVector m4Mom(0.,0.,0.,m1M);
3798  G4LorentzVector k4Mom(0.,0.,0.,m2M);
3799  G4LorentzVector n4Mom(0.,0.,0.,totRM);
3800  if(!G4QHadron(tot4M).DecayIn3(m4Mom, k4Mom, n4Mom))
3801  {
3802  G4cout<<"---Warning---G4QEnv::HadronizeQE:N*Pi="<<PiPDG<<"(m="<<mM<<")+N="
3803  <<totPDG<<"(m="<<totRM<<") >(?)SN="<<totMass<<G4endl;
3804  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3805  CleanUp();
3806  if(!CheckGroundState(quasH,true))
3807  {
3808  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3809  theQHadrons.push_back(hadr); // Cor or fill as It Is
3810 #ifdef debug
3811  G4cout<<"***G4QEnv::HQE:FillAsItIs(5),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3812 #endif
3813  //throw G4QException("G4QEnvironment::HadronizeQE:ManyIsoNucleus error");
3814  }
3815  delete quasH;
3816  return theQHadrons;
3817  }
3818 #ifdef debug
3819  G4cout<<"G4QEnv::HadronizeQEnv: SN="<<tot4M<<" -> N*PI="<<PiPDG
3820  <<" (4M1="<<m4Mom<<" + 4M2="<<k4Mom<<") + N="<<totPDG<<n4Mom<<G4endl;
3821 #endif
3822  G4LorentzVector one1=m4Mom; // 4-mom of the 1st cluster only pion
3823  if(N1Pi>1) one1=m4Mom/N1Pi; // 4-mom of the 1st cluster one pion
3824  for (G4int ip=0; ip<N1Pi; ip++)
3825  {
3826  G4QHadron* curP = new G4QHadron(PiPDG,one1);
3827  theQHadrons.push_back(curP); // Fill the curP (delete equivalent)
3828  }
3829  G4LorentzVector one2=k4Mom; // 4-mom of the 2nd cluster only pion
3830  if(N2Pi>1) one2=k4Mom/N2Pi; // 4-mom of the 2nd cluster one pion
3831  for (G4int jp=0; jp<N2Pi; jp++)
3832  {
3833  G4QHadron* curP = new G4QHadron(PiPDG,one2);
3834  theQHadrons.push_back(curP); // Fill the curP (delete equivalent)
3835  }
3836  G4QHadron* curN = new G4QHadron(totPDG,n4Mom);
3837  EvaporateResidual(curN); // Try to evaporate residual (del.equiv.)
3838  }
3839  return theQHadrons;
3840  }
3841  }
3842 #ifdef fdebug
3843  G4cout<<"G4QE::HadrQEnv: Try FinalEvaporation t4M="<<tot4M<<",tQC="<<totQC<<G4endl;
3844 #endif
3845  CleanUp();
3846  G4QHadron* evH = new G4QHadron(totQC,tot4M); // Create a Hadron for theResidualNucl
3847  EvaporateResidual(evH); // Try to evaporate residual (del.equiv.)
3848  return theQHadrons;
3849  }
3850  else // ==> "Only with GSEnvironment" case
3851  {
3852  if(totPDG==90000000 || fabs(totMass)<0.000001)
3853  {
3854  CleanUp();
3855  return theQHadrons;
3856  }
3857  G4double dM=totMass-totM;
3858 #ifdef debug
3859  G4cout<<"G4QEnv::HadrQEnv:GroundState tM-GSM="<<dM<<",GSM="<<totM<<",tPDG="<<totPDG
3860  <<",nQ="<<nQuasmons<<G4endl;
3861 #endif
3862  G4Quasmon* pQ = theQuasmons[0]; // Pointer to the first Quasmon
3863  G4QPDGCode QQPDG = pQ->GetQPDG(); // QPDG of the first Quasmon
3864  G4int QPDG = QQPDG.GetPDGCode();
3865  G4QNucleus totRN(totQC,tot4M); // Nucleus for theTotalResidualNuclearComp
3866  G4int spbRN=totRN.SplitBaryon();// PossibilityToSplit baryon from Residual
3867  if(dM>-0.001)
3868  {
3869 #ifdef fdebug
3870  G4cout<<"G4QE::HadrQE:ExcitedNucleus, dM="<<dM<<">0,tBN="<<totBN<<",nQ="<<G4endl;
3871 #endif
3872  CleanUp();
3873  G4QHadron* evH = new G4QHadron(totQC,tot4M);// Create a Hadron for ResidualNucl
3874  EvaporateResidual(evH); // Try to evaporate residual (del. equiv.)
3875  }
3876  else if(nQuasmons==1&&QPDG!=22&&QPDG!=111)// => "Decay Quasmon or Q+Environ" case
3877  {
3878  G4int envPDG = theEnvironment.GetPDG();// PDGCode of the NuclQEnvironment
3879 #ifdef debug
3880  G4cout<<"G4QEnv::HadrQEnv: nQ=1, QPDG=="<<QPDG<<G4endl;
3881 #endif
3882  if(!QPDG)
3883  {
3885  ed <<"(2)Can't Decay QEnv: Quasmon is an unknown QHadron: PDG="<< QPDG<<G4endl;
3886  G4Exception("G4QEnvironment::HadronizeQEnvironmen()", "HAD_CHPS_0011",
3887  FatalException, ed);
3888  }
3889  // => "Quasmon-Chipolino or Environment-Dibaryon" case
3890  else if(QPDG==10||QPDG==92000000||QPDG==90002000||QPDG==90000002)
3891  {
3892  G4QContent QQC = pQ->GetQC(); // Quark Content of the Quasmon
3893  G4QPDGCode h1QPDG=nQPDG; // QPDG of the first hadron
3894  G4double h1M =mNeut; // Mass of the first hadron
3895  G4QPDGCode h2QPDG=h1QPDG; // QPDG of the second hadron
3896  G4double h2M =mNeut; // Mass of the second hadron
3897  if(QPDG==10)
3898  {
3899  G4QChipolino QChip(QQC); // define the Quasmon as a Chipolino
3900  h1QPDG=QChip.GetQPDG1(); // QPDG of the first hadron
3901  h1M =h1QPDG.GetMass(); // Mass of the first hadron
3902  h2QPDG=QChip.GetQPDG2(); // QPDG of the second hadron
3903  h2M =h2QPDG.GetMass(); // Mass of the second hadron
3904  }
3905  else if(QPDG==90002000)
3906  {
3907  h1QPDG=pQPDG; // QPDG of the first hadron
3908  h1M =mProt; // Mass of the first hadron
3909  h2QPDG=h1QPDG; // QPDG of the second hadron
3910  h2M =mProt; // Mass of the second hadron
3911  }
3912  else if(QPDG==92000000)
3913  {
3914  h1QPDG=lQPDG; // QPDG of the first hadron
3915  h1M =mLamb; // Mass of the first hadron
3916  h2QPDG=h1QPDG; // QPDG of the second hadron
3917  h2M =mLamb; // Mass of the second hadron
3918  G4double ddMass=totMass-envM; // Free CM energy
3919  if(ddMass>mSigZ+mSigZ) // Sigma0+Sigma0 is possible
3920  { // @@ Only two particles PS is used
3921  G4double dd2=ddMass*ddMass; // Squared free energy
3922  G4double sma=mLamb+mLamb; // Lambda+Lambda sum
3923  G4double pr1=0.; // Prototype to avoid sqrt(-)
3924  if(ddMass>sma) pr1=sqrt((dd2-sma*sma)*dd2); // Lamb+Lamb PS
3925  sma=mLamb+mSigZ; // Lambda+Sigma0 sum
3926  G4double smi=mSigZ-mLamb; // Sigma0-Lambda difference
3927  G4double pr2=pr1; // Prototype of +L+S0 PS
3928  if(ddMass>sma && ddMass>smi) pr2+=sqrt((dd2-sma*sma)*(dd2-smi*smi));
3929  sma=mSigZ+mSigZ; // Sigma0+Sigma0 sum
3930  G4double pr3=pr2; // Prototype of +Sigma0+Sigma0 PS
3931  if(ddMass>sma) pr3+=sqrt((dd2-sma*sma)*dd2);
3932  G4double hhRND=pr3*G4UniformRand(); // Randomize PS
3933  if(hhRND>pr2) // --> "ENnv+Sigma0+Sigma0" case
3934  { //
3935  h1QPDG=s0QPDG; // QPDG of the first hadron
3936  h1M =mSigZ; // Mass of the first hadron
3937  h2QPDG=h1QPDG; // QPDG of the second hadron
3938  h2M =mSigZ; // Mass of the second hadron
3939  } //
3940  else if(hhRND>pr1) // --> "ENnv+Sigma0+Lambda" case
3941  { //
3942  h1QPDG=s0QPDG; // QPDG of the first hadron
3943  h1M =mSigZ; // Mass of the first hadron
3944  } //
3945  } //
3946  else if(ddMass>mSigZ+mLamb) // Lambda+Sigma0 is possible
3947  { // @@ Only two particles PS is used
3948  G4double dd2=ddMass*ddMass; // Squared free energy
3949  G4double sma=mLamb+mLamb; // Lambda+Lambda sum
3950  G4double pr1=0.; // Prototype to avoid sqrt(-)
3951  if(ddMass>sma) pr1=sqrt((dd2-sma*sma)*dd2); // Lamb+Lamb PS
3952  sma=mLamb+mSigZ; // Lambda+Sigma0 sum
3953  G4double smi=mSigZ-mLamb; // Sigma0-Lambda difference
3954  G4double pr2=pr1; // Prototype of +L+S0 PS
3955  if(ddMass>sma && ddMass>smi) pr2+=sqrt((dd2-sma*sma)*(dd2-smi*smi));
3956  if(pr2*G4UniformRand()>pr1) // --> "ENnv+Sigma0+Lambda" case
3957  { //
3958  h1QPDG=s0QPDG; // QPDG of the first hadron
3959  h1M =mSigZ; // Mass of the first hadron
3960  } //
3961  } //
3962  } //
3963  if(h1M+h2M+envM<totMass) // => "Three parts decay" case
3964  {
3965  G4LorentzVector h14M(0.,0.,0.,h1M);
3966  G4LorentzVector h24M(0.,0.,0.,h2M);
3967  G4LorentzVector e4M(0.,0.,0.,envM);
3968  if(!G4QHadron(tot4M).DecayIn3(h14M,h24M,e4M))
3969  {
3970  G4cout<<"Warning->G4QE::HQE:M="<<tot4M.m()<<","<<totMass<<"->"<<h1QPDG<<"("
3971  <<h1M<<")+"<<h1QPDG<<"("<<h2M<<")+"<<envM<<"="<<h1M+h2M+envM<<G4endl;
3972  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
3973  CleanUp();
3974  if(!CheckGroundState(quasH,true))
3975  {
3976  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
3977  theQHadrons.push_back(hadr); // Cor or fill as It Is
3978 #ifdef debug
3979  G4cout<<"***G4QEnv::HQE:FillAsItIs(6),QC="<<totQC<<",4M="<<tot4M<<G4endl;
3980 #endif
3981  //throw G4QException("G4QEnv::HadrQEnv:QChipo+Environment DecIn3 Error");
3982  }
3983  delete quasH;
3984  return theQHadrons;
3985 
3986  }
3987  G4QHadron* h1H = new G4QHadron(h1QPDG.GetPDGCode(),h14M);
3988  theQHadrons.push_back(h1H); // (delete equivalent)
3989 #ifdef debug
3990  G4cout<<"G4QE::HQE:(2) H1="<<h1QPDG<<h14M<<G4endl;
3991 #endif
3992  G4QHadron* h2H = new G4QHadron(h2QPDG.GetPDGCode(),h24M);
3993  theQHadrons.push_back(h2H); // (delete equivalent)
3994 #ifdef debug
3995  G4cout<<"G4QE::HQE:(2) H2-"<<h2QPDG<<h24M<<G4endl;
3996 #endif
3997  G4QHadron* qeH = new G4QHadron(envPDG,e4M);
3998  theQHadrons.push_back(qeH); // (delete equivalent)
3999 #ifdef debug
4000  G4cout<<"G4QE::HQE:(2) QEenv="<<envPDG<<e4M<<G4endl;
4001 #endif
4002  }
4003 #ifdef fdebug
4004  G4cout<<"***G4QEnv::HadQEnv:tM="<<tot4M.m()<<totQC<<"< h1="<<h1QPDG<<"(M="<<h1M
4005  <<")+h2="<<h1QPDG<<"(M="<<h2M<<")+eM="<<envM<<"="<<h1M+h2M+envM<<G4endl;
4006  //throw G4QException("G4QEnv::HadrQEnv:QChipo+Env mass > than decaying mass");
4007 #endif
4008  CleanUp();
4009  G4QHadron* evH = new G4QHadron(totQC,tot4M);// Create a Hadron for ResidualNucl
4010  EvaporateResidual(evH); // Try to evaporate residual (del. equiv.)
4011  return theQHadrons;
4012  }
4013  else // No environment
4014  {
4015  G4int nHadrs=theQHadrons.size(); // #of available hadrons
4016  for(G4int ih=0; ih<nHadrs; ++ih)
4017  {
4018  G4QHadron* ch=theQHadrons[ih];
4019  G4LorentzVector ch4M=ch->Get4Momentum();
4020  G4double chM=ch4M.m();
4021  G4LorentzVector tch4M=ch4M+tot4M;
4022  if(tch4M.m() > chM + totM) // Can be corrected
4023  {
4024  G4LorentzVector h14M(0.,0.,0.,chM);
4025  G4LorentzVector h24M(0.,0.,0.,totM);
4026  if(!G4QHadron(tch4M).DecayIn2(h14M,h24M))
4027  {
4028  G4cout<<"-Warning->G4QE::HQE:M="<<tch4M.m()<<"->"<<chM<<"+"<<totM<<"="
4029  <<chM+totM<<G4endl;
4030  }
4031  else
4032  {
4033  tot4M=h24M; // Change the residual 4M
4034  ch->Set4Momentum(h14M); // Change 4M of the current hadron
4035  break; // Quit the loop
4036  }
4037  }
4038  }
4039  G4QHadron* rH = new G4QHadron(totQC,tot4M);// Create a Hadron for ResidualNucl
4040  theQHadrons.push_back(rH);
4041  }
4042  }
4043  else if(spbRN)// => "Join all quasmons to the residual compound and evaporate" case
4044  {
4045 #ifdef fdebug
4046  G4cout<<"***G4QEnv::HadQEnv: Evaporate the total residual tRN="<<totRN<<G4endl;
4047 #endif
4048  CleanUp();
4049  G4QHadron* evH = new G4QHadron(totQC,tot4M);// Create Hadron for theResidNucleus
4050  EvaporateResidual(evH); // Try to evaporate residual (del.equiv.)
4051  return theQHadrons;
4052  }
4053  //else if(nQuasmons<3||theQHadrons.size()<12)//"Try to correct" case (change cond)
4054  else if(2>3) // "Try to correct" case (change condition)
4055  {
4056 #ifdef debug
4057  G4cout<<"***G4QEnv::HadrQE: M="<<totMass<<",dM="<<dM<<",nQ="<<nQuasmons<<G4endl;
4058 #endif
4059  G4int nOfOUT = theQHadrons.size();
4060  while(nOfOUT)
4061  {
4062  G4QHadron* theLast = theQHadrons[nOfOUT-1];
4063  G4LorentzVector last4M = theLast->Get4Momentum();
4064  G4QContent lastQC = theLast->GetQC();
4065  G4int lastS = lastQC.GetStrangeness();
4066  totS = totQC.GetStrangeness();
4067  G4int nFr = theLast->GetNFragments();
4068  G4int gam = theLast->GetPDGCode();
4069  if(gam!=22&&!nFr&&lastS<0&&lastS+totS<0&&nOfOUT>1) // => "Skip K,gam & decayed"
4070  {
4071  G4QHadron* thePrev = theQHadrons[nOfOUT-2];
4072  theQHadrons.pop_back(); // the last QHadron is excluded from OUTPUT
4073  theQHadrons.pop_back(); // the prev QHadron is excluded from OUTPUT
4074  theQHadrons.push_back(thePrev); // thePast becomes theLast as an instance
4075  delete theLast; // theLast QHadron is deleated as an instance
4076  theLast = thePrev; // Update parameters(thePrev becomes theLast)
4077  last4M = theLast->Get4Momentum();
4078  lastQC = theLast->GetQC();
4079  }
4080  else
4081  {
4082  theQHadrons.pop_back(); // the last QHadron is excluded from OUTPUT
4083  delete theLast; // theLastQHadron is deleated as an instance
4084  }
4085  totQC+=lastQC; // Update (increase) the total QC
4086  tot4M+=last4M; // Update (increase) the total 4-momentum
4087  totMass=tot4M.m(); // Calculate new real total mass
4088  G4int bn=totQC.GetBaryonNumber(); // The BaryNum after addition
4089  totPDG=totQC.GetSPDGCode();
4090  if(totPDG==10&&totQC.GetBaryonNumber()>0) totPDG=totQC.GetZNSPDGCode();
4091  if(bn>1)
4092  {
4093  totS =totQC.GetStrangeness(); // Total Strangeness of this System
4094  if(totS>=0) // => "This is a normal nucleus" case
4095  {
4096  G4QNucleus newN(totQC,tot4M);
4097  totPDG=newN.GetPDG();
4098  totM =newN.GetMZNS(); // Calculate new minimum (GS) mass
4099  }
4100  else if(totS==-1) // => "Try to decay in K+/aK0 and finish"
4101  {
4102  G4double m1=mK;
4103  G4int PDG1=321;
4104  G4QNucleus newNp(totQC-KpQC);
4105  G4int PDG2=newNp.GetPDG();
4106  G4double m2_value=newNp.GetMZNS();
4107  G4QNucleus newN0(totQC-K0QC);
4108  G4double m3_value=newN0.GetMZNS();
4109  if (m3_value+mK0<m2_value+mK) // => "aK0+ResA is better" case
4110  {
4111  m1 =mK0;
4112  PDG1=311;
4113  m2_value =m3_value;
4114  PDG2=newN0.GetPDG();
4115  }
4116  if(totMass>m1+m2_value) // => "can decay" case
4117  {
4118  G4LorentzVector fq4M(0.,0.,0.,m1);
4119  G4LorentzVector qe4M(0.,0.,0.,m2_value);
4120  if(!G4QHadron(tot4M).DecayIn2(fq4M,qe4M))
4121  {
4122  G4cout<<"---Warning---G4QE::HadQE:tM="<<tot4M.m()<<"->aK="<<PDG1<<"(M="
4123  <<m1<<")+ResA="<<PDG2<<"(M="<<m2_value<<")="<<m1+m2_value<<G4endl;
4124  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
4125  CleanUp();
4126  if(!CheckGroundState(quasH,true))
4127  {
4128  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
4129  theQHadrons.push_back(hadr); // Cor or fill as It Is
4130 #ifdef debug
4131  G4cout<<"***G4QE::HQE:FillAsIs(7),QC="<<totQC<<",4M="<<tot4M<<G4endl;
4132 #endif
4133  //throw G4QException("G4QEnv::HadrQEnv: aK+ResA DecayIn2 error");
4134  }
4135  delete quasH;
4136  return theQHadrons;
4137  }
4138  G4QHadron* H1 = new G4QHadron(PDG1,fq4M);
4139 #ifdef debug
4140  G4cout<<"G4QE::HQE:Kaon(Env)="<<PDG1<<fq4M<<G4endl;
4141 #endif
4142  theQHadrons.push_back(H1); // (delete equivalent)
4143  G4QHadron* H2 = new G4QHadron(PDG2,qe4M);
4144 #ifdef debug
4145  G4cout<<"G4QE::HQE:ResidEnv="<<PDG2<<qe4M<<G4endl;
4146 #endif
4147  theQHadrons.push_back(H2); // (delete equivalent)
4148  break;
4149  }
4150  else totM=250000.; // => "Continue reversion" case
4151  }
4152  else if(totS==-2) //=>"Try to decay in 2(K+/aK0) and finish"
4153  {
4154  G4double m1=mK;
4155  G4int PDG1=321;
4156  G4double m2_value=mK0;
4157  G4int PDG2=311;
4158  G4QNucleus newNp0(totQC-KpQC-K0QC);
4159  G4int PDG3=newNp0.GetPDG();
4160  G4double m3_value=newNp0.GetMZNS(); // M-K^0-K^+
4161  G4QNucleus newN00(totQC-K0QC-K0QC);
4162  G4double m4=newN00.GetMZNS(); // M-2*K^0
4163  G4QNucleus newNpp(totQC-KpQC-KpQC);
4164  G4double m5=newNpp.GetMZNS(); // M-2*K^+
4165  if (m4+mK0+mK0<m3_value+mK+mK0 && m4+mK0+mK0<=m5+mK+mK) //=>"2K0+ResA is theBest"
4166  {
4167  m1 =mK0;
4168  PDG1=311;
4169  m3_value =m4;
4170  PDG3=newN00.GetPDG();
4171  }
4172  else if(m5+mK+mK<m3_value+mK+mK0 && m5+mK+mK<=m4+mK0+mK0)//=>"2Kp+ResA isTheBest"
4173  {
4174  m2_value =mK;
4175  PDG1=321;
4176  m3_value =m5;
4177  PDG3=newNpp.GetPDG();
4178  }
4179  if(totMass>m1+m2_value+m3_value) // => "can decay" case
4180  {
4181  G4LorentzVector k14M(0.,0.,0.,m1);
4182  G4LorentzVector k24M(0.,0.,0.,m2_value);
4183  G4LorentzVector ra4M(0.,0.,0.,m3_value);
4184  if(!G4QHadron(tot4M).DecayIn3(k14M,k24M,ra4M))
4185  {
4186  G4cout<<"--Warning--G4QE::HQE:tM="<<tot4M.m()<<"->aK="<<PDG1<<"(M="<<m1
4187  <<")+K2="<<PDG2<<"(M="<<m2_value<<")+A="<<PDG3<<"(M="<<m3_value<<")"<<G4endl;
4188  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
4189  CleanUp();
4190  if(!CheckGroundState(quasH,true))
4191  {
4192  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
4193  theQHadrons.push_back(hadr); // Cor or fill as It Is
4194 #ifdef debug
4195  G4cout<<"***G4QE::HQE:FillAsIs(8),QC="<<totQC<<",4M="<<tot4M<<G4endl;
4196 #endif
4197  //throw G4QException("G4QEnv::HadrQE:2K+ResidNucleus DecIn3 Error");
4198  }
4199  delete quasH;
4200  return theQHadrons;
4201  }
4202  G4QHadron* H1 = new G4QHadron(PDG1,k14M);
4203  theQHadrons.push_back(H1); // (delete equivalent)
4204 #ifdef debug
4205  G4cout<<"G4QE::HQE:K1(Env)="<<PDG1<<k14M<<G4endl;
4206 #endif
4207  G4QHadron* H2 = new G4QHadron(PDG2,k24M);
4208  theQHadrons.push_back(H2); // (delete equivalent)
4209 #ifdef debug
4210  G4cout<<"G4QE::HQE:K2(Env)="<<PDG2<<k24M<<G4endl;
4211 #endif
4212  G4QHadron* H3 = new G4QHadron(PDG3,ra4M);
4213  theQHadrons.push_back(H3); // (delete equivalent)
4214 #ifdef debug
4215  G4cout<<"G4QE::HQE:ResKKEnv="<<PDG3<<ra4M<<G4endl;
4216 #endif
4217  break;
4218  }
4219  else totM=270000.; // => "Continue reversion" case
4220  }
4221  else totM=300000.; // => "Continue reversion" case
4222  }
4223  else
4224  {
4225  if (totPDG==1114||totPDG==2224||totPDG==10) // Decay right now and finish
4226  {
4227  G4double m1=mNeut;
4228  G4int PDG1=2112;
4229  G4double m2_value=mPi;
4230  G4int PDG2=-211;
4231  if(totPDG==2224)
4232  {
4233  m1=mProt;
4234  PDG1=2212;
4235  m2_value=mPi;
4236  PDG2=211;
4237  }
4238  else if(totPDG==10) // "Chipolino" case
4239  {
4240  G4QChipolino resChip(totQC); // define the residual as a Chipolino
4241  G4QPDGCode h1=resChip.GetQPDG1();
4242  PDG1=h1.GetPDGCode(); // PDG code of the first hadron
4243  m1 =h1.GetMass(); // Mass of the first hadron
4244  G4QPDGCode h2=resChip.GetQPDG2();
4245  PDG2=h2.GetPDGCode(); // PDG code of the second hadron
4246  m2_value =h2.GetMass(); // Mass of the second hadron
4247  }
4248  if(totMass>m1+m2)
4249  {
4250  G4LorentzVector fq4M(0.,0.,0.,m1);
4251  G4LorentzVector qe4M(0.,0.,0.,m2_value);
4252  if(!G4QHadron(tot4M).DecayIn2(fq4M,qe4M))
4253  {
4254  G4cout<<"---Warning---G4QE::HaQE:tM="<<tot4M.m()<<"-> h1="<<PDG1<<"(M="
4255  <<m1<<") + h2="<<PDG2<<"(M="<<m2_value<<")="<<m1+m2_value<<G4endl;
4256  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M); // totQC not tQC!
4257  CleanUp();
4258  if(!CheckGroundState(quasH,true))
4259  {
4260  G4QHadron* hadr = new G4QHadron(totQC,tot4M); // totQC not tQC!
4261  theQHadrons.push_back(hadr); // Cor or fill as It Is
4262 #ifdef debug
4263  G4cout<<"***G4QE::HQE:FillAsIs(9),QC="<<totQC<<",4M="<<tot4M<<G4endl;
4264 #endif
4265  //throw G4QException("G4QEnv::HadrQEnv: h1+h2 DecayIn2 Error");
4266  }
4267  delete quasH;
4268  return theQHadrons;
4269  }
4270  G4QHadron* H1 = new G4QHadron(PDG1,fq4M);
4271  theQHadrons.push_back(H1); // (delete equivalent)
4272 #ifdef debug
4273  G4cout<<"G4QE::HQE:h1="<<PDG1<<fq4M<<G4endl;
4274 #endif
4275  G4QHadron* H2 = new G4QHadron(PDG2,qe4M);
4276 #ifdef debug
4277  G4cout<<"G4QE::HQE:h2="<<PDG2<<qe4M<<G4endl;
4278 #endif
4279  theQHadrons.push_back(H2); // (delete equivalent)
4280  break;
4281  }
4282  else totM=350000.;
4283  }
4284  else if(totPDG) totM=G4QPDGCode(totPDG).GetMass();
4285  else totM=400000.;
4286  }
4287  totBN=totQC.GetBaryonNumber(); // The BaryNum after addition
4288  totS=totQC.GetStrangeness(); // The Strangeness after addition
4289  dM=totMass-totM;
4290 #ifdef fdebug
4291  G4cout<<"G4QEnv::HadrQE: Add H="<<last4M<<lastQC<<",tM="<<tot4M<<totM<<totQC
4292  <<",dM="<<dM<<", tB="<<totBN<<", tS="<<totS<<G4endl;
4293 #endif
4294  if(dM>-0.001&&totPDG)
4295  {
4296  CleanUp();
4297  G4QHadron* evH = new G4QHadron(totPDG,tot4M);//Create Hadron for ResidNucleus
4298  EvaporateResidual(evH); // Evaporate ResNuc (del.equiv)
4299  break;
4300  }
4301  nOfOUT = theQHadrons.size(); // Update the value of OUTPUT entries
4302  } // End of WHILE(nOfOUT)
4303  nOfOUT = theQHadrons.size(); // Update the value of OUTPUT entries
4304  if(!nOfOUT)
4305  {
4306  G4cout<<"---Warning---G4QEnv::HadrQE:M="<<totMass<<"<gsM="<<totM<<",dM="<<dM
4307  <<", tPDG="<<totPDG<<", t4M="<<tot4M<<G4endl;
4308  // throw G4QException("G4QEnvironment::HadronizeQEnv:Can't decayExhostedQEnv");
4309  CleanUp();
4310  G4QHadron* evH = new G4QHadron(totPDG,tot4M);// Create Hadron for ResidNucleus
4311  EvaporateResidual(evH); // Evaporate ResidNucl (del.equiv)
4312  }
4313  }
4314  else // "Last decay was fatal" case @@ buggy ?MK
4315  {
4316 #ifdef debug
4317  G4cout<<"***G4QEnv::HadrQE: M="<<totMass<<",dM="<<dM<<",nQ="<<nQuasmons<<G4endl;
4318 #endif
4319  G4Quasmon* quasH = new G4Quasmon(totQC,tot4M);
4320  CleanUp();
4321  if(!CheckGroundState(quasH,true))
4322  {
4323  G4QHadron* hadr = new G4QHadron(totQC,tot4M);
4324 #ifdef debug
4325  G4cout<<"G4QE::HQE:CheckGS failed H="<<totQC<<tot4M<<G4endl;
4326 #endif
4327  theQHadrons.push_back(hadr); // Cor or fill asItIs
4328  }
4329  delete quasH;
4330  }
4331  CleanUp();
4332  }
4333  } // End of "infinit" WHILE LOOP
4334  } // End of the "Nuclear Environment" case
4335  return theQHadrons;
4336 } // End of the main member function HadronizeQEnvironment
4337 
4338 // Clean up the QEnvironment to Zero
4339 void G4QEnvironment::CleanUp()
4340 {
4341  static const G4QNucleus vacuum(90000000);
4342  theEnvironment=vacuum;
4343  G4int nQuasmons = theQuasmons.size();
4344  if (nQuasmons) for (G4int iq=0; iq<nQuasmons; iq++)theQuasmons[iq]->KillQuasmon();
4345 } // End of CleanUp
4346 
4347 //Evaporate Residual Nucleus
4348 void G4QEnvironment::EvaporateResidual(G4QHadron* qH, G4bool fCGS)
4349 {
4350  static const G4double mAlph = G4QPDGCode(2112).GetNuclMass(2,2,0);
4351  static const G4double mDeut = G4QPDGCode(2112).GetNuclMass(1,1,0);
4352  static const G4double mNeut = G4QPDGCode(2112).GetMass();
4353  static const G4double mProt = G4QPDGCode(2212).GetMass();
4354  static const G4double mAlPr = mAlph+mProt;
4355  static const G4double mAlNt = mAlph+mNeut;
4356  static const G4double dProt = mProt+mProt;
4357  static const G4double dNeut = mNeut+mNeut;
4358  static const G4double dAlph = mAlph+mAlph;
4359  static const G4double eps=.003;
4360  G4int thePDG = qH->GetPDGCode(); // Get PDG code of the Residual Nucleus
4361  G4int theBN = qH->GetBaryonNumber(); // A (Baryon number of the nucleus)
4362  G4QContent theQC = qH->GetQC(); // Quark Content of the hadron
4363  G4int theS=theQC.GetStrangeness(); // S (Strangeness of the nucleus)
4364 #ifdef debug
4365  G4cout<<"G4QE::EvaporateRes:Called for PDG="<<thePDG<<",4M="<<qH->Get4Momentum()<<G4endl;
4366 #endif
4367  if(thePDG==10)
4368  {
4369  G4QContent chQC=qH->GetQC(); // Quark content of the Hadron-Chipolino
4370  G4QChipolino QCh(chQC); // Define a Chipolino instance for the Hadron
4371  G4LorentzVector ch4M=qH->Get4Momentum(); // 4Mom of the Hadron-Chipolino
4372  G4QPDGCode h1QPDG=QCh.GetQPDG1(); // QPDG of the first hadron
4373  G4double h1M =h1QPDG.GetMass(); // Mass of the first hadron
4374  G4QPDGCode h2QPDG=QCh.GetQPDG2(); // QPDG of the second hadron
4375  G4double h2M =h2QPDG.GetMass(); // Mass of the second hadron
4376  G4double chM2 =ch4M.m2(); // Squared Mass of the Chipolino
4377  if( sqr(h1M+h2M) < chM2 ) // Decay is possible
4378  {
4379  G4LorentzVector h14M(0.,0.,0.,h1M);
4380  G4LorentzVector h24M(0.,0.,0.,h2M);
4381  if(!G4QHadron(ch4M).DecayIn2(h14M,h24M))
4382  {
4384  ed << "QChipolino DecIn2 error: CM=" << std::sqrt(chM2) << " -> h1="
4385  << h1QPDG << "(" << h1M << ") + h2=" << h1QPDG << "(" << h2M
4386  << ") = " << h1M+h2M << " **Failed**" << G4endl;
4387  G4Exception("G4QEnvironment::EvaporateResidual()", "HAD_CHPS_0000",
4388  FatalException, ed);
4389  }
4390  delete qH; // Kill the primary Chipolino
4391  G4QHadron* h1H = new G4QHadron(h1QPDG.GetPDGCode(),h14M);
4392  theQHadrons.push_back(h1H); // (delete equivalent)
4393 #ifdef debug
4394  G4cout<<"G4QE::EvaporateResidual: Chipolino -> H1="<<h1QPDG<<h14M<<G4endl;
4395 #endif
4396  qH = new G4QHadron(h2QPDG.GetPDGCode(),h24M);
4397  theQHadrons.push_back(qH); // (delete equivalent)
4398 #ifdef debug
4399  G4cout<<"G4QE::EvaporateResidual: Chipolino -> H2="<<h2QPDG<<h24M<<G4endl;
4400 #endif
4401  }
4402  else
4403  {
4404  // G4cerr<<"***G4QEnv::EvaporateResid: ChipoMeson="<<qH->GetQC()<<qH->Get4Momentum()
4405  // <<", chipoM="<<std::sqrt(chM2)<<" < m1="<<h1M<<"("<<h1QPDG<<") + m2="<<h2M
4406  // <<"("<<h2QPDG<<") = "<<h1M+h2M<<G4endl;
4407  // throw G4QException("G4QEnvironment::EvaporateResidual: LowMassChipolino in Input");
4409  ed << "LowMassChipolino in Input: ChipoMeson=" << qH->GetQC()
4410  << qH->Get4Momentum() << ", chipoM=" << std::sqrt(chM2) << " < m1="
4411  << h1M << "(" << h1QPDG << ") + m2=" << h2M << "(" << h2QPDG << ") = "
4412  << h1M+h2M << G4endl;
4413  G4Exception("G4QEnvironment::EvaporateResidual()", "HAD_CHPS_0001",
4414  FatalException, ed);
4415  }
4416  return;
4417  }
4418  else if(theS<0) // Antistrange nucleus
4419  {
4420 #ifdef debug
4421  G4cout<<"G4QE::EvaporateRes: AntistrangeNucleus="<<thePDG<<qH->Get4Momentum()<<G4endl;
4422 #endif
4423  DecayAntistrange(qH, &theQHadrons); // (delete equivalent)
4424  return;
4425  }
4426  else if(theBN==1)
4427  {
4428 #ifdef debug
4429  G4cout<<"G4QE::EvaporateRes: Baryon="<<thePDG<<qH->Get4Momentum()<<G4endl;
4430 #endif
4431  DecayBaryon(qH, &theQHadrons); // (delete equivalent)
4432  return;
4433  }
4434  else if(!theBN) // @@ In future it is usefull to add the MesonExcitationDecay (?!)
4435  {
4436 #ifdef debug
4437  G4LorentzVector mesLV=qH->Get4Momentum();
4438  G4cout<<"G4QE::EvaporateRes:(!)Meson(!) PDG="<<thePDG<<",4M="<<mesLV<<mesLV.m()
4439  <<",QC="<<qH->GetQC()<<",MPDG="<<G4QPDGCode(thePDG).GetMass()<<G4endl;
4440 #endif
4441  DecayMeson(qH, &theQHadrons); // (delete equivalent)
4442  //theQHadrons.push_back(qH); // Old solution
4443  return;
4444  }
4445  G4int theC=theQC.GetCharge(); // P
4446  if(!thePDG) thePDG = theQC.GetSPDGCode(); // If there is no PDG code, get it from QC
4447  if(thePDG==10 && theBN>0) thePDG=theQC.GetZNSPDGCode();
4448  if(theS>0) thePDG-=theS*999999; // @@ May hide hypernuclear problems (G4) ! @@
4449  G4double totGSM = G4QNucleus(thePDG).GetGSMass();// TheGroundStMass of theTotalResNucleus
4450  if(theBN==2)
4451  {
4452  if(!theC) totGSM=dNeut; // nn, nL, LL
4453  else if(theC==2) totGSM=dProt; // pp
4454  else totGSM=mDeut; // np, Lp
4455  }
4456  else if(theBN==5)
4457  {
4458  if (theC==3) totGSM=mAlPr; // effective "Alph+p"
4459  else if(theC==2) totGSM=mAlNt; // effective "Alph+n"
4460  }
4461  else if(theBN==8) totGSM=dAlph; // effective "Be8"
4462  // @@ Should be more (else if) for bigger A=theBN
4463  G4LorentzVector q4M = qH->Get4Momentum(); // Get 4-momentum of theTotalResidNucleus
4464  G4double totMass = q4M.m(); // Get theRealMass of theTotalResidNucleus
4465  if(fabs(totMass-totGSM)<eps)
4466  {
4467  theQHadrons.push_back(qH); // fill As It Is
4468  }
4469  else if(totMass>totGSM)
4470  {
4471  theEnvironment.EvaporateNucleus(qH,&theQHadrons);
4472 #ifdef qdebug
4473  qH=0;
4474 #endif
4475  }
4476  else // Correction must be done
4477  {
4478 #ifdef debug
4479  G4cout<<"G4QE::EvaRes: *Correct* "<<theQC<<q4M<<totMass<<"<"<<totGSM<<G4endl;
4480 #endif
4481  G4Quasmon* quasH = new G4Quasmon(theQC,q4M);
4482  if(fCGS && !CheckGroundState(quasH, true) )
4483  {
4484 #ifdef debug
4485  G4cout<<"***G4QE::EvaporResid:GSCorFailed.FillAsItIs,n="<<theQHadrons.size()<<G4endl;
4486 #endif
4487  theQHadrons.push_back(qH); // Correction failed: fill as it is
4488 #ifdef qdebug
4489  qH=0;
4490 #endif
4491  }
4492  else
4493  {
4494  delete qH;
4495 #ifdef qdebug
4496  qH=0;
4497 #endif
4498  }
4499  delete quasH;
4500  }
4501 #ifdef qdebug
4502  if (qH)
4503  {
4504  G4cout<<"G4QEnvironment::EvaporateResidual:EndDeleted, PDG="<<qH->GetPDGCode()<<G4endl;
4505  delete qH;
4506  }
4507 #endif
4508  return;
4509 } // End of EvaporateResidual
4510 
4511 //Public Hadronisation function with Exception treatment (del is responsibility of User!)
4513 {
4514 #ifdef chdebug
4515  G4int fCharge=theEnvironment.GetCharge();
4516  G4int fBaryoN=theEnvironment.GetA();
4517  G4int nHad=theQHadrons.size();
4518  if(nHad) for(G4int ih=0; ih<nHad; ih++)
4519  {
4520  fCharge+=theQHadrons[ih]->GetCharge();
4521  fBaryoN+=theQHadrons[ih]->GetBaryonNumber();
4522  }
4523  G4int nQuas=theQuasmons.size();
4524  if(nQuas)for(G4int iqs=0; iqs<nQuas; iqs++)
4525  {
4526  fCharge+=theQuasmons[iqs]->GetCharge();
4527  fBaryoN+=theQuasmons[iqs]->GetBaryonNumber();
4528  }
4529  if(fCharge!=totCharge || fBaryoN!=totBaryoN)
4530  {
4531  G4cout<<"*::*G4QE::Frag:(4) tC="<<totCharge<<",C="<<fCharge<<",tB="<<totBaryoN
4532  <<",B="<<fBaryoN<<",E="<<theEnvironment<<G4endl;
4533  if(nHad) for(G4int h=0; h<nHad; h++)
4534  {
4535  G4QHadron* cH = theQHadrons[h];
4536  G4cout<<"*::*G4QE::HQ:h#"<<h<<",QC="<<cH->GetQC()<<",PDG="<<cH->GetPDGCode()<<G4endl;
4537  }
4538  if(nQuas) for(G4int q=0; q<nQuas; q++)
4539  {
4540  G4Quasmon* cQ = theQuasmons[q];
4541  G4cout<<"*::*G4QE::HQ:q#"<<q<<",C="<<cQ->GetCharge()<<",QCont="<<cQ->GetQC()<<G4endl;
4542  }
4543  }
4544 #endif
4545  G4QHadronVector dummy; // Prototype of the output G4QHadronVector to avoid warnings
4546  G4QHadronVector* theFragments = &dummy; // Prototype of the output G4QHadronVector
4547  G4int ExCount =0; // Counter of the repetitions
4548  G4int MaxExCnt=1; // A#of of repetitions + 1 (1 for no repetitions)
4549  G4bool RepFlag=true; // To come inside the while
4550  // For the purpose of the recalculation the Quasmons, Hadrons, Environment must be stored
4551  G4QuasmonVector* reQuasmons = new G4QuasmonVector; // deleted after the "while LOOP"
4552  G4int nQ = theQuasmons.size();
4553  if(nQ)
4554  {
4555  for(G4int iq=0; iq<nQ; iq++)
4556  {
4557  G4Quasmon* curQ = new G4Quasmon(theQuasmons[iq]);
4558  reQuasmons->push_back(curQ); // deleted after the "while LOOP"
4559  }
4560  }
4561  G4QHadronVector* reQHadrons = new G4QHadronVector; // deleted after the "while LOOP"
4562  G4int nH = theQHadrons.size();
4563  if(nH)
4564  {
4565  for(G4int ih=0; ih<nH; ih++)
4566  {
4567  G4QHadron* curH = new G4QHadron(theQHadrons[ih]);
4568  reQHadrons->push_back(curH); // deleted after the "while LOOP"
4569  }
4570  }
4571  G4QNucleus reEnvironment=theEnvironment;
4572  G4LorentzVector rem4M=tot4Mom;
4573  while (RepFlag && ExCount<MaxExCnt)
4574  {
4575  try
4576  {
4577  RepFlag=false; // If OK - go out of the while
4578  theFragments = FSInteraction(); // InterClass creation. User must delet QHadrons.
4579  }
4580  catch (G4QException& error)
4581  {
4582  G4cout<<"***G4QEnvironment::Fragment: Exception is catched"<<G4endl;
4583  RepFlag=true; // For the Exception - repete
4584  ExCount++; // Increment the repetition counter
4585  G4cout<<"***G4QEnv::Fragment:Exception #"<<ExCount<<": "<<error.GetMessage()<<G4endl;
4586  G4LorentzVector dif=rem4M-theEnvironment.Get4Momentum(); // CHECK difference
4587  G4int nHp=theQHadrons.size();
4588  G4int nQp = theQuasmons.size();
4589  G4cout<<"***G4QEnvir::Fragment:nH="<<nHp<<",nQ="<<nQp<<",E="<<theEnvironment<<G4endl;
4590  for(G4int ph=0; ph<nHp; ph++)
4591  {
4592  G4QHadron* cH = theQHadrons[ph];
4593  dif-=cH->Get4Momentum();
4594  G4cout<<"***G4QEnvir::Fr:H"<<ph<<"="<<cH->Get4Momentum()<<cH->GetPDGCode()<<G4endl;
4595  }
4596  for(G4int pq=0; pq<nQp; pq++)
4597  {
4598  G4Quasmon* cQ = theQuasmons[pq];
4599  dif-=cQ->Get4Momentum();
4600  G4cout<<"***G4QEnvir::Fr:Quasm#"<<pq<<"="<<cQ->Get4Momentum()<<cQ->GetQC()<<G4endl;
4601  }
4602  // *** Cleaning Up of all old output instances for the recalculation purposes ***
4603  for_each(theFragments->begin(), theFragments->end(), DeleteQHadron()); // old Hadrons
4604  theFragments->clear();
4605  for_each(theQHadrons.begin(), theQHadrons.end(), DeleteQHadron()); //internal Hadrons
4606  theQHadrons.clear();
4607  for_each(theQuasmons.begin(), theQuasmons.end(), DeleteQuasmon()); // old Quasmons
4608  theQuasmons.clear();
4609  G4cout<<"***G4QEnv::Fragment: ----------- End of CleaningUp: 4Mdif="<<dif<<G4endl;
4610  // **************** Recover all conditions for the recalculation ********************
4611  theEnvironment=reEnvironment; // Recover the nuclear environment
4612  tot4Mom=rem4M; // Recover the total 4Momentum of the React
4613  G4cout<<"***G4QEnv::Fragment:*Recover*Env="<<theEnvironment<<",4M="<<tot4Mom<<G4endl;
4614  G4int mQ = reQuasmons->size(); // Recover the memorizedQuasmons with print
4615  for(G4int jq=0; jq<mQ; jq++)
4616  {
4617  //G4Quasmon* curQ = new G4Quasmon(reQuasmons->operator[](jq));
4618  G4Quasmon* curQ = new G4Quasmon((*reQuasmons)[jq]);
4619  G4cout<<"***G4QE::Fragm:Q("<<jq<<")="<<curQ->Get4Momentum()<<curQ->GetQC()<<G4endl;
4620  theQuasmons.push_back(curQ); // (delete equivalent)
4621  }
4622  G4int mH = reQHadrons->size(); // Recover the memorizedQHadrons with print
4623  for(G4int jh=0; jh<mH; jh++)
4624  {
4625  //G4QHadron* curH = new G4QHadron(reQHadrons->operator[](jh));
4626  G4QHadron* curH = new G4QHadron((*reQHadrons)[jh]);
4627  G4cout<<"***G4QE::Fragm:H("<<jh<<")="<<curH->Get4Momentum()<<curH->GetQC()<<G4endl;
4628  theQHadrons.push_back(curH); // (delete equivalent)
4629  }
4630  }
4631  }
4632  if(reQuasmons->size()) // If something is still in memory then clean it up
4633  {
4634  for_each(reQuasmons->begin(),reQuasmons->end(),DeleteQuasmon()); // CleanUp oldQuasmons
4635  reQuasmons->clear();
4636  }
4637  delete reQuasmons; // All temporary Quasmons memory is wiped out
4638  if(reQHadrons->size()) // If something is still in memory then clean it up
4639  {
4640  for_each(reQHadrons->begin(),reQHadrons->end(),DeleteQHadron()); //CleanUp old QHadrons
4641  reQHadrons->clear();
4642  }
4643  delete reQHadrons; // All temporary QHadrons memory is wiped out
4644  if(ExCount>=MaxExCnt)
4645  {
4646  G4int nProj=theProjectiles.size();
4647  G4cerr<<"*G4QEnv::Fragment:Exception.Target="<<theTargetPDG<<". #Proj="<<nProj<<G4endl;
4648  if(nProj) for(G4int ipr=0; ipr<nProj; ipr++)
4649  {
4650  G4QHadron* prH = theProjectiles[ipr];
4651  G4cerr<<"G4QE::F:#"<<ipr<<",PDG/4M="<<prH->GetPDGCode()<<prH->Get4Momentum()<<G4endl;
4652  }
4653  G4Exception("G4QEnvironment::Fragment()", "HAD_CHPS_0000",
4654  FatalException, "This reaction caused the CHIPSException");
4655  }
4656  // Put the postponed hadrons in the begining of theFragments and clean them up
4657  G4int tmpS=intQHadrons.size();
4658  if(tmpS)
4659  {
4660  //tmpS=theFragments->size();
4661  //intQHadrons.resize(tmpS+intQHadrons.size());
4662  //copy(theFragments->begin(), theFragments->end(), intQHadrons.end()-tmpS);
4663  //tmpS=intQHadrons.size();
4664  //theFragments->resize(tmpS); // Resize theFragments
4665  //copy(intQHadrons.begin(), intQHadrons.end(), theFragments->begin());
4666  // Can be like this, but by performance it is closer to FNAL (but better than it)
4667  //copy(theFragments->begin(), theFragments->end(), back_inserter(intQHadrons));
4668  //theFragments->resize(intQHadrons.size()); // Resize theFragments
4669  //copy(intQHadrons.begin(), intQHadrons.end(), theFragments->begin());
4670  // The following (istead of all above) has worse performance !
4671  theFragments->insert(theFragments->begin(), intQHadrons.begin(), intQHadrons.end() );
4672  intQHadrons.clear();
4673  }
4674  // No we need to check that all hadrons are on the mass shell
4675  CheckMassShell(theFragments); // @@ the same can be done in the end of G4QFragmentation
4676  return theFragments;
4677 } // End of the Fragmentation member function
4678 
4679 //The Final State Interaction Filter for the resulting output of ::HadronizeQEnvironment()
4680 G4QHadronVector* G4QEnvironment::FSInteraction()
4681 {
4682  static const G4QPDGCode gQPDG(22);
4683  static const G4QPDGCode pizQPDG(111);
4684  static const G4QPDGCode pipQPDG(211);
4685  static const G4QPDGCode pimQPDG(-211);
4686  static const G4QPDGCode nQPDG(2112);
4687  static const G4QPDGCode pQPDG(2212);
4688  static const G4QPDGCode lQPDG(3122);
4689  static const G4QPDGCode s0QPDG(3212);
4690  //static const G4QPDGCode dQPDG(90001001);
4691  static const G4QPDGCode tQPDG(90001002);
4692  static const G4QPDGCode he3QPDG(90002001);
4693  static const G4QPDGCode aQPDG(90002002);
4694  static const G4QPDGCode a6QPDG(90002004);
4695  static const G4QPDGCode be6QPDG(90004002);
4696  //static const G4QPDGCode b7QPDG(90005002);
4697  //static const G4QPDGCode he7QPDG(90002005);
4698  static const G4QPDGCode c8QPDG(90006002);
4699  static const G4QPDGCode a8QPDG(90002006);
4700  static const G4QPDGCode c10QPDG(90006004);
4701  static const G4QPDGCode o14QPDG(90008006);
4702  static const G4QPDGCode o15QPDG(90008007);
4703  static const G4QContent K0QC(1,0,0,0,0,1);
4704  static const G4QContent KpQC(0,1,0,0,0,1);
4705  static const G4double mPi = G4QPDGCode(211).GetMass();
4706  static const G4double mPi0 = G4QPDGCode(111).GetMass();
4707  static const G4double mK = G4QPDGCode(321).GetMass();
4708  static const G4double mK0 = G4QPDGCode(311).GetMass();
4709  static const G4double mNeut= G4QPDGCode(2112).GetMass();
4710  static const G4double mProt= G4QPDGCode(2212).GetMass();
4711  static const G4double mLamb= G4QPDGCode(3122).GetMass();
4712  static const G4double mSigZ= G4QPDGCode(3212).GetMass();
4713  static const G4double mSigM= G4QPDGCode(3112).GetMass();
4714  static const G4double mSigP= G4QPDGCode(3222).GetMass();
4715  static const G4double mXiZ = G4QPDGCode(3322).GetMass();
4716  static const G4double mXiM = G4QPDGCode(3312).GetMass();
4717  static const G4double mOmM = G4QPDGCode(3334).GetMass();
4718  static const G4double mDeut= G4QPDGCode(2112).GetNuclMass(1,1,0);
4719  static const G4double mTrit= G4QPDGCode(2112).GetNuclMass(1,2,0);
4720  static const G4double mHe3 = G4QPDGCode(2112).GetNuclMass(2,1,0);
4721  static const G4double mAlph= G4QPDGCode(2112).GetNuclMass(2,2,0);
4722  static const G4double mHe6 = G4QPDGCode(2112).GetNuclMass(2,4,0);
4723  static const G4double mBe6 = G4QPDGCode(2112).GetNuclMass(4,2,0);
4724  //static const G4double mHe7 = G4QPDGCode(2112).GetNuclMass(2,5,0);
4725  //static const G4double mB7 = G4QPDGCode(2112).GetNuclMass(5,2,0);
4726  static const G4double mHe8 = G4QPDGCode(2112).GetNuclMass(2,6,0);
4727  static const G4double mC8 = G4QPDGCode(2112).GetNuclMass(6,2,0);
4728  static const G4double mC10 = G4QPDGCode(2112).GetNuclMass(6,4,0);
4729  static const G4double mO14 = G4QPDGCode(2112).GetNuclMass(8,6,0);
4730  static const G4double mO15 = G4QPDGCode(2112).GetNuclMass(8,7,0);
4731  static const G4double mKmP = mK+mProt;
4732  static const G4double mKmN = mK+mNeut;
4733  static const G4double mK0mP = mK0+mProt;
4734  static const G4double mK0mN = mK0+mNeut;
4735  static const G4QNucleus vacuum(90000000);
4736  static const G4double eps=0.003;
4739  G4int envA=theEnvironment.GetBaryonNumber();
4741 #ifdef rdebug
4742  G4int totInC=theEnvironment.GetZ();
4743  G4LorentzVector totIn4M=theEnvironment.Get4Momentum();
4744  G4cout<<"G4QEnvironment(G4QE)::FSInter(FSI): ***called*** envA="<<envA<<totIn4M<<G4endl;
4745  G4int nQuasmons=theQuasmons.size();
4746  for (G4int is=0; is<nQuasmons; is++) // Sum 4mom's of Quasmons for comparison
4747  {
4748  G4Quasmon* pQ = theQuasmons[is];
4749  G4LorentzVector Q4M= pQ->Get4Momentum();
4750  G4cout<<"G4QE::FSI: Quasmon ("<<is<<") is added, 4M="<<Q4M<<G4endl;
4751  totIn4M += Q4M;
4752  totInC += pQ->GetQC().GetCharge();
4753  } // End of TotInitial4Momentum summation LOOP over Quasmons
4754  G4int nsHadr = theQHadrons.size(); // Update the value of OUTPUT entries
4755  if(nsHadr) for(G4int jso=0; jso<nsHadr; jso++)// LOOP over output hadrons
4756  {
4757  G4int hsNF = theQHadrons[jso]->GetNFragments(); // A#of secondary fragments
4758  if(!hsNF) // Add only final hadrons
4759  {
4760  G4LorentzVector hs4Mom = theQHadrons[jso]->Get4Momentum();
4761  G4cout<<"G4QE::FSI: Hadron ("<<jso<<") is added, 4M="<<hs4Mom<<G4endl;
4762  totIn4M += hs4Mom;
4763  totInC += theQHadrons[jso]->GetCharge();
4764  }
4765  }
4766  G4cout<<"G4QE::FSI: The resulting 4Momentum="<<totIn4M<<G4endl;
4767 #endif
4768 #ifdef chdebug
4769  G4int fCharge=theEnvironment.GetCharge();
4770  G4int fBaryoN=theEnvironment.GetA();
4771  G4int nHad=theQHadrons.size();
4772  if(nHad) for(G4int ih=0; ih<nHad; ih++)
4773  {
4774  fCharge+=theQHadrons[ih]->GetCharge();
4775  fBaryoN+=theQHadrons[ih]->GetBaryonNumber();
4776  }
4777  G4int nQuas=theQuasmons.size();
4778  if(nQuas)for(G4int iqs=0; iqs<nQuas; iqs++)
4779  {
4780  fCharge+=theQuasmons[iqs]->GetCharge();
4781  fBaryoN+=theQuasmons[iqs]->GetBaryonNumber();
4782  }
4783  if(fCharge!=totCharge || fBaryoN!=totBaryoN)
4784  {
4785  G4cout<<"*::*G4QE::FSI:(5) tC="<<totCharge<<",C="<<fCharge<<",tB="<<totBaryoN
4786  <<",B="<<fBaryoN<<",E="<<theEnvironment<<G4endl;
4787  if(nHad) for(G4int h=0; h<nHad; h++)
4788  {
4789  G4QHadron* cH = theQHadrons[h];
4790  G4cout<<"*::*G4QE::HQ:h#"<<h<<",QC="<<cH->GetQC()<<",PDG="<<cH->GetPDGCode()<<G4endl;
4791  }
4792  if(nQuas) for(G4int q=0; q<nQuas; q++)
4793  {
4794  G4Quasmon* cQ = theQuasmons[q];
4795  G4cout<<"*::*G4QE::HQ:q#"<<q<<",C="<<cQ->GetCharge()<<",QCont="<<cQ->GetQC()<<G4endl;
4796  }
4797  }
4798 #endif
4799  G4QHadronVector* theFragments = new G4QHadronVector;//Internal creation. User must delete
4800  HadronizeQEnvironment(); // --->> Call the main fragmentation function
4801 #ifdef rdebug
4802  G4int tC=totInC-theEnvironment.GetZ(); // Subtract theResidualEnvironCharge
4803  G4LorentzVector t4M=totIn4M; // Compare with the total
4804  G4cout<<"G4QEnv::FSI: Initial tot4M="<<t4M<<" to be subtracted"<<G4endl;
4805  G4LorentzVector theEnv4m=theEnvironment.Get4Momentum(); // Environment 4Mom
4806  t4M-=theEnv4m; // Subtract the Environment 4-momentum
4807  G4cout<<"G4QEnv::FSI: Subtract Environ="<<theEnv4m<<theEnvironment<<G4endl;
4808  for (G4int js=0; js<nQuasmons; js++) // Subtract 4mom's of Quasmons (compare)
4809  { //
4810  G4Quasmon* prQ = theQuasmons[js];//
4811  if(prQ->GetStatus()) // Subtract only if Quasmon is alive
4812  { //
4813  G4LorentzVector Q4M= prQ->Get4Momentum(); // 4-momentum of the Quasmon
4814  G4QContent qQC= prQ->GetQC(); //
4815  G4cout<<"G4QE::FSI: Subtract Quasmon("<<js<<"),4M="<<Q4M<<",QC="<<qQC<<G4endl;
4816  t4M -= Q4M; // Subtract 4-momentum of the Quasmon
4817  tC -= prQ->GetQC().GetCharge(); //
4818  } //
4819  else G4cout<<"G4QE::FSI:Dead Quasmon("<<js<<")="<<prQ->GetStatus()<<G4endl;
4820  } // End of Quasmons4Momentum subtractions
4821  G4int nsbHadr=theQHadrons.size(); // Update the value of OUTPUT entries
4822  if(nsbHadr) for(G4int jpo=0; jpo<nsbHadr; jpo++)// LOOP over output hadrons
4823  {
4824  G4int hsNF = theQHadrons[jpo]->GetNFragments();// A#of out fragments
4825  if(!hsNF) // Subtract only final hadrons
4826  { //
4827  G4LorentzVector hs4Mom = theQHadrons[jpo]->Get4Momentum(); // Output hadron
4828  G4int hPDG = theQHadrons[jpo]->GetPDGCode(); // PDG of the Output Hadron
4829  G4cout<<"G4QE::FSI: Subtract Hadron("<<jpo<<"), 4M="<<hs4Mom<<hPDG<<G4endl;
4830  t4M -= hs4Mom; //
4831  tC -= theQHadrons[jpo]->GetCharge(); // Subtract charge of the OutHadron
4832  } // End of the "FinalHadron" IF
4833  } // End of the LOOP over output hadrons
4834  G4cout<<"G4QEnv::FSI:|||||4-MomCHECK||||d4M="<<t4M<<",dCharge="<<tC<<G4endl;
4835 #endif
4836  unsigned nHadr=theQHadrons.size();
4837  if(nHadr<=0)
4838  {
4839  G4cout<<"---Warning---G4QEnvironment::FSInteraction: nHadrons="<<nHadr<<G4endl;
4840  //throw G4QException("G4QEnvironment::FSInteraction: No hadrons in the output");
4841  return theFragments;
4842  }
4843  G4int lHadr=theQHadrons[nHadr-1]->GetBaryonNumber();
4844 #ifdef debug
4845  G4cout<<"G4QE::FSI:after HQE,nH="<<nHadr<<",lHBN="<<lHadr<<",E="<<theEnvironment<<G4endl;
4846 #endif
4847  if(lHadr>1) // TheLastHadron is nucleus:try to decay/evap/cor it
4848  {
4849  G4QHadron* theLast = theQHadrons[nHadr-1];
4850  G4QHadron* curHadr = new G4QHadron(theLast);
4851  G4LorentzVector lh4M=curHadr->Get4Momentum(); // Actual mass of the last fragment
4852  G4double lhM=lh4M.m(); // Actual mass of the last fragment
4853  G4int lhPDG=curHadr->GetPDGCode(); // PDG code of the last fragment
4854  G4double lhGSM=G4QPDGCode(lhPDG).GetMass(); // GroundStateMass of the last fragment
4855 #ifdef debug
4856  G4cout<<"G4QE::FSI:lastHadr 4M/M="<<lh4M<<lhM<<",GSM="<<lhGSM<<",PDG="<<lhPDG<<G4endl;
4857 #endif
4858  if(lhM>lhGSM+eps) // ==> Try to evaporate the residual nucleus
4859  {
4860  theQHadrons.pop_back(); // the last QHadron-Nucleus is excluded from OUTPUT
4861  delete theLast;// *!!When kill,DON'T forget to delete theLastQHadron as an instance!*
4862  EvaporateResidual(curHadr); // Try to evaporate Hadr-Nucl (@@DecDib)(delete eq.)
4863  nHadr=theQHadrons.size();
4864 #ifdef debug
4865  G4cout<<"G4QE::FSI:After nH="<<nHadr<<",PDG="<<curHadr->GetPDGCode()<<G4endl;
4866 #endif
4867  }
4868  else if(lhM<lhGSM-eps) // ==> Try to make the HadronicSteck FSI correction
4869  {
4870  theQHadrons.pop_back(); //exclude LastHadronPointer from OUTPUT
4871  delete theLast; // *!! When killing, DON'T forget to delete the last QHadron !!*
4872  G4Quasmon* quasH = new G4Quasmon(curHadr->GetQC(),lh4M); // Fake Quasmon ctreation
4873  if(!CheckGroundState(quasH,true))// Try to correct with other hadrons
4874  {
4875 #ifdef debug
4876  // M.K. Fake complain in the low energy nHe/pHe reactions, while everything is OK
4877  G4cout<<"---Warning---G4QEnv::FSI:Correction error LeaveAsItIs h4m="<<lh4M<<G4endl;
4878 #endif
4879  theQHadrons.push_back(curHadr);// Fill theResidualNucleus asItIs(delete equivalent)
4880  //throw G4QException("G4QEnv::FSI: STOP at Correction Error");
4881  }
4882  else
4883  {
4884  delete curHadr; // The intermediate curHadr isn't necessary any more
4885  nHadr=theQHadrons.size(); // Update nHadr after successful correction
4886  }
4887  delete quasH; // Delete the temporary fake Quasmon
4888  }
4889  else delete curHadr; // ==> Leave the nucleus as it is (close to the GSM)
4890  }
4891 #ifdef debug
4892  G4LorentzVector ccs4M(0.,0.,0.,0.); // CurrentControlSum of outgoing Hadrons
4893 #endif
4894  // *** Initial Charge Control Sum Calculation ***
4895  G4int chContSum=0; // ChargeControlSum to keepTrack FSI transformations
4896  G4int bnContSum=0; // BaryoNControlSum to keepTrack FSI transformations
4897  if(nHadr)for(unsigned ich=0; ich<nHadr; ich++) if(!(theQHadrons[ich]->GetNFragments()))
4898  {
4899  chContSum+=theQHadrons[ich]->GetCharge();
4900  bnContSum+=theQHadrons[ich]->GetBaryonNumber();
4901  }
4902 #ifdef chdebug
4903  if(chContSum!=totCharge || bnContSum!=totBaryoN)
4904  {
4905  G4cout<<"*::*G4QE::Fr:(6)tC="<<totCharge<<",C="<<chContSum<<",tB="<<totBaryoN
4906  <<",B="<<bnContSum<<",E="<<theEnvironment<<G4endl;
4907  if(nHadr) for(unsigned h=0; h<nHadr; h++)
4908  {
4909  G4QHadron* cH = theQHadrons[h];
4910  G4cout<<"*::*G4QE::HQ:h#"<<h<<",QC="<<cH->GetQC()<<",PDG="<<cH->GetPDGCode()<<G4endl;
4911  }
4912  if(nQuas) for(G4int q=0; q<nQuas; q++)
4913  {
4914  G4Quasmon* cQ = theQuasmons[q];
4915  G4cout<<"*::*G4QE::HQ:q#"<<q<<",C="<<cQ->GetCharge()<<",QCont="<<cQ->GetQC()<<G4endl;
4916  }
4917  }
4918 #endif
4919  // ***
4920  if(nHadr)for(unsigned ipo=0; ipo<theQHadrons.size(); ipo++)//FindBigestNuclFragm & DecayA
4921  {
4922  unsigned jpo=ipo;
4923  nHadr=theQHadrons.size();
4924  lHadr=theQHadrons[nHadr-1]->GetBaryonNumber();
4925  G4QHadron* theCurr = theQHadrons[ipo]; // Pointer to the Current Hadron
4926  G4int hBN = theCurr->GetBaryonNumber();
4927  G4int sBN = theCurr->GetStrangeness();
4928  G4int cBN = theCurr->GetCharge();
4929  G4int hPDG = theCurr->GetPDGCode();
4930  G4LorentzVector h4Mom = theCurr->Get4Momentum();
4931 #ifdef debug
4932  G4int hNF = theCurr->GetNFragments();
4933  G4cout<<"G4QE::FSI:h#"<<ipo<<",PDG="<<hPDG<<h4Mom<<",mGS="<<G4QPDGCode(hPDG).GetMass()
4934  <<",F="<<hNF<<",nH="<<theQHadrons.size()<<G4endl;
4935 #endif
4936  if(hBN>lHadr && ipo+1<theQHadrons.size()) // CurrHadron=BiggestFragment -> Swap w/ Last
4937  {
4938  G4QHadron* curHadr = new G4QHadron(theCurr);// Remember CurHadron for evaporation
4939  G4QHadron* theLast = theQHadrons[theQHadrons.size()-1]; // theLastHadron (Cur<Last)
4940  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
4941  if(lQP.GetPDGCode()!=10) theCurr->SetQPDG(lQP); //CurHadr instead of LastHadr
4942  else theCurr->SetQC(theLast->GetQC()); // CurHadrPDG instead of LastHadrPDG
4943  theCurr->Set4Momentum(theLast->Get4Momentum()); // ... continue substitution
4944  h4Mom = theCurr->Get4Momentum();
4945  hBN = theCurr->GetBaryonNumber();
4946  cBN = theCurr->GetCharge();
4947  sBN = theCurr->GetStrangeness();
4948  hPDG = theCurr->GetPDGCode();
4949  theQHadrons.pop_back(); // pointer to theLastHadron is excluded from OUTPUT
4950  delete theLast;// *!!When kill,DON'T forget to delete theLastQHadron asAnInstance !!*
4951  theQHadrons.push_back(curHadr);
4952  nHadr=theQHadrons.size();
4953  }
4954  if(hPDG==89002000||hPDG==89001001||hPDG==89000002)// 2pt dec. of anti-strange (3pt dec)
4955  {
4956 #ifdef debug
4957  G4cout<<"G4QE::FSI:***ANTISTRANGE*** i="<<ipo<<",PDG="<<hPDG<<",BaryN="<<hBN<<G4endl;
4958 #endif
4959  G4double hM=h4Mom.m(); // 89002000
4960  G4double hMi=hM+eps;
4961  G4QPDGCode fQPDG = pQPDG;
4962  G4double fM = mProt;
4963  G4int sPDG = 321;
4964  G4double sM = mK;
4965  G4int tPDG = 0;
4966  G4double tM = 0.;
4967  if(hPDG==89002000) // Use the prototypes above
4968  {
4969  if(hMi<mKmP)
4970  {
4971  if(hMi>mProt+mPi+mPi0)
4972  {
4973  sPDG=211;
4974  sM =mPi;
4975  tPDG=111;
4976  tM =mPi0;
4977  }
4978  else if(hMi>mProt+mPi) // @@ Does not conserve strangeness (Week decay)
4979  {
4980 #ifdef debug
4981  G4cout<<"**G4QE::FSI:ANTISTRANGE*++*STRANGENESS,PDG="<<hPDG<<",M="<<hM<<G4endl;
4982 #endif
4983  sPDG=211;
4984  sM =mPi;
4985  }
4986  else sPDG=0;
4987  }
4988  }
4989  else if(hPDG==89001001)
4990  {
4991  fQPDG= nQPDG;
4992  fM = mNeut;
4993  sPDG = 321;
4994  sM = mK;
4995  if(hMi>mK0mP&&G4UniformRand()>.5)
4996  {
4997  fQPDG= pQPDG;
4998  fM = mProt;
4999  sPDG = 311;
5000  sM = mK0;
5001  }
5002  else if(hMi<mKmN)
5003  {
5004  if(hMi>mProt+mPi0+mPi0)
5005  {
5006  fQPDG= pQPDG;
5007  fM = mProt;
5008  sPDG = 111;
5009  sM = mPi0;
5010  tPDG = 111;
5011  tM = mPi0;
5012  if(hMi>mNeut+mPi+mPi0&&G4UniformRand()>.67)
5013  {
5014  fQPDG= nQPDG;
5015  fM = mNeut;
5016  tPDG = 211;
5017  tM = mPi;
5018  }
5019  if(hMi>mProt+mPi+mPi&&G4UniformRand()>.5)
5020  {
5021  sPDG = 211;
5022  sM = mPi;
5023  tPDG =-211;
5024  tM = mPi;
5025  }
5026  }
5027  else if(hMi>mProt+mPi0) // @@ Does not conserve strangeness (Week decay)
5028  {
5029 #ifdef debug
5030  G4cout<<"**G4QE::FSI:*ANTISTRANGE*+*STRANGENESS*PDG="<<hPDG<<",M="<<hM<<G4endl;
5031 #endif
5032  fQPDG= pQPDG;
5033  fM = mProt;
5034  sPDG = 111;
5035  sM = mPi0;
5036  }
5037  else sPDG=0; // @@ Still can try to decay in gamma+neutron (electromagnetic)
5038  }
5039  }
5040  else if(hPDG==89000002)
5041  {
5042  fQPDG= nQPDG;
5043  fM = mNeut;
5044  sPDG = 311;
5045  sM = mK0;
5046  if(hMi<mK0mN)
5047  {
5048  if(hMi>mNeut+mPi+mPi)
5049  {
5050  sPDG = 211;
5051  sM = mPi;
5052  tPDG =-211;
5053  tM = mPi;
5054  }
5055  if(hMi>mProt+mPi+mPi0)
5056  {
5057  fQPDG= pQPDG;
5058  fM = mProt;
5059  sPDG = 111;
5060  sM = mPi0;
5061  tPDG =-211;
5062  tM = mPi;
5063  }
5064  else if(hMi>mProt+mPi) // @@ Does not conserve strangeness (Week decay)
5065  {
5066 #ifdef debug
5067  G4cout<<"**G4QE::FSI:**ANTISTRANGE*0*STRANGENE**PDG="<<hPDG<<",M="<<hM<<G4endl;
5068 #endif
5069  fQPDG= pQPDG;
5070  fM = mProt;
5071  sPDG =-211;
5072  sM = mPi;
5073  }
5074  else sPDG=0; // @@ Still can try to decay in gamma+neutron (electromagnetic)
5075  }
5076  }
5077  if(!sPDG)
5078  {
5079 #ifdef debug
5080  G4cout<<"***G4QE::FSI:***ANTISTRANGE***CANN'T DECAY,PDG="<<hPDG<<",M="<<hM<<G4endl;
5081 #endif
5082  }
5083  else if(!tPDG) // 2 particle decay
5084  {
5085  G4bool fOK=true;
5086  G4LorentzVector f4M(0.,0.,0.,fM);
5087  G4LorentzVector s4M(0.,0.,0.,sM);
5088  G4double sum=fM+sM;
5089  if(fabs(hM-sum)<=eps)
5090  {
5091  f4M=h4Mom*(fM/sum);
5092  s4M=h4Mom*(sM/sum);
5093  }
5094  else if(hM<sum || !G4QHadron(h4Mom).DecayIn2(f4M,s4M))
5095  {
5096  G4cout<<"---Warning---G4QE::FSI: Still try(2),M="<<hM<<"->"<<fM<<"("<<fQPDG<<")+"
5097  <<sM<<"("<<sPDG<<")="<<sum<<G4endl;
5098  // Tipical scenario of recovery:
5099  // 1. Check that the Environment is vacuum (must be),
5100  //if(theEnvironment==vacuum)
5101  if(!theEnvironment.GetA())
5102  {
5103  // 2. Extract and put in qH, substitute by the Last and make quasH,
5104  G4QHadron* theLast = theCurr; // Prototype of thePointer to theLastHadron
5105  G4QHadron* qH = new G4QHadron(theCurr); // Copy of the Current Hadron
5106  if(ipo+1<theQHadrons.size()) // If ipo<Last, swap CurHadr & LastHadr
5107  {
5108  theLast = theQHadrons[theQHadrons.size()-1];//PointerTo theLastHadr(ipo<Last)
5109  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
5110  if(lQP.GetPDGCode()!=10) theCurr->SetQPDG(lQP); //CurHadr instead of LastHadr
5111  else theCurr->SetQC(theLast->GetQC());// CurHadrPDG instead of LastHadrPDG
5112  theCurr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
5113  } //ELSE: it's already theLast -> no swap
5114  theQHadrons.pop_back(); //exclude LastHadronPointer from OUTPUT
5115  delete theLast;// *!! When killing, DON'T forget to delete the last QHadron !!*
5116  G4Quasmon* quasH = new G4Quasmon(qH->GetQC(),qH->Get4Momentum());//Fake Quasmon
5117  // 3. Try to use other hadrons to recover this one (under Mass Shell)
5118  if(!CheckGroundState(quasH,true)) // Try to correct with other hadrons
5119  {
5120  G4cout<<"---Warning---G4QEnv::FSI:Failed (2) LeaveAsItIs 4m="<<h4Mom<<G4endl;
5121  theQHadrons.push_back(qH); // Fill as it is (delete equivalent)
5122  }
5123  else
5124  {
5125  delete qH;
5126  // 4. Decrement jpo index (copy of ipo) to find theBiggestNuclearFrag
5127  jpo--;
5128  // 5. Recheck the probuct, which replaced the Last and check others
5129  nHadr=theQHadrons.size();
5130  }
5131  // 6. Delete the intermediate quasmon
5132  delete quasH;
5133  // 7. Forbid the decay
5134  fOK=false;
5135  }
5136  else
5137  {
5138  // G4cerr<<"***G4QEnv::FSI: No recovery (1) Env="<<theEnvironment<<G4endl;
5139  // throw G4QException("G4QEnv::FSI:ANTISTRANGE DecayIn2 did not succeed");
5141  ed << "FSI:ANTISTRANGE DecayIn2 did not succeed: FSI: No recovery (1) Env="
5142  << theEnvironment << G4endl;
5143  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0000",
5144  FatalException, ed);
5145  }
5146  }
5147  if(fOK)
5148  {
5149  theQHadrons[ipo]->SetQPDG(fQPDG);
5150  theQHadrons[ipo]->Set4Momentum(f4M);
5151  G4QHadron* sH = new G4QHadron(sPDG,s4M);
5152  theQHadrons.push_back(sH); // (delete equivalent)
5153  }
5154  }
5155  else
5156  {
5157  G4bool fOK=true;
5158  G4LorentzVector f4M(0.,0.,0.,fM);
5159  G4LorentzVector s4M(0.,0.,0.,sM);
5160  G4LorentzVector t4M(0.,0.,0.,tM);
5161  G4double sum=fM+sM+tM;
5162  if(fabs(hM-sum)<=eps)
5163  {
5164  f4M=h4Mom*(fM/sum);
5165  s4M=h4Mom*(sM/sum);
5166  t4M=h4Mom*(tM/sum);
5167  }
5168  else if(hM<sum || !G4QHadron(h4Mom).DecayIn3(f4M,s4M,t4M))
5169  {
5170  G4cout<<"---Warning---G4QE::FSI: Still try(3), M"<<hM<<"->"<<fM<<"("<<fQPDG<<")+"
5171  <<sM<<"("<<sPDG<<")+"<<tM<<"("<<tPDG<<")="<<sum<<G4endl;
5172  //if(theEnvironment==vacuum)
5173  if(!theEnvironment.GetA())
5174  {
5175  G4QHadron* theLast = theCurr; // Prototype of the pointer to the Last Hadron
5176  G4QHadron* qH = new G4QHadron(theCurr); // Copy of the Current Hadron
5177  if(ipo+1<theQHadrons.size()) // If ipo<Last, swap CurHadr and theLastHadr
5178  {
5179  theLast = theQHadrons[theQHadrons.size()-1];//Pointer to LastHadron(ipo<Last)
5180  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
5181  if(lQP.GetPDGCode()!=10) theCurr->SetQPDG(lQP); //CurHadr instead of LastHadr
5182  else theCurr->SetQC(theLast->GetQC());// CurHadrPDG instead of LastHadrPDG
5183  theCurr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
5184  }
5185  theQHadrons.pop_back(); // exclude theLastHadron pointer from the OUTPUT
5186  delete theLast;// *!! When killing, DON'T forget to delete the last QHadron !!*
5187  G4Quasmon* quasH = new G4Quasmon(qH->GetQC(),qH->Get4Momentum());//Fake Quasmon
5188  if(!CheckGroundState(quasH,true)) // Try to correct by other hadrons
5189  {
5190  G4cout<<"---Warning---G4QEnv::FSI:Failed (3) LeaveAsItIs,4M="<<h4Mom<<G4endl;
5191  theQHadrons.push_back(qH); // Fill as it is (delete equivalent)
5192  }
5193  else
5194  {
5195  delete qH;
5196  jpo--;
5197  nHadr=theQHadrons.size();
5198  }
5199  delete quasH;
5200  fOK=false;
5201  }
5202  else
5203  {
5204  // G4cout<<"***G4QEnv::FSI: No recovery (2) Env="<<theEnvironment<<G4endl;
5205  // throw G4QException("G4QEnv::FSI:ANTISTRANGE DecayIn3 did not succeed");
5207  ed << "ANTISTRANGE DecayIn3 did not succeed: No recovery (2) Env="
5208  << theEnvironment << G4endl;
5209  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0001",
5210  FatalException, ed);
5211  }
5212  }
5213  if(fOK)
5214  {
5215  theQHadrons[ipo]->SetQPDG(fQPDG);
5216  theQHadrons[ipo]->Set4Momentum(f4M);
5217  G4QHadron* sH = new G4QHadron(sPDG,s4M);
5218  theQHadrons.push_back(sH); // (delete equivalent)
5219  G4QHadron* tH = new G4QHadron(tPDG,t4M);
5220  theQHadrons.push_back(tH); // (delete equivalent)
5221  }
5222  }
5223  nHadr=theQHadrons.size();
5224  }
5225  else if(hPDG==89999003||hPDG==90002999||hPDG==90000003||hPDG==90003000||
5226  hPDG==90999002||hPDG==91001999) // "3-particles decays of dibaryons and 3N"
5227  {
5228 #ifdef debug
5229  G4cout<<"G4QE::FSI:***nD-/pD++/nnn/ppp***i="<<ipo<<",PDG="<<hPDG<<",A="<<hBN<<G4endl;
5230 #endif
5231  G4double hM=h4Mom.m();
5232  G4QPDGCode nuQPDG=nQPDG; // n,n,pi-
5233  G4double nucM = mNeut;
5234  G4int barPDG = 2112;
5235  G4double barM = mNeut;
5236  G4int tPDG = -211;
5237  G4double tM = mPi;
5238  if(hPDG==90002999) // p,p,pi+
5239  {
5240  nuQPDG = pQPDG; // Substitute p for the first n
5241  nucM = mProt;
5242  barPDG = 2212; // Substitute p for the second n
5243  barM = mProt;
5244  tPDG = 211; // Substitute pi+ for the first pi-
5245  }
5246  else if(hPDG==90003000) // 3p
5247  {
5248  nuQPDG = pQPDG; // Substitute p for the first n
5249  nucM = mProt;
5250  barPDG = 2212; // Substitute p for the second n
5251  barM = mProt;
5252  tPDG = 2212; // Substitute p for pi-
5253  tM = mProt;
5254  }
5255  else if(hPDG==90999002) // n,Lambda,pi-/n,Sigma0,pi-/n,Sigma-,gamma(@@)
5256  {
5257  if(hM>mSigZ+mNeut+mPi)
5258  {
5259  G4double ddMass=hM-mPi; // Free CM energy
5260  G4double dd2=ddMass*ddMass; // Squared free energy
5261  G4double sma=mLamb+mNeut; // Neutron+Lambda sum
5262  G4double pr1=0.; // Prototype to avoid sqrt(-)
5263  if(ddMass>sma) pr1=sqrt((dd2-sma*sma)*dd2); // Neut+Lamb PS
5264  sma=mNeut+mSigZ; // Neutron+Sigma0 sum
5265  G4double smi=mSigZ-mNeut; // Sigma0-Neutron difference
5266  G4double pr2=pr1; // Prototype of +N+S0 PS
5267  if(ddMass>sma && ddMass>smi) pr2+=sqrt((dd2-sma*sma)*(dd2-smi*smi));
5268  if(pr2*G4UniformRand()>pr1) // --> "ENnv+Sigma0+Lambda" case
5269  {
5270  barPDG = 3212; // Substitute Sigma0 for the second n
5271  barM = mSigZ;
5272  }
5273  else
5274  {
5275  barPDG = 3122; // Substitute Lambda for the second n
5276  barM = mLamb;
5277  }
5278  }
5279  else if(hM>mLamb+mNeut+mPi)
5280  {
5281  barPDG = 3122; // Substitute Lambda for the second n
5282  barM = mLamb;
5283  }
5284  else if(hM>mSigM+mNeut)// @@ Decay in 2
5285  {
5286  barPDG = 3112; // Substitute Sigma- for the second n
5287  barM = mSigM;
5288  tPDG = 22;
5289  tM = 0;
5290  }
5291  }
5292  else if(hPDG==91001999) // p,Lambda,pi+/p,Sigma0,pi+/p,Sigma+,gamma(@@)
5293  {
5294  nuQPDG = pQPDG; // Substitute p for the first n
5295  nucM = mProt;
5296  tPDG = 211; // Substitute pi+ for the first pi-
5297  if(hM>mSigZ+mProt+mPi)
5298  {
5299  G4double ddMass=hM-mPi; // Free CM energy
5300  G4double dd2=ddMass*ddMass; // Squared free energy
5301  G4double sma=mLamb+mProt; // Lambda+Proton sum
5302  G4double pr1=0.; // Prototype to avoid sqrt(-)
5303  if(ddMass>sma) pr1=sqrt((dd2-sma*sma)*dd2); // Lamb+Prot PS
5304  sma=mProt+mSigZ; // Proton+Sigma0 sum
5305  G4double smi=mSigZ-mProt; // Sigma0-Proton difference
5306  G4double pr2=pr1; // Prototype of +P+S0 PS
5307  if(ddMass>sma && ddMass>smi) pr2+=sqrt((dd2-sma*sma)*(dd2-smi*smi));
5308  if(pr2*G4UniformRand()>pr1) // --> "ENnv+Sigma0+Lambda" case
5309  {
5310  barPDG = 3212; // Substitute Sigma0 for the second n
5311  barM = mSigZ;
5312  }
5313  else
5314  {
5315  barPDG = 3122; // Substitute Lambda for the second n
5316  barM = mLamb;
5317  }
5318  }
5319  if(hM>mLamb+mProt+mPi)
5320  {
5321  barPDG = 3122; // Substitute Lambda for the second n
5322  barM = mLamb;
5323  }
5324  else if(hM>mSigP+mProt) // @@ Decay in 2
5325  {
5326  barPDG = 3222; // Substitute Sigma- for the second n
5327  barM = mSigP;
5328  tPDG = 22;
5329  tM = 0;
5330  }
5331  }
5332  else if(hPDG==90000003) // 3n
5333  {
5334  tPDG = 2112; // Substitute n for pi-
5335  tM = mNeut;
5336  }
5337  G4bool fOK=true;
5338  G4LorentzVector nu4M(0.,0.,0.,nucM);
5339  G4LorentzVector ba4M(0.,0.,0.,barM);
5340  G4LorentzVector pi4M(0.,0.,0.,tM);
5341  G4double sum=nucM+barM+tM;
5342  if(fabs(hM-sum)<=eps)
5343  {
5344  nu4M=h4Mom*(nucM/sum);
5345  ba4M=h4Mom*(barM/sum);
5346  pi4M=h4Mom*(tM/sum);
5347  }
5348  if(hM<sum || !G4QHadron(h4Mom).DecayIn3(nu4M,ba4M,pi4M))
5349  {
5350 #ifdef debug
5351  G4int eA=theEnvironment.GetA();
5352  G4cout<<"***G4QEnv::FSI:T="<<hPDG<<"("<<hM<<")-> N="<<nuQPDG<<"(M="<<nucM<<") + B="
5353  <<barPDG<<"("<<barM<<")+N/pi="<<tPDG<<"("<<tM<<")="<<sum<<", A="<<eA<<G4endl;
5354 #endif
5355  //if(!eA)
5356  //{
5357  G4QHadron* theLast = theCurr; // Prototype of the pointer to theLastHadron
5358  G4QHadron* qH = new G4QHadron(theCurr); // Copy of the Current Hadron
5359 #ifdef debug
5360  G4cout<<"***G4QE::FSI:#"<<ipo<<",4MQC="<<qH->Get4Momentum()<<qH->GetQC()<<G4endl;
5361 #endif
5362  if(ipo+1<theQHadrons.size()) // If ipo<Last, swap CurHadr and theLastHadr
5363  {
5364  G4int nhd1=theQHadrons.size()-1;
5365  theLast = theQHadrons[nhd1];// Pointer to theLastHadron (ipo<L)
5366  G4LorentzVector l4M=theLast->Get4Momentum();
5367  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
5368  if(lQP.GetPDGCode()!=10) theCurr->SetQPDG(lQP); //CurHadr instead of LastHadr
5369  else theCurr->SetQC(theLast->GetQC());// CurHadrPDG instead of LastHadrPDG
5370 #ifdef debug
5371  G4cout<<"---Warning---G4QE::FSI:l#"<<nhd1<<",4M="<<l4M<<",PDG="<<lQP<<G4endl;
5372 #endif
5373  theCurr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
5374  }
5375  theQHadrons.pop_back(); // exclude theLastHadron pointer from OUTPUT
5376  delete theLast; // *!! When killing, DON'T forget to delete the last QHadron !!*
5377  G4QContent cqQC=qH->GetQC();
5378  G4LorentzVector tqLV=qH->Get4Momentum();
5379  G4Quasmon* quasH = new G4Quasmon(cqQC,tqLV);//Create fakeQuasm
5380  if(!CheckGroundState(quasH,true)) // Try to correct by other hadrons
5381  {
5382 #ifdef chdebug
5383  G4cout<<":W:G4QE::FSI:E="<<theEnvironment<<",Q="<<cqQC<<tqLV<<tqLV.m()<<G4endl;
5384 #endif
5385  theQHadrons.push_back(qH); // Fill as it is (delete equivalent)
5386  }
5387  else
5388  {
5389  delete qH;
5390  jpo--;
5391  nHadr=theQHadrons.size();
5392  }
5393  delete quasH;
5394  fOK=false;
5395  //}
5396  //else
5397  //{
5398  // G4cerr<<"***G4QEnv::FSI:NoRec(3)E="<<theEnvironment<<eA<<",PDG="<<hPDG<<G4endl;
5399  // throw G4QException("G4QEnv::FSI:ISO-dibaryon or 3n/3p DecayIn3 error");
5400  //}
5401  }
5402  if(fOK)
5403  {
5404  theQHadrons[ipo]->SetQPDG(nuQPDG);
5405  theQHadrons[ipo]->Set4Momentum(nu4M);
5406  G4QHadron* baH = new G4QHadron(barPDG,ba4M);
5407  theQHadrons.push_back(baH); // (delete equivalent)
5408  G4QHadron* piH = new G4QHadron(tPDG,pi4M);
5409  theQHadrons.push_back(piH); // (delete equivalent)
5410  nHadr=theQHadrons.size();
5411  }
5412  }
5413  else if(hBN>1 && !sBN && (cBN<0 || cBN>hBN)) // "nN+mD- or nP+mD++ decay"
5414  {
5415 #ifdef debug
5416  G4cout<<"G4QE::FSI:nNmD-/nPmD++ #"<<ipo<<",P="<<hPDG<<",B="<<hBN<<",C="<<cBN<<G4endl;
5417 #endif
5418  G4double hM=h4Mom.m();
5419  G4QPDGCode nuQPDG=nQPDG; // "(n+m)*N,m*pi-" case === Default
5420  G4double nucM = mNeut;
5421  G4int barPDG = 2112;
5422  G4double barM = mNeut;
5423  G4int nN = hBN-1; // a#of baryons - 1
5424  G4int tPDG = -211;
5425  G4double tM = mPi;
5426  G4int nPi = -cBN; // a#of Pi-'s
5427  if( cBN>hBN) // reinitialization for the "(n+m)*P,m*pi+" case
5428  {
5429  nuQPDG = pQPDG; // Substitute p for the first n
5430  nucM = mProt;
5431  barPDG = 2212; // Substitute p for the second n
5432  barM = mProt;
5433  tPDG = 211; // Substitute pi+ for the first pi-
5434  nPi = cBN-hBN; // a#0f Pi+'s
5435  }
5436  if(nPi>1) tM*=nPi;
5437  if(nN >1) barM*=nN;
5438  G4bool fOK=true;
5439  G4LorentzVector nu4M(0.,0.,0.,nucM);
5440  G4LorentzVector ba4M(0.,0.,0.,barM);
5441  G4LorentzVector pi4M(0.,0.,0.,tM);
5442  G4double sum=nucM+barM+tM;
5443  if(fabs(hM-sum)<=eps)
5444  {
5445  nu4M=h4Mom*(nucM/sum);
5446  ba4M=h4Mom*(barM/sum);
5447  pi4M=h4Mom*(tM/sum);
5448  }
5449  if(hM<sum || !G4QHadron(h4Mom).DecayIn3(nu4M,ba4M,pi4M))
5450  {
5451 #ifdef debug
5452  G4cout<<"***G4QEnv::FSI:IsN M="<<hM<<","<<hPDG<<"->N="<<nuQPDG<<"(M="<<nucM<<")+"
5453  <<nN<<"*B="<<barPDG<<"(M="<<barM<<")+"<<nPi<<"*pi="<<tPDG<<"(M="<<tM<<")="
5454  <<nucM+barM+tM<<G4endl;
5455  G4cout<<"***G4QEnv::FSI:IsN BaryN="<<hBN<<",Charge="<<cBN<<",Stran="<<sBN<<G4endl;
5456 #endif
5457  if(!theEnvironment.GetA()) // Emergency recovery
5458  {
5459  G4QHadron* theLast = theCurr; // Prototype of the pointer to the Last Hadron
5460  G4QHadron* qH = new G4QHadron(theCurr); // Copy of the Current Hadron
5461  if(ipo+1<theQHadrons.size()) // If ipo<Last, swap CurHadr and theLastHadr
5462  {
5463  theLast = theQHadrons[theQHadrons.size()-1];// Ptr to theLastHadron (ipo<Last)
5464  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
5465  if(lQP.GetPDGCode()!=10) theCurr->SetQPDG(lQP); //CurHadr instead of LastHadr
5466  else theCurr->SetQC(theLast->GetQC());// CurHadrPDG instead of LastHadrPDG
5467  theCurr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
5468  }
5469  theQHadrons.pop_back(); // exclude theLastHadron pointer from OUTPUT
5470  delete theLast; // *!! When killing, DON'T forget to delete the last QHadron !!*
5471  G4QContent cqQC=qH->GetQC();
5472  G4LorentzVector cq4M=qH->Get4Momentum();
5473  G4Quasmon* quasH = new G4Quasmon(cqQC,cq4M);// Create fakeQuasmon for the Last
5474  if(!CheckGroundState(quasH,true)) // Try to correct by other hadrons
5475  {
5476  G4cout<<"---Warning---G4QEnv::FSI:IN Failed, FillAsItIs: "<<cqQC<<cq4M<<G4endl;
5477  theQHadrons.push_back(qH); // Fill as it is (delete equivalent)
5478  }
5479  else
5480  {
5481  delete qH;
5482  jpo--;
5483  nHadr=theQHadrons.size();
5484  }
5485  delete quasH;
5486  fOK=false;
5487  }
5488  else
5489  {
5491  ed << "IN Multy ISO-dibaryon DecayIn3 did not succeed: IN,NoRec(4) Env="
5492  << theEnvironment << ",PDG=" << hPDG << G4endl;
5493  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0002",
5494  FatalException, ed);
5495  }
5496  }
5497  if(fOK)
5498  {
5499  theQHadrons[ipo]->SetQPDG(nuQPDG);
5500  theQHadrons[ipo]->Set4Momentum(nu4M);
5501  if(nN>1) ba4M=ba4M/nN;
5502  for(G4int ib=0; ib<nN; ib++)
5503  {
5504  G4QHadron* baH = new G4QHadron(barPDG,ba4M);
5505  theQHadrons.push_back(baH); // (delete equivalent)
5506  }
5507  if(nPi>1) pi4M=pi4M/nPi;
5508  for(G4int im=0; im<nPi; im++)
5509  {
5510  G4QHadron* piH = new G4QHadron(tPDG,pi4M);
5511  theQHadrons.push_back(piH); // (delete equivalent)
5512  }
5513  nHadr=theQHadrons.size();
5514  }
5515  }
5516 #ifdef debug
5517  G4int hNFrag= theQHadrons[ipo]->GetNFragments(); //Recover after swapping
5518  G4QContent hQC = theQHadrons[ipo]->GetQC(); // ...
5519  hPDG = theQHadrons[ipo]->GetPDGCode(); // ...
5520  h4Mom = theQHadrons[ipo]->Get4Momentum(); // ...
5521  ccs4M+=h4Mom; // Calculate CurSum of Hadrs
5522  G4cout<<"G4QE::FSI:#"<<ipo<<": h="<<hPDG<<hQC<<",h4M="<<h4Mom<<h4Mom.m()<<",hNF="
5523  <<hNFrag<<G4endl;
5524 #endif
5525  ipo=jpo; // Take into account the roll back in case of the Last substitution
5526  }
5527 #ifdef debug
5528  G4cout<<"G4QE::FSI: --->>CurrentControlSumOf4MomOfHadrons="<<ccs4M<<G4endl;
5529 #endif
5530  nHadr=theQHadrons.size();
5531 #ifdef chdebug
5532  // *** (1) Charge Control Sum Calculation for the Charge Conservation Check ***
5533  G4int ccContSum=0; // Intermediate ChargeControlSum
5534  G4int cbContSum=0; // Intermediate BaryonNumberControlSum
5535  if(nHadr)for(unsigned ic1=0; ic1<nHadr; ic1++) if(!(theQHadrons[ic1]->GetNFragments()))
5536  {
5537  ccContSum+=theQHadrons[ic1]->GetCharge();
5538  cbContSum+=theQHadrons[ic1]->GetBaryonNumber();
5539  }
5540  if(ccContSum-chContSum || cbContSum-bnContSum)
5541  {
5542  G4cout<<"*::*G4QE::FSI:(7)dC="<<ccContSum-chContSum<<",dB="<<cbContSum-bnContSum
5543  <<G4endl;
5544  //throw G4QException("G4QEnvironment::FSInteract: (1) Charge is not conserved");
5545  }
5546  // ***
5547 #endif
5548  G4double p2cut=250000.; // 250000=(2*p_Ferm)**2
5549  if(envA>0) p2cut/=envA*envA;
5550  //G4double p2cut2=0.; //cut for the alpha creation
5551  //
5552  G4int bfCountM=3;
5553  if(envA>10) bfCountM*=(envA-1)/3;
5554  G4bool bfAct = true;
5555  G4int bfCount= 0;
5556  G4LorentzVector tmp4Mom=tot4Mom;
5557  G4LorentzVector postp4M(0.,0.,0.,0.);
5558  G4int nPost=intQHadrons.size();
5559  if(nPost) for(G4int psp=0; psp<nPost; psp++)
5560  if(!(intQHadrons[psp]->GetNFragments())) postp4M+=intQHadrons[psp]->Get4Momentum();
5561  while(bfAct&&bfCount<bfCountM) // "Infinite" LOOP of the ThermoNuclearBackFusion
5562  {
5563  tot4Mom=tmp4Mom-postp4M; // Prepare tot4Mom for the "En/Mom conservation" reduction
5564  bfAct=false;
5565  bfCount++;
5566  nHadr=theQHadrons.size();
5567  if(nHadr) for(unsigned hadron=0; hadron<theQHadrons.size(); hadron++)// BackFusion LOOP
5568  {
5569  G4QHadron* curHadr = theQHadrons[hadron]; // Get a pointer to the current Hadron
5570  G4int hPDG = curHadr->GetPDGCode();
5571  G4QPDGCode hQPDG(hPDG);
5572  G4double hGSM = hQPDG.GetMass(); // Ground State Mass of the first fragment
5573 #ifdef debug
5574  G4cout<<"G4QE::FSI:LOOP START,h#"<<hadron<<curHadr->Get4Momentum()<<hPDG<<G4endl;
5575 #endif
5576  if(hPDG==89999003||hPDG==90002999)
5577  {
5578  G4cout<<"---WARNING---G4QE::FSI:**nD-/pD++**(3),PDG="<<hPDG<<" CORRECTION"<<G4endl;
5579  G4LorentzVector h4Mom=curHadr->Get4Momentum();
5580  G4double hM=h4Mom.m();
5581  G4QPDGCode fQPDG=nQPDG;
5582  G4double fM =mNeut;
5583  G4int sPDG =2112;
5584  G4double sM =mNeut;
5585  G4int tPDG =-211;
5586  G4double tM =mPi;
5587  if(hPDG==90002999)
5588  {
5589  fQPDG=pQPDG;
5590  fM =mProt;
5591  sPDG =2212;
5592  sM =mProt;
5593  tPDG =211;
5594  }
5595  G4bool fOK=true;
5596  G4LorentzVector f4M(0.,0.,0.,fM);
5597  G4LorentzVector s4M(0.,0.,0.,sM);
5598  G4LorentzVector t4M(0.,0.,0.,tM);
5599  G4double sum=fM+sM+tM;
5600  if(fabs(hM-sum)<=eps)
5601  {
5602  f4M=h4Mom*(fM/sum);
5603  s4M=h4Mom*(sM/sum);
5604  t4M=h4Mom*(tM/sum);
5605  }
5606  else if(hM<sum || !G4QHadron(h4Mom).DecayIn3(f4M,s4M,t4M))
5607  {
5608  G4cout<<"---WARNING---G4QE::FSI: Still trying, NDM="<<hM<<"->"<<fM<<"("<<fQPDG
5609  <<")+"<<sM<<"("<<sPDG<<")+"<<tM<<"("<<tPDG<<")="<<sum<<G4endl;
5610  if(!theEnvironment.GetA())
5611  {
5612  G4QHadron* theLast = curHadr; // Prototype of Pointer to theLastHadron
5613  G4QHadron* qH = new G4QHadron(curHadr);// Copy of the Current Hadron
5614  if(hadron+1<theQHadrons.size()) // If hadr<Last,swap CurHadr & LastHadr
5615  {
5616  theLast = theQHadrons[theQHadrons.size()-1]; // Pointer to LastHadr (nh<Last)
5617  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
5618  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of LastHadr
5619  else curHadr->SetQC(theLast->GetQC());// CurHadrPDG instead of LastHadrPDG
5620  curHadr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
5621  }
5622  theQHadrons.pop_back(); // exclude theLastHadron pointer from the OUTPUT
5623  delete theLast;// *!! When killing, DON'T forget to delete the last QHadron !!*
5624  G4Quasmon* quasH = new G4Quasmon(qH->GetQC(),qH->Get4Momentum());//Fake Quasmon
5625  if(!CheckGroundState(quasH,true)) // Try to correct by other hadrons
5626  {
5627  G4cout<<"---Warning---G4QE::FSI:NDel Failed LeaveAsItIs, 4m="<<h4Mom<<G4endl;
5628  theQHadrons.push_back(qH); // Leave as it is (delete equivalent)
5629  }
5630  else
5631  {
5632  delete qH;
5633  nHadr=theQHadrons.size();
5634  }
5635  delete quasH;
5636  fOK=false;
5637  }
5638  else
5639  {
5640  // G4cout<<"***G4QEnv::FSI: No ND recovery Env="<<theEnvironment<<G4endl;
5641  // throw G4QException("G4QEnv::FSI:ND DecayIn3 did not succeed");
5643  ed << "ND DecayIn3 did not succeed: No ND recovery Env="
5644  << theEnvironment << G4endl;
5645  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0003",
5646  FatalException, ed);
5647  }
5648  }
5649  if(fOK)
5650  {
5651  curHadr->SetQPDG(fQPDG);
5652  curHadr->Set4Momentum(f4M);
5653  G4QHadron* sH = new G4QHadron(sPDG,s4M);
5654  theQHadrons.push_back(sH); // (delete equivalent)
5655  G4QHadron* tH = new G4QHadron(tPDG,t4M);
5656  theQHadrons.push_back(tH); // (delete equivalent)
5657  }
5658  hPDG = curHadr->GetPDGCode(); // Change PDG Code of theFirstFragment
5659  hQPDG= G4QPDGCode(hPDG);
5660  hGSM = hQPDG.GetMass(); // Change GroundStateMass of theFirstFragm
5661  }
5662  nHadr=theQHadrons.size();
5663  if(hPDG==89001001||hPDG==89002000||hPDG==89000002)
5664  {
5665  G4cout<<"---WARNING---G4QE::FSI:***(K+N)*** (2),PDG="<<hPDG<<" CORRECTION"<<G4endl;
5666  G4LorentzVector h4Mom=curHadr->Get4Momentum();
5667  G4double hM=h4Mom.m();
5668  G4QPDGCode fQPDG=nQPDG;
5669  G4double fM =mNeut;
5670  G4int sPDG =311;
5671  G4double sM =mK0;
5672  if(hPDG==89000002)
5673  {
5674  fQPDG=pQPDG;
5675  fM =mProt;
5676  sPDG =321;
5677  sM =mK;
5678  }
5679  if(hPDG==89001001)
5680  {
5681  if(hM<mK0+mProt || G4UniformRand()>.5)
5682  {
5683  sPDG =321;
5684  sM =mK;
5685  }
5686  else
5687  {
5688  fQPDG=pQPDG;
5689  fM =mProt;
5690  }
5691  }
5692  G4bool fOK=true;
5693  G4LorentzVector f4M(0.,0.,0.,fM);
5694  G4LorentzVector s4M(0.,0.,0.,sM);
5695  G4double sum=fM+sM;
5696  if(fabs(hM-sum)<=eps)
5697  {
5698  f4M=h4Mom*(fM/sum);
5699  s4M=h4Mom*(sM/sum);
5700  }
5701  else if(hM<sum || !G4QHadron(h4Mom).DecayIn2(f4M,s4M))
5702  {
5703  G4cout<<"---WARNING---G4QE::FSI: Still trying (2),NDM="<<hM<<"->"<<fM<<"("<<fQPDG
5704  <<")+"<<sM<<"("<<sPDG<<")="<<sum<<G4endl;
5705  if(!theEnvironment.GetA())
5706  {
5707  G4QHadron* theLast = curHadr; // Prototype of Pointer to theLastHadron
5708  G4QHadron* qH = new G4QHadron(curHadr);// Copy of the Current Hadron
5709  if(hadron+1<theQHadrons.size()) // If hadr<Last, swap CurHadr & LastHadr
5710  {
5711  theLast = theQHadrons[theQHadrons.size()-1]; // Pointer to LastHadr (nh<Last)
5712  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
5713  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of LastHadr
5714  else curHadr->SetQC(theLast->GetQC());// CurHadrPDG instead of LastHadrPDG
5715  curHadr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
5716  }
5717  theQHadrons.pop_back(); // exclude theLastHadron pointer from the OUTPUT
5718  delete theLast;// *!! When killing, DON'T forget to delete the last QHadron !!*
5719  G4Quasmon* quasH = new G4Quasmon(qH->GetQC(),qH->Get4Momentum());//Fake Quasmon
5720  if(!CheckGroundState(quasH,true)) // Try to correct by other hadrons
5721  {
5722  G4cout<<"---Warning---G4QE::FSI:KN Failed LeaveAsItIs 4m="<<h4Mom<<G4endl;
5723  theQHadrons.push_back(qH); // Leave as it is (delete equivalent)
5724  }
5725  else
5726  {
5727  delete qH;
5728  nHadr=theQHadrons.size();
5729  }
5730  delete quasH;
5731  fOK=false;
5732  }
5733  else
5734  {
5735  // G4cerr<<"***G4QEnv::FSI: No KN recovery Env="<<theEnvironment<<G4endl;
5736  // throw G4QException("G4QEnv::FSI:KN DecayIn2 did not succeed");
5738  ed << "KN DecayIn2 did not succeed: No KN recovery Env="
5739  << theEnvironment << G4endl;
5740  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0004",
5741  FatalException, ed);
5742  }
5743  }
5744  if(fOK)
5745  {
5746  curHadr->SetQPDG(fQPDG);
5747  curHadr->Set4Momentum(f4M);
5748  G4QHadron* sH = new G4QHadron(sPDG,s4M);
5749  theQHadrons.push_back(sH); // (delete equivalent)
5750  }
5751  hPDG = curHadr->GetPDGCode(); // Change PDG Code of theFirstFragment
5752  hQPDG= G4QPDGCode(hPDG);
5753  hGSM = hQPDG.GetMass(); // Change GroundStateMass of theFirstFragm
5754  }
5755  nHadr=theQHadrons.size();
5756  G4int hS = curHadr->GetStrangeness();
5757  G4int hF = curHadr->GetNFragments();
5758  G4LorentzVector h4m= curHadr->Get4Momentum();
5759  G4double hM = h4m.m(); // Real Mass of the first fragment
5760  G4int hB = curHadr->GetBaryonNumber();
5762 #ifdef debug
5763  if(!hF && ( (hPDG>80000000 && hPDG<90000000) || hPDG==90000000 ||
5764  (hPDG>90000000 && (hPDG%1000000>200000 || hPDG%1000>300) ) ) )
5765  G4cout<<"**G4QEnv::FSInteraction: PDG("<<hadron<<")="<<hPDG<<", M="<<hM<<G4endl;
5766 #endif
5767 #ifdef debug
5768  G4cout<<"G4QE::FSI:h="<<hPDG<<",S="<<hS<<",B="<<hB<<",#"<<hadron<<"<"<<nHadr<<G4endl;
5769 #endif
5770  //if(hadron&&!hF&&hB>0&&!hS&&(nHadr>3||hB<2)) // ThermoBackFus (VIMP for gamA TotCS)
5771  //if(hadron&&!hF&&hB>0&&!hS&&(nHadr>2||hB<4)) // ThermoBackFus (VIMP for gamA TotCS)
5772  if(hadron&&!hF&&hB>0&&!hS) // ThermoBackFusion cond. (VIMP for gamA TotCS)
5773  //if(hadron&&!hF&&hB>0&&hB<4&&!hS) // ThermoBackFusion cond. (VIMP for gamA TotCS)
5774  //if(hadron&&!hF&&hB>0&&!hS&&nHadr>2)//ThermoBackFusion MAX condition (VIMP for gamA)
5775  //if(2>3) // Close the ThermoBackFusion (VIMP for gamA TotCS)
5776  {
5777 #ifdef debug
5778  //if(nHadr==3)
5779  G4cout<<"G4QE::FSI: h="<<hPDG<<",B="<<hB<<",h#"<<hadron<<" < nH="<<nHadr<<G4endl;
5780 #endif
5781  G4QContent hQC = curHadr->GetQC();
5782  if(hadron&&!hF&&hB>0) for(unsigned pt=0; pt<hadron; pt++)
5783  {
5784  G4QHadron* backH = theQHadrons[pt]; // Get pointer to one of thePreviousHadrons
5785  G4int bF = backH->GetNFragments();
5786  G4LorentzVector b4m= backH->Get4Momentum();
5787  G4double bM= b4m.m(); // Real Mass of the second fragment
5788  G4QContent bQC = backH->GetQC();
5789  G4int bPDG=bQC.GetZNSPDGCode();
5790  G4QPDGCode bQPDG(bPDG);
5791  G4double bGSM=bQPDG.GetMass(); // Ground State Mass of the second fragment
5792  G4int bB = backH->GetBaryonNumber();
5793 
5795  G4QContent sQC=bQC+hQC;
5796  G4int sPDG=sQC.GetZNSPDGCode();
5797  G4QPDGCode sQPDG(sPDG);
5798  G4double tM=sQPDG.GetMass();
5799  G4LorentzVector s4M=h4m+b4m;
5800  G4double sM2=s4M.m2();
5801  G4double sM=sqrt(sM2);
5802  G4double dsM2=sM2+sM2;
5803  G4double rm=bM-hM;
5804  G4double sm=bM+hM;
5805  G4double pCM2=(sM2-rm*rm)*(sM2-sm*sm)/(dsM2+dsM2);
5806  G4int bS = backH->GetStrangeness();
5807 #ifdef debug
5808  //if(nHadr==3)
5809  G4cout<<"G4QE::FSI:"<<pt<<",B="<<bB<<",S="<<bS<<",p="<<pCM2<<"<"<<p2cut<<",hB="
5810  <<hB<<",bM+hM="<<bM+hM<<">tM="<<tM<<",tQC="<<sQC<<G4endl;
5811 #endif
5812  //if(!bF&&(bB==1||hB==1)&&bM+hM>tM+.001&&pCM2<p2cut) // Only baryons == pcut
5813  //if(!bF&&!bS&&(bB==1&&hB>0||hB==1&&bB>0)&&bM+hM>tM+.00001
5814  // && (pCM2<p2cut&&nHadr>3||pCM2<p2cut2&&nHadr==3))
5815  //if(!bF&&(bB==1||hB==1)&&bM+hM>tM+.001&&(pCM2<p2cut&&nHadr>3 ||
5816  // pCM2<p2cut2&&nHadr==3&&bPDG>90000000))
5817  //if(!bF&&bB<4&&bM+hM>tM+.001&&pCM2<p2cut)
5818  if(!bF&&!bS&&bB>0&&bM+hM>tM+.001&&pCM2<p2cut)
5819  //if(!bF&&bB<4&&bM+hM>tM+.001&&(pCM2<p2cut || bB+hB==4&&pCM2<p2cut2))
5820  //if(!bF&&(bB==1||hB==1)&&(nHadr>3||bPDG>90000000)&&bM+hM>tM+.001&&pCM2<p2cut)
5821  //if(!bF&&(bB==1&&!bC||hB==1&&!hC)&&bM+hM>tM+.001&&pCM2<p2cut)// Only n == pcut
5822  //if(!bF&&(bB==1||hB==1)&&bM+hM>tM+.001&&sM-bM-hM<cut) // Only baryons == ecut
5823  //if(!bF&&bB&&bB<fL&&bM+hM>tM+.001&&sM-bM-hM<cut) // Light fragments == ecut
5824  {
5825 #ifdef fdebug
5826  G4int bPDG = backH->GetPDGCode();
5827  if(sPDG==89999003||sPDG==90002999||sPDG==89999002||sPDG==90001999)
5828  G4cout<<"G4QE::FSI:**nD-/pD++**,h="<<hPDG<<",hB="<<hB<<",b="<<bPDG<<",bB="
5829  <<bB<<G4endl;
5830  //if(nHadr==3)
5831  G4cout<<"G4QE::FSI:*FUSION*#"<<hadron<<"["<<hPDG<<"]"<<hM<<"+#"<<pt<<"["<<bPDG
5832  <<"]"<<bM<<"="<<bM+hM<<", sM="<<sM<<">["<<sPDG<<"]"<<tM<<",p2="<<pCM2
5833  <<"<"<<p2cut<<G4endl;
5834 #endif
5835  bfAct=true;
5836  //@@Temporary decay in gamma
5837  G4bool three=false;
5838  G4QPDGCode fQPDG=sQPDG;
5839  G4QPDGCode rQPDG=gQPDG;
5840  hQPDG=gQPDG;
5841  G4LorentzVector f4Mom(0.,0.,0.,tM);
5842  G4LorentzVector g4Mom(0.,0.,0.,0.);
5843  G4LorentzVector t4Mom(0.,0.,0.,0.);
5844  if(sPDG==89999002) // A=1
5845  {
5846  fQPDG=nQPDG;
5847  rQPDG=pimQPDG;
5848  f4Mom=G4LorentzVector(0.,0.,0.,mNeut);
5849  g4Mom=G4LorentzVector(0.,0.,0.,mPi);
5850  }
5851  else if(sPDG==90001999)
5852  {
5853  fQPDG=pQPDG;
5854  rQPDG=pipQPDG;
5855  f4Mom=G4LorentzVector(0.,0.,0.,mProt);
5856  g4Mom=G4LorentzVector(0.,0.,0.,mPi);
5857  }
5858  else if(sPDG==90000002) // A=2
5859  {
5860  fQPDG=nQPDG;
5861  rQPDG=nQPDG;
5862  f4Mom=G4LorentzVector(0.,0.,0.,mNeut);
5863  g4Mom=f4Mom;
5864  }
5865  else if(sPDG==90002000)
5866  {
5867  fQPDG=pQPDG;
5868  rQPDG=pQPDG;
5869  f4Mom=G4LorentzVector(0.,0.,0.,mProt);
5870  g4Mom=f4Mom;
5871  }
5872  else if(sPDG==92000000)
5873  {
5874  fQPDG=lQPDG;
5875  rQPDG=lQPDG;
5876  f4Mom=G4LorentzVector(0.,0.,0.,mLamb);
5877  g4Mom=f4Mom;
5878  if(sM>mSigZ+mSigZ) // Sigma0+Sigma0 is possible
5879  { // @@ Only two particles PS is used
5880  G4double sma=mLamb+mLamb; // Lambda+Lambda sum
5881  G4double pr1=0.; // Prototype to avoid sqrt(-)
5882  if(sM>sma) pr1=sqrt((sM2-sma*sma)*sM2); // Lamb+Lamb PS
5883  sma=mLamb+mSigZ; // Lambda+Sigma0 sum
5884  G4double smi=mSigZ-mLamb; // Sigma0-Lambda difference
5885  G4double pr2=pr1; // Prototype of +L +S0 PS
5886  if(sM>sma && sM>smi) pr2+=sqrt((sM2-sma*sma)*(sM2-smi*smi));
5887  sma=mSigZ+mSigZ; // Sigma0+Sigma0 sum
5888  G4double pr3=pr2; // Prototype of +Sigma0+Sigma0 PS
5889  if(sM>sma) pr3+=sqrt((sM2-sma*sma)*sM2);
5890  G4double hhRND=pr3*G4UniformRand(); // Randomize PS
5891  if(hhRND>pr2) // --> "ENnv+Sigma0+Sigma0" case
5892  { //
5893  fQPDG=s0QPDG;
5894  f4Mom=G4LorentzVector(0.,0.,0.,mSigZ);
5895  rQPDG=s0QPDG;
5896  g4Mom=f4Mom;
5897  } //
5898  else if(hhRND>pr1) // --> "ENnv+Sigma0+Lambda" case
5899  { //
5900  fQPDG=s0QPDG;
5901  f4Mom=G4LorentzVector(0.,0.,0.,mSigZ);
5902  } //
5903  }
5904  else if(sM>mSigZ+mLamb) // Lambda+Sigma0 is possible
5905  { // @@ Only two particles PS is used
5906  G4double sma=mLamb+mLamb; // Lambda+Lambda sum
5907  G4double pr1=0.; // Prototype to avoid sqrt(-)
5908  if(sM>sma) pr1=sqrt((sM2-sma*sma)*sM2); // Lamb+Lamb PS
5909  sma=mLamb+mSigZ; // Lambda+Sigma0 sum
5910  G4double smi=mSigZ-mLamb; // Sigma0-Lambda difference
5911  G4double pr2=pr1; // Prototype of +L +S0 PS
5912  if(sM>sma && sM>smi) pr2+=sqrt((sM2-sma*sma)*(sM2-smi*smi));
5913  if(pr2*G4UniformRand()>pr1) // --> "ENnv+Sigma0+Lambda" case
5914  { //
5915  fQPDG=s0QPDG;
5916  f4Mom=G4LorentzVector(0.,0.,0.,mSigZ);
5917  } //
5918  } //
5919  }
5920  else if(sPDG==89999003) // A=2
5921  {
5922  hQPDG=nQPDG;
5923  rQPDG=nQPDG;
5924  fQPDG=pimQPDG;
5925  t4Mom=G4LorentzVector(0.,0.,0.,mNeut);
5926  g4Mom=G4LorentzVector(0.,0.,0.,mNeut);
5927  f4Mom=G4LorentzVector(0.,0.,0.,mPi);
5928  three=true;
5929  }
5930  else if(sPDG==90002999)
5931  {
5932  hQPDG=pQPDG;
5933  rQPDG=pQPDG;
5934  fQPDG=pipQPDG;
5935  t4Mom=G4LorentzVector(0.,0.,0.,mProt);
5936  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
5937  f4Mom=G4LorentzVector(0.,0.,0.,mPi);
5938  three=true;
5939  }
5940  else if(sPDG==90000003) // A=3
5941  {
5942  hQPDG=nQPDG;
5943  rQPDG=nQPDG;
5944  fQPDG=nQPDG;
5945  t4Mom=G4LorentzVector(0.,0.,0.,mNeut);
5946  g4Mom=G4LorentzVector(0.,0.,0.,mNeut);
5947  f4Mom=G4LorentzVector(0.,0.,0.,mNeut);
5948  three=true;
5949  }
5950  else if(sPDG==90003000)
5951  {
5952  hQPDG=pQPDG;
5953  rQPDG=pQPDG;
5954  fQPDG=pQPDG;
5955  t4Mom=G4LorentzVector(0.,0.,0.,mProt);
5956  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
5957  f4Mom=G4LorentzVector(0.,0.,0.,mProt);
5958  three=true;
5959  }
5960  else if(sPDG==90001003) // A=4
5961  {
5962  rQPDG=nQPDG;
5963  fQPDG=tQPDG;
5964  g4Mom=G4LorentzVector(0.,0.,0.,mNeut);
5965  f4Mom=G4LorentzVector(0.,0.,0.,mTrit);
5966  }
5967  else if(sPDG==90003001)
5968  {
5969  rQPDG=pQPDG;
5970  fQPDG=he3QPDG;
5971  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
5972  f4Mom=G4LorentzVector(0.,0.,0.,mHe3);
5973  }
5974  else if(sPDG==90002003) // A=5
5975  {
5976  rQPDG=nQPDG;
5977  fQPDG=aQPDG;
5978  g4Mom=G4LorentzVector(0.,0.,0.,mNeut);
5979  f4Mom=G4LorentzVector(0.,0.,0.,mAlph);
5980  }
5981  else if(sPDG==90003002)
5982  {
5983  rQPDG=pQPDG;
5984  fQPDG=aQPDG;
5985  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
5986  f4Mom=G4LorentzVector(0.,0.,0.,mAlph);
5987  }
5988  else if(sPDG==90004002) // A=6
5989  {
5990  hQPDG=pQPDG;
5991  rQPDG=pQPDG;
5992  fQPDG=aQPDG;
5993  t4Mom=G4LorentzVector(0.,0.,0.,mProt);
5994  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
5995  f4Mom=G4LorentzVector(0.,0.,0.,mAlph);
5996  three=true;
5997  }
5998  else if(sPDG==90002005) // A=7
5999  {
6000  rQPDG=nQPDG;
6001  fQPDG=a6QPDG;
6002  g4Mom=G4LorentzVector(0.,0.,0.,mNeut);
6003  f4Mom=G4LorentzVector(0.,0.,0.,mHe6);
6004  }
6005  else if(sPDG==90005002)
6006  {
6007  rQPDG=pQPDG;
6008  fQPDG=be6QPDG;
6009  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
6010  f4Mom=G4LorentzVector(0.,0.,0.,mBe6);
6011  }
6012  else if(sPDG==90004004) // A=8
6013  {
6014  fQPDG=aQPDG;
6015  rQPDG=aQPDG;
6016  f4Mom=G4LorentzVector(0.,0.,0.,mAlph);
6017  g4Mom=f4Mom;
6018  }
6019  //else if(sPDG==90006002)
6020  //{
6021  // hQPDG=pQPDG;
6022  // rQPDG=pQPDG;
6023  // fQPDG=be6QPDG;
6024  // t4Mom=G4LorentzVector(0.,0.,0.,mProt);
6025  // g4Mom=G4LorentzVector(0.,0.,0.,mProt);
6026  // f4Mom=G4LorentzVector(0.,0.,0.,mBe6);
6027  // three=true;
6028  //}
6029  //else if(sPDG==90002006)
6030  //{
6031  // hQPDG=nQPDG;
6032  // rQPDG=nQPDG;
6033  // fQPDG=a6QPDG;
6034  // t4Mom=G4LorentzVector(0.,0.,0.,mNeut);
6035  // g4Mom=G4LorentzVector(0.,0.,0.,mNeut);
6036  // f4Mom=G4LorentzVector(0.,0.,0.,mHe6);
6037  // three=true;
6038  //}
6039  else if(sPDG==90002007) // A=9
6040  {
6041  rQPDG=nQPDG;
6042  fQPDG=a8QPDG;
6043  g4Mom=G4LorentzVector(0.,0.,0.,mNeut);
6044  f4Mom=G4LorentzVector(0.,0.,0.,mHe8);
6045  }
6046  else if(sPDG==90005004) // A=9
6047  {
6048  rQPDG=pQPDG;
6049  fQPDG=aQPDG;
6050  hQPDG=aQPDG;
6051  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
6052  f4Mom=G4LorentzVector(0.,0.,0.,mAlph);
6053  t4Mom=G4LorentzVector(0.,0.,0.,mAlph);
6054  three=true;
6055  }
6056  else if(sPDG==90007002) // A=9
6057  {
6058  rQPDG=pQPDG;
6059  fQPDG=c8QPDG;
6060  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
6061  f4Mom=G4LorentzVector(0.,0.,0.,mC8);
6062  }
6063  else if(sPDG==90008004) // A=12
6064  {
6065  hQPDG=pQPDG;
6066  rQPDG=pQPDG;
6067  fQPDG=c10QPDG;
6068  t4Mom=G4LorentzVector(0.,0.,0.,mProt);
6069  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
6070  f4Mom=G4LorentzVector(0.,0.,0.,mC10);
6071  three=true;
6072  }
6073  else if(sPDG==90009006) // A=15
6074  {
6075  rQPDG=pQPDG;
6076  fQPDG=o14QPDG;
6077  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
6078  f4Mom=G4LorentzVector(0.,0.,0.,mO14);
6079  }
6080  else if(sPDG==90009007) // A=16
6081  {
6082  rQPDG=pQPDG;
6083  fQPDG=o15QPDG;
6084  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
6085  f4Mom=G4LorentzVector(0.,0.,0.,mO15);
6086  }
6087  else if(sPDG==90010006) // A=16
6088  {
6089  hQPDG=pQPDG;
6090  rQPDG=pQPDG;
6091  fQPDG=o14QPDG;
6092  t4Mom=G4LorentzVector(0.,0.,0.,mProt);
6093  g4Mom=G4LorentzVector(0.,0.,0.,mProt);
6094  f4Mom=G4LorentzVector(0.,0.,0.,mO14);
6095  three=true;
6096  }
6097 #ifdef debug
6098  G4cout<<"G4QE::FSI: "<<three<<",r="<<rQPDG<<",f="<<fQPDG<<",t="<<hQPDG<<G4endl;
6099 #endif
6100  if(!three)
6101  {
6102  if(!G4QHadron(s4M).DecayIn2(f4Mom,g4Mom))
6103  {
6105  ed << "Fusion (1) DecIn2 error: (2)*FUSION*,tM[" << sPDG << "]="
6106  << tM << ">sM=" << sM << " of " << h4m << hM << hQC << hGSM
6107  << " & " << b4m << bM << bQC << bGSM << G4endl;
6108  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0005",
6109  FatalException, ed);
6110  }
6111  else
6112  {
6113 #ifdef debug
6114  G4cout<<"G4QE::FSI:*FUSION IS DONE*,fPDG="<<sPDG<<",PDG1="<<hPDG<<",PDG2="
6115  <<bPDG<<G4endl;
6116 #endif
6117  curHadr->SetQPDG(fQPDG);
6118  curHadr->Set4Momentum(f4Mom);
6119  backH->SetQPDG(rQPDG);
6120  backH->Set4Momentum(g4Mom);
6121 #ifdef debug
6122  G4cout<<"G4QE::FSI:h="<<h4m<<",b="<<b4m<<",s="<<s4M<<G4endl;
6123  G4cout<<"G4QE::FSI:f="<<f4Mom<<",g="<<g4Mom<<",s="<<f4Mom+g4Mom<<G4endl;
6124 #endif
6125  }
6126  }
6127  else
6128  {
6129  if(!G4QHadron(s4M).DecayIn3(f4Mom,g4Mom,t4Mom))
6130  {
6132  ed << "Fusion(2) DecayIn3 error: (3)*FUSION*,tM[" << sPDG
6133  << "]=" << tM << ">sM=" << sM << " of " << h4m << hM << hQC
6134  << hGSM << " & " << b4m << bM << bQC << bGSM << G4endl;
6135  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0006",
6136  FatalException, ed);
6137  }
6138  else
6139  {
6140 #ifdef debug
6141  G4cout<<"G4QE::FSI:DONE,n="<<nHadr<<",PDG="<<sPDG<<",1="<<hPDG<<",2="<<bPDG
6142  <<G4endl;
6143 #endif
6144  curHadr->SetQPDG(fQPDG);
6145  curHadr->Set4Momentum(f4Mom);
6146  backH->SetQPDG(rQPDG);
6147  backH->Set4Momentum(g4Mom);
6148  G4QHadron* newH = new G4QHadron(hQPDG.GetPDGCode(),t4Mom);
6149  theQHadrons.push_back(newH); // (delete equivalent for newH)
6150  nHadr=theQHadrons.size();
6151 #ifdef debug
6152  G4cout<<"G4QE::FSI:h="<<h4m<<",b="<<b4m<<G4endl;
6153  G4cout<<"G4QE::FSI:s="<<s4M<<" = Sum"<<f4Mom+g4Mom+t4Mom<<G4endl;
6154  G4cout<<"G4QE::FSI:*Products*,nH="<<nHadr<<",f="<<fQPDG<<f4Mom<<",b="
6155  <<rQPDG<<g4Mom<<",new="<<hQPDG<<t4Mom<<",nH="<<nHadr<<",nD="
6156  <<theQHadrons.size()<<G4endl;
6157 #endif
6158  }
6159  }
6160  tot4Mom+=b4m; // Instead of the fused hadron
6161  tot4Mom-=g4Mom; // subtract from the total the new hadron
6163  // Instead the curHadr parameters should be updated ______
6164  hQPDG=fQPDG;
6165  hPDG=hQPDG.GetPDGCode();
6166  hQC=fQPDG.GetQuarkContent();
6167  hS=hQC.GetStrangeness();
6168  hB=hQC.GetBaryonNumber();
6169  hGSM = hQPDG.GetMass();
6170  h4m=f4Mom;
6171  hM=h4m.m();
6172  // End of Instead ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6173 #ifdef debug
6174  G4cout<<"G4QE::FSI:cH4M="<<curHadr->Get4Momentum()<<G4endl;
6175 #endif
6176  } // End of the fusion check
6177  } // End of the LOOP over previous hadrons
6178  } // End of the FUSION check
6179 #ifdef chdebug
6180  // *** (2) Charge Control Sum Calculation for the Charge Conservation Check ***
6181  ccContSum=0; // Intermediate ChargeControlSum
6182  cbContSum=0; // Intermediate BaryonNumberControlSum
6183  if(nHadr)for(unsigned ic2=0;ic2<nHadr;ic2++) if(!(theQHadrons[ic2]->GetNFragments()))
6184  {
6185  ccContSum+=theQHadrons[ic2]->GetCharge();
6186  cbContSum+=theQHadrons[ic2]->GetBaryonNumber();
6187  }
6188  unsigned pHadr=intQHadrons.size();
6189  if(pHadr)for(unsigned ic3=0;ic3<pHadr;ic3++) if(!(intQHadrons[ic3]->GetNFragments()))
6190  {
6191  ccContSum+=intQHadrons[ic3]->GetCharge();
6192  cbContSum+=intQHadrons[ic3]->GetBaryonNumber();
6193  }
6194  if(ccContSum-chContSum || cbContSum-bnContSum)
6195  {
6196  G4cout<<"*::*G4QE::FSI:(8) dC="<<ccContSum-chContSum<<",dB="<<cbContSum-bnContSum
6197  <<G4endl;
6198  //throw G4QException("G4QEnvironment::FSInteract: (2) Charge is not conserved");
6199  }
6200  // ***
6201 #endif
6202  G4LorentzVector cH4Mom = curHadr->Get4Momentum(); // 4-mom of the current hadron
6203  tot4Mom-=cH4Mom; // Reduce theTotal 4mom by theCurrent 4mom
6204  totCharge-=curHadr->GetCharge(); // @!@
6205  totBaryoN-=curHadr->GetBaryonNumber(); // @!@
6206 #ifdef pdebug
6207  G4cout<<"G4QE::FSI:Cur4M="<<tot4Mom<<",tC="<<totCharge<<",tB="<<totBaryoN<<G4endl;
6208 #endif
6209  if(hadron+1==nHadr) // The Last Hadron in the set
6210  {
6211 #ifdef pdebug
6212  G4cout<<"G4QE::FSI:Last4M="<<tot4Mom<<",tC="<<totCharge<<",tB="<<totBaryoN<<G4endl;
6213 #endif
6214  G4double misM=0.; // @!@
6215  G4int mPDG=0; // @!@
6216  if(totCharge>=0 && totBaryoN > 0) // @!@
6217  { // @!@
6218  mPDG=90000000+999*totCharge+totBaryoN;// @!@
6219  misM=G4QPDGCode(mPDG).GetMass(); // @!@
6220  } // @!@
6221  G4double re =tot4Mom.e();
6222  G4double rpx=tot4Mom.px();
6223  G4double rpy=tot4Mom.py();
6224  G4double rpz=tot4Mom.pz();
6225  G4double re2=re*re; // @!@
6226  G4double dmo=rpx*rpx+rpy*rpy+rpz*rpz;
6227  G4double dem=re2+dmo;
6228  G4double dm2=re2-dmo; // @!@
6229  G4double sdm=0.; // @!@
6230  if(dm2>0.) sdm=std::sqrt(dm2); // @!@
6231 #ifdef debug
6232  G4cout<<"G4QE::FSI: Is En&Mom conserved? t4M="<<tot4Mom<<",dM="<<sdm<<", mM="<<misM
6233  <<",mPDG="<<mPDG<<",dCH="<<totCharge<<",dBN="<<totBaryoN<<G4endl;
6234 #endif
6235  G4LorentzVector cor4M(0.,0.,0.,0.); // Prototype for the missing particle
6236  if(dem>0.1) // Energy or momentum is not conserved
6237  {
6238  G4bool corf=false;
6239 #ifdef pdebug
6240  G4cout<<"--Warning--G4QE::FSI:dE/Mc4M="<<tot4Mom<<sdm<<". Correct it!"<<G4endl;
6241 #endif
6242  if(sdm < .01 || (re2 > 0. && !totCharge && !totBaryoN && sdm/re2 < .0001)) // @!@
6243  {
6244 #ifdef pdebug
6245  G4cout<<"...G4QE::FSI:E/M conservation is corrected by a photon"<<G4endl;
6246 #endif
6247  cor4M=tot4Mom; // Complete correction
6248  G4QHadron* theH = new G4QHadron(22,tot4Mom);
6249  theQHadrons.push_back(theH); // (delete equivalent for the proton)
6250  corf=true;
6251  }
6252  else // @!@
6253  {
6254  if(dmo<0.0001 && re>900.) // MomentumIsConserved - recoverMissing
6255  {
6256  if(fabs(re-mNeut)<.01)
6257  {
6258 #ifdef pdebug
6259  G4cout<<"...G4QE::FSI:E/M conservation is corrected by neutron"<<G4endl;
6260 #endif
6261  cor4M=G4LorentzVector(0.,0.,0.,mNeut);
6262  G4QHadron* theH = new G4QHadron(90000001,G4LorentzVector(0.,0.,0.,mNeut));
6263  theQHadrons.push_back(theH); // (delete equivalent for the proton)
6264  corf=true;
6265  }
6266  else if(fabs(re-mProt)<.01)
6267  {
6268 #ifdef pdebug
6269  G4cout<<"...G4QE::FSI:E/M conservation is corrected by proton"<<G4endl;
6270 #endif
6271  cor4M=G4LorentzVector(0.,0.,0.,mProt);
6272  G4QHadron* theH = new G4QHadron(90001000,G4LorentzVector(0.,0.,0.,mProt));
6273  theQHadrons.push_back(theH); // (delete equivalent for the proton)
6274  corf=true;
6275  }
6276  else if(fabs(re-mDeut)<.01)
6277  {
6278 #ifdef pdebug
6279  G4cout<<"...G4QE::FSI:E/M conservation is corrected by deuteron"<<G4endl;
6280 #endif
6281  cor4M=G4LorentzVector(0.,0.,0.,mDeut);
6282  G4QHadron* theH = new G4QHadron(90001001,G4LorentzVector(0.,0.,0.,mDeut));
6283  theQHadrons.push_back(theH); // (delete equivalent for the proton)
6284  corf=true;
6285  }
6286  else if(fabs(re-mTrit)<.01)
6287  {
6288 #ifdef pdebug
6289  G4cout<<"...G4QE::FSI:E/M conservation is corrected by tritium"<<G4endl;
6290 #endif
6291  cor4M=G4LorentzVector(0.,0.,0.,mTrit);
6292  G4QHadron* theH = new G4QHadron(90001002,G4LorentzVector(0.,0.,0.,mTrit));
6293  theQHadrons.push_back(theH); // (delete equivalent for the proton)
6294  corf=true;
6295  }
6296  else if(fabs(re-mHe3)<.01)
6297  {
6298 #ifdef pdebug
6299  G4cout<<"...G4QE::FSI:E/M conservation is corrected by He3"<<G4endl;
6300 #endif
6301  cor4M=G4LorentzVector(0.,0.,0.,mHe3);
6302  G4QHadron* theH = new G4QHadron(90002001,G4LorentzVector(0.,0.,0.,mHe3));
6303  theQHadrons.push_back(theH); // (delete equivalent for the proton)
6304  corf=true;
6305  }
6306  else if(fabs(re-mAlph)<.01)
6307  {
6308 #ifdef pdebug
6309  G4cout<<"...G4QE::FSI:E/M conservation is corrected by alpha"<<G4endl;
6310 #endif
6311  cor4M=G4LorentzVector(0.,0.,0.,mAlph);
6312  G4QHadron* theH = new G4QHadron(90002002,G4LorentzVector(0.,0.,0.,mAlph));
6313  theQHadrons.push_back(theH); // (delete equivalent for the proton)
6314  corf=true;
6315  }
6316  else if(fabs(re-mNeut-mNeut)<.01)
6317  {
6318  cor4M=G4LorentzVector(0.,0.,0.,mNeut+mNeut);
6319 #ifdef pdebug
6320  G4cout<<"...G4QE::FSI:E/M conservation is corrected by 2 neutrons"<<G4endl;
6321 #endif
6322  G4QHadron* theH1 = new G4QHadron(90000001,G4LorentzVector(0.,0.,0.,mNeut));
6323  theQHadrons.push_back(theH1); // (delete equivalent for the proton)
6324  G4QHadron* theH2 = new G4QHadron(90000001,G4LorentzVector(0.,0.,0.,mNeut));
6325  theQHadrons.push_back(theH2); // (delete equivalent for the proton)
6326  corf=true;
6327  }
6328  else if(fabs(re-mProt-mProt)<.01)
6329  {
6330 #ifdef pdebug
6331  G4cout<<"...G4QE::FSI:E/M conservation is corrected by 2 protons"<<G4endl;
6332 #endif
6333  cor4M=G4LorentzVector(0.,0.,0.,mProt+mProt);
6334  G4QHadron* theH1 = new G4QHadron(90001000,G4LorentzVector(0.,0.,0.,mProt));
6335  theQHadrons.push_back(theH1); // (delete equivalent for the proton)
6336  G4QHadron* theH2 = new G4QHadron(90001000,G4LorentzVector(0.,0.,0.,mProt));
6337  theQHadrons.push_back(theH2); // (delete equivalent for the proton)
6338  corf=true;
6339  }
6340  else G4Exception("G4QEnvironment::FSInteract()", "HAD_CHPS_0007",
6341  JustWarning, "Try heavier nuclei at rest");
6342  }
6343  else if(std::abs(sdm-misM) < 0.01) // on flight correction @!@
6344  {
6345 #ifdef pdebug
6346  G4cout<<"...G4QE::FSI:E/M conservation is corrected by ResidualNucl"<<G4endl;
6347 #endif
6348  if(!misM) mPDG=22;
6349  G4QHadron* theH = new G4QHadron(mPDG,tot4Mom); // Create Residual Nucleus
6350  cor4M=tot4Mom; // Complete correction
6351  if(std::fabs(sdm-misM) <= 0.01) theQHadrons.push_back(theH); // As is
6352  else EvaporateResidual(theH); // Evaporate Residual Nucleus
6353  corf=true;
6354  }
6355  else if(tot4Mom.e() > 0 && cH4Mom.e() > 0 && nHadr > 1) // TeV error check
6356  {
6357  G4QHadron* prevHadr = theQHadrons[nHadr-2]; // GetPointer to Prev to theLast
6358  G4LorentzVector pH4Mom = prevHadr->Get4Momentum(); // 4mom of thePrevHadron
6359  G4double cHM = curHadr->GetMass(); // Mass of the current hadron
6360  G4double pHM = prevHadr->GetMass(); // Mass of the previous hadron
6361 #ifdef pdebug
6362  G4cout<<"G4QE::FSI:Bt4M="<<tot4Mom<<",c4M="<<cH4Mom<<",p4M="<<pH4Mom<<G4endl;
6363 #endif
6364  G4LorentzVector tt4Mom=tot4Mom+cH4Mom+pH4Mom;
6365  G4double totRM=tt4Mom.m();
6366 #ifdef pdebug
6367  G4cout<<"G4QE::FS:"<<tt4Mom<<",tM="<<totRM<<",cM="<<cHM<<",pM="<<pHM<<G4endl;
6368 #endif
6369  if(cHM+pHM<=totRM) // *** Make the final correction ***
6370  {
6371  if(!G4QHadron(tt4Mom).DecayIn2(pH4Mom,cH4Mom))
6372  {
6373  G4cout<<"***G4QE::FSI:**Correction**tot4M="<<tt4Mom<<totRM<<">sM="
6374  <<cHM+cHM<<G4endl;
6375 #ifdef pdebug
6377  ed << "CORRECT DecIn2 error: **Correction**tot4M=" << tt4Mom
6378  << totRM << ">sM=" << cHM+cHM << G4endl;
6379  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0007",
6380  JustWarning, ed);
6381 #endif
6382  }
6383 #ifdef chdebug
6384  G4cout<<"-:-Warning-:-G4QE::FSI:***CORRECTION IS DONE*** d="<<dem<<G4endl;
6385 #endif
6386  cor4M=tot4Mom; // Complete correction
6387  curHadr->Set4Momentum(cH4Mom);
6388  prevHadr->Set4Momentum(pH4Mom);
6389  corf=true;
6390  }
6391  else
6392  {
6393 #ifdef pdebug
6394  G4cerr<<"*!*G4QE::FSI: "<<cHM<<"+"<<pHM<<"="<<cHM+pHM<<">"<<totRM<<G4endl;
6396  ed <<"TEMPORARY EXCEPTION: "<<cHM<<"+"<<pHM<<" = "<<cHM+pHM<<" > "<<totRM
6397  <<", tot4M="<<tot4Mom<<", c4M="<<cH4Mom<<", p4M="<<pH4Mom<< G4endl;
6398  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0008",
6399  JustWarning, ed);
6400 #endif
6401  }
6402  }
6403  else
6404  {
6405  G4cerr<<"*!*G4QE::FSI: tE="<<tot4Mom.e()<<", nHadr="<<nHadr<<G4endl;
6407  ed << "TEMPORARY EXCEPTION: *check energy!* tot4M=" << tot4Mom << ", c4M="
6408  << cH4Mom << ", nHadr="<< nHadr << " > 1 ?" << G4endl;
6409  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0009",
6410  JustWarning, ed);
6411  }
6412  tot4Mom=tot4Mom-cor4M;
6413 #ifdef pdebug
6414  G4cout<<"---Warning---G4QE::FSI:En/MomCons.Error is corrected:"<<cor4M<<G4endl;
6415 #endif
6416  }
6417  if(nHadr>2 && !corf)
6418  {
6419  G4double cHM = curHadr->GetMass(); // Mass of the current hadron
6420  G4int ch=0;
6421  for(ch=nHadr-3; ch>-1; --ch)
6422  {
6423  G4QHadron* prevHadr = theQHadrons[ch]; // GetPointer to Hadr prev to theLast
6424  G4LorentzVector pH4Mom = prevHadr->Get4Momentum();// 4M of thePreviousHadron
6425  G4double pHM = prevHadr->GetMass(); // Mass of the current hadron
6426  tot4Mom+=cH4Mom+pH4Mom;
6427  G4double totRM=tot4Mom.m();
6428  if(cHM+pHM<=totRM) // *** Make the final correction ***
6429  {
6430  if(!G4QHadron(tot4Mom).DecayIn2(pH4Mom,cH4Mom))
6431  {
6432  G4cout<<"***G4QEnv::FSI:**Correction**,tot4M="<<tot4Mom<<totRM<<" > sM="
6433  <<cHM+cHM<<G4endl;
6434 #ifdef debug
6436  ed << "CORRECTION DecIn2Error: **Correction**,tot4M=" << tot4Mom
6437  << totRM << " > sM=" << cHM+cHM << G4endl;
6438  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0010",
6439  FatalException, ed);
6440 #endif
6441  }
6442 #ifdef chdebug
6443  G4cout<<"-:-!!!-:-G4QE::FSI:***CORRECTION IS DONE*** d="<<dem<<G4endl;
6444 #endif
6445  curHadr->Set4Momentum(cH4Mom);
6446  prevHadr->Set4Momentum(pH4Mom);
6447  break; // Get out of the correction LOOP
6448  }
6449  else tot4Mom-=cH4Mom+pH4Mom;
6450  }
6451 #ifdef ppdebug
6452  if(ch<0)
6453  {
6455  ed << "EnMomCorrectionFailed: EnergyMomentumCorrection FAILED "
6456  << G4endl;
6457  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0011",
6458  FatalException, ed);
6459  }
6460 #endif
6461  } // End of additional attempt to correct EM by other hadrons
6462  }
6463 #ifdef debug
6464  else G4cout<<"...G4QE::FSI:E/M conservation is good enough"<<G4endl;
6465  G4cout<<"G4QE::FSI:EMCorrection by "<<theQHadrons.size()-nHadr<<" hadrons"<<G4endl;
6466 #endif
6467  break;
6468  }
6469  } // End of the Back fusion LOOP
6470  // >| 2 | 2 | 2 | 2 | 2 | 2 - old | 1. If gamma: add to sum4Mom
6471  // |>0->sum| 3 | 3 | 3 | 3 | 3 - old | 2. Compare BN with the Last
6472  // | 5 |>5 | 4 | 4 | 4 | 4 - old | 3. Swap if larger, del theLast
6473  // | 0 | 0 |>0->sum| 5<-sum| 5->evap| 2 - new | 4. If the Last: add the sum
6474  // | 4 | 4 | 5 | ex | |(0 - gamma?)| 5. Decay/Eporate the Last
6475  // | 3 | ex | | 3 - new
6476 #ifdef chdebug
6477  // *** (3) Charge Control Sum Calculation for the Charge Conservation Check ***
6478  ccContSum=0; // Intermediate ChargeControlSum
6479  cbContSum=0; // Intermediate BaryonNumberControlSum
6480  if(nHadr)for(unsigned ic3=0; ic3<nHadr; ic3++) if(!(theQHadrons[ic3]->GetNFragments()))
6481  {
6482  ccContSum+=theQHadrons[ic3]->GetCharge();
6483  cbContSum+=theQHadrons[ic3]->GetBaryonNumber();
6484  }
6485  if(ccContSum-chContSum || cbContSum-bnContSum)
6486  {
6487  G4cout<<"*::*G4QE::FSI:(9) dC="<<ccContSum-chContSum<<",dB="<<cbContSum-bnContSum
6488  <<G4endl;
6489  //throw G4QException("G4QEnvironment::FSInteract: (3) Charge is not conserved");
6490  }
6491  // ***
6492 #endif
6493  G4LorentzVector sum(0.,0.,0.,0.);
6494  G4int gamCount=0;
6495  nHadr=theQHadrons.size();
6496  G4bool frag=false;
6497  if(nHadr>2)for(unsigned f=0; f<theQHadrons.size(); f++) //Check that there's a fragment
6498  {
6499  G4int fBN=theQHadrons[f]->GetBaryonNumber(); // Baryon number of the fragment
6500 #ifdef debug
6501  G4int fPDG=theQHadrons[f]->GetPDGCode(); // PDG code of the fragment
6502  G4LorentzVector fLV=theQHadrons[f]->Get4Momentum(); // 4Mom of the fragment
6503  G4cout<<"G4QE::FSI:"<<f<<",PDG="<<fPDG<<",fBN="<<fBN<<",f4M="<<fLV<<G4endl;
6504 #endif
6505  if(fBN>1) // At least one fragment (A>1) is found
6506  {
6507  frag=true;
6508  break;
6509  }
6510  }
6511 #ifdef debug
6512  G4cout<<"G4QE::FSI:===Before Gamma Compression===, nH="<<nHadr<<",frag="<<frag<<G4endl;
6513 #endif
6514  if(nHadr>2 && frag) for(G4int h=nHadr-1; h>=0; h--)//Collect gammas & kill DecayedHadrs
6515  {
6516  G4QHadron* curHadr = theQHadrons[h]; // Get a pointer to the current Hadron
6517  G4int hF = curHadr->GetNFragments();
6518  G4int hPDG = curHadr->GetPDGCode();
6519  if(hPDG==89999003||hPDG==90002999)
6520  G4cout<<"---Warning---G4QEnv::FSI:nD-/pD++(1)="<<hPDG<<G4endl;
6521 #ifdef debug
6522  G4cout<<"G4QE::FSI: h#"<<h<<", hPDG="<<hPDG<<", hNFrag="<<hF<<G4endl;
6523 #endif
6524  if(hF||hPDG==22) // It should be compressed
6525  {
6526  G4QHadron* theLast = theQHadrons[theQHadrons.size()-1];//Get Ptr to the Last Hadron
6527  if(hPDG==22)
6528  {
6529  G4LorentzVector g4M=curHadr->Get4Momentum();
6530  sum+=g4M; // Add 4Mom of gamma to the "sum"
6531  gamCount++;
6532 #ifdef debug
6533  G4cout<<"G4QE::FSI: gam4M="<<g4M<<" is added to s4M="<<sum<<G4endl;
6534 #endif
6535  }
6536  nHadr = theQHadrons.size()-1;
6537  if(h < static_cast<G4int>(nHadr)) // Need swap with the Last
6538  {
6539  curHadr->SetNFragments(0);
6540  curHadr->Set4Momentum(theLast->Get4Momentum());
6541  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
6542  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of LastHadr
6543  else curHadr->SetQC(theLast->GetQC());// CurHadrPDG instead of LastHadrPDG
6544 #ifdef debug
6545  G4cout<<"G4QE::FSI: Exchange with the last is done"<<G4endl;
6546 #endif
6547  }
6548  theQHadrons.pop_back(); // theLastQHadron is excluded from QHadrons
6549  delete theLast;
6550 #ifdef debug
6551  G4cout<<"G4QE::FSI: The last is compessed"<<G4endl;
6552 #endif
6553  }
6554  }
6555 #ifdef debug
6556  G4cout<<"G4QE::FSI: nH="<<nHadr<<"="<<theQHadrons.size()<<", sum="<<sum<<G4endl;
6557 #endif
6558 #ifdef chdebug
6559  // *** (4) Charge Control Sum Calculation for the Charge Conservation Check ***
6560  ccContSum=0; // Intermediate ChargeControlSum
6561  cbContSum=0; // Intermediate BaryonNumberControlSum
6562  if(nHadr)for(unsigned ic4=0; ic4<nHadr; ic4++) if(!(theQHadrons[ic4]->GetNFragments()))
6563  {
6564  ccContSum+=theQHadrons[ic4]->GetCharge();
6565  cbContSum+=theQHadrons[ic4]->GetBaryonNumber();
6566  }
6567  if(ccContSum-chContSum || cbContSum-bnContSum)
6568  {
6569  G4cout<<"*::*G4QE::FSI:(A) dC="<<ccContSum-chContSum<<",dB="<<cbContSum-bnContSum
6570  <<G4endl;
6571  //throw G4QException("G4QEnvironment::FSInteract: (4) Charge is not conserved");
6572  }
6573  // ***
6574 #endif
6575  if(nHadr>1)for(unsigned hdr=0; hdr<theQHadrons.size()-1; hdr++)//Ord:theBigestIsTheLast
6576  {
6577  G4QHadron* curHadr = theQHadrons[hdr]; // Get a pointer to the current Hadron
6578 #ifdef debug
6579  G4cout<<"G4QE::FSI:ORD,h="<<hdr<<"<"<<nHadr<<",hPDG="<<curHadr->GetPDGCode()<<G4endl;
6580 #endif
6581  G4QHadron* theLast = theQHadrons[theQHadrons.size()-1]; //Get Ptr to the Last Hadron
6582  G4int hB = curHadr->GetBaryonNumber();
6583  G4int lB = theLast->GetBaryonNumber();
6584 #ifdef debug
6585  G4cout<<"G4QE::FSI:hBN="<<hB<<"<lBN="<<lB<<",lstPDG="<<theLast->GetPDGCode()<<G4endl;
6586 #endif
6587  if(lB<hB) // Must be swapped
6588  {
6589  G4QPDGCode hQPDG = curHadr->GetQPDG();
6590  G4LorentzVector h4m= curHadr->Get4Momentum();
6591  curHadr->Set4Momentum(theLast->Get4Momentum());
6592  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
6593  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of LastHadr
6594  else curHadr->SetQC(theLast->GetQC());// CurHadrPDG instead of LastHadrPDG
6595  theLast->Set4Momentum(h4m);
6596  theLast->SetQPDG(hQPDG);
6597  }
6598  }
6599  nHadr=theQHadrons.size();
6600 #ifdef chdebug
6601  // *** (5) Charge Control Sum Calculation for the Charge Conservation Check ***
6602  ccContSum=0; // Intermediate ChargeControlSum
6603  cbContSum=0; // Intermediate BaryonNumberControlSum
6604  if(nHadr)for(unsigned ic5=0; ic5<nHadr; ic5++) if(!(theQHadrons[ic5]->GetNFragments()))
6605  {
6606  ccContSum+=theQHadrons[ic5]->GetCharge();
6607  cbContSum+=theQHadrons[ic5]->GetBaryonNumber();
6608  }
6609  if(ccContSum-chContSum || cbContSum-bnContSum)
6610  {
6611  G4cout<<"*::*G4QE::FSI:(B) dC="<<ccContSum-chContSum<<",dB="<<cbContSum-bnContSum
6612  <<G4endl;
6613  //throw G4QException("G4QEnvironment::FSInteract: (5) Charge is not conserved");
6614  }
6615  // ***
6616 #endif
6617  if(gamCount)
6618  {
6619  G4QHadron* theLast = theQHadrons[nHadr-1];// Get a pointer to the Last Hadron
6620  if(theLast->GetBaryonNumber()>0) // "Absorb photons & evaporate/decay" case
6621  {
6622  G4QHadron* theNew = new G4QHadron(theLast); // Make New Hadron of the Last Hadron
6623 #ifdef ffdebug
6624  G4cout<<"G4QE::FSI:BeforeLastSub,n="<<nHadr<<",PDG="<<theNew->GetPDGCode()<<G4endl;
6625 #endif
6626  theQHadrons.pop_back(); // the last QHadron is excluded from OUTPUT
6627  delete theLast;// *!When kill,DON'T forget to delete theLastQHadron as anInstance!*
6628  nHadr--; // TheLastHadron is only virtually exists now
6629  G4int newPDG=theNew->GetPDGCode();
6630  G4LorentzVector new4M=theNew->Get4Momentum(); // 4-mom of the fragment
6631 #ifdef debug
6632  G4cout<<"G4QE::FSI:gSum4M="<<sum<<" is added to "<<new4M<<", PDG="<<newPDG<<G4endl;
6633 #endif
6634  G4LorentzVector exRes4M=new4M+sum; //Icrease 4Mom of theLast by "sum of gammas"
6635  G4QNucleus exResidN(exRes4M,newPDG);
6636  //G4double mGamEva=2700.; // @@Threshold for the evaporation
6637  G4double mGamEva=1700.; // @@Threshold for the evaporation
6638  if(exResidN.SplitBaryon())
6639  //if(2>3) //CloseTheFirstPriorityResN+gamSumEvaporation
6640  {
6641  theNew->Set4Momentum(exRes4M); // Icrease 4Mom of theLast by "sum" to Evapor
6642 #ifdef ffdebug
6643  G4cout<<"G4QE::FSI:BeforeE(1),n="<<nHadr<<",nPDG="<<theNew->GetPDGCode()<<G4endl;
6644 #endif
6645  EvaporateResidual(theNew); // Try to evaporate the Nucl.(@@DecDib)(d.e.)
6646  }
6647  else if(theNew->GetPDGCode()==90002002&&exRes4M.m()>mHe3+mNeut&&G4UniformRand()>.5)
6648  {
6649  theNew->Set4Momentum(exRes4M); // Icrease 4Mom of theLast by "sum" to Evapor
6650  G4LorentzVector n4M(0.,0.,0.,mNeut);
6651  G4LorentzVector h4M(0.,0.,0.,mHe3);
6652  if(!theNew->DecayIn2(n4M,h4M))
6653  {
6655  ed << "GamSUPPRES DecIn2(n+He3)error: GamSup, tM=" << exRes4M.m()
6656  << "<n+He3=" << mNeut+mHe3 << G4endl;
6657  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0012",
6658  FatalException, ed);
6659  }
6660 #ifdef ffdebug
6661  G4cout<<"G4QE::FSI:Gamma Suppression succided, n="<<n4M<<", He3="<<h4M<<G4endl;
6662 #endif
6663  theNew->Set4Momentum(n4M);
6664  theNew->SetQPDG(nQPDG); // convert the alpha to the neutron
6665  theQHadrons.push_back(theNew); // (delete equivalent for theHad=neutron)
6666  G4QHadron* theHe3 = new G4QHadron(90002001,h4M);// Make a New Hadr for the He3
6667  theQHadrons.push_back(theHe3); // (delete equivalent for the proton)
6668  }
6669  else if(nHadr) // Get LastHadrBefResNuc, absorb gam & decay
6670  //else if(2>3) // Close the pair absorbtion of gamma
6671  {
6672  if(nHadr>1)for(unsigned sh=0; sh<theQHadrons.size()-1; sh++)//Ord:MinE is TheLast
6673  {
6674  G4QHadron* curHadr = theQHadrons[sh];// Get a pointer to the current Hadron
6675  G4QHadron* thePrev = theQHadrons[theQHadrons.size()-1]; //GetPtr to theLastHadr
6676  G4LorentzVector h4M= curHadr->Get4Momentum();
6677  G4LorentzVector l4M= thePrev->Get4Momentum();
6678 #ifdef ffdebug
6679  G4cout<<"G4QE::FSI:SO,h="<<sh<<"<"<<nHadr<<",PDG/LV="<<curHadr->GetPDGCode()
6680  <<h4M<<G4endl;
6681 #endif
6682  G4double hM=h4M.m();
6683  G4double hT=h4M.e()-hM;
6684  G4double lT=l4M.e()-l4M.m();
6685 #ifdef ffdebug
6686  G4cout<<"G4QE::FSI:hT="<<hT<<"<T="<<lT<<".PDG="<<thePrev->GetPDGCode()<<G4endl;
6687 #endif
6688  if(hM>mGamEva&&lT>hT) // Must be swapped as the current is smaller
6689  {
6690  G4QPDGCode hQPDG = curHadr->GetQPDG();
6691  curHadr->Set4Momentum(l4M);
6692  G4QPDGCode lQP=thePrev->GetQPDG(); // The QPDG of the previous
6693  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of PrevHadr
6694  else curHadr->SetQC(thePrev->GetQC());// CurHadrPDG instead of PrevHadrPDG
6695  thePrev->Set4Momentum(h4M);
6696  thePrev->SetQPDG(hQPDG);
6697  }
6698  }
6699  nHadr=theQHadrons.size();
6700  G4QHadron* thePrev = theQHadrons[nHadr-1]; // GetPtr to the BeforeResidNuclHadron
6701  if(thePrev->Get4Momentum().m()>mGamEva)
6702  {
6703  G4QHadron* theHad = new G4QHadron(thePrev);// MakeNewHadr of theBeforeResNuclH
6704 #ifdef ffdebug
6705  G4cout<<"G4QE::FSI:BeforeResidNucHadr nH="<<nHadr<<",hPDG="
6706  <<theHad->GetPDGCode()<<G4endl;
6707 #endif
6708  theQHadrons.pop_back(); // theLastQHadron excluded from OUTPUT
6709  delete thePrev;// *!When kill,DON'T forget to delete theLastQHadrAsAnInstance!*
6710  G4LorentzVector n4M=theNew->Get4Momentum();// 4Mom of theLast (biggest nucleus)
6711  G4LorentzVector h4M=theHad->Get4Momentum();// 4Mom of the previous Hadron in HV
6712  G4LorentzVector dh4M=exRes4M+h4M; // 4Mom of LH+PH+sum(gam) for theDecay
6713  G4double dhM=dh4M.m(); // M of LH+PH+sum(gammas) for theDecay
6714  if(theHad->GetPDGCode()==90001001&&dhM>n4M.m()+mProt+mNeut&&G4UniformRand()>.5)
6715  //if(2>3) // Close Possibility toSplitDeuteron
6716  {
6717  G4double nuM=n4M.m();
6718  h4M=G4LorentzVector(0.,0.,0.,mNeut);
6719  G4LorentzVector p4M(0.,0.,0.,mProt);
6720  G4double sum_value=nuM+mNeut+mProt;
6721  if(fabs(dhM-sum_value)<eps)
6722  {
6723  n4M=dh4M*(nuM/sum_value);
6724  h4M=dh4M*(mNeut/sum_value);
6725  p4M=dh4M*(mProt/sum_value);
6726  }
6727  else if(dhM<sum_value || !G4QHadron(dh4M).DecayIn3(n4M,h4M,p4M))
6728  {
6730  ed << "Gamma SUPPRESSION by D DecIn3error: GamSupByD,M="
6731  << dhM << "<A+p+n=" << sum_value << G4endl;
6732  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0013",
6733  FatalException, ed);
6734  }
6735 #ifdef ffdebug
6736  G4cout<<"G4QE::FSI:GamSuppression by d succided,h="<<h4M<<",A="<<n4M<<G4endl;
6737 #endif
6738  theHad->Set4Momentum(h4M);
6739  theHad->SetQPDG(nQPDG); // convert the deuteron to the neutron
6740  theQHadrons.push_back(theHad); // (delete equivalent for theHad=neutron)
6741  G4QHadron* theProt = new G4QHadron(90001000,p4M);// Make NewHadr for Proton
6742  theQHadrons.push_back(theProt); // (delete equivalent for the proton)
6743  theNew->Set4Momentum(n4M);
6744  EvaporateResidual(theNew); // TryToEvaporate theResNuc onceMore(del.eq.)
6745  }
6746  else
6747  {
6748  if(!G4QHadron(dh4M).DecayIn2(n4M,h4M))
6749  {
6751  ed << "GamSUPPRESSION (3) DecIn2 error: GamSup,M=" << dh4M.m()
6752  << "<A+h=" << n4M.m()+h4M.m() << G4endl;
6753  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0014",
6754  FatalException, ed);
6755  }
6756 #ifdef ffdebug
6757  G4cout<<"G4QE::FSI:Gamma Suppression succided, h="<<h4M<<", A="<<n4M<<G4endl;
6758 #endif
6759  theHad->Set4Momentum(h4M);
6760  theQHadrons.push_back(theHad); // (delete equivalent for theHad)
6761  theNew->Set4Momentum(n4M);
6762  EvaporateResidual(theNew); // Try to evaporate theResNuc (del.eq.)
6763  }
6764  }
6765  else
6766  {
6767  theNew->Set4Momentum(exRes4M); // Icrease 4MomOfTheLast by "sum" for Evapor
6768 #ifdef ffdebug
6769  G4cout<<"G4QE::FSI:BeforE(2),n="<<nHadr<<",PDG="<<theNew->GetPDGCode()<<G4endl;
6770 #endif
6771  EvaporateResidual(theNew); // Try to evaporate the Nucl.(@@DecDib)(delete eq.)
6772  }
6773  }
6774  else // Absorb gammas to theResidNucleus and evaporateIt
6775  {
6776  theNew->Set4Momentum(exRes4M);// Icrease 4Mom of the Last by the "sum" for Evap
6777  EvaporateResidual(theNew); // Try to evaporate the Nucl.(@@DecDib)(delete eq.)
6778 #ifdef ffdebug
6779  G4cout<<"G4QE::FSI:Bef.E(3),n="<<nHadr<<",PDG="<<newPDG<<",4M="<<exRes4M<<G4endl;
6780  unsigned nHN=theQHadrons.size();
6781  G4cout<<"G4QE::FSI:AfterEvaporation: nNew="<<nHN<<G4endl;
6782  if(nHN>nHadr)for(unsigned idp=nHadr; idp<nHN; idp++)
6783  G4cout<<"G4QE::FSI: h#"<<idp<<", PDG="<<theQHadrons[idp]->GetPDGCode()<<G4endl;
6784 #endif
6785  }
6786  //G4int onH=nHadr;
6787  nHadr=theQHadrons.size();
6788  //if(nHadr>onH) bfAct=true;
6789  } // End of "the last is the nucleus" case
6790  } // End of "There are gammas to assimilate"
6791  } // End of the While-LOOOP for the Back Fusion
6792  tot4Mom=tmp4Mom; // Recover tot4Mom after the "En/Mom conservation" reduction
6793  // Final attempt to alpha-decay the residual nucleus, suppressing the gamma ===
6794  G4int gamcnt=0; // Counter of the residual gammas at this level
6795  nHadr=theQHadrons.size();
6796  unsigned maxB=nHadr-1;
6797 #ifdef chdebug
6798  // *** (6) Charge Control Sum Calculation for the Charge Conservation Check ***
6799  ccContSum=0; // Intermediate ChargeControlSum
6800  cbContSum=0; // Intermediate BaryonNumberControlSum
6801  if(nHadr)for(unsigned ic6=0; ic6<nHadr; ic6++) if(!(theQHadrons[ic6]->GetNFragments()))
6802  {
6803  ccContSum+=theQHadrons[ic6]->GetCharge();
6804  cbContSum+=theQHadrons[ic6]->GetBaryonNumber();
6805  }
6806  if(ccContSum-chContSum || cbContSum-bnContSum)
6807  {
6808  G4cout<<"*::*G4QE::FSI:(C) dC="<<ccContSum-chContSum<<",dB="<<cbContSum-bnContSum
6809  <<G4endl;
6810  //throw G4QException("G4QEnvironment::FSInteract: (6) Charge is not conserved");
6811  }
6812  // ***
6813 #endif
6814  lHadr=theQHadrons[maxB]->GetBaryonNumber();
6815  G4int tHadr=lHadr; // Total Baryon number
6816  if(nHadr>1)for(unsigned ipo=0; ipo<theQHadrons.size()-1; ipo++) // Find BiggestNuclFragm
6817  {
6818  G4int hPDG = theQHadrons[ipo]->GetPDGCode();
6819  if(hPDG==22) gamcnt++;
6820  else
6821  {
6822  G4int hBN = theQHadrons[ipo]->GetBaryonNumber();
6823  tHadr+=hBN;
6824 #ifdef debug
6825  G4cout<<"G4QE::FSI:h#"<<ipo<<":hPDG="<<hPDG<<",hBN="<<hBN<<",nH="<<theQHadrons.size()
6826  <<G4endl;
6827 #endif
6828  if(hBN>lHadr)
6829  {
6830  lHadr=hBN;
6831  maxB=ipo;
6832  } // the current biggest nuclear fragment
6833  }
6834  }
6835 #ifdef debug
6836  G4cout<<"G4QE::FSI:max#"<<maxB<<",lB="<<lHadr<<",tBN="<<tHadr<<",gam="<<gamcnt<<G4endl;
6837 #endif
6838  nHadr=theQHadrons.size();
6839 #ifdef chdebug
6840  // *** (7) Charge Control Sum Calculation for the Charge Conservation Check ***
6841  ccContSum=0; // Intermediate ChargeControlSum
6842  cbContSum=0; // Intermediate BaryonNumberControlSum
6843  if(nHadr)for(unsigned ic7=0; ic7<nHadr; ic7++) if(!(theQHadrons[ic7]->GetNFragments()))
6844  {
6845  ccContSum+=theQHadrons[ic7]->GetCharge();
6846  cbContSum+=theQHadrons[ic7]->GetBaryonNumber();
6847  }
6848  if(ccContSum-chContSum || cbContSum-bnContSum)
6849  {
6850  G4cout<<"*::*G4QE::FSI:(D) dC="<<ccContSum-chContSum<<",dB="<<cbContSum-bnContSum
6851  <<G4endl;
6852  //throw G4QException("G4QEnvironment::FSInteract: (7) Charge is not conserved");
6853  }
6854  // ***
6855 #endif
6856  if(gamcnt&&tHadr>1) // Only if there are gammas one should act
6857  {
6858  if(maxB+1<nHadr) // If maxB<Last, swap theCurH and theLastH
6859  {
6860  G4QHadron* theCurr = theQHadrons[maxB]; // Pointer to the Current Hadron
6861  G4QHadron* theLast = theQHadrons[nHadr-1];// Pointer to the Last Hadron
6862  G4QHadron* curHadr = new G4QHadron(theCurr);//Remember theCurrentHadron to put on top
6863  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
6864  if(lQP.GetPDGCode()!=10) theCurr->SetQPDG(lQP); //CurHadr instead of PrevHadr
6865  else theCurr->SetQC(theLast->GetQC()); // CurHadrPDG instead of LastHadrPDG
6866  theCurr->Set4Momentum(theLast->Get4Momentum()); // ... continue substitution
6867  theQHadrons.pop_back(); // Rnt to theLastHadron is excluded from HV
6868  delete theLast;// *!!When kill,DON'T forget to delete the last QHadron as anInst. !!*
6869  theQHadrons.push_back(curHadr); // The current Hadron, which is the Biggest
6870  }
6871  nHadr=theQHadrons.size(); // Must be the same
6872  // Now it is necessary to absorb the photon (photons) and try to radiate alpha or evap.
6873  G4LorentzVector gamSum(0.,0.,0.,0.);
6874  if(nHadr>1)for(unsigned gp=0; gp<nHadr-1; gp++)// Find Gumma, remember and kill
6875  {
6876  G4QHadron* theCurr = theQHadrons[gp]; // Pointer to the Current Hadron
6877  G4int hPDG=theCurr->GetPDGCode();
6878 #ifdef debug
6879  G4cout<<"G4QE::FSI:gp#"<<gp<<", PDG="<<hPDG<<", is found"<<G4endl;
6880 #endif
6881  if(hPDG==22) // Photon is foun ond the "gp" position
6882  {
6883  gamSum=gamSum+theCurr->Get4Momentum(); // Accumulate the 4Momenta of the photon
6884 #ifdef debug
6885  G4cout<<"G4QE::FSI:Photon gp#"<<gp<<",nH="<<nHadr<<", update gS="<<gamSum<<G4endl;
6886 #endif
6887  unsigned nLast=nHadr-1; // position of theLastHadron (gp<nHadr-1)
6888  G4QHadron* theLast = theQHadrons[nLast]; // Pointer to the Last Hadron
6889 #ifdef debug
6890  G4int wcn=0;
6891 #endif
6892  while(nLast>=gp && theLast->GetPDGCode()==22) // "TheLast is a photon too" LOOP
6893  {
6894 #ifdef debug
6895  ++wcn;
6896 #endif
6897  if(nLast>gp)
6898  {
6899  gamSum=gamSum+theLast->Get4Momentum();// Accumulate 4-momentum of theLastPhoton
6900 #ifdef debug
6901  G4cout<<"G4QE::FSI:TheLastPhotonIsFound #"<<wcn<<",update gS="<<gamSum<<G4endl;
6902 #endif
6903  }
6904  theQHadrons.pop_back(); // Pnt to theLastHadr.is excluded from HV
6905  delete theLast;// *!!When kill,DON'T forget to delete theLastQHadron as anInst!!*
6906  nHadr=theQHadrons.size();
6907  nLast=nHadr-1;
6908  theLast = theQHadrons[nLast];
6909  }
6910  if(nLast>gp) // -> swapping with the last
6911  {
6912  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
6913  if(lQP.GetPDGCode()!=10) theCurr->SetQPDG(lQP); //CurHadr instead of PrevHadr
6914  else theCurr->SetQC(theLast->GetQC()); // CurHadrPDG instead of LastHadrPDG
6915  theCurr->Set4Momentum(theLast->Get4Momentum()); // ... continue substitution
6916  theQHadrons.pop_back(); // Pnt to theLastHadr.is excluded from HV
6917  delete theLast;// *!|When kill,DON'T forget to delete theLastQHadron as anInst!!*
6918  nHadr=theQHadrons.size();
6919 #ifdef debug
6920  G4cout<<"G4QE::FSI:RepBy lPDG="<<lQP<<", nH="<<nHadr<<", gS="<<gamSum<<G4endl;
6921 #endif
6922  }
6923  }
6924  }
6925  // @@ Now it is necessary to try to emit alpha or evaporate the residual nucleus
6926  G4QHadron* theLast = theQHadrons[nHadr-1]; // Pointer to the Last Hadron
6927  if(theLast->GetPDGCode()==22)
6928  {
6929  gamSum=gamSum+theLast->Get4Momentum(); // Accumulate 4-momentum of the LastPhoton
6930  theQHadrons.pop_back(); // Pnt to theLastHadr.is excluded from HV
6931  delete theLast; // *!!When kill,DON'T forget to delete theLastQHadron as an inst.!!*
6932  nHadr=theQHadrons.size();
6933 #ifdef debug
6934  G4cout<<"-Warning-G4QE::FSI: LastPhotonIsKilled, nH="<<nHadr<<",gS="<<gamSum<<G4endl;
6935 #endif
6936  theLast = theQHadrons[nHadr-1];
6937  }
6938  G4int nEx=nHadr-2; // position to be exchanged with theLast
6939  while(theLast->GetBaryonNumber()<1 && nEx>=0)// theLastHadron must be a nucleus (A>0)
6940  {
6941  G4QHadron* theEx=theQHadrons[nEx]; // A hadron to be exchanged with theLast
6942  G4LorentzVector ex4Mom=theEx->Get4Momentum();
6943  G4QPDGCode exQPDG=theEx->GetQPDG();
6944  G4QContent exQC=theEx->GetQC();
6945  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
6946  if(lQP.GetPDGCode()!=10) theEx->SetQPDG(lQP); //CurHadr instead of PrevHadr
6947  else theEx->SetQC(theLast->GetQC()); // CurHadrPDG instead of LastHadrPDG
6948  theEx->Set4Momentum(theLast->Get4Momentum());
6949  if(exQPDG.GetPDGCode()!=10) theLast->SetQPDG(exQPDG);
6950  else theLast->SetQC(exQC); // CurHadrPDG instead of LastHadrPDG
6951  theLast->Set4Momentum(ex4Mom);
6952  nEx--;
6953  }
6954  G4QHadron* curHadr = new G4QHadron(theLast); // Pnt to theCurrentHadron is theLastCopy
6955  theQHadrons.pop_back(); // Pnt to theLastHadron is excluded from OUTPUT
6956  delete theLast;// *!!When kill,DON'T forget to delete the LastQHadron as an instance!!*
6957  G4int theLB= curHadr->GetBaryonNumber();
6958  G4LorentzVector tR4M=curHadr->Get4Momentum()+gamSum;
6959  G4double tRM=tR4M.m(); // TotMass of theResidualNucleus to decay
6960  if(theLB>4)
6961  {
6962  G4QContent lrQC=curHadr->GetQC()-G4QContent(6,6,0,0,0,0);
6963  G4QNucleus lrN(lrQC);
6964  G4double lrM=lrN.GetMZNS();
6965  if(tRM>lrM+mAlph)
6966  {
6967  G4LorentzVector lr4M(0.,0.,0.,lrM);
6968  G4LorentzVector al4M(0.,0.,0.,mAlph);
6969  if(!G4QHadron(tR4M).DecayIn2(lr4M,al4M))
6970  {
6971  curHadr->Set4Momentum(tR4M);
6972  EvaporateResidual(curHadr); // delete equivalent
6973 #ifdef fdebug
6974  G4cout<<"G4QE::FSI: After Evap (1) nH="<<theQHadrons.size()<<G4endl;
6975 #endif
6976  }
6977  else
6978  {
6979  delete curHadr;
6980  G4int APDG=lrN.GetPDG();
6981 #ifdef debug
6982  G4cout<<"G4QE::FSI: Final A+alpha, A="<<APDG<<lr4M<<", a="<<al4M<<G4endl;
6983 #endif
6984  G4QHadron* lrH = new G4QHadron(APDG,lr4M);
6985  theQHadrons.push_back(lrH); // (delete equivalent for lrH)
6986  G4QHadron* alH = new G4QHadron(90002002,al4M);
6987  theQHadrons.push_back(alH); // (delete equivalent for alH)
6988  }
6989  }
6990  else
6991  {
6992  curHadr->Set4Momentum(tR4M);
6993  EvaporateResidual(curHadr); // delete equivalent
6994 #ifdef fdebug
6995  G4cout<<"G4QE::FSI: After Evap (2) nH="<<theQHadrons.size()<<G4endl;
6996 #endif
6997  }
6998  }
6999  else
7000  {
7001  curHadr->Set4Momentum(tR4M);
7002  EvaporateResidual(curHadr); // delete equivalent
7003 #ifdef fdebug
7004  G4cout<<"G4QE::FSI: After Evap (5) nH="<<theQHadrons.size()<<G4endl;
7005 #endif
7006  }
7007  }
7008  //Now just fill the output theFravment vector (User is responsible to ClearAndDestroy it)
7009  nHadr=theQHadrons.size();
7010 #ifdef chdebug
7011  // *** (8) Charge Control Sum Calculation for the Charge Conservation Check ***
7012  ccContSum=0; // Intermediate ChargeControlSum
7013  cbContSum=0; // Intermediate BaryonNumberControlSum
7014  if(nHadr)for(unsigned ic8=0; ic8<nHadr; ic8++) if(!(theQHadrons[ic8]->GetNFragments()))
7015  {
7016  ccContSum+=theQHadrons[ic8]->GetCharge();
7017  cbContSum+=theQHadrons[ic8]->GetBaryonNumber();
7018  }
7019  if(ccContSum-chContSum || cbContSum-bnContSum)
7020  {
7021  G4cout<<"*::*G4QE::FSI:(E) dC="<<ccContSum-chContSum<<",dB="<<cbContSum-bnContSum
7022  <<G4endl;
7023  //throw G4QException("G4QEnvironment::FSInteract: (8) Charge is not conserved");
7024  }
7025  // ***
7026 #endif
7027  if(nHadr) for(unsigned hd=0; hd<theQHadrons.size(); hd++)
7028  {
7029  //G4QHadron* curHadr = new G4QHadron(theQHadrons[hd]);
7030  G4QHadron* curHadr = theQHadrons[hd];
7031  G4int hPDG=curHadr->GetPDGCode();
7032  if(hPDG==22 && fabs(curHadr->Get4Momentum().e())<.00001) // E=0, gamma in the OUTPUT
7033  {
7034  unsigned lin=theQHadrons.size()-1;
7035  G4QHadron* theLast = theQHadrons[lin];// Pointer to theLastHadron in theQHadrVector
7036  if(lin>hd)
7037  {
7038  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
7039  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of PrevHadr
7040  else curHadr->SetQC(theLast->GetQC()); // CurHadrPDG instead of LastHadrPDG
7041  curHadr->Set4Momentum(theLast->Get4Momentum()); // ... continue substitution (4Mom)
7042  }
7043  //else break; // It's not necessary to delete: not copy to theFragments is enough
7044  delete theLast;// *!!When kill, DON'T forget to delete theLastQHadron asAnInstance!!*
7045  theQHadrons.pop_back(); //pointer to theLastHadron is excluded from HV
7046  hPDG=curHadr->GetPDGCode(); // Redefine thePDGCode of theCurrentHadron
7047  if(lin==hd) break;
7048  }
7049 #ifdef fdebug
7050  G4cout<<"G4QE::FSI: LOOP starts nH="<<nHadr<<", h#"<<hd<<", PDG="<<hPDG<<G4endl;
7051 #endif
7052  if(hPDG==89999003||hPDG==90002999) G4cout<<"G4QEnv::FSI:nD-/pD++(0)="<<hPDG<<G4endl;
7053  if(hPDG==89999004||hPDG==90003999) G4cout<<"G4QEnv::FSI:nnD-/ppD++(0)="<<hPDG<<G4endl;
7054  //if(hPDG==89998003||hPDG==90002998)G4cout<<"G4QE::FSI:D-Pi-/D++Pi+PDG="<<hPDG<<G4endl;
7055  if(hPDG>100000000) G4cout<<"***G4QE::FSI: h#"<<hd<<", wrong PDGCode="<<hPDG<<G4endl;
7056 #ifdef fdebug
7057  G4cout<<"G4QE::FSI:Copy is made with PDG="<<hPDG<<G4endl;//To compare with Original
7058 #endif
7059  G4int hBN=curHadr->GetBaryonNumber();
7060  G4int hCG=curHadr->GetCharge();
7061  G4int hST=curHadr->GetStrangeness();
7062  G4int hNF=curHadr->GetNFragments();
7063  G4bool fOK=true;
7064  if(hNF==-1) curHadr->SetNFragments(0);
7065  else if(hPDG==91000000) curHadr->SetQPDG(G4QPDGCode(3122));// Move to theNextLoop
7066  else if(hPDG==90998003||hPDG==91002998) // n,pi-,Sigma- OR p,pi+,Sigma+ (StrangeIso)
7067  { // @@ can be converted here to B>2
7068 #ifdef fdebug
7069  G4cout<<"G4QE::FSI: Pi+Nuc+Sigma state decay is found PDG="<<hPDG<<G4endl;
7070 #endif
7071  G4LorentzVector r4M=curHadr->Get4Momentum(); // Real 4-mom of theIsoNucleus
7072  G4double reM=r4M.m(); // Real mass of the IsoNucleus
7073  G4bool dub=false;
7074  G4int PDGnu=2112;
7075  G4double mNucl=mNeut;
7076  G4int PDGpi=-211;
7077  G4double mPion=mPi;
7078  G4int PDGsi=3112;
7079  G4double mSi=mSigM;
7080  G4double sum=mNucl+mPion+mSi;
7081  if(hPDG==90998003&&reM<sum) // Default -- values
7082  {
7083  PDGsi=2112;
7084  mSi=mNeut;
7085  mPion=mPi+mPi;
7086  sum=mNucl+mPion+mSi;
7087  dub=true;
7088  }
7089  if(hPDG==91002998) // Change -- default values to +++ values
7090  {
7091  mNucl=mProt;
7092  PDGnu=2212;
7093  PDGpi=211;
7094  PDGsi=3222;
7095  mSi =mSigP;
7096  sum=mNucl+mPion+mSi;
7097  if(reM<sum)
7098  {
7099  PDGsi=2212;
7100  mSi=mProt;
7101  sum=mNucl+mPion+mSi;
7102  }
7103  }
7104  G4LorentzVector n4M(0.,0.,0.,mNucl);
7105  G4LorentzVector p4M(0.,0.,0.,mPion);
7106  G4LorentzVector k4M(0.,0.,0.,mSi);
7107  if(fabs(reM-sum)<eps)
7108  {
7109  //G4cout<<"G4QE::FSI:*TMP* PiDelta split PDG="<<hPDG<<G4endl;//To find out why?
7110  n4M=r4M*(mNucl/sum);
7111  p4M=r4M*(mPion/sum);
7112  k4M=r4M*(mSi/sum);
7113  }
7114  else if(reM<sum || !G4QHadron(r4M).DecayIn3(n4M,p4M,k4M))
7115  {
7116  G4cout<<"---Warning---G4QE::FSI:Pi+N+Sigma recovery INPDG="<<hPDG<<","<<reM<<" < "
7117  <<mNucl<<"(PDG="<<PDGnu<<")+Pi="<<mPion<<")+Sigma="<<mSi<<"="<<sum<<G4endl;
7118  if(!theEnvironment.GetA())
7119  {
7120  G4QHadron* theLast = curHadr; // Prototype of Pointer to theLastHadron
7121  G4QHadron* qH = new G4QHadron(curHadr);// Copy of the Current Hadron
7122  if(hd+1<theQHadrons.size()) // If ipo<Last, swap CurHadr & LastHadr
7123  {
7124  theLast = theQHadrons[theQHadrons.size()-1]; // Pointer to LastHadr(ipo<Last)
7125  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
7126  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of PrevHadr
7127  else curHadr->SetQC(theLast->GetQC()); // CurHadrPDG instead of LastHadrPDG
7128  curHadr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
7129  }
7130  theQHadrons.pop_back(); // exclude theLastHadron pointer from the OUTPUT
7131  delete theLast; // *!! When killing, DON'T forget to delete the last QHadron !!*
7132  G4Quasmon* quasH = new G4Quasmon(qH->GetQC(),qH->Get4Momentum());//Fake Quasmon
7133  if(!CheckGroundState(quasH,true)) // Try to correct by other hadrons
7134  {
7135  qH->SetNFragments(-1); //@@ To avoid looping
7136  G4cout<<"---Warning---G4QE::FSI:PiNSig Failed, LeaveAsItIs 4m="<<r4M<<G4endl;
7137  theQHadrons.push_back(qH); // Leave as it is (delete equivalent)
7138  }
7139  else
7140  {
7141 #ifdef fdebug
7142  for(unsigned hp=0; hp<theQHadrons.size(); hp++)
7143  {
7144  G4QHadron* cpHadr = new G4QHadron(theQHadrons[hp]);
7145  G4int hpPDG=cpHadr->GetPDGCode();
7146  G4LorentzVector hpLV=cpHadr->Get4Momentum();
7147  G4cout<<"G4QE::FSI:h#"<<hp<<": hPDG="<<hpPDG<<", h4M="<<hpLV<<G4endl;
7148  }
7149 #endif
7150  delete qH;
7151  nHadr=theQHadrons.size();
7152  }
7153  delete quasH;
7154  fOK=false;
7155  }
7156  else
7157  {
7159  ed << "PiNucSigma Final Decay Error: No Final PiNSig recovery, Env="
7160  << theEnvironment << G4endl;
7161  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0015",
7162  FatalException, ed);
7163  }
7164 #ifdef fdebug
7165  G4cout<<"G4QEnv::FSI: PiNSi recover #"<<hd<<",PDG="<<curHadr->GetPDGCode()<<G4endl;
7166 #endif
7167  }
7168  if(fOK)
7169  {
7170 #ifdef fdebug
7171  G4cout<<"G4QE::FSI:PiNSigma==>"<<r4M<<"->N="<<PDGnu<<n4M<<"+Pi="<<PDGpi<<p4M
7172  <<"+ Sigma="<<PDGsi<<k4M<<G4endl;
7173 #endif
7174  curHadr->Set4Momentum(n4M);
7175  curHadr->SetQPDG(G4QPDGCode(PDGnu));// At least one nucleun always exists
7176  if(dub)
7177  {
7178  p4M/=2.;
7179  G4QHadron* Pid = new G4QHadron(PDGpi,p4M); // Create a Hadron for the pion
7180  theQHadrons.push_back(Pid); // Fill pion (delete equivalent)
7181  }
7182  G4QHadron* Pi = new G4QHadron(PDGpi,p4M); // Create a Hadron for the pion
7183  theQHadrons.push_back(Pi); // Fill pion (delete equivalent)
7184  G4QHadron* Si = new G4QHadron(PDGsi,k4M); // Create a Hadron for the Sigma
7185  theQHadrons.push_back(Si); // Fill Sigma (delete equivalent)
7186  }
7187 #ifdef fdebug
7188  G4cout<<"G4QE::FSI:*TMP* PiNSigma end up PDG="<<hPDG<<G4endl;//To find out why?
7189 #endif
7190  }
7191  else if(hPDG==89998003||hPDG==90002998) // Isonucleus (pi- + DEL- or pi+ + DEL++)
7192  { // @@ can be converted here to B>1
7193  //G4cout<<"G4QE::FSI:*TMP* PiDelta decay PDG="<<hPDG<<G4endl;//To find out why?
7194  G4double mNucl=mNeut;
7195  G4int PDGnu=2112;
7196  G4int PDGpi=-211;
7197  if(hPDG==90002998) // Change DEL- default values to DEL++ values
7198  {
7199  mNucl=mProt;
7200  PDGnu=2212;
7201  PDGpi=211;
7202  }
7203  //G4double nucM=mNucl*hBN;
7204  G4LorentzVector r4M=curHadr->Get4Momentum(); // Real 4-mom of theIsoNucleus
7205  G4double reM=r4M.m(); // Real mass of the IsoNucleus
7206  G4LorentzVector n4M(0.,0.,0.,mNucl);
7207  G4LorentzVector p4M(0.,0.,0.,mPi);
7208  G4LorentzVector k4M(0.,0.,0.,mPi);
7209  G4double sum=mNucl+mPi+mPi;
7210  if(fabs(reM-sum)<eps)
7211  {
7212  //G4cout<<"G4QE::FSI:*TMP* PiDelta split PDG="<<hPDG<<G4endl;//To find out why?
7213  n4M=r4M*(mNucl/sum);
7214  p4M=r4M*(mPi/sum);
7215  k4M=r4M*(mPi/sum);
7216  }
7217  else if(reM<sum || !G4QHadron(r4M).DecayIn3(n4M,p4M,k4M))
7218  {
7219  G4cout<<"---Warning---G4QE::FSI: Isonuc+Pi recovery INPDG="<<hPDG<<","<<reM<<" < "
7220  <<mNucl<<"(PDG="<<PDGnu<<") + 2*"<<mPi<<"="<<sum<<G4endl;
7221  if(!theEnvironment.GetA())
7222  {
7223  G4QHadron* theLast = curHadr; // Prototype of Pointer to theLastHadron
7224  G4QHadron* qH = new G4QHadron(curHadr);// Copy of the Current Hadron
7225  if(hd+1<theQHadrons.size()) // If ipo<Last, swap CurHadr & LastHadr
7226  {
7227  theLast = theQHadrons[theQHadrons.size()-1]; // Pointer to LastHadr(ipo<Last)
7228  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
7229  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of PrevHadr
7230  else curHadr->SetQC(theLast->GetQC()); // CurHadrPDG instead of LastHadrPDG
7231  curHadr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
7232  }
7233  theQHadrons.pop_back(); // exclude theLastHadron pointer from the OUTPUT
7234  delete theLast; // *!! When killing, DON'T forget to delete the last QHadron !!*
7235  G4Quasmon* quasH = new G4Quasmon(qH->GetQC(),qH->Get4Momentum());//Fake Quasmon
7236  if(!CheckGroundState(quasH,true)) // Try to correct by other hadrons
7237  {
7238  qH->SetNFragments(-1); //@@ To avoid looping
7239  G4cout<<"---Warning---G4QE::FSI:IsoN+Pi Failed, LeaveAsItIs 4m="<<r4M<<G4endl;
7240  theQHadrons.push_back(qH); // Leave as it is (delete equivalent)
7241  }
7242  else
7243  {
7244  delete qH;
7245  nHadr=theQHadrons.size();
7246  }
7247  delete quasH;
7248  fOK=false;
7249  }
7250  else
7251  {
7253  ed << "IsoNucl+Pi FinalDecayError: No Final IsoN+Pi recovery, Env="
7254  << theEnvironment << G4endl;
7255  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0016",
7256  FatalException, ed);
7257  }
7258 #ifdef fdebug
7259  G4cout<<"G4QEnv::FSI: PiDel recover #"<<hd<<",PDG="<<curHadr->GetPDGCode()<<G4endl;
7260 #endif
7261  }
7262  if(fOK)
7263  {
7264 #ifdef fdebug
7265  G4cout<<"G4QE::FSI:IsoNuc+Pi==>"<<r4M<<"->N="<<PDGnu<<n4M<<"+Pi="<<PDGpi<<p4M
7266  <<"+ Pi="<<PDGpi<<k4M<<G4endl;
7267 #endif
7268  curHadr->Set4Momentum(n4M);
7269  curHadr->SetQPDG(G4QPDGCode(PDGnu)); // At least one nucleun always exists
7270  G4QHadron* Pi1 = new G4QHadron(PDGpi,p4M); // Create a Hadron for the pion
7271  theQHadrons.push_back(Pi1); // Fill pion (delete equivalent)
7272  G4QHadron* Pi2 = new G4QHadron(PDGpi,k4M); // Create a Hadron for the pion
7273  theQHadrons.push_back(Pi2); // Fill pion (delete equivalent)
7274  }
7275 #ifdef fdebug
7276  G4cout<<"G4QE::FSI:*TMP* PiDelta end up PDG="<<hPDG<<G4endl;//To find out why?
7277 #endif
7278  }
7279  else if(hBN>0 && !hST && (hCG<0||hCG>hBN)) // Isonucleus (n*N+k*DEL- or n*P+k*DEL++)
7280  {
7281  G4double mNucl=mNeut;
7282  G4int PDGnu=2112;
7283  G4int PDGpi=-211;
7284  G4int nPi=-hCG; // Prototype of the minimum number of pions
7285  if(hCG>0) // Change DEL- default values to DEL++ values
7286  {
7287  mNucl=mProt;
7288  PDGnu=2212;
7289  PDGpi=211;
7290  nPi=hCG-hBN;
7291  }
7292  G4double nucM=mNucl*hBN;
7293  G4double pioM=mPi*nPi;
7294  G4LorentzVector r4M=curHadr->Get4Momentum(); // Real 4-mom of theIsoNucleus
7295  G4double reM=r4M.m(); // Real mass of the IsoNucleus
7296  G4LorentzVector n4M(0.,0.,0.,nucM);
7297  G4LorentzVector k4M(0.,0.,0.,pioM);
7298  G4double sum=nucM+pioM;
7299  if(fabs(reM-sum)<eps)
7300  {
7301  n4M=r4M*(nucM/sum);
7302  k4M=r4M*(pioM/sum);
7303  }
7304  else if(reM<sum || !G4QHadron(r4M).DecayIn2(n4M,k4M))
7305  {
7306 #ifdef fdebug
7307  G4cout<<"---Warning---G4QE::FSI: Isonucleus recovery INPDG="<<hPDG<<", M="<<reM
7308  <<" < "<<nucM<<"+"<<pioM<<"="<<sum<<G4endl;
7309 #endif
7310  if(!theEnvironment.GetA())
7311  {
7312  G4QHadron* theLast = curHadr; // Prototype of Pointer to theLastHadron
7313  G4QHadron* qH = new G4QHadron(curHadr);// Copy of the Current Hadron
7314  G4QContent tQC=qH->GetQC(); // Quark content of the hadron
7315  G4LorentzVector t4M=qH->Get4Momentum();// 4Momentum of the hadron
7316  if(hd+1<theQHadrons.size()) // If ipo<Last, swap CurHadr & LastHadr
7317  {
7318  theLast = theQHadrons[theQHadrons.size()-1]; // Pointer to LastHadr(ipo<Last)
7319  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
7320  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of PrevHadr
7321  else curHadr->SetQC(theLast->GetQC()); // CurHadrPDG instead of LastHadrPDG
7322  curHadr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
7323  }
7324  theQHadrons.pop_back(); // exclude theLastHadron pointer from the OUTPUT
7325  delete theLast; // *!! When killing, DON'T forget to delete the last QHadron !!*
7326  G4Quasmon* quasH = new G4Quasmon(tQC,t4M); // Fake Quasmon for the Recovery
7327  if(!CheckGroundState(quasH,true)) // Try to correct by other hadrons
7328  {
7329  G4int tPDG=qH->GetPDGCode();
7330  qH->SetNFragments(-1); // @@ To avoid looping
7331  G4cout<<"---Warning---G4QE::FSI:IsoN="<<tPDG<<tQC<<" FAsIs 4m="<<t4M<<G4endl;
7332  theQHadrons.push_back(qH); // Leave as it is (delete equivalent)
7333  }
7334  else
7335  {
7336 #ifdef fdebug
7337  for(unsigned hp=0; hp<theQHadrons.size(); hp++)
7338  {
7339  G4QHadron* cpHadr = new G4QHadron(theQHadrons[hp]);
7340  G4int hpPDG=cpHadr->GetPDGCode();
7341  G4LorentzVector hpLV=cpHadr->Get4Momentum();
7342  G4cout<<"G4QE::FSI:h#"<<hp<<": hPDG="<<hpPDG<<", h4M="<<hpLV<<G4endl;
7343  }
7344 #endif
7345  delete qH; // Temporary Hadron is used for recovery
7346  nHadr=theQHadrons.size();
7347  }
7348  delete quasH; // TemporaryQuasmon is used for recovery
7349  fOK=false;
7350  }
7351  else
7352  {
7354  ed << "IsoNucleus FinalDecayError: No FinalIsoNucRecovery, Env="
7355  << theEnvironment << G4endl;
7356  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0017",
7357  FatalException, ed);
7358  }
7359 #ifdef fdebug
7360  G4cout<<"G4QEnv::FSI: Isonucleus recovery outPDG="<<curHadr->GetPDGCode()<<G4endl;
7361 #endif
7362  }
7363  if(fOK)
7364  {
7365 #ifdef fdebug
7366  G4cout<<"G4QE::FSI:IsoN==>"<<r4M<<"->N="<<PDGnu<<n4M<<"+Pi="<<PDGpi<<k4M<<G4endl;
7367 #endif
7368  if(hBN>1) n4M/=hBN; // Calculate the 4mom per one nucleon
7369  curHadr->Set4Momentum(n4M);
7370  curHadr->SetQPDG(G4QPDGCode(PDGnu)); // At least one nucleun always exists
7371  if(hBN>1) for(G4int ih=1; ih<hBN; ih++)
7372  {
7373  G4QHadron* Hi = new G4QHadron(PDGnu,n4M); // Create a Hadron for the baryon
7374  theQHadrons.push_back(Hi); // (del.eq.- user is responsible for del)
7375  //theFragments->push_back(Hi); // Fill nucleons (delete equivalent)
7376  }
7377  if(nPi>1) k4M/=nPi;
7378  for(G4int ip=0; ip<nPi; ip++)
7379  {
7380  G4QHadron* Hj = new G4QHadron(PDGpi,k4M); // Create a Hadron for the pion
7381  theQHadrons.push_back(Hj); // Fill pion (delete equivalent)
7382  }
7383  }
7384 #ifdef fdebug
7385  G4cout<<"G4QEnv::FSI: Isonucleus decay result h#="<<hd<<", outPDG="<<hPDG<<G4endl;
7386 #endif
7387  }
7388  else if ( hBN > 1 &&
7389  ( (hBN == hCG && !hST) ||
7390  (!hCG && !hST) ||
7391  (!hCG && hST==hBN) ) ) //(n*P, n*N, or n*L)
7392  {
7393  // *** Temporary Correction *** (To find out where is the error)
7394  if(hPDG==90000003 && fabs(curHadr->Get4Momentum().m()-mNeut-mNeut)<.1) {
7395  hPDG=90000002;
7396  hBN=2;
7397  G4cout<<"--Warning--G4QEnv::FSI:3->2 neutrons conversion (***Check it***)"<<G4endl;
7398  }
7399  // End of the Temporary Correction
7400  if (!hCG&&!hST) hPDG=90000001;
7401  else if(hBN==hCG&&!hST) hPDG=90001000;
7402  else if(!hCG&&hST==hBN) hPDG=91000000;
7403  else {
7404  // throw G4QException("***G4QEnvironment::FSInteract: MultyDibaryon cant be here");
7405  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0018",
7406  FatalException, "MultyDibaryon cant be here");
7407  }
7408  G4LorentzVector newLV=(curHadr->Get4Momentum())/hBN;
7409  curHadr->Set4Momentum(newLV);
7410  curHadr->SetQPDG(G4QPDGCode(hPDG));
7411  for(G4int bd=1; bd<hBN; bd++)
7412  {
7413  G4QHadron* secHadr = new G4QHadron(curHadr);
7414  theQHadrons.push_back(secHadr); // (del.eq.- user is responsible for del)
7415  //theFragments->push_back(secHadr);// (del.equiv. - user is responsible for that)
7416  }
7417  }
7418  else if(hST<0 && hBN>0) // AntistrangeNucleus (@@ see above, already done)
7419  {
7420  G4LorentzVector r4M=curHadr->Get4Momentum(); // Real 4-mom of theAntiStrangeNucleus
7421  G4double reM=r4M.m(); // Real mass of the antiStrange nucleus
7422  G4QContent nQC=curHadr->GetQC(); // QCont of the Antistrange nucleus
7423  G4QNucleus newN0(nQC-K0QC);
7424  G4int RPDG=newN0.GetPDG();
7425  G4double mR=newN0.GetMZNS(); // Residual mass for K0
7426  G4double mKaon=mK0; // Prototype is mass of K0
7427  G4int kPDG =311; // Prototype is PDG of K0
7428  G4QNucleus newNp(nQC-KpQC);
7429  G4double mp=newNp.GetMZNS(); // Residual mass for K+
7430  if(mp+mK<mR+mK0) // Select K+ as the minimum mass of products
7431  {
7432  mR=mp;
7433  RPDG=newNp.GetPDG();
7434  mKaon=mK;
7435  kPDG=321;
7436  }
7437  G4double sum=mR+mKaon;
7438  if(sum>reM) // for GEANT4 (Can not decay in kaon and residual)
7439  {
7440  if(kPDG==321) // *** Very seldom *** "K+->pi+ conversion"
7441  {
7442  kPDG=211;
7443  mKaon=mPi;
7444  }
7445  else // *** Very seldom *** "K0(S=-1)->pi- conversion"
7446  {
7447  kPDG=111;
7448  mKaon=mPi0;
7449  }
7450  sum=mR+mKaon;
7451  }
7452  G4LorentzVector n4M(0.,0.,0.,mR);
7453  G4LorentzVector k4M(0.,0.,0.,mKaon);
7454  if(fabs(reM-sum)<eps)
7455  {
7456  n4M=r4M*(mR/sum);
7457  k4M=r4M*(mKaon/sum);
7458  }
7459  else if(reM<sum || !G4QHadron(r4M).DecayIn2(n4M,k4M))
7460  {
7461 #ifdef debug
7462 
7463  G4cout<<"---Warning---G4QE::FSI: Try to recover ASN="<<hPDG<<","<<reM<<"<"<<mR<<"+"
7464  <<mKaon<<"="<<sum<<G4endl;
7465 #endif
7466  if(!theEnvironment.GetA())
7467  {
7468  G4QHadron* theLast = curHadr; // Prototype of Pointer to theLastHadron
7469  G4QHadron* qH = new G4QHadron(curHadr);// Copy of the Current Hadron
7470  if(hd+1<theQHadrons.size()) // If ipo<Last, swap CurHadr & LastHadr
7471  {
7472  theLast = theQHadrons[theQHadrons.size()-1]; // Pointer to LastHadr(ipo<Last)
7473  G4QPDGCode lQP=theLast->GetQPDG(); // The QPDG of the last
7474  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP); //CurHadr instead of PrevHadr
7475  else curHadr->SetQC(theLast->GetQC()); // CurHadrPDG instead of LastHadrPDG
7476  curHadr->Set4Momentum(theLast->Get4Momentum()); // ... 4Momentum substitution
7477  }
7478  theQHadrons.pop_back(); // exclude theLastHadron pointer from the OUTPUT
7479  delete theLast; // *!! When killing, DON'T forget to delete the last QHadron !!*
7480  G4Quasmon* quasH = new G4Quasmon(qH->GetQC(),qH->Get4Momentum());//Fake Quasmon
7481  if(!CheckGroundState(quasH,true)) // Try to correct by other hadrons
7482  {
7483  qH->SetNFragments(-1); //@@ To avoid looping
7484 #ifdef debug
7485  G4cout<<"---Warning---G4QE::FSI:AntiStraN Failed LeaveAsItIs 4m="<<r4M<<G4endl;
7486 #endif
7487  theQHadrons.push_back(qH); // Leave as it is (delete equivalent)
7488  }
7489  else
7490  {
7491  delete qH;
7492  nHadr=theQHadrons.size();
7493  }
7494  delete quasH;
7495  fOK=false;
7496  }
7497  else
7498  {
7500  ed << "AntistrangeNucleus decayError: No Final AntiSN recovery, E="
7501  << theEnvironment << G4endl;
7502  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0019",
7503  FatalException, ed);
7504  }
7505  }
7506  if(fOK)
7507  {
7508 #ifdef fdebug
7509  G4cout<<"G4QE::FSI:AntiSN==>"<<r4M<<"->A="<<RPDG<<n4M<<"+K="<<kPDG<<k4M<<G4endl;
7510 #endif
7511  curHadr->Set4Momentum(k4M); // Kaon
7512  curHadr->SetQPDG(G4QPDGCode(kPDG));
7513  G4QHadron* theRes = new G4QHadron(RPDG,n4M);// Make a New Hadr for the residual
7514  EvaporateResidual(theRes); // Try to evaporate theResNuc (del.eq.)
7515  }
7516  }
7517  // =Lambda(Sigma0)= = Sigma+ = = Sigma- =
7518  else if(hPDG>90500000 && hPDG!=91000000 && hPDG!=91000999 && hPDG!=90999001 &&
7519  hPDG!=91999000 && hPDG!=91999999 && hPDG!=92998999 )
7520  // == Xi- == == Xi0 == === Omega- ===
7521  {
7522 #ifdef pdebug
7523  G4cout<<"***G4QEnvironment::FSI:*G4* Hypernucleus PDG="<<hPDG<<" must decay"<<G4endl;
7524 #endif
7525  G4int nL=curHadr->GetStrangeness(); // A number of Lambdas in the Hypernucleus
7526  G4int nB=curHadr->GetBaryonNumber(); // Total Baryon Number of the Hypernucleus
7527  G4int nC=curHadr->GetCharge(); // Charge of the Hypernucleus
7528  G4int nSM=0; // A#0f unavoidable Sigma-
7529  G4int nSP=0; // A#0f unavoidable Sigma+
7530  G4int nXZ=0; // A#0f unavoidable Xi0
7531  G4int nXM=0; // A#0f unavoidable Xi-
7532  G4int nOM=0; // A#0f unavoidable Omega-
7533  // @@ Now it does not include more complicated clusters as Omega-,Xi- (Improve)
7534  if(nC < 0) // Negative hypernucleus
7535  {
7536  if(-nC <= nL) // Negative Charge is smaller than Strange
7537  {
7538  if(nL <= nB) // ==> Big Hyper-nucleus
7539  {
7540  nSM=-nC; // Can be compensated by Sigma-
7541  nL+=nC; // Reduce the residual strangeness
7542  }
7543  else // ==> Lack of BaryonNumber (better use Xi-)
7544  {
7545  G4int nX=nL-nB;
7546  if(-nC <= nX && nL >= nX+nX) // Part or all Xi are Xi- (e.g. Xi-,Lambda)
7547  {
7548  nXM=-nC;
7549  if(nXM != nX) nXZ=nX-nXM; // The rest are Xi0
7550  nL-=nX+nX; // Xi reduce srangeness twice faster
7551  }
7552  else if(nL >= nX-nC) // Sigma- should be used in addition to Xi-
7553  { // e.g. Xi-, Sigma-
7554  nXM=nX;
7555  nSM=-nC-nX;
7556  nL-=nX-nC;
7557  }
7558  // @@ Don't close this warning as it costs days to find out this growing point!
7559  else G4cout<<"-Warning-G4QEn::FSI:*Improve*,-nC<=nL,nL>nB, PDG="<<hPDG<<G4endl;
7560  }
7561  }
7562  else // -nC can not be totally compensated by nL
7563  {
7564  nSM=nL; // The maximumNumber of Sigma- (theRest pi-)
7565  nL=0; // Kill the residualStrangeness (@notEnough)
7566  }
7567  }
7568  else if(nC>nB-nL) // Extra positive hypernucleus (nC>=0 here)
7569  { // Can't compensate theCharge by onlyProtons
7570  if(nC<=nB)
7571  {
7572  if(nL <= nB)
7573  {
7574  G4int dH=nB-nC;
7575  nSP=nL-dH; // Can be compensated by Sigma+
7576  nL=dH; // Reduce the residual strangeness
7577  }
7578  else if(nL<nB+nB) // Xi0 can be used
7579  {
7580  nXZ=nL-nB; // This is how many Xi0
7581  nL=nB-nL+nB; // a#of S=1 particles
7582  if(nC <= nL)
7583  {
7584  nSP=nC;
7585  nL-=nSP;
7586  }
7587  else
7588  {
7589  nSP=nL;
7590  nL=0;
7591  }
7592  }
7593  else if(nL > nB && ((nL-nB)/2)*2 == nL-nB && nC+nL <= nB+nB)// Omega- can be used
7594  {
7595  nOM=(nL-nB)/2; // This is how many Omega- can be made
7596  nL=nB+nB-nL-nC; // a#of Lambdas should be 0 !
7597  nSP=nOM-nC;
7598  }
7599  // @@ Do not close this warning as it costs days to find out this growing point !
7600  else G4cout<<"-Warning-G4QEn::FSI:*Improve*,nC>nB-nL,nC<=nB, PDG="<<hPDG<<G4endl;
7601  }
7602  else
7603  {
7604  nSP=nL; // The maximumNumber of Sigma+ (theRest pi+)
7605  nL=0; // Kill the residual strangeness
7606  }
7607  }
7608  // else = the charge can be compensated by nucleons
7609  G4LorentzVector r4M=curHadr->Get4Momentum(); // Real 4-momentum of the hypernucleus
7610  G4double reM=r4M.m(); // Real mass of the hypernucleus
7611  // Subtract Lamb/Sig/Xi/Omega from the Nucleus and decay
7612  G4int SS=nL+nSP+nSM+nXZ+nXM;
7613  if(SS<nB && !nOM) // Should not be Xi's or Omeg in the nucleus
7614  {
7615  G4int rlPDG = hPDG-nL*1000000-nSP*1000999-nSM*999001;
7616  G4int sPDG=3122; // Prototype for the Hyperon PDG (Lambda)
7617  G4double MLa=mLamb; // Prototype for one Hyperon decay
7618 #ifdef pdebug
7619  G4cout<<"G4QEnvironment::FSI:*G4* nS+="<<nSP<<", nS-="<<nSM<<", nL="<<nL<<G4endl;
7620 #endif
7621  if(nSP || nSM)
7622  {
7623  if(nL)
7624  {
7625  // Hopefully it never happens
7626  G4cout<<"-Warning-G4QE::FSI:*Improve*,PDG="<<hPDG<<": both Sigma&Lamb"<<G4endl;
7627  // @@ Bad Correction, which does not conserve the charge !! (-> add decay in 3)
7628  if(nSP) nL+=nSP;
7629  else nL+=nSM;
7630  }
7631  if(nSP)
7632  {
7633  nL=nSP;
7634  sPDG=3222;
7635  MLa=mSigP;
7636  }
7637  else
7638  {
7639  nL=nSM;
7640  sPDG=3112;
7641  MLa=mSigM;
7642  }
7643  }
7644 #ifdef pdebug
7645  G4cout<<"G4QEnvironment::FSI:*G4* mS="<<MLa<<", sPDG="<<sPDG<<", nL="<<nL<<G4endl;
7646 #endif
7647  if(nL>1) MLa*=nL;
7648  G4double rlM=G4QNucleus(rlPDG).GetMZNS();// Mass of theNewResidualNonstrangeNucleus
7649  if(!nSP&&!nSM&&nL==1&&reM>rlM+mSigZ&&G4UniformRand()>.5)// Sigma0 @@ AddToHadroniz?
7650  {
7651  sPDG=3212;
7652  MLa=mSigZ;
7653  }
7654  G4int rnPDG = hPDG-nL*999999; // Convert Lambdas to neutrons (for convInN)
7655  G4QNucleus rnN(rnPDG); // New nonstrange nucleus
7656  G4double rnM=rnN.GetMZNS(); // Mass of the new nonstrange nucleus
7657  // @@ Take into account that can be Iso-Hypernucleus (Add PI+,R & Pi-,R decays)
7658  if(rlPDG==90000000) // Multy Hyperon (HyperNuc of only hyperons)
7659  {
7660  if(nL>1) r4M=r4M/nL; // split the 4-mom for the MultyLambda
7661  for(G4int il=0; il<nL; il++) // loop over Lambdas
7662  {
7663  G4QHadron* theLam = new G4QHadron(sPDG,r4M);// Make a New Hadr for the Hyperon
7664  theQHadrons.push_back(theLam); // (del.eq.- user is responsible for del)
7665  }
7666  }
7667  else if(reM>rlM+MLa-eps) // Lambda(or Sigma) can be split
7668  {
7669  G4LorentzVector n4M(0.,0.,0.,rlM);
7670  G4LorentzVector h4M(0.,0.,0.,MLa);
7671  G4double sum=rlM+MLa;
7672  if(fabs(reM-sum)<eps)
7673  {
7674  n4M=r4M*(rlM/sum);
7675  h4M=r4M*(MLa/sum);
7676  }
7677  else if(reM<sum || !G4QHadron(r4M).DecayIn2(n4M,h4M))
7678  {
7680  ed << "Hypernuclear L-decay error: Hypern, M=" << reM << "<A+n*L="
7681  << sum << ",d=" << sum-reM << G4endl;
7682  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0020",
7683  FatalException, ed);
7684  }
7685 #ifdef pdebug
7686  G4cout<<"*G4QE::FSI:HypN="<<r4M<<"->A="<<rlPDG<<n4M<<",n*Lamb="<<nL<<h4M<<G4endl;
7687 #endif
7688  curHadr->Set4Momentum(n4M);
7689  curHadr->SetQPDG(G4QPDGCode(rlPDG)); // converted hypernucleus
7690  if(rlPDG==90000002) // Additional action with curHadr change
7691  {
7692  G4LorentzVector newLV=n4M/2.;
7693  curHadr->Set4Momentum(newLV);
7694  curHadr->SetQPDG(G4QPDGCode(90000001));
7695  G4QHadron* secHadr = new G4QHadron(curHadr);
7696  theQHadrons.push_back(secHadr); // (del.eq.- user is responsible for del)
7697  }
7698  else if(rlPDG==90002000) // Additional action with curHadr change
7699  {
7700  G4LorentzVector newLV=n4M/2.;
7701  curHadr->Set4Momentum(newLV);
7702  curHadr->SetQPDG(G4QPDGCode(90001000));
7703  G4QHadron* secHadr = new G4QHadron(curHadr);
7704  theQHadrons.push_back(secHadr); // (del.eq.- user is responsible for del)
7705  }
7706  // @@(?) Add multybaryon decays if necessary (Now it anyhow is made later)
7707 #ifdef pdebug
7708  G4cout<<"*G4QE::FSI: resNucPDG="<<curHadr->GetPDGCode()<<G4endl;
7709 #endif
7710  if(nL>1) h4M=h4M/nL; // split the lambda's 4-mom if necessary
7711  for(G4int il=0; il<nL; il++) // loop over excessive
7712  {
7713  G4QHadron* theLamb = new G4QHadron(sPDG,h4M);// Make a New Hadr for the Hyperon
7714  theQHadrons.push_back(theLamb); // (del.eq.- user is responsible for del)
7715  }
7716  }
7717  else if(reM>rnM+mPi0-eps&&!nSP&&!nSM) // Lambda->N only if Sigmas are absent
7718  {
7719  G4int nPi=static_cast<G4int>((reM-rnM)/mPi0);
7720  if (nPi>nL) nPi=nL;
7721  G4double npiM=nPi*mPi0;
7722  G4LorentzVector n4M(0.,0.,0.,rnM);
7723  G4LorentzVector h4M(0.,0.,0.,npiM);
7724  G4double sum=rnM+npiM;
7725  if(fabs(reM-sum)<eps)
7726  {
7727  n4M=r4M*(rnM/sum);
7728  h4M=r4M*(npiM/sum);
7729  }
7730  else if(reM<sum || !G4QHadron(r4M).DecayIn2(n4M,h4M))
7731  {
7733  ed << "Hypernuclear decay error: HyperN,M=" << reM << "<A+n*Pi0="
7734  << sum << ",d=" << sum-reM << G4endl;
7735  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0021",
7736  FatalException, ed);
7737  }
7738  curHadr->Set4Momentum(n4M);
7739  curHadr->SetQPDG(G4QPDGCode(rnPDG)); // converted hypernucleus
7740 #ifdef pdebug
7741  G4cout<<"*G4QE::FSI:HypN "<<r4M<<"->A="<<rnPDG<<n4M<<",n*Pi0="<<nPi<<h4M<<G4endl;
7742 #endif
7743  if(nPi>1) h4M=h4M/nPi; // split the 4-mom if necessary
7744  for(G4int ihn=0; ihn<nPi; ihn++) // loop over additional pions
7745  {
7746  G4QHadron* thePion = new G4QHadron(111,h4M);// Make a New Hadr for the pion
7747  theQHadrons.push_back(thePion); // (del.eq.- user is responsible for del)
7748  //theFragments->push_back(thePion); // (delete equivalent for the pion)
7749  }
7750  if(rnPDG==90000002) // Additional action with curHadr change
7751  {
7752  G4LorentzVector newLV=n4M/2.;
7753  curHadr->Set4Momentum(newLV);
7754  curHadr->SetQPDG(G4QPDGCode(90000001));
7755  G4QHadron* secHadr = new G4QHadron(curHadr);
7756  theQHadrons.push_back(secHadr); // (del.eq.- user is responsible for del)
7757  //theFragments->push_back(secHadr); // (del.eq.- user is responsible for del)
7758  }
7759  else if(rnPDG==90002000) // Additional action with curHadr change
7760  {
7761  G4LorentzVector newLV=n4M/2.;
7762  curHadr->Set4Momentum(newLV);
7763  curHadr->SetQPDG(G4QPDGCode(90001000));
7764  G4QHadron* secHadr = new G4QHadron(curHadr);
7765  theQHadrons.push_back(secHadr); // (del.eq.- user is responsible for del)
7766  //theFragments->push_back(secHadr); // (del.eq.- user is responsible for del)
7767  }
7768  // @@ Add multybaryon decays if necessary
7769  }
7770  else if(reM>rnM-eps) // Decay in nonstrange and gamma
7771  {
7772  G4LorentzVector n4M(0.,0.,0.,rnM);
7773  G4LorentzVector h4M(0.,0.,0.,0.);
7774  G4double sum=rnM;
7775  if(fabs(reM-sum)<eps) n4M=r4M;
7776  else if(reM<sum || !G4QHadron(r4M).DecayIn2(n4M,h4M))
7777  {
7779  ed << "Hypernuclear GammaDecay error: Hypern,M=" << reM << "<A+n*Pi0="
7780  << sum << ",d=" << sum-reM << G4endl;
7781  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0022",
7782  FatalException, ed);
7783  }
7784  curHadr->Set4Momentum(n4M);
7785  curHadr->SetQPDG(G4QPDGCode(rnPDG)); // converted hypernucleus
7786 #ifdef pdebug
7787  G4cout<<"*G4QE::FSI:HypNg "<<r4M<<"->A="<<rnPDG<<n4M<<",gamma="<<h4M<<G4endl;
7788 #endif
7789  G4QHadron* theGamma = new G4QHadron(22,h4M);// Make a New Hadr for the gamma
7790  theQHadrons.push_back(theGamma); // (del.eq.- user is responsible for del)
7791  if(rnPDG==90000002) // Additional action with curHadr change
7792  {
7793  G4LorentzVector newLV=n4M/2.;
7794  curHadr->Set4Momentum(newLV);
7795  curHadr->SetQPDG(G4QPDGCode(90000001));
7796  G4QHadron* secHadr = new G4QHadron(curHadr);
7797  theQHadrons.push_back(secHadr); // (del.eq.- user is responsible for del)
7798  //theFragments->push_back(secHadr); // (del.eq.- user is responsible for del)
7799  }
7800  else if(rnPDG==90002000) // Additional action with curHadr change
7801  {
7802  G4LorentzVector newLV=n4M/2.;
7803  curHadr->Set4Momentum(newLV);
7804  curHadr->SetQPDG(G4QPDGCode(90001000));
7805  G4QHadron* secHadr = new G4QHadron(curHadr);
7806  theQHadrons.push_back(secHadr); // (del.eq.- user is responsible for del)
7807  //theFragments->push_back(secHadr); // (del.eq.- user is responsible for del)
7808  }
7809  // @@ Add multybaryon decays if necessary
7810  }
7811 #ifdef pdebug
7812  else // If this Error shows up (lowProbable appearance) => now it is left as is
7813  {
7814  G4cout<<"-Warning-G4QEnv::F:R="<<rlM<<",S+="<<nSP<<",S-="<<nSM<<",L="<<nL<<",d1="
7815  <<rlM+MLa-reM<<G4endl;
7816  G4cout<<"-Warning-G4QEnv::FSI:HyperN="<<hPDG<<", M="<<reM<<"<"<<rnM+mPi0<<", d2="
7817  <<rnM+mPi0-reM<<G4endl;
7818  //throw G4QException("G4QEnvironment::FSInteract: Hypernuclear conversion");
7819  }
7820 #endif
7821  }
7822  else if(SS==nB && !nOM) // Decay with Xi, but without residual nucleus
7823  {
7824 #ifdef pdebug
7825  G4cout<<"G4QEnvironment::FSI:OnlyHyp,B="<<nB<<",SP="<<nSP<<",SM="<<nSM<<",L="<<nL
7826  <<",XM="<<nXM<<",XZ="<<nXZ<<G4endl;
7827 #endif
7828  G4int SP=0;
7829  if(nL) ++SP;
7830  if(nSP) ++SP;
7831  if(nSM) ++SP;
7832  if(nXZ) ++SP;
7833  if(nXM) ++SP;
7834  if(SP>1 && SP<4)
7835  {
7836  G4int fPDG=3122;
7837  G4double fM=mLamb;
7838  G4int fS=nL;
7839  G4int sPDG=3222;
7840  G4double sM=mSigP;
7841  G4int sS=nSP;
7842  G4int uPDG=3322;
7843  G4double uM=mXiZ;
7844  G4int uS=nSP;
7845  if(nL)
7846  {
7847  if(nSM)
7848  {
7849  sPDG=3112;
7850  sM =mSigM;
7851  sS =nSM;
7852  if(SP==3)
7853  {
7854  if(nXM)
7855  {
7856  uPDG=3312;
7857  uM =mXiM;
7858  uS =nXM;
7859  }
7860  }
7861  }
7862  else if(nXZ)
7863  {
7864  sPDG=3322;
7865  sM =mXiZ;
7866  sS =nXZ;
7867  if(SP==3)
7868  {
7869  if(nSP)
7870  {
7871  uPDG=3222;
7872  uM =mSigP;
7873  uS =nSP;
7874  }
7875  else if(nXM)
7876  {
7877  uPDG=3312;
7878  uM =mXiM;
7879  uS =nXM;
7880  }
7881  }
7882  }
7883  else if(nXM)
7884  {
7885  sPDG=3312;
7886  sM =mXiM;
7887  sS =nXM;
7888  //if(SP==3) uXiZ is a default
7889  }
7890  else if(SP==3) // Lambda,Sigma+ (only Xi0 is possible)
7891  {
7892  if(nXZ)
7893  {
7894  uPDG=3322;
7895  uM =mXiZ;
7896  uS =nXZ;
7897  }
7898  else G4cout<<"-Warning-G4QE::FSI: *Improve* StrangeComb, PDG="<<hPDG<<G4endl;
7899  }
7900  }
7901  else if(nSM)
7902  {
7903  fPDG=3112;
7904  fM =mSigM;
7905  fS =nSM;
7906  if(nXZ)
7907  {
7908  sPDG=3322;
7909  sM =mXiZ;
7910  sS =nXZ;
7911  if(SP==3)
7912  {
7913  if(nXM)
7914  {
7915  uPDG=3312;
7916  uM =mXiM;
7917  uS =nXM;
7918  }
7919  else if(nXZ)
7920  {
7921  uPDG=3322;
7922  uM =mXiZ;
7923  uS =nXZ;
7924  }
7925  }
7926  }
7927  else if(nXM)
7928  {
7929  sPDG=3312;
7930  sM =mXiM;
7931  sS =nXM;
7932  }
7933  }
7934  else if(nSP)
7935  {
7936  fPDG=3222;
7937  fM =mSigP;
7938  fS =nSP;
7939  if(nXZ)
7940  {
7941  sPDG=3322;
7942  sM =mXiZ;
7943  sS =nXZ;
7944  if(SP==3)
7945  {
7946  if(nXZ)
7947  {
7948  uPDG=3322;
7949  uM =mXiZ;
7950  uS =nXZ;
7951  }
7952  }
7953  }
7954  else if(nXM)
7955  {
7956  sPDG=3312;
7957  sM =mXiM;
7958  sS =nXM;
7959  }
7960  }
7961  else if(nXZ)
7962  {
7963  fPDG=3322;
7964  fM =mXiZ;
7965  fS =nXZ;
7966  if(nXM)
7967  {
7968  sPDG=3312;
7969  sM =mXiM;
7970  sS =nXM;
7971  }
7972  }
7973  else G4cout<<"-Warning-G4QE::FSI: *Improve* StrangeFragment, PDG="<<hPDG<<G4endl;
7974  // Now make two or three particles decay
7975  if(SP==2) // @@ Only 2BodyDecay is implemented >Improve
7976  {
7977 #ifdef pdebug
7978  G4cout<<"G4QEnvironment::FSI:2HypD,fS="<<fS<<",fPDG="<<sPDG<<",fM="<<fM<<",sS="
7979  <<sS<<",sPDG="<<sPDG<<",sM="<<sM<<",rM="<<reM<<G4endl;
7980 #endif
7981  fM*=fS;
7982  sM*=sS;
7983  G4double mm_value=fM+sM;
7984  G4double MM=reM+eps;
7985  if(MM<=mm_value && fPDG==3122 && sPDG==3222) // Lamba,Sigma+ => Xi0,p (can be 50%)
7986  {
7987  fPDG= 2212;
7988  fM = mProt;
7989  sPDG= 3322;
7990  sM = mXiZ;
7991  mm_value = fM+sM;
7992  }
7993  if(MM>mm_value) // can be split or decayed
7994  {
7995  G4LorentzVector f4M(0.,0.,0.,fM);
7996  G4LorentzVector s4M(0.,0.,0.,sM);
7997  G4double sum=fM+sM;
7998  if(fabs(reM-sum)<=eps) // splitting
7999  {
8000  f4M=r4M*(fM/sum);
8001  s4M=r4M*(sM/sum);
8002  }
8003  else if(reM<sum || !G4QHadron(r4M).DecayIn2(f4M,s4M))
8004  {
8005  // G4cerr<<"***G4QE::FSI:Hyp2,M="<<reM<<"< sum="<<sum<<",d="<<sum-reM<<G4endl;
8006  // throw G4QException("***G4QEnvironment::FSInter: HypernucOnlyStran2 error");
8008  ed << "HypernucOnlyStran2 error: Hyp2,M=" << reM << "< sum=" << sum
8009  << ",d=" << sum-reM << G4endl;
8010  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0023",
8011  FatalException, ed);
8012  }
8013 #ifdef pdebug
8014  G4cout<<"G4QEnv::FSI:2,HN="<<r4M<<hPDG<<"->First="<<fS<<f4M<<fPDG<<",Second="
8015  <<sS<<s4M<<sPDG<<G4endl;
8016 #endif
8017  if(fS>1)
8018  {
8019  f4M/=fS; // split the Hyperons 4-mom if necessary
8020  for(G4int il=1; il<fS; il++) // loop over excessive Hyperons
8021  {
8022  G4QHadron* theHyp = new G4QHadron(fPDG,f4M);// Make NewHadr for theHyper
8023  theQHadrons.push_back(theHyp); // (del.eq.- user is respons for del)
8024  }
8025  }
8026  curHadr->Set4Momentum(f4M);
8027  curHadr->SetQPDG(G4QPDGCode(fPDG)); // converted hypernucleus
8028  if(sS>1) s4M/=sS; // split the Hyperon 4-mom if necessary
8029  for(G4int il=0; il<sS; il++) // loop over excessive
8030  {
8031  G4QHadron* theHyp = new G4QHadron(sPDG,s4M);// Make NewHadr for theHyperon
8032  theQHadrons.push_back(theHyp); // (del.eq.- user is respons for del)
8033  }
8034  }
8035  // @@ Don't close this warning as it costs days to find out this growing point!
8036  else G4cout<<"-Warning-G4QE::FSI:*Improve* S2, PDG="<<hPDG<<",M="<<reM<<",fS="
8037  <<fS<<",sS="<<sS<<",fM="<<fM<<",sM="<<sM<<G4endl;
8038  }
8039  else // --> 3Body @@ Only 3BodyDecay is implemented >Improve
8040  {
8041 #ifdef pdebug
8042  G4cout<<"G4QEnvironment::FSI:3HypD,fS="<<fS<<",fPDG="<<sPDG<<",fM="<<fM<<",sS="
8043  <<sS<<",sPDG="<<sPDG<<",fM="<<fM<<",uS="<<sS<<",uPDG="<<sPDG<<",uM="<<sM
8044  <<",rM="<<reM<<G4endl;
8045 #endif
8046  fM*=fS;
8047  sM*=sS;
8048  uM*=sS;
8049  G4double mm_value=fM+sM+uM;
8050  G4double MM=reM+eps;
8051  // @@ There is much more alternative 3B states...
8052  //if(MM<=mm_value && fPDG==3122 && sPDG==3222) // Lamba,Sigma+ => Xi0,p (can be 50%)
8053  //{
8054  // fPDG= 2212;
8055  // fM = mProt;
8056  // sPDG= 3322;
8057  // sM = mXiZ;
8058  // mm_value = fM+sM;
8059  //}
8060  if(MM>mm_value) // can be split or decayed
8061  {
8062  G4LorentzVector f4M(0.,0.,0.,fM);
8063  G4LorentzVector s4M(0.,0.,0.,sM);
8064  G4LorentzVector u4M(0.,0.,0.,uM);
8065  G4double sum=fM+sM+uM;
8066  if(fabs(reM-sum)<=eps) // splitting
8067  {
8068  f4M=r4M*(fM/sum);
8069  s4M=r4M*(sM/sum);
8070  u4M=r4M*(uM/sum);
8071  }
8072  else if(reM<sum || !G4QHadron(r4M).DecayIn2(f4M,s4M))
8073  {
8075  ed << "HypernucOnlyStran3 error: Hyp3,M=" << reM << "< sum="
8076  << sum << ",d=" << sum-reM << G4endl;
8077  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0024",
8078  FatalException, ed);
8079  }
8080 #ifdef pdebug
8081  G4cout<<"G4QEnv::FSI:3,HN="<<r4M<<hPDG<<"->First="<<fS<<f4M<<fPDG<<",Second="
8082  <<sS<<s4M<<sPDG<<",Third="<<fS<<f4M<<fPDG<<G4endl;
8083 #endif
8084  if(fS>1)
8085  {
8086  f4M/=fS; // split the Hyperons 4-mom if necessary
8087  for(G4int il=1; il<fS; ++il) // loop over excessive Hyperons
8088  {
8089  G4QHadron* theHyp = new G4QHadron(fPDG,f4M);// Make NewHadr for theHyper
8090  theQHadrons.push_back(theHyp); // (del.eq.- user is respons for del)
8091  }
8092  }
8093  curHadr->Set4Momentum(f4M); // The hypernucleus itself is modified
8094  curHadr->SetQPDG(G4QPDGCode(fPDG)); // converted hypernucleus
8095  if(sS>1) s4M/=sS; // split the Hyperon 4-mom if necessary
8096  for(G4int il=0; il<sS; ++il) // loop over excessive
8097  {
8098  G4QHadron* theHyp = new G4QHadron(sPDG,s4M);// Make NewHadr for theHyperon
8099  theQHadrons.push_back(theHyp); // (del.eq.- user is respons for del)
8100  }
8101  if(uS>1) u4M/=uS; // split the Hyperon 4-mom if necessary
8102  for(G4int il=0; il<uS; ++il) // loop over excessive
8103  {
8104  G4QHadron* theHyp = new G4QHadron(uPDG,u4M);// Make NewHadr for theHyperon
8105  theQHadrons.push_back(theHyp); // (del.eq.- user is respons for del)
8106  }
8107  }
8108  // @@ Don't close this warning as it costs days to find out this growing point!
8109  else G4cout<<"-Warn-G4QE::FSI:*Improve* S3, PDG="<<hPDG<<",M="<<reM<<",fS="<<fS
8110  <<",sS="<<sS<<",uS="<<uS<<",fM="<<fM<<",sM="<<sM<<",uM="<<uM<<G4endl;
8111  }
8112  }
8113  }
8114  else if(nOM) // Decay with Omega-, but without residual nucleus
8115  {
8116 #ifdef pdebug
8117  G4cout<<"G4QEnvir::FSI:Omega-,B="<<nB<<",SP="<<nSP<<",OM="<<nOM<<",L="<<nL<<G4endl;
8118 #endif
8119  G4int SP=0;
8120  if(nL) ++SP;
8121  if(nSP) ++SP;
8122  if(nOM) ++SP;
8123  if(!nL)
8124  {
8125  G4int fPDG= 3334;
8126  G4double fM = mOmM;
8127  G4int fS = nOM;
8128  G4int sPDG= 3222;
8129  G4double sM = mSigP;
8130  G4int sS = nSP;
8131 #ifdef pdebug
8132  G4cout<<"G4QEnvironment::FSI:2HypD,fS="<<fS<<",fPDG="<<sPDG<<",fM="<<fM<<",sS="
8133  <<sS<<",sPDG="<<sPDG<<",sM="<<sM<<",rM="<<reM<<G4endl;
8134 #endif
8135  fM*=fS;
8136  sM+=sS;
8137  if(reM>fM+sM-eps) // can be split or decayed
8138  {
8139  G4LorentzVector f4M(0.,0.,0.,fM);
8140  G4LorentzVector s4M(0.,0.,0.,sM);
8141  G4double sum=fM+sM;
8142  if(fabs(reM-sum)<eps) // splitting
8143  {
8144  f4M=r4M*(fM/sum);
8145  s4M=r4M*(sM/sum);
8146  }
8147  else if(reM<sum || !G4QHadron(r4M).DecayIn2(f4M,s4M))
8148  {
8150  ed << "HypernucOnlyStran3 error: Hyp,M=" << reM << "<OM+SP="
8151  << sum << ",d=" << sum-reM << G4endl;
8152  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0025",
8153  FatalException, ed);
8154  }
8155 #ifdef pdebug
8156  G4cout<<"G4QEnv::FSI:OHNuc="<<r4M<<hPDG<<"->First="<<fS<<f4M<<fPDG<<",Second="
8157  <<sS<<s4M<<sPDG<<G4endl;
8158 #endif
8159  if(fS>1)
8160  {
8161  f4M/=fS; // split the Hyperons 4-mom if necessary
8162  for(G4int il=1; il<fS; il++) // loop over excessive Hyperons
8163  {
8164  G4QHadron* theHyp = new G4QHadron(fPDG,f4M);// Make NewHadr for theHyper
8165  theQHadrons.push_back(theHyp); // (del.eq.- user is respons for del)
8166  }
8167  }
8168  curHadr->Set4Momentum(f4M);
8169  curHadr->SetQPDG(G4QPDGCode(fPDG)); // converted hypernucleus
8170  if(sS>1) s4M/=sS; // split the Hyperon 4-mom if necessary
8171  for(G4int il=0; il<sS; il++) // loop over excessive
8172  {
8173  G4QHadron* theHyp = new G4QHadron(sPDG,s4M);// Make NewHadr for theHyperon
8174  theQHadrons.push_back(theHyp); // (del.eq.- user is respons for del)
8175  }
8176  }
8177  // @@ Don't close this warning as it costs days to find out this growing point!
8178  else G4cout<<"-Warning-G4QE::FSI:*Improve* OMSP, PDG="<<hPDG<<",M="<<reM<<",nSP="
8179  <<nSP<<",nOM="<<nOM<<",mOM="<<fM<<",mSP="<<sM<<G4endl;
8180  }
8181  // @@ Do not close this warning as it costs days to find out this growing point !
8182  else G4cout<<"-Warning-G4QE::FSI:*Improve* nLamb="<<nL<<" # 0, PDG="<<hPDG<<G4endl;
8183  }
8184  // @@ Do not close this warning as it costs days to find out this growing point !
8185  else G4cout<<"-Warning-G4QE::FSI:*Improve*,S="<<SS<<">B="<<nB<<",PDG="<<hPDG<<G4endl;
8186  }
8187  if(!fOK) hd--;
8188  } //
8189 #ifdef pdebug
8190  G4cout<<"G4QE::FSI:==>OUT,nH="<<theQHadrons.size()<<",nF="<<theFragments->size()<<G4endl;
8191 #endif
8192  // *** (Final) Charge Control Sum Calculation for the Charge Conservation Check ***
8193  //nHadr=theFragments->size();
8194  nHadr=theQHadrons.size();
8195  G4int cfContSum=0; // Final ChargeControlSum
8196  G4int bfContSum=0; // Final BaryonNumberControlSum
8197  if(nHadr)for(unsigned f=0; f<nHadr; f++)
8198  {
8199  G4QHadron* curHadr = new G4QHadron(theQHadrons[f]);
8200 #ifdef debug
8201  G4cout<<"G4QE::FSI:#"<<f<<curHadr->Get4Momentum()<<curHadr->GetPDGCode()<<G4endl;
8202 #endif
8203  if(!(curHadr->GetNFragments()))
8204  {
8205  G4int chg=curHadr->GetCharge();
8206  cfContSum+=chg;
8207  G4int brn=curHadr->GetBaryonNumber();
8208  bfContSum+=brn;
8209  G4int str=curHadr->GetStrangeness();
8210  if ( brn > 1 &&
8211  ( (!str && (chg == brn || !chg)) ||
8212  (!chg && str == brn) ) ) // Check for multibaryon(split)
8213  {
8214  G4int bPDG=90000001; // Prototype: multineutron
8215  if (chg==brn) bPDG=90001000; // Multyproton
8216  else if(str==brn) bPDG=91000000; // Multilambda
8217  G4LorentzVector sp4m=curHadr->Get4Momentum()/brn; // Split 4-mom of the Multibaryon
8218  curHadr->Set4Momentum(sp4m);
8219  curHadr->SetQPDG(G4QPDGCode(bPDG)); // Substitute Multibaryon by a baryon
8220  for (G4int ib=1; ib<brn; ib++)
8221  {
8222  G4QHadron* bH = new G4QHadron(bPDG, sp4m);
8223  theFragments->push_back(bH); //(del eq. - user is responsible for deleting)
8224  }
8225  }
8226  theFragments->push_back(curHadr); //(del eq. - user is responsible for deleting)
8227  }
8228  }
8229 #ifdef chdebug
8230  if(cfContSum-chContSum || bfContSum-bnContSum)
8231  {
8233  ed << "::(F) Charge is not conserved: Ch=" << cfContSum-chContSum << ",Bn="
8234  << bfContSum-bnContSum << G4endl;
8235  G4Exception("G4QEnvironment::FSInteraction()", "HAD_CHPS_0026",
8236  FatalException, ed);
8237  }
8238 #endif
8239  // ***
8240  return theFragments;
8241 } // End of "FSInteraction"
8242 
8243 //The public Quasmons duplication with delete responsibility of User (!)
8245 {
8246  G4int nQ=theQuasmons.size();
8247 #ifdef debug
8248  G4cout<<"G4QEnvironment::GetQuasmons is called nQ="<<nQ<<G4endl;
8249 #endif
8250  G4QuasmonVector* quasmons = new G4QuasmonVector; // !! User is responsible to delet it
8251  if(nQ) for(G4int iq=0; iq<nQ; iq++)
8252  {
8253 #ifdef debug
8254  G4cout<<"G4QEnv::GetQuasm:Q#"<<iq<<",QQPDG="<<theQuasmons[iq]->GetQPDG()<<",QQC="
8255  <<theQuasmons[iq]->GetQC()<<",M="<<theQuasmons[iq]->Get4Momentum().m()<<G4endl;
8256 #endif
8257  G4Quasmon* curQ = new G4Quasmon(theQuasmons[iq]);
8258  quasmons->push_back(curQ); // (delete equivalent - user is responsible)
8259  }
8260 #ifdef debug
8261  G4cout<<"G4QEnvironment::GetQuasmons ===OUT==="<<G4endl;
8262 #endif
8263  return quasmons;
8264 } // End of GetQuasmons
8265 
8266 //The public QHadrons duplication with delete responsibility of User (!)
8268 {
8269  G4int nH=theQHadrons.size();
8270 #ifdef debug
8271  G4cout<<"G4QEnvironment::GetQHadrons is called nH="<<nH<<G4endl;
8272 #endif
8273  G4QHadronVector* hadrons = new G4QHadronVector; // !! User is responsible to delet it
8274  if(nH) for(G4int ih=0; ih<nH; ih++)
8275  {
8276 #ifdef debug
8277  G4cout<<"G4QEnv::GetQHadrons:H#"<<ih<<",HQPDG="<<theQHadrons[ih]->GetQPDG()<<",HQC="
8278  <<theQHadrons[ih]->GetQC()<<",HM="<<theQHadrons[ih]->GetMass()<<G4endl;
8279 #endif
8280  G4QHadron* curH = new G4QHadron(theQHadrons[ih]);
8281  hadrons->push_back(curH); // (del. equiv. - user is responsibile)
8282  }
8283 #ifdef debug
8284  G4cout<<"G4QEnvironment::GetQHadrons ===OUT=== Copied nQH="<<hadrons->size()<<G4endl;
8285 #endif
8286  return hadrons;
8287 } // End of GetQHadrons
8288 
8289 //Public QHadrons cleaning up after extraction (GetQHadrons) between Construct and Fragment
8291 {
8292  for_each(theQHadrons.begin(), theQHadrons.end(), DeleteQHadron());
8293  theQHadrons.clear();
8294 } // End of CleanUpQHadrons
8295 
8296 //The public FillQHadrons filling. It must be used only internally in CHIPS
8298 {
8299  G4int nH=input->size();
8300 #ifdef debug
8301  G4cout<<"G4QEnvironment::FillQHadrons is called nH="<<nH<<G4endl;
8302 #endif
8303  if(nH) for(G4int ih=0; ih<nH; ih++)
8304  {
8305 #ifdef debug
8306  G4cout<<"G4QEnv::FillQHadrons:H#"<<ih<<",HQPDG="<<(*input)[ih]->GetQPDG()<<",HQC="
8307  <<(*input)[ih]->GetQC()<<",HM="<<(*input)[ih]->GetMass()<<G4endl;
8308 #endif
8309  G4QHadron* curH = new G4QHadron((*input)[ih]);
8310  theQHadrons.push_back(curH); // (del. equiv.
8311  }
8312 #ifdef debug
8313  G4cout<<"G4QEnvironment::FillQHadrons ===OUT=== Filled nQH="<<theQHadrons.size()<<G4endl;
8314 #endif
8315 } // End of FillQHadrons
8316 
8317 //Decay of the excited Baryon in baryon & meson (gamma)
8319 {
8320  static const G4QPDGCode gQPDG(22);
8321  static const G4QPDGCode pizQPDG(111);
8322  static const G4QPDGCode pipQPDG(211);
8323  static const G4QPDGCode pimQPDG(-211);
8324  static const G4QPDGCode kmQPDG(-321);
8325  static const G4QPDGCode kzQPDG(-311);
8326  static const G4QPDGCode nQPDG(2112);
8327  static const G4QPDGCode pQPDG(2212);
8328  static const G4QPDGCode lQPDG(3122);
8329  static const G4QPDGCode laQPDG(3122);
8330  static const G4QPDGCode smQPDG(3112);
8331  static const G4QPDGCode szQPDG(3212);
8332  static const G4QPDGCode spQPDG(3222);
8333  static const G4QPDGCode kszQPDG(3322);
8334  static const G4QPDGCode ksmQPDG(3312);
8335  static const G4double mPi = G4QPDGCode(211).GetMass();
8336  static const G4double mPi0 = G4QPDGCode(111).GetMass();
8337  static const G4double mK = G4QPDGCode(321).GetMass();
8338  static const G4double mK0 = G4QPDGCode(311).GetMass();
8339  static const G4double mNeut= G4QPDGCode(2112).GetMass();
8340  static const G4double mProt= G4QPDGCode(2212).GetMass();
8341  static const G4double mSigM= G4QPDGCode(3112).GetMass();
8342  static const G4double mLamb= G4QPDGCode(3122).GetMass();
8343  static const G4double mSigZ= G4QPDGCode(3212).GetMass();
8344  static const G4double mSigP= G4QPDGCode(3222).GetMass();
8345  //static const G4double mKsiM= G4QPDGCode(3312).GetMass();
8346  //static const G4double mKsi0= G4QPDGCode(3322).GetMass();
8347  //static const G4double mOmeg= G4QPDGCode(3334).GetMass();
8348  static const G4double mNPi0 = mPi0+ mNeut;
8349  static const G4double mNPi = mPi + mNeut;
8350  static const G4double mPPi0 = mPi0+ mProt;
8351  static const G4double mPPi = mPi + mProt;
8352  static const G4double mLPi0 = mPi0+ mLamb;
8353  static const G4double mLPi = mPi + mLamb;
8354  static const G4double mSpPi = mPi + mSigP;
8355  static const G4double mSmPi = mPi + mSigM;
8356  static const G4double mPK = mK + mProt;
8357  static const G4double mPKZ = mK0 + mProt;
8358  static const G4double mNKZ = mK0 + mNeut;
8359  static const G4double mSpPi0= mPi0+ mSigP;
8360  static const G4double mSzPi0= mPi0+ mSigZ;
8361  static const G4double mSzPi = mPi + mSigZ;
8362  static const G4double eps = 0.003;
8363  //static const G4QNucleus vacuum(90000000);
8364  G4int theLB= qH->GetBaryonNumber(); // Baryon number of the Baryon
8365  if(theLB!=1)
8366  {
8367  G4cerr<<"***G4QEnvironment::DecayBaryon: A!=1 -> fill as it is"<<G4endl;
8368 #ifdef ppdebug
8369  // throw G4QException("G4QEnv::DecayBaryon: Unknown Baryon with A!=1");
8370  G4Exception("G4QEnvironment::DecayBaryon()", "HAD_CHPS_0000",
8371  FatalException, "Unknown Baryon with A!=1");
8372 #endif
8373  HV->push_back(qH); // Fill AsIs (delete equivalent)
8374  return;
8375  }
8376  G4int theLC= qH->GetCharge(); // Chsrge of the Baryon
8377  G4int theLS= qH->GetStrangeness(); // Strangness of the Baryon
8378  //G4int qPDG = qH->GetPDGCode(); // PDG Code of the decaying baryon
8379  G4LorentzVector q4M = qH->Get4Momentum(); // Get 4-momentum of the Baryon
8380  G4double qM = q4M.m(); // Mass of the Baryon
8381 #ifdef debug
8382  G4cout<<"G4QEnv::DecayBaryon: *Called* S="<<theLS<<",C="<<theLC<<",4M="<<q4M<<qM<<G4endl;
8383 #endif
8384  // Select a chanel of the baryon decay
8385  G4QPDGCode fQPDG = pQPDG; // Prototype for Proton
8386  G4double fMass= mProt;
8387  G4QPDGCode sQPDG = pizQPDG; // Prototype for Pi0
8388  G4double sMass= mPi0;
8389  if(!theLS) // This is only for not strange baryons
8390  {
8391  if(!theLC) // Neutron like: n+gam, n+Pi0, p+Pi- are possible
8392  {
8393  if(qM<mNPi0) // Only n+gamma decay is possible
8394  {
8395  if(qM < mNeut+eps)
8396  {
8397 #ifdef debug
8398  G4cout<<"G4QEnv::DecayBaryon: Fill Neutron AsIs"<<G4endl;
8399 #endif
8400  qH->SetQPDG(nQPDG);
8401  HV->push_back(qH); // Fill AsIs (delete equivalent)
8402  if(qM+eps<mNeut) G4cout<<"-Warning-G4QEnv::DecayBaryon: N0 AsIs, M="<<qM<<G4endl;
8403  return;
8404  }
8405  fQPDG=nQPDG; // Baryon is neutron
8406  fMass=mNeut;
8407  sQPDG=gQPDG; // Meson is gamma
8408  sMass=0.;
8409 #ifdef debug
8410  G4cout<<"-Warning-G4QEnv::DecayBaryon: Gamma+n, M="<<qM<<",d="<<qM-mNeut<<G4endl;
8411 #endif
8412  }
8413  else if(qM>mPPi) // Both n+pi0 (p=2/3) & p+Pi- (p=1/3) are possible
8414  {
8415  if(G4UniformRand()>.333333333) // Clebsh value for the Isobar decay
8416  {
8417  fQPDG=nQPDG; // Baryon is neutron (meson is Pi0)
8418  fMass=mNeut;
8419  }
8420  else
8421  {
8422  sQPDG=pimQPDG; // Meson is Pi- (baryon is proton)
8423  sMass=mPi;
8424  }
8425  }
8426  else // Only n+Pi0 decay is possible
8427  {
8428  fQPDG=nQPDG; // Baryon is neutron
8429  fMass=mNeut;
8430  }
8431  }
8432  else if(theLC==1) // Proton like: p+gam, p+Pi0, n+Pi+ are possible
8433  {
8434  if(qM<mPPi0) // Only p+gamma decay is possible
8435  {
8436  if(qM < mProt+eps)
8437  {
8438 #ifdef debug
8439  G4cout<<"G4QEnv::DecayBaryon: Fill Proton AsIs"<<G4endl;
8440 #endif
8441  qH->SetQPDG(pQPDG);
8442  HV->push_back(qH); // Fill AsIs (delete equivalent)
8443 #ifdef debug
8444  if(qM+eps<mProt)G4cout<<"-Warning-G4QEnv::DecayBaryon: Pr+ AsIs, M="<<qM<<G4endl;
8445 #endif
8446  return;
8447  }
8448  sQPDG=gQPDG; // Meson is gamma (baryon is proton)
8449  sMass=0.;
8450  }
8451  else if(qM>mNPi) // Both p+pi0 (p=2/3) & n+Pi+ (p=1/3) are possible
8452  {
8453  if(G4UniformRand()<.333333333) // Clebsh value for the Isobar decay
8454  {
8455  fQPDG=nQPDG; // Baryon is neutron
8456  fMass=mNeut;
8457  sQPDG=pipQPDG; // Meson is Pi+
8458  sMass=mPi;
8459  }
8460  // p+Pi0 is a default case
8461  }
8462  // p+Pi0 is a default case
8463  }
8464  else if(theLC==2) // Delta++ like: only p+PiP is possible
8465  {
8466  if(qM>mPPi) // Only p+gamma decay is possible
8467  {
8468  sQPDG=pipQPDG; // Meson is Pi+ (baryon is proton)
8469  sMass=mPi;
8470  }
8471  else // @@ Can be aReason to search for anError in Fragmentation
8472  {
8473 #ifdef debug
8474  G4cout<<"-Warning-G4QE::DecBary:*AsIs* DEL++ M="<<qM<<"<"<<mPPi<<G4endl;
8475 #endif
8476  HV->push_back(qH); // Fill AsIs (delete equivalent)
8477  return;
8478  }
8479  }
8480  else if(theLC==-1) // Delta- like: only n+PiM is possible
8481  {
8482  if(qM+eps>mNPi) // Only p+gamma decay is possible
8483  {
8484  fQPDG=nQPDG; // Baryon is neutron
8485  fMass=mNeut;
8486  sQPDG=pimQPDG; // Meson is Pi-
8487  sMass=mPi;
8488  }
8489  else // @@ Can be aReason to search for anError in Fragmentation
8490  {
8491 #ifdef debug
8492  G4cout<<"-Warning-G4QE::DecBary:*AsIs* DEL++ M="<<qM<<"<"<<mNPi<<G4endl;
8493 #endif
8494  HV->push_back(qH); // Fill AsIs (delete equivalent)
8495  return;
8496  }
8497  }
8498  else
8499  {
8500 #ifdef debug
8501  G4cout<<"-Warning-G4QE::DecBary:*AsIs* UnknBaryon (S=0) QC="<<qH->GetQC()<<G4endl;
8502 #endif
8503  HV->push_back(qH); // Fill AsIs (delete equivalent)
8504  return;
8505  }
8506  }
8507  else if(theLS==1) // ==>->->-> S=1 <-<-<-<==
8508  {
8509  if(!theLC) // -->> Lambda/Sz: L+g,L+Pi0,Sz+Pi0,Sm+Pip,Sp+Pim,p+Km,n+Kz
8510  {
8511  if(qM<mLPi0) // Only Lambda+gamma decay is possible
8512  {
8513  if(qM < mLamb+eps)
8514  {
8515 #ifdef debug
8516  G4cout<<"G4QEnv::DecayBaryon: Fill Lambda AsIs"<<G4endl;
8517 #endif
8518  qH->SetQPDG(lQPDG);
8519  HV->push_back(qH); // Fill AsIs (delete equivalent)
8520  if(qM+eps<mLamb)G4cout<<"-Warning-G4QEnv::DecayBaryon: La0 AsIs, M="<<qM<<G4endl;
8521  return;
8522  }
8523  fQPDG=lQPDG; // Baryon is Lambda
8524  fMass=mLamb;
8525  sQPDG=gQPDG; // Meson is gamma
8526  sMass=0.;
8527  }
8528  else if(qM<mSzPi0) // Only Lambda+Pi0 is possible
8529  {
8530  fQPDG=lQPDG; // Baryon is Lambda
8531  fMass=mLamb;
8532  }
8533  else if(qM<mSpPi) // Both Lambda+Pi0 & Sigma0+Pi0 are possible
8534  {
8535  if(G4UniformRand()>.6) // @@ Relative probability (take into account Phase Space)
8536  {
8537  fQPDG=szQPDG; // Baryon is Sigma0
8538  fMass=mSigZ;
8539  }
8540  else
8541  {
8542  fQPDG=lQPDG; // Baryon is Lambda
8543  fMass=mLamb;
8544  }
8545  }
8546  else if(qM<mSmPi) // Lambda+Pi0, Sigma0+Pi0, & SigmaP+PiM are possible
8547  {
8548  G4double ra=G4UniformRand();
8549  if(ra<.4) // @@ Rel. probab. (take into account Phase Space)
8550  {
8551  fQPDG=lQPDG; // Baryon is Lambda
8552  fMass=mLamb;
8553  }
8554  else if(ra<.7) // @@ Rel. probab. (take into account Phase Space)
8555  {
8556  fQPDG=szQPDG; // Baryon is Sigma0
8557  fMass=mSigZ;
8558  }
8559  else
8560  {
8561  fQPDG=spQPDG; // Baryon is SigmaP
8562  fMass=mSigP;
8563  sQPDG=pimQPDG; // Meson is Pi-
8564  sMass=mPi;
8565  }
8566  }
8567  else if(qM<mPK) // Lambda+Pi0, Sig0+Pi0, SigP+PiM, SigM+PiP are possible
8568  {
8569  G4double ra=G4UniformRand();
8570  if(ra<.35) // @@ Rel. probab. (take into account Phase Space)
8571  {
8572  fQPDG=lQPDG; // Baryon is Lambda
8573  fMass=mLamb;
8574  }
8575  else if(ra<.6) // @@ Rel. probab. (take into account Phase Space)
8576  {
8577  fQPDG=szQPDG; // Baryon is Sigma0
8578  fMass=mSigZ;
8579  }
8580  else if(ra<.8) // @@ Rel. probab. (take into account Phase Space)
8581  {
8582  fQPDG=smQPDG; // Baryon is SigmaM
8583  fMass=mSigM;
8584  sQPDG=pipQPDG; // Meson is Pi+
8585  sMass=mPi;
8586  }
8587  else
8588  {
8589  fQPDG=spQPDG; // Baryon is SigmaP
8590  fMass=mSigP;
8591  sQPDG=pimQPDG; // Meson is Pi-
8592  sMass=mPi;
8593  }
8594  }
8595  else if(qM<mNKZ) // Lambda+Pi0, Sig0+Pi0, SigP+PiM, SigM+PiP are possible
8596  {
8597  G4double ra=G4UniformRand();
8598  if(ra<.3) // @@ Rel. probab. (take into account Phase Space)
8599  {
8600  fQPDG=lQPDG; // Baryon is Lambda
8601  fMass=mLamb;
8602  }
8603  else if(ra<.5) // @@ Rel. probab. (take into account Phase Space)
8604  {
8605  fQPDG=szQPDG; // Baryon is Sigma0
8606  fMass=mSigZ;
8607  }
8608  else if(ra<.7) // @@ Rel. probab. (take into account Phase Space)
8609  {
8610  fQPDG=smQPDG; // Baryon is SigmaM
8611  fMass=mSigM;
8612  sQPDG=pipQPDG; // Meson is Pi+
8613  sMass=mPi;
8614  }
8615  else if(ra<.9) // @@ Rel. probab. (take into account Phase Space)
8616  {
8617  fQPDG=spQPDG; // Baryon is SigmaP
8618  fMass=mSigP;
8619  sQPDG=pimQPDG; // Meson is Pi-
8620  sMass=mPi;
8621  }
8622  else
8623  {
8624  fQPDG=pQPDG; // Baryon is Proton
8625  fMass=mProt;
8626  sQPDG=kmQPDG; // Meson is K-
8627  sMass=mK;
8628  }
8629  }
8630  else // Only n+Pi0 decay is possible
8631  {
8632  G4double ra=G4UniformRand();
8633  if(ra<.3) // @@ Rel. probab. (take into account Phase Space)
8634  {
8635  fQPDG=lQPDG; // Baryon is Lambda
8636  fMass=mLamb;
8637  }
8638  else if(ra<.5) // @@ Rel. probab. (take into account Phase Space)
8639  {
8640  fQPDG=szQPDG; // Baryon is Sigma0
8641  fMass=mSigZ;
8642  }
8643  else if(ra<.65) // @@ Rel. probab. (take into account Phase Space)
8644  {
8645  fQPDG=smQPDG; // Baryon is SigmaM
8646  fMass=mSigM;
8647  sQPDG=pipQPDG; // Meson is Pi+
8648  sMass=mPi;
8649  }
8650  else if(ra<.8) // @@ Rel. probab. (take into account Phase Space)
8651  {
8652  fQPDG=spQPDG; // Baryon is SigmaP
8653  fMass=mSigP;
8654  sQPDG=pimQPDG; // Meson is Pi-
8655  sMass=mPi;
8656  }
8657  else if(ra<.9) // @@ Rel. probab. (take into account Phase Space)
8658  {
8659  fQPDG=pQPDG; // Baryon is Proton
8660  fMass=mProt;
8661  sQPDG=kmQPDG; // Meson is K-
8662  sMass=mK;
8663  }
8664  else
8665  {
8666  fQPDG=nQPDG; // Baryon is Neutron
8667  fMass=mNeut;
8668  sQPDG=kzQPDG; // Meson is K0
8669  sMass=mK0;
8670  }
8671  }
8672  }
8673  else if(theLC==1) // SigmaP: SigP+gam,SigP+Pi0,Sp+PiP,L+Pi0,p+K0 are possible
8674  {
8675  if(qM<mLPi) // Only SigmaPlus+gamma decay is possible
8676  {
8677  if(qM < mSigP+eps)
8678  {
8679 #ifdef debug
8680  G4cout<<"G4QEnv::DecayBaryon: Fill SigmaPlus AsIs"<<G4endl;
8681 #endif
8682  qH->SetQPDG(spQPDG);
8683  HV->push_back(qH); // Fill AsIs (delete equivalent)
8684  if(qM+eps<mSigP)G4cout<<"-Warning-G4QEnv::DecayBaryon: Si+ AsIs, M="<<qM<<G4endl;
8685  return;
8686  }
8687  fQPDG=spQPDG; // Baryon is SigmaP
8688  fMass=mSigP;
8689  sQPDG=gQPDG; // Meson is gamma
8690  sMass=0.;
8691  }
8692  else if(qM<mSpPi0) // Only Lambda+PiP is possible
8693  {
8694  fQPDG=lQPDG; // Baryon is Lambda
8695  fMass=mLamb;
8696  sQPDG=pipQPDG; // Meson is Pi+
8697  sMass=mPi;
8698  }
8699  else if(qM<mSzPi) // Both Lambda+PiP & Sigma0+Pi0 are possible
8700  {
8701  if(G4UniformRand()<.6) // @@ Relative probability (take into account Phase Space)
8702  {
8703  fQPDG=lQPDG; // Baryon is Lambda
8704  fMass=mLamb;
8705  sQPDG=pipQPDG; // Meson is Pi+
8706  sMass=mPi;
8707  }
8708  else
8709  {
8710  fQPDG=spQPDG; // Baryon is SigmaP
8711  fMass=mSigP;
8712  }
8713  }
8714  else if(qM<mPKZ) // Lambda+PiP, SigmaP+Pi0, & Sigma0+PiP are possible
8715  {
8716  G4double ra=G4UniformRand();
8717  if(ra<.4) // @@ Rel. probab. (take into account Phase Space)
8718  {
8719  fQPDG=lQPDG; // Baryon is Lambda
8720  fMass=mLamb;
8721  sQPDG=pipQPDG; // Meson is Pi+
8722  sMass=mPi;
8723  }
8724  else if(ra<.7) // @@ Rel. probab. (take into account Phase Space)
8725  {
8726  fQPDG=spQPDG; // Baryon is SigmaP
8727  fMass=mSigP;
8728  }
8729  else
8730  {
8731  fQPDG=szQPDG; // Baryon is SigmaZ
8732  fMass=mSigZ;
8733  sQPDG=pipQPDG; // Meson is Pi+
8734  sMass=mPi;
8735  }
8736  }
8737  else // Lambda+PiP, SigmaP+Pi0, Sigma0+PiP, p+K0 are possible
8738  {
8739  G4double ra=G4UniformRand();
8740  if(ra<.35) // @@ Rel. probab. (take into account Phase Space)
8741  {
8742  fQPDG=lQPDG; // Baryon is Lambda
8743  fMass=mLamb;
8744  sQPDG=pipQPDG; // Meson is Pi+
8745  sMass=mPi;
8746  }
8747  else if(ra<.6) // @@ Rel. probab. (take into account Phase Space)
8748  {
8749  fQPDG=spQPDG; // Baryon is SigmaP
8750  fMass=mSigP;
8751  }
8752  else if(ra<.8) // @@ Rel. probab. (take into account Phase Space)
8753  {
8754  fQPDG=szQPDG; // Baryon is SigmaZ
8755  fMass=mSigZ;
8756  sQPDG=pipQPDG; // Meson is Pi+
8757  sMass=mPi;
8758  }
8759  else
8760  {
8761  fQPDG=pQPDG; // Baryon is Proton
8762  fMass=mProt;
8763  sQPDG=kzQPDG; // Meson is K0
8764  sMass=mK0;
8765  }
8766  }
8767  }
8768  else if(theLC==-1) // SigmaM: SigM+gam,SigM+Pi0,S0+PiM,L+Pi-,n+KM are possible
8769  {
8770  if(qM<mLPi) // Only SigmaMinus + gamma decay is possible
8771  {
8772  if(qM < mSigM+eps)
8773  {
8774 #ifdef debug
8775  G4cout<<"G4QEnv::DecayBaryon: Fill SigmaMinus AsIs"<<G4endl;
8776 #endif
8777  qH->SetQPDG(smQPDG);
8778  HV->push_back(qH); // Fill AsIs (delete equivalent)
8779  if(qM+eps<mSigM)G4cout<<"-Warning-G4QEnv::DecayBaryon: Si- AsIs, M="<<qM<<G4endl;
8780  return;
8781  }
8782  fQPDG=smQPDG; // Baryon is SigmaP
8783  fMass=mSigM;
8784  sQPDG=gQPDG; // Meson is gamma
8785  sMass=0.;
8786  }
8787  else if(qM<mSzPi) // Only Lambda+PiM is possible
8788  {
8789  fQPDG=lQPDG; // Baryon is Lambda
8790  fMass=mLamb;
8791  sQPDG=pimQPDG; // Meson is Pi-
8792  sMass=mPi;
8793  }
8794  else if(qM<mSzPi) // Both Lambda+PiM & Sigma0+PiM are possible
8795  {
8796  if(G4UniformRand()<.6) // @@ Relative probability (take into account Phase Space)
8797  {
8798  fQPDG=lQPDG; // Baryon is Lambda
8799  fMass=mLamb;
8800  sQPDG=pimQPDG; // Meson is Pi-
8801  sMass=mPi;
8802  }
8803  else
8804  {
8805  fQPDG=szQPDG; // Baryon is Sigma0
8806  fMass=mSigZ;
8807  sQPDG=pimQPDG; // Meson is Pi-
8808  sMass=mPi;
8809  }
8810  }
8811  else if(qM<mPKZ) // Lambda+PiM, Sigma0+PiM, & SigmaM+Pi0 are possible
8812  {
8813  G4double ra=G4UniformRand();
8814  if(ra<.4) // @@ Rel. probab. (take into account Phase Space)
8815  {
8816  fQPDG=lQPDG; // Baryon is Lambda
8817  fMass=mLamb;
8818  sQPDG=pimQPDG; // Meson is Pi-
8819  sMass=mPi;
8820  }
8821  else if(ra<.7) // @@ Rel. probab. (take into account Phase Space)
8822  {
8823  fQPDG=szQPDG; // Baryon is Sigma0
8824  fMass=mSigZ;
8825  sQPDG=pimQPDG; // Meson is Pi-
8826  sMass=mPi;
8827  }
8828  else
8829  {
8830  fQPDG=smQPDG; // Baryon is SigmaM
8831  fMass=mSigM;
8832  }
8833  }
8834  else // Lambda+PiM, Sig0+PiM, SigM+Pi0, n+KM are possible
8835  {
8836  G4double ra=G4UniformRand();
8837  if(ra<.35) // @@ Rel. probab. (take into account Phase Space)
8838  {
8839  fQPDG=lQPDG; // Baryon is Lambda
8840  fMass=mLamb;
8841  sQPDG=pimQPDG; // Meson is Pi-
8842  sMass=mPi;
8843  }
8844  else if(ra<.6) // @@ Rel. probab. (take into account Phase Space)
8845  {
8846  fQPDG=szQPDG; // Baryon is Sigma0
8847  fMass=mSigZ;
8848  sQPDG=pimQPDG; // Meson is Pi-
8849  sMass=mPi;
8850  }
8851  else if(ra<.8) // @@ Rel. probab. (take into account Phase Space)
8852  {
8853  fQPDG=smQPDG; // Baryon is SigmaM
8854  fMass=mSigM;
8855  }
8856  else
8857  {
8858  fQPDG=nQPDG; // Baryon is Proton
8859  fMass=mNeut;
8860  sQPDG=kmQPDG; // Meson is K-
8861  sMass=mK;
8862  }
8863  }
8864  }
8865  else if(theLC==2 || theLC==-2) // SigmaPlus+PiPlus or SigmaMinus+PiMinus
8866  {
8867  if(theLC==2 && qM>=mSpPi) // SigmaPlus+PiPlus decay is possible
8868  {
8869  fQPDG=spQPDG; // Baryon is SigmaP
8870  fMass=mSigP;
8871  sQPDG=pipQPDG; // Pi+ Meson
8872  sMass=mPi;
8873  }
8874  if(theLC==-2 && qM>=mSmPi)// SigmaPlus+PiPlus decay is possible
8875  {
8876  fQPDG=smQPDG; // Baryon is SigmaP
8877  fMass=mSigM;
8878  sQPDG=pimQPDG; // Pi- Meson
8879  sMass=mPi;
8880  }
8881  else
8882  {
8883 #ifdef debug
8884  G4cout<<"-Warning-G4QE::DecBary:*AsIs* Baryon(S=1,|C|=2),QC="<<qH->GetQC()<<G4endl;
8885 #endif
8886  HV->push_back(qH); // Fill AsIs (delete equivalent)
8887  return;
8888  }
8889  }
8890  else
8891  {
8892  //KsiM: KsiM+Pi0=1456.29, Ksi0+Pi=1454.4, L+K=1609.36, Sig0+K=1686.32, SigM+K0=1695.1
8893  //KsiZ: Ksi0+Pi0=1449.81, KsiM+Pi=1460.9, L+K0=1613.3, Sig0+K0=1690.3, SigP+K=1683.05
8894  //Omeg: Omeg+Pi0=1807.43, Ksi0+K=1808.5, KsiM+K0=1818.96
8895  G4cout<<"-Warning-G4QE::DecBary:*AsIs* UnknownBaryon(S=1)QC="<<qH->GetQC()<<G4endl;
8896  HV->push_back(qH); // Fill AsIs (delete equivalent)
8897  return;
8898  }
8899  }
8900  else
8901  {
8902 #ifdef debug
8903  G4cout<<"---Warning---G4QE::DecBary:*AsIso*UnknBaryon(AntiS),QC="<<qH->GetQC()<<G4endl;
8904 #endif
8905  HV->push_back(qH); // Fill AsIs (delete equivalent)
8906  return;
8907  }
8908  G4LorentzVector f4Mom(0.,0.,0.,fMass);
8909  G4LorentzVector s4Mom(0.,0.,0.,sMass);
8910  G4double sum=fMass+sMass;
8911  if(fabs(qM-sum)<eps)
8912  {
8913  f4Mom=q4M*(fMass/sum);
8914  s4Mom=q4M*(sMass/sum);
8915  }
8916  else if(qM<sum || !G4QHadron(q4M).DecayIn2(f4Mom, s4Mom))
8917  {
8918 #ifdef debug
8919  G4cout<<"---Warning---G4QE::DecBar:fPDG="<<fQPDG<<"(M="<<fMass<<")+sPDG="<<sQPDG<<"(M="
8920  <<sMass<<") > TotM="<<q4M.m()<<G4endl;
8921 #endif
8922  if(!theEnvironment.GetA())
8923  {
8924  G4Quasmon* quasH = new G4Quasmon(qH->GetQC(),qH->Get4Momentum());
8925  if(!CheckGroundState(quasH,true)) HV->push_back(qH); // Cor or fill asItIs
8926  else delete qH;
8927  delete quasH;
8928  return;
8929  }
8930  else
8931  {
8932  delete qH;
8934  ed << "Baryon DecayIn2 error: Can't Correct, *EmptyEnv*="
8935  << theEnvironment << G4endl;
8936  G4Exception("G4QEnvironment::DecayBaryon()", "HAD_CHPS_0001",
8937  FatalException, ed);
8938  }
8939  }
8940 #ifdef debug
8941  G4cout<<"G4QEnv::DecayBaryon: *DONE* f4M="<<f4Mom<<",fPDG="<<fQPDG<<", s4M="<<s4Mom
8942  <<",sPDG="<<sQPDG<<G4endl;
8943 #endif
8944  delete qH;
8945  //
8946  G4QHadron* H1 = new G4QHadron(fQPDG,f4Mom); // Create a Hadron for the 1-st baryon
8947  HV->push_back(H1); // Fill "H1" (delete equivalent)
8948  G4QHadron* H2 = new G4QHadron(sQPDG,s4Mom); // Create a Hadron for the 2-nd baryon
8949  HV->push_back(H2); // Fill "H2" (delete equivalent)
8950 } // End of DecayBaryon
8951 
8952 //Decay of the excited Meson in meson & meson (gamma)
8954 {
8955  static const G4QPDGCode gQPDG(22);
8956  static const G4QPDGCode pizQPDG(111);
8957  static const G4QPDGCode pipQPDG(211);
8958  static const G4QPDGCode pimQPDG(-211);
8959  static const G4QPDGCode kmQPDG(-321);
8960  static const G4QPDGCode kzQPDG(-311);
8961  static const G4QPDGCode kpQPDG(321);
8962  static const G4QPDGCode akzQPDG(311);
8963  static const G4double mPi = G4QPDGCode(211).GetMass();
8964  static const G4double mPi0 = G4QPDGCode(111).GetMass();
8965  static const G4double mK = G4QPDGCode(321).GetMass();
8966  static const G4double mK0 = G4QPDGCode(311).GetMass();
8967  static const G4double m2Pi0 = mPi0+ mPi0;
8968  static const G4double mPiPi0= mPi + mPi0;
8969  static const G4double mPiPi = mPi + mPi;
8970  static const G4double mKPi0 = mPi0+ mK;
8971  static const G4double mK0Pi0= mPi0+ mK0;
8972  static const G4double mKPi = mPi + mK;
8973  static const G4double mK0Pi = mPi + mK0;
8974  static const G4double mK0K = mK0 + mK;
8975  static const G4double mK0K0 = mK0 + mK0;
8976  static const G4double mKK = mK + mK;
8977  static const G4double eps = 0.003;
8978  //static const G4QNucleus vacuum(90000000);
8979  G4int theLB= qH->GetBaryonNumber(); // Baryon number of the Meson
8980  if(theLB)
8981  {
8982  G4cerr<<"*Warning*G4QEnvironment::DecayMeson:A="<<theLB<<" != 0 -> Fill asIs"<<G4endl;
8983 #ifdef ppdebug
8984  // throw G4QException("G4QEnv::DecayMeson: Unknown Meson with A!=0");
8985  G4Exception("G4QEnvironment::DecayMeson()", "HAD_CHPS_0000",
8986  FatalException, "Unknown Meson with A!=0");
8987 #endif
8988  HV->push_back(qH); // Fill AsIs (delete equivalent)
8989  return;
8990  }
8991  G4LorentzVector q4M = qH->Get4Momentum(); // Get 4-momentum of the Meson
8992  G4double qM = q4M.m(); // Excited Mass of the Meson
8993  G4int theLC= qH->GetCharge(); // Chsrge of the Meson
8994  G4int theLS= qH->GetStrangeness(); // Strangness of the Meson
8995  if(qM < eps)
8996  {
8997  HV->push_back(qH); // Fill AsIs (delete equivalent)
8998  if(theLC || theLS) G4cout<<"-Warning-G4QEnv::DecMes: S="<<theLS<<", C="<<theLC<<G4endl;
8999  return;
9000  }
9001 #ifdef debug
9002  G4cout<<"G4QEnv::DecayMeson: *Called* S="<<theLS<<",C="<<theLC<<",4M="<<q4M<<qM<<G4endl;
9003 #endif
9004  // Select a chanel of the Excited Meson decay
9005  G4QPDGCode fQPDG = pipQPDG; // Prototype for Meson1 = Pi+
9006  G4double fMass= mPi;
9007  G4QPDGCode sQPDG = pizQPDG; // Prototype for Meson2 = Pi0
9008  G4double sMass= mPi0;
9009  if(!theLS) // This is only for not strange Excited Mesons
9010  {
9011  if(!theLC) // Rho0 like
9012  {
9013  if(qM < m2Pi0) // Only Pi0+gamma decay is possible
9014  {
9015  if(qM < mPi0+eps)
9016  {
9017 #ifdef debug
9018  G4cout<<"G4QEnv::DecayMeson: Fill Pi0 AsIs"<<G4endl;
9019 #endif
9020  qH->SetQPDG(pizQPDG);
9021  HV->push_back(qH); // Fill AsIs (delete equivalent)
9022  if(qM+eps < mPi0)G4cout<<"-Warning-G4QEnv::DecayMeson: Pi0 AsIs, M="<<qM<<G4endl;
9023  return;
9024  }
9025  fQPDG=gQPDG; // Meson1 is gamma
9026  fMass=0.;
9027 #ifdef debug
9028  G4cout<<"-Warning-G4QEnv::DecayMeson: Gamma+Pi0, M="<<qM<<",d="<<qM-mPi0<<G4endl;
9029 #endif
9030  }
9031  else if(qM < mPiPi) // only Pi0+Pi0 is possible
9032  {
9033  fQPDG=pizQPDG; // Meson1 is Pi0
9034  fMass=mPi0;
9035  }
9036  else
9037  {
9038  if(G4UniformRand() < .333333333) // @@ can be smaller or dec \w qM !
9039  {
9040  fQPDG=pizQPDG; // Meson1 is Pi0
9041  fMass=mPi0;
9042  }
9043  else
9044  {
9045  sQPDG=pimQPDG; // Meson2 is Pi- (Pi+/Pi- decay)
9046  sMass=mPi;
9047  }
9048  }
9049  }
9050  else if(theLC==1) // Rho+ like decay
9051  {
9052  if(qM < mPiPi0) // Only gamma+Pi+ decay is possible
9053  {
9054  if(qM < mPi+eps)
9055  {
9056 #ifdef debug
9057  G4cout<<"G4QEnv::DecayMeson: Fill Pi+ AsIs"<<G4endl;
9058 #endif
9059  qH->SetQPDG(pipQPDG);
9060  HV->push_back(qH); // Fill AsIs (delete equivalent)
9061  if(qM+eps < mPi) G4cout<<"-Warning-G4QEnv::DecayMeson: Pi+ AsIs, M="<<qM<<G4endl;
9062  return;
9063  }
9064  sQPDG=gQPDG; // Meson is gamma (gamma + Pi+ decay)
9065  sMass=0.;
9066 #ifdef debug
9067  G4cout<<"-Warning-G4QEnv::DecayMeson: Gamma+Pi+, M="<<qM<<",d="<<qM-mPi0<<G4endl;
9068 #endif
9069  }
9070  //else // Pi0+Pi+ is a default case
9071  }
9072  else if(theLC==2) // Meson++ like: only PiP+PiP is possible
9073  {
9074  if(qM > mPiPi) // Only Pi+ + Pi+ decay is possible
9075  {
9076  sQPDG=pipQPDG; // Meson2 is Pi+
9077  sMass=mPi;
9078  }
9079  else // @@ Can be aReason to search for anError in Fragmentation
9080  {
9081 #ifdef debug
9082  G4cout<<"-Warning-G4QE::DecayMeson:*AsIs* Meson++ M="<<qM<<",d="<<qM-mPiPi<<G4endl;
9083 #endif
9084  HV->push_back(qH); // Fill AsIs (delete equivalent)
9085  return;
9086  }
9087  }
9088  else if(theLC==-1) // Rho- like decay
9089  {
9090  if(qM < mPiPi0) // Only gamma + Pi- decay is possible
9091  {
9092  if(qM < mPi+eps)
9093  {
9094 #ifdef debug
9095  G4cout<<"G4QEnv::DecayMeson: Fill Pi- AsIs"<<G4endl;
9096 #endif
9097  qH->SetQPDG(pimQPDG);
9098  HV->push_back(qH); // Fill AsIs (delete equivalent)
9099  if(qM+eps < mPi) G4cout<<"-Warning-G4QEnv::DecayMeson: Pi- AsIs, M="<<qM<<G4endl;
9100  return;
9101  }
9102  fQPDG=pimQPDG; // Meson1 is Pi-
9103  sQPDG=gQPDG; // Meson2 is gamma (gamma + Pi- decay)
9104  sMass=0.;
9105 #ifdef debug
9106  G4cout<<"-Warning-G4QEnv::DecayMeson: Gamma+Pi-, M="<<qM<<",d="<<qM-mPi<<G4endl;
9107 #endif
9108  }
9109  else fQPDG=pimQPDG; // Meson1 is Pi- instead of Pi+
9110  }
9111  else if(theLC==-2) // Meson-- like: only p+PiP is possible
9112  {
9113  if(qM > mPiPi) // Only Pi- + Pi- decay is possible
9114  {
9115  fQPDG=pimQPDG; // Meson1 is Pi-
9116  sQPDG=pimQPDG; // Meson2 is Pi-
9117  sMass=mPi;
9118  }
9119  else // @@ Can be aReason to search for anError in Fragmentation
9120  {
9121 #ifdef debug
9122  G4cout<<"-Warning-G4QE::DecayMeson:*AsIs* Meson-- M="<<qM<<",d="<<qM-mPiPi<<G4endl;
9123 #endif
9124  HV->push_back(qH); // Fill AsIs (delete equivalent)
9125  return;
9126  }
9127  }
9128  else // @@ Growing point: No solution for |C| > 2 so far
9129  {
9130 #ifdef debug
9131  G4cout<<"-Warning-G4QE::DecayMeson:*AsIs* UnknMeson (S=0) QC="<<qH->GetQC()<<G4endl;
9132 #endif
9133  HV->push_back(qH); // Fill AsIs (delete equivalent)
9134  return;
9135  }
9136  }
9137  else if( theLS == 1 ) // ==>->->-> Strange mesons (K-* like) S = 1 <-<-<-<==
9138  {
9139  if(!theLC) // -->> K0* like decay
9140  {
9141  if(qM < mKPi) // Only K0+gamma decay is possible KPi < K0Pi0
9142  {
9143  if(qM < mK0+eps) // Can not decay, hopefully it is close to K0
9144  {
9145 #ifdef debug
9146  G4cout << "G4QEnv::DecayMeson: Fill K0 AsIs" << G4endl;
9147 #endif
9148  qH->SetQPDG(kzQPDG);
9149  HV->push_back(qH); // Fill AsIs (delete equivalent)
9150  if(qM+eps < mK0) G4cout<<"-Warning-G4QEnv::DecayMeson: K0 AsIs, M="<<qM<<G4endl;
9151  return;
9152  }
9153  fQPDG=kzQPDG; // Meson is K0
9154  fMass=mK0;
9155  sQPDG=gQPDG; // Meson is gamma
9156  sMass=0.;
9157  }
9158  else if(qM < mK0Pi0) // Only K- + Pi+ is possible
9159  {
9160  sQPDG=kmQPDG; // Meson2 is K-
9161  sMass=mK;
9162  }
9163  else // Both K0 + Pi0 & K- + Pi+ are possible
9164  {
9165  if(G4UniformRand()>.5) // @@ Relative probability (take into account Phase Space)
9166  {
9167  sQPDG=kmQPDG; // Meson2 is K-
9168  sMass=mK;
9169  }
9170  else
9171  {
9172  fQPDG=kzQPDG; // Meson2 is K0
9173  fMass=mK0;
9174  }
9175  }
9176  }
9177  else if(theLC==-1) // -->> K-* like decay
9178  {
9179  if(qM < mKPi0) // Only K- + gamma decay is possible
9180  {
9181  if(qM < mK+eps) // Can not decay, hopefully it is close to K-
9182  {
9183 #ifdef debug
9184  G4cout << "G4QEnv::DecayMeson: Fill K- AsIs" << G4endl;
9185 #endif
9186  qH->SetQPDG(kmQPDG);
9187  HV->push_back(qH); // Fill AsIs (delete equivalent)
9188  if(qM+eps < mK) G4cout<<"-Warning-G4QEnv::DecayMeson: K- AsIs, M="<<qM<<G4endl;
9189  return;
9190  }
9191  fQPDG=kmQPDG; // Meson is K-
9192  fMass=mK;
9193  sQPDG=gQPDG; // Meson is gamma
9194  sMass=0.;
9195  }
9196  else if(qM < mKPi0) // Only K- + Pi0 is possible
9197  {
9198  fQPDG=kmQPDG; // Meson1 is K-
9199  fMass=mK;
9200  }
9201  else // Both K0 + Pi0 & K- + Pi+ are possible
9202  {
9203  if(G4UniformRand()>.5) // @@ Relative probability (take into account Phase Space)
9204  {
9205  fQPDG=kmQPDG; // Meson1 is K-
9206  fMass=mK;
9207  }
9208  else
9209  {
9210  fQPDG=pimQPDG; // Meson1 is Pi-
9211  sQPDG=kzQPDG; // Meson2 is K0
9212  sMass=mK0;
9213  }
9214  }
9215  }
9216  else if(theLC== 1) // -->> K0 + Pi+ decay only
9217  {
9218  if(qM+eps < mK0Pi) // Nothing can be done for this bad combination (Recover!)
9219  {
9220  G4cout<<"-Warniong-G4QEnv::DecayMeson: LowMassPositive Strange Meson AsIs"<<G4endl;
9221  HV->push_back(qH); // Fill AsIs (delete equivalent)
9222  return;
9223  }
9224  else // Only K- + Pi0 is possible
9225  {
9226  sQPDG=kzQPDG; // Meson2 is K0
9227  sMass=mK0;
9228  }
9229  }
9230  else if(theLC== -2) // -->> K- + Pi- decay only
9231  {
9232  if(qM+eps < mKPi) // Nothing can be done for this bad combination (Recover!)
9233  {
9234  G4cout<<"-Warniong-G4QEnv::DecayMeson: LowMassDNegativeStrange Meson AsIs"<<G4endl;
9235  HV->push_back(qH); // Fill AsIs (delete equivalent)
9236  return;
9237  }
9238  else // Only K- + Pi- is possible
9239  {
9240  fQPDG=pimQPDG; // Meson1 is Pi-
9241  sQPDG=kmQPDG; // Meson2 is K-
9242  sMass=mK;
9243  }
9244  }
9245  else
9246  {
9247  G4cout<<"-Warning-G4QE::DecMeson:*AsIs*UnknownMeson.(S=1), QC="<<qH->GetQC()<<G4endl;
9248  HV->push_back(qH); // Fill AsIs (delete equivalent)
9249  return;
9250  }
9251  }
9252  else if(theLS==2) // ==>->->-> Double srange Meson: S = 2 <-<-<-<==
9253  {
9254  if(theLC== 0) // -->> K0 + K0 decay only
9255  {
9256  if(qM+eps < mK0K0) // Nothing can be done for this bad combination (Recover!)
9257  {
9258  G4cout<<"-Warniong-G4QEnv::DecayMeson: LowMassNeutral DStrange Meson AsIs"<<G4endl;
9259  HV->push_back(qH); // Fill AsIs (delete equivalent)
9260  return;
9261  }
9262  else // Only K- + Pi0 is possible
9263  {
9264  fQPDG=kzQPDG; // Meson1 is K0
9265  fMass=mK0;
9266  sQPDG=kzQPDG; // Meson2 is K0
9267  sMass=mK0;
9268  }
9269  }
9270  else if(theLC== -1) // -->> K- + K0 decay only
9271  {
9272  if(qM+eps < mK0K) // Nothing can be done for this bad combination (Recover!)
9273  {
9274  G4cout<<"-Warniong-G4QEnv::DecayMeson: LowMassNegativeDStrange Meson AsIs"<<G4endl;
9275  HV->push_back(qH); // Fill AsIs (delete equivalent)
9276  return;
9277  }
9278  else // Only K- + Pi- is possible
9279  {
9280  fQPDG=kmQPDG; // Meson1 is K-
9281  fMass=mK;
9282  sQPDG=kzQPDG; // Meson2 is K0
9283  sMass=mK0;
9284  }
9285  }
9286  else if(theLC==-2) // -->> K- + K- decay only
9287  {
9288  if(qM+eps < mKK) // Nothing can be done for this bad combination (Recover!)
9289  {
9290  G4cout<<"-Warniong-G4QEnv::DecayMeson:LowMassDNegativeADStrangeMeson AsIs"<<G4endl;
9291  HV->push_back(qH); // Fill AsIs (delete equivalent)
9292  return;
9293  }
9294  else // Only K+ + K+ is possible
9295  {
9296  fQPDG=kmQPDG; // Meson1 is K-
9297  fMass=mK;
9298  sQPDG=kmQPDG; // Meson2 is K-
9299  sMass=mK;
9300  }
9301  }
9302  else
9303  {
9304  G4cout<<"-Warning-G4QE::DecMeson:*AsIs*UnknownMeson.(S=2), QC="<<qH->GetQC()<<G4endl;
9305  HV->push_back(qH); // Fill AsIs (delete equivalent)
9306  return;
9307  }
9308  }
9309  else if( theLS ==-1 ) // ==>->->-> AntiStrange mesons (K+* like) S =-1 <-<-<-<==
9310  {
9311  if(!theLC) // -->> aK0* like decay
9312  {
9313  if(qM < mKPi) // Only aK0+gamma decay is possible
9314  {
9315  if(qM < mK0+eps) // Can not decay, hopefully it is close to K0
9316  {
9317 #ifdef debug
9318  G4cout << "G4QEnv::DecayMeson: Fill K0 AsIs" << G4endl;
9319 #endif
9320  qH->SetQPDG(akzQPDG);
9321  HV->push_back(qH); // Fill AsIs (delete equivalent)
9322  if(qM+eps < mK0) G4cout<<"-Warning-G4QEnv::DecayMeson: aK0 AsIs, M="<<qM<<G4endl;
9323  return;
9324  }
9325  fQPDG=akzQPDG; // Meson is aK0
9326  fMass=mK0;
9327  sQPDG=gQPDG; // Meson is gamma
9328  sMass=0.;
9329  }
9330  else if(qM < mK0Pi0) // Only K+ + Pi- is possible
9331  {
9332  fQPDG=pimQPDG; // Meson1 is Pi-
9333  sQPDG=kpQPDG; // Meson2 is K+
9334  sMass=mK;
9335  }
9336  else // Both aK0 + Pi0 & K+ + Pi- are possible
9337  {
9338  if(G4UniformRand()>.5) // @@ Relative probability (take into account Phase Space)
9339  {
9340  fQPDG=pimQPDG; // Meson1 is Pi-
9341  sQPDG=kpQPDG; // Meson2 is K+
9342  sMass=mK;
9343  }
9344  else
9345  {
9346  fQPDG=akzQPDG; // Meson1 is aK0
9347  fMass=mK0;
9348  }
9349  }
9350  }
9351  else if(theLC == 1) // -->> aK+* like decay
9352  {
9353  if(qM < mKPi0) // Only aK+ + gamma decay is possible
9354  {
9355  if(qM < mK+eps) // Can not decay, hopefully it is close to K+
9356  {
9357 #ifdef debug
9358  G4cout << "G4QEnv::DecayMeson: Fill K+ AsIs" << G4endl;
9359 #endif
9360  HV->push_back(qH); // Fill AsIs (delete equivalent)
9361  if(qM+eps < mK) G4cout<<"-Warning-G4QEnv::DecayMeson: K+ AsIs, M="<<qM<<G4endl;
9362  return;
9363  }
9364  fQPDG=kpQPDG; // Meson is K+
9365  fMass=mK;
9366  sQPDG=gQPDG; // Meson is gamma
9367  sMass=0.;
9368  }
9369  else if(qM < mKPi0) // Only K+ + Pi0 is possible
9370  {
9371  fQPDG=kpQPDG; // Meson1 is K+
9372  fMass=mK;
9373  }
9374  else // Both K+ + Pi0 & aK0 + Pi+ are possible
9375  {
9376  if(G4UniformRand()>.5) // @@ Relative probability (take into account Phase Space)
9377  {
9378  fQPDG=kpQPDG; // Meson1 is K+
9379  fMass=mK;
9380  }
9381  else
9382  {
9383  sQPDG=akzQPDG; // Meson2 is aK0
9384  sMass=mK0;
9385  }
9386  }
9387  }
9388  else if(theLC==-1) // -->> aK0 + Pi- decay only
9389  {
9390  if(qM+eps < mK0Pi) // Nothing can be done for this bad combination (Recover!)
9391  {
9392  G4cout<<"-Warniong-G4QEnv::DecayMeson: LowMassNegativeAStrange Meson AsIs"<<G4endl;
9393  HV->push_back(qH); // Fill AsIs (delete equivalent)
9394  return;
9395  }
9396  else // Only aK0 + Pi- is possible
9397  {
9398  fQPDG=pimQPDG; // Meson1 is Pi-
9399  sQPDG=akzQPDG; // Meson2 is K0
9400  sMass=mK0;
9401  }
9402  }
9403  else if(theLC== 2) // -->> K+ + Pi+ decay only
9404  {
9405  if(qM+eps < mKPi) // Nothing can be done for this bad combination (Recover!)
9406  {
9407  G4cout<<"-Warniong-G4QEnv::DecayMeson: LowMassDPositiveStrange Meson AsIs"<<G4endl;
9408  HV->push_back(qH); // Fill AsIs (delete equivalent)
9409  return;
9410  }
9411  else // Only K- + Pi- is possible
9412  {
9413  sQPDG=kpQPDG; // Meson2 is K+
9414  sMass=mK;
9415  }
9416  }
9417  else
9418  {
9419  G4cout<<"-Warning-G4QE::DecMeson:*AsIs*UnknownMeson.(S=-1),QC="<<qH->GetQC()<<G4endl;
9420  HV->push_back(qH); // Fill AsIs (delete equivalent)
9421  return;
9422  }
9423  }
9424  else if(theLS==-2) // ==>->->-> Double srange Meson: S =-2 <-<-<-<==
9425  {
9426  if(theLC== 0) // -->> aK0 + aK0 decay only
9427  {
9428  if(qM+eps < mK0K0) // Nothing can be done for this bad combination (Recover!)
9429  {
9430  G4cout<<"-Warniong-G4QEnv::DecayMeson: LowMassNeutralADStrange Meson AsIs"<<G4endl;
9431  HV->push_back(qH); // Fill AsIs (delete equivalent)
9432  return;
9433  }
9434  else // Only K- + Pi0 is possible
9435  {
9436  fQPDG=akzQPDG; // Meson1 is aK0
9437  fMass=mK0;
9438  sQPDG=akzQPDG; // Meson2 is aK0
9439  sMass=mK0;
9440  }
9441  }
9442  else if(theLC== 1) // -->> K+ + K0 decay only
9443  {
9444  if(qM+eps < mK0K) // Nothing can be done for this bad combination (Recover!)
9445  {
9446  G4cout<<"-Warniong-G4QEnv::DecayMeson: LowMassPositiveADStrangeMeson AsIs"<<G4endl;
9447  HV->push_back(qH); // Fill AsIs (delete equivalent)
9448  return;
9449  }
9450  else // Only K+ + K0 is possible
9451  {
9452  fQPDG=kpQPDG; // Meson1 is K+
9453  fMass=mK;
9454  sQPDG=akzQPDG; // Meson2 is K0
9455  sMass=mK0;
9456  }
9457  }
9458  else if(theLC== 2) // -->> K+ + K+ decay only
9459  {
9460  if(qM+eps < mKK) // Nothing can be done for this bad combination (Recover!)
9461  {
9462  G4cout<<"-Warniong-G4QEnv::DecayMeson:LowMassDPositiveADStrangeMeson AsIs"<<G4endl;
9463  HV->push_back(qH); // Fill AsIs (delete equivalent)
9464  return;
9465  }
9466  else // Only K+ + K+ is possible
9467  {
9468  fQPDG=kpQPDG; // Meson1 is K+
9469  fMass=mK;
9470  sQPDG=kpQPDG; // Meson2 is K+
9471  sMass=mK;
9472  }
9473  }
9474  else
9475  {
9476  G4cout<<"-Warning-G4QE::DecMeson:*AsIs*UnknownMeson.(S=-2),QC="<<qH->GetQC()<<G4endl;
9477  HV->push_back(qH); // Fill AsIs (delete equivalent)
9478  return;
9479  }
9480  }
9481  else
9482  {
9483  //#ifdef debug
9484  G4cout<<"---Warning---G4QE::DecMeso: *Fill AsIso* UnknMeson, QC="<<qH->GetQC()<<G4endl;
9485  //#endif
9486  HV->push_back(qH); // Fill AsIs (delete equivalent)
9487  return;
9488  }
9489  G4LorentzVector f4Mom(0.,0.,0.,fMass);
9490  G4LorentzVector s4Mom(0.,0.,0.,sMass);
9491  G4double sum=fMass+sMass;
9492  if(fabs(qM-sum)<eps)
9493  {
9494  f4Mom=q4M*(fMass/sum);
9495  s4Mom=q4M*(sMass/sum);
9496  }
9497  else if(qM<sum || !G4QHadron(q4M).DecayIn2(f4Mom, s4Mom))
9498  {
9499 #ifdef debug
9500  G4cout<<"---Warning---G4QE::DecMes:fPDG="<<fQPDG<<"(M="<<fMass<<")+sPDG="<<sQPDG<<"(M="
9501  <<sMass<<") > TotM="<<q4M.m()<<G4endl;
9502 #endif
9503  if(!theEnvironment.GetA())
9504  {
9505  G4Quasmon* quasH = new G4Quasmon(qH->GetQC(),qH->Get4Momentum());
9506  if(!CheckGroundState(quasH,true)) HV->push_back(qH); // Cor or fill asItIs
9507  else delete qH;
9508  delete quasH;
9509  return;
9510  }
9511  else
9512  {
9513  delete qH;
9515  ed << "Meson DecayIn2 error: Can't Correct, *EmptyEnv*="
9516  << theEnvironment << G4endl;
9517  G4Exception("G4QEnvironment::DecayMeson()", "HAD_CHPS_0001",
9518  FatalException, ed);
9519  }
9520  }
9521 #ifdef debug
9522  G4cout<<"G4QEnv::DecayMeson: *DONE* f4M="<<f4Mom<<",fPDG="<<fQPDG<<", s4M="<<s4Mom
9523  <<",sPDG="<<sQPDG<<G4endl;
9524 #endif
9525  delete qH;
9526  //
9527  G4QHadron* H1 = new G4QHadron(fQPDG,f4Mom); // Create a Hadron for the 1-st baryon
9528  HV->push_back(H1); // Fill "H1" (delete equivalent)
9529  G4QHadron* H2 = new G4QHadron(sQPDG,s4Mom); // Create a Hadron for the 2-nd baryon
9530  HV->push_back(H2); // Fill "H2" (delete equivalent)
9531 } // End of DecayMeson
9532 
9533 //Decay of the Antistrange Nucleus in nucleus & K+/antiK0 (at present only S=-1)
9535 {
9536  static const G4QPDGCode kpQPDG(321); // QPDG for Antistrange positive kaon
9537  static const G4QPDGCode kzQPDG(311); // QPDG for Antistrange neutral anti-kaon
9538  static const G4double mK =G4QPDGCode(321).GetMass(); // Mass of antistrange positive Kaon
9539  static const G4double mK0=G4QPDGCode(311).GetMass(); // Mass of antistrange neutral aK0
9540  static const G4double eps=0.003;
9541  //static const G4QNucleus vacuum(90000000);
9542  G4int theLS= qH->GetStrangeness(); // Strangness of the Nucleus
9543  if(theLS>=0)
9544  {
9545  G4cerr<<"***G4QEnvironment::DecayAntistrange: S="<<theLS<<", but must be <0"<<G4endl;
9546  //#ifdef ppdebug
9547  // throw G4QException("G4QEnv::DecayAntistrange: Not Antistrange nucleus");
9548  G4Exception("G4QEnvironment::DecayAntistrange()", "HAD_CHPS_0000",
9549  FatalException, "Not Antistrange nucleus");
9550  //#endif
9551  //HV->push_back(qH); // Fill AsIs (delete equivalent)
9552  return;
9553  }
9554  //else if(theLS<-1)
9555  //{
9556  // G4cout<<"*Warning*G4QEnviron::DecayAntistrange: S="<<theLS<<",AsIs->Improve"<<G4endl;
9557  // HV->push_back(qH); // Fill AsIs (delete equivalent)
9558  // return;
9559  //}
9560  G4int astr=-theLS; // Number of K+ (or anti-K0)
9561  G4int theLB= qH->GetBaryonNumber(); // Baryon number of the Nucleus
9562  G4int theLC= qH->GetCharge(); // Chsrge of the Nucleus
9563  G4int qPDG = qH->GetPDGCode(); // PDG Code of the decaying Nucleus
9564  G4int K0PDG= qPDG+astr*999999; // Residual nonStrange nucleus for S*antiK0
9565  G4QPDGCode K0QPDG(K0PDG); // QPDG of the nuclear residual for S*antiK0
9566  G4double rK0M=K0QPDG.GetMass(); // Mass of the nuclear residual for S*antiK0
9567  G4int KpPDG= qPDG+astr*999000; // Residual nonStrange nucleus for S*K+
9568  G4QPDGCode KpQPDG(KpPDG); // QPDG of the nuclear residual for S*K+
9569  G4double rKpM=KpQPDG.GetMass(); // Mass of the nuclear residual for S*K+
9570  G4LorentzVector q4M = qH->Get4Momentum(); // Get 4-momentum of the Nucleus
9571  G4double qM = q4M.m(); // Mass of the Nucleus
9572 #ifdef debug
9573  G4cout<<"G4QE::DecayAntistrang:S="<<theLS<<",C="<<theLC<<",B="<<theLB<<",M="<<qM<<G4endl;
9574 #endif
9575  // Select a chanel of the decay: @@ The Kaon binding energy is not taken into account !!
9576  G4QPDGCode fQPDG = kzQPDG; // Prototype for Kaon (anti-K0)
9577  G4double fMass= mK0;
9578  G4QPDGCode sQPDG = K0QPDG; // Prototype for residual nucleus to Kaon
9579  G4double sMass= rK0M;
9580  if(astr*mK0+rK0M>qM) // Can not be K0
9581  {
9582  if(astr*mK+rKpM>qM) // Can not be K+ too
9583  {
9584 #ifdef debug
9585  // @@ Survices, but...
9586  G4cout<<"*Warning*G4QEnvironment::DecayAntistrange: Too low mass, keep AsIs"<<G4endl;
9587 #endif
9588  HV->push_back(qH); // Fill AsIs (delete equivalent)
9589  return;
9590  }
9591  else // Switch to K+
9592  {
9593  fQPDG = kpQPDG; // Positive Kaon
9594  fMass= mK;
9595  sQPDG = KpQPDG; // Residual nucleus to K+
9596  sMass= rKpM;
9597  }
9598  }
9599  else if(astr*mK+rKpM<qM && theLC>theLB-theLC) // Switch to K+ if Z>N
9600  {
9601  fQPDG = kpQPDG; // Positive Kaon
9602  fMass= mK;
9603  sQPDG = KpQPDG; // Residual nucleus to K+
9604  sMass= rKpM;
9605  }
9606  G4double afMass=fMass;
9607  if(astr>1) afMass*=astr;
9608  G4LorentzVector f4Mom(0.,0.,0.,afMass);
9609  G4LorentzVector s4Mom(0.,0.,0.,sMass);
9610  G4double sum=afMass+sMass;
9611  if(fabs(qM-sum)<eps)
9612  {
9613  f4Mom=q4M*(afMass/sum);
9614  s4Mom=q4M*(sMass/sum);
9615  }
9616  else if(qM<sum || !G4QHadron(q4M).DecayIn2(f4Mom, s4Mom))
9617  {
9618 #ifdef debug
9619  G4cout<<"--Warning--G4QE::DecAntistrange: fPDG="<<fQPDG<<"(M="<<fMass<<")+sPDG="<<sQPDG
9620  <<"(M="<<sMass<<") > TotM="<<q4M.m()<<G4endl;
9621 #endif
9622  // G4cerr<<"***G4QEnv::DecayAntistrange: M="<<qM<<", sum="<<sum<<G4endl;
9623  // throw G4QException("G4QEnv::DecayAntistrange: Nucleus DecayIn2 error");
9625  ed << "Nucleus DecayIn2 error: DecayAntistrange: M=" << qM << ", sum="
9626  << sum << G4endl;
9627  G4Exception("G4QEnvironment::DecayAntistrange()", "HAD_CHPS_0001",
9628  FatalException, ed);
9629  }
9630 #ifdef debug
9631  G4cout<<"G4QEnv::DecayAntistrange: *Done* f4M="<<f4Mom<<",fPDG="<<fQPDG<<", s4M="<<s4Mom
9632  <<",sPDG="<<sQPDG<<G4endl;
9633 #endif
9634  delete qH;
9635  //
9636  if(astr>1) f4Mom/=astr;
9637  G4QHadron* H1 = new G4QHadron(fQPDG,f4Mom); // Create a Hadron for the 1-st kaon
9638  HV->push_back(H1); // Fill "H1" (delete equivalent)
9639  for(G4int ia=1; ia < astr; ++ia)
9640  {
9641  H1 = new G4QHadron(fQPDG,f4Mom); // Create a Hadron for other kaons
9642  HV->push_back(H1); // Fill "H1" (delete equivalent)
9643  }
9644  G4QHadron* H2 = new G4QHadron(sQPDG,s4Mom); // Create a Hadron for the Residual Nucleus
9645  HV->push_back(H2); // Fill "H2" (delete equivalent)
9646 } // End of DecayAntistrange
9647 
9648 // Check that it's possible to decay the TotalResidualNucleus in Quasmon+Environ & correct
9649 // In case of correction the "quasm" is never deleted! If corFlag==true - correction.
9650 G4bool G4QEnvironment::CheckGroundState(G4Quasmon* quasm, G4bool corFlag)
9651 {
9652  static const G4QPDGCode gamQPDG(22);
9653  static const G4QContent neutQC(2,1,0,0,0,0);
9654  static const G4QContent protQC(1,2,0,0,0,0);
9655  static const G4QContent lambQC(1,1,1,0,0,0);
9656  static const G4QContent pimQC(1,0,0,0,1,0);
9657  static const G4QContent pipQC(0,1,0,1,0,0);
9658  static const G4double mNeut= G4QPDGCode(2112).GetMass();
9659  static const G4double mProt= G4QPDGCode(2212).GetMass();
9660  static const G4double mLamb= G4QPDGCode(3122).GetMass();
9661  static const G4double mPi = G4QPDGCode(211).GetMass();
9662  //static const G4double dmPi = mPi+mPi;
9666  G4QContent valQ=quasm->GetQC(); // Quark content of the Quasmon
9667  G4int resQPDG=valQ.GetSPDGCode(); // Reachable in a member function
9668  G4int resB=valQ.GetBaryonNumber(); // Baryon number of the Quasmon
9669  G4int resC=valQ.GetCharge(); // Charge of the Quasmon
9670  G4int resS=valQ.GetStrangeness(); // Strangeness of the Quasmon
9671  if(resQPDG==10 && resB>0) resQPDG=valQ.GetZNSPDGCode();
9672  G4double resQMa=G4QPDGCode(resQPDG).GetMass();// GS Mass of the Residual Quasmon
9673  G4double resEMa=0.; // GS Mass of the EmptyResidualEnvironment
9674  G4bool bsCond=false; // FragSeparatCondition for QuasmonInVacuum
9675  G4LorentzVector enva4M=G4LorentzVector(0.,0.,0.,0.); // Prototype of the environment Mass
9676  G4QContent reTQC=valQ; // Prototype QuarkContent of the ResidNucl
9677  G4LorentzVector reTLV=quasm->Get4Momentum(); // Prototyoe 4-Mom of the Residual Nucleus
9678  G4double reTM=reTLV.m(); // Real mass of the Quasmon
9679  G4int envPDG=theEnvironment.GetPDG();
9680 
9681  if ( resB > 1 &&
9682  ( ( !resS &&
9683  ( (resC == resB && reTM > resC*mProt) || (!resC && reTM > resB*mNeut) )
9684  ) ||
9685  (resS == resB && reTM > resS*mLamb)
9686  )
9687  ) // Immediate Split(@@Decay) MultiBaryon
9688  {
9689 #ifdef chdebug
9690  G4cout<<"::G4QE::CGS:*MultyB*E="<<envPDG<<",B="<<resB<<",C="<<resC<<",S"<<resS<<G4endl;
9691 #endif
9692  if(envPDG!=90000000)
9693  {
9694  resEMa=theEnvironment.GetMZNS(); // GSMass of the Residual Environment
9695  enva4M=theEnvironment.Get4Momentum(); // 4-Mom of the Residual Environment
9696  G4LorentzVector toLV=reTLV+enva4M; // Total 4-mom for decay
9697  enva4M=G4LorentzVector(0.,0.,0.,resEMa); // GSM of the Environment
9698  reTLV=G4LorentzVector(0.,0.,0.,resQMa); // GSM of the Quasmon
9699  if(G4QHadron(toLV).DecayIn2(reTLV,enva4M))
9700  {
9701 #ifdef debug
9702  G4cout<<"G4QE::CGS: fill EnvPDG="<<envPDG<<",4M="<<enva4M<<" and continue"<<G4endl;
9703 #endif
9704  theQHadrons.push_back(new G4QHadron(envPDG,enva4M)); // (delete equivalent)
9705  theEnvironment=G4QNucleus(G4QContent(0,0,0,0,0,0), G4LorentzVector(0.,0.,0.,0.));
9706  }
9707  else G4cout<<"*G4QE::CGS:tM="<<toLV.m()<<toLV<<"<q="<<resQMa<<"+EM="<<resEMa<<G4endl;
9708  }
9709  G4int baPDG=3122; // Prototype for MultiLambda
9710  if(!resS) baPDG = (!resC) ? 2112 : 2212; // MultiNeutron or MultiProton
9711 #ifdef debug
9712  G4cout<<"G4QE::CGS: fill "<<resB<<" of "<<baPDG<<" with t4M="<<reTLV<<G4endl;
9713 #endif
9714  reTLV/=resB; // Recalculate! Anyway go out...
9715  for(G4int ib=0; ib<resB; ib++) theQHadrons.push_back(new G4QHadron(baPDG,reTLV));
9716  return true;
9717  }
9718 #ifdef cdebug
9719  if(resQPDG==89998005)
9720  G4cout<<"G4QE::CGS:Q="<<valQ<<resQPDG<<",GM="<<resQMa<<",4M="<<reTLV<<reTLV.m()<<G4endl;
9721 #endif
9722  G4double resSMa=resQMa; // Prototype MinimalSplitMass of ResidNucl
9723  enva4M=theEnvironment.Get4Momentum(); // 4-Mom of the Residual Environment
9724  if(envPDG!=90000000 && fabs(enva4M.m2())>1.) // => "Environment is not vacuum" case
9725  { // @@@@@@@@@@@@@@@@@@@ CALL SUBROUTINE ? @@@@@@@@@
9726  resEMa=theEnvironment.GetMZNS(); // GSMass of the Residual Environment
9727 #ifdef cdebug
9728  G4cout<<"G4QE::CGS:EnvironmentExists,gsM="<<resEMa<<",4M="<<enva4M<<enva4M.m()<<G4endl;
9729 #endif
9730  reTQC+=theEnvironment.GetQCZNS(); // Quark content of the Residual Nucleus
9731  reTLV+=enva4M; // 4-Mom of Residual Nucleus
9732  //resSMa+=resEMa; // Minimal Split Mass of Residual Nucleus
9733  resSMa=G4QPDGCode(reTQC).GetMass(); // GS Mass of the Residual Quasmon+Environ
9734  }
9735  else // Calculate BaryonSeparatCond for vacQuasm
9736  {
9737  G4double resQM=reTLV.m(); // CM Mass of the Residual vacQuasmon
9738  G4int baryn=valQ.GetBaryonNumber(); // Baryon Number of the Residual vacQuasmon
9739  if(baryn>1) // => "Can split baryon?"
9740  {
9741  if(valQ.GetN()) // ===> "Can split neutron?"
9742  {
9743  G4QContent resQC=valQ-neutQC; // QC of Residual for the Neutron
9744  G4int resPDG=resQC.GetSPDGCode(); // PDG of Residual for the Neutron
9745  if(resPDG==10&&resQC.GetBaryonNumber()>0) resPDG=resQC.GetZNSPDGCode();
9746  G4double resMas=G4QPDGCode(resPDG).GetMass(); // GS Mass of the Residual
9747  if(resMas+mNeut<resQM) bsCond=true;
9748  }
9749  else if(valQ.GetP()) // ===> "Can split proton?"
9750  {
9751  G4QContent resQC=valQ-protQC; // QC of Residual for the Proton
9752  G4int resPDG=resQC.GetSPDGCode(); // PDG of Residual for the Proton
9753  if(resPDG==10&&resQC.GetBaryonNumber()>0) resPDG=resQC.GetZNSPDGCode();
9754  G4double resMas=G4QPDGCode(resPDG).GetMass(); // GS Mass of the Residual
9755  if(resMas+mProt<resQM) bsCond=true;
9756  }
9757  else if(valQ.GetL()) // ===> "Can split Lambda?"
9758  {
9759  G4QContent resQC=valQ-lambQC; // QC of Residual for the Lambda
9760  G4int resPDG=resQC.GetSPDGCode(); // PDG of Residual for the Lambda
9761  if(resPDG==10&&resQC.GetBaryonNumber()>0) resPDG=resQC.GetZNSPDGCode();
9762  G4double resMas=G4QPDGCode(resPDG).GetMass(); // GS Mass of the Residual
9763  if(resMas+mLamb<resQM) bsCond=true;
9764  }
9765  }
9766  }
9767  G4double resTMa=reTLV.m(); // CM Mass of the ResidualNucleus (Q+Env)
9768  //if(resTMa>resSMa && (resEMa || bsCond)) return true;// Why not ?? @@ (See G4Q the same)
9769  G4int nOfOUT = theQHadrons.size(); // Total #of QHadrons at this point
9770 #ifdef cdebug
9771  G4int reTPDG=reTQC.GetSPDGCode();
9772  if(reTPDG==10&&reTQC.GetBaryonNumber()>0) reTPDG=reTQC.GetZNSPDGCode();
9773  G4cout<<"G4QEnv::CheckGS:(tM="<<resTMa<<"<rQM+rEM="<<resSMa<<",d="<<resSMa-resTMa
9774  <<" || rEM="<<resEMa<<"=0 & "<<!bsCond<<"=1) & n="<<nOfOUT<<">0 & F="<<corFlag
9775  <<" then the correction must be done for PDG="<<reTPDG<<G4endl;
9776 #endif
9777  if ( (resTMa < resSMa || (!resEMa && !bsCond) ) && nOfOUT > 0 && corFlag) // *CORRECTION*
9778  {
9779  G4QHadron* theLast = theQHadrons[nOfOUT-1];
9780  G4int cNf=theLast->GetNFragments();
9781  G4int crPDG=theLast->GetPDGCode();
9782 #ifdef cdebug
9783  G4cout<<"G4QE::CGS: **Correction** lNF="<<cNf<<",lPDG="<<crPDG<<",Q4M="<<reTLV<<G4endl;
9784 #endif
9785  G4LorentzVector hadr4M = theLast->Get4Momentum();
9786  G4double hadrMa=hadr4M.m();
9787  G4LorentzVector tmpTLV=reTLV+hadr4M; // Tot (ResidNucl+LastHadron) 4-Mom
9788 #ifdef cdebug
9789  G4cout<<"G4QE::CGS:YES, s4M/M="<<tmpTLV<<tmpTLV.m()<<">rSM+hM="<<resSMa+hadrMa<<G4endl;
9790 #endif
9791  G4double tmpTM=tmpTLV.m();
9792  if(tmpTM>resSMa+hadrMa &&!cNf && crPDG!=22) // Q(E)L contain QM(+EM)+lM ***Last CORR***
9793  {
9794  if(resEMa) // => "NonVacuumEnvironment exists" case
9795  {
9796  G4LorentzVector quas4M = G4LorentzVector(0.,0.,0.,resQMa); // GS Mass of Quasmon
9797  enva4M = G4LorentzVector(0.,0.,0.,resEMa); // GS Mass of ResidEnvir
9798  if(tmpTM>=resQMa+resEMa+hadrMa && G4QHadron(tmpTLV).DecayIn3(hadr4M,quas4M,enva4M))
9799  {
9800  //@@CHECK CoulBar (only for ResQuasmon in respect to ResEnv) and may be evaporate
9801 #ifdef debug
9802  G4cout<<"G4QE::CGS: Modify the Last 4-momentum to "<<hadr4M<<G4endl;
9803 #endif
9804  theLast->Set4Momentum(hadr4M);
9805  G4QHadron* quasH = new G4QHadron(valQ, quas4M);
9806  G4QContent theEQC=theEnvironment.GetQCZNS();
9807  G4QHadron* envaH = new G4QHadron(theEQC,enva4M);
9808 #ifdef debug
9809  G4cout<<"G4QE::CGS: Fill Quasm "<<valQ<<quas4M<<" in any form"<<G4endl;
9810 #endif
9811  EvaporateResidual(quasH, false); // Try to evaporate residual quasmon (del.eq.)
9812 #ifdef debug
9813  G4cout<<"G4QE::CGS: Fill envir "<<theEQC<<enva4M<<" in any form"<<G4endl;
9814 #endif
9815  // @@ Substitute by EvaporateResidual (if it is not used in the evaporateResid)
9816  envaH->Set4Momentum(enva4M);
9817  EvaporateResidual(envaH); // Try to evaporate residual environment(del.eq.)
9818  // Kill environment as it is already included in the decay
9819  theEnvironment=G4QNucleus(G4QContent(0,0,0,0,0,0), G4LorentzVector(0.,0.,0.,0.));
9820  }
9821  else
9822  {
9823 #ifdef cdebug
9824  G4cout<<"***G4QEnv::CheckGroundState: Decay in Frag+ResQ+ResE error"<<G4endl;
9825 #endif
9826  return false;
9827  }
9828  }
9829  else // => "Environ is vacuum" case (DecayIn2)
9830  {
9831  G4LorentzVector quas4M = G4LorentzVector(0.,0.,0.,resQMa); // GS Mass of Quasmon
9832  G4QHadron* quasH = new G4QHadron(valQ, quas4M);
9833  if(tmpTM>=resQMa+hadrMa && G4QHadron(tmpTLV).DecayIn2(hadr4M,quas4M))//DeIn2(noEnv)
9834  {
9835  //@@CHECK CoulBar (only for ResQuasmon in respect to ResEnv) & may be evaporate
9836  theLast->Set4Momentum(hadr4M);
9837 #ifdef debug
9838  G4cout<<"G4QE::CGS: modify theLast 4M="<<hadr4M<<hadr4M.m()<<G4endl;
9839 #endif
9840  quasH->Set4Momentum(quas4M);
9841 #ifdef debug
9842  G4cout<<"G4QE::CGS: fill newQH "<<valQ<<quas4M<<quas4M.m()<<" inAnyForm"<<G4endl;
9843 #endif
9844  EvaporateResidual(quasH, false); // Try to evaporate residual quasmon (del.eq.)
9845  }
9846  else
9847  {
9848  delete quasH; // Delete "Quasmon Hadron"
9849 #ifdef cdebug
9850  G4cout<<"***G4QEnv::CheckGS: Decay in Fragm+ResQ did not succeeded"<<G4endl;
9851 #endif
9852  return false;
9853  }
9854  }
9855  }
9856  else // *** Try Last+Previous CORRECTION ***
9857  {
9858 #ifdef cdebug
9859  G4cout<<"G4QEnv::CheckGS: the Last did not help, nH="<<nOfOUT<<G4endl;
9860 #endif
9861  if(nOfOUT>1) // Cor with Last&Previous can be tryed
9862  {
9863  G4QHadron* thePrev = theQHadrons[nOfOUT-2]; // Get pointer to Prev before Last
9864  if(thePrev->GetNFragments()||thePrev->GetNFragments()) return false;// Dec H/g
9865  G4LorentzVector prev4M = thePrev->Get4Momentum();
9866  G4double prevMa=prev4M.m(); // Mass of previous hadron
9867  tmpTLV+=prev4M; // Increase Total 4-Mom of TotalResidNucl
9868  G4int totPDG=reTQC.GetSPDGCode(); // PDG Code of Total Residual Nucleus
9869  if(totPDG==10&&reTQC.GetBaryonNumber()>0) totPDG=reTQC.GetZNSPDGCode();
9870  G4double tQMa=G4QPDGCode(totPDG).GetMass(); // GS Mass of the Residual Nucleus
9871 #ifdef cdebug
9872  G4cout<<"G4QE::CGS:T3="<<tmpTLV<<tmpTLV.m()<<">t+h+p="<<tQMa+hadrMa+prevMa<<G4endl;
9873 #endif
9874  if(tmpTLV.m()>tQMa+hadrMa+prevMa)
9875  {
9876  G4LorentzVector nuc4M = G4LorentzVector(0.,0.,0.,tQMa);// 4-Mom of ResidNucAtRest
9877  G4QHadron* nucH = new G4QHadron(reTQC, nuc4M);
9878  if(!G4QHadron(tmpTLV).DecayIn3(hadr4M,prev4M,nuc4M))
9879  {
9880  delete nucH; // Delete "Residual Nucleus Hadron"
9881  G4cout<<"---Warning---G4QE::CGS:DecayIn ResNuc+LastH+PrevH Error"<<G4endl;
9882  return false;
9883  }
9884  else
9885  {
9886  theLast->Set4Momentum(hadr4M);
9887  thePrev->Set4Momentum(prev4M);
9888  nucH->Set4Momentum(nuc4M);
9889 #ifdef cdebug
9890  G4cout<<"G4QE::CGS:*SUCCESS**>CHECK, D4M="<<tmpTLV-hadr4M-prev4M-nuc4M<<G4endl;
9891 #endif
9892 #ifdef debug
9893  G4cout<<"G4QE::CGS: Fill nucleus "<<reTQC<<nuc4M<<" in any form"<<G4endl;
9894 #endif
9895  EvaporateResidual(nucH, false); // Try to evaporate residual nucleus(del.eq.)
9896  }
9897  }
9898  else // ===> Try to use any hadron from the output
9899  {
9900 #ifdef cdebug
9901  G4cout<<"G4QE::CGS:Prev&Last didn't help,nH="<<nOfOUT<<">2, MQ="<<resQMa<<G4endl;
9902 #endif
9903  G4int nphot=-1; // #of photons
9904  G4int npip=-1; // #of Pi+
9905  G4int npiz=-1; // #of Pi0
9906  G4int npim=-1; // #of Pi-
9907  G4double emaz=0.; // The maximum energy for pi0 (to sel high E)
9908  for(G4int id=nOfOUT-1; id>=0; id--) // Search for photons and pi+, and pi-
9909  {
9910  G4QHadron* curHadr = theQHadrons[id];
9911  G4int hPDG=curHadr->GetPDGCode();
9912  if(hPDG == 22) nphot=id; // Get the earliest gamma
9913  else if(hPDG==211 && npip<1) npip=id; // Get the latest Pi+
9914  else if(hPDG==111)
9915  {
9916  G4double piE=curHadr->Get4Momentum().e();
9917 #ifdef chdebug
9918  G4cout<<"::G4QE::CheckGroundState:"<<id<<",Epi0="<<piE<<">"<<emaz<<G4endl;
9919 #endif
9920  if(piE>emaz)
9921  {
9922  npiz=id;
9923  emaz=piE;
9924  }
9925  }
9926  else if(hPDG==-211 && npim<1) npim=id; // Get the latest Pi-
9927  }
9928  if(nphot>=0) // Photon is found, try to use it to resolve PANIC
9929  {
9930  G4QHadron* curHadr = theQHadrons[nphot]; // Pointer to the photon
9931  G4LorentzVector ch4M=curHadr->Get4Momentum(); // 4-Mom of the Photon
9932  G4LorentzVector tt4M=ch4M+reTLV;// (resQMa=GSMass of the ResidQuasmon(+Env.))
9933  G4double ttM=tt4M.m(); // Mass of the Phot+ResidQm compaund system
9934  if(resQMa<ttM) // PANIC can be resolved with this Photon
9935  {
9936  G4LorentzVector quas4M = G4LorentzVector(0.,0.,0.,resSMa);//GSMass of Quasm
9937  G4QHadron* rqH = new G4QHadron(reTQC,quas4M); // Prototype of outputResidQ
9938  if(!G4QHadron(tt4M).DecayIn2(ch4M,quas4M))
9939  {
9940  delete rqH; // Delete tmp "Residual Quasmon Hadron"
9941 #ifdef cdebug
9942  G4cout<<"***G4QEnv::CheckGS: Decay in Photon+ResQ tM="<<ttM<<G4endl;
9943 #endif
9944  }
9945  else
9946  {
9947  curHadr->Set4Momentum(ch4M);// Change 4M of Photon (reduced by decay)
9948  rqH->Set4Momentum(quas4M); // Fill 4M of the GS Residual Quasmon
9949 #ifdef cdebug
9950  G4cout<<"G4QE::CGS:nPhot="<<nphot<<",ph4M="<<ch4M<<"+r4M="<<quas4M<<G4endl;
9951 #endif
9952 #ifdef debug
9953  G4cout<<"G4QE::CGS: Fill Resid "<<reTQC<<quas4M<<" in any form"<<G4endl;
9954 #endif
9955  EvaporateResidual(rqH, false);//Try to evaporate residual quasmon (del.eq.)
9956  if(envPDG!=90000000) theEnvironment=G4QNucleus(G4QContent(0,0,0,0,0,0),
9957  G4LorentzVector(0.,0.,0.,0.));
9958  return true;
9959  }
9960  } // End of the KINEMATIC CHECK FOR THE PHOTON if
9961  } // End of nphot IF
9962 #ifdef chdebug
9963  if(resQPDG==89998004) G4cout<<"::G4QE::CGS:S="<<resS<<",B="<<resB<<",C="<<resC
9964  <<",+#"<<npip<<",-#"<<npim<<",0#"<<npiz<<",E="<<envPDG<<G4endl;
9965 #endif
9966  //if(npip>=0&&resQPDG==89998004 || npim>=0&&resQPDG==90003998)// D+D+pi->N+N+pi
9967  if (envPDG == 90000000 && !resS && resB > 1 &&
9968  ((npip >= 0 && resC == -2) || (npim >= 0 && resC-resB == 2)) )
9969  {
9970  G4int npi=npip; // (Delta-)+(Delta-)+k*n+(pi+)->(k+2)*n+(pi-)
9971  G4int piPD=-211;
9972  G4int nuPD=2112;
9973  G4double nuM=mNeut;
9974  if(resC!=-2) // (Delta++)+(Delta++)+k*p+(pi-)->(k+2)*p+(pi-)
9975  {
9976  npi=npim;
9977  piPD=211;
9978  nuPD=2212;
9979  nuM=mProt;
9980  }
9981  G4QPDGCode piQPDG(piPD);
9982  G4int rB=resB-1;
9983  G4double suB=rB*nuM;
9984  G4double suM=suB+nuM+mPi;
9985  G4QHadron* curHadr = theQHadrons[npi]; // Pointer to the pion of oposit sign
9986  G4LorentzVector ch4M=curHadr->Get4Momentum(); // 4-Mom of the Pion
9987  G4LorentzVector tt4M=ch4M+reTLV;// (resQMa=GSMass of the ResidQuasmon(+Env.))
9988  G4double ttM=tt4M.m(); // Mass of the Pion+ResidQm compaund system
9989 #ifdef cdebug
9990  if(resQPDG==89998005)
9991  G4cout<<"G4QE::CGS:Sm="<<suM<<"<Tot="<<ttM<<tt4M
9992  <<",pi="<<ch4M<<",Q="<<reTLV.m()<<reTLV<<G4endl;
9993 #endif
9994  if(suM<ttM) // PANIC can be resolved with this Pion
9995  {
9996  G4LorentzVector fn4M = G4LorentzVector(0.,0.,0.,suB);//First nucleon(s)
9997  G4LorentzVector sn4M = G4LorentzVector(0.,0.,0.,nuM);//Second nucleon
9998  G4LorentzVector pi4M = G4LorentzVector(0.,0.,0.,mPi);//Pion
9999  if(!G4QHadron(tt4M).DecayIn3(fn4M,sn4M,pi4M))
10000  {
10001 #ifdef cdebug
10002  if(resQPDG==89998005)
10003  G4cout<<"***G4QEnv::CheckGS:DecayIn3 2N+Pi,tM="<<ttM<<","<<suM<<G4endl;
10004 #endif
10005  }
10006  else
10007  {
10008  if(rB>1) fn4M/=rB;
10009  for(G4int ib=0; ib<rB; ib++)
10010  {
10011  G4QHadron* fnH = new G4QHadron(nuPD,fn4M);// First Nucleon(s)
10012 #ifdef debug
10013  G4cout<<"G4QE::CGS: fill Nucleon #"<<ib<<", "<<nuPD<<fn4M<<G4endl;
10014 #endif
10015  theQHadrons.push_back(fnH); // Fill First Nucleon(s) (del. equivalent)
10016  }
10017  G4QHadron* snH = new G4QHadron(nuPD,sn4M);// Second Nucleon
10018 #ifdef debug
10019  G4cout<<"G4QE::CGS: fill the Last Nucleon, "<<nuPD<<sn4M<<G4endl;
10020 #endif
10021  theQHadrons.push_back(snH); // Fill Second Nucleon (delete equivalent)
10022  curHadr->Set4Momentum(pi4M);// Change 4M of the Pion (reduced by decay)
10023  curHadr->SetQPDG(piQPDG); // Change Charge of thePion
10024 #ifdef cdebug
10025  if(resQPDG==89998005)
10026  G4cout<<"G4QE::CGS:1="<<nuPD<<fn4M<<rB<<",2="<<sn4M<<",p="<<pi4M<<G4endl;
10027 #endif
10028  return true;
10029  }
10030  } // End of the KINEMATIC CHECK FOR THE PI+/PI- if
10031  } // End of npip/pin Isonucleus IF
10032  if(envPDG==90000000&&!resS&&resB>1&&npiz>=0&&(resC<-1||resC-resB>1))
10033  {
10034 #ifdef chdebug
10035  G4cout<<"*::*G4QE::CGS:Pi0,rPDG="<<resQPDG<<",rC="<<resC<<",rB="<<resB<<G4endl;
10036 #endif
10037  G4int npi=-resC; // k*(Delta-)+m*n+pi0->(k+m)*k+(pi-)
10038  G4int piPD=-211;
10039  G4int nuPD=2112;
10040  G4double nuM=mNeut;
10041  if(resC!=-2) // k*(Delta++)+m*p+pi0->(k+m)*p+k*(pi+)
10042  {
10043  npi=resC-resB;
10044  piPD=211;
10045  nuPD=2212;
10046  nuM=mProt;
10047  }
10048  G4QPDGCode piQPDG(piPD);
10049  G4double suB=resB*nuM; // Total mass of nucleons
10050  G4double suM=npi*mPi; // Total mass of pions
10051  G4double sum=suB+suM; // Total mass of secondaries
10052  G4QHadron* curHadr = theQHadrons[npiz]; // Pointer to pi0
10053  G4LorentzVector ch4M=curHadr->Get4Momentum(); // 4-Mom of the Pion
10054  G4LorentzVector tt4M=ch4M+reTLV;// (resQMa=GSMass of the ResidQuasmon(+Env.))
10055  G4double ttM=tt4M.m(); // Mass of the Pion+ResidQm compaund system
10056 #ifdef chdebug
10057  G4cout<<"::G4QE::CGS:sum="<<sum<<"<"<<ttM<<tt4M<<",pi0="<<ch4M<<",Q="
10058  <<reTLV.m()<<reTLV<<G4endl;
10059 #endif
10060  if(sum<ttM) // PANIC can be resolved with this Pi0
10061  {
10062  G4LorentzVector fn4M = G4LorentzVector(0.,0.,0.,suB); // Nucleon(s)
10063  G4LorentzVector pi4M = G4LorentzVector(0.,0.,0.,suM); // Pion(s)
10064  if(G4QHadron(tt4M).DecayIn2(fn4M,pi4M))
10065  {
10066  if(npi>1) pi4M/=npi;
10067  curHadr->Set4Momentum(pi4M);// Change 4M of the Pion (reduced by decay)
10068  curHadr->SetQPDG(piQPDG); // Change Charge of thePion
10069  if(npi>1) for(G4int ip=1; ip<npi; ip++)
10070  {
10071  G4QHadron* piH = new G4QHadron(piPD,pi4M);// Pion(s)
10072 #ifdef debug
10073  G4cout<<"G4QE::CGS: fill Pion #"<<ip<<", "<<piPD<<pi4M<<G4endl;
10074 #endif
10075  theQHadrons.push_back(piH); // Fill Pion(s) (delete equivalent)
10076  }
10077  if(resB>1) fn4M/=resB;
10078  for(G4int ib=0; ib<resB; ib++)
10079  {
10080  G4QHadron* fnH = new G4QHadron(nuPD,fn4M);// Nucleon(s)
10081 #ifdef debug
10082  G4cout<<"G4QE::CGS: fill IsoNucleon #"<<ib<<", "<<nuPD<<fn4M<<G4endl;
10083 #endif
10084  theQHadrons.push_back(fnH); // Fill Nucleon(s) (delete equivalent)
10085  }
10086 #ifdef chdebug
10087  G4cout<<"::G4QE::CGS:nucl="<<nuPD<<fn4M<<resB<<",pion="<<pi4M<<npi<<G4endl;
10088 #endif
10089 
10090  return true;
10091  }
10092 #ifdef chdebug
10093  else G4cout<<"*::*G4QEnv::CheckGS:DecayIn3:*Pi0* tM="<<ttM<<","<<sum<<G4endl;
10094 #endif
10095  } // End of the KINEMATIC CHECK FOR THE PI0 if
10096  } // End of npiz Isonucleus IF
10097 #ifdef cdebug
10098  G4cout<<"G4QE::CGS: Photons can't help nP="<<nphot<<". TryChangeCharge."<<G4endl;
10099 #endif
10100  // > Photons did not help, try to find an appropriate partner to join and decay
10101  G4int reTBN=reTQC.GetBaryonNumber(); // Baryon number of theHadronicState
10102  G4int reTCH=reTQC.GetCharge(); // Charge of theHadronicState
10103  G4bool isoN = reTCH-reTBN>0 || reTCH<0; // UnavoidableIsonucleus (Delta cond.)
10104  G4bool norN = reTCH<=reTBN || reTCH>=0; // "Regular nucleus" condition
10105  G4double nnM=resSMa; // Fake prototype of the NormalNucleusMass
10106  G4QContent ipiQC=pipQC; // Prototype of QCont for the Residual Pion+
10107  G4QContent nnQC=reTQC+pimQC; // Prototype of theIsoReduceNucleus(Delta++)
10108  G4int nnPDG=nnQC.GetSPDGCode(); // Prot. PDGCode of the ResidNormalNucleus
10109  if((!nnPDG||nnPDG==10)&&nnQC.GetBaryonNumber()>0) nnPDG=nnQC.GetZNSPDGCode();
10110 #ifdef cdebug
10111  G4cout<<"G4QE::CGS: nnPDR="<<nnPDG<<". TryChangeCharge nOUT="<<nOfOUT<<",Iso="
10112  <<isoN<<",Nor="<<norN<<",C="<<reTCH<<",B="<<reTBN<<G4endl;
10113 #endif
10114  if(isoN) // Calculations for the Isonuclear Residual
10115  {
10116  if(reTCH<0) // "at least one Delta-" isostate (chngPort)
10117  {
10118  ipiQC=pimQC; // Change QCont for the Residual Pion-
10119  nnQC=reTQC+pipQC; // Change QCont for theNormalNucleus(Delta-)
10120  nnPDG=nnQC.GetSPDGCode(); // Change PDGCode of theResidNormalNucleus
10121  if(nnPDG==10&&nnQC.GetBaryonNumber()>0) nnPDG=nnQC.GetZNSPDGCode();
10122  }
10123  G4QPDGCode nnQPDG(nnPDG); // Now can even have Q-code !
10124  if(nnPDG<80000000) nnM=nnQPDG.GetMass(); // Mass for the Fundamental Hadron
10125  else nnM=nnQPDG.GetNuclMass(nnPDG); // Mass for the Nucleus
10126  }
10127  G4bool chx2g=true;
10128  G4bool force=false; // Force-flag to initiate gamma decays (ChEx=>"Pi0"->2gamma)
10129  while(chx2g)
10130  {
10131  if(force) chx2g=false;
10132  for(G4int hd=nOfOUT-1; hd>=0; hd--)// Try to use any hadron to resolve PANIC
10133  {
10134  G4QHadron* curHadr = theQHadrons[hd];
10135  G4int chNF=curHadr->GetNFragments();
10136  G4int chCH=curHadr->GetCharge();
10137  G4int chBN=curHadr->GetBaryonNumber();
10138  //G4int chS=curHadr->GetStrangeness();
10139  G4LorentzVector ch4M=curHadr->Get4Momentum(); // 4Mom of the Current Hadron
10140 #ifdef cdebug
10141  G4cout<<"G4QE::CGS:#"<<hd<<",ch="<<chCH<<",b="<<chBN<<",4M="<<ch4M<<G4endl;
10142 #endif
10143  if(!chNF)
10144  {
10145  G4LorentzVector tt4M=ch4M+reTLV;// resSMa=GSMass of the ResidQuasmon(+Env)
10146  G4double chM=ch4M.m(); // Mass of the CurrentHadron from theOUTPUT
10147  G4double ttM=tt4M.m(); // TotalMass of CurHadr+Residual compaund
10148  if(isoN) // "1 Delta Isonucleus" case
10149  {
10150  if(nnM+mPi+chM<ttM) // PANIC can be resolved with thisCurHadron
10151  {
10152 #ifdef cdebug
10153  G4cout<<"G4QE::CGS:CurH+ResQ+Pion t="<<tt4M<<ttM<<",cM="<<chM<<",rM="
10154  <<nnM<<", d="<<ttM-chM-nnM-mPi<<G4endl;
10155 #endif
10156  ch4M = G4LorentzVector(0.,0.,0.,chM); // Mass of current Hadron
10157  G4LorentzVector quas4M = G4LorentzVector(0.,0.,0.,nnM); // GSMass of RQ
10158  G4LorentzVector ipi4M = G4LorentzVector(0.,0.,0.,mPi);// GSMass of Pion
10159  if(G4QHadron(tt4M).DecayIn3(ch4M,ipi4M,quas4M))
10160  {
10161  curHadr->Set4Momentum(ch4M);// Change 4M of the Current Hadron
10162  G4QHadron* rpH = new G4QHadron(ipiQC,ipi4M);// Prototype of ResidPion
10163 #ifdef debug
10164  G4cout<<"G4QE::CGS: fill Pion "<<ipiQC<<ipi4M<<G4endl;
10165 #endif
10166  theQHadrons.push_back(rpH); // Fill Resid Pion (delete equivalent)
10167  G4QHadron* rqH = new G4QHadron(nnQC,quas4M);// Prototype of OutResidQ
10168 #ifdef debug
10169  G4cout<<"G4QE::CGS:Fill isoRes "<<nnQC<<quas4M<<" inAnyForm"<<G4endl;
10170 #endif
10171 #ifdef cdebug
10172  //if(resQPDG==89998004)
10173  G4cout<<"G4QE::CGS:#"<<hd<<"is h="<<curHadr->GetPDGCode()<<ch4M
10174  <<curHadr->Get4Momentum()<<" + rq="<<nnPDG<<quas4M<<" + pi="
10175  <<ipiQC<<ipi4M<<G4endl;
10176 #endif
10177  EvaporateResidual(rqH, false); // Try to evaporate residual (del.eq.)
10178  if(envPDG!=90000000)theEnvironment=G4QNucleus(G4QContent(0,0,0,0,0,0)
10179  ,G4LorentzVector(0.,0.,0.,0.));
10180  return true;
10181  }
10182 #ifdef cdebug
10183  else G4cout<<"***G4QE::CGS:DecIn3 CurH+ResQ+Pion dM="<<ttM-chM<<G4endl;
10184 #endif
10185  }
10186  if ( (reTCH < 0 && chCH > 0) || (reTCH > reTBN && chCH < chBN) ) //IsoEx?
10187  {
10188  G4QContent chQC=curHadr->GetQC(); // QuarkCont of the CurrentHadron
10189  if(reTCH<0)chQC+=pimQC; // Add the negativPion QC to CurHadr
10190  else chQC+=pipQC; // Add the positivePion QC to CurHadr
10191  G4QPDGCode nnQPDG=G4QPDGCode(nnPDG);// New QPDG of the Residual
10192  nnM=nnQPDG.GetMass(); // New Mass of the Residual
10193  G4QPDGCode chQPDG=G4QPDGCode(chQC.GetSPDGCode());// New QPDG of CurHadr
10194  chM=chQPDG.GetMass(); // New Mass of the CurHadron
10195  if(force && nnPDG==111) nnM=0.; // Decay of Pi0->2 gammas is possible
10196 #ifdef cdebug
10197  G4cout<<"G4QE::CGS:ChargeExchange,cx="<<chx2g<<",rC="<<reTCH<<",rB="
10198  <<reTBN<<",rM="<<nnM<<",hC="<<chCH<<",hB="<<chBN<<",hM="<<chM
10199  <<",rM+hB="<<nnM+chM<<" < "<<ttM<<G4endl;
10200 #endif
10201  if(nnM+chM<ttM)
10202  {
10203  G4LorentzVector quas4M = G4LorentzVector(0.,0.,0.,nnM);//GSMass of RQ
10204  G4LorentzVector gam4M = G4LorentzVector(0.,0.,0.,0.);//4Mom of gamma1
10205  ch4M = G4LorentzVector(0.,0.,0.,chM);//GSMass of ChrgExchanged Hadron
10206  G4QHadron* rqH = new G4QHadron(nnQPDG,quas4M);//ChrgExResidualQuasmon
10207  if(!nnM) // Decay ResidualVirtualQ: Pi0->2 gamma
10208  {
10209  if(!G4QHadron(tt4M).DecayIn3(ch4M,quas4M,gam4M))
10210  {
10211  delete rqH; // Delete tmp "Residual Quasmon Hadron"
10212 #ifdef cdebug
10213  G4cout<<"***G4QE::CGS:DecayIn3 CurH+2Gammas,d="<<ttM-chM<<G4endl;
10214 #endif
10215  }
10216  else
10217  {
10218  if(chCH+reTCH-chQC.GetCharge()-nnQC.GetCharge())
10219  G4cout<<"**G4QE::CGS:ChEx CH+2G i="<<reTCH<<"+h="<<chCH<<", f="
10220  <<nnQC.GetCharge()<<"+o="<<chQC.GetCharge()<<G4endl;
10221  curHadr->Set4Momentum(ch4M);// Change 4M of the Current Hadron
10222  curHadr->SetQPDG(chQPDG); // Change QPDG of the Current Hadron
10223 #ifdef cdebug
10224  G4cout<<"G4QE::CGS:SubstituteH#"<<hd<<"->"<<chQPDG<<ch4M<<G4endl;
10225 #endif
10226  rqH->Set4Momentum(quas4M); // Fill 4M of the GS Residual Quasmon
10227  rqH->SetQPDG(gamQPDG); // Change QPDG of the ResidualQuasmon
10228  theQHadrons.push_back(rqH); // Fill Gamma 1 as QHadron (del. eq.)
10229 #ifdef debug
10230  G4cout<<"G4QE::CGS:Fill (SubRQ) Gamma 1,(22)4M="<<quas4M<<G4endl;
10231 #endif
10232  G4QHadron* gamH = new G4QHadron(gamQPDG, gam4M);
10233  theQHadrons.push_back(gamH);// Fill Gamma 2 as QHadron (del. eq.)
10234 #ifdef debug
10235  G4cout<<"G4QE::CGS:Fill newMadeGamma 2, (22) 4M="<<gam4M<<G4endl;
10236 #endif
10237  if(envPDG!=90000000) theEnvironment=
10238  G4QNucleus(G4QContent(0,0,0,0,0,0),G4LorentzVector(0.,0.,0.,0.));
10239  return true;
10240  }
10241  } // End of "the Normal decay without 2 gammas"
10242  else // Normal decay (without "Pi0"->2 gammas)
10243  {
10244  if(!G4QHadron(tt4M).DecayIn2(ch4M,quas4M))
10245  {
10246  delete rqH; // Delete tmp "Residual Quasmon Hadron"
10247 #ifdef cdebug
10248  G4cout<<"**G4QE::CGS:DecayIn2 CurH+ResQ d="<<ttM-chM-nnM<<G4endl;
10249 #endif
10250  }
10251  else
10252  {
10253  if(chCH+reTCH-chQC.GetCharge()-nnQC.GetCharge())
10254  G4cout<<"**G4QE::CGS:ChEx CH+RQ i="<<reTCH<<"+h="<<chCH<<", f="
10255  <<nnQC.GetCharge()<<"+o="<<chQC.GetCharge()<<G4endl;
10256  curHadr->Set4Momentum(ch4M);// Change 4M of the Current Hadron
10257  curHadr->SetQPDG(chQPDG); // Change QPDG of the Current Hadron
10258  rqH->Set4Momentum(quas4M); // Fill 4M of the GS Residual Quasmon
10259 #ifdef cdebug
10260  G4cout<<"G4QE::CGS:#"<<hd<<",h="<<ch4M<<"+rq="<<quas4M<<G4endl;
10261 #endif
10262 #ifdef debug
10263  G4cout<<"G4QE::CGS:FilFr "<<nnQPDG<<quas4M<<" inAnyForm"<<G4endl;
10264 #endif
10265  EvaporateResidual(rqH, false); // Try to evaporate resQ (del.eq.)
10266  if(envPDG!=90000000) theEnvironment=
10267  G4QNucleus(G4QContent(0,0,0,0,0,0),G4LorentzVector(0.,0.,0.,0.));
10268  return true;
10269  }
10270  } // End of "the Normal decay without 2 gammas"
10271  }
10272  else
10273  {
10274 #ifdef cdebug
10275  G4cout<<"**G4QE::CGS:rM+hB="<<nnM+chM<<">"<<ttM<<",B="<<chBN<<G4endl;
10276 #endif
10277  if(chBN>1)
10278  {
10279  G4QContent tcQC=chQC+nnQC; //QuarkCont for theTotalCompound nucleus
10280  G4QPDGCode tcQPDG(tcQC); // QPDG for the Total Compound
10281  G4double tcM=tcQPDG.GetMass(); // GS Mass of the TotalCompound
10282  G4QHadron* tcH = new G4QHadron(tcQPDG,tt4M);// Hadron=TotalCompound
10283  G4int tcS=tcQC.GetStrangeness(); // Total Strangeness
10284  G4int tcC=tcQC.GetCharge(); // Total Charge
10285  G4int tcBN=tcQC.GetBaryonNumber(); // Total Baryon Number
10286  //Try to decay in DiBaryon or MultyBaryon
10287  if ( tcBN == 2 || (!tcS && !tcC) || tcS == tcBN || tcC == tcBN )
10288  {
10289  if(tcBN==2) theEnvironment.DecayDibaryon(tcH,&theQHadrons); // DB
10290  else theEnvironment.DecayMultyBaryon(tcH,&theQHadrons); // MB
10291  G4QHadron* theLast_value = theQHadrons[theQHadrons.size()-1];
10292  curHadr->Set4Momentum(theLast_value->Get4Momentum());//4-Mom of CurHadr
10293  G4QPDGCode lQP=theLast_value->GetQPDG();
10294  if(lQP.GetPDGCode()!=10) curHadr->SetQPDG(lQP);
10295  else curHadr->SetQC(theLast_value->GetQC());
10296  theQHadrons.pop_back(); // theLastQHadron is excluded from OUTPUT
10297  delete theLast_value;// *!!When kill,delete theLastQHadr asAnInstance!*
10298  }
10299  else if(tcM<ttM)// @@ Can't evaporate here, can only radiate gamma
10300  {
10301  G4LorentzVector tc4M=G4LorentzVector(0.,0.,0.,tcM);//4M of TotCom
10302  G4LorentzVector gc4M=G4LorentzVector(0.,0.,0.,0.); //4M of gamma
10303  if(!G4QHadron(tt4M).DecayIn2(tc4M,gc4M))
10304  {
10305  delete tcH; // Delete tmp TotalCompoundHadron
10306  curHadr->Set4Momentum(tt4M);// Change 4M of the Current Hadron
10307  curHadr->SetQPDG(tcQPDG); // Change QPDG of theCurrentHadron
10308 #ifdef cdebug
10309  G4cout<<"**G4QE::CGS:DecayIn2 TotComp+gam d="<<ttM-tcM<<G4endl;
10310 #endif
10311  }
10312  else
10313  {
10314  curHadr->Set4Momentum(gc4M);//Change 4Mom of the Current Hadron
10315  curHadr->SetQPDG(gamQPDG);//Change PDG of theCurHadron to gamma
10316  tcH->Set4Momentum(tc4M); // Fill 4-Mom of the GS Total Compound
10317 #ifdef cdebug
10318  G4cout<<"G4QE::CGS:#"<<hd<<",ch="<<ch4M<<"+t4M="<<tc4M<<G4endl;
10319 #endif
10320 #ifdef debug
10321  G4cout<<"G4QE::CGS:FilTC "<<tcQPDG<<tc4M<<" inAnyForm"<<G4endl;
10322 #endif
10323  EvaporateResidual(tcH, false);// Try to evaporate hadron (d.e.)
10324  }
10325  }
10326  else // @@ Fill the TotalCompound instead of the CurrentHadron @@
10327  {
10328 #ifdef cdebug
10329  G4cout<<"G4QE::CGS:**CEF,M="<<tcM<<">"<<ttM<<",B="<<chBN<<G4endl;
10330 #endif
10331  delete tcH; // Delete tmp "TotalCompound"
10332  curHadr->Set4Momentum(tt4M); // Change 4Mom of the Current Hadron
10333  curHadr->SetQPDG(tcQPDG); // Change QPDG of the Current Hadron
10334  }
10335  return true;
10336  } // Check that the residual is a nucleus, not just a nucleon
10337  } // Check if pion can still be radiated or must be absorbed
10338  } // Check that the iso-exchange could help
10339  } // End of the IF: KINEMATIC CHECK FOR THE CURRENT HADRON(Isonuclear Case)
10340  else if(norN)
10341  {
10342  if(resSMa+chM<ttM) // PANIC can be resolved with this CurHadron
10343  {
10344  G4LorentzVector quas4M = G4LorentzVector(0.,0.,0.,resSMa);// GSMass ofQ
10345  G4QHadron* rqH = new G4QHadron(reTQC,quas4M);// Prototype OutputResidQ
10346  if(!G4QHadron(tt4M).DecayIn2(ch4M,quas4M))
10347  {
10348  delete rqH; // Delete tmp "Residual Quasmon Hadron"
10349 #ifdef cdebug
10350  G4cout<<"***G4QE::CheckGS:Decay in CurH+ResQ dM="<<ttM-chM<<G4endl;
10351 #endif
10352  }
10353  else
10354  {
10355  curHadr->Set4Momentum(ch4M); // Change 4M of the Current Hadron
10356  rqH->Set4Momentum(quas4M); // Fill 4M of the GS Residual Quasmon
10357 #ifdef cdebug
10358  G4cout<<"G4QEnv::CheckGS:#"<<hd<<",ch4M="<<curHadr->GetPDGCode()
10359  <<ch4M<<" + ResQ4M="<<totPDG<<quas4M<<G4endl;
10360 #endif
10361 #ifdef debug
10362  G4cout<<"G4QE::CGS:Fill GSRes "<<reTQC<<quas4M<<" inAnyForm"<<G4endl;
10363 #endif
10364  EvaporateResidual(rqH, false); // Try to evaporate residHadron (d.e.)
10365  if(envPDG!=90000000)theEnvironment=G4QNucleus(G4QContent(0,0,0,0,0,0)
10366  ,G4LorentzVector(0.,0.,0.,0.));
10367  return true;
10368  }
10369  } // End of the KINEMATIC CHECK FOR THE CURRENT HADRON if (NormNuclCase)
10370  } // End of IsoNucleus/NormalNucleus choice
10371  } // End of the NumberOfFragments=0 (NOT DECAYED PARTICLE) if
10372  } // End of the LOOP over hadrons and all attempts to resolve PANIC
10373 #ifdef cdebug
10374  G4cout<<"G4QEnv::CheckGS:***Any hadron from the OUTPUT did not help"<<G4endl;
10375 #endif
10376  force=true;
10377  } // End of while for chx2g
10378  if(resB>1)
10379  {
10380  G4int hind=-1;
10381  if(npiz>-1) hind=npiz;
10382  else
10383  {
10384  if(resC+resC>resB && npim>-1) hind=npim;
10385  else hind=npip;
10386  }
10387  if(hind>-1)
10388  {
10389  G4QHadron* curHadr = theQHadrons[hind];
10390  G4int chNF=curHadr->GetNFragments();
10391  if(!chNF)
10392  {
10393  G4LorentzVector ch4M=curHadr->Get4Momentum(); // 4Mom of the Current Hadron
10394  G4LorentzVector tt4M=ch4M+reTLV; // resSMa=GSMass of the ResidQuasmon(+Env)
10395  G4double ttM=tt4M.m(); // TotalMass of CurHadr+Residual compaund
10396  G4QContent ttQC=valQ+curHadr->GetQC(); // total Quark Content
10397  G4int ttPDG=ttQC.GetZNSPDGCode();
10398  G4QPDGCode ttQPDG(ttPDG);
10399  G4double ttGSM=ttQPDG.GetMass();
10400  if(ttM>ttGSM && ttQC.GetStrangeness()>0)//Hypernucleus can be L->N degraded
10401  {
10402  ttPDG-=ttQC.GetStrangeness()*999999; // S Neutrons instead of S Lambdas
10403  ttQPDG=G4QPDGCode(ttPDG); // Update QPDGcode defining fragment
10404  ttGSM=ttQPDG.GetMass(); // Update the degraded mass value
10405 #ifdef debug
10406  G4cout<<"G4QEnv::CheckGS:Hypernucleus degraded to QPDG="<<ttQPDG<<G4endl;
10407 #endif
10408  }
10409  if(ttM>ttGSM) // Decay of Pi0 in 2 gammas with the residual nucleus
10410  {
10411 #ifdef cdebug
10412  G4cout<<"G4QEnv::CheckGS: Decay in ResQ="<<ttQPDG<<" & 2 gammas"<<G4endl;
10413 #endif
10414  G4LorentzVector quas4M = G4LorentzVector(0.,0.,0.,ttGSM); // GSMass of RQ
10415  G4LorentzVector fgam4M = G4LorentzVector(0.,0.,0.,0.); // 4Mom of gamma 1
10416  G4LorentzVector sgam4M = G4LorentzVector(0.,0.,0.,0.); // 4Mom of gamma 2
10417  if(!G4QHadron(tt4M).DecayIn3(quas4M,fgam4M,sgam4M))G4cout<<"*3*"<<G4endl;
10418  else
10419  {
10420  curHadr->Set4Momentum(fgam4M); // Change 4M of the Pion to Gamma
10421  curHadr->SetQPDG(gamQPDG); // Change QPDG of the Pion to Gamma
10422  G4QHadron* sgH = new G4QHadron(gamQPDG,sgam4M); // Gamma 2
10423  theQHadrons.push_back(sgH); // Fill Gamma 2 as QHadron (del. eq.)
10424  G4QHadron* rqH = new G4QHadron(ttQPDG,quas4M); // GSResidualQuasmon
10425  theQHadrons.push_back(rqH); // Fill GSResidQuasmon as QHadron (del.eq.)
10426  return true;
10427  }
10428  }
10429 #ifdef debug
10430  else G4cout<<"-W-G4QEn::CheckGS:M="<<ttM<<" < GSM="<<ttGSM<<ttQPDG<<G4endl;
10431 #endif
10432  }
10433  }
10434  }
10435  return false;
10436  } // End of the KINEMATIC LIMIT FOR THE L&P CORRECTION if/else (try any hadron)
10437  } // End of the POSSIBILITY OF PREV+LAST (OR MORE) CORRECTION if
10438  else return false;
10439  } // End of the CORRECTION WITH THE LAST if/else
10440  } // End of the CORRECTION IS POSSIBLE if
10441  else return false; // Correction can not be done
10442  return true; // If correction was done successfully
10443 } // End of "CheckGroundState"
10444 
10445 // Try to decay the Total Residual Nucleus in Environ+Quasmon
10446 void G4QEnvironment::CopyAndDeleteHadronVector(G4QHadronVector* HV)
10447 {
10448  G4int nHadrons = HV->size();
10449  if(nHadrons)
10450  {
10451  for(G4int ih=0; ih<nHadrons; ++ih) // LOOP over output QHadrons
10452  {
10453  //G4QHadron* inH = HV->operator[](ih); // Pointer to the i-th QHadron
10454  G4QHadron* inH = (*HV)[ih]; // Pointer to the i-th QHadron
10455  G4int hNF = inH->GetNFragments(); // A#of secondary fragments
10456  if(!hNF) // Fill only final hadrons
10457  {
10458 #ifdef debug
10459  G4cout<<"G4QEnv::Copy&DeleteHV:#"<<ih<<", hPDG="<<inH->GetPDGCode()<<G4endl;
10460 #endif
10461  G4QHadron* curH = new G4QHadron(inH); // will be deleted with allQHadronVector
10462  theQHadrons.push_back(curH); // Fill hadron-copy (delete equivalent)
10463  }
10464  }
10465  for_each(HV->begin(), HV->end(), DeleteQHadron()); // Delete instances
10466  HV->clear(); // Delete pointers
10467  }
10468 #ifdef debug
10469  else G4cout<<"***G4QEnv::Kopy&DelHV: No hadrons in the QHadronVector"<<G4endl;
10470 #endif
10471  delete HV; // Delete the inputQHadronVector
10472 } // End of "CopyAndDeleteHadronVector"
10473 
10474 // Try to decay the Total Residual Nucleus in Environ+Quasmon
10475 G4bool G4QEnvironment::DecayInEnvQ(G4Quasmon* quasm)
10476 {
10477  G4QContent valQ=quasm->GetQC(); // Quark content of the Quasmon
10478  G4int resQPDG=valQ.GetSPDGCode(); // Reachable in a member function
10479  if(resQPDG==10&&valQ.GetBaryonNumber()>0) resQPDG=valQ.GetZNSPDGCode();
10480  G4double resQMa=G4QPDGCode(resQPDG).GetMass(); // GS Mass of the Residual Quasmon
10481  G4LorentzVector enva4M=G4LorentzVector(0.,0.,0.,0.);
10482  G4LorentzVector reTLV=quasm->Get4Momentum(); // Prototyoe of the 4-Mom of the ResidNuc
10483  G4double resSMa=resQMa; // Prototype of MinSplitMass of ResidNucl
10484  G4int envPDG=theEnvironment.GetPDG(); // PDG Code of the Environment
10485  if(envPDG!=90000000) // => "Environment is not vacuum" case
10486  {
10487  G4double resEMa=theEnvironment.GetMZNS(); // GSMass of the Residual Environment
10488  enva4M=G4LorentzVector(0.,0.,0.,resEMa); // 4-Mom of the Residual Environment
10489  reTLV+=enva4M; // 4-Mom of Residual Nucleus
10490  resSMa+=resEMa; // Minimal Split Mass of Residual Nucleus
10491  G4double resTMa=reTLV.m(); // CM Mass of theResidNucleus (Quasm+Env)
10492  //#ifdef debug
10493  G4cout<<"G4QEnv::DecayInEnvQ: totM="<<reTLV<<resTMa<<" > rQM+rEM="<<resSMa<<G4endl;
10494  //#endif
10495  if(resTMa>resSMa)
10496  {
10497  G4LorentzVector quas4M = G4LorentzVector(0.,0.,0.,resQMa); // GS Mass of Quasmon
10498  G4QHadron* quasH = new G4QHadron(valQ, quas4M);
10499  G4QHadron* envaH = new G4QHadron(envPDG, enva4M);
10500  if(!G4QHadron(reTLV).DecayIn2(enva4M,quas4M))
10501  {
10502  delete quasH; // Delete "Quasmon Hadron"
10503  delete envaH; // Delete "Environment Hadron"
10504  G4cout<<"---Warning---G4Q::DecInEnvQ:Decay in Environment+ResidualQuasmon"<<G4endl;
10505  return false;
10506  }
10507  else
10508  {
10509  quasH->Set4Momentum(quas4M);
10510  EvaporateResidual(quasH); // Try to evaporate quasmon (del. equiv.)
10511  envaH->Set4Momentum(enva4M);
10512  EvaporateResidual(envaH); // Try to evaporate residual (del. equiv.)
10513  }
10514  }
10515  else return false;
10516  }
10517  else return false; // => "Environment is vacuum" case
10518  return true;
10519 } // End of "DecayInEnvQ"
10520 
10521 // Add a Quasmon to the Environment
10523 {
10524  theQuasmons.push_back(Q);
10525  totCharge+=Q->GetCharge();
10526  totBaryoN+=Q->GetBaryonNumber();
10527  tot4Mom +=Q->Get4Momentum();
10528 #ifdef debug
10529  G4cout<<"G4QEnv::AddQuasmon:t4M="<<tot4Mom<<",tC="<<totCharge<<",tB="<<totBaryoN<<G4endl;
10530 #endif
10531 }
10532 
10533 // Put all hadrons in the vector to the mass shell
10535 {
10536  static const G4double eps=.003;
10537  G4int nHadrons = HV->size();
10538  if(nHadrons)
10539  {
10540  for(G4int ih=0; ih<nHadrons; ++ih) // LOOP over output QHadrons
10541  {
10542  G4QHadron* inH = (*HV)[ih]; // Pointer to the i-th QHadron
10543  G4int hNF = inH->GetNFragments(); // A#of secondary fragments
10544  if(!hNF) // Fill only final hadrons
10545  {
10546  G4LorentzVector q4M = inH->Get4Momentum(); // Get 4-momentum of the Hadron
10547  G4double qM2 = q4M.m2(); // Squared Mass of the Hadron
10548  G4double qGM = inH->GetQPDG().GetMass(); // Get Ground State Mass
10549  G4double qGM2= qGM*qGM; // Squared Ground State Mass
10550 #ifdef debug
10551  G4cout << "G4QEnv::ChkMassShell:#" << ih <<", hPDG="<< inH->GetPDGCode() <<", dM2="
10552  << qM2 - qGM*qGM << G4endl;
10553 #endif
10554  if( fabs(qM2 - qGM*qGM) > eps) // Correct the mass shell
10555  {
10556  G4double mins= 10000000000.; // Minimum excitation found
10557  G4int nj = -1; // Minimum j-index
10558  for(G4int jh=0; jh<nHadrons; ++jh) // LOOP over output QHadrons
10559  {
10560  if(jh != ih)
10561  {
10562  G4QHadron* jnH = (*HV)[jh]; // Pointer to the j-th QHadron
10563  hNF = inH->GetNFragments(); // A#of secondary fragments
10564  if(!hNF) // Fill only final hadrons
10565  {
10566  G4LorentzVector j4M = jnH->Get4Momentum(); // Get 4-mom of the Hadron
10567  G4double jGM = jnH->GetQPDG().GetMass(); // Get Ground State Mass
10568  G4double jGM2= jGM*jGM; // Doubled GS Mass
10569  G4LorentzVector s4M = j4M+q4M; // Compound 4-mom
10570  G4double jqM = qGM * jGM; // Worling var.
10571  G4double s2M = s4M.m2()-qGM2-jGM2-jqM-jqM;// Closeness parameter
10572  if(s2M > eps && s2M < mins)
10573  {
10574  mins = s2M;
10575  nj = jh;
10576  }
10577  }
10578  }
10579  } // End of the searching LOOP for the rest of hadrons
10580  //if(nj<0) G4cout<<"-W-G4QE::ChkMShell:NotCorr,M2="<<qM2<<",GSM2="<<qGM2<<G4endl;
10581  //else // It's possible to correct
10582  if(nj >= 0) // It's possible to correct
10583  {
10584  G4QHadron* jnH = (*HV)[nj]; // Pointer to j-th QHadron
10585  G4LorentzVector j4M = jnH->Get4Momentum(); // Get 4-mom of the Hadron
10586  G4double jGM = jnH->GetQPDG().GetMass(); // Get Ground State Mass
10587  G4LorentzVector c4M = q4M + j4M; // Get 4-mom of Compound
10588  G4LorentzVector i4Mom(0.,0.,0.,qGM);
10589  G4LorentzVector j4Mom(0.,0.,0.,jGM);
10590  /*
10591  // DHW 16 June 2011: variable set but not used. Comment out to fix compiler
10592  // warning.
10593  G4bool done = true;
10594  */
10595  if(!G4QHadron(c4M).DecayIn2(i4Mom, j4Mom))
10596  {
10597  G4cout<<"-Warning-G4QEnv::ChkMShell: tM="<< c4M.m() <<", iM="<< qGM <<", jM="
10598  << jGM <<", d="<< c4M.m()-qGM-jGM << G4endl;
10599  /*
10600  // DHW 16 June 2011: set but not used.
10601  done = false;
10602  */
10603  }
10604  else
10605  {
10606  inH->Set4Momentum(i4Mom);
10607  jnH->Set4Momentum(j4Mom);
10608  }
10609  }
10610  }
10611  }
10612  }
10613  }
10614 }