00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "generators/MJGeneratorPNNLRadioisotope.hh"
00013 #include "Randomize.hh"
00014 #include <iostream.h>
00015 #include <fstream.h>
00016
00018 MJGeneratorPNNLRadioisotope::
00019 MJGeneratorPNNLRadioisotope(G4String cascade_filename) :
00020 fCascade_filename(cascade_filename)
00021 {
00022 ifstream pCascade_file((const char *)cascade_filename);
00023
00024
00025
00026
00027 if (!pCascade_file){
00028 cout << "Error in MJGeneratorPNNLRadioisotope constructor." << endl
00029 << "Could not open radioisotope cascade file "
00030 << cascade_filename << endl;
00031 cout << "Aborting." << endl;
00032 exit(1);
00033 }
00034
00035 pCascade_file >> fA >> fZ >> fNum_cascades;
00036 cout << "MJGeneratorPNNLRadioisotope:" << endl;
00037 cout << "Initiating parameters from file " << cascade_filename << endl;
00038 cout << "A: " << fA << " Z: " << fZ << " number of cascades: "
00039 << fNum_cascades << endl;
00040
00041 if (fNum_cascades <= 0) {
00042 cout << "ERROR in MJGeneratorPNNLRadioisotope constructor" << endl
00043 << "Number of cascades read from file: " << fNum_cascades << endl
00044 << "Number of cascades must be > 0 to create cascade list." << endl
00045 << "Aborting." << endl;
00046 exit(1);
00047 }
00048
00049 fCascade_list = new MJGeneratorPNNLCascade*[fNum_cascades];
00050 fBranching_fraction_list = new G4double[fNum_cascades];
00051
00052 G4double E_endpoint;
00053 G4int iparticle_type;
00054 G4int delta_L;
00055 G4int num_gammas;
00056
00057 for (G4int i=0; i<fNum_cascades; i++) {
00058 pCascade_file >> fBranching_fraction_list[i] >> E_endpoint
00059 >> iparticle_type >> delta_L >> num_gammas;
00060 G4double* pGamma_E = new G4double[num_gammas];
00061 for (G4int j=0; j<num_gammas; j++)
00062 pCascade_file >> pGamma_E[j];
00063
00064 fCascade_list[i] = new
00065 MJGeneratorPNNLCascade(iparticle_type, fA, fZ, E_endpoint, delta_L,
00066 num_gammas, pGamma_E);
00067
00068 delete [] pGamma_E;
00069 }
00070
00071 pCascade_file.close();
00072
00073 if (fNum_cascades > 1)
00074 f_pCascadeSelector = new MJGeneratorPNNLLookup(fNum_cascades,
00075 fBranching_fraction_list);
00076 }
00077
00079 MJGeneratorPNNLRadioisotope::
00080 MJGeneratorPNNLRadioisotope(const MJGeneratorPNNLRadioisotope& RadioIsotope)
00081 {
00082 fCascade_filename = RadioIsotope.fCascade_filename;
00083 fA = RadioIsotope.fA;
00084 fZ = RadioIsotope.fZ;
00085 fNum_cascades = RadioIsotope.fNum_cascades;
00086 fCascade_list = new MJGeneratorPNNLCascade*[fNum_cascades];
00087 fBranching_fraction_list = new G4double[fNum_cascades];
00088 for (G4int i=0; i<fNum_cascades; i++) {
00089 fBranching_fraction_list[i] = RadioIsotope.fBranching_fraction_list[i];
00090 fCascade_list[i] = new MJGeneratorPNNLCascade(
00091 *(RadioIsotope.fCascade_list[i]));
00092 }
00093 f_pCascadeSelector = new MJGeneratorPNNLLookup(
00094 *(RadioIsotope.f_pCascadeSelector));
00095 }
00097 void MJGeneratorPNNLRadioisotope::
00098 operator=(const MJGeneratorPNNLRadioisotope& RadioIsotope)
00099 {
00100 fCascade_filename = RadioIsotope.fCascade_filename;
00101 fA = RadioIsotope.fA;
00102 fZ = RadioIsotope.fZ;
00103 fNum_cascades = RadioIsotope.fNum_cascades;
00104 fCascade_list = new MJGeneratorPNNLCascade*[fNum_cascades];
00105 fBranching_fraction_list = new G4double[fNum_cascades];
00106 for (G4int i=0; i<fNum_cascades; i++) {
00107 fBranching_fraction_list[i] = RadioIsotope.fBranching_fraction_list[i];
00108 fCascade_list[i] = new MJGeneratorPNNLCascade(
00109 *(RadioIsotope.fCascade_list[i]));
00110 }
00111 f_pCascadeSelector = new MJGeneratorPNNLLookup(
00112 *(RadioIsotope.f_pCascadeSelector));
00113 }
00115 MJGeneratorPNNLRadioisotope::
00116 ~MJGeneratorPNNLRadioisotope()
00117 {
00118 for (G4int i=0; i<fNum_cascades; i++)
00119 delete fCascade_list[i];
00120
00121 delete [] fCascade_list;
00122 delete [] fBranching_fraction_list;
00123
00124 if (f_pCascadeSelector)
00125 delete f_pCascadeSelector;
00126 }
00127
00129 MJGeneratorPNNLCascadeEvent MJGeneratorPNNLRadioisotope::
00130 DoCascadeEvent() const {
00131
00132 G4int indx_cascade;
00133
00134 if (fNum_cascades > 1) {
00135 G4double x = G4UniformRand();
00136 indx_cascade = f_pCascadeSelector->DoLookupDiscrete(x);
00137 if ((indx_cascade < 0) || (indx_cascade >= fNum_cascades)) {
00138 cout << "ERROR in MJGeneratorPNNLRadioisotope::DoCascadeEvent" << endl
00139 << "Anomalous value for sampled cascade index" << endl
00140 << "indx_cascade = " << indx_cascade << endl
00141 << "Aborting." << endl;
00142 exit(1);
00143 }
00144 }
00145 else
00146 indx_cascade = 0;
00147
00148 MJGeneratorPNNLCascade* pCascade = fCascade_list[indx_cascade];
00149
00150 G4double E_charged_particle = pCascade->DoSampleChargedParticleEnergy();
00151 G4int num_gammas = pCascade->GetNumGammas();
00152 G4double* pGammaList = pCascade->GetGammaList();
00153
00154 MJGeneratorPNNLCascadeEvent CascadeEvent(indx_cascade, E_charged_particle,
00155 num_gammas, pGammaList);
00156
00157 return CascadeEvent;
00158
00159 }
00160
00162 void MJGeneratorPNNLRadioisotope::
00163 DoPrintCascadeList() const
00164 {
00165 for (G4int i=0; i<fNum_cascades; i++) {
00166 cout << "-----------------------" << endl;
00167 cout << "Cascade " << i << endl;
00168 fCascade_list[i]->DoPrintCascade();
00169 }
00170 }