G4Parton.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 //
00028 // ------------------------------------------------------------
00029 //      GEANT 4 class implementation file
00030 //
00031 //      ---------------- G4Parton ----------------
00032 //             by Gunter Folger, June 1998.
00033 //       class for Parton (inside a string) used by Parton String Models
00034 // ------------------------------------------------------------
00035 
00036 #include "G4Parton.hh"
00037 #include "G4HadronicException.hh"
00038 
00039 G4Parton::G4Parton(G4int PDGcode)
00040 {
00041         PDGencoding=PDGcode;
00042         theX = 0;
00043         theDefinition=G4ParticleTable::GetParticleTable()->FindParticle(PDGencoding);
00044         if (theDefinition == NULL)
00045         {
00046           G4cout << "Encoding = "<<PDGencoding<<G4endl;
00047           G4String text = "G4Parton::GetDefinition(): Encoding not in particle table";
00048           throw G4HadronicException(__FILE__, __LINE__, text);
00049         }
00050         //
00051         // colour by random in (1,2,3)=(R,G,B) for quarks and 
00052         //                  in (-1,-2,-3)=(Rbar,Gbar,Bbar) for anti-quarks:
00053   //
00054         if (theDefinition->GetParticleType() == "quarks") {
00055                 theColour = ((G4int)(3.*G4UniformRand())+1)*(std::abs(PDGencoding)/PDGencoding) ;
00056         }
00057         //
00058         // colour by random in (-1,-2,-3)=(Rbar,Gbar,Bbar)=(GB,RB,RG) for di-quarks and
00059         //                  in (1,2,3)=(R,G,B)=(GB,RB,RG) for anti-di-quarks:
00060   //
00061         else if (theDefinition->GetParticleType() == "diquarks") {
00062                 theColour = -((G4int)(3.*G4UniformRand())+1)*(std::abs(PDGencoding)/PDGencoding);
00063         }
00064         //
00065         // colour by random in (-11,-12,...,-33)=(RRbar,RGbar,RBbar,...,BBbar) for gluons:
00066   //
00067         else if (theDefinition->GetParticleType() == "gluons") {
00068                 theColour = -(((G4int)(3.*G4UniformRand())+1)*10 + ((G4int)(3.*G4UniformRand())+1));
00069         }
00070         else {
00071           G4cout << "Encoding = "<<PDGencoding<<G4endl;
00072           G4String text = "G4Parton::GetDefinition(): Particle is not a parton";
00073           throw G4HadronicException(__FILE__, __LINE__, text);
00074         }
00075         //  
00076         // isospin-z from PDG-encoded isospin-z for 
00077         // quarks, anti-quarks, di-quarks, and anti-di-quarks:
00078   //
00079         if ((theDefinition->GetParticleType() == "quarks") || (theDefinition->GetParticleType() == "diquarks")){
00080                 theIsoSpinZ = theDefinition->GetPDGIsospin3();
00081         }
00082         //
00083   // isospin-z choosen at random from PDG-encoded isospin for gluons (should be zero):
00084         //
00085         else {
00086                 G4int thisPDGiIsospin=theDefinition->GetPDGiIsospin();
00087                 if (thisPDGiIsospin == 0) {
00088                         theIsoSpinZ = 0;
00089                 }
00090                 else {
00091                         theIsoSpinZ = ((G4int)((thisPDGiIsospin+1)*G4UniformRand()))-thisPDGiIsospin*0.5;
00092                 }
00093         }
00094         //
00095         // spin-z choosen at random from PDG-encoded spin:
00096         //
00097         G4int thisPDGiSpin=theDefinition->GetPDGiSpin();
00098         if (thisPDGiSpin == 0) {
00099                 theSpinZ = 0;
00100         }
00101         else {
00102                 G4int rand=((G4int)((thisPDGiSpin+1)*G4UniformRand()));
00103                 theSpinZ = rand-thisPDGiSpin*0.5;;
00104         }
00105 }
00106 
00107 G4Parton::G4Parton(const G4Parton &right)
00108 {
00109         PDGencoding = right.PDGencoding;
00110         theMomentum = right.theMomentum;
00111         thePosition = right.thePosition;
00112         theX = right.theX;
00113         theDefinition = right.theDefinition;
00114         theColour = right.theColour;
00115         theIsoSpinZ = right.theIsoSpinZ;
00116         theSpinZ = right.theSpinZ;
00117 }
00118 
00119 G4Parton & G4Parton::operator=(const G4Parton &right)
00120 {
00121    if (this != &right)
00122    {
00123       PDGencoding=right.GetPDGcode();
00124       theMomentum=right.Get4Momentum();
00125       thePosition=right.GetPosition();
00126       theX = right.theX;
00127       theDefinition = right.theDefinition;
00128       theColour = right.theColour;
00129       theIsoSpinZ = right.theIsoSpinZ;
00130       theSpinZ = right.theSpinZ;
00131    }
00132 
00133         return *this;
00134 }
00135 
00136 G4Parton::~G4Parton()
00137 {
00138 //  cout << "G4Parton::~G4Parton(): this = "<<this <<endl;
00139 //  cout << "break here"<<this <<endl;
00140 }
00141 
00142 void G4Parton::DefineMomentumInZ(G4double aLightConeMomentum, G4bool aDirection)
00143 {
00144         G4double Mass = GetMass();
00145         G4LorentzVector a4Momentum = Get4Momentum();
00146         aLightConeMomentum*=theX;
00147         G4double TransverseMass2 = sqr(a4Momentum.px()) + sqr(a4Momentum.py()) + sqr(Mass);
00148         a4Momentum.setPz(0.5*(aLightConeMomentum - TransverseMass2/aLightConeMomentum)*(aDirection? 1: -1)); 
00149         a4Momentum.setE( 0.5*(aLightConeMomentum + TransverseMass2/aLightConeMomentum));
00150         Set4Momentum(a4Momentum);
00151 }  
00152 
00153 void G4Parton::DefineMomentumInZ(G4double aLightConeMomentum,G4double aLightConeE, G4bool aDirection)
00154 {
00155         G4double Mass = GetMass();
00156         G4LorentzVector a4Momentum = Get4Momentum();
00157         aLightConeMomentum*=theX;
00158         aLightConeE*=theX;
00159         G4double TransverseMass2 = sqr(a4Momentum.px()) + sqr(a4Momentum.py()) + sqr(Mass);
00160         a4Momentum.setPz(0.5*(aLightConeMomentum - aLightConeE - TransverseMass2/aLightConeMomentum)*(aDirection? 1: -1)); 
00161         a4Momentum.setE( 0.5*(aLightConeMomentum + aLightConeE + TransverseMass2/aLightConeMomentum));
00162         Set4Momentum(a4Momentum);
00163 }  

Generated on Mon May 27 17:49:16 2013 for Geant4 by  doxygen 1.4.7