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