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 the hadron beam going 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 
10 void tracker()
11 {
12  // Load basic libraries;
13  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
14 
15  // Detector name will be "FWDST" (Forward Silicon Tracker); should be consistent through
16  // all the [simulation.C -> digitization.C -> reconstruction.C] chain;
17  EicGeoParData *fst = new EicGeoParData("FwdST", 0, 0);
18  // Output ROOT file name;
19  fst->SetFileName("fwdst.root");
20 
21  // So 10x 250x250mm^2 layers of 200um thick silicon, 100mm apart from each other, at
22  // an "average" 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  // Square wafers; beam pipe will not be used in the 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  // Wafers will be placed inside a "container" air volume; give it +/-5mm size margin 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" TGeo box volume;
35  TGeoBBox *container = new TGeoBBox("ContainerVolume",
36  containerVolumeWidth/2,
37  containerVolumeWidth/2,
38  containerVolumeLength/2);
39  // Media "air" and "silicon" are defined in geometry/media.geo;
40  TGeoVolume *vcontainer = new TGeoVolume("ContainerVolume", container, fst->GetMedium("air"));
41 
42  // Silicon wafer;
43  TGeoBBox *wafer = new TGeoBBox("SiliconWafer", waferWidth/2, waferWidth/2, waferThickness/2);
44  TGeoVolume *vwafer = new TGeoVolume("SiliconWafer", wafer, fst->GetMedium("silicon"));
45 
46  // Black magic related to the sensitive volume mapping; can be safely ignored at
47  // the beginning except for the vcontainer->AddNode() call, which places the silicon
48  // wafers into the air container one by one;
49  {
50  EicGeoMap *fgmap = fst->CreateNewMap();
51  fgmap->AddGeantVolumeLevel("SiliconWafer", waferNum);
52  fgmap->SetSingleSensorContainerVolume("SiliconWafer");
53 
54  // The easiest option: encode wafer ID along beam axis as Z-index; XY-indices are not needed;
55  // alternatively could define 10 separate groups without XYZ-substructure;
56  fst->AddLogicalVolumeGroup(0, 0, waferNum);
57 
58  // And place all wafers into the container volume;
59  for(unsigned wf=0; wf<waferNum; wf++) {
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  // The actual placement call;
70  vcontainer->AddNode(vwafer, wf, new TGeoCombiTrans(0.0, 0.0, offset, new TGeoRotation()));
71  } // for wf
72  }
73 
74  // Place container volume into the detector assembly at a Z-offset of beamLineOffset;
75  fst->GetTopVolume()->AddNode(vcontainer, 0, new TGeoCombiTrans(0.0, 0.0, 0.0, new TGeoRotation()));
76  fst->SetTopVolumeTransformation(new TGeoTranslation(0.0, 0.0, beamLineOffset));
77 
78  // Define color attributes of the silicon wafers (NB: volumes which are not
79  // described this way will NOT be visible in the event display;
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