Message: Re: Custom G4Solid Units Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Custom G4Solid Units 

Forum: Geometry
Re: Question Custom G4Solid Units (Andrew Davis)
Date: 31 Mar, 2014
From: Tom Roberts <Tom Roberts>

I think the best approach to units in Geant4 is to always convert to the standard unit as soon as a number is input. So if you type a unitsful number into the code, multiply by its unit symbol as you type it. When you read a value from a file, the file format should specify its unit, either implicitly or as an explicit field, and the conversion should be applied right there. Anything else will probably cause great confusion, especially in several years when you come back to the code :-).

Because of the way units symbols are defined, you don't need to know what the standard Geant4 units are, you just need to know what unit applies to any given input value, and you multiply by the appropriate symbol immediately.

Similarly, divide by the desired unit only when writing a value to a file.

Some external libraries use different units. Again you don't need to know what the standard Geant4 units are, you just need to know what units the external library uses: divide when passing unitsful values to the library, and multiply when retrieving unitsful values. Do it right at the interface function(s).

 Add Message Add Message
to: "Re: Custom G4Solid Units"

 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 ]