Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4IsomerTable.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 //
28 // MODULE: G4IsomerTable.cc
29 //
30 // Date: 5/05/13
31 // Author: H.Kurashige
32 //
33 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 //
35 // HISTORY
36 ////////////////////////////////////////////////////////////////////////////////
37 //
38 #include "G4IsomerTable.hh"
39 
40 #include "G4ios.hh"
41 #include "globals.hh"
42 #include "G4PhysicalConstants.hh"
43 #include "G4SystemOfUnits.hh"
44 #include <iomanip>
45 #include <fstream>
46 #include <sstream>
47 
48 const G4double G4IsomerTable::levelTolerance = 1.0*keV;
49 // torelance for excitation energy
50 
51 
52 ///////////////////////////////////////////////////////////////////////////////
54  :G4VIsotopeTable("Isomer"),
55  fIsotopeList(0)
56 {
59  return;
60 }
61 
62 ///////////////////////////////////////////////////////////////////////////////
64 {
65  if(fIsotopeList !=0) return;
66 
67  fIsotopeList = new G4IsotopeList();
68  fIsotopeList->reserve(nEntries);
69 
70  for (size_t i=0; i<nEntries; i++) {
71  G4int pid = (G4int)(isomerTable[i][idxPID]);
72  G4int ionZ = pid/10000;
73  G4int ionA = (pid-ionZ*10000)/10;
74  G4int lvl = pid%10;
75  G4double ionE = isomerTable[i][idxEnergy]*keV;
76  G4double ionLife = isomerTable[i][idxLife]*ns;
77  G4int ionJ = (G4int)(isomerTable[i][idxSpin]);
78  G4double ionMu = isomerTable[i][idxMu]*(joule/tesla);
79 
80  G4IsotopeProperty* fProperty = new G4IsotopeProperty();
81  // Set Isotope Property
82  fProperty->SetAtomicNumber(ionZ);
83  fProperty->SetAtomicMass(ionA);
84  fProperty->SetIsomerLevel(lvl);
85  fProperty->SetEnergy(ionE);
86  fProperty->SetiSpin(ionJ);
87  fProperty->SetLifeTime(ionLife);
88  fProperty->SetDecayTable(0);
89  fProperty->SetMagneticMoment(ionMu);
90 
91  fIsotopeList->push_back(fProperty);
92  }
93 }
94 
95 ///////////////////////////////////////////////////////////////////////////////
97 {
98  if (fIsotopeList!=0) {
99  for (size_t i = 0 ; i<fIsotopeList->size(); i++) {
100  delete (*fIsotopeList)[i];
101  }
102  fIsotopeList->clear();
103  delete fIsotopeList;
104  fIsotopeList = 0;
105  }
106 }
107 
108 ///////////////////////////////////////////////////////////////////////////////
110  :G4VIsotopeTable(right),
111  fIsotopeList(0)
112 {
113  FillIsotopeList();
114 }
115 
116 ///////////////////////////////////////////////////////////////////////////////
118 {
119  FillIsotopeList();
120  return *this;
121 }
122 
123 ///////////////////////////////////////////////////////////////////////////////
124 //
126 {
127  G4IsotopeProperty* fProperty = 0;
128  if ((Z<MinZ)||(Z>MaxZ)||(A>MaxA)) return fProperty; // not found
129 
130  G4int low = 0;
131  G4int high = entries() -1;
132  G4int ptr = (low+high)/2;
133 
134  // find Z
135  G4int zptr = (*fIsotopeList)[ptr]->GetAtomicNumber();
136  while ( high-low > 1){
137  if (zptr == Z){
138  while ((zptr == Z)&&(ptr>0)) {
139  ptr -= 1;
140  zptr = (*fIsotopeList)[ptr]->GetAtomicNumber();
141  }
142  if (ptr!=0) ptr += 1;
143  break;
144  } else if (zptr >Z) {
145  high = ptr;
146  ptr = (low+high)/2;
147  } else {
148  low = ptr;
149  ptr = (low+high)/2;
150  }
151  zptr = (*fIsotopeList)[ptr]->GetAtomicNumber();
152  }
153  if ( Z == (*fIsotopeList)[low]->GetAtomicNumber()) ptr =low;
154  else if ( Z != zptr ) return fProperty; // not found
155 
156  // find A
157  G4int aptr = (*fIsotopeList)[ptr]->GetAtomicMass();
158  while ( (aptr<A) && (ptr+1<(G4int)(entries())) ) {
159  ptr +=1;
160  aptr = (*fIsotopeList)[ptr]->GetAtomicMass();
161  if (Z != (*fIsotopeList)[ptr]->GetAtomicNumber()) break;
162  }
163  if ( aptr != A) return fProperty; // not found
164 
165  // find E
166  G4double ptrE = (*fIsotopeList)[ptr]->GetEnergy();
167  while ( (ptrE < E-levelTolerance ) && (ptr+1<(G4int)(entries())) ){
168  ptr +=1;
169  ptrE = (*fIsotopeList)[ptr]->GetEnergy();
170  if (A != (*fIsotopeList)[ptr]->GetAtomicMass()) return fProperty; // not found
171  }
172  if (ptrE > E+levelTolerance) return fProperty; // not found
173 
174  // FOUND !!
175  fProperty = (*fIsotopeList)[ptr];
176 
177  return fProperty;
178 
179 }
180 
181 ///////////////////////////////////////////////////////////////////////
184 {
185  G4IsotopeProperty* fProperty = 0;
186  if ((Z<MinZ)||(Z>MaxZ)||(A>MaxA)) return fProperty; // not found
187 
188  G4int low = 0;
189  G4int high = entries() -1;
190  G4int ptr = (low+high)/2;
191 
192 
193  // find PID
194  const G4int PID = 10000*Z +10*A + lvl;
195  G4int id = (fIsotopeList->at(ptr))->GetAtomicNumber() *10000
196  + (fIsotopeList->at(ptr))->GetAtomicMass() *10
197  + (fIsotopeList->at(ptr))->GetIsomerLevel();
198  while ( high-low > 1){
199  if (id == PID){
200  break;
201  } else if (id >PID) {
202  high = ptr;
203  ptr = (low+high)/2;
204  } else {
205  low = ptr;
206  ptr = (low+high)/2;
207  }
208  id = (fIsotopeList->at(ptr))->GetAtomicNumber() *10000
209  + (fIsotopeList->at(ptr))->GetAtomicMass() *10
210  + (fIsotopeList->at(ptr))->GetIsomerLevel();
211  }
212 
213  if (id == PID) {
214  fProperty = (*fIsotopeList)[ptr];
215  } else {
216  id = (fIsotopeList->at(low))->GetAtomicNumber() *10000
217  + (fIsotopeList->at(low))->GetAtomicMass() *10
218  + (fIsotopeList->at(low))->GetIsomerLevel();
219  if (id == PID) {
220  fProperty = (*fIsotopeList)[low];
221  } else {
222  id = (fIsotopeList->at(high))->GetAtomicNumber() *10000
223  + (fIsotopeList->at(high))->GetAtomicMass() *10
224  + (fIsotopeList->at(high))->GetIsomerLevel();
225  if (id == PID) fProperty = (*fIsotopeList)[high];
226  }
227  }
228  return fProperty;
229 
230 }
size_t entries() const
virtual G4IsotopeProperty * GetIsotope(G4int Z, G4int A, G4double E)
int G4int
Definition: G4Types.hh:78
G4double GetEnergy() const
G4IsomerTable & operator=(const G4IsomerTable &right)
void FillIsotopeList()
virtual ~G4IsomerTable()
static G4ParticleTable * GetParticleTable()
G4int GetVerboseLevel() const
virtual G4IsotopeProperty * GetIsotopeByIsoLvl(G4int Z, G4int A, G4int lvl=0)
double G4double
Definition: G4Types.hh:76
void SetVerboseLevel(G4int level)
#define ns
Definition: xmlparse.cc:597
G4int GetAtomicMass() const
std::vector< G4IsotopeProperty * > G4IsotopeList