~maus-emr/maus/devel

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "BarParameterisation.hh"

#include "G4VPhysicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4Box.hh"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

BarParameterisation::BarParameterisation(G4double BarWidth,
					 G4double BarHeight,
					 G4int NbOfBars,
					 G4double Gap)
{
  fBarWidth = BarWidth;
  fBarHeight = BarHeight;
  fNbOfBars = NbOfBars;
  fGap = Gap;
  rotation = new G4RotationMatrix();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

BarParameterisation::~BarParameterisation()
{}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void BarParameterisation::ComputeTransformation
(const G4int copyNo, G4VPhysicalVolume* physVol) const
{
  G4ThreeVector placement(0.0,0.0,0.0);

  G4ThreeVector rowX(1.0,0.0,0.0);
  G4ThreeVector rowY(0.0,1.0,0.0);
  G4ThreeVector rowZ(0.0,0.0,1.0);

  rotation->setRows(rowX,rowY,rowZ);

  G4int plainID = copyNo/59;
  G4int barIDinPlain = copyNo-59*plainID;
  G4int Nplains = fNbOfBars/59+1;

  G4int NbarsInPlain;
  if (fNbOfBars<59) NbarsInPlain = fNbOfBars;
  else if (plainID<(fNbOfBars/59)) NbarsInPlain = 59;
  else NbarsInPlain = 59-fNbOfBars%59;
  
  G4double StartX = -(NbarsInPlain/2)*(0.5*fBarWidth+fGap);
  G4double StartY = StartX;
  G4double StartZ = -(Nplains/2)*(fBarHeight+fGap);

  placement.setZ(StartZ+plainID*(fBarHeight+fGap));
  rotation->rotateY(0.0*deg);

  if (plainID%2==0) {
    if (copyNo%2==0) rotation->rotateX(0.0*deg);
    else rotation->rotateX(180.0*deg);
    rotation->rotateZ(0.0*deg);
    placement.setX(0.0*cm);
    placement.setY(StartY+barIDinPlain*(0.5*fBarWidth+fGap));
  } else {
    if (copyNo%2==0) rotation->rotateX(0.0*deg);
    else rotation->rotateX(180.0*deg);
    rotation->rotateZ(90.0*deg);
    placement.setX(StartX+barIDinPlain*(0.5*fBarWidth+fGap));
    placement.setY(0.0*cm);
  }

  physVol->SetTranslation(placement);
  physVol->SetRotation(rotation);
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......