G4GenericMessenger - Not showing properties

I am following the Geant4 tutorials by Physics Matters on YouTube, and tutorial 10: user-defined messengers goes through how to implement a messenger to edit the parameters of the detector(s).

However, i keep getting weird errors, and i am not sure where i am going wrong…

i am getting errors like these:

This is my code for the messenger:


MyDetectorConstruction::MyDetectorConstruction() : nCols(0), nRows(0) {

	fMessenger = new G4GenericMessenger(this, "/detector/", "Detector Construction");

	fMessenger->DeclareProperty("nCols", nCols, "Number of columns");
	fMessenger->DeclareProperty("nRows", nRows, "Number of rows");

	DefineMaterials();
}

MyDetectorConstruction::~MyDetectorConstruction()
{
delete fMessenger;
}


class MyDetectorConstruction : public G4VUserDetectorConstruction
{
public:
	MyDetectorConstruction();
	~MyDetectorConstruction();

	virtual G4VPhysicalVolume *Construct();

private:
	G4int nRows, nCols;
	G4Box *solidWorld, *solidRadiator, solidDetector;
	G4LogicalVolume *logicWorld, *logicRadiator, logicDetector;
	G4VPhysicalVolume *physWorld, *physRadiator, *physDetector;

	G4Material *SiO2, *H2O, *Aerogel, *worldMat;
	G4Element *C;

	G4GenericMessenger *fMessenger;

	void DefineMaterials();
	virtual void ConstructSDandField();


};

/detector/nCols 10
/detector/nCols 10
/run/reinitializeGeometry
/run/beamOn 100

there is a lot of useful tips in this post: Beginner at geant4 - #2 by John_McFee

besides: sometimes you define G4Box objects as pointers („*solidWorld“), sometimes you don’t („solidDetector“). is that on purpose? Same for G4LogicalVolume…

Ah!

No those were a mistake, both should have been as pointers!!
-Thank you, a mistake on my behalf…

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.