Red block visible outside World volume

Dear All,

Observing a strange behaviour while visualizing particle interaction in a detector geometry.
Short description of the geometry :

  1. Three concentric cylinders of different radiuses are built. The innermost cylinder is filled with Air and rest two filled with Fe.
  2. Primary particles generated from ParticleGun originated at vertex(0,0,0)

In some of the events, I am observing random red blocks(even outside the World). Not able to figure out the reason for that.
Does anyone notice this ? Please let me possible explanation of this behaviour.

Please find the attached picture. Thanks in advance.

Tapasipic.pdf (273.4 KB)

Interesting. Do you have any volumes out there? Have you implemented DrawHits and /vis/scene/add/hits? Or drawing of volumes from your own code?

Hi Allison,

Thanks for your reply.
Replying you in b/w lines:

Do you have any volumes out there?
There is no volume beyond the rectangular box. The box is the World volume.

Have you implemented DrawHits and /vis/scene/add/hits ?
How to implement DrawHits ?

I tried to see the hits through /vis/scene/add/hits beafore \run\BeamOn however didn’t notice anything to navigate. I am using OpenGlStoredQt viewer.
Could you please provide more details to implement this ? May be a set of commands or any reference will help.

Or drawing of volumes from your own code?
Yes, I could visualize different volumes in the geometry.

  • /vis/scene/add/volume Vol_name
  • /vis/specify vol_name


Hi Tapasi

Are you, perhaps, using some borrowed code, in which someone else has implemented hits? Have a look through your code for DrawHits.

By “drawing of volumes from your own code” I meant from your C++ code. Have a look through your code for the use of VisManager.

Otherwise it’s an intriguing mystery.


Hi John,
My apology for very late reply. I have written the whole code following some examples specially basic/B2a and extended/runAnEvent/RE05. Recently, I am able to identify the cause of the problem. However I am not sure “why it is causing this type problem”. It was an attribute setting causing the issue inside the Draw() function of as

void CellHit::Draw(){

G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
G4Transform3D trans(fRot,fPos);

G4VisAttributes attribs;
const G4VisAttributes* pVA = fLogV->GetVisAttributes();
if(pVA) attribs = *pVA;
G4Colour colour(1.,0.,0.);


So, I would like to explain a bit. The geometry contain coaxial cylinders in the form of tracker and calorimeter. The outermost two layers are calorimeter. Each of the calorimeter is divided into Z, phi direction in cells. Hits information (e.g. edep, z, phi, pos etc) are collected from each cell(z,phi). I have noticed that when (aTrans.NetRotation()) is defined in is breaking the run :

G4AffineTransform aTrans = touchable->GetHistory()->GetTopTransform();



Once I commented out the draw() …the red blocks disappeared. Hope I could clarify. If possible please explain me the reason of the problem.

Stay Safe…


Hi Tapasi

Without more information I find it difficult to comment. You are setting fRot and fPos for each hit? And they are taken from the inverse of the top transform? That might be OK but is it right. Is it the inverse you need, or not? Have a look at Frequently Asked Questions, Geometry, Conversion Global to Local Co-ordinates. (I am not an expert here.) If these are wrong then the drawings will be in the wrong place, which could explain the red blocks.

I cannot see anything in your code that would explain “when ( aTrans.NetRotation() ) is defined in is breaking the run”. Aaaah. Is fRot a pointer? I wonder…is fRot a pointer? If it is it points to aTrans.NetRotation() that will have been destroyed before drawing. You need to copy the rotation matrix itself; it is not enough to copy the pointer.

Of course, if you comment out the Draw method hits will not be drawn. But you want drawing (I think) - you just want to in the right place!

Good luck


Hi John,
Thanks for explaining… I will ask in the other forum. I checked that fRot is not a pointer G4RotationMatrix fRot.
I am facing difficulty to understand the functionality of touchable->GetHistory()->GetTopTransform() …it’s not clear from the user manual. Need to spend sometime on that.

You are setting fRot and fPos for each hit? And they are taken from the inverse of the top transform?
Yes…I intend to set the fRot and fPos for each hit…though I have customised it. …fPos is set from WorldPosition and fRot is breaking the Run.

Attaching the macros …please have a look.

Thanks a lot.

Tapasi (3.7 KB) (6.6 KB)