Message: Re: Printing out density of each voxel in example Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Printing out density of each voxel in example 

Forum: Geometry
Re: Question Printing out density of each voxel in example (Katya Gilbo)
Re: None Re: Printing out density of each voxel in example (Youming Yang)
Re: Ok Re: Printing out density of each voxel in example (Katya Gilbo)
Date: 26 Jul, 2016
From: Youming Yang <Youming Yang>

Thank you for the kind words Katya. C:

To run the function (if you've declared your function as void DicomNestedParamDetectorConstruction::printPhantom(), which means it will be accessible and call-able by other functions within DicomNestedParamDetectorConstruction), you can just put the line at the end of the createPhantom function within the .cc file:

   void DicomNestedParamDetectorConstruction::createPhantom()

       ... //original code already in the .cc file


As for a more general answer to your original question: > I am just wondering; how does GEANT4 know to execute the new function?

Geant4 will know to run some commands internally, either by checking whether the user has specifically implemented that command (such as a userSteppingAction), or by some explicit statement in the manual that such a function _must_ exist and follow certain rules.

How these generally work is that a base class will have a "virtual void/int/etc." function declared that has no functionality, but which will be called by the run manager. It is expected to be basically overwritten by the user in a derived class, to add the user-specific functionality that behaves in a manner expected of that class (i.e. is ready to take certain inputs, can only output certain values or none at all, knows that it is allowed/not allowed to modify certain runtime values, etc.)

Another method that is quite commonly used for the _user_ to interact with the code is via a messenger class. The framework for that is pretty straightforward, and you can easily modify the messenger classes from existing examples that either have a detector messenger or primary generator messenger.

Again similar rules apply for messenger classes, for example the initialize() command you mentioned (which you call from the messenger via /run/initialize) must be executed before any primary generator Messenger commands can be executed (the PGA doesn't generally get built prior that). Similarly, if you use a messenger for your geometry, it's best to have the dimensions etc. of your geometry finalized before the /run/initialize command, otherwise you need to implement some sort of /geo/update command in order to delete the current geometry elements and create new ones (some examples have this I believe).

Hope that helps, Ming

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Ok: Re: Printing out density of each voxel in example   (Katya Gilbo - 26 Jul, 2016)
 Add Message Add Message
to: "Re: Printing out density of each voxel in example"

 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 ]