source: trunk/source/particles/utils/src/G4TextPPReporter.cc @ 992

Last change on this file since 992 was 992, checked in by garnier, 15 years ago

fichiers oublies

File size: 4.5 KB
Line 
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//
32// $Id: G4TextPPReporter.cc,v 1.2 2006/06/29 19:28:02 gunter Exp $
33// GEANT4 tag $Name: geant4-09-02-ref-02 $
34//
35//
36// ---------------------------------------------------------------
37#include "G4TextPPReporter.hh"
38#include "G4ios.hh"
39#include "globals.hh"
40#include "G4DecayTable.hh" 
41#include "G4Tokenizer.hh"
42#include <iomanip>
43#include <fstream>      
44
45//////////////////////////////
46G4TextPPReporter::G4TextPPReporter():G4VParticlePropertyReporter()
47{ 
48}
49
50////////////////////////////
51G4TextPPReporter::~G4TextPPReporter()
52{
53}   
54
55/////////////////////
56void G4TextPPReporter::Print(const G4String& option)
57{
58  SparseOption( option );
59
60  for (size_t i=0; i< pList.size(); i++){
61    G4ParticleDefinition* particle  = G4ParticleTable::GetParticleTable()->FindParticle( pList[i]->GetParticleName() ); 
62
63    GeneratePropertyTable(particle);
64  }
65}   
66
67
68void G4TextPPReporter::SparseOption(const G4String& option)
69{
70  G4Tokenizer savedToken( option );
71 
72  // 1st option : base directory
73  baseDir = savedToken();
74  if (!baseDir.isNull()) {
75    if(baseDir(baseDir.length()-1)!='/') {
76      baseDir += "/";
77    }
78  }
79}
80
81
82
83void  G4TextPPReporter::GeneratePropertyTable(G4ParticleDefinition* particle)
84{
85  G4String name = particle->GetParticleName();
86 
87  //--- open file -----
88  G4String fileName = baseDir + name + ".txt";
89  // exception
90  if (name == "J/psi") fileName = baseDir +"jpsi.txt";
91
92  std::ofstream outFile(fileName, std::ios::out );
93  outFile.setf( std::ios:: scientific, std::ios::floatfield );
94  outFile << std::setprecision(7) << G4endl;
95
96  // particle name  encoding
97  outFile << name << " "
98          <<  particle->GetPDGEncoding()  << G4endl;
99
100  // IJPC
101  outFile << particle->GetPDGiIsospin()       << " "
102          << particle->GetPDGiSpin()          << " "
103          << particle->GetPDGiParity()        << " "
104          << particle->GetPDGiConjugation()   << G4endl;
105
106  // mass, width, charge
107  outFile <<  particle->GetPDGMass()/GeV      << " "
108          <<  particle->GetPDGWidth()/GeV     << " " 
109          <<  particle->GetPDGCharge()/eplus  << G4endl;
110
111  // life time
112  outFile << particle->GetPDGLifeTime()/second << G4endl;
113
114// Decay Table 
115  G4DecayTable* dcyTable = particle->GetDecayTable(); 
116  if (dcyTable != 0) { 
117    for (G4int i=0; i< dcyTable->entries(); i++){
118      G4VDecayChannel * channel = dcyTable->GetDecayChannel(i);
119      // column 1  : BR
120      outFile << channel->GetBR() << " ";
121      // column 2.  : daughters
122      outFile << channel->GetNumberOfDaughters() << " ";
123      // column 3 : Kinematics
124      outFile << channel->GetKinematicsName() << " ";
125      // daughters
126      for (G4int j=0; j< channel->GetNumberOfDaughters(); j++){
127        outFile << channel->GetDaughter(j)->GetParticleName() << " ";
128      }
129      outFile << G4endl;
130    }
131  }
132}
133
134
135
136
137
Note: See TracBrowser for help on using the repository browser.