Hello I need to set the sample material using a detector construction messenger
Here the DetectorMessenger
MGEMIDetectorMessenger.cc (3.5 KB)
MGEMIDetectorMessenger.hh (2.8 KB)
then in the DetectorConstruction I called the messenger (line 269)
theMessenger = new MGEMIDetectorMessenger(this);
and I setted the sample material as (line 338)
G4Material* sample_mat = G4Material::GetMaterial(sample_mat_name);
B1DetectorConstruction.cc (58.9 KB)
In the Detectorconstruction.hh I defined the function (line 81)
void SetSampleMaterial(G4String mat_name){sample_mat_name = mat_name;};
B1DetectorConstruction.hh (13.2 KB)
I don’t get errors during the building and the compiling, but when I run the simulation I get the error
------ EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : GeomMgt0002
issued by : G4Region::ScanVolumeTree()
Logical volume <sample_log>
does not have a valid material pointer.
A logical volume belonging to the (tracking) world volume must have a valid material.Check your geometry construction.
*** Fatal Exception *** core dump ***
**** Track information is not available at this moment
**** Step information is not available at this moment
-------- EEEE -------- G4Exception-END --------- EEEE -------
i.e. it doens’t get the material from the messenger
Edit:
Maybe the problem is the function
void SetSampleMaterial(G4String mat_name){sample_mat_name = "SampleName";};
in the detector construction.hh because even if I wrtite the string (“SampleName”) it doesn’t set sample_mat_name="SampleName".