Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4HEVector.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$
28 //
29 //
30 
31 //
32 // G4 Gheisha friend class G4GHEVector
33 // J.L. Chuma, TRIUMF, 22-Feb-1996
34 // last modified: H. Fesefeldt 02-July--1998
35 // Fesefeldt, bug fixed in Defs1, 14 August 2000
36 
37 #include "G4HEVector.hh"
38 #include "globals.hh"
39 #include "G4ios.hh"
40 #include "G4PhysicalConstants.hh"
41 #include "G4SystemOfUnits.hh"
42 #include "G4ParticleDefinition.hh"
43 
45  {
46  G4ThreeVector aMom = 1./GeV*aParticle->Get4Momentum().vect();
47  px = aMom.x();
48  py = aMom.y();
49  pz = aMom.z();
50  energy = aParticle->GetTotalEnergy()/GeV;
51  kineticEnergy = aParticle->GetKineticEnergy()/GeV;
52  mass = aParticle->GetDefinition()->GetPDGMass()/GeV;
53  charge = aParticle->GetDefinition()->GetPDGCharge()/eplus;
54  timeOfFlight = 0.0;
55  side = 0;
56  flag = false;
57  code = aParticle->GetDefinition()->GetPDGEncoding();
58  baryon = aParticle->GetDefinition()->GetBaryonNumber();
60  particleType = aParticle->GetDefinition()->GetParticleType();
61  strangeness = aParticle->GetDefinition()->GetQuarkContent(3);
62  }
63 
65  {
66  G4double c = a;
67  if(b > a) c = b;
68  return c;
69  }
70 
72  {
73  G4String name;
74  if(aCode == 211) name = "PionPlus";
75  else if(aCode == 111) name = "PionZero";
76  else if(aCode == -211) name = "PionMinus";
77  else if(aCode == 321) name = "KaonPlus";
78  else if(aCode == 311) name = "KaonZero";
79  else if(aCode == -311) name = "AntiKaonZero";
80  else if(aCode == -321) name = "KaonMinus";
81  else if(aCode == 310) name = "KaonZeroShort";
82  else if(aCode == 130) name = "KaonZeroLong";
83  else if(aCode == 2212) name = "Proton";
84  else if(aCode == -2212) name = "AntiProton";
85  else if(aCode == 2112) name = "Neutron";
86  else if(aCode == -2112) name = "AntiNeutron";
87  else if(aCode == 3122) name = "Lambda";
88  else if(aCode == -3122) name = "AntiLambda";
89  else if(aCode == 3222) name = "SigmaPlus";
90  else if(aCode == 3212) name = "SigmaZero";
91  else if(aCode == 3112) name = "SigmaMinus";
92  else if(aCode == -3222) name = "AntiSigmaPlus";
93  else if(aCode == -3212) name = "AntiSigmaZero";
94  else if(aCode == -3112) name = "AntiSigmaMinus";
95  else if(aCode == 3322) name = "XiZero";
96  else if(aCode == 3312) name = "XiMinus";
97  else if(aCode == -3322) name = "AntiXiZero";
98  else if(aCode == -3312) name = "AntiXiMinus";
99  else if(aCode == 3334) name = "OmegaMinus";
100  else if(aCode == -3334) name = "AntiOmegaMinus";
101  else if(aCode == 0)
102  {
103  if(aBaryon==2) name = "Deuteron";
104  else if(aBaryon==3) name = "Triton";
105  else if(aBaryon==4) name = "Alpha";
106  }
107  else if(aCode == 22) name = "Gamma";
108  else
109  {
110  G4cout << "particle " << aCode << " " <<aBaryon<< " not known in this generator!!" << G4endl;
111  }
112  return name;
113  }
114 
115 
116 void
118  {
119  px = mom.x();
120  py = mom.y();
121  pz = mom.z();
122  return;
123  }
124 
125 void
127  {
128  px = mom->x();
129  py = mom->y();
130  pz = mom->z();
131  return;
132  }
133 
134 void
136  {
137  px = mom.x();
138  py = mom.y();
139  pz = mom.z();
140  energy = std::sqrt(mass*mass + px*px + py*py + pz*pz);
141  kineticEnergy = Amax(0.,energy - mass);
142  return;
143  }
144 
145 void
147  {
148  px = mom->x();
149  py = mom->y();
150  pz = mom->z();
151  energy = std::sqrt(mass*mass + px*px + py*py + pz*pz);
152  kineticEnergy = Amax(0.,energy - mass);
153  return;
154  }
155 
156 const G4ParticleMomentum
158  {
159  G4ParticleMomentum mom;
160  mom.setX(px);
161  mom.setY(py);
162  mom.setZ(pz);
163  return mom;
164  }
165 
167 {
168  return std::sqrt(px*px + py*py + pz*pz);
169 }
170 
171 void
173 {
174  px = x;
175  py = y;
176  pz = z;
177  return;
178 }
179 
180 void
182 {
183  px = x;
184  py = y;
185  pz = z;
186  energy = std::sqrt(mass*mass + px*px + py*py + pz*pz);
188  return;
189 }
190 
191 void
193 {
194  px = x;
195  py = y;
196  return;
197 }
198 
199 void
201  {
202  px = x;
203  py = y;
204  energy = std::sqrt(mass*mass + px*px + py*py + pz*pz);
206  return;
207  }
208 
209 void
211  {
212  pz = z;
213  return;
214  }
215 
216 void
218  {
219  pz = z;
220  energy = std::sqrt(mass*mass + px*px + py*py + pz*pz);
222  return;
223  }
224 
225 void
227  {
228  energy = e;
229  return;
230  }
231 
232 void
234  {
235  if (e <= mass)
236  {
237  energy = mass;
238  kineticEnergy = 0.;
239  px = 0.;
240  py = 0.;
241  pz = 0.;
242  }
243  else
244  {
245  energy = e;
247  G4double momold = std::sqrt(px*px + py*py + pz*pz);
248  G4double momnew = std::sqrt(energy*energy - mass*mass);
249  if (momold == 0.)
250  {
251  G4double cost = 1.0- 2.0*G4UniformRand();
252  G4double sint = std::sqrt(1. - cost*cost);
253  G4double phi = twopi* G4UniformRand();
254  px = momnew * sint * std::cos(phi);
255  py = momnew * sint * std::sin(phi);
256  pz = momnew * cost;
257  }
258  else
259  {
260  momnew /= momold;
261  px *= momnew;
262  py *= momnew;
263  pz *= momnew;
264  }
265  }
266  return;
267  }
268 
269 void
271  {
272  kineticEnergy = ekin;
273  return;
274  }
275 
276 void
278  {
279  if (ekin <= 0.)
280  {
281  energy = mass;
282  kineticEnergy = 0.;
283  px = 0.;
284  py = 0.;
285  pz = 0.;
286  }
287  else
288  {
289  energy = ekin + mass;
290  kineticEnergy = ekin;
291  G4double momold = std::sqrt(px*px + py*py + pz*pz);
292  G4double momnew = std::sqrt(energy*energy - mass*mass);
293  if (momold == 0.)
294  {
295  G4double cost = 1.0-2.0*G4UniformRand();
296  G4double sint = std::sqrt(1. - cost*cost);
297  G4double phi = twopi* G4UniformRand();
298  px = momnew * sint * std::cos(phi);
299  py = momnew * sint * std::sin(phi);
300  pz = momnew * cost;
301  }
302  else
303  {
304  momnew /= momold;
305  px *= momnew;
306  py *= momnew;
307  pz *= momnew;
308  }
309  }
310  return;
311  }
312 
314 {
315  return energy;
316 }
317 
319 {
320  return kineticEnergy;
321 }
322 
323 
325 {
326  mass = amass;
327  return;
328 }
329 
330 
332 {
333  kineticEnergy = Amax(0., energy - mass);
334  mass = amass;
336  G4double momnew = std::sqrt(Amax(0., energy*energy - mass*mass));
337  if (momnew == 0.0) {
338  px = 0.;
339  py = 0.;
340  pz = 0.;
341  } else {
342  G4double momold = std::sqrt(px*px + py*py + pz*pz);
343  if (momold == 0.) {
344  G4double cost = 1.-2.*G4UniformRand();
345  G4double sint = std::sqrt(1.-cost*cost);
346  G4double phi = twopi*G4UniformRand();
347  px = momnew*sint*std::cos(phi);
348  py = momnew*sint*std::sin(phi);
349  pz = momnew*cost;
350  } else {
351  momnew /= momold;
352  px *= momnew ;
353  py *= momnew ;
354  pz *= momnew ;
355  }
356  }
357  return;
358 }
359 
360 
362 {
363  return mass;
364 }
365 
366 void
368  {
369  charge = c;
370  return;
371  }
372 
374 {
375  return charge;
376 }
377 
378 void
380  {
381  timeOfFlight = t;
382  return;
383  }
384 
385 G4double
387  {
388  return timeOfFlight;
389  }
390 
391 
393 {
394  side = aside;
395  return;
396 }
397 
398 
399 G4int
401  {
402  return side;
403  }
404 
405 
406 void
408  {
409  flag = f;
410  return;
411  }
412 
413 G4bool
415  {
416  return flag;
417  }
418 
419 void
421  {
422  code = c;
423  return;
424  }
425 
427 {
428  return code;
429 }
430 
432 {
433  return particleName;
434 }
435 
437 {
438  return particleType;
439 }
440 
442 {
443  return baryon;
444 }
445 
447 {
448  return strangeness;
449 }
450 
451 G4int
453  {
454  if(flavor > 0 && flavor < 8)
455  {
456  G4int check;
457  check = FillQuarkContent();
458  if(check != code)
459  {
460  return 0;
461  }
462  else
463  {
464  return theQuarkContent[flavor-1];
465  }
466  }
467  else
468  {
469  return 0;
470  }
471  }
472 
473 G4int
475  {
476  if(flavor > 0 && flavor < 8)
477  {
478  G4int check;
479  check = FillQuarkContent();
480  if(check != code)
481  {
482  return 0;
483  }
484  else
485  {
486  return theAntiQuarkContent[flavor-1];
487  }
488  }
489  else
490  {
491  return 0;
492  }
493  }
494 
495 void
497  {
498  px = 0.0;
499  py = 0.0;
500  pz = 0.0;
501  energy = 0.0;
502  kineticEnergy = 0.0;
503  mass = 0.0;
504  charge = 0.0;
505  timeOfFlight = 0.0;
506  side = 0;
507  flag = false;
508  code = 0;
509  particleName = "";
510  particleType = "";
511  baryon = 0;
512  strangeness = 0;
513  }
514 
515 void
516 G4HEVector::Add( const G4HEVector & p1, const G4HEVector & p2 )
517  {
518  px = p1.px + p2.px;
519  py = p1.py + p2.py;
520  pz = p1.pz + p2.pz;
521  energy = p1.energy + p2.energy;
522  G4double b = energy*energy - px*px - py*py - pz*pz;
523  if( b < 0 )
524  mass = -1. * std::sqrt( -b );
525  else
526  mass = std::sqrt( b );
527  kineticEnergy = Amax(0.,energy - mass);
528  charge = p1.charge + p2.charge;
529  code = 0;
530  particleName = "";
531  particleType = "";
532  baryon = 0;
533  strangeness = 0;
534  }
535 
536 void
537 G4HEVector::Sub( const G4HEVector & p1, const G4HEVector & p2 )
538  {
539  px = p1.px - p2.px;
540  py = p1.py - p2.py;
541  pz = p1.pz - p2.pz;
542  energy = p1.energy - p2.energy;
543  G4double b = energy*energy - px*px - py*py - pz*pz;
544  if( b < 0 )
545  mass = -1. * std::sqrt( -b );
546  else
547  mass = std::sqrt( b );
548  kineticEnergy = Amax(0.,energy - mass);
549  charge = p1.charge - p2.charge;
550  code = 0;
551  particleName = "";
552  particleType = "";
553  baryon = 0;
554  strangeness = 0;
555  }
556 
557 void
558 G4HEVector::Lor( const G4HEVector & p1, const G4HEVector & p2 )
559  {
560  G4double a;
561  a = ( Dot(p1,p2)/(p2.energy+p2.mass) - p1.energy ) / p2.mass;
562  px = p1.px + a*p2.px;
563  py = p1.py + a*p2.py;
564  pz = p1.pz + a*p2.pz;
565  energy = std::sqrt( sqr(p1.mass) + px*px + py*py + pz*pz);
566  mass = p1.mass;
567  kineticEnergy = Amax(0.,energy - mass);
569  side = p1.side;
570  flag = p1.flag;
571  code = p1.code;
574  baryon = p1.baryon;
576  }
577 
579 {
580  G4double a = std::sqrt( (px*px + py*py + pz*pz)*(p.px*p.px + p.py*p.py + p.pz*p.pz) );
581  if (a != 0.0) {
582  a = (px*p.px + py*p.py + pz*p.pz)/a;
583  if (std::fabs(a) > 1.0) {
584  if (a < 0.0) a = -1.0;
585  else a = 1.0;
586  }
587  }
588  return a;
589 }
590 
591 G4double
593  {
594  G4double a = std::sqrt( (px*px + py*py + pz*pz)*(p.px*p.px + p.py*p.py + p.pz*p.pz) );
595  if( a != 0.0 )
596  {
597  a = (px*p.px + py*p.py + pz*p.pz)/a;
598  if( std::fabs(a) > 1.0 )
599  {
600  if(a<0.0) a=-1.0;
601  else a=1.0;
602  }
603  }
604  return std::acos(a);
605  }
606 
607 G4double
608 G4HEVector::Dot4( const G4HEVector & p1, const G4HEVector & p2)
609  {
610  return ( p1.energy*p2.energy - p1.px*p2.px - p1.py*p2.py - p1.pz*p2.pz );
611  }
612 
613 G4double
614 G4HEVector::Impu( const G4HEVector & p1, const G4HEVector & p2)
615  {
616  return ( - sqr( p1.energy - p2.energy)
617  + sqr( p1.px - p2.px)
618  + sqr( p1.py - p2.py)
619  + sqr( p1.pz - p2.pz) );
620  }
621 
622 void
623 G4HEVector::Add3( const G4HEVector & p1, const G4HEVector & p2)
624  {
625  px = p1.px + p2.px;
626  py = p1.py + p2.py;
627  pz = p1.pz + p2.pz;
628  return;
629  }
630 
631 void
632 G4HEVector::Sub3( const G4HEVector & p1, const G4HEVector & p2)
633  {
634  px = p1.px - p2.px;
635  py = p1.py - p2.py;
636  pz = p1.pz - p2.pz;
637  return;
638  }
639 
640 void
641 G4HEVector::Cross( const G4HEVector & p1, const G4HEVector & p2)
642  {
643  G4double tpx = p1.py * p2.pz - p1.pz * p2.py;
644  G4double tpy = p1.pz * p2.px - p1.px * p2.pz;
645  G4double tpz = p1.px * p2.py - p1.py * p2.px;
646  px=tpx;
647  py=tpy;
648  pz=tpz;
649  return;
650  }
651 
652 G4double
653 G4HEVector::Dot( const G4HEVector & p1, const G4HEVector & p2)
654  {
655  return ( p1.px * p2.px + p1.py * p2.py + p1.pz * p2.pz );
656  }
657 
658 void
660  {
661  px = h * p.px;
662  py = h * p.py;
663  pz = h * p.pz;
664  return;
665  }
666 
667 void
669  {
670  px = h * p.px;
671  py = h * p.py;
672  pz = h * p.pz;
673  mass = p.mass;
674  energy = std::sqrt(px*px + py*py + pz*pz + mass*mass);
676  charge = p.charge;
678  side = p.side;
679  flag = p.flag;
680  code = p.code;
683  baryon = p.baryon;
685  return;
686  }
687 
688 void
690  {
691  G4double a = p.px*p.px + p.py*p.py + p.pz*p.pz;
692  if (a > 0.0) a = 1./std::sqrt(a);
693  px = a * p.px;
694  py = a * p.py;
695  pz = a * p.pz;
696  mass = p.mass;
697  energy = std::sqrt(px*px + py*py + pz*pz + mass*mass);
699  charge = p.charge;
701  side = p.side;
702  flag = p.flag;
703  code = p.code;
706  baryon = p.baryon;
708  return;
709  }
710 
712 {
713  return std::sqrt(px*px + py*py + pz*pz);
714 }
715 
716 void
718  {
719  G4HEVector mx = *this;
720  *this = p1;
721  p1 = mx;
722  return;
723  }
724 
725 void
726 G4HEVector::Defs1( const G4HEVector & p1, const G4HEVector & p2)
727  {
728  G4double pt2 = p2.px*p2.px + p2.py*p2.py;
729  if (pt2 > 0.0)
730  {
731  G4double ph, qx, qy, qz;
732  G4double a = std::sqrt(p2.px*p2.px + p2.py*p2.py + p2.pz*p2.pz);
733  G4double cost = p2.pz/a;
734  G4double sint = 0.5 * (std::sqrt(std::fabs((1.-cost)*(1.+cost))) + std::sqrt(pt2)/a);
735  if(p2.py < 0.) ph = 1.5*pi;
736  else ph = halfpi;
737  if( p2.px != 0.0)
738  ph = std::atan2(p2.py,p2.px);
739  qx = cost*std::cos(ph)*p1.px - std::sin(ph)*p1.py
740  + sint*std::cos(ph)*p1.pz;
741  qy = cost*std::sin(ph)*p1.px + std::cos(ph)*p1.py
742  + sint*std::sin(ph)*p1.pz;
743  qz = - sint *p1.px
744  + cost *p1.pz;
745  px = qx;
746  py = qy;
747  pz = qz;
748  }
749  else
750  {
751  px = p1.px;
752  py = p1.py;
753  pz = p1.pz;
754  }
755  }
756 
757 void
758 G4HEVector::Defs( const G4HEVector & p1, const G4HEVector & p2,
759  G4HEVector & my, G4HEVector & mz )
760  {
761  my = p1;
762  mz = p2;
763  px = my.py*mz.pz - my.pz*mz.py;
764  py = my.pz*mz.px - my.px*mz.pz;
765  pz = my.px*mz.py - my.py*mz.px;
766  my.px = mz.py*pz - mz.pz*py;
767  my.py = mz.pz*px - mz.px*pz;
768  my.pz = mz.px*py - mz.py*px;
769  G4double pp;
770  pp = std::sqrt(px*px + py*py + pz*pz);
771  if (pp > 0.)
772  {
773  pp = 1./pp;
774  px = px*pp ;
775  py = py*pp ;
776  pz = pz*pp ;
777  }
778  pp = std::sqrt(my.px*my.px + my.py*my.py + my.pz*my.pz);
779  if (pp > 0.)
780  {
781  pp = 1./pp;
782  my.px = my.px*pp ;
783  my.py = my.py*pp ;
784  my.pz = my.pz*pp ;
785  }
786  pp = std::sqrt(mz.px*mz.px + mz.py*mz.py + mz.pz*mz.pz);
787  if (pp > 0.)
788  {
789  pp = 1./pp;
790  mz.px = mz.px*pp ;
791  mz.py = mz.py*pp ;
792  mz.pz = mz.pz*pp ;
793  }
794  return;
795  }
796 
797 void
798 G4HEVector::Trac( const G4HEVector & p1, const G4HEVector & mx,
799  const G4HEVector & my, const G4HEVector & mz)
800  {
801  G4double qx, qy, qz;
802  qx = mx.px*p1.px + mx.py*p1.py + mx.pz*p1.pz;
803  qy = my.px*p1.px + my.py*p1.py + my.pz*p1.pz;
804  qz = mz.px*p1.px + mz.py*p1.py + mz.pz*p1.pz;
805  px = qx ;
806  py = qy ;
807  pz = qz ;
808  return;
809  }
810 
811 void
813  {
814  if(name == "PionPlus")
815  {
816  mass = 0.1395700;
817  charge = 1.;
818  code = 211;
819  particleType = "Meson";
820  particleName = name;
821  baryon = 0;
822  strangeness = 0;
823  }
824  else if(name == "PionZero")
825  {
826  mass = 0.1349764;
827  charge = 0.;
828  code = 111;
829  particleType = "Meson";
830  particleName = name;
831  baryon = 0;
832  strangeness = 0;
833  }
834  else if(name == "PionMinus")
835  {
836  mass = 0.1395700;
837  charge = -1.;
838  code = -211;
839  particleType = "Meson";
840  particleName = name;
841  baryon = 0;
842  strangeness = 0;
843  }
844  else if(name == "KaonPlus")
845  {
846  mass = 0.493677;
847  charge = 1.;
848  code = 321;
849  particleType = "Meson";
850  particleName = name;
851  baryon = 0;
852  strangeness = 1;
853  }
854  else if(name == "KaonZero")
855  {
856  mass = 0.497672;
857  charge = 0.;
858  code = 311;
859  particleType = "Meson";
860  particleName = name;
861  baryon = 0;
862  strangeness = 1;
863  }
864  else if(name == "AntiKaonZero")
865  {
866  mass = 0.497672;
867  charge = 0.;
868  code = -311;
869  particleType = "Meson";
870  particleName = name;
871  baryon = 0;
872  strangeness =-1;
873  }
874  else if(name == "KaonMinus")
875  {
876  mass = 0.493677;
877  charge = -1.;
878  code = -321;
879  particleType = "Meson";
880  particleName = name;
881  baryon = 0;
882  strangeness = -1;
883  }
884  else if(name == "KaonZeroShort")
885  {
886  mass = 0.497672;
887  charge = 0.;
888  code = 310;
889  particleType = "Meson";
890  particleName = name;
891  baryon = 0;
892  strangeness = 0;
893  }
894  else if(name == "KaonZeroLong")
895  {
896  mass = 0.497672;
897  charge = 0.;
898  code = 130;
899  particleType = "Meson";
900  particleName = name;
901  baryon = 0;
902  strangeness = 0;
903  }
904  else if(name == "Proton")
905  {
906  mass = 0.9382723;
907  charge = 1.;
908  code = 2212;
909  particleType = "Baryon";
910  particleName = name;
911  baryon = 1;
912  strangeness = 0;
913  }
914  else if(name == "AntiProton")
915  {
916  mass = 0.9382723;
917  charge = -1.;
918  code = -2212;
919  particleType = "AntiBaryon";
920  particleName = name;
921  baryon = -1;
922  strangeness = 0;
923  }
924  else if(name == "Neutron")
925  {
926  mass = 0.93956563;
927  charge = 0.;
928  code = 2112;
929  particleType = "Baryon";
930  particleName = name;
931  baryon = 1;
932  strangeness = 0;
933  }
934  else if(name == "AntiNeutron")
935  {
936  mass = 0.93956563;
937  charge = 0.;
938  code = -2112;
939  particleType = "AntiBaryon";
940  particleName = name;
941  baryon = -1;
942  strangeness = 0;
943  }
944  else if(name == "Lambda")
945  {
946  mass = 1.115684;
947  charge = 0.;
948  code = 3122;
949  particleType = "Baryon";
950  particleName = name;
951  baryon = 1;
952  strangeness = -1;
953  }
954  else if(name == "AntiLambda")
955  {
956  mass = 1.115684;
957  charge = 0.;
958  code = -3122;
959  particleType = "AntiBaryon";
960  particleName = name;
961  baryon = -1;
962  strangeness = 1;
963  }
964  else if(name == "SigmaPlus")
965  {
966  mass = 1.18937;
967  charge = 1.;
968  code = 3222;
969  particleType = "Baryon";
970  particleName = name;
971  baryon = 1;
972  strangeness = -1;
973  }
974  else if(name == "SigmaZero")
975  {
976  mass = 1.19255;
977  charge = 0.;
978  code = 3212;
979  particleType = "Baryon";
980  particleName = name;
981  baryon = 1;
982  strangeness = -1;
983  }
984  else if(name == "SigmaMinus")
985  {
986  mass = 1.19744;
987  charge = -1.;
988  code = 3112;
989  particleType = "Baryon";
990  particleName = name;
991  baryon = 1;
992  strangeness = -1;
993  }
994  else if(name == "AntiSigmaPlus")
995  {
996  mass = 1.18937;
997  charge = -1.;
998  code = -3222;
999  particleType = "AntiBaryon";
1000  particleName = name;
1001  baryon = -1;
1002  strangeness = 1;
1003  }
1004  else if(name == "AntiSigmaZero")
1005  {
1006  mass = 1.19255;
1007  charge = 0.;
1008  code = -3212;
1009  particleType = "AntiBaryon";
1010  particleName = name;
1011  baryon = -1;
1012  strangeness = 1;
1013  }
1014  else if(name == "AntiSigmaMinus")
1015  {
1016  mass = 1.19744;
1017  charge = 1.;
1018  code = -3112;
1019  particleType = "AntiBaryon";
1020  particleName = name;
1021  baryon = -1;
1022  strangeness = 1;
1023  }
1024  else if(name == "XiZero")
1025  {
1026  mass = 1.3149;
1027  charge = 0.;
1028  code = 3322;
1029  particleType = "Baryon";
1030  particleName = name;
1031  baryon = 1;
1032  strangeness = -2;
1033  }
1034  else if(name == "XiMinus")
1035  {
1036  mass = 1.32132;
1037  charge = -1.;
1038  code = 3312;
1039  particleType = "Baryon";
1040  particleName = name;
1041  baryon = 1;
1042  strangeness = -2;
1043  }
1044  else if(name == "AntiXiZero")
1045  {
1046  mass = 1.3149;
1047  charge = 0.;
1048  code = -3322;
1049  particleType = "AntiBaryon";
1050  particleName = name;
1051  baryon = -1;
1052  strangeness = 2;
1053  }
1054  else if(name == "AntiXiMinus")
1055  {
1056  mass = 1.32132;
1057  charge = 1.;
1058  code = -3312;
1059  particleType = "AntiBaryon";
1060  particleName = name;
1061  baryon = -1;
1062  strangeness = 2;
1063  }
1064  else if(name == "OmegaMinus")
1065  {
1066  mass = 1.67245;
1067  charge = -1.;
1068  code = 3334;
1069  particleType = "Baryon";
1070  particleName = name;
1071  baryon = 1;
1072  strangeness = -3;
1073  }
1074  else if(name == "AntiOmegaMinus")
1075  {
1076  mass = 1.67245;
1077  charge = 1.;
1078  code = -3334;
1079  particleType = "AntiBaryon";
1080  particleName = name;
1081  baryon = -1;
1082  strangeness = 3;
1083  }
1084  else if(name == "Deuteron")
1085  {
1086  mass = 1.875613;
1087  charge = 1.;
1088  code = 0;
1089  particleType = "Nucleus";
1090  particleName = name;
1091  baryon = 2;
1092  strangeness = 0;
1093  }
1094  else if(name == "Triton")
1095  {
1096  mass = 2.80925;
1097  charge = 1.;
1098  code = 0;
1099  particleType = "Nucleus";
1100  particleName = name;
1101  baryon = 3;
1102  strangeness = 0;
1103  }
1104  else if(name == "Alpha")
1105  {
1106  mass = 3.727417;
1107  charge = 2.;
1108  code = 0;
1109  particleType = "Nucleus";
1110  particleName = name;
1111  baryon = 4;
1112  strangeness = 0;
1113  }
1114  else if(name == "Gamma")
1115  {
1116  mass = 0.;
1117  charge = 0.;
1118  code = 22;
1119  particleType = "Boson";
1120  particleName = name;
1121  baryon = 0;
1122  strangeness = 0;
1123  }
1124  else
1125  {
1126  G4cout << "particle " << name << " not known in this generator!!" << G4endl;
1127  return;
1128  }
1129  px = 0.;
1130  py = 0.;
1131  pz = 0.;
1132  kineticEnergy = 0.;
1133  energy = mass;
1134  timeOfFlight = 0.;
1135  side = 0;
1136  flag = false;
1137  return;
1138  }
1139 
1141 {
1142  // Calculate quark and anti-quark content
1143  // Return value is PDG encoding for this particle
1144  // Error if return value is differnt from this->thePDGEncoding
1145 
1146  G4int tempPDGcode = code;
1147  G4double echarge = 1.;
1148 
1149  for (G4int flavor=0; flavor<NumberOfQuarkFlavor; flavor++){
1150  theQuarkContent[flavor] =0;
1151  theAntiQuarkContent[flavor] =0;
1152  }
1153 
1154  G4int temp = std::abs(tempPDGcode);
1155  G4int multiplet = temp/10000;
1156  temp -= G4int(multiplet*10000);
1157  G4int quark1 = temp/1000;
1158  temp -= G4int(quark1*1000);
1159  G4int quark2 = temp/100;
1160  temp -= G4int(quark2*100);
1161  G4int quark3 = temp/10;
1162  temp -= G4int(quark3*10);
1163 
1164  // G4int spin= (temp-1); DHW 19 May 2011: variable set but not used
1165 
1166  if (particleType =="quark") {
1167  if (tempPDGcode>0){
1168  if (tempPDGcode<=NumberOfQuarkFlavor){
1169  theQuarkContent[tempPDGcode-1] =1;
1170  } else {
1171  // --- thePDGEncoding is wrong
1172  tempPDGcode = 0;
1173  }
1174  } else {
1175  G4int temp0 = -1*tempPDGcode;
1176  if (temp0 <= NumberOfQuarkFlavor) {
1177  theAntiQuarkContent[temp0-1] =1;
1178  } else {
1179  // --- thePDGEncoding is wrong
1180  tempPDGcode = 0;
1181  }
1182  }
1183 
1184  } else if (particleType == "Meson") {
1185  // -- exceptions --
1186  // if (tempPDGcode == 310) spin = 0; //K0s
1187  // DHW 19 May 2011: variable set but not used
1188 
1189  if (tempPDGcode == 130) { //K0l
1190  // spin = 0; DHW 19 May 2011: variable set but not used
1191  quark2 = 3;
1192  quark3 = 1;
1193  }
1194 
1195  if (quark1 !=0)
1196  {
1197  tempPDGcode = 0;
1198  }
1199  if ((quark2==0)||(quark3==0)){
1200  tempPDGcode = 0;
1201  }
1202  if (quark2<quark3) {
1203  tempPDGcode = 0;
1204  }
1205  // check quark flavor
1206  if (quark2>=NumberOfQuarkFlavor){
1207  tempPDGcode = 0;
1208  }
1209  // check heavier quark type
1210  if (quark2 & 1) {
1211  // down type qurak
1212  if (tempPDGcode >0) {
1213  theQuarkContent[quark3-1] =1;
1214  theAntiQuarkContent[quark2-1] =1;
1215  } else {
1216  theQuarkContent[quark2-1] =1;
1217  theAntiQuarkContent[quark3-1] =1;
1218  }
1219  } else {
1220  // up type quark
1221  if (tempPDGcode >0) {
1222  theQuarkContent[quark2-1] =1;
1223  theAntiQuarkContent[quark3-1] =1;
1224  } else {
1225  theQuarkContent[quark3-1] =1;
1226  theAntiQuarkContent[quark2-1] =1;
1227  }
1228  }
1229  // check charge
1230  G4double totalCharge = 0.0;
1231  for (G4int flavor= 0; flavor<NumberOfQuarkFlavor-1; flavor+=2){
1232  totalCharge += (-1./3.)*echarge*theQuarkContent[flavor];
1233  totalCharge += 1./3.*echarge*theAntiQuarkContent[flavor];
1234  totalCharge += 2./3.*echarge*theQuarkContent[flavor+1];
1235  totalCharge += (-2./3.)*echarge*theAntiQuarkContent[flavor+1];
1236  }
1237  if (std::abs(totalCharge-charge)>0.1*echarge) {
1238  tempPDGcode = 0;
1239  }
1240  } else if (particleType == "baryon"){
1241  // check Meson or not
1242  if ((quark1==0)||(quark2==0)||(quark3==0)){
1243  tempPDGcode = 0;
1244  }
1245  //exceptions
1246  if (std::abs(tempPDGcode) == 3122) {
1247  // Lambda
1248  quark2 = 2;
1249  quark3 = 1;
1250  // spin = 1; DHW 19 May 2011: variable set but not used
1251  } else if (std::abs(tempPDGcode) == 4122) {
1252  // Lambda_c
1253  quark2 = 2;
1254  quark3 = 1;
1255  // spin = 1; DHW 19 May 2011: variable set but not used
1256  }
1257  // check quark flavor
1258  if ((quark1<quark2)||(quark2<quark3)||(quark1<quark3)) {
1259  tempPDGcode = 0;
1260  }
1261  if (quark1>=NumberOfQuarkFlavor) {
1262  tempPDGcode = 0;
1263  }
1264  if (tempPDGcode >0) {
1265  theQuarkContent[quark1-1] ++;
1266  theQuarkContent[quark2-1] ++;
1267  theQuarkContent[quark3-1] ++;
1268  } else {
1269  theAntiQuarkContent[quark1-1] ++;
1270  theAntiQuarkContent[quark2-1] ++;
1271  theAntiQuarkContent[quark3-1] ++;
1272  }
1273  // check charge
1274  G4double totalCharge = 0.0;
1275  for (G4int flavor= 0; flavor<NumberOfQuarkFlavor-1; flavor+=2){
1276  totalCharge += (-1./3.)*echarge*theQuarkContent[flavor];
1277  totalCharge += 1./3.*echarge*theAntiQuarkContent[flavor];
1278  totalCharge += 2./3.*echarge*theQuarkContent[flavor+1];
1279  totalCharge += (-2./3.)*echarge*theAntiQuarkContent[flavor+1];
1280  }
1281  if (std::abs(totalCharge - charge) > 0.1*echarge) tempPDGcode = 0;
1282 
1283  } else {
1284  }
1285  return tempPDGcode;
1286 }
1287 
1288 
1290 {
1291  G4cout << "HEV: "
1292  << L << " " << px << " " << py << " " << pz << " "
1293  << energy << " " << mass << " " << charge << " "
1294  << timeOfFlight << " " << side << " " << flag << " "
1295  << code << " " << baryon << " " << particleName << G4endl;
1296  return;
1297 }