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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /particles/utils/src/G4HtmlPPReporter.cc (Version 11.3.0) and /particles/utils/src/G4HtmlPPReporter.cc (Version 5.0)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25                                                   
 26 #include "G4HtmlPPReporter.hh"                    
 27                                                   
 28 #include "G4DecayTable.hh"                        
 29 #include "G4ParticleDefinition.hh"                
 30 #include "G4ParticleTable.hh"                     
 31 #include "G4SystemOfUnits.hh"                     
 32 #include "G4Tokenizer.hh"                         
 33 #include "G4VDecayChannel.hh"                     
 34 #include "G4ios.hh"                               
 35 #include "globals.hh"                             
 36                                                   
 37 #include <iomanip>                                
 38                                                   
 39 void G4HtmlPPReporter::Print(const G4String& o    
 40 {                                                 
 41   SparseOption(option);                           
 42                                                   
 43   GenerateIndex();                                
 44                                                   
 45   for (const auto& i : pList) {                   
 46     G4ParticleDefinition* particle =              
 47       G4ParticleTable::GetParticleTable()->Fin    
 48     GeneratePropertyTable(particle);              
 49   }                                               
 50 }                                                 
 51                                                   
 52 void G4HtmlPPReporter::SparseOption(const G4St    
 53 {                                                 
 54   G4Tokenizer savedToken(option);                 
 55                                                   
 56   // 1st option : base directory                  
 57   baseDir = savedToken();                         
 58   if (!baseDir.empty()) {                         
 59     if (baseDir.back() != '/') {                  
 60       baseDir += "/";                             
 61     }                                             
 62   }                                               
 63   comment = savedToken();                         
 64 }                                                 
 65                                                   
 66 void G4HtmlPPReporter::GenerateIndex()            
 67 {                                                 
 68   //--- open index file -----                     
 69   G4String fileName = baseDir + "index.html";     
 70   std::ofstream outFile(fileName, std::ios::ou    
 71   outFile.setf(std::ios::scientific, std::ios:    
 72                                                   
 73   // header                                       
 74   PrintHeader(outFile);                           
 75                                                   
 76   // comment                                      
 77   outFile << "<! -- " << comment << " -- !> "     
 78   outFile << G4endl;                              
 79                                                   
 80   outFile << sTABLE << '"' << "80%" << '"' <<     
 81                                                   
 82   // Raw #1                                       
 83   outFile << sTR;                                 
 84   outFile << sTD << sLFONT << "Code" << eLFONT    
 85   outFile << sTD << sLFONT << "Name" << eLFONT    
 86   outFile << sTD << sLFONT << "Mass" << eLFONT    
 87   outFile << sTD << sLFONT << "Charge" << eLFO    
 88   outFile << sTD << sLFONT << "Life Time" << e    
 89   outFile << sTD << sLFONT << "Anti-Particle"     
 90   outFile << eTR << G4endl;                       
 91   ;                                               
 92                                                   
 93   // Raw #2                                       
 94   outFile << sTR;                                 
 95   outFile << sTD << " " << eTD;                   
 96   outFile << sTD << " " << eTD;                   
 97   outFile << sTD << " [GeV/c" << sSUP << "2" <    
 98   outFile << sTD << " " << eTD;                   
 99   outFile << sTD << " [ns]" << eTD;               
100   outFile << sTD << " " << eTD;                   
101   outFile << eTR << G4endl;                       
102   ;                                               
103                                                   
104   for (const auto& i : pList) {                   
105     if (i->GetPDGEncoding() < 0) continue;        
106                                                   
107     outFile << sTR << G4endl;                     
108     ;                                             
109     // column 1  : endcoding                      
110     outFile << sTD << i->GetPDGEncoding() << e    
111     ;                                             
112     // column 2  : name                           
113     G4String name = i->GetParticleName();         
114                                                   
115     G4String fname = name + ".html";              
116     // exception                                  
117     if (name == "J/psi") fname = "jpsi.html";     
118                                                   
119     outFile << sTD;                               
120     outFile << "<A HREF=" << '"' << fname << '    
121     outFile << name << "</A>" << eTD << G4endl    
122                                                   
123     // column 3 mass                              
124     outFile << sTD << i->GetPDGMass() / GeV <<    
125                                                   
126     // column 4 charge                            
127     outFile << sTD << i->GetPDGCharge() / eplu    
128                                                   
129     // column 5 life time                         
130     outFile << sTD << i->GetPDGLifeTime() / ns    
131                                                   
132     // column 6 AntiParticle                      
133     if ((i->GetAntiPDGEncoding() != 0) && (i->    
134       G4ParticleDefinition* anti_particle =       
135         G4ParticleTable::GetParticleTable()->F    
136                                                   
137       outFile << sTD << anti_particle->GetPart    
138       ;                                           
139     }                                             
140                                                   
141     // end raw                                    
142     outFile << eTR << G4endl;                     
143     ;                                             
144   }                                               
145                                                   
146   outFile << eTABLE << G4endl;                    
147                                                   
148   // footer                                       
149   PrintFooter(outFile);                           
150 }                                                 
151                                                   
152 void G4HtmlPPReporter::GeneratePropertyTable(c    
153 {                                                 
154   if (particle->GetPDGEncoding() < 0) return;     
155                                                   
156   G4String name = particle->GetParticleName();    
157   //--- open index file -----                     
158   G4String fileName = baseDir + name + ".html"    
159   // exception                                    
160   if (name == "J/psi") fileName = baseDir + "j    
161   std::ofstream outFile(fileName, std::ios::ou    
162   outFile.setf(std::ios::scientific, std::ios:    
163   outFile << std::setprecision(7) << G4endl;      
164                                                   
165   PrintHeader(outFile);                           
166                                                   
167   // particle name                                
168   outFile << "<H2>" << name << "</H2>" << G4en    
169   outFile << "<HR>" << G4endl;                    
170                                                   
171   // encoding, type                               
172   outFile << sTABLE << '"' << "40%" << '"' <<     
173   outFile << sTR << sTD << sB << "PDG encoding    
174   outFile << sTD << particle->GetPDGEncoding()    
175   outFile << sTR << sTD << sB << "Type" << eB     
176   outFile << sTD << particle->GetParticleType(    
177   outFile << eTABLE << G4endl;                    
178   outFile << "<HR>" << G4endl;                    
179                                                   
180   // Properties                                   
181   outFile << sTABLE << '"' << "60%" << '"' <<     
182   // mass                                         
183   outFile << sTR << sTD << sB << "Mass" << eB     
184   outFile << sTD << particle->GetPDGMass() / G    
185   outFile << " [GeV/c" << sSUP << "2" << eSUP     
186   // width                                        
187   outFile << sTR << sTD << sB << "Width" << eB    
188   outFile << sTD << particle->GetPDGWidth() /     
189   outFile << " [GeV/c" << sSUP << "2" << eSUP     
190   // IJPC                                         
191   outFile << sTR << sTD << sB << "I J" << sSUP    
192   if (particle->GetPDGiIsospin() < 0) {           
193     outFile << sTD << "    ";                     
194   }                                               
195   else if (particle->GetPDGiIsospin() == 1) {     
196     outFile << sTD << "1/2 ";                     
197   }                                               
198   else if (particle->GetPDGiIsospin() == 3) {     
199     outFile << sTD << "3/2 ";                     
200   }                                               
201   else {                                          
202     outFile << sTD << particle->GetPDGiIsospin    
203   }                                               
204   if (particle->GetPDGiSpin() == 1) {             
205     outFile << "1/2";                             
206   }                                               
207   else if (particle->GetPDGiSpin() == 3) {        
208     outFile << "3/2";                             
209   }                                               
210   else if (particle->GetPDGiSpin() == 5) {        
211     outFile << "5/2";                             
212   }                                               
213   else if (particle->GetPDGiSpin() == 7) {        
214     outFile << "7/2";                             
215   }                                               
216   else if (particle->GetPDGiSpin() == 9) {        
217     outFile << "9/2";                             
218   }                                               
219   else if (particle->GetPDGiSpin() == 11) {       
220     outFile << "11/2";                            
221   }                                               
222   else if (particle->GetPDGiSpin() == 13) {       
223     outFile << "13/2";                            
224   }                                               
225   else {                                          
226     outFile << particle->GetPDGiSpin() / 2;       
227   }                                               
228   outFile << sSUP << sSYMBOL;                     
229   if (particle->GetPDGiParity() == +1) {          
230     outFile << "+";                               
231   }                                               
232   else if (particle->GetPDGiParity() == -1) {     
233     outFile << "-";                               
234   }                                               
235   else {                                          
236     outFile << " ";                               
237   }                                               
238   if (particle->GetPDGiConjugation() == +1) {     
239     outFile << "+";                               
240   }                                               
241   else if (particle->GetPDGiConjugation() == -    
242     outFile << "-";                               
243   }                                               
244   else {                                          
245     outFile << " ";                               
246   }                                               
247   outFile << eSYMBOL << eSUP;                     
248   outFile << eTD << eTR << G4endl;                
249   // charge                                       
250   outFile << sTR << sTD << sB << "Charge" << e    
251   outFile << sTD << particle->GetPDGCharge() /    
252   outFile << eTD << eTR << G4endl;                
253   // Magnetic Moment                              
254   outFile << sTR << sTD << sB << "Magnetic Mom    
255   if (particle->GetPDGMagneticMoment() != 0.0)    
256     outFile << sTD << particle->GetPDGMagnetic    
257     outFile << "[MeV/T]" << eTD << eTR << G4en    
258   }                                               
259   else {                                          
260     outFile << sTD << " not defined ";            
261     outFile << eTD << eTR << G4endl;              
262   }                                               
263   // life time                                    
264   outFile << sTR << sTD << sB << "Life Time" <    
265   if (particle->GetPDGLifeTime() > 0.0) {         
266     outFile << sTD << particle->GetPDGLifeTime    
267     outFile << "[sec]" << eTD << G4endl;          
268   }                                               
269   else {                                          
270     if (particle->GetPDGStable()) {               
271       outFile << sTD << "stable" << eTD;          
272     }                                             
273     else if (particle->IsShortLived()) {          
274       outFile << sTD << "short-lived" << eTD;     
275     }                                             
276     else {                                        
277       outFile << sTD << "not Defined" << eTD;     
278     }                                             
279   }                                               
280   outFile << eTR << G4endl;                       
281                                                   
282   outFile << eTABLE << G4endl;                    
283   outFile << "<HR>" << G4endl;                    
284                                                   
285   // Qurak content                                
286   outFile << "<H2>"                               
287           << " Quark Content "                    
288           << "</H2>" << G4endl;                   
289                                                   
290   outFile << sTABLE << '"' << "60%" << '"' <<     
291                                                   
292   outFile << sTR;                                 
293   outFile << sTD << sB << "flavour " << eB <<     
294   outFile << sTD << sB << " quark " << eB << e    
295   outFile << sTD << sB << " anti-quark " << eB    
296   outFile << eTR;                                 
297                                                   
298   static const char* quarkName[6] = {"d", "u",    
299   for (G4int flv = 0; flv < 6; flv++) {           
300     outFile << sTR;                               
301     outFile << sTD << sB << quarkName[flv] <<     
302     outFile << sTD << sB << particle->GetQuark    
303     outFile << sTD << sB << particle->GetAntiQ    
304     outFile << eTR;                               
305   }                                               
306   outFile << eTABLE << G4endl;                    
307   outFile << "<HR>" << G4endl;                    
308                                                   
309   // Decay Table                                  
310   G4DecayTable* dcyTable = particle->GetDecayT    
311   if (dcyTable != nullptr) {                      
312     outFile << "<H2>"                             
313             << " Decay Table "                    
314             << "</H2>" << G4endl;                 
315                                                   
316     outFile << sTABLE << '"' << "80%" << '"' <    
317                                                   
318     outFile << sTR;                               
319     outFile << sTD << sB << "BR" << eB << eTD;    
320     outFile << sTD << sB << "kinematics" << eB    
321     outFile << eTR;                               
322                                                   
323     for (G4int i = 0; i < dcyTable->entries();    
324       G4VDecayChannel* channel = dcyTable->Get    
325       outFile << sTR << G4endl;                   
326       ;                                           
327       // column 1  : BR                           
328       outFile << sTD << channel->GetBR() << eT    
329       // column 2 : Kinematics                    
330       outFile << sTD << channel->GetKinematics    
331       // column 3..  : daughters                  
332       for (G4int j = 0; j < channel->GetNumber    
333         outFile << sTD << channel->GetDaughter    
334       }                                           
335       outFile << eTR << G4endl;                   
336     }                                             
337     outFile << eTABLE << G4endl;                  
338     outFile << "<HR>" << G4endl;                  
339   }                                               
340                                                   
341   outFile << sB;                                  
342   outFile << "<A HREF=" << '"' << "index.html"    
343   outFile << eB << G4endl;                        
344                                                   
345   PrintFooter(outFile);                           
346 }                                                 
347                                                   
348 void G4HtmlPPReporter::PrintHeader(std::ofstre    
349 {                                                 
350   outFile << "<HTML>" << G4endl;                  
351   outFile << "<HEAD>" << G4endl;                  
352   outFile << " <META HTTP-EQUIV="                 
353           << "\""                                 
354           << " Content-Type"                      
355           << "\"";                                
356   outFile << " CONTENT="                          
357           << "\""                                 
358           << "text/html; charset=iso-8859-1"      
359           << "\""                                 
360           << ">" << G4endl;                       
361   outFile << " <TITLE>Geant4 Particle List </T    
362   outFile << "</HEAD>" << G4endl;                 
363   outFile << "<! -- Generated automatically by    
364           << " -- !>" << G4endl;                  
365   outFile << "<BODY>" << G4endl;                  
366 }                                                 
367                                                   
368 void G4HtmlPPReporter::PrintFooter(std::ofstre    
369 {                                                 
370   outFile << "<HR>" << G4endl;                    
371   outFile << "</BODY>" << G4endl;                 
372   outFile << "</HTML>" << G4endl;                 
373 }                                                 
374                                                   
375 const char* G4HtmlPPReporter::sTABLE = "<TABLE    
376 const char* G4HtmlPPReporter::eTABLE = "</TABL    
377 const char* G4HtmlPPReporter::sTR = "<TR>";       
378 const char* G4HtmlPPReporter::eTR = "</TR>";      
379 const char* G4HtmlPPReporter::sTD = "<TD>";       
380 const char* G4HtmlPPReporter::eTD = "</TD>";      
381 const char* G4HtmlPPReporter::sB = "<B>";         
382 const char* G4HtmlPPReporter::eB = "</B>";        
383 const char* G4HtmlPPReporter::sLFONT = "<FONT     
384 const char* G4HtmlPPReporter::eLFONT = "</FONT    
385 const char* G4HtmlPPReporter::sSYMBOL = "<FONT    
386 const char* G4HtmlPPReporter::eSYMBOL = "</FON    
387 const char* G4HtmlPPReporter::sSUP = "<SUP>";     
388 const char* G4HtmlPPReporter::eSUP = "</SUP>";    
389 const char* G4HtmlPPReporter::sSUB = "<SUB>";     
390 const char* G4HtmlPPReporter::eSUB = "</SUB>";    
391