The hexagonal cells on the images can be subdivided in vertical sets. So, I would implement a function PlaceHexagons()
that places a vertical set of hexagons into its mother volume (box).
Parameters:
d
- the mesh cell diameter
xc
- x coordinate of the set
nhex
- number of hexagons in the set
logHexagon
- logical volume of the hexagon
logMother
- its mother logical volume
It is easy to verify that the radius of the circumscribed circle around a cell is r=d/sqrt(3)
, hence the distance between two adjacent vertical sets is 1.5*r
. So, xc
for the sets should be equal: 0., -1.5*r, 1.5.*r, -3*r, 3.*r, ...
void PlaceHexagons(double d, double xc, int nhex, G4LogicalVolume* logHexagon, G4LogicalVolume* logMother)
{
bool checkOverlaps = true;
for (int i=0; i<nhex; ++i) {
G4ThreeVector pos(xc, d*(i - (nhex-1)*0.5), 0.);
new G4PVPlacement(0, // no rotation
pos, // position
logHexagon, // logical volume
"Hexagon", // its name
logMother, // its mother volume
false, // no boolean operation
0, // copy number
checkOverlaps); //overlaps checking
}
}
The function is similar to replica, but it is easier to understand how the hexagons are placed into the mother volume.