G4Tubs vs G4Box placement


I’m having issues defining a detector based on the basic example B4c with G4Tubs instead of G4Box as the solid shapes (I’ve also enlarged the transverse face and increased the number of layers). However, I find significantly different response distributions between the two shapes. When I switch from G4Box to G4Tubs, I set the outer radius to sqrt(2) times the half length of the box face so that the cylinder has a somewhat larger volume than the box. Oddly, the response distribution of the cylindrical calorimeter has a significant (heavy) low energy tail; whereas the rectangular calorimeter has a normally distributed response.

Am I missing something in placing or orienting the solids; is there something more I need to do besides replacing G4Box with G4Tubs?


I think I found the problem. The dynamic cast in the primary generator action was still to a G4Box. So, I think when the code intended to place the particle gun at the face of the detector, it was really placing it somewhere in the interior. Correcting the dynamic cast to the correct type seems to have solved my problem.

You shouldn’t need a cast at all. Unless you’re calling a G4Box-specific Set function (never a good idea :-), the G4VSolid* base pointer should be sufficient everywhere.

Good point. The cast is there in the example, so I just ran with it.