source: trunk/source/processes/hadronic/models/cascade/cascade/src/G4CascadeChannel.cc @ 1340

Last change on this file since 1340 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 5.0 KB
Line 
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// $Id: G4CascadeChannel.cc,v 1.8 2010/06/25 09:44:02 gunter Exp $
27// GEANT4 tag: $Name: hadr-casc-V09-03-85 $
28//
29// 20100514  M. Kelsey -- All functionality removed except quantum-number
30//              validation functions.
31
32#include "G4CascadeChannel.hh"
33#include "G4ParticleDefinition.hh"
34#include <vector>
35
36
37std::vector<G4int> G4CascadeChannel::getQnums(G4int type) {
38  G4int bary=0, str=0, ch=0;
39  std::vector<G4int> Qnums(3);
40
41    switch(type) {
42    case 1: // proton
43      bary = 1;
44      str = 0;
45      ch = 1;
46      break;
47    case 2: // neutron
48      bary = 1;
49      str = 0;
50      ch = 0;
51      break;
52    case 3: // pi+
53      bary = 0;
54      str = 0;
55      ch = 1;
56      break;
57    case 5: // pi-
58      bary = 0;
59      str = 0;
60      ch = -1;
61      break;
62    case 7: // pi0
63      bary = 0;
64      str = 0;
65      ch = 0;
66      break;
67    case 11: // k+
68      bary = 0;
69      str = 1;
70      ch = 1;
71      break;
72    case 13: // k-
73      bary = 0;
74      str = -1;
75      ch = -1;
76      break;
77    case 15: // k0
78      bary = 0;
79      str = 1;
80      ch = 0;
81      break;
82    case 17: // k0bar
83      bary = 0;
84      str = -1;
85      ch = 0;
86      break;
87    case 21: // lambda
88      bary = 1;
89      str = -1;
90      ch = 0;
91      break;
92    case 23: // sigma+
93      bary = 1;
94      str = -1;
95      ch = 1;
96      break;
97    case 25: // sigma0
98      bary = 1;
99      str = -1;
100      ch = 0;
101      break;
102    case 27: // sigma-
103      bary = 1;
104      str = -1;
105      ch = -1;
106      break;
107    case 29: // xi0
108      bary = 1;
109      str = -2;
110      ch = 0;
111      break;
112    case 31: // xi-
113      bary = 1;
114      str = -2;
115      ch = -1;
116      break;
117    default:
118      G4cout << " Unknown particle type " << type << G4endl;
119    };
120
121    Qnums[0] = bary;
122    Qnums[1] = str;
123    Qnums[2] = ch;
124    return Qnums;
125}
126
127void 
128G4CascadeChannel::CheckQnums(const G4FastVector<G4ReactionProduct,256> &vec,
129                             G4int &vecLen,
130                             G4ReactionProduct &currentParticle,
131                             G4ReactionProduct &targetParticle,
132                             G4double Q, G4double B, G4double S) {
133  G4ParticleDefinition* projDef = currentParticle.GetDefinition();
134  G4ParticleDefinition* targDef = targetParticle.GetDefinition();
135  G4double chargeSum = projDef->GetPDGCharge() + targDef->GetPDGCharge();
136  G4double baryonSum = projDef->GetBaryonNumber() + targDef->GetBaryonNumber();
137  G4double strangenessSum = projDef->GetQuarkContent(3) - 
138                            projDef->GetAntiQuarkContent(3) + 
139                            targDef->GetQuarkContent(3) -
140                            targDef->GetAntiQuarkContent(3);
141
142  G4ParticleDefinition* secDef = 0;
143  for (G4int i = 0; i < vecLen; i++) {
144    secDef = vec[i]->GetDefinition();
145    chargeSum += secDef->GetPDGCharge();
146    baryonSum += secDef->GetBaryonNumber();
147    strangenessSum += secDef->GetQuarkContent(3) 
148                    - secDef->GetAntiQuarkContent(3);
149  }
150
151  G4bool OK = true;
152  if (chargeSum != Q) {
153    G4cout << " Charge not conserved " << G4endl;
154    OK = false;
155  }
156  if (baryonSum != B) {
157    G4cout << " Baryon number not conserved " << G4endl;
158    OK = false;
159  }
160  if (strangenessSum != S) {
161    G4cout << " Strangeness not conserved " << G4endl;
162    OK = false;
163  } 
164
165  if (!OK) {
166    G4cout << " projectile: " << projDef->GetParticleName() 
167           << "  target: " << targDef->GetParticleName() << G4endl;
168    for (G4int i = 0; i < vecLen; i++) {
169      secDef = vec[i]->GetDefinition();
170      G4cout << secDef->GetParticleName() << " " ;
171    }
172    G4cout << G4endl;
173  }
174}
Note: See TracBrowser for help on using the repository browser.