// Author: Andrew M. Rogers <mailto, NSCL 08/01/2008
//* Copyright (C) 2006-2008 Andrew M. Rogers

#include <iostream>
#include <fstream>
#include <math.h>
#include <stdio.h>

#include <TString.h>

#include "TAme.h"

ClassImp(TAme);

//////////////////////////////////////////////////////////////////////////
/* BEGIN_HTML
   <h1>Atomic Mass Evalutaion</h1>
   <p>
   This class uses the data from the AME to create TNucleus objects. 
   </p>
   END_HTML */
//////////////////////////////////////////////////////////////////////////


//______________________________________________________________________________
TAme::TAme(const char *name, const char *title, Int_t AmeYear)
{
  // -- Default Constuctor.

  SetNameTitle(name,title);
  fAmeYear = AmeYear;
  //  for(Int_t i=0; i<119; i++) fAmeNuclei[i] = new TObjArray(200);

  LoadAmeFiles(fAmeYear);
}


//______________________________________________________________________________
Int_t TAme::LoadAmeFiles(Int_t AmeYear)
{
  // -- Load Ame values for a given year.

  for(Int_t i=0; i<119; i++) fAmeNuclei[i].Expand(200);
  
  Int_t fileLines,charLines,headLines;
  if(AmeYear==2003){
    fileLines = 3179;
    charLines = 124;
    headLines = 39;
  }

  // Open the input files
  ifstream f0("TAme/AmeData/mass.mas03",ios::in);
  ifstream f1("TAme/AmeData/rct1.mas03",ios::in);
  ifstream f2("TAme/AmeData/rct2.mas03",ios::in);
  if(!f0.is_open()) {printf("ERROR:  File could not be opened.\n"); return -1;}
  if(!f1.is_open()) {printf("ERROR:  File could not be opened.\n"); return -2;}
  if(!f2.is_open()) {printf("ERROR:  File could not be opened.\n"); return -3;}

  Char_t header[10000];
  Char_t line[200];
  // Get the header.
  for(Int_t i=0; i<headLines; i++){
    f0.getline(line,200);
  }
  
  // Get values.
  for(Int_t j=0; j<fileLines; j++){
    Int_t     nz,n,z,a;
    Double_t  massEx,massExUnc,be,beUnc,bdE,bdEUnc,aMass,aMassUnc;
    TString   elt,valO,valC;
    TString   cnz,cn,cz,ca,cmassEx,cmassExUnc,cbe,cbeUnc,cbdE,cbdEUnc,caMass,caMassUnc;

    memset(line,'\0',sizeof(line));
    f0.getline(line,200);
    //    sscanf(line,"%*c%3i%5i%5i%5i %3s%c%c%c%c%c%c %13s%11s%11s%9s %*2s%11s%9s %*3i %12s%11s ",
    //    	   &nz,&n,&z,&a,elt,&valO[0],&valO[1],&valO[2],&valO[3],&valO[4],&valO[5],
    //	   cmassEx,cmassExUnc,cbe,cbeUnc,cbdE,cbdEUnc,caMass,caMassUnc);
    for(Int_t t=1;   t<4;   t++) cnz.Append(line[t]);
    for(Int_t t=4;   t<9;   t++) cn.Append(line[t]);
    for(Int_t t=9;   t<14;  t++) cz.Append(line[t]);
    for(Int_t t=14;  t<19;  t++) ca.Append(line[t]);
    for(Int_t t=20;  t<23;  t++) elt.Append(line[t]);
    for(Int_t t=23;  t<27;  t++) valO.Append(line[t]);
    for(Int_t t=28;  t<41;  t++) cmassEx.Append(line[t]);
    for(Int_t t=41;  t<52;  t++) cmassExUnc.Append(line[t]);
    for(Int_t t=52;  t<63;  t++) cbe.Append(line[t]);
    for(Int_t t=63;  t<72;  t++) cbeUnc.Append(line[t]);
    for(Int_t t=75;  t<86;  t++) cbdE.Append(line[t]);
    for(Int_t t=86;  t<95;  t++) cbdEUnc.Append(line[t]);
    for(Int_t t=100; t<112; t++) caMass.Append(line[t]);
    for(Int_t t=112; t<123; t++) caMassUnc.Append(line[t]);
 
    Double_t iVal = sqrt(-1.0);
    nz = cnz.Atoi(); 
    n  = cn.Atoi(); 
    z  = cz.Atoi(); 
    a  = ca.Atoi(); 

    if(cmassEx.Contains("*"))    { massEx    = iVal;           massExUnc = iVal;}
    else                         { massEx    = cmassEx.Atof(); massExUnc = cmassExUnc.Atof();}
    if(cbe.Contains("*"))        { be        = iVal;           beUnc     = iVal;}
    else                         { be        = cbe.Atof();     beUnc     = cbeUnc.Atof();}
    if(cbdE.Contains("*"))       { bdE       = iVal;           bdEUnc    = iVal;}
    else                         { bdE       = cbdE.Atof();    bdEUnc    = cbdEUnc.Atof();}
    if(caMass.Contains("*"))     { aMass     = iVal;           aMassUnc  = iVal;}
    else                         { aMass     = caMass.Atof();  aMassUnc  = caMassUnc.Atof();}

    //    printf(" %3i%5i%5i%5i %-3s%4s %13.5lf%11.5lf%11.3lf%9.3lf   %11.3lf%9.3lf     %012.5lf%11.5lf\n",
    //	   nz,n,z,a,elt.Data(),valO.Data(),massEx,massExUnc,be,beUnc,bdE,bdEUnc,aMass,aMassUnc);

    // Create the TNucleus object.
    Char_t name[50],title[50];
    sprintf(name,"%i%s",a,elt.Data());
    sprintf(title,"Ame Nucleus %i%s: N-Z=%3i N=%3i Z=%3i A=%3i",a,elt.Data(),nz,n,z,a); 
    TNucleus *nuc = new TNucleus(name,title,z,a);
    nuc->SetMassEx(massEx);
    nuc->SetMassExUnc(massExUnc);
    nuc->SetBE(be);
    nuc->SetBEUnc(beUnc);
    nuc->SetBetaDE(bdE);
    nuc->SetBetaDEUnc(bdEUnc);
    nuc->SetAMass(aMass);
    nuc->SetAMassUnc(aMassUnc);
    fAmeNuclei[z].AddAt(nuc,n);
    
  }
  f0.close();
  f1.close();
  f2.close();
  
  return 1;
}


//______________________________________________________________________________
void TAme::Print(Option_t *option)
{
  // -- Print Ame data.
  
}


//______________________________________________________________________________
TNucleus *TAme::GetNucleus(Int_t Z, Int_t A)
{
  // -- Retrive a TNucleus object.

  TObjArray *ob = (TObjArray*)&fAmeNuclei[Z];
  TNucleus *nuc = (TNucleus*)ob->At(A-Z);
  
  return nuc;
}

Last change: Sun Dec 21 13:32:48 2008
Last generated: 2008-12-21 13:32

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.