| [968] | 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 | //
|
|---|
| [1192] | 26 | // $Id: G4CrossSectionPsCreationChampionPartial.cc,v 1.2 2009/06/10 13:32:36 mantero Exp $
|
|---|
| [1196] | 27 | // GEANT4 tag $Name: geant4-09-03-cand-01 $
|
|---|
| [968] | 28 | // -------------------------------------------------------------------
|
|---|
| 29 |
|
|---|
| 30 | #include "G4CrossSectionPsCreationChampionPartial.hh"
|
|---|
| 31 |
|
|---|
| 32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 33 |
|
|---|
| 34 | G4CrossSectionPsCreationChampionPartial::G4CrossSectionPsCreationChampionPartial()
|
|---|
| 35 | {
|
|---|
| 36 | numberOfPartialCrossSections=2;
|
|---|
| 37 |
|
|---|
| 38 | G4double scaleFactor = 1e-16*cm*cm;
|
|---|
| 39 |
|
|---|
| 40 | G4DNACrossSectionDataSet* tablePositronium1s =
|
|---|
| 41 | new G4DNACrossSectionDataSet(new G4LogLogInterpolation, eV, scaleFactor);
|
|---|
| 42 |
|
|---|
| 43 | G4DNACrossSectionDataSet* tablePositronium2s =
|
|---|
| 44 | new G4DNACrossSectionDataSet(new G4LogLogInterpolation, eV, scaleFactor);
|
|---|
| 45 |
|
|---|
| 46 | G4String positronium1s("positronium1s");
|
|---|
| 47 | G4String filePositronium1s("dna/sigma_positronium1s_creation_champion");
|
|---|
| 48 |
|
|---|
| 49 | G4String positronium2s("positronium2s");
|
|---|
| 50 | G4String filePositronium2s("dna/sigma_positronium2s_creation_champion");
|
|---|
| 51 |
|
|---|
| 52 | tablePositronium1s->LoadData(filePositronium1s);
|
|---|
| 53 | tablePositronium2s->LoadData(filePositronium2s);
|
|---|
| 54 |
|
|---|
| 55 | tableData[positronium1s] = tablePositronium1s;
|
|---|
| 56 | tableData[positronium2s] = tablePositronium2s;
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 60 |
|
|---|
| 61 | G4CrossSectionPsCreationChampionPartial::~G4CrossSectionPsCreationChampionPartial()
|
|---|
| 62 | {
|
|---|
| 63 | std::map< G4String,G4DNACrossSectionDataSet*,std::less<G4String> >::iterator pos;
|
|---|
| 64 | for (pos = tableData.begin(); pos != tableData.end(); ++pos)
|
|---|
| 65 | {
|
|---|
| 66 | G4DNACrossSectionDataSet* table = pos->second;
|
|---|
| 67 | delete table;
|
|---|
| 68 | }
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 72 |
|
|---|
| 73 | G4double G4CrossSectionPsCreationChampionPartial::CrossSection
|
|---|
| 74 | (G4double k, G4int index, const G4ParticleDefinition* particleDefinition)
|
|---|
| 75 | {
|
|---|
| 76 | if (particleDefinition != G4Positron::PositronDefinition())
|
|---|
| 77 | G4Exception("G4CrossSectionPsCreationChampionPartial::CrossSection: attempting to calculate cross section for wrong particle");
|
|---|
| 78 |
|
|---|
| 79 | G4double sigma = 0.;
|
|---|
| 80 |
|
|---|
| 81 | std::map< G4String,G4DNACrossSectionDataSet*,std::less<G4String> >::iterator pos;
|
|---|
| 82 |
|
|---|
| 83 | if (index==0)
|
|---|
| 84 | {
|
|---|
| 85 | pos = tableData.find("positronium1s");
|
|---|
| 86 | if (pos != tableData.end())
|
|---|
| 87 | {
|
|---|
| 88 | G4DNACrossSectionDataSet* table = pos->second;
|
|---|
| 89 | if (table != 0) sigma = table->FindValue(k);
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | if (index==1)
|
|---|
| 94 | {
|
|---|
| 95 | pos = tableData.find("positronium2s");
|
|---|
| 96 | if (pos != tableData.end())
|
|---|
| 97 | {
|
|---|
| 98 | G4DNACrossSectionDataSet* table = pos->second;
|
|---|
| 99 | if (table != 0) sigma = table->FindValue(k);
|
|---|
| 100 | }
|
|---|
| 101 | }
|
|---|
| 102 | return sigma;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 106 |
|
|---|
| 107 | G4int G4CrossSectionPsCreationChampionPartial::RandomSelectState
|
|---|
| 108 | (G4double k, const G4ParticleDefinition* particleDefinition)
|
|---|
| 109 | {
|
|---|
| 110 | const G4int n = numberOfPartialCrossSections;
|
|---|
| 111 | G4double* values(new G4double[n]);
|
|---|
| 112 | G4double value = 0;
|
|---|
| 113 | G4int i = n;
|
|---|
| 114 |
|
|---|
| 115 | while (i>0)
|
|---|
| 116 | {
|
|---|
| 117 | i--;
|
|---|
| 118 | values[i]=CrossSection(k, i, particleDefinition);
|
|---|
| 119 | value+=values[i];
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | value*=G4UniformRand();
|
|---|
| 123 |
|
|---|
| 124 | i=n;
|
|---|
| 125 | while (i>0)
|
|---|
| 126 | {
|
|---|
| 127 | i--;
|
|---|
| 128 |
|
|---|
| 129 | if (values[i]>value)
|
|---|
| 130 | break;
|
|---|
| 131 |
|
|---|
| 132 | value-=values[i];
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | delete[] values;
|
|---|
| 136 |
|
|---|
| 137 | return i;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 141 |
|
|---|
| 142 | G4int G4CrossSectionPsCreationChampionPartial::RandomSelectShell
|
|---|
| 143 | (G4double k, const G4ParticleDefinition*, G4int state)
|
|---|
| 144 | {
|
|---|
| 145 | G4int level = 0;
|
|---|
| 146 |
|
|---|
| 147 | std::map< G4String,G4DNACrossSectionDataSet*,std::less<G4String> >::iterator pos;
|
|---|
| 148 |
|
|---|
| 149 | if (state==0) pos = tableData.find("positronium1s");
|
|---|
| 150 | if (state==1) pos = tableData.find("positronium2s");
|
|---|
| 151 |
|
|---|
| 152 | if (pos != tableData.end())
|
|---|
| 153 | {
|
|---|
| 154 | G4DNACrossSectionDataSet* table = pos->second;
|
|---|
| 155 |
|
|---|
| 156 | if (table != 0)
|
|---|
| 157 | {
|
|---|
| 158 | G4double* valuesBuffer = new G4double[table->NumberOfComponents()];
|
|---|
| 159 |
|
|---|
| 160 | const size_t n(table->NumberOfComponents());
|
|---|
| 161 | size_t i(n);
|
|---|
| 162 | G4double value = 0.;
|
|---|
| 163 |
|
|---|
| 164 | while (i>0)
|
|---|
| 165 | {
|
|---|
| 166 | i--;
|
|---|
| 167 | valuesBuffer[i] = table->GetComponent(i)->FindValue(k);
|
|---|
| 168 | value += valuesBuffer[i];
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | value *= G4UniformRand();
|
|---|
| 172 |
|
|---|
| 173 | i = n;
|
|---|
| 174 |
|
|---|
| 175 | while (i > 0)
|
|---|
| 176 | {
|
|---|
| 177 | i--;
|
|---|
| 178 |
|
|---|
| 179 | if (valuesBuffer[i] > value)
|
|---|
| 180 | {
|
|---|
| 181 | delete[] valuesBuffer;
|
|---|
| 182 | return i;
|
|---|
| 183 | }
|
|---|
| 184 | value -= valuesBuffer[i];
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | if (valuesBuffer) delete[] valuesBuffer;
|
|---|
| 188 |
|
|---|
| 189 | }
|
|---|
| 190 | }
|
|---|
| 191 | else
|
|---|
| 192 | {
|
|---|
| 193 | G4Exception("G4CrossSectionPsCreationChampionPartial::RandomSelectShell: attempting to calculate cross section for wrong particle");
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | return level;
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 200 |
|
|---|
| 201 | G4double G4CrossSectionPsCreationChampionPartial::Sum
|
|---|
| 202 | (G4double k, const G4ParticleDefinition* particleDefinition)
|
|---|
| 203 | {
|
|---|
| 204 | G4double totalCrossSection = 0.;
|
|---|
| 205 |
|
|---|
| 206 | for (G4int i=0; i<numberOfPartialCrossSections; i++)
|
|---|
| 207 | {
|
|---|
| 208 | totalCrossSection += CrossSection(k,i,particleDefinition);
|
|---|
| 209 | }
|
|---|
| 210 | return totalCrossSection;
|
|---|
| 211 | }
|
|---|