[ROOT] Advice for Better Programming:

From: B.V.L.S.Prasad (shiva@mbu.iisc.ernet.in)
Date: Mon Sep 03 2001 - 19:10:14 MEST


Dear rooters and others,

	I have a file which keeps all the information about an element and its
scattering factors and all other information,like atomic number, atomic mass.

	I created a class BioAtomLibrary to keep all that information , and
later  mapped this to element name so that I can access :

cint>{	cout<<Atom["Ca"].getAtomicMass()<<endl; }


	When I am compiling, its working perfectly okay with g++ 2.96.
but when I am using makecint( cint5.15.06), its not compiling successfully.
After 20minutes or so, it gave internal error.

I checked the top: process monitoring.... cc1plus:
when the memory usage was around 255MB.  it crashed.

But, how to keep such data, as this data should be available when we write
scripts in the cint...

Please give an advice .

Thankyou for the patience and time.

Prasad.

I am attaching the file : here: the class and the data information.


#ifndef BIOATOMLIBRARY_H
#define BIOATOMLIBRARY_H

#include <string>
#include <map>

class BioAtomLibrary
{
	int atomicNumber_;
	string elementCode_;
	string elementName_;
	double atomicMass_;
	double atomicRadius_;
	double atomicScatteringFactor_;
//	double atomicColour_;
public:
	BioAtomLibrary(){};
	BioAtomLibrary(int eNum,string eCode,string eName, double eMass,double eRad,
	double eScF):atomicNumber_(eNum),elementCode_(eCode),elementName_(eName),
	atomicMass_(eMass),atomicRadius_(eRad), atomicScatteringFactor_(eScF){}

						  //, atomicColour_(eCol){}

	int getAtomicNumber() const { return atomicNumber_; }
	string getElementName() const { return elementName_; }
	string getElementCode() const { return elementCode_; }
	double getAtomicMass() const { return atomicMass_; }
	double getAtomicRadius() const { return atomicRadius_; }
	double getAtomicScatteringFactor() const { return atomicScatteringFactor_; }

//double getAtomicColour() const { return atomicColour_; }
};

static map<string,BioAtomLibrary>Atom;

