EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tpc-builder.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file tpc-builder.C
1 
2 //
3 // This TPC implementation is indeed naive; in particular it digitizes every
4 // MC point separately, therefore heavily relies on the max step value for
5 // "ArCF4iC4H10" mixture (1cm in media.geo); so is expected to work more
6 // or less reasonably for eta~0 tracks;
7 //
8 
9 // A more real-life digitization scheme will be invoked if this line is uncommented
10 // (see digitization.C for more details); ! NB: if changed, need to re-run both
11 // tpc-builder.C & simulation.C before running digitization.C !;
12 #define _USE_BEAST_TPC_DIGITIZER_
13 
14 // Used volume names;
15 #define _CONTAINER_NAME_ "TpcContainer"
16 #define _GAS_VOLUME_NAME_ "GasVolume"
17 #define _FIELD_CAGE_NAME_ "FieldCage"
18 
20 {
21  // Detector name will be "TPC"; should be consistent through
22  // all the simulation.C->digitization.C->reconstruction.C chain;
23 #ifdef _USE_BEAST_TPC_DIGITIZER_
24  auto tpc = new TpcGeoParData();
25 #else
26  auto tpc = new EicGeoParData("TPC");
27 #endif
28 
29  // Hardcode TGeo file name (no versioning, etc);
30  tpc->SetFileName("tpc.root");
31 
32  //
33  // Hardcode all the geometry parameters for simplicity; NB: for most part of
34  // EicRoot detector types respective variables (like gas volume radius below)
35  // are EicGeoParData inherited class variables which get saved in the
36  // output file containing TGeo information; units are [cm] everywhere;
37  //
38 
39  double innerGasVolumeRadius = 12.0;
40  double outerGasVolumeRadius = 42.0;
41  // Will be two half-length volumes;
42  double gasVolumeLength = 30.0;
43 #ifdef _USE_BEAST_TPC_DIGITIZER_
44  // Well, this is the only parameter required by EicTpcDigiHitProducer::HandleHit();
45  // and parameters in TpcGeoParData class are assumed to be in [mm];
46  tpc->mTotalGasVolumeLength = 10.0 * gasVolumeLength;
47 #endif
48  // Well, 2.0% rad.length must be reasonable for IFC (see "X0=10cm" material definition);
49  double fieldCageThickness = 0.2;
50 
51  unsigned group = tpc->AddLogicalVolumeGroup(0, 0, 2);
52  auto xmap = tpc->CreateNewMap();
53  xmap->AddGeantVolumeLevel(_GAS_VOLUME_NAME_, 2);
54  xmap->SetSingleSensorContainerVolume(_GAS_VOLUME_NAME_);
55  // Well, GEANT4 mode does not acknowledge max step size in VGM; fix later;
56  tpc->AddStepEnforcedVolume(_GAS_VOLUME_NAME_);
57 
58  // Inner field cage;
59  auto fc = new TGeoTube(_FIELD_CAGE_NAME_,
60  innerGasVolumeRadius - fieldCageThickness,
61  innerGasVolumeRadius,
62  gasVolumeLength/2);
63  auto vfc = new TGeoVolume(_FIELD_CAGE_NAME_, fc, tpc->GetMedium("X0=10cm"));
64  tpc->GetTopVolume()->AddNode(vfc, 0, new TGeoCombiTrans(0.0, 0.0, 0.0, 0));
65 
66  // Gas volume definition;
67  auto gv = new TGeoTube(_GAS_VOLUME_NAME_,
68  innerGasVolumeRadius,
69  outerGasVolumeRadius,
70  gasVolumeLength/4);
71  // NB: this medium is defined as 1cm max.step (see media.geo); so at eta~0 expect
72  // roughly (rmax-rmin) hits (GEANT steps); fine for demonstration purposes;
73  auto vgv = new TGeoVolume(_GAS_VOLUME_NAME_, gv, tpc->GetMedium("ArCF4iC4H10"));
74 
75  // Gas volumes (upstream & downstream halves);
76  for(unsigned ud=0; ud<2; ud++) {
77  // Insert mapping table entry; a trivial one, indeed;
78  UInt_t geant[1] = {ud}, logical[3] = {0, 0, ud};
79  if (tpc->SetMappingTableEntry(xmap, geant, group, logical)) {
80  cout << "Failed to set mapping table entry!" << endl;
81  exit(0);
82  } //if
83 
84  double zOffset = (ud ? -1. : 1.)*gasVolumeLength/4;
85 
86  // Well, the idea behind this rotation for ud=1 half is that local hit coordinates
87  // will be obtained in coordinate system which has the same orientation with respect
88  // to the pad plane, no matter ud=0 or ud=1 gas volume was hit; this is indeed helpful
89  // if hit resolution depends on drift distance, etc;
90  TGeoRotation *rw = 0;
91  if (ud) {
92  rw = new TGeoRotation();
93  rw->RotateY(180);
94  } //if
95 
96  tpc->GetTopVolume()->AddNode(vgv, ud, new TGeoCombiTrans(0.0, 0.0, zOffset, rw));
97  } //for ud
98 
99  tpc->GetColorTable()->AddPatternMatch("FieldCage", kGray);
100  tpc->GetColorTable()->AddPatternMatch("GasVolume", kCyan);
101  tpc->GetTransparencyTable()->AddPatternMatch("GasVolume", 40);
102 
103  // A unified user call which places assembled detector volume in a proper place in MASTER (top)
104  // coordinate system, puts this MASTER (top) volume into GEANT volume tree, and dumps this tree
105  // together with EicRoot mapping table in one file;
106  tpc->FinalizeOutput();
107 
108  // Yes, always exit;
109  exit(0);
110 } // tpc_builder()
111