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 | Static Protected Member Functions | Protected Attributes
ENSDFProcessor Class Reference

This class acts as an intermediate step between the Main function and the ENSDF object and the different DataQuery objects. More...

#include <ENSDFProcessor.h>

Inheritance diagram for ENSDFProcessor:
VerbosePrinterEventEnabled

List of all members.

Public Member Functions

 ENSDFProcessor (string ENSDFDirectory, string MassTableDirectory, VerbosePrinter *toRegister=NULL, unsigned int nbrOfThreads=5)
 Constructor, constructs the processor, which will also construct the underlying ENSDF and MassTable objects.
 ~ENSDFProcessor ()
 Prevents memory leaks by destroying for example the ENSDF and MassTable objects.
list< InterestingDecayBetaGamma * > runBetaGammaQuery (double minBetaDecayTime, double maxBetaDecayTime)
 Runs a DataQueryBetaGamma.
void runBetaGammaQuery (double minBetaDecayTime, double maxBetaDecayTime, double minBetaBranchStrength, double minGammaBranchStrength, string outputFileName)
 Runs a DataQueryBetaGamma with the arguments minBetaDecayTime and maxBetaDecayTime, and saves the results to outputFileName.
void runBetaGammaQuery_GenerateGammaList (double minBetaDecayTime, double maxBetaDecayTime, double minGammaBranchStrength, string outputFileName)
 Just like runBetaGammaQuery(double, double, double, double, string), but generates a list of nucleids and gamma energies only.
void runBetaGammaQuery_GenerateChartList (double minBetaDecayTime, double maxBetaDecayTime, double minGammaBranchStrength, string outputFileName)
 Just like runBetaGammaQuery(double, double, double, double, string), but generates a list of nucleids and gamma energies only.
void runBetaGammaQuery_GenerateTexList (double minBetaDecayTime, double maxBetaDecayTime, double minGammaBranchStrength, string outputFileName)
 Just like runBetaGammaQuery(double, double, double, double, string), but generates a list of nucleids and gamma energies only.
list< InterestingDecayIsomer * > runIsomerQuery (double tLower, double tUpper)
 Runs a DataQueryIsomer.
void runIsomerQuery (double tLower, double tUpper, string outputFileName)
 Calls runIsomerQuery(double, double), and writes the data to the file specified by outputFileName.

Protected Member Functions

vector< string > getDirectoryContent (string DirectoryName)
 Returns a list of the files in a given directory.

Static Protected Member Functions

static int one (const struct dirent *unused)
 Used to when retrieving directory content.

Protected Attributes

ENSDFmyENSDF
 The ENSDF object used in this ENSDFprocessor.
MassTablemyTable
 The MassTable object used in this ENSDFProcessor.

Detailed Description

This class acts as an intermediate step between the Main function and the ENSDF object and the different DataQuery objects.

It controlls the construction of the ENSDF and MassTable objects.

Author:
Rikard Lundmark

Definition at line 83 of file ENSDFProcessor.h.


Constructor & Destructor Documentation

ENSDFProcessor::ENSDFProcessor ( string  ENSDFDirectory,
string  MassTableDirectory,
VerbosePrinter toRegister = NULL,
unsigned int  nbrOfThreads = 5 
)

Constructor, constructs the processor, which will also construct the underlying ENSDF and MassTable objects.

Parameters:
ENSDFDirectoryThe directory containing the ENSDF files.
MassTableDirectoryThe directory containing the MassTable files (mass.mas03).
toRegisterUsed to display information to the user.
nbrOfThreadsThe number of working threads the ENSDF object should use when constructing the Isotope objects.

Definition at line 3 of file ENSDFProcessor.cpp.

References getDirectoryContent(), myENSDF, myTable, VerbosePrinterEventEnabled::registerChild(), and VerbosePrinterEventEnabled::registerListener().

{
  registerListener(toRegister);
  vector<string> myDirectory = getDirectoryContent(ENSDFDirectory);
  for(unsigned int i = 0; i<myDirectory.size(); i++)
    {
      myDirectory[i]=ENSDFDirectory + "/" + myDirectory[i];
    }
  myENSDF = new ENSDF(myDirectory, toRegister, nbrOfThreads);
  vector<string> myMassDirectory = getDirectoryContent(MassTableDirectory);
  myTable = new MassTable(MassTableDirectory + "/" + myMassDirectory.front(), toRegister);


  registerChild(myTable);
  registerChild(myENSDF);
}

