-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrootGeo.C
74 lines (56 loc) · 2.44 KB
/
rootGeo.C
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
void rootGeo()
{
TGeoManager* geoM = new TGeoManager("geoM", "geoM");
// Materials and media --------------------------------------------------------------
TGeoMaterial* vacMat = new TGeoMaterial("vacMat", 0, 0, 0);
TGeoMedium* vacMed = new TGeoMedium("vacMed", 1, vacMat);
TGeoMaterial* ledMat = new TGeoMaterial("ledMat", 0, 0, 0);
TGeoMedium* ledMed = new TGeoMedium("ledMed", 1, ledMat);
TGeoMaterial* sciMat = new TGeoMaterial("sciMat", 0, 0, 0);
TGeoMedium* sciMed = new TGeoMedium("sciMed", 1, sciMat);
// Shapes and volumes ---------------------------------------------------------------
Double_t xSize = 10.;
Double_t ySize = 10.;
Double_t zSize = 50.;
UInt_t nSlices = 6;
Double_t sliceZsize = zSize/(Double_t)nSlices;
// Half dimensions are given as constructor parameters
TGeoBBox* worldShape = new TGeoBBox("worldShape", 1000., 1000., 1000.);
TGeoVolume* worldVol = new TGeoVolume("worldVol", worldShape, vacMed);
TGeoBBox* moduleShape = new TGeoBBox("moduleShape", xSize/2., ySize/2., zSize/2.);
TGeoVolume* moduleVol = new TGeoVolume("moduleVol", moduleShape, ledMed);
TGeoBBox* sliceShape = new TGeoBBox("sliceShape", xSize/2., ySize/2., sliceZsize/2.);
TGeoVolume* sliceVol = new TGeoVolume("sliceVol", sliceShape, sciMed);
// Volume hierarchy -----------------------------------------------------------------
TGeoRotation* rotNoRot = new TGeoRotation("rotNoRot", 0., 0., 0.);
rotNoRot->RegisterYourself();
UInt_t nX=20;
UInt_t nY=5;
TString transName;
for (UInt_t i=0; i<nX; i++) {
for (UInt_t j=0; j<nY; j++) {
transName.Form("trans_module_%d_%d", i, j);
TGeoCombiTrans* trans1 = new TGeoCombiTrans(transName.Data(),
-((Double_t)nX/2.)*xSize + xSize/2. + (Double_t)i*xSize,
-((Double_t)nY/2.)*ySize + ySize/2. + (Double_t)j*ySize,
0., rotNoRot);
trans1->RegisterYourself();
worldVol->AddNode(moduleVol, i*nY+j, trans1);
}
}
for (UInt_t i=0; i<nSlices; i++) {
transName.Form("trans_slice_%d", i);
TGeoCombiTrans* trans2 = new TGeoCombiTrans(transName.Data(), 0., 0., -((Double_t)nSlices/2.)*sliceZsize + sliceZsize/2. + (Double_t)i*sliceZsize, rotNoRot);
trans2->RegisterYourself();
moduleVol->AddNode(sliceVol, i, trans2);
}
// Finalization ---------------------------------------------------------------------
geoM->SetTopVolume(worldVol);
geoM->CloseGeometry();
/*
geoM->CheckOverlaps();
geoM->CheckGeometry();
geoM->CheckGeometryFull();
*/
TBrowser* bro = new TBrowser("bro", "bro");
}