Ignore:
Timestamp:
Jun 18, 2010, 11:42:07 AM (14 years ago)
Author:
garnier
Message:

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/cascade/cascade/include/G4InuclElementaryParticle.hh

    r1196 r1315  
     1#ifndef G4INUCL_ELEMENTARY_PARTICLE_HH
     2#define G4INUCL_ELEMENTARY_PARTICLE_HH
    13//
    24// ********************************************************************
     
    2325// * acceptance of all terms of the Geant4 Software license.          *
    2426// ********************************************************************
     27// $Id: G4InuclElementaryParticle.hh,v 1.22 2010/04/29 19:39:55 mkelsey Exp $
     28// Geant4 tag: $Name: geant4-09-04-beta-cand-01 $
    2529//
    26 #ifndef G4INUCL_ELEMENTARY_PARTICLE_HH
    27 #define G4INUCL_ELEMENTARY_PARTICLE_HH
     30// 20100114  M. Kelsey -- Remove G4CascadeMomentum, use G4LorentzVector directly
     31// 20100409  M. Kelsey -- Drop unused string argument from ctors.
     32// 20100429  M. Kelsey -- Change "photon()" to "isPhoton()", use enum names
    2833
    29 
     34#include "G4InuclParticle.hh"
     35#include "G4InuclParticleNames.hh"
    3036#include "globals.hh"
    3137
    32 #ifndef G4INUCL_PARTICLE_HH
    33 #include "G4InuclParticle.hh"
    34 #endif
     38class G4ParticleDefinition;
    3539
    3640class G4InuclElementaryParticle : public G4InuclParticle {
     41public:
     42  G4InuclElementaryParticle()
     43    : G4InuclParticle(), generation(0) {}
    3744
    38 //                     known particle types:
    39 //      1 - proton          11 - k+         111 - quasideuteron PP
    40 //      2 - neutron         13 - k-         112 - quasideuteron PN
    41 //      3 - pi+             15 - k0         122 - quasideuteron NN
    42 //      5 - pi-             17 - k0bar
    43 //      7 - pi 0            21 - lambda
    44 //     10 - photon          23 - sigma+
    45 //                          25 - sigma0
    46 //                          27 - sigma-
    47 //                          29 - xi0
    48 //                          31 - xi-
    49  
    50 public:
     45  explicit G4InuclElementaryParticle(G4int type)
     46    : G4InuclParticle(makeDefinition(type)), generation(0) {}
    5147
    52   G4InuclElementaryParticle() {
    53     particleType = 0;     // DHW: added to keep 4.3 compiler happy
    54     particleMass = 0.;    //            "              "
    55     valid_particle = false;
    56     generation = 0;
    57   };
     48  G4InuclElementaryParticle(const G4LorentzVector& mom,
     49                            G4int type, G4int model=0)
     50    : G4InuclParticle(makeDefinition(type), mom), generation(0) {
     51    setModel(model);
     52  }
    5853
    59   G4InuclElementaryParticle(G4int type)
    60     : particleType(type) {
     54  G4InuclElementaryParticle(G4double ekin, G4int type)
     55    : G4InuclParticle(makeDefinition(type), ekin), generation(0) {}
    6156
    62     particleMass = getParticleMass(type);
    63     valid_particle = false;
    64   };
     57  // Copy and assignment constructors for use with std::vector<>
     58  G4InuclElementaryParticle(const G4InuclElementaryParticle& right)
     59    : G4InuclParticle(right), generation(right.generation) {}
    6560
    66   G4InuclElementaryParticle(const G4CascadeMomentum& mom,
    67                             G4int type)
    68     : G4InuclParticle(mom),
    69       particleType(type) {
     61  G4InuclElementaryParticle& operator=(const G4InuclElementaryParticle& right);
    7062
    71     particleMass = getParticleMass(type);
    72     momentum[0] = std::sqrt(momentum[1] * momentum[1] + momentum[2] * momentum[2] +
    73                        momentum[3] * momentum[3] + particleMass * particleMass);
    74     valid_particle = true;
    75   };
     63  void setType(G4int ityp);
     64  G4int type() const { return type(getDefinition()); }
    7665
    77  
    78   G4InuclElementaryParticle(const G4CascadeMomentum& mom,
    79                             G4int type, G4int model)
    80     : G4InuclParticle(mom),
    81       particleType(type) {
     66  static G4int type(const G4ParticleDefinition* pd);
    8267
    83     G4InuclParticle::setModel(model);
     68  G4bool isPhoton() const { return (type() == G4InuclParticleNames::photon); }
    8469
    85     particleMass = getParticleMass(type);
    86     momentum[0] = std::sqrt(momentum[1] * momentum[1] + momentum[2] * momentum[2] +
    87                        momentum[3] * momentum[3] + particleMass * particleMass);
    88     valid_particle = true;
    89   };
     70  G4bool pion() const { return (type()==G4InuclParticleNames::pionPlus ||
     71                                type()==G4InuclParticleNames::pionMinus ||
     72                                type()==G4InuclParticleNames::pionZero); }
    9073
    91   G4InuclElementaryParticle(G4double ekin,
    92                             G4int type)
    93     : particleType(type) {
     74  G4bool nucleon() const { return (type()==G4InuclParticleNames::proton ||
     75                                   type()==G4InuclParticleNames::neutron); }
    9476
    95     particleMass = getParticleMass(type);
    96     momentum[0] = ekin + particleMass;
    97     momentum[3] = std::sqrt(momentum[0] * momentum[0] - particleMass * particleMass);
    98     momentum[1] = momentum[2] = 0.0;
    99     valid_particle = true;
    100   };
     77  G4int baryon() const {                // Can use as a bool (!=0 ==> true)
     78    return getDefinition()->GetBaryonNumber();
     79  }
    10180
    102   void setType(G4int ityp) {
     81  G4bool quasi_deutron() const { return (type() > 100); }
    10382
    104     particleType = ityp;
    105     particleMass = getParticleMass(ityp);
    106   };
    107 
    108   void setMomentum(const G4CascadeMomentum& mom) {
    109 
    110     momentum = mom;
    111     momentum[0] = std::sqrt(momentum[1] * momentum[1] + momentum[2] * momentum[2] +
    112                        momentum[3] * momentum[3] + particleMass * particleMass);
    113     valid_particle = true;
    114   };
    115 
    116   G4int type() const {
    117 
    118     return particleType;
    119   };
    120 
    121   G4bool photon() const {
    122 
    123     return particleType == 10;
    124   };
    125 
    126   G4bool nucleon() const {
    127     return particleType <= 2;
    128   };
    129 
    130   G4bool baryon() const {
    131     return (particleType == 1  ||
    132             particleType == 2  ||
    133             particleType == 21 ||
    134             particleType == 23 ||
    135             particleType == 25 ||
    136             particleType == 27 ||
    137             particleType == 29 ||
    138             particleType == 31 );
    139   };
    140 
    141   G4bool pion() const {
    142 
    143     return particleType == 3 || particleType == 5 || particleType == 7;
    144   };
    145 
    146   G4bool quasi_deutron() const {
    147 
    148     return particleType > 100;
    149   };
    150 
    151   G4double getMass() const {
    152 
    153     return particleMass;
    154   };
    155 
    156   G4double getParticleMass() const {
    157 
    158     G4double mass;
    159 
    160     switch(particleType) {
    161     case 1: // proton
    162       mass = 0.93827;
    163       break;
    164     case 2: // neutron
    165       mass = 0.93957;
    166       break;
    167     case 3: // pi+
    168       mass = 0.13957;
    169       break;
    170     case 5: // pi-
    171       mass = 0.13957;
    172       break;
    173     case 7: // pi0
    174       mass = 0.13498;
    175       break;
    176     case 10: // photon
    177       mass = 0.0;
    178       break;
    179     case 11: // k+
    180       mass = 0.49368;
    181       break;
    182     case 13: // k-
    183       mass = 0.49368;
    184       break;
    185     case 15: // k0
    186       mass = 0.49767;
    187       break;
    188     case 17: // k0bar
    189       mass = 0.49767;
    190       break;
    191     case 21: // lambda
    192       mass = 1.1157;
    193       break;
    194     case 23: // sigma+
    195       mass = 1.1894;
    196       break;
    197     case 25: // sigma0
    198       mass = 1.1926;
    199       break;
    200     case 27: // sigma-
    201       mass = 1.1974;
    202       break;
    203     case 29: // xi0
    204       mass = 1.3148;
    205       break;
    206     case 31: // xi-
    207       mass = 1.3213;
    208       break;
    209     case 111: // PP
    210       mass = 0.93827 + 0.93827;
    211       break;
    212     case 112: // PN
    213       mass = 0.93827 + 0.93957;
    214       break;
    215     case 122: // NN
    216       mass = 0.93957 + 0.93957;
    217       break;
    218     default:
    219       G4cout << " uups, unknown particle type " << particleType << G4endl;
    220       mass = 0.;
    221     };
    222        
    223     return mass;
    224   };
    225 
    226   G4double getCharge() const {
    227 
    228     G4double charge;
    229 
    230     switch(particleType) {
    231     case 1: // proton
    232       charge = 1.0;
    233       break;
    234     case 2: // neutron
    235       charge = 0.0;
    236       break;
    237     case 3: // pi+
    238       charge = 1.0;
    239       break;
    240     case 5: // pi-
    241       charge = -1.0;
    242       break;
    243     case 7: // pi0
    244       charge = 0.0;
    245       break;
    246     case 10: // photon
    247       charge = 0.0;
    248       break;
    249     case 11: // k+
    250       charge = 1.0;
    251       break;
    252     case 13: // k-
    253       charge = -1.0;
    254       break;
    255     case 15: // k0
    256       charge = 0.0;
    257       break;
    258     case 17: // k0bar
    259       charge = 0.0;
    260       break;
    261     case 21: // lambda
    262       charge = 0.0;
    263       break;
    264     case 23: // sigma+
    265       charge = 1.0;
    266       break;
    267     case 25: // sigma0
    268       charge = 0.0;
    269       break;
    270     case 27: // sigma-
    271       charge = -1.0;
    272       break;
    273     case 29: // xi0
    274       charge = 0.0;
    275       break;
    276     case 31: // xi-
    277       charge = -1.0;
    278       break;
    279     case 111: // PP
    280       charge = 2.0;
    281       break;
    282     case 112: // PN
    283       charge = 1.0;
    284       break;
    285     case 122: // NN
    286       charge = 0.0;
    287       break;
    288     default:
    289       G4cout << " uups, unknown particle type " << particleType << G4endl;
    290       charge = 0.0;
    291     };
    292        
    293     return charge;
    294   };
    295 
    296 
    297   G4double getStrangeness(G4int type) const {
    298 
    299     G4double strangeness;
    300 
    301     switch(type) {
    302     case 1: // proton
    303       strangeness = 0.0;
    304       break;
    305     case 2: // neutron
    306       strangeness = 0.0;
    307       break;
    308     case 3: // pi+
    309       strangeness = 0.0;
    310       break;
    311     case 5: // pi-
    312       strangeness = 0.0;
    313       break;
    314     case 7: // pi0
    315       strangeness = 0.0;
    316       break;
    317     case 10: // photon
    318       strangeness = 0.0;
    319       break;
    320     case 11: // k+
    321       strangeness = 1.0;
    322       break;
    323     case 13: // k-
    324       strangeness = -1.0;
    325       break;
    326     case 15: // k0
    327       strangeness = 1.0;
    328       break;
    329     case 17: // k0bar
    330       strangeness = -1.0;
    331       break;
    332     case 21: // lambda
    333       strangeness = -1.0;
    334       break;
    335     case 23: // sigma+
    336       strangeness = -1.0;
    337       break;
    338     case 25: // sigma0
    339       strangeness = -1.0;
    340       break;
    341     case 27: // sigma-
    342       strangeness = -1.0;
    343       break;
    344     case 29: // xi0
    345       strangeness = -2.0;
    346       break;
    347     case 31: // xi-
    348       strangeness = -2.0;
    349       break;
    350     case 111: // PP
    351       strangeness = 0.0;
    352       break;
    353     case 112: // PN
    354       strangeness = 0.0;
    355       break;
    356     case 122: // NN
    357       strangeness = 0.0;
    358       break;
    359     default:
    360       G4cout << " unknown particle type " << type << G4endl;
    361       strangeness = 0.0;
    362     };
    363        
    364     return strangeness;
    365   };
    366 
    367 
    368   G4double getParticleMass(G4int type) const {
    369 
    370     G4double mass;
    371 
    372     switch(type) {
    373     case 1: // proton
    374       mass = 0.93827;
    375       break;
    376     case 2: // neutron
    377       mass = 0.93957;
    378       break;
    379     case 3: // pi+
    380       mass = 0.13957;
    381       break;
    382     case 5: // pi-
    383       mass = 0.13957;
    384       break;
    385     case 7: // pi0
    386       mass = 0.13498;
    387       break;
    388     case 10: // photon
    389       mass = 0.0;
    390       break;
    391     case 11: // k+
    392       mass = 0.49368;
    393       break;
    394     case 13: // k-
    395       mass = 0.49368;
    396       break;
    397     case 15: // k0
    398       mass = 0.49767;
    399       break;
    400     case 17: // k0bar
    401       mass = 0.49767;
    402       break;
    403     case 21: // lambda
    404       mass = 1.1157;
    405       break;
    406     case 23: // sigma+
    407       mass = 1.1894;
    408       break;
    409     case 25: // sigma0
    410       mass = 1.1926;
    411       break;
    412     case 27: // sigma-
    413       mass = 1.1974;
    414       break;
    415     case 29: // xi0
    416       mass = 1.3148;
    417       break;
    418     case 31: // xi-
    419       mass = 1.3213;
    420       break;
    421     case 111: // PP
    422       mass = 0.93827 + 0.93827;
    423       break;
    424     case 112: // PN
    425       mass = 0.93827 + 0.93957;
    426       break;
    427     case 122: // NN
    428       mass = 0.93957 + 0.93957;
    429       break;
    430     default:
    431       G4cout << " uups, unknown particle type " << type << G4endl;
    432       mass = 0.0;
    433     };
    434        
    435     return mass;
    436   };
    437 
    438   G4double getKineticEnergy() const {
    439 
    440     return momentum[0] - particleMass;
    441   };
    442 
    443   G4double getEnergy() const {
    444 
    445     return momentum[0];
    446   };
    447 
    448   G4bool valid() const {
    449 
    450     return valid_particle;
    451   };
     83  G4bool valid() const { return type()>0; }
    45284
    45385  virtual void printParticle() const {
    454 
    45586    G4InuclParticle::printParticle();
    456 
    457     G4cout << " Particle: type " << particleType << " mass " << particleMass <<
    458       " ekin " << getKineticEnergy() << G4endl;
    459   };
    460 
    461   void setGeneration(G4int gen) {
    462     generation = gen;
     87    G4cout << " Particle: type " << type() << " mass " << getMass()
     88           << " ekin " << getKineticEnergy() << G4endl;
    46389  }
    46490
    465   G4int getGeneration() {
    466     return generation;
    467   }
     91  void setGeneration(G4int gen) { generation = gen; }
     92  G4int getGeneration() const { return generation; }
     93
     94  static G4double getStrangeness(G4int type);
     95  static G4double getParticleMass(G4int type);
     96
     97protected:
     98  // Convert internal type code to standard GEANT4 pointer
     99  static G4ParticleDefinition* makeDefinition(G4int ityp);
    468100
    469101private:
    470 
    471   G4int particleType;
    472 
    473   G4double particleMass;
    474 
    475   G4bool valid_particle;
    476 
    477102  G4int generation;
    478 
    479103};       
    480104
Note: See TracChangeset for help on using the changeset viewer.