0%

geant4DetectorConstruction

geant detector construction

  1. 几何旋转符合左手法则及RotationMatrix的使用
    经过验证geant4中的rotate符合左手法则
1
2
3
4
G4RotationMatrix *rot=new G4RotationMatrix;
rot->rotateX(90*degree);
rot->rotateY(90*degree);
rot->rotateZ(90*degree);

注意,再次对rot重复赋值无效,如对上述代码再作如下操作rot->rotateX(180*degree),该操作将无效,不会改变之前的rot;
那么,要对rot再次赋值该怎么办呢?如下:只需在再次赋值前加rot =new G4RotationMatrix即可;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  G4RotationMatrix* rotationMatrix_X = new G4RotationMatrix;

for(G4int x_col_num = 0; x_col_num <=NBD_colNb; x_col_num++){
if(x_col_num==0){ // the center colume
NBDx = NBDx0;
for(G4int y_row_num = 0; y_row_num <=NBD_rowNb; y_row_num++ ){
index// NBDx = NBDx0;
indexNBDy = NBDy0+R*sin(y_row_num*theta);
indexNBDz = NBDz0+R*(1-cos(y_row_num*theta));

indexif(y_row_num==0){
index // center position
index rotationMatrix_X = new G4RotationMatrix;
index rotationMatrix_X->rotateX(y_row_num*theta);

index new G4PVPlacement(rotationMatrix_X, //no rotation
indexindexindex G4ThreeVector(NBDx,NBDy,NBDz), //at (0,0,0)
indexindexindex logicAssembleNBD, //its logical volume
indexindexindex "AssembleNBD", //its name
indexindexindex expHall_logV, //its mother volume
indexindexindex false, //no boolean operation
indexindexindex 0, //copy number
indexindexindex true); //overlaps checking
index}
indexelse{
index //+y++
index rotationMatrix_X = new G4RotationMatrix;
index rotationMatrix_X->rotateX(-y_row_num*theta);

index new G4PVPlacement(rotationMatrix_X, //no rotation
indexindexindex G4ThreeVector(NBDx,NBDy,NBDz), //at (0,0,0)
indexindexindex logicAssembleNBD, //its logical volume
indexindexindex "AssembleNBD", //its name
indexindexindex expHall_logV, //its mother volume
indexindexindex false, //no boolean operation
indexindexindex 0, //copy number
indexindexindex true); // overlaps checking
index //-y++
index rotationMatrix_X = new G4RotationMatrix;
index rotationMatrix_X->rotateX(y_row_num*theta);
index new G4PVPlacement(rotationMatrix_X, //no rotation
indexindexindex G4ThreeVector(NBDx,-NBDy,NBDz), //at (0,0,0)
indexindexindex logicAssembleNBD, //its logical volume
indexindexindex "AssembleNBD", //its name
indexindexindex expHall_logV, //its mother volume
indexindexindex false, //no boolean operation
indexindexindex 0, //copy number
indexindexindex true); // overlaps checking
index}
}
...

  1. G4VParameterisation()的使用
  • ComputeTransformation defines where one of the copies is placed
  • ComputeDimensions defines the size of one copy, and a constructor that initializes any member variables that are required.

G4VParameterisation的具体应用可参看Basics/B2/B2b

Donate comment here.

欢迎关注我的其它发布渠道