Exemple #1
0
/***********************************************************************//**
 * @brief Print energy
 *
 * @param[in] chatter Chattiness (defaults to NORMAL).
 * @return String containing energy information.
 ***************************************************************************/
std::string GEnergy::print(const GChatter& chatter) const
{
    // Initialise result string
    std::string result;

    // Continue only if chatter is not silent
    if (chatter != SILENT) {

        // Append energy
        if (TeV() >= 1000.0) {
            result.append(gammalib::str(TeV()/1000.0)+" PeV");
        }
        else if (GeV() >= 1000.0) {
            result.append(gammalib::str(TeV())+" TeV");
        }
        else if (MeV() >= 1000.0) {
            result.append(gammalib::str(GeV())+" GeV");
        }
        else if (keV() >= 1000.0) {
            result.append(gammalib::str(MeV())+" MeV");
        }
        else {
            result.append(gammalib::str(keV())+" keV");
        }

        // VERBOSE: append energy and log10 energy
        if (chatter == VERBOSE) {
            result.append(" (E="+gammalib::str(m_energy));
            if (m_has_log10) {
                result.append(", log10(E)="+gammalib::str(m_elog10)+")");
            }
            else {
                result.append(", no log10(E) value)");
            }
        }

    } // endif: chatter was not silent

    // Return
    return result;
}
Exemple #2
0
void PhysicalUnits::PrintUnits()
{
  printf("%24s = %-14.3e %s\n", "[Length]", Length, "cm");
  printf("%24s = %-14.3e %s\n", "[Mass]", Mass, "gm");
  printf("%24s = %-14.3e %s\n", "[Time]", Time, "s");
  printf("%24s = %-14.3e %s\n", "[Velocity]", Length/Time, "cm/s");
  printf("%24s = %-14.3e %s\n", "[Energy]", 1.0/Erg(), "erg");
  printf("%24s = %-14.3e %s\n", "[B-field]", 1.0/Gauss(), "Gauss");
  printf("%24s = %-14.3e %s\n", "MeV", MeV(), "[Energy]");
  printf("%24s = %-14.3e %s\n", "LightSpeed", LightSpeed(), "[Velocity]");
  printf("%24s = %-14.3e %s\n", "GramsPerCubicCentimeter", GramsPerCubicCentimeter(), "[Mass]/[Length]^3");
}