void setAtomDefaults()
{

//BioAtomLibrary(eNum, eCode, eName, eMass, eRad, eScF);

Atom["H"] = BioAtomLibrary(1,"H","Hydrogen",1.008,0.78,0);
Atom["D"] = BioAtomLibrary(1,"D","Deuterium",2.000,0.78,0);
Atom["He"] = BioAtomLibrary(2,"He","Helium",4.003,1.00,0);
Atom["Li"] = BioAtomLibrary(3,"Li","Lithium",6.941,1.56,0);
Atom["Be"] = BioAtomLibrary(4,"Be","Beryllium",9.012,1.13,0);
Atom["B"] = BioAtomLibrary(5,"B","Boron",10.811,0.95,0);
Atom["C"] = BioAtomLibrary(6,"C","Carbon",12.011,0.86,0);
Atom["N"] = BioAtomLibrary(7,"N","Nitrogen",14.007,0.80,0);
Atom["O"] = BioAtomLibrary(8,"O","Oxygen",15.999,0.66,0);
Atom["F"] = BioAtomLibrary(9,"F","Fluorine",18.998,0.64,0);
Atom["Ne"] = BioAtomLibrary(10,"Ne","Neon",20.180,1.00,0);
Atom["Na"] = BioAtomLibrary(11,"Na","Sodium",22.990,1.91,0);
Atom["Mg"] = BioAtomLibrary(12,"Mg","Magnesium",24.305,1.60,0);
Atom["Al"] = BioAtomLibrary(13,"Al","Aluminium",26.982,1.43,0);
Atom["Si"] = BioAtomLibrary(14,"Si","Silicon",28.086,1.34,0);
Atom["P"] = BioAtomLibrary(15,"P","Phosphorus",30.974,1.30,0);
Atom["S"] = BioAtomLibrary(16,"S","Sulphur",32.066,1.04,0);
Atom["Cl"] = BioAtomLibrary(17,"Cl","Chlorine",35.452,1.62,0);
Atom["Ar"] = BioAtomLibrary(18,"Ar","Argon",39.948,1.00,0);
Atom["K"] = BioAtomLibrary(19,"K","Potassium",39.098,2.34,0);
Atom["Ca"] = BioAtomLibrary(20,"Ca","Calcium",40.078,1.97,0);
Atom["Sc"] = BioAtomLibrary(21,"Sc","Scandium",44.956,1.64,0);
Atom["Ti"] = BioAtomLibrary(22,"Ti","Titanium",47.883,1.45,0);
Atom["V"] = BioAtomLibrary(23,"V","Vanadium",50.941,1.35,0);
Atom["Cr"] = BioAtomLibrary(24,"Cr","Chromium",51.996,1.27,0);
Atom["Mn"] = BioAtomLibrary(25,"Mn","Manganese",54.938,1.32,0);
Atom["Fe"] = BioAtomLibrary(26,"Fe","Iron",55.847,1.27,0);
Atom["Co"] = BioAtomLibrary(27,"Co","Cobalt",58.933,1.26,0);
Atom["Ni"] = BioAtomLibrary(28,"Ni","Nickel",58.691,1.24,0);
Atom["Cu"] = BioAtomLibrary(29,"Cu","Copper",63.546,1.28,0);
Atom["Zn"] = BioAtomLibrary(30,"Zn","Zinc",65.392,1.39,0);
Atom["Ga"] = BioAtomLibrary(31,"Ga","Gallium",69.723,1.40,0);
Atom["Ge"] = BioAtomLibrary(32,"Ge","Germanium",72.612,1.40,0);
Atom["As"] = BioAtomLibrary(33,"As","Arsenic",74.922,1.50,0);
Atom["Se"] = BioAtomLibrary(34,"Se","Selenium",78.963,1.60,0);
Atom["Br"] = BioAtomLibrary(35,"Br","Bromine",79.904,1.11,0);
Atom["Kr"] = BioAtomLibrary(36,"Kr","Krypton",83.801,1.14,0);
Atom["Rb"] = BioAtomLibrary(37,"Rb","Rubidium",85.468,2.50,0);
Atom["Sr"] = BioAtomLibrary(38,"Sr","Strontium",87.621,2.15,0);
Atom["Y"] = BioAtomLibrary(39,"Y","Yttrium",88.906,1.80,0);
Atom["Zr"] = BioAtomLibrary(40,"Zr","Zirconium",91.224,1.60,0);
Atom["Nb"] = BioAtomLibrary(41,"Nb","Niobium",92.906,1.48,0);
Atom["Mo"] = BioAtomLibrary(42,"Mo","Molybdenum",95.941,1.40,0);
Atom["Tc"] = BioAtomLibrary(43,"Tc","Technetium",98.000,1.35,0);
Atom["Ru"] = BioAtomLibrary(44,"Ru","Ruthenium",101.072,1.32,0);
Atom["Rh"] = BioAtomLibrary(45,"Rh","Rhodium",102.905,1.34,0);
Atom["Pd"] = BioAtomLibrary(46,"Pd","Palladium",106.421,1.37,0);
Atom["Ag"] = BioAtomLibrary(47,"Ag","Silver",107.868,1.44,0);
Atom["Cd"] = BioAtomLibrary(48,"Cd","Cadmium",112.411,1.57,0);
Atom["In"] = BioAtomLibrary(49,"In","Indium",114.821,1.66,0);
Atom["Sn"] = BioAtomLibrary(50,"Sn","Tin",118.710,1.58,0);
Atom["Sb"] = BioAtomLibrary(51,"Sb","Antimony",121.753,1.60,0);
Atom["Te"] = BioAtomLibrary(52,"Te","Tellurium",127.603,1.70,0);
Atom["I"] = BioAtomLibrary(53,"I","Iodine",126.904,1.95,0);
Atom["Xe"] = BioAtomLibrary(54,"Xe","Xenon",131.292,1.33,0);
Atom["Cs"] = BioAtomLibrary(55,"Cs","Cesium",132.905,2.71,0);
Atom["Ba"] = BioAtomLibrary(56,"Ba","Barium",137.327,2.24,0);
Atom["La"] = BioAtomLibrary(57,"La","Lanthanum",138.906,1.87,0);
Atom["Ce"] = BioAtomLibrary(58,"Ce","Cerium",140.115,1.82,0);
Atom["Pr"] = BioAtomLibrary(59,"Pr","Praseodymium",140.908,1.83,0);
Atom["Nd"] = BioAtomLibrary(60,"Nd","Neodymium",144.243,1.82,0);
Atom["Pm"] = BioAtomLibrary(61,"Pm","Promethium",145.000,1.63,0);
Atom["Sm"] = BioAtomLibrary(62,"Sm","Samarium",150.363,1.80,0);
Atom["Eu"] = BioAtomLibrary(63,"Eu","Europium",151.965,2.04,0);
Atom["Gd"] = BioAtomLibrary(64,"Gd","Gadolinium",157.253,1.80,0);
Atom["Tb"] = BioAtomLibrary(65,"Tb","Terbium",158.925,1.78,0);
Atom["Dy"] = BioAtomLibrary(66,"Dy","Dysprosium",162.503,1.77,0);
Atom["Ho"] = BioAtomLibrary(67,"Ho","Holmium",164.930,1.77,0);
Atom["Er"] = BioAtomLibrary(68,"Er","Erbium",167.263,1.76,0);
Atom["Tm"] = BioAtomLibrary(69,"Tm","Thuliam",168.934,1.75,0);
Atom["Yb"] = BioAtomLibrary(70,"Tm","Ytterbium",173.043,1.94,0);
Atom["Lu"] = BioAtomLibrary(71,"Lu","Lutetium",174.967,1.73,0);
Atom["Hf"] = BioAtomLibrary(72,"Hf","Hafnium",178.492,1.59,0);
Atom["Ta"] = BioAtomLibrary(73,"Ta","Tantalum",180.948,1.48,0);
Atom["W"] = BioAtomLibrary(74,"W","Tungsten",183.853,1.41,0);
Atom["Re"] = BioAtomLibrary(75,"Re","Rhenium",186.207,1.46,0);
Atom["Os"] = BioAtomLibrary(76,"Os","Osmium",190.210,1.34,0);
Atom["Ir"] = BioAtomLibrary(77,"Ir","Iridium",192.223,1.36,0);
Atom["Pt"] = BioAtomLibrary(78,"Pt","Platinum",195.083,1.39,0);
Atom["Au"] = BioAtomLibrary(79,"Au","Gold",196.967,1.44,0);
Atom["Hg"] = BioAtomLibrary(80,"Hg","Mercury",200.593,1.62,0);
Atom["Tl"] = BioAtomLibrary(81,"Tl","Thallium",204.383,1.73,0);
Atom["Pb"] = BioAtomLibrary(82,"Pb","Lead",207.210,1.75,0);
Atom["Bi"] = BioAtomLibrary(83,"Bi","Bismuth",208.980,1.70,0);
Atom["Po"] = BioAtomLibrary(84,"Po","Polonium",209.000,1.70,0);
Atom["At"] = BioAtomLibrary(85,"At","Astatine",210.000,1.53,0);
Atom["Rn"] = BioAtomLibrary(86,"Rn","Radon",222.000,1.53,0);
Atom["Fr"] = BioAtomLibrary(87,"Fr","Francium",223.000,1.53,0);
Atom["Ra"] = BioAtomLibrary(88,"Ra","Radium",226.025,1.53,0);
Atom["Ac"] = BioAtomLibrary(89,"Ac","Actinium",227.028,1.88,0);
Atom["Th"] = BioAtomLibrary(90,"Th","Thorium",232.038,1.80,0);
Atom["Pa"] = BioAtomLibrary(91,"Pa","Protactinium",231.035,1.61,0);
Atom["U"] = BioAtomLibrary(92,"U","Uranium",238.028,1.55,0);
Atom["Np"] = BioAtomLibrary(93,"Np","Neptunium",237.048,1.58,0);
Atom["Pu"] = BioAtomLibrary(94,"Pu","Plutonium",244.000,1.64,0);
Atom["Am"] = BioAtomLibrary(95,"Am","Americium",243.000,1.73,0);
Atom["Cm"] = BioAtomLibrary(96,"Cm","Curium",247.000,1.42,0);
Atom["Bk"] = BioAtomLibrary(97,"Bk","Berkelium",247.000,1.42,0);
Atom["Cf"] = BioAtomLibrary(98,"Cf","Californium",251.000,1.42,0);
Atom["Es"] = BioAtomLibrary(99,"Es","Einsteinium",254.000,1.42,0);
Atom["Fm"] = BioAtomLibrary(100,"Fm","Fermium",257.000,1.42,0);
Atom["Md"] = BioAtomLibrary(101,"Md","Mendelevium",258.000,1.42,0);
Atom["No"] = BioAtomLibrary(102,"No","Nobelium",259.000,1.42,0);
Atom["Lr"] = BioAtomLibrary(103,"Lr","Lawrencium",260.000,1.42,0);

}

#endif

-- 
Be Happy,
Enjoy Life.
with love
shiva.
********************************************************************
*   If the Problem is Clear, the Solution is  Near.    ...shiva... *
********************************************************************



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:59 MET