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

Contains the MassTable from the mass.mas03 file. More...

#include <MassTable.h>

Inheritance diagram for MassTable:
VerbosePrinterEventEnabled

List of all members.

Public Member Functions

 MassTable (string filename, VerbosePrinter *toRegister=NULL)
 C.
list< MassObjectgetMassObjects () const
 Get the mass objects in the table.
const MassObject getMassObject (Nukleid toGet) const
 Returns a MassObject corresponding to toGet.
const MassObject getMassObject (unsigned short int Z, unsigned short int A) const
 Returns a MassObject corresponding to a specific atomic- and massnumber.

Private Attributes

list< MassObjectmyMasses
 A list of MassObject loaded in the constructor.

Detailed Description

Contains the MassTable from the mass.mas03 file.

Author:
Rikard Lundmark

Definition at line 47 of file MassTable.h.


Constructor & Destructor Documentation

MassTable::MassTable ( string  filename,
VerbosePrinter toRegister = NULL 
)

C.

Parameters:
filenameThe filename to load the masstable from.
toRegisterUsed to display information to the user.

Definition at line 4 of file MassTable.cpp.

References myMasses, NULL, VerbosePrinterEventEnabled::registerListener(), and VerbosePrinterEventEnabled::vPrint().

{
  registerListener(toRegister);
  vPrint(4,"Creating mass table from file %s.\n", filename.c_str());
  FILE * myFile;
  myFile = fopen(filename.c_str(),"r");
  if(myFile==NULL)
    perror("The opened file is null");
  char line[200];
  vector<string> fileContent;
  while (fgets(line,200, myFile)!=NULL)
    {
      string myString(line);
      fileContent.push_back(myString);
    }
  vector<string>::iterator it = fileContent.begin();
  for(int i = 0; i<40 && it!=fileContent.end(); i++)
    ++it;
  while(it!=fileContent.end())
    {
      myMasses.push_back(MassObject(*(it++)));
    }
  if(myFile!=NULL)
    fclose(myFile);
  vPrint(4,"Done creating mass table.\n");
  return;
}

Member Function Documentation

const MassObject MassTable::getMassObject ( Nukleid  toGet) const

Returns a MassObject corresponding to toGet.

Returns:
a MassObject.
Exceptions:
DataFileExceptionif there is no such MassObject.
Parameters:
toGetThe Nukleid object to get a MassObject for.

Definition at line 37 of file MassTable.cpp.

References myMasses, Nukleid::toString(), and VerbosePrinterEventEnabled::vPrint().

Referenced by DataQueryBetaGamma::DetectInterestingStuffWithThisIsotope(), and main().

{
  vPrint(13, "Now searching through %d masstable entries.\n",myMasses.size());
  for(list<MassObject>::const_iterator it = myMasses.begin(); it!=myMasses.end(); it++)
    {
      if(it->getNukleid()==toGet)
        return (*it);
    }
  throw DataFileException("The requested nucleid was not found in the masstable: " + toGet.toString() + " Probable cause: incorrect or missing masstable.");
}
const MassObject MassTable::getMassObject ( unsigned short int  Z,
unsigned short int  A 
) const

Returns a MassObject corresponding to a specific atomic- and massnumber.

Returns:
a MassObject.
Exceptions:
DataFileExceptionif no such MassObject exists.
Parameters:
ZThe atomic number.
AThe mass number

Definition at line 48 of file MassTable.cpp.

References myMasses.

{
  for(list<MassObject>::const_iterator it = myMasses.begin(); it!=myMasses.end(); it++)
    {
      if(it->getNukleid().getA()==A && it->getNukleid().getZ()==Z)
        return (*it);
    }
  throw DataFileException("The requested nucleid was not found. ");
}
list< MassObject > MassTable::getMassObjects ( ) const

Get the mass objects in the table.

Returns:
A list of MassObjects.

Definition at line 32 of file MassTable.cpp.

References myMasses.

Referenced by main().

{
  return myMasses;
}

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