ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4HadronBuilder.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4HadronBuilder.cc
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 //
27 //
28 // -----------------------------------------------------------------------------
29 // GEANT 4 class implementation file
30 //
31 // History:
32 // Gunter Folger, August/September 2001
33 // Create class; algorithm previously in G4VLongitudinalStringDecay.
34 // -----------------------------------------------------------------------------
35 
36 #include "G4HadronBuilder.hh"
37 #include "G4SystemOfUnits.hh"
38 #include "Randomize.hh"
39 #include "G4HadronicException.hh"
40 #include "G4ParticleTable.hh"
41 
42 //#define debug_Hbuilder
43 
45  std::vector<double> scalarMesonMix,
46  std::vector<double> vectorMesonMix,
47  G4double Eta_cProb, G4double Eta_bProb)
48 {
49  mesonSpinMix = mesonMix;
50  barionSpinMix = barionMix;
51  scalarMesonMixings = scalarMesonMix;
52  vectorMesonMixings = vectorMesonMix;
53 
54  ProbEta_c = Eta_cProb;
55  ProbEta_b = Eta_bProb;
56 }
57 
59 {
60  if (black->GetParticleSubType()== "di_quark" || white->GetParticleSubType()== "di_quark" ) {
61  // Barion
63  return Barion(black,white,spin);
64  } else {
65  // Meson
67  return Meson(black,white,spin);
68  }
69 }
70 
71 //-------------------------------------------------------------------------
72 
74 {
75  if ( black->GetParticleSubType()== "quark" && white->GetParticleSubType()== "quark" ) {
76  return Meson(black,white, SpinZero);
77  } else {
78  // will return a SpinThreeHalf Barion if all quarks the same
79  return Barion(black,white, SpinHalf);
80  }
81 }
82 
83 //-------------------------------------------------------------------------
84 
86 {
87  if ( black->GetParticleSubType()== "quark" && white->GetParticleSubType()== "quark" ) {
88  return Meson(black,white, SpinOne);
89  } else {
90  return Barion(black,white,SpinThreeHalf);
91  }
92 }
93 
94 //-------------------------------------------------------------------------
95 
97  G4ParticleDefinition * white, Spin theSpin)
98 {
99  #ifdef debug_Hbuilder
100  // Verify Input Charge
101  G4double charge = black->GetPDGCharge() + white->GetPDGCharge();
102  if (std::abs(charge) > 2 || std::abs(3.*charge - 3*G4int(charge*1.001)) > perCent ) // 1.001 to avoid int(.9999) -> 0
103  {
104  G4cerr << " G4HadronBuilder::Build()" << G4endl;
105  G4cerr << " Invalid total charge found for on input: "
106  << charge<< G4endl;
107  G4cerr << " PGDcode input quark1/quark2 : " <<
108  black->GetPDGEncoding() << " / "<<
109  white->GetPDGEncoding() << G4endl;
110  G4cerr << G4endl;
111  }
112  #endif
113 
114  G4int id1 = black->GetPDGEncoding();
115  G4int id2 = white->GetPDGEncoding();
116 
117  // G4int ifl1= std::max(std::abs(id1), std::abs(id2));
118  if ( std::abs(id1) < std::abs(id2) )
119  {
120  G4int xchg = id1;
121  id1 = id2;
122  id2 = xchg;
123  }
124 
125  G4int abs_id1 = std::abs(id1);
126 
127  if ( abs_id1 > 5 )
128  throw G4HadronicException(__FILE__, __LINE__, "G4HadronBuilder::Meson : Illegal Quark content as input");
129 
130  G4int PDGEncoding=0;
131 
132  if (id1 + id2 == 0) {
133  if ( abs_id1 < 4) { // light quarks: u, d or s
134  G4double rmix = G4UniformRand();
135  G4int imix = 2*std::abs(id1) - 1;
136  if (theSpin == SpinZero) {
137  PDGEncoding = 110*(1 + (G4int)(rmix + scalarMesonMixings[imix - 1])
138  + (G4int)(rmix + scalarMesonMixings[imix])
139  ) + theSpin;
140  } else {
141  PDGEncoding = 110*(1 + (G4int)(rmix + vectorMesonMixings[imix - 1])
142  + (G4int)(rmix + vectorMesonMixings[imix])
143  ) + theSpin;
144  }
145  } else { // for c and b quarks
146 
147  PDGEncoding = abs_id1*100 + abs_id1*10;
148 
149  if (PDGEncoding == 440) {
150  if ( G4UniformRand() < ProbEta_c ) {
151  PDGEncoding +=1;
152  } else {
153  PDGEncoding +=3;
154  }
155  }
156  if (PDGEncoding == 550) {
157  if ( G4UniformRand() < ProbEta_b ) {
158  PDGEncoding +=1;
159  } else {
160  PDGEncoding +=3;
161  }
162  }
163  }
164  } else {
165  PDGEncoding = 100 * std::abs(id1) + 10 * std::abs(id2) + theSpin;
166  G4bool IsUp = (std::abs(id1)&1) == 0; // quark 1 up type quark (u or c)
167  G4bool IsAnti = id1 < 0; // quark 1 is antiquark?
168  if ( (IsUp && IsAnti ) || (!IsUp && !IsAnti ) ) PDGEncoding = - PDGEncoding;
169  }
170 
171  G4ParticleDefinition * MesonDef=
173 
174  #ifdef debug_Hbuilder
175  if (MesonDef == 0 ) {
176  G4cerr << " G4HadronBuilder - Warning: No particle for PDGcode= "
177  << PDGEncoding << G4endl;
178 
179  } else if ( ( black->GetPDGCharge() + white->GetPDGCharge()
180  - MesonDef->GetPDGCharge() ) > perCent ) {
181  G4cerr << " G4HadronBuilder - Warning: Incorrect Charge : "
182  << " Quark1/2 = "
183  << black->GetParticleName() << " / "
184  << white->GetParticleName()
185  << " resulting Hadron " << MesonDef->GetParticleName()
186  << G4endl;
187  }
188  #endif
189 
190  return MesonDef;
191 }
192 
193 
195  G4ParticleDefinition * white,Spin theSpin)
196 {
197  #ifdef debug_Hbuilder
198  // Verify Input Charge
199  G4double charge = black->GetPDGCharge() + white->GetPDGCharge();
200  if (std::abs(charge) > 2 || std::abs(3.*charge - 3*G4int(charge*1.001)) > perCent )
201  {
202  G4cerr << " G4HadronBuilder::Build()" << G4endl;
203  G4cerr << " Invalid total charge found for on input: "
204  << charge<< G4endl;
205  G4cerr << " PGDcode input quark1/quark2 : " <<
206  black->GetPDGEncoding() << " / "<<
207  white->GetPDGEncoding() << G4endl;
208  G4cerr << G4endl;
209  }
210  #endif
211 
212  G4int id1 = black->GetPDGEncoding();
213  G4int id2 = white->GetPDGEncoding();
214 
215  if ( std::abs(id1) < std::abs(id2) )
216  {
217  G4int xchg = id1;
218  id1 = id2;
219  id2 = xchg;
220  }
221 
222  if (std::abs(id1) < 1000 || std::abs(id2) > 5 )
223  throw G4HadronicException(__FILE__, __LINE__, "G4HadronBuilder::Barion: Illegal quark content as input");
224 
225  G4int ifl1= std::abs(id1)/1000;
226  G4int ifl2 = (std::abs(id1) - ifl1 * 1000)/100;
227  G4int diquarkSpin = std::abs(id1)%10;
228  G4int ifl3 = id2;
229  if (id1 < 0)
230  {
231  ifl1 = - ifl1;
232  ifl2 = - ifl2;
233  }
234  //... Construct barion, distinguish Lambda and Sigma barions.
235  G4int kfla = std::abs(ifl1);
236  G4int kflb = std::abs(ifl2);
237  G4int kflc = std::abs(ifl3);
238 
239  G4int kfld = std::max(kfla,kflb);
240  kfld = std::max(kfld,kflc);
241  G4int kflf = std::min(kfla,kflb);
242  kflf = std::min(kflf,kflc);
243 
244  G4int kfle = kfla + kflb + kflc - kfld - kflf;
245 
246  //... barion with content uuu or ddd or sss has always spin = 3/2
247  theSpin = (kfla == kflb && kflb == kflc)? SpinThreeHalf : theSpin;
248 
249  G4int kfll = 0;
250  if (kfld < 4) {
251  if (theSpin == SpinHalf && kfld > kfle && kfle > kflf) {
252  // Spin J=1/2 and all three quarks different
253  // Two states exist: (uds -> lambda or sigma0)
254  // - lambda: s(ud)0 s : 3122; ie. reverse the two lighter quarks
255  // - sigma0: s(ud)1 s : 3212
256  if (diquarkSpin == 1 ) {
257  if ( kfla == kfld) { // heaviest quark in diquark
258  kfll = 1;
259  } else {
260  kfll = (G4int)(0.25 + G4UniformRand());
261  }
262  }
263  if (diquarkSpin == 3 && kfla != kfld)
264  kfll = (G4int)(0.75 + G4UniformRand());
265  }
266  }
267 
268  G4int PDGEncoding;
269  if (kfll == 1)
270  PDGEncoding = 1000 * kfld + 100 * kflf + 10 * kfle + theSpin;
271  else
272  PDGEncoding = 1000 * kfld + 100 * kfle + 10 * kflf + theSpin;
273 
274  if (id1 < 0)
275  PDGEncoding = -PDGEncoding;
276 
277  G4ParticleDefinition * BarionDef=
279 
280  #ifdef debug_Hbuilder
281  if (BarionDef == 0 ) {
282  G4cerr << " G4HadronBuilder - Warning: No particle for PDGcode= "
283  << PDGEncoding << G4endl;
284  } else if ( ( black->GetPDGCharge() + white->GetPDGCharge()
285  - BarionDef->GetPDGCharge() ) > perCent ) {
286  G4cerr << " G4HadronBuilder - Warning: Incorrect Charge : "
287  << " DiQuark/Quark = "
288  << black->GetParticleName() << " / "
289  << white->GetParticleName()
290  << " resulting Hadron " << BarionDef->GetParticleName()
291  << G4endl;
292  }
293  #endif
294 
295  return BarionDef;
296 }
297