G4TextPPReporter.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // the GEANT4 collaboration.
00027 //
00028 // By copying, distributing or modifying the Program (or any work
00029 // based on the Program) you indicate your acceptance of this statement,
00030 // and all its terms.
00031 //
00032 // $Id$
00033 //
00034 // 
00035 // ---------------------------------------------------------------
00036 #include "G4TextPPReporter.hh"
00037 #include "G4ios.hh"
00038 #include "globals.hh"
00039 #include "G4SystemOfUnits.hh"
00040 #include "G4ParticleTable.hh"
00041 #include "G4ParticleDefinition.hh"
00042 #include "G4DecayTable.hh"  
00043 #include "G4VDecayChannel.hh"  
00044 #include "G4Tokenizer.hh"
00045 #include <iomanip>
00046 #include <fstream>       
00047 
00049 G4TextPPReporter::G4TextPPReporter():G4VParticlePropertyReporter()
00050 { 
00051 }
00052 
00054 G4TextPPReporter::~G4TextPPReporter()
00055 {
00056 }    
00057 
00059 void G4TextPPReporter::Print(const G4String& option)
00060 {
00061   SparseOption( option );
00062 
00063   for (size_t i=0; i< pList.size(); i++){
00064     G4ParticleDefinition* particle  = G4ParticleTable::GetParticleTable()->FindParticle( pList[i]->GetParticleName() ); 
00065 
00066     GeneratePropertyTable(particle);
00067   }
00068 }    
00069 
00070 
00071 void G4TextPPReporter::SparseOption(const G4String& option)
00072 {
00073   G4Tokenizer savedToken( option );
00074   
00075   // 1st option : base directory
00076   baseDir = savedToken();
00077   if (!baseDir.isNull()) {
00078     if(baseDir(baseDir.length()-1)!='/') {
00079       baseDir += "/";
00080     }
00081   }
00082 }
00083 
00084 
00085 
00086 void  G4TextPPReporter::GeneratePropertyTable(const G4ParticleDefinition* particle)
00087 {
00088   G4String name = particle->GetParticleName();
00089   
00090   //--- open file -----
00091   G4String fileName = baseDir + name + ".txt";
00092   // exception
00093   if (name == "J/psi") fileName = baseDir +"jpsi.txt";
00094 
00095   std::ofstream outFile(fileName, std::ios::out );
00096   outFile.setf( std::ios:: scientific, std::ios::floatfield );
00097   outFile << std::setprecision(7) << G4endl;
00098 
00099   // particle name  encoding
00100   outFile << name << " "
00101           <<  particle->GetPDGEncoding()  << G4endl;
00102 
00103   // IJPC
00104   outFile << particle->GetPDGiIsospin()       << " "
00105           << particle->GetPDGiSpin()          << " "
00106           << particle->GetPDGiParity()        << " "
00107           << particle->GetPDGiConjugation()   << G4endl;
00108 
00109   // mass, width, charge 
00110   outFile <<  particle->GetPDGMass()/GeV      << " "
00111           <<  particle->GetPDGWidth()/GeV     << " " 
00112           <<  particle->GetPDGCharge()/eplus  << G4endl;
00113 
00114   // life time
00115   outFile << particle->GetPDGLifeTime()/second << G4endl;
00116 
00117 // Decay Table  
00118   G4DecayTable* dcyTable = particle->GetDecayTable(); 
00119   if (dcyTable != 0) { 
00120     for (G4int i=0; i< dcyTable->entries(); i++){
00121       G4VDecayChannel * channel = dcyTable->GetDecayChannel(i);
00122       // column 1  : BR
00123       outFile << channel->GetBR() << " ";
00124       // column 2.  : daughters
00125       outFile << channel->GetNumberOfDaughters() << " ";
00126       // column 3 : Kinematics
00127       outFile << channel->GetKinematicsName() << " ";
00128       // daughters
00129       for (G4int j=0; j< channel->GetNumberOfDaughters(); j++){
00130         outFile << channel->GetDaughter(j)->GetParticleName() << " ";
00131       }
00132       outFile << G4endl;
00133     }
00134   }
00135 }
00136 
00137 
00138 
00139 
00140 

Generated on Mon May 27 17:49:57 2013 for Geant4 by  doxygen 1.4.7