Member Function Documentation

vector< string > ENSDFProcessor::getDirectoryContent ( string  DirectoryName) [protected]

Returns a list of the files in a given directory.

Returns:
A list of the files in the directory.
Parameters:
DirectoryNameThe directory to find the files in.

Definition at line 182 of file ENSDFProcessor.cpp.

References one(), and VerbosePrinterEventEnabled::vPrint().

Referenced by ENSDFProcessor().

{
  vPrint(3,"Loading directory content of %s\n",directoryName.c_str());
  vector<string> toReturn;

  struct dirent **eps;
  int n;

  n = scandir (directoryName.c_str(), &eps, one, alphasort);
  if (n >= 0)
    {
      int cnt;
      for (cnt = 0; cnt < n; ++cnt)
        {
          string tmp(eps[cnt]->d_name);
          if(!(tmp.compare(".")==0 || tmp.compare("..")==0 || tmp.compare(".svn")==0))
            toReturn.push_back(eps[cnt]->d_name);
        }
    }
  else
    perror ("Couldn't open the directory");
  vPrint(3,"Found %d entries in folder %s\n", (int)toReturn.size(), directoryName.c_str());
  return toReturn;
}
static int ENSDFProcessor::one ( const struct dirent *  unused) [inline, static, protected]

Used to when retrieving directory content.

Parameters:
unusedUnused.

Definition at line 147 of file ENSDFProcessor.h.

Referenced by getDirectoryContent().

void ENSDFProcessor::runBetaGammaQuery ( double  minBetaDecayTime,
double  maxBetaDecayTime,
double  minBetaBranchStrength,
double  minGammaBranchStrength,
string  outputFileName 
)

Runs a DataQueryBetaGamma with the arguments minBetaDecayTime and maxBetaDecayTime, and saves the results to outputFileName.

See also:
DataQueryBetaGamma, InterestingDecayBetaGamma::toString(double, double)
Parameters:
minBetaDecayTimeThe minimum beta decay time to search for.
maxBetaDecayTimeThe maximum beta decay time to search for.
minBetaBranchStrengthThe minimum beta branch strength to print.
minGammaBranchStrengthThe minimum gamma branch strength to print.
outputFileNameThe file to write the result to. Must be a valid filename.

Definition at line 28 of file ENSDFProcessor.cpp.

References NULL, runBetaGammaQuery(), and VerbosePrinterEventEnabled::vPrint().

{
  vPrint(2,"Running query to file.\n");
  FILE * myFile = fopen (outputFileName.c_str(), "w");
  if(myFile!=NULL)
    {    
      vPrint(3,"File was successfully created.\n");
      list<InterestingDecayBetaGamma* > myDecays = runBetaGammaQuery(minBetaDecayTime, maxBetaDecayTime);
      for(list<InterestingDecayBetaGamma* >::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          fprintf(myFile, "%s\n", (*it)->toString(minBetaBranchStrength, minGammaBranchStrength).c_str());
        }
      vPrint(3,"Wrote %d posts to the file.\n", myDecays.size());
      vPrint(3,"Closing file.\n");
      fclose(myFile); 
      for(list<InterestingDecayBetaGamma*>::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          delete *it;
          *it = NULL;
        }
    }
}
list< InterestingDecayBetaGamma * > ENSDFProcessor::runBetaGammaQuery ( double  minBetaDecayTime,
double  maxBetaDecayTime 
)

Runs a DataQueryBetaGamma.

Returns:
a list with the InterestingDecayBetaGamma found.
See also:
DataQueryBetaGamma.
Parameters:
minBetaDecayTimeThe minimum beta decay time to search for.
maxBetaDecayTimeThe maximum beta decay time to search for.

Definition at line 166 of file ENSDFProcessor.cpp.

