Message: G4UnionSolid: problem with dimensions of constituents Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question G4UnionSolid: problem with dimensions of constituents 

Forum: Geometry
Date: 22 Oct, 2008
From: Angela Lucaci-Timoce <Angela Lucaci-Timoce>

Hello, I have a weird problem with an union of a box and a trapezoid (right wedge), and I hope you can help me. This is what I do:

---------------------------------------
{
  G4double trap_small_x = 1519 * mm;
  G4double trap_x       = 3245 * mm;
  G4double trap_y       = 1725 * mm;
  G4double trap_z       = 1274 * mm;

  G4Trap *top = new G4Trap("top", trap_z, trap_y, trap_x, trap_small_x);	

  G4double box_half_x = trap_x/2.;
  G4double box_half_y = trap_y/2;
  G4double box_half_z = 456 * mm;

  G4Box *bottom = new G4Box("bottom", box_half_x, box_half_y, box_half_z);

  //-----------------------------------------------
  //Build an union out of the two
  //---------
  //x-dimension of the trapezoid center of gravity
  G4double trap_center_of_grav_half_x = (trap_small_x + trap_z/2 * tan(pi/4.))/2;

  //shift the top trapezoidal part with respect to the bottom part to get the union
  G4double shift_x = (-1)*abs(box_half_x - trap_center_of_grav_half_x);
  G4double shift_y = box_half_z + trap_z/2.;
  G4UnionSolid* union = new G4UnionSolid("union", bottom, top,
0,G4ThreeVector(shift_x, shift_y, 0)); 

  G4LogicalVolume *logVolume = new G4LogicalVolume(union, material, "logVolume", 0, 0, 0);
}
-----------------------------------------------------------

The above works without a problem. However, I have then another function, with my logical volume as argument, and I need to access the dimensions of the solids building my union. I thought I could do something like this:

--------------------------------------------------------
void function(G4LogicalVolume* logVolume)
{
  G4UnionSolid *union = (G4UnionSolid*)logVolume->GetSolid();

  G4Box *bottom = (G4Box*)union->GetConstituentSolid(0);
  G4double box_half_x = bottom->GetXHalfLength();
  G4double box_half_z = bottom->GetYHalfLength();

  //==================================
  G4Trap *top = (G4Trap*)union->GetConstituentSolid(1);
  TopEndcap->DumpInfo();
  G4cout<<"X1: "<<top->GetXHalfLength1()<<G4endl;
  G4cout<<"X2: "<<top->GetXHalfLength2()<<G4endl;
  G4cout<<"X3: "<<top->GetXHalfLength3()<<G4endl;
  G4cout<<"X4: "<<top->GetXHalfLength4()<<G4endl;
  G4cout<<"Y1: "<<top->GetYHalfLength1()<<G4endl;
  G4cout<<"Y2: "<<top->GetYHalfLength2()<<G4endl;
  G4cout<<"Z: "<<top->GetZHalfLength()<<G4endl;
}
---------------------------------------------------------

DumpInfo() gives the right values out:

-----------------------------------------------------------
    *** Dump for Displaced solid - placedB ***
    ===================================================
 Solid type: G4DisplacedSolid
 Parameters of constituent solid:
===========================================================
-----------------------------------------------------------
    *** Dump for solid - TopEndcap ***
    ===================================================
 Solid type: G4Trap
 Parameters:
    half length Z: 637 mm
    half length Y of face -fDz: 862.633 mm
    half length X of side -fDy1, face -fDz: 1647.61 mm
    half length X of side +fDy1, face -fDz: 784.974 mm
    half length Y of face +fDz: 862.633 mm
    half length X of side -fDy2, face +fDz: 1647.61 mm
    half length X of side +fDy2, face +fDz: 784.974 mm
    std::tan(theta)*std::cos(phi): 0 degrees
    std::tan(theta)*std::sin(phi): 0 degrees
    std::tan(alpha), -fDz: -28.6479 degrees
    std::tan(alpha), +fDz: -28.6479 degrees
    trap side plane equations:
        0 X + -1 Y + 0 Z + -862.633 = 0
        0 X + 1 Y + -0 Z + -862.633 = 0
        -1 X + 0 Y + 0 Z + -1216.29 = 0
        0.707107 X + 0.707107 Y + 0 Z + -860.047 = 0
-----------------------------------------------------------
===========================================================
 Transformations:
    Direct transformation - translation :
           (-431.317,1294.61,0)
                          - rotation    :

   [ (           1             0             0)
     (           0             1             0)
     (           0             0             1) ]

===========================================================

but I cannot get the dimensions of the trapezoid with GetXHalfLength()... The output looks like this:

X1: 1 X2: 0 X3: 1 X4: 431.317 Y1: 0 Y2: 0

Do I understand wrong the meaning of GetZHalfLength() etc as half of dimensions, or it is something wrong with my code?

Thank you in advance for your help, Angela

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

1 None: Re: G4UnionSolid: problem with dimensions of constituents(Replay from Ivana Hrivnacova)   (Tatiana Nikitina - 23 Oct, 2008)
 Add Message Add Message
to: "G4UnionSolid: problem with dimensions of constituents"

 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 ]