G4NeutronHPReasctionWhiteBoard.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 // Class Description
00027 // Keep Information about current reaction
00028 // 121031 First implementation done by T. Koi (SLAC/PPA)
00029 
00030 #include "G4NeutronHPReactionWhiteBoard.hh"
00031 
00032 G4NeutronHPReactionWhiteBoard::G4NeutronHPReactionWhiteBoard()
00033 :targZ(0)
00034 ,targA(0)
00035 ,targM(0)
00036 {
00037 ;
00038 }
00039 G4NeutronHPReactionWhiteBoard::~G4NeutronHPReactionWhiteBoard()
00040 {
00041    mapStringPair.clear();
00042 }
00043 
00044 void G4NeutronHPReactionWhiteBoard::Dump()
00045 {
00046    G4cout << "G4NeutronHPReactionWhiteBoard::Dump" << G4endl;
00047    G4cout << "Target Z = " << targZ << G4endl;
00048    G4cout << "Target A = " << targA << G4endl;
00049    G4cout << "Target M = " << targM << G4endl;
00050 
00051    for ( std::map< G4String,G4String >::iterator 
00052          it = mapStringPair.begin(); it != mapStringPair.end(); it++ )
00053    {
00054       G4cout << it->first << " " << it->second << G4endl; 
00055    }
00056    //,,,
00057    G4cout << G4endl;
00058 }
00059 
00060 bool G4NeutronHPReactionWhiteBoard::AddRecord( std::pair<G4String,G4String> new_record )
00061 {
00062    if ( mapStringPair.find( new_record.first ) !=  mapStringPair.end() ) {
00063       G4cout << "This key is already used in the current reaction white board!" << G4endl;
00064       return false;
00065    }
00066    mapStringPair.insert ( new_record );
00067    return true;
00068 }
00069 
00070 G4String G4NeutronHPReactionWhiteBoard::GetValue( G4String key )
00071 {
00072    std::map< G4String,G4String >::iterator it = mapStringPair.find( key );
00073    if ( it == mapStringPair.end() ) {
00074       G4cout << "No entry for this key " << key << " in the current reaction white board!" << G4endl;
00075       return "NONE";
00076    }
00077    return it->second;
00078 }
00079 
00080 G4int G4NeutronHPReactionWhiteBoard::GetValueInInt( G4String key )
00081 {
00082    G4String result = GetValue( key );  
00083    if ( result == "NONE" ) return 0;
00084    std::stringstream ss;
00085    ss << key;
00086    G4int i;
00087    ss >> i;
00088    return i;
00089 }
00090 
00091 G4double G4NeutronHPReactionWhiteBoard::GetValueInDouble( G4String key )
00092 {
00093    G4String result = GetValue( key );  
00094    if ( result == "NONE" ) return 0.0;
00095    std::stringstream ss;
00096    ss << key;
00097    G4double x;
00098    ss >> x;
00099    return x;
00100 }

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