Message: Re: G4Material WARNING: doublicate name of the new material Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Ok Re: G4Material WARNING: doublicate name of the new material 

Forum: Geometry
Re: Question G4Material WARNING: doublicate name of the new material (Stefan E. Mueller)
Re: None Re: G4Material WARNING: doublicate name of the new material (John Apostolakis)
Date: 20 Jun, 2014
From: Stefan E. Mueller <Stefan E. Mueller>

Thanks,

the flag just worked out fine. I defined the G4Material* variables in the header file one by one as private variables and assigned values to them inside the {...} block of an if-case.

In the header file DetectorConstruction.hh I put:

 private:
     G4bool fMaterialsCreated;
    G4Material* COPPER;
    G4Material* BERYLLIUM;
    ...

And in DetectorConstruction.cc:

    G4NistManager* man = G4NistManager::Instance();
    if ( !fMaterialsCreated ) {

    BERYLLIUM = man->FindOrBuildMaterial("G4_Be");

    G4Element* elCu = man->FindOrBuildElement("Cu");   
    density = 8.96*g/cm3; 
    COPPER = new G4Material("Copper",density,ncomponents=1);
    COPPER->AddElement(elCu, fractionmass=100.*perCent);
   ...

    }

Now the warnings are gone, the materials are defined only once, even if

DetectorConstruction->UpdateGeometry();

is called between runs.

Thanks,

Stefan

 Add Message Add Message
to: "Re: G4Material WARNING: doublicate name of the new material"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]