ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
Public Member Functions | Protected Member Functions | Private Attributes
Record Class Reference

Extended by all specializing Record classes in the ENSDF database. More...

#include <Record.h>

Inheritance diagram for Record:
AlphaRecord BetaRecordWrapper CommentRecord CrossReferenceRecord DelayedParticleRecord GammaRecord HistoryRecord IdentificationRecord LevelRecord NormalizationRecord ParentRecord ProductionNormalizationRecord QValueRecord ReferenceRecord

List of all members.

Public Member Functions

 Record (list< string > cardArg)
 Constructor.
Nukleid getNukleid () const
 Returns the associated Nukleid object.
list< string > getCardStrings () const
 Get the card strings.

Protected Member Functions

double cardToDouble (int startPos, int endPos)
 Takes a portion of the record card, and parses it as a double.
double parseHalfLife (int startPos, int endPos)
 Takes a portion of the record card, and parses it as a half-life (number and unit).
string trimString (string toTrim)
 Trim a string.

Private Attributes

Nukleid myNukleid
 The Nukleid object corresponding to this Record.
list< string > myCard
 Holds the 80 character wide ENSDF record card(s) for this record.

Detailed Description

Extended by all specializing Record classes in the ENSDF database.

Author:
Rikard Lundmark

Definition at line 55 of file Record.h.


Constructor & Destructor Documentation

Record::Record ( list< string >  cardArg)

Constructor.

Parameters:
cardArgThe card string(s) corresponding to this record.

Definition at line 4 of file Record.cpp.

References myCard, and myNukleid.

{
  if(!cardArg.empty())
    {
      myCard = cardArg;
      myNukleid = Nukleid(myCard.front().substr(0,5));
    }
}

Member Function Documentation

double Record::cardToDouble ( int  startPos,
int  endPos 
) [protected]

Takes a portion of the record card, and parses it as a double.

Todo:
Implement this for continuation records also.
Parameters:
startPosThe start position in the ENSDF record card.
endPosThe end position in the ENSDF record card.

Definition at line 28 of file Record.cpp.

References myCard.

Referenced by QValueRecord::processCard(), NormalizationRecord::processCard(), LevelRecord::processCard(), GammaRecord::processCard(), BetaPlusRecord::processCard(), and BetaMinusRecord::processCard().

{
  if(!myCard.empty())
    {
      string data = myCard.front().substr(startPos-1, endPos-startPos+1);
      const char* dataCString = data.c_str();
      double number = atof(dataCString);
      return number;
    }
  else
    {
      throw DataFileException("Empty card string.\n");
    }
}
list< string > Record::getCardStrings ( ) const

Get the card strings.

Returns:
A list of strings, where each string corresponds to a record (all strings except the first is the continuation records.)

Definition at line 23 of file Record.cpp.

References myCard.

Referenced by DataQueryBetaGamma::findNextLevel(), and IdentificationRecord::processCard().

{
  return myCard;
}
Nukleid Record::getNukleid ( ) const
double Record::parseHalfLife ( int  startPos,
int  endPos 
) [protected]

Takes a portion of the record card, and parses it as a half-life (number and unit).

Todo:
Fix the times given in units of time.

Parameters:
startPosThe start position in the ENSDF card.
endPosThe end position in the ENSDF card.

Definition at line 53 of file Record.cpp.

References myCard, and trimString().

Referenced by ParentRecord::processCard(), and LevelRecord::processCard().

{
  string tempStr = myCard.front().substr(startPos-1, endPos-startPos+1);
  string halfLifeStr = trimString(tempStr);


  if (halfLifeStr.substr(0,5).compare("STABLE") == 0)                   // the strings are equal
    return -1;
  unsigned int i = 0;
  for (i = 0; i < halfLifeStr.length(); i++)
    {
      if (!((halfLifeStr.at(i) <= '9' && halfLifeStr.at(i) >= '0') || halfLifeStr.at(i) == '.'))
        break;
    }
  if(halfLifeStr.size()<i+2)
    return -3;
  string numberStr = halfLifeStr.substr(0, i);
  const char* numberCString = numberStr.c_str();
  double number = atof(numberCString);
  if(halfLifeStr.size()>i+2)
    {
      string unit = halfLifeStr.substr(i+1, 2);
      if (unit.compare("Y ") == 0)
        number *= 365*24*60*60;
      else if (unit.compare("D ") == 0)
        number *= 60*60*24;
      else if (unit.compare("H ") == 0)
        number *= 60*60;
      else if (unit.compare("M ") == 0)
        number *= 60;
      else if (unit.compare("S ") == 0)
        number *= 1;
      else if (unit.compare("MS") == 0)
        number *= 1E-3;
      else if (unit.compare("US") == 0)
        number *= 1E-6;
      else if (unit.compare("NS") == 0)
        number *= 1E-9;
      else if (unit.compare("PS") == 0)
        number *= 1E-12;
      else if (unit.compare("FS") == 0)
        number *= 1E-15;
      else if (unit.compare("AS") == 0)
        number *= 1E-18;
      else
        return -2;
    }
  else if(halfLifeStr.size()>i+1)
    {
      string unit = halfLifeStr.substr(i+1, 1);
      if (unit.compare("Y") == 0)
        number *= 365*24*60*60;
      else if (unit.compare("D") == 0)
        number *= 60*60*24;
      else if (unit.compare("H") == 0)
        number *= 60*60;
      else if (unit.compare("M") == 0)
        number *= 60;
      else if (unit.compare("S") == 0)
        number *= 1;
      else
        return -5;
    }
  else
    {
      number = - 1339;
    }
  return number;
}
string Record::trimString ( string  toTrim) [protected]

Trim a string.

Parameters:
toTrimThe string to trim.

Definition at line 43 of file Record.cpp.

Referenced by parseHalfLife().

{
  int ptrStart = -1;
  int ptrStop = toTrim.size();
  while(toTrim[++ptrStart]==' ');
  while(toTrim[--ptrStop]==' ');
  return toTrim.substr(ptrStart,ptrStop-ptrStart+1);
}

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Defines

Back to the main page of the Precalibrated Ion Beam Identification Detector project

Created by Rikard Lundmark