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 #include "G4HtmlPPReporter.hh"
00037 #include "G4ios.hh"
00038 #include "globals.hh"
00039 #include "G4SystemOfUnits.hh"
00040 #include "G4ParticleDefinition.hh"
00041 #include "G4ParticleTable.hh"
00042 #include "G4DecayTable.hh"
00043 #include "G4VDecayChannel.hh"
00044 #include "G4Tokenizer.hh"
00045 #include <iomanip>
00046
00047 G4HtmlPPReporter::G4HtmlPPReporter():G4VParticlePropertyReporter()
00048 {
00049
00050 }
00051
00052 G4HtmlPPReporter::~G4HtmlPPReporter()
00053 {
00054 }
00055
00056 void G4HtmlPPReporter::Print(const G4String& option)
00057 {
00058 SparseOption( option );
00059
00060 GenerateIndex();
00061
00062 for (size_t i=0; i< pList.size(); i++){
00063 G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle( pList[i]->GetParticleName() );
00064 GeneratePropertyTable(particle);
00065 }
00066 }
00067
00068
00069 void G4HtmlPPReporter::SparseOption(const G4String& option)
00070 {
00071 G4Tokenizer savedToken( option );
00072
00073
00074 baseDir = savedToken();
00075 if (!baseDir.isNull()) {
00076 if(baseDir(baseDir.length()-1)!='/') {
00077 baseDir += "/";
00078 }
00079 }
00080 comment = savedToken();
00081 }
00082
00083 void G4HtmlPPReporter::GenerateIndex()
00084 {
00085
00086 G4String fileName = baseDir + "index.html";
00087 std::ofstream outFile(fileName, std::ios::out );
00088 outFile.setf( std::ios:: scientific, std::ios::floatfield );
00089
00090
00091 PrintHeader(outFile);
00092
00093
00094 outFile << "<! -- " << comment << " -- !> " << G4endl;
00095 outFile << G4endl;
00096
00097
00098 outFile << sTABLE << '"' << "80%" << '"' << " > " << G4endl;
00099
00100
00101 outFile << sTR;
00102 outFile << sTD << sLFONT << "Code" << eLFONT<< eTD;
00103 outFile << sTD << sLFONT << "Name" << eLFONT<< eTD;
00104 outFile << sTD << sLFONT << "Mass" << eLFONT << eTD;
00105 outFile << sTD << sLFONT << "Charge" << eLFONT << eTD;
00106 outFile << sTD << sLFONT << "Life Time" << eLFONT << eTD;
00107 outFile << sTD << sLFONT << "Anti-Particle" << eLFONT<< eTD;
00108 outFile << eTR << G4endl;;
00109
00110
00111 outFile << sTR;
00112 outFile << sTD << " " << eTD;
00113 outFile << sTD << " " << eTD;
00114 outFile << sTD << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD;
00115 outFile << sTD << " " << eTD;
00116 outFile << sTD << " [ns]" << eTD;
00117 outFile << sTD << " " << eTD;
00118 outFile << eTR << G4endl;;
00119
00120 for (size_t i=0; i< pList.size(); i++){
00121 if (pList[i]->GetPDGEncoding()<0) continue;
00122
00123 outFile << sTR << G4endl;;
00124
00125 outFile << sTD << pList[i]->GetPDGEncoding() << eTD << G4endl;;
00126
00127 G4String name = pList[i]->GetParticleName();
00128
00129 G4String fname = name +".html";
00130
00131 if (name == "J/psi") fname = "jpsi.html";
00132
00133 outFile << sTD;
00134 outFile << "<A HREF=" << '"' << fname << '"' << ">";
00135 outFile << name << "</A>" << eTD << G4endl;
00136
00137
00138 outFile << sTD << pList[i]->GetPDGMass()/GeV << eTD << G4endl;
00139
00140
00141 outFile << sTD << pList[i]->GetPDGCharge()/eplus << eTD << G4endl;
00142
00143
00144 outFile << sTD << pList[i]->GetPDGLifeTime()/ns << eTD << G4endl;
00145
00146
00147 if ( (pList[i]->GetAntiPDGEncoding()!= 0) &&
00148 (pList[i]->GetAntiPDGEncoding() != pList[i]->GetPDGEncoding() ) ) {
00149 G4ParticleDefinition* anti_particle = G4ParticleTable::GetParticleTable()->FindParticle( pList[i]->GetAntiPDGEncoding() );
00150
00151 outFile << sTD << anti_particle->GetParticleName() << eTD << G4endl;;
00152 }
00153
00154
00155 outFile << eTR << G4endl;;
00156 }
00157
00158 outFile << eTABLE << G4endl;
00159
00160
00161 PrintFooter(outFile);
00162
00163 }
00164
00165 void G4HtmlPPReporter::GeneratePropertyTable(const G4ParticleDefinition* particle)
00166 {
00167 if (particle->GetPDGEncoding()<0) return;
00168
00169 G4String name = particle->GetParticleName();
00170
00171 G4String fileName = baseDir + name + ".html";
00172
00173 if (name == "J/psi") fileName = baseDir +"jpsi.html";
00174 std::ofstream outFile(fileName, std::ios::out );
00175 outFile.setf( std::ios:: scientific, std::ios::floatfield );
00176 outFile << std::setprecision(7) << G4endl;
00177
00178 PrintHeader(outFile);
00179
00180
00181 outFile << "<H2>" << name << "</H2>" << G4endl;
00182 outFile << "<HR>" << G4endl;
00183
00184
00185 outFile << sTABLE << '"' << "40%" << '"' << " > " << G4endl;
00186 outFile << sTR << sTD << sB << "PDG encoding" << eB << eTD;
00187 outFile << sTD << particle->GetPDGEncoding() << eTD << eTR << G4endl;
00188 outFile << sTR << sTD << sB << "Type" << eB << eTD;
00189 outFile << sTD << particle->GetParticleType() << eTD << eTR << G4endl;
00190 outFile << eTABLE << G4endl;
00191 outFile << "<HR>" << G4endl;
00192
00193
00194 outFile << sTABLE << '"' << "60%" << '"' << " > " << G4endl;
00195
00196 outFile << sTR << sTD << sB << "Mass" << eB << eTD;
00197 outFile << sTD << particle->GetPDGMass()/GeV;
00198 outFile << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD << eTR << G4endl;
00199
00200 outFile << sTR << sTD << sB << "Width" << eB << eTD;
00201 outFile << sTD << particle->GetPDGWidth()/GeV;
00202 outFile << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD << eTR << G4endl;
00203
00204 outFile << sTR << sTD << sB << "I J" << sSUP << "PC"<< eSUP << eB << eTD;
00205 if ( particle->GetPDGiIsospin() <0 ) {
00206 outFile << sTD << " ";
00207 } else if ( particle->GetPDGiIsospin() == 1) {
00208 outFile << sTD << "1/2 ";
00209 } else if ( particle->GetPDGiIsospin() == 3) {
00210 outFile << sTD << "3/2 ";
00211 } else {
00212 outFile << sTD << particle->GetPDGiIsospin()/2 << " ";
00213 }
00214 if ( particle->GetPDGiSpin() == 1) {
00215 outFile << "1/2";
00216 } else if ( particle->GetPDGiSpin() == 3) {
00217 outFile << "3/2";
00218 } else if ( particle->GetPDGiSpin() == 5) {
00219 outFile << "5/2";
00220 } else if ( particle->GetPDGiSpin() == 7) {
00221 outFile << "7/2";
00222 } else if ( particle->GetPDGiSpin() == 9) {
00223 outFile << "9/2";
00224 } else if ( particle->GetPDGiSpin() == 11) {
00225 outFile << "11/2";
00226 } else if ( particle->GetPDGiSpin() == 13) {
00227 outFile << "13/2";
00228 } else {
00229 outFile << particle->GetPDGiSpin()/2;
00230 }
00231 outFile << sSUP << sSYMBOL;
00232 if (particle->GetPDGiParity() == +1 ){
00233 outFile << "+";
00234 } else if (particle->GetPDGiParity() == -1 ){
00235 outFile << "-";
00236 } else {
00237 outFile << " ";
00238 }
00239 if (particle->GetPDGiConjugation() == +1 ){
00240 outFile << "+";
00241 } else if (particle->GetPDGiConjugation() == -1 ){
00242 outFile << "-";
00243 } else {
00244 outFile << " ";
00245 }
00246 outFile << eSYMBOL << eSUP;
00247 outFile << eTD << eTR << G4endl;
00248
00249 outFile << sTR << sTD << sB << "Charge" << eB << eTD;
00250 outFile << sTD << particle->GetPDGCharge()/eplus;
00251 outFile << eTD << eTR << G4endl;
00252
00253 outFile << sTR << sTD << sB << "Magnetic Moment" << eB << eTD;
00254 if (particle->GetPDGMagneticMoment() != 0.0){
00255 outFile << sTD << particle->GetPDGMagneticMoment()/MeV*tesla;
00256 outFile << "[MeV/T]" << eTD << eTR << G4endl;
00257 } else {
00258 outFile << sTD << " not defined ";
00259 outFile << eTD << eTR << G4endl;
00260 }
00261
00262 outFile << sTR << sTD << sB << "Life Time" << eB << eTD;
00263 if ( particle->GetPDGLifeTime() >0.0 ) {
00264 outFile << sTD << particle->GetPDGLifeTime()/second;
00265 outFile << "[sec]" << eTD << G4endl;
00266 } else {
00267 if (particle->GetPDGStable()) {
00268 outFile << sTD << "stable" << eTD;
00269 } else if (particle->IsShortLived()) {
00270 outFile << sTD << "short-lived" << eTD;
00271 } else {
00272 outFile << sTD << "not Defined" << eTD;
00273 }
00274 }
00275 outFile << eTR << G4endl;
00276
00277 outFile << eTABLE << G4endl;
00278 outFile << "<HR>" << G4endl;
00279
00280
00281 outFile << "<H2>" << " Quark Content " << "</H2>" << G4endl;
00282
00283 outFile << sTABLE << '"' << "60%" << '"' << " > " << G4endl;
00284
00285 outFile << sTR;
00286 outFile << sTD << sB << "flavour " << eB << eTD ;
00287 outFile << sTD << sB << " quark " << eB << eTD;
00288 outFile << sTD << sB << " anti-quark " << eB << eTD;
00289 outFile << eTR;
00290
00291 static const char* quarkName[6] = { "d", "u", "s", "c", "b", "t" };
00292 for (G4int flv = 0; flv <6 ; flv++ ){
00293 outFile << sTR;
00294 outFile << sTD << sB << quarkName[flv] << eB << eTD ;
00295 outFile << sTD << sB << particle->GetQuarkContent(flv+1) << eB << eTD ;
00296 outFile << sTD << sB << particle->GetAntiQuarkContent(flv+1) << eB << eTD ;
00297 outFile << eTR;
00298 }
00299 outFile << eTABLE << G4endl;
00300 outFile << "<HR>" << G4endl;
00301
00302
00303 G4DecayTable* dcyTable = particle->GetDecayTable();
00304 if (dcyTable != 0) {
00305 outFile << "<H2>" << " Decay Table " << "</H2>" << G4endl;
00306
00307 outFile << sTABLE << '"' << "80%" << '"' << " > " << G4endl;
00308
00309 outFile << sTR;
00310 outFile << sTD << sB << "BR" << eB << eTD ;
00311 outFile << sTD << sB << "kinematics" << eB << eTD;
00312 outFile << eTR;
00313
00314 for (G4int i=0; i< dcyTable->entries(); i++){
00315 G4VDecayChannel * channel = dcyTable->GetDecayChannel(i);
00316 outFile << sTR << G4endl;;
00317
00318 outFile << sTD << channel->GetBR() << eTD;
00319
00320 outFile << sTD << channel->GetKinematicsName() << eTD;
00321
00322 for (G4int j=0; j< channel->GetNumberOfDaughters(); j++){
00323 outFile << sTD << channel->GetDaughter(j)->GetParticleName() << eTD;
00324 }
00325 outFile << eTR << G4endl;
00326 }
00327 outFile << eTABLE << G4endl;
00328 outFile << "<HR>" << G4endl;
00329 }
00330
00331 outFile << sB;
00332 outFile << "<A HREF=" << '"' << "index.html" << '"' << ">back to index</A>";
00333 outFile << eB << G4endl;
00334
00335 PrintFooter(outFile);
00336 }
00337
00338 void G4HtmlPPReporter::PrintHeader(std::ofstream& outFile)
00339 {
00340 outFile << "<HTML>" << G4endl;
00341 outFile << "<HEAD>" << G4endl;
00342 outFile << " <META HTTP-EQUIV=" << "\"" << " Content-Type" << "\"";
00343 outFile << " CONTENT="
00344 << "\"" << "text/html; charset=iso-8859-1"
00345 << "\"" << ">" << G4endl;
00346 outFile << " <TITLE>Geant4 Particle List </TITLE>" << G4endl;
00347 outFile << "</HEAD>" << G4endl;
00348 outFile << "<! -- Generated automatically by Geant4, "
00349 << " -- !>" << G4endl;
00350 outFile << "<BODY>" << G4endl;
00351 }
00352
00353 void G4HtmlPPReporter::PrintFooter(std::ofstream& outFile)
00354 {
00355 outFile << "<HR>" << G4endl;
00356 outFile << "</BODY>" << G4endl;
00357 outFile << "</HTML>" << G4endl;
00358 }
00359
00360 const char* G4HtmlPPReporter::sTABLE = "<TABLE WIDTH=";
00361 const char* G4HtmlPPReporter::eTABLE = "</TABLE>";
00362 const char* G4HtmlPPReporter::sTR = "<TR>";
00363 const char* G4HtmlPPReporter::eTR = "</TR>";
00364 const char* G4HtmlPPReporter::sTD = "<TD>";
00365 const char* G4HtmlPPReporter::eTD = "</TD>";
00366 const char* G4HtmlPPReporter::sB = "<B>";
00367 const char* G4HtmlPPReporter::eB = "</B>";
00368 const char* G4HtmlPPReporter::sLFONT = "<FONT SIZE = +1>";
00369 const char* G4HtmlPPReporter::eLFONT = "</FONT>";
00370 const char* G4HtmlPPReporter::sSYMBOL = "<FONT FACE = \"symbol\" >";
00371 const char* G4HtmlPPReporter::eSYMBOL = "</FONT>";
00372 const char* G4HtmlPPReporter::sSUP = "<SUP>";
00373 const char* G4HtmlPPReporter::eSUP = "</SUP>";
00374 const char* G4HtmlPPReporter::sSUB = "<SUB>";
00375 const char* G4HtmlPPReporter::eSUB = "</SUB>";
00376
00377