source: trunk/source/particles/utils/src/G4HtmlPPReporter.cc@ 1225

Last change on this file since 1225 was 1196, checked in by garnier, 16 years ago

update CVS release candidate geant4.9.3.01

File size: 12.4 KB
RevLine 
[824]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// the GEANT4 collaboration.
27//
28// By copying, distributing or modifying the Program (or any work
29// based on the Program) you indicate your acceptance of this statement,
30// and all its terms.
31//
[850]32// $Id: G4HtmlPPReporter.cc,v 1.6 2008/06/08 14:05:33 kurasige Exp $
[1196]33// GEANT4 tag $Name: geant4-09-03-cand-01 $
[824]34//
35//
36// ---------------------------------------------------------------
37#include "G4HtmlPPReporter.hh"
38#include "G4ios.hh"
39#include "globals.hh"
40#include "G4DecayTable.hh"
41#include "G4Tokenizer.hh"
42#include <iomanip>
43
44 G4HtmlPPReporter::G4HtmlPPReporter():G4VParticlePropertyReporter()
45{
46
47}
48
49 G4HtmlPPReporter::~G4HtmlPPReporter()
50{
51}
52
53 void G4HtmlPPReporter::Print(const G4String& option)
54{
55 SparseOption( option );
56
57 GenerateIndex();
58
59 for (size_t i=0; i< pList.size(); i++){
60 G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle( pList[i]->GetParticleName() );
61 GeneratePropertyTable(particle);
62 }
63}
64
65
66void G4HtmlPPReporter::SparseOption(const G4String& option)
67{
68 G4Tokenizer savedToken( option );
69
70 // 1st option : base directory
71 baseDir = savedToken();
72 if (!baseDir.isNull()) {
73 if(baseDir(baseDir.length()-1)!='/') {
74 baseDir += "/";
75 }
76 }
77 comment = savedToken();
78}
79
80 void G4HtmlPPReporter::GenerateIndex()
81{
82 //--- open index file -----
83 G4String fileName = baseDir + "index.html";
84 std::ofstream outFile(fileName, std::ios::out );
85 outFile.setf( std::ios:: scientific, std::ios::floatfield );
86
87 // header
88 PrintHeader(outFile);
89
90 // comment
91 outFile << "<! -- " << comment << " --!> " << G4endl;
92 outFile << G4endl;
93
94
95 outFile << sTABLE << '"' << "80%" << '"' << " > " << G4endl;
96
97 // Raw #1
98 outFile << sTR;
99 outFile << sTD << sLFONT << "Code" << eLFONT<< eTD;
100 outFile << sTD << sLFONT << "Name" << eLFONT<< eTD;
[850]101 outFile << sTD << sLFONT << "Mass" << eLFONT << eTD;
102 outFile << sTD << sLFONT << "Charge" << eLFONT << eTD;
103 outFile << sTD << sLFONT << "Life Time" << eLFONT << eTD;
[824]104 outFile << sTD << sLFONT << "Anti-Particle" << eLFONT<< eTD;
105 outFile << eTR << G4endl;;
106
[850]107 // Raw #2
108 outFile << sTR;
109 outFile << sTD << " " << eTD;
110 outFile << sTD << " " << eTD;
111 outFile << sTD << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD;
112 outFile << sTD << " " << eTD;
113 outFile << sTD << " [ns]" << eTD;
114 outFile << sTD << " " << eTD;
115 outFile << eTR << G4endl;;
116
[824]117 for (size_t i=0; i< pList.size(); i++){
118 if (pList[i]->GetPDGEncoding()<0) continue;
119
120 outFile << sTR << G4endl;;
121 // column 1 : endcoding
122 outFile << sTD << pList[i]->GetPDGEncoding() << eTD << G4endl;;
123 // column 2 : name
124 G4String name = pList[i]->GetParticleName();
125
126 G4String fname = name +".html";
127 // exception
128 if (name == "J/psi") fname = "jpsi.html";
129
130 outFile << sTD;
131 outFile << "<A HREF=" << '"' << fname << '"' << ">";
132 outFile << name << "</A>" << eTD << G4endl;
133
[850]134 // column 3 mass
135 outFile << sTD << pList[i]->GetPDGMass()/GeV << eTD << G4endl;
136
137 // column 4 charge
138 outFile << sTD << pList[i]->GetPDGCharge()/eplus << eTD << G4endl;
139
140 // column 5 life time
141 outFile << sTD << pList[i]->GetPDGLifeTime()/ns << eTD << G4endl;
142
143 // column 6 AntiParticle
[824]144 if ( (pList[i]->GetAntiPDGEncoding()!= 0) &&
145 (pList[i]->GetAntiPDGEncoding() != pList[i]->GetPDGEncoding() ) ) {
146 G4ParticleDefinition* anti_particle = G4ParticleTable::GetParticleTable()->FindParticle( pList[i]->GetAntiPDGEncoding() );
147
148 outFile << sTD << anti_particle->GetParticleName() << eTD << G4endl;;
149 }
[850]150
151 // end raw
[824]152 outFile << eTR << G4endl;;
153 }
154
155 outFile << eTABLE << G4endl;
156
157 // footer
158 PrintFooter(outFile);
159
160}
161
162 void G4HtmlPPReporter::GeneratePropertyTable(G4ParticleDefinition* particle)
163{
164 if (particle->GetPDGEncoding()<0) return;
165
166 G4String name = particle->GetParticleName();
167 //--- open index file -----
168 G4String fileName = baseDir + name + ".html";
169 // exception
170 if (name == "J/psi") fileName = baseDir +"jpsi.html";
171 std::ofstream outFile(fileName, std::ios::out );
172 outFile.setf( std::ios:: scientific, std::ios::floatfield );
173 outFile << std::setprecision(7) << G4endl;
174
175 PrintHeader(outFile);
176
177 // particle name
178 outFile << "<H2>" << name << "</H2>" << G4endl;
179 outFile << "<HR>" << G4endl;
180
181 // encoding, type
182 outFile << sTABLE << '"' << "40%" << '"' << " > " << G4endl;
183 outFile << sTR << sTD << sB << "PDG encoding" << eB << eTD;
184 outFile << sTD << particle->GetPDGEncoding() << eTD << eTR << G4endl;
185 outFile << sTR << sTD << sB << "Type" << eB << eTD;
186 outFile << sTD << particle->GetParticleType() << eTD << eTR << G4endl;
187 outFile << eTABLE << G4endl;
188 outFile << "<HR>" << G4endl;
189
190 // Properties
191 outFile << sTABLE << '"' << "60%" << '"' << " > " << G4endl;
192 // mass
193 outFile << sTR << sTD << sB << "Mass" << eB << eTD;
194 outFile << sTD << particle->GetPDGMass()/GeV;
195 outFile << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD << eTR << G4endl;
196 // width
197 outFile << sTR << sTD << sB << "Width" << eB << eTD;
198 outFile << sTD << particle->GetPDGWidth()/GeV;
199 outFile << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD << eTR << G4endl;
200 // IJPC
201 outFile << sTR << sTD << sB << "I J" << sSUP << "PC"<< eSUP << eB << eTD;
202 if ( particle->GetPDGiIsospin() <0 ) {
203 outFile << sTD << " ";
204 } else if ( particle->GetPDGiIsospin() == 1) {
205 outFile << sTD << "1/2 ";
206 } else if ( particle->GetPDGiIsospin() == 3) {
207 outFile << sTD << "3/2 ";
208 } else {
209 outFile << sTD << particle->GetPDGiIsospin()/2 << " ";
210 }
211 if ( particle->GetPDGiSpin() == 1) {
212 outFile << "1/2";
213 } else if ( particle->GetPDGiSpin() == 3) {
214 outFile << "3/2";
215 } else if ( particle->GetPDGiSpin() == 5) {
216 outFile << "5/2";
217 } else if ( particle->GetPDGiSpin() == 7) {
218 outFile << "7/2";
219 } else if ( particle->GetPDGiSpin() == 9) {
220 outFile << "9/2";
221 } else if ( particle->GetPDGiSpin() == 11) {
222 outFile << "11/2";
223 } else if ( particle->GetPDGiSpin() == 13) {
224 outFile << "13/2";
225 } else {
226 outFile << particle->GetPDGiSpin()/2;
227 }
228 outFile << sSUP << sSYMBOL;
229 if (particle->GetPDGiParity() == +1 ){
230 outFile << "+";
231 } else if (particle->GetPDGiParity() == -1 ){
232 outFile << "-";
233 } else {
234 outFile << " ";
235 }
236 if (particle->GetPDGiConjugation() == +1 ){
237 outFile << "+";
238 } else if (particle->GetPDGiConjugation() == -1 ){
239 outFile << "-";
240 } else {
241 outFile << " ";
242 }
243 outFile << eSYMBOL << eSUP;
244 outFile << eTD << eTR << G4endl;
245 // charge
246 outFile << sTR << sTD << sB << "Charge" << eB << eTD;
247 outFile << sTD << particle->GetPDGCharge()/eplus;
248 outFile << eTD << eTR << G4endl;
249 // Magnetic Moment
250 outFile << sTR << sTD << sB << "Magnetic Moment" << eB << eTD;
251 if (particle->GetPDGMagneticMoment() != 0.0){
252 outFile << sTD << particle->GetPDGMagneticMoment()/MeV*tesla;
253 outFile << "[MeV/T]" << eTD << eTR << G4endl;
254 } else {
255 outFile << sTD << " not defined ";
256 outFile << eTD << eTR << G4endl;
257 }
258 // life time
259 outFile << sTR << sTD << sB << "Life Time" << eB << eTD;
260 if ( particle->GetPDGLifeTime() >0.0 ) {
261 outFile << sTD << particle->GetPDGLifeTime()/second;
262 outFile << "[sec]" << eTD << G4endl;
263 } else {
264 if (particle->GetPDGStable()) {
265 outFile << sTD << "stable" << eTD;
266 } else if (particle->IsShortLived()) {
267 outFile << sTD << "short-lived" << eTD;
268 } else {
269 outFile << sTD << "not Defined" << eTD;
270 }
271 }
272 outFile << eTR << G4endl;
273
274 outFile << eTABLE << G4endl;
275 outFile << "<HR>" << G4endl;
276
277 // Qurak content
278 outFile << "<H2>" << " Quark Content " << "</H2>" << G4endl;
279
280 outFile << sTABLE << '"' << "60%" << '"' << " > " << G4endl;
281
282 outFile << sTR;
283 outFile << sTD << sB << "flavour " << eB << eTD ;
284 outFile << sTD << sB << " quark " << eB << eTD;
285 outFile << sTD << sB << " anti-quark " << eB << eTD;
286 outFile << eTR;
287
288 static const char* quarkName[6] = { "d", "u", "s", "c", "b", "t" };
289 for (G4int flv = 0; flv <6 ; flv++ ){
290 outFile << sTR;
291 outFile << sTD << sB << quarkName[flv] << eB << eTD ;
292 outFile << sTD << sB << particle->GetQuarkContent(flv+1) << eB << eTD ;
293 outFile << sTD << sB << particle->GetAntiQuarkContent(flv+1) << eB << eTD ;
294 outFile << eTR;
295 }
296 outFile << eTABLE << G4endl;
297 outFile << "<HR>" << G4endl;
298
299 // Decay Table
300 G4DecayTable* dcyTable = particle->GetDecayTable();
301 if (dcyTable != 0) {
302 outFile << "<H2>" << " Decay Table " << "</H2>" << G4endl;
303
304 outFile << sTABLE << '"' << "80%" << '"' << " > " << G4endl;
305
306 outFile << sTR;
307 outFile << sTD << sB << "BR" << eB << eTD ;
308 outFile << sTD << sB << "kinematics" << eB << eTD;
309 outFile << eTR;
310
311 for (G4int i=0; i< dcyTable->entries(); i++){
312 G4VDecayChannel * channel = dcyTable->GetDecayChannel(i);
313 outFile << sTR << G4endl;;
314 // column 1 : BR
315 outFile << sTD << channel->GetBR() << eTD;
316 // column 2 : Kinematics
317 outFile << sTD << channel->GetKinematicsName() << eTD;
318 // column 3.. : daughters
319 for (G4int j=0; j< channel->GetNumberOfDaughters(); j++){
320 outFile << sTD << channel->GetDaughter(j)->GetParticleName() << eTD;
321 }
322 outFile << eTR << G4endl;
323 }
324 outFile << eTABLE << G4endl;
325 outFile << "<HR>" << G4endl;
326 }
327
328 outFile << sB;
329 outFile << "<A HREF=" << '"' << "index.html" << '"' << ">back to index</A>";
330 outFile << eB << G4endl;
331
332 PrintFooter(outFile);
333}
334
335 void G4HtmlPPReporter::PrintHeader(std::ofstream& outFile)
336{
337 outFile << "<HTML>" << G4endl;
338 outFile << "<HEAD>" << G4endl;
339 outFile << " <META HTTP-EQUIV=" << "\"" << " Content-Type" << "\"";
340 outFile << " CONTENT=" << "\"" << "text/html; charset=iso-8859-1" << "\"" << ">" << G4endl;
341 outFile << " <TITLE>Geant4 Particle List </TITLE>" << G4endl;
342 outFile << "</HEAD>" << G4endl;
343 outFile << "<!-- Generated automatically by Geant4, ";
344 outFile << " -- >" << G4endl;
345 outFile << "<BODY>" << G4endl;
346}
347
348 void G4HtmlPPReporter::PrintFooter(std::ofstream& outFile)
349{
350 outFile << "<HR>" << G4endl;
351 outFile << "</BODY>" << G4endl;
352 outFile << "</HTML>" << G4endl;
353}
354
355const char* G4HtmlPPReporter::sTABLE = "<TABLE WIDTH=";
356const char* G4HtmlPPReporter::eTABLE = "</TABLE>";
357const char* G4HtmlPPReporter::sTR = "<TR>";
358const char* G4HtmlPPReporter::eTR = "</TR>";
359const char* G4HtmlPPReporter::sTD = "<TD>";
360const char* G4HtmlPPReporter::eTD = "</TD>";
361const char* G4HtmlPPReporter::sB = "<B>";
362const char* G4HtmlPPReporter::eB = "</B>";
363const char* G4HtmlPPReporter::sLFONT = "<FONT SIZE = +1>";
364const char* G4HtmlPPReporter::eLFONT = "</FONT>";
365const char* G4HtmlPPReporter::sSYMBOL = "<FONT FACE = \"symbol\" >";
366const char* G4HtmlPPReporter::eSYMBOL = "</FONT>";
367const char* G4HtmlPPReporter::sSUP = "<SUP>";
368const char* G4HtmlPPReporter::eSUP = "</SUP>";
369const char* G4HtmlPPReporter::sSUB = "<SUB>";
370const char* G4HtmlPPReporter::eSUB = "</SUB>";
371
372
Note: See TracBrowser for help on using the repository browser.