References myENSDF, VerbosePrinterEventEnabled::myPrinter, myTable, NULL, VerbosePrinterEventEnabled::registerChild(), DataQueryBetaGamma::RunQuery(), and VerbosePrinterEventEnabled::vPrint().

Referenced by proceed_interact(), proceed_nointeract(), runBetaGammaQuery(), runBetaGammaQuery_GenerateChartList(), runBetaGammaQuery_GenerateGammaList(), and runBetaGammaQuery_GenerateTexList().

{
  vPrint(2,"Creating BetaGamma data query.\n");
  DataQueryBetaGamma * myQuery = new DataQueryBetaGamma(myENSDF, myTable, myPrinter);
  registerChild(myQuery);

  list<InterestingDecayBetaGamma*> myDecayList = myQuery->RunQuery(minBetaDecayTime, maxBetaDecayTime);

  delete myQuery;
  myQuery = NULL;

  return myDecayList;
}
void ENSDFProcessor::runBetaGammaQuery_GenerateChartList ( double  minBetaDecayTime,
double  maxBetaDecayTime,
double  minGammaBranchStrength,
string  outputFileName 
)

Just like runBetaGammaQuery(double, double, double, double, string), but generates a list of nucleids and gamma energies only.

Parameters:
minBetaDecayTimeThe minimum beta decay time to search for.
maxBetaDecayTimeThe maximum beta decay time to search for.
minGammaBranchStrengthThe minimum gamma branch strength to print.
outputFileNameThe file to write the result to. Must be a valid filename.

Definition at line 76 of file ENSDFProcessor.cpp.

References NULL, runBetaGammaQuery(), and VerbosePrinterEventEnabled::vPrint().

Referenced by proceed_nointeract().

{
  vPrint(2, "Running ChartList query to file.\n");
  FILE * myFile = fopen(outputFileName.c_str(), "w");
  if(myFile!=NULL)
    {
      vPrint(3,"File was successfully created.\n");
      list<InterestingDecayBetaGamma* > myDecays = runBetaGammaQuery(minBetaDecayTime, maxBetaDecayTime);
      for(list<InterestingDecayBetaGamma*>::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          fprintf(myFile, "%s", (*it)->toChartString(minGammaBranchStrength).c_str());
        }
      vPrint(3,"Wrote %d posts to the file.\n", myDecays.size());
      vPrint(3,"Closing file.\n");
      fclose(myFile);
      for(list<InterestingDecayBetaGamma*>::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          delete *it;
          *it = NULL;
        }
    }
  else
    vPrint(1,"Could not create file!");
}
void ENSDFProcessor::runBetaGammaQuery_GenerateGammaList ( double  minBetaDecayTime,
double  maxBetaDecayTime,
double  minGammaBranchStrength,
string  outputFileName 
)

Just like runBetaGammaQuery(double, double, double, double, string), but generates a list of nucleids and gamma energies only.

Parameters:
minBetaDecayTimeThe minimum beta decay time to search for.
maxBetaDecayTimeThe maximum beta decay time to search for.
minGammaBranchStrengthThe minimum gamma branch strength to print.
outputFileNameThe file to write the result to. Must be a valid filename.

Definition at line 51 of file ENSDFProcessor.cpp.

References NULL, runBetaGammaQuery(), and VerbosePrinterEventEnabled::vPrint().

Referenced by proceed_nointeract().

{
  vPrint(2, "Running GammaList query to file.\n");
  FILE * myFile = fopen(outputFileName.c_str(), "w");
  if(myFile!=NULL)
    {
      vPrint(3,"File was successfully created.\n");
      list<InterestingDecayBetaGamma* > myDecays = runBetaGammaQuery(minBetaDecayTime, maxBetaDecayTime);
      for(list<InterestingDecayBetaGamma*>::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          fprintf(myFile, "%s", (*it)->toGammaString(minGammaBranchStrength).c_str());
        }
      vPrint(3,"Wrote %d posts to the file.\n", myDecays.size());
      vPrint(3,"Closing file.\n");
      fclose(myFile);
      for(list<InterestingDecayBetaGamma*>::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          delete *it;
          *it = NULL;
        }
    }
  else
    vPrint(1,"Could not create file!");
}
void ENSDFProcessor::runBetaGammaQuery_GenerateTexList ( double  minBetaDecayTime,
double  maxBetaDecayTime,
double  minGammaBranchStrength,
string  outputFileName 
)

