Hi,
I'm using VGM 2.08.04 and ROOT v5-14-00 and am having trouble creating Elements via a RootGM factory. After creating 15 elements ROOT's TGeoElementTable's underlying TObjArray overflows. This is due to a hard coded array size and unchecked insertion. I've reported this to the ROOT bug tracking page.
I tried to work around the problem by only creating an element if it doesn't exist but as far as I can tell the RootGM layer doesn't know about the automatically filled element table.
The appended vgm-test.cc file provides an example of what I mean.
Please let me know if I'm missing something.
Thanks,
-Brett.
// vgm-test.cc
#include <VGM/volumes/IFactory.h>
#include <VGM/materials/IMaterialFactory.h>
#include <VGM/materials/IElement.h>
#include <ClhepVGM/transform.h>
#include <CLHEP/Units/SystemOfUnits.h>
#include <cassert>
using namespace CLHEP;
using namespace std;
VGM::IElement* make_element(VGM::IMaterialFactory* mf,
const char* name, const char* symbol, double atomic_number, double atomic_mass){
cerr << "Element: " << name << " (" << symbol << ") with mass="
<< atomic_mass << " number=" << atomic_number << " ";
// tried lookup by symbol also
VGM::IElement* el = const_cast<VGM::IElement*>(mf->Element(name));
if (el) {
cerr << "(exists)\n"; return el;
void make_material(VGM::IFactory& fact)
{
VGM::IMaterialFactory* mf = fact.MaterialFactory(); assert(mf);
double a=0; // atomic mass
double z=0; // atomic number
cerr << "Element store is of size " << mf->Elements().size() << endl;
a = 1.0079*g/mole;
VGM::IElement* elH = make_element(mf, "Hydrogen","H", z=1, a);
a = 10.811*g/mole;
VGM::IElement* elB = make_element(mf,"Boron", "B", z=5, a);
a = 12.0107*g/mole;
VGM::IElement* elC = make_element(mf,"Carbon", "C", z=6, a);
a = 14.0067*g/mole;
VGM::IElement* elN = make_element(mf,"Nitrogen", "N", z=7, a);
a = 15.9994*g/mole;
VGM::IElement* elO = make_element(mf,"Oxygen", "O", z=8, a);
a = 22.9898*g/mole;
VGM::IElement* elNa = make_element(mf,"Sodium", "Na",z=11,a);
a = 24.3050*g/mole;
VGM::IElement* elMg = make_element(mf,"Mg", "Mg",z=12,a);
a = 26.9815*g/mole;
VGM::IElement* elAl = make_element(mf,"Al", "Al",z=13,a);
a = 28.0855*g/mole;
VGM::IElement* elSi = make_element(mf,"Silicon", "Si",z=14,a);
a = 30.9738*g/mole;
VGM::IElement* elP = make_element(mf,"Phosphorus","P",z=15,a);
a = 32.066*g/mole;
VGM::IElement* elS = make_element(mf,"S", "S",z=16,a);
a = 39.948*g/mole;
VGM::IElement* elAr = make_element(mf,"Argon", "Ar",z=18,a);
a = 39.0983*g/mole;
VGM::IElement* elK = make_element(mf,"Potassium", "K",z=19,a);
a = 40.078*g/mole;
VGM::IElement* elCa = make_element(mf,"Calcium", "Ca",z=20,a);
a = 51.9961*g/mole;
VGM::IElement* elCr = make_element(mf,"Cr", "Cr",z=24,a);
a = 54.9381*g/mole;
VGM::IElement* elMn = make_element(mf,"Mn", "Mn",z=25,a);
a = 55.847*g/mole;
VGM::IElement* elFe = make_element(mf,"Fe", "Fe",z=26,a);
a = 58.6934*g/mole;
VGM::IElement* elNi = make_element(mf,"Ni", "Ni",z=28,a);
cerr << "Element store is of size " << mf->Elements().size() << endl;
const double density = 1.0*g/cm3;
VGM::ElementVector elements;
VGM::MassFractionVector massfrac;
elements.push_back(elH); massfrac.push_back(0.1119);
elements.push_back(elO); massfrac.push_back(0.8881);
VGM::IMaterial* waterMat = mf->CreateMaterial("WaterMat",density,elements,massfrac);
assert(waterMat);
assert(mf->Material("WaterMat"));
int mediumCounter = 0;
VGM::IMedium* waterMed = mf->CreateMedium("WaterMed",mediumCounter++,waterMat,0,0);
assert(waterMed);
}
void make_volume(VGM::IFactory& fact)
{
VGM::ISolid* worldS = fact.CreateBox("world_solid", 10,10,10);
assert(worldS);
VGM::IVolume* worldV = fact.CreateVolume("world_volume",worldS,"WaterMed");
assert(worldV);
VGM::IPlacement* world =
fact.CreatePlacement("world",0,worldV,0, ClhepVGM::Identity());
assert(world);
}
#include <RootGM/volumes/Factory.h>
int main()
{
RootGM::Factory fact;
make_material(fact);
make_volume(fact);
return 0;
}
Element: Hydrogen (H) with mass=6.29081e+21 number=1 (created) Element: Boron (B) with mass=6.74769e+22 number=5 (created) Element: Carbon (C) with mass=7.49649e+22 number=6 (created) Element: Nitrogen (N) with mass=8.74229e+22 number=7 (created) Element: Oxygen (O) with mass=9.98604e+22 number=8 (created) Element: Sodium (Na) with mass=1.43491e+23 number=11 (created) Element: Mg (Mg) with mass=1.517e+23 number=12 (created) Element: Al (Al) with mass=1.68405e+23 number=13 (created) Element: Silicon (Si) with mass=1.75296e+23 number=14 (created) Element: Phosphorus (P) with mass=1.93323e+23 number=15 (created) Element: S (S) with mass=2.0014e+23 number=16 (created) Element: Argon (Ar) with mass=2.49336e+23 number=18 (created) Element: Potassium (K) with mass=2.44032e+23 number=19 (created) Element: Calcium (Ca) with mass=2.50147e+23 number=20 (created) Element: Cr (Cr) with mass=3.24534e+23 number=24 (created) Element: Mn (Mn) with mass=3.42897e+23 number=25 Error in <TObjArray::AddAt>: index 128 out of bounds (size: 128, this: 0x08406038)(created)
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:55:09 MET