EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tracker.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file tracker.C
1 
2 //
3 // Example tracker: 10x 200um thick layers of silicon in H+ beam direction;
4 // output file (fwdst.root) can be used as geometry input for
5 // simulation.C->digitization.C->reconstruction.C scripts in this directory;
6 //
7 // resolutions are specified at a later stage (see digitization.C);
8 //
9 // Prefer to declare dimensions in [mm]; convert to [cm] when calling ROOT shape
10 // definition routines only;
11 //
12 
13 void tracker()
14 {
15  // Detector name will be "FWDST" (Forward Silicon Tracker); should be consistent through
16  // all the simulation.C->digitization.C->reconstruction.C chain; see calorimetry/calorimeter.C
17  // for the rationale behind using EicGeoParDataHelper wrapper class;
18  auto fst = new EicGeoParData("FwdST", 0, 0);
19  fst->SetFileName("fwdst.root");
20 
21  // So 10x 250x250mm^2 layers of 200um thick silicon, 100mm apart from each other, at an "average"
22  // distance of 1m from the IP; layers orthogonal to the beam line direction;
23  UInt_t waferNum = 10;
24  Double_t waferThickness = 200 * eic::um;
25  // Rectangular wafers; beam pipe will not be used in simulation.C anyway,
26  // so why bother about more realistic shapes;
27  Double_t waferWidth = 250 * eic::mm;
28  Double_t waferSpacing = 100 * eic::mm;
29  Double_t beamLineOffset = 1000 * eic::mm;
30  // Give it +/-5mm on all sides;
31  Double_t containerVolumeLength = (waferNum-1) * waferSpacing + waferThickness + (10 * eic::mm);
32  Double_t containerVolumeWidth = waferWidth + (10 * eic::mm);
33 
34  // Create a "container" volume;
35  auto container = new TGeoBBox("ContainerVolume",
36  containerVolumeWidth/2,
37  containerVolumeWidth/2,
38  containerVolumeLength/2);
39  // Make sure media names are listed in geometry/media.geo;
40  auto vcontainer = new TGeoVolume("ContainerVolume", container, fst->GetMedium("air"));
41 
42  // Silicon wafer;
43  auto wafer = new TGeoBBox("SiliconWafer",
44  waferWidth/2,
45  waferWidth/2,
46  waferThickness/2);
47  auto vwafer = new TGeoVolume("SiliconWafer", wafer, fst->GetMedium("silicon"));
48 
49  auto fgmap = fst->CreateNewMap();
50  fgmap->AddGeantVolumeLevel("SiliconWafer", waferNum);
51  fgmap->SetSingleSensorContainerVolume("SiliconWafer");
52 
53  // Easiest option: encode wafer ID along beam axis as Z-index; XY-indices are not needed;
54  // alternatively could define 10 separate groups without XYZ-substructure;
55  fst->AddLogicalVolumeGroup(0, 0, waferNum);
56 
57  // And place all wafers into the container volume;
58  for(unsigned wf=0; wf<waferNum; wf++)
59  {
60  double offset = (wf - (waferNum-1)/2.)*waferSpacing;
61 
62  UInt_t geant[1] = {wf}, group = 0, logical[3] = {0, 0, wf};
63 
64  if (fst->SetMappingTableEntry(fgmap, geant, group, logical)) {
65  cout << "Failed to set mapping table entry!" << endl;
66  exit(0);
67  } //if
68 
69  vcontainer->AddNode(vwafer, wf, new TGeoCombiTrans(0.0, 0.0, offset, new TGeoRotation()));
70  } // for wf
71 
72  // Place container volume;
73  fst->GetTopVolume()->AddNode(vcontainer, 0, new TGeoCombiTrans(0.0, 0.0, 0.0, new TGeoRotation()));
74 
75  fst->SetTopVolumeTransformation(new TGeoTranslation(0.0, 0.0, beamLineOffset));
76 
77  fst->GetColorTable()->AddPatternMatch ("Silicon", kYellow);
78  fst->GetTransparencyTable()->AddPatternMatch("Silicon", 50);
79 
80  // A unified user call which places assembled detector volume in a proper place in MASTER (top)
81  // coordinate system, puts this MASTER (top) volume into GEANT volume tree, and dumps this tree
82  // together with EicRoot mapping table in one file;
83  fst->FinalizeOutput();
84 
85  // Yes, always exit;
86  exit(0);
87 } // tracker()
88