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 void tracker()
3 {
4  // Detector name will be "FWDST" (Forward Silicon Tracker); should be consistent through
5  // all the [simulation.C -> digitization.C -> reconstruction.C] chain;
6  EicGeoParData *fst = new EicGeoParData("FwdST", 0, 0);
7  // Output ROOT file name;
8  fst->SetFileName("fwdst.root");
9 
10  // So 10x 250x250mm^2 layers of 200um thick silicon, 100mm apart from each other, at
11  // an "average" distance of 1m from the IP; layers orthogonal to the beam line direction;
12  UInt_t waferNum = 10;
13  Double_t waferThickness = 200 * eic::um;
14  // Square wafers; beam pipe will not be used in the simulation.C anyway,
15  // so why bother about more realistic shapes;
16  Double_t waferWidth = 250 * eic::mm;
17  Double_t waferSpacing = 100 * eic::mm;
18  Double_t beamLineOffset = 1000 * eic::mm;
19  // Wafers will be placed inside a "container" air volume; give it +/-5mm size margin on all sides;
20  Double_t containerVolumeLength = (waferNum-1) * waferSpacing + waferThickness + (10 * eic::mm);
21  Double_t containerVolumeWidth = waferWidth + (10 * eic::mm);
22 
23  // Create a "container" TGeo box volume;
24  TGeoBBox *container = new TGeoBBox("ContainerVolume",
25  containerVolumeWidth/2,
26  containerVolumeWidth/2,
27  containerVolumeLength/2);
28  // Media "air" and "silicon" are defined in geometry/media.geo;
29  TGeoVolume *vcontainer = new TGeoVolume("ContainerVolume", container, fst->GetMedium("air"));
30 
31  // Silicon wafer;
32  TGeoBBox *wafer = new TGeoBBox("SiliconWafer", waferWidth/2, waferWidth/2, waferThickness/2);
33  TGeoVolume *vwafer = new TGeoVolume("SiliconWafer", wafer, fst->GetMedium("silicon"));
34 
35  // Black magic related to the sensitive volume mapping; can be safely ignored at
36  // the beginning except for the vcontainer->AddNode() call, which places the silicon
37  // wafers into the air container one by one;
38  {
39  EicGeoMap *fgmap = fst->CreateNewMap();
40  fgmap->AddGeantVolumeLevel("SiliconWafer", waferNum);
41  fgmap->SetSingleSensorContainerVolume("SiliconWafer");
42 
43  // The easiest option: encode wafer ID along beam axis as Z-index; XY-indices are not needed;
44  // alternatively could define 10 separate groups without XYZ-substructure;
45  fst->AddLogicalVolumeGroup(0, 0, waferNum);
46 
47  // And place all wafers into the container volume;
48  for(unsigned wf=0; wf<waferNum; wf++) {
49  double offset = (wf - (waferNum-1)/2.)*waferSpacing;
50 
51  UInt_t geant[1] = {wf}, group = 0, logical[3] = {0, 0, wf};
52 
53  if (fst->SetMappingTableEntry(fgmap, geant, group, logical)) {
54  cout << "Failed to set mapping table entry!" << endl;
55  exit(0);
56  } //if
57 
58  // The actual placement call;
59  vcontainer->AddNode(vwafer, wf, new TGeoCombiTrans(0.0, 0.0, offset, new TGeoRotation()));
60  } // for wf
61  }
62 
63  // Place container volume into the detector assembly at a Z-offset of beamLineOffset;
64  fst->GetTopVolume()->AddNode(vcontainer, 0, new TGeoCombiTrans(0.0, 0.0, 0.0, new TGeoRotation()));
65  fst->SetTopVolumeTransformation(new TGeoTranslation(0.0, 0.0, beamLineOffset));
66 
67  // Define color attributes of the silicon wafers (NB: volumes which are not
68  // described this way will NOT be visible in the event display;
69  fst->GetColorTable()->AddPatternMatch ("Silicon", kYellow);
70  fst->GetTransparencyTable()->AddPatternMatch("Silicon", 50);
71 
72  // A unified user call which places assembled detector volume in a proper place in MASTER (top)
73  // coordinate system, puts this MASTER (top) volume into GEANT volume tree, and dumps this tree
74  // together with EicRoot mapping table in one file;
75  fst->FinalizeOutput();
76 
77  // Yes, always exit;
78  exit(0);
79 } // tracker()
80