Just like runBetaGammaQuery(double, double, double, double, string), but generates a list of nucleids and gamma energies only.

Parameters:
minBetaDecayTimeThe minimum beta decay time to search for.
maxBetaDecayTimeThe maximum beta decay time to search for.
minGammaBranchStrengthThe minimum gamma branch strength to print.
outputFileNameThe file to write the result to. Must be a valid filename.

Definition at line 102 of file ENSDFProcessor.cpp.

References NULL, runBetaGammaQuery(), and VerbosePrinterEventEnabled::vPrint().

Referenced by proceed_nointeract().

{
  vPrint(2, "Running ChartList query to file.\n");
  FILE * myFile = fopen(outputFileName.c_str(), "w");
  if(myFile!=NULL)
    {
      vPrint(3,"File was successfully created.\n");
      list<InterestingDecayBetaGamma* > myDecays = runBetaGammaQuery(minBetaDecayTime, maxBetaDecayTime);
      for(list<InterestingDecayBetaGamma*>::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          fprintf(myFile, "%s", (*it)->toTexString(minGammaBranchStrength).c_str());
          vPrint(3,"%s",(*it)->toTexString(minGammaBranchStrength).c_str());
        }
      vPrint(3,"Wrote %d posts to the file.\n", myDecays.size());
      vPrint(3,"Closing file.\n");
      fclose(myFile);
      for(list<InterestingDecayBetaGamma*>::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          delete *it;
          *it = NULL;
        }
    }
  else
    vPrint(1,"Could not create file!");
}
list< InterestingDecayIsomer * > ENSDFProcessor::runIsomerQuery ( double  tLower,
double  tUpper 
)

Runs a DataQueryIsomer.

Returns:
the InterestingDecaysIsomer objects found.
See also:
DataQueryIsomer.
Parameters:
tLowerThe lower level decay time to search for.
tUpperThe upper level decay time to search for.

Definition at line 153 of file ENSDFProcessor.cpp.

References myENSDF, VerbosePrinterEventEnabled::myPrinter, NULL, VerbosePrinterEventEnabled::registerChild(), DataQueryIsomer::RunQuery(), and VerbosePrinterEventEnabled::vPrint().

Referenced by proceed_nointeract(), and runIsomerQuery().

{
  vPrint(2, "Creating Isomer query.\n");
  DataQueryIsomer * myQuery = new DataQueryIsomer(myENSDF, myPrinter);
  registerChild(myQuery);
  list<InterestingDecayIsomer*> myDecayList = myQuery->RunQuery(tLower, tUpper);

  delete myQuery;
  myQuery = NULL;
  
  return myDecayList;
}
void ENSDFProcessor::runIsomerQuery ( double  tLower,
double  tUpper,
string  outputFileName 
)

Calls runIsomerQuery(double, double), and writes the data to the file specified by outputFileName.

See also:
InterestingDecayIsomer::toString()
Parameters:
tLowerThe lower level decay time to search for.
tUpperThe upper level decay time to search for.
outputFileNameThe file to write the result to.

Definition at line 130 of file ENSDFProcessor.cpp.

References NULL, runIsomerQuery(), and VerbosePrinterEventEnabled::vPrint().

{
  vPrint(2,"Running Isomer query to file.\n");
  FILE * myFile = fopen (outputFileName.c_str(), "w");
  if(myFile!=NULL)
    {    
      vPrint(3,"File was successfully created.\n");
      list<InterestingDecayIsomer*> myDecays = runIsomerQuery(tLower, tUpper);
      for(list<InterestingDecayIsomer*>::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          fprintf(myFile, "%s\n", (*it)->toString().c_str());
        }
      vPrint(3,"Closing file.\n");
      fclose(myFile);
      for(list<InterestingDecayIsomer*>::iterator it = myDecays.begin(); it!=myDecays.end(); it++)
        {
          delete *it;
          *it = NULL;
        }
    }
  vPrint(2,"Done with query.\n");
}

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