Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4HadronBuilder.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 //
27 // $Id: G4HadronBuilder.cc 100828 2016-11-02 15:25:59Z gcosmo $
28 //
29 // -----------------------------------------------------------------------------
30 // GEANT 4 class implementation file
31 //
32 // History:
33 // Gunter Folger, August/September 2001
34 // Create class; algorithm previously in G4VLongitudinalStringDecay.
35 // -----------------------------------------------------------------------------
36 
37 #include "G4HadronBuilder.hh"
38 #include "G4SystemOfUnits.hh"
39 #include "Randomize.hh"
40 #include "G4HadronicException.hh"
41 #include "G4ParticleTable.hh"
42 
44  std::vector<double> scalarMesonMix,
45  std::vector<double> vectorMesonMix)
46 {
47  mesonSpinMix=mesonMix;
48  barionSpinMix=barionMix;
49  scalarMesonMixings=scalarMesonMix;
50  vectorMesonMixings=vectorMesonMix;
51 }
52 
54 {
55 
56  if (black->GetParticleSubType()== "di_quark" || white->GetParticleSubType()== "di_quark" ) {
57 
58  // Baryon
59  Spin spin = (G4UniformRand() < barionSpinMix) ? SpinHalf : SpinThreeHalf;
60  return Barion(black,white,spin);
61 
62  } else {
63 
64  // Meson
65  Spin spin = (G4UniformRand() < mesonSpinMix) ? SpinZero : SpinOne;
66  return Meson(black,white,spin);
67 
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 Baryon 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 
96 G4ParticleDefinition * G4HadronBuilder::Meson(G4ParticleDefinition * black,
97  G4ParticleDefinition * white, Spin theSpin)
98 {
99  #ifdef G4VERBOSE
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  //G4int ifl1= std::max(std::abs(id1), std::abs(id2));
117  if ( std::abs(id1) < std::abs(id2) )
118  {
119  G4int xchg = id1;
120  id1 = id2;
121  id2 = xchg;
122  }
123 
124  if (std::abs(id1) > 3 )
125  throw G4HadronicException(__FILE__, __LINE__, "G4HadronBuilder::Meson : Illegal Quark content as input");
126 
127  G4int PDGEncoding=0;
128 
129  if (id1 + id2 == 0) {
130  G4double rmix = G4UniformRand();
131  G4int imix = 2*std::abs(id1) - 1;
132  if(theSpin == SpinZero) {
133  PDGEncoding = 110*(1 + (G4int)(rmix + scalarMesonMixings[imix - 1])
134  + (G4int)(rmix + scalarMesonMixings[imix])
135  ) + theSpin;
136  } else {
137  PDGEncoding = 110*(1 + (G4int)(rmix + vectorMesonMixings[imix - 1])
138  + (G4int)(rmix + vectorMesonMixings[imix])
139  ) + theSpin;
140  }
141  } else {
142  PDGEncoding = 100 * std::abs(id1) + 10 * std::abs(id2) + theSpin;
143  G4bool IsUp = (std::abs(id1)&1) == 0; // quark 1 up type quark (u or c)
144  G4bool IsAnti = id1 < 0; // quark 1 is antiquark?
145  if( (IsUp && IsAnti ) || (!IsUp && !IsAnti ) )
146  PDGEncoding = - PDGEncoding;
147  }
148 
149  G4ParticleDefinition * MesonDef=
151 
152  #ifdef G4VERBOSE
153  if (MesonDef == 0 ) {
154  G4cerr << " G4HadronBuilder - Warning: No particle for PDGcode= "
155  << PDGEncoding << G4endl;
156  } else if ( ( black->GetPDGCharge() + white->GetPDGCharge()
157  - MesonDef->GetPDGCharge() ) > perCent ) {
158  G4cerr << " G4HadronBuilder - Warning: Incorrect Charge : "
159  << " Quark1/2 = "
160  << black->GetParticleName() << " / "
161  << white->GetParticleName()
162  << " resulting Hadron " << MesonDef->GetParticleName()
163  << G4endl;
164  }
165  #endif
166 
167  return MesonDef;
168 }
169 
170 
171 G4ParticleDefinition * G4HadronBuilder::Barion(G4ParticleDefinition * black,
172  G4ParticleDefinition * white,Spin theSpin)
173 {
174 
175  #ifdef G4VERBOSE
176  // Verify Input Charge
177  G4double charge = black->GetPDGCharge() + white->GetPDGCharge();
178  if (std::abs(charge) > 2 || std::abs(3.*charge - 3*G4int(charge*1.001)) > perCent )
179  {
180  G4cerr << " G4HadronBuilder::Build()" << G4endl;
181  G4cerr << " Invalid total charge found for on input: " << charge<< G4endl;
182  G4cerr << " PGDcode input quark1/quark2 : " <<
183  black->GetPDGEncoding() << " / "<<
184  white->GetPDGEncoding() << G4endl;
185  G4cerr << G4endl;
186  }
187  #endif
188 
189  G4int id1= black->GetPDGEncoding();
190  G4int id2= white->GetPDGEncoding();
191  if ( std::abs(id1) < std::abs(id2) )
192  {
193  G4int xchg = id1;
194  id1 = id2;
195  id2 = xchg;
196  }
197 
198  if (std::abs(id1) < 1000 || std::abs(id2) > 3 )
199  throw G4HadronicException(__FILE__, __LINE__, "G4HadronBuilder::Barion: Illegal quark content as input");
200 
201  G4int ifl1= std::abs(id1)/1000;
202  G4int ifl2 = (std::abs(id1) - ifl1 * 1000)/100;
203  G4int diquarkSpin = std::abs(id1)%10;
204  G4int ifl3 = id2;
205  if (id1 < 0)
206  {
207  ifl1 = - ifl1;
208  ifl2 = - ifl2;
209  }
210  //... Construct barion, distinguish Lambda and Sigma barions.
211  G4int kfla = std::abs(ifl1);
212  G4int kflb = std::abs(ifl2);
213  G4int kflc = std::abs(ifl3);
214 
215  G4int kfld = std::max(kfla,kflb);
216  kfld = std::max(kfld,kflc);
217  G4int kflf = std::min(kfla,kflb);
218  kflf = std::min(kflf,kflc);
219 
220  G4int kfle = kfla + kflb + kflc - kfld - kflf;
221 
222  //... barion with content uuu or ddd or sss has always spin = 3/2
223  theSpin = (kfla == kflb && kflb == kflc)? SpinThreeHalf : theSpin;
224 
225  G4int kfll = 0;
226  if(theSpin == SpinHalf && kfld > kfle && kfle > kflf) {
227  // Spin J=1/2 and all three quarks different
228  // Two states exist: (uds -> lambda or sigma0)
229  // - lambda: s(ud)0 s : 3122; ie. reverse the two lighter quarks
230  // - sigma0: s(ud)1 s : 3212
231  if(diquarkSpin == 1 ) {
232  if ( kfla == kfld) { // heaviest quark in diquark
233  kfll = 1;
234  } else {
235  kfll = (G4int)(0.25 + G4UniformRand());
236  }
237  }
238  if(diquarkSpin == 3 && kfla != kfld)
239  kfll = (G4int)(0.75 + G4UniformRand());
240  }
241 
242  G4int PDGEncoding;
243  if (kfll == 1) PDGEncoding = 1000 * kfld + 100 * kflf + 10 * kfle + theSpin;
244  else PDGEncoding = 1000 * kfld + 100 * kfle + 10 * kflf + theSpin;
245 
246  if (id1 < 0) PDGEncoding = -PDGEncoding;
247 
248  G4ParticleDefinition * BarionDef=
250 
251  #ifdef G4VERBOSE
252  if (BarionDef == 0 ) {
253  G4cerr << " G4HadronBuilder - Warning: No particle for PDGcode= "
254  << PDGEncoding << G4endl;
255  } else if ( ( black->GetPDGCharge() + white->GetPDGCharge()
256  - BarionDef->GetPDGCharge() ) > perCent ) {
257  G4cerr << " G4HadronBuilder - Warning: Incorrect Charge : "
258  << " DiQuark/Quark = "
259  << black->GetParticleName() << " / "
260  << white->GetParticleName()
261  << " resulting Hadron " << BarionDef->GetParticleName()
262  << G4endl;
263  }
264  #endif
265 
266  return BarionDef;
267 }
268 
G4ParticleDefinition * BuildHighSpin(G4ParticleDefinition *black, G4ParticleDefinition *white)
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4ParticleDefinition * BuildLowSpin(G4ParticleDefinition *black, G4ParticleDefinition *white)
G4HadronBuilder(G4double mesonMix, G4double barionMix, std::vector< double > scalarMesonMix, std::vector< double > vectorMesonMix)
static constexpr double perCent
Definition: G4SIunits.hh:332
G4ParticleDefinition * Build(G4ParticleDefinition *black, G4ParticleDefinition *white)
const G4String & GetParticleSubType() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
#define G4UniformRand()
Definition: Randomize.hh:97
bool G4bool
Definition: G4Types.hh:79
static G4ParticleTable * GetParticleTable()
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double GetPDGCharge() const
G4GLOB_DLL std::ostream G4cerr