00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "G4ComponentSAIDTotalXS.hh"
00041 #include "G4PhysicsVector.hh"
00042 #include "G4LPhysicsFreeVector.hh"
00043 #include "G4HadronicException.hh"
00044
00045 G4String G4ComponentSAIDTotalXS::fnames[13] = {
00046 "","pp","np","pip","pim",
00047 "pin","pie",
00048 "gp_pi0p","gp_pi+n","gn_pi-p","gn_pi0n","gp_etap","gp_etapp"
00049 };
00050 G4PhysicsVector* G4ComponentSAIDTotalXS::elastdata[13] = {0};
00051 G4PhysicsVector* G4ComponentSAIDTotalXS::inelastdata[13] = {0};
00052
00053 G4ComponentSAIDTotalXS::G4ComponentSAIDTotalXS()
00054 : G4VComponentCrossSection("xsSAID"),numberOfSaidXS(13)
00055 {}
00056
00057 G4ComponentSAIDTotalXS::~G4ComponentSAIDTotalXS()
00058 {
00059 for(G4int i=0; i<numberOfSaidXS; ++i) {
00060 if(elastdata[i]) {
00061 delete elastdata[i];
00062 elastdata[i] = 0;
00063 }
00064 if(inelastdata[i]) {
00065 delete inelastdata[i];
00066 inelastdata[i] = 0;
00067 }
00068 }
00069 }
00070
00071 G4double
00072 G4ComponentSAIDTotalXS::GetTotalElementCrossSection(
00073 const G4ParticleDefinition* part,
00074 G4double, G4int Z, G4double N)
00075 {
00076 PrintWarning(part,0,Z,G4lrint(N),
00077 "G4ComponentSAIDTotalXS::GetTotalElementCrossSection",
00078 "Method is not implemented");
00079 return 0.0;
00080 }
00081
00082 G4double
00083 G4ComponentSAIDTotalXS::GetTotalIsotopeCrossSection(
00084 const G4ParticleDefinition* part,
00085 G4double kinEnergy, G4int Z, G4int N)
00086 {
00087 return GetInelasticIsotopeCrossSection(part,kinEnergy,Z,N)
00088 + GetElasticIsotopeCrossSection(part,kinEnergy,Z,N);
00089 }
00090
00091 G4double
00092 G4ComponentSAIDTotalXS::GetInelasticElementCrossSection(
00093 const G4ParticleDefinition* part,
00094 G4double, G4int Z, G4double N)
00095 {
00096 PrintWarning(part,0,Z,G4lrint(N),
00097 "G4ComponentSAIDTotalXS::GetTotalElementCrossSection",
00098 "Method is not implemented");
00099 return 0.0;
00100 }
00101
00102 G4double
00103 G4ComponentSAIDTotalXS::GetInelasticIsotopeCrossSection(
00104 const G4ParticleDefinition* part,
00105 G4double kinEnergy, G4int Z, G4int N)
00106 {
00107 G4double cross = 0.0;
00108 G4SAIDCrossSectionType tp = GetType(part,0,Z,N);
00109 if(saidUnknown != tp) {
00110 G4int idx = G4int(tp);
00111 if(!inelastdata[idx]) { Initialise(tp); }
00112 if(inelastdata[idx]) {
00113 cross = (inelastdata[idx])->Value(kinEnergy);
00114 }
00115 }
00116 return cross;
00117 }
00118
00119 G4double
00120 G4ComponentSAIDTotalXS::GetElasticElementCrossSection(
00121 const G4ParticleDefinition* part,
00122 G4double, G4int Z, G4double N)
00123 {
00124 PrintWarning(part,0,Z,G4lrint(N),
00125 "G4ComponentSAIDTotalXS::GetTotalElementCrossSection",
00126 "Method is not implemented");
00127 return 0.0;
00128 }
00129
00130 G4double
00131 G4ComponentSAIDTotalXS::GetElasticIsotopeCrossSection(
00132 const G4ParticleDefinition* part,
00133 G4double kinEnergy, G4int Z, G4int N)
00134 {
00135 G4double cross = 0.0;
00136 G4SAIDCrossSectionType tp = GetType(part,0,Z,N);
00137 if(saidUnknown != tp) {
00138 G4int idx = G4int(tp);
00139 if(!elastdata[idx]) { Initialise(tp); }
00140 if(elastdata[idx]) {
00141 cross = (elastdata[idx])->Value(kinEnergy);
00142 }
00143 }
00144 return cross;
00145 }
00146
00147 G4double
00148 G4ComponentSAIDTotalXS::GetChargeExchangeCrossSection(
00149 const G4ParticleDefinition* prim,
00150 const G4ParticleDefinition* sec,
00151 G4double kinEnergy, G4int Z, G4int N)
00152 {
00153 G4double cross = 0.0;
00154 G4SAIDCrossSectionType tp = GetType(prim,sec,Z,N);
00155 if(saidUnknown != tp) {
00156 G4int idx = G4int(tp);
00157 if(!inelastdata[idx]) { Initialise(tp); }
00158 if(inelastdata[idx]) {
00159 cross = (inelastdata[idx])->Value(kinEnergy);
00160 }
00161 }
00162 return cross;
00163 }
00164
00165 void
00166 G4ComponentSAIDTotalXS::Description() const
00167 {
00168 }
00169
00170 G4SAIDCrossSectionType
00171 G4ComponentSAIDTotalXS::GetType(const G4ParticleDefinition* prim,
00172 const G4ParticleDefinition* sec,
00173 G4int Z, G4int N)
00174 {
00175 G4SAIDCrossSectionType type = saidUnknown;
00176 if(1 == N && prim) {
00177 G4int code = prim->GetPDGEncoding();
00178
00179
00180 if(0 == Z && sec && 22 == code) {
00181 G4int code1 = sec->GetPDGEncoding();
00182 if(-211 == code1) { type = saidGN_PINP; }
00183 else if(111 == code1) { type = saidGN_PI0N; }
00184
00185
00186 } else if(1 == Z) {
00187 if(sec) {
00188 G4int code1 = sec->GetPDGEncoding();
00189 if(-211 == code) {
00190 if(111 == code1) { type = saidPINP_PI0N; }
00191 else if(221 == code1) { type = saidPINP_ETAN; }
00192
00193 } else if(22 == code) {
00194 if(111 == code1) { type = saidGP_PI0P; }
00195 else if(211 == code1) { type = saidGP_PIPN; }
00196 else if(221 == code1) { type = saidGP_ETAP; }
00197 else if(331 == code1) { type = saidGP_ETAPP; }
00198 }
00199 } else {
00200 if(2212 == code) { type = saidPP; }
00201 else if(2112 == code) { type = saidNP; }
00202 else if(211 == code) { type = saidPIPP; }
00203 else if(-211 == code) { type = saidPINP; }
00204 }
00205 }
00206 }
00207
00208 return type;
00209 }
00210
00211 void G4ComponentSAIDTotalXS::Initialise(G4SAIDCrossSectionType tp)
00212 {
00213 G4int idx = G4int(tp);
00214
00215
00216 char* path = getenv("G4SAIDXSDATA");
00217 if (!path){
00218 throw G4HadronicException(__FILE__, __LINE__,
00219 "G4SAIDXSDATA environment variable not defined");
00220 return;
00221 }
00222 if(idx <= 4) {
00223 elastdata[idx] = new G4LPhysicsFreeVector();
00224 inelastdata[idx] = new G4LPhysicsFreeVector();
00225 ReadData(idx,elastdata[idx],path,"_el.dat");
00226 ReadData(idx,inelastdata[idx],path,"_in.dat");
00227 } else {
00228 inelastdata[idx] = new G4LPhysicsFreeVector();
00229 ReadData(idx,inelastdata[idx],path,".dat");
00230 }
00231 }
00232
00233 void G4ComponentSAIDTotalXS::ReadData(G4int index,
00234 G4PhysicsVector* v,
00235 const G4String& ss1,
00236 const G4String& ss2)
00237 {
00238 std::ostringstream ost;
00239 ost << ss1 << "/" << fnames[index] << ss2;
00240 std::ifstream filein(ost.str().c_str());
00241 if (!(filein)) {
00242 G4cout << ost.str() << " is not opened by G4ComponentSAIDTotalXS"
00243 << G4endl;
00244 G4String sss(ost.str());
00245 throw G4HadronicException(__FILE__, __LINE__,
00246 "Data file " + sss +
00247 " is not opened," +
00248 "chech that G4SAIDXSDATA correctly set");
00249
00250 } else {
00251 if(GetVerboseLevel() > 1) {
00252 G4cout << "File " << ost.str()
00253 << " is opened by G4ComponentSAIDTotalXS" << G4endl;
00254 }
00255
00256 v->Retrieve(filein, true);
00257 v->ScaleVector(CLHEP::MeV,CLHEP::millibarn);
00258 v->SetSpline(true);
00259 }
00260 }
00261
00262 void
00263 G4ComponentSAIDTotalXS::PrintWarning(const G4ParticleDefinition* prim,
00264 const G4ParticleDefinition* sec,
00265 G4int Z, G4int N,
00266 const G4String& ss1,
00267 const G4String& ss2)
00268 {
00269 G4cout << ss1 << ": " << ss2 << G4endl;
00270 G4cout << "For Z= " << Z << " N= " << N << " of ";
00271 if(prim) { G4cout << prim->GetParticleName() << " "; }
00272 if(sec) { G4cout << " x-section to " << sec->GetParticleName(); }
00273 G4cout << G4endl;
00274 }