EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VstGeoParData.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VstGeoParData.cxx
1 //
2 // AYK (ayk@bnl.gov), 2014/08/07
3 //
4 // FIXME: materials are hardcoded indeed; but I know, they are well defined ...;
5 //
6 
7 #include <iostream>
8 using namespace std;
9 
10 #include <TMath.h>
11 #include <TGeoTrd1.h>
12 #include <TGeoTube.h>
13 #include <TVector2.h>
14 
15 #include <EtmOrphans.h>
16 #include <VstGeoParData.h>
17 
18 // ---------------------------------------------------------------------------------------
19 
20 VstGeoParData::VstGeoParData(int version, int subVersion):
21  MapsGeoParData(_VST_DETECTOR_NAME_, version, subVersion),
22  mMountingRingRadialOffset ( 3.00 * etm::mm)
23 {
24 } // VstGeoParData::VstGeoParData()
25 
26 // ---------------------------------------------------------------------------------------
27 
28 int VstGeoParData::ConstructGeometry(bool root, bool gdml, bool check)
29 {
30  // FIXME: may want to put these into MapsGeoParData?!;
31  unsigned staveGlobalCounter = 0, chipGlobalCounter = 0;
32 
33  for(unsigned bl=0; bl<GetNumberOfLayers(); bl++) {
34  const VstBarrelLayer *blayer = GetBarrelLayer(bl);
35  MapsMimosaAssembly *mcell = blayer->mChipAssembly;
36 
37  staveGlobalCounter += blayer->mStaveNum;
38  chipGlobalCounter += blayer->mStaveNum*blayer->mMimosaChipNum;
39 
40  AddLogicalVolumeGroup(blayer->mStaveNum, 0, blayer->mMimosaChipNum);
41 
42  char mountingRingName[128];
43 
44  snprintf(mountingRingName, 128-1, "VstMountingRing%02d", bl);
45 
46  MapsStave *stave = ConstructStave(blayer->mMimosaChipNum, bl, mcell);
47 
48  // Yes, carelessly create one map per layer;
49  EicGeoMap *fgmap = CreateNewMap();
53  fgmap->AddGeantVolumeLevel(stave->GetName(), blayer->mStaveNum);
54 
56 
57  // Construct mapping table; no tricks like linear cell numbering and circular
58  // quadrant arrangement in say FEMC calorimeter construction -> may just use a separate loop;
59  for(unsigned st=0; st<blayer->mStaveNum; st++)
60  for(unsigned nn=0; nn<blayer->mMimosaChipNum; nn++) {
61  UInt_t geant[4] = {0, 0, nn, st}, logical[3] = {st, 0, nn};
62 
63  if (SetMappingTableEntry(fgmap, geant, bl, logical)) {
64  cout << "Failed to set mapping table entry!" << endl;
65  exit(0);
66  } //if
67  } //for st..nn
68 
69  {
70  // ALICE TDR gives silicon chip center intallation radius (p.8); want to reproduce the
71  // geometry (and slope in particular) in order to cross-check material budget;
72  double alfa = blayer->mStaveSlope*TMath::Pi()/180.0;
73  // Use sine theorem or such;
74  double beta = asin(fabs(mMimosaOffset)*sin(alfa)/blayer->mRadius);
75  double gamma = TMath::Pi() - alfa - beta;
76  double staveCenterRadius = blayer->mRadius*sin(gamma)/sin(alfa);
77 
78  // Figure out thickness of the overall air container volume;
79  double H = GetAssemblyContainerWidth(mcell), W = mcell->GetAssemblyHeight();
80  TVector2 A(-W/2, -H/2), B(W/2, -H/2), C(0.0, H/2), *arr[3] = {&A, &B, &C};
81  double rmin = 0.0, rmax = 0.0;
82  for(unsigned iq=0; iq<3; iq++) {
83  TVector2 pt = arr[iq]->Rotate(alfa) + TVector2(0.0, staveCenterRadius);
84  double r = pt.Mod();
85 
86  if (!iq || r < rmin) rmin = r;
87  if (!iq || r > rmax) rmax = r;
88  } //for iq
89  //printf("%f %f %f\n", rmin, blayer->mRadius, rmax);
90 
91  // Define air container volume and place it into the top volume;
92  char barrelContainerVolumeName[128];
93  snprintf(barrelContainerVolumeName, 128-1, "%sBarrelContainerVolume%02d", "Vst", bl);
94 
95  TGeoTube *bcontainer = new TGeoTube(barrelContainerVolumeName,
96  rmin,
97  rmax,
98  stave->GetLength()/2);
99  TGeoVolume *vbcontainer = new TGeoVolume(barrelContainerVolumeName, bcontainer, GetMedium(_AIR_));
100 
101  GetTopVolume()->AddNode(vbcontainer, 0, 0);//barrel->mTransformation);
102 
103  // Place staves into master volume; FIXME: no extral hierarchy here?; well, otherwise
104  // would have to precisely calculate barrel TUBE volume inner/outer radius;
105  for(unsigned st=0; st<blayer->mStaveNum; st++) {
106  TGeoRotation *rw = new TGeoRotation();
107 
108  double degAngle = st*360.0/blayer->mStaveNum + blayer->mAsimuthalOffset;
109  double radAngle = degAngle*TMath::Pi()/180.0;
110  double fullAngle = degAngle + blayer->mStaveSlope;
111 
112  rw->SetAngles(90.0, 0.0 - fullAngle, 180.0, 0.0, 90.0, 90.0 - fullAngle);
113 
114  vbcontainer->AddNode(stave->GetVolume(), st,
115  new TGeoCombiTrans(staveCenterRadius*sin(radAngle),
116  staveCenterRadius*cos(radAngle), 0.0, rw));
117  } //for st
118 
119  // Construct a mounting ring; let it be there for all geometry types;
120  if (mWithMountingRings) {
121  printf("%f %f %f\n", (staveCenterRadius + mMountingRingRadialOffset - mMountingRingRadialThickness/2),
124  TGeoTube *mring = new TGeoTube(mountingRingName,
128  TGeoVolume *vmring = new TGeoVolume(mountingRingName, mring, GetMedium(mCarbonFiberMaterial));
129 
130  // Place two rings; FIXME: it looks like they do not belong to the container volume?;
131  for(unsigned fb=0; fb<2; fb++) {
132  double zOffset = (fb ? -1. : 1.)*(stave->GetLength()/2 + mMountingRingBeamLineThickness/2);
133 
134  GetTopVolume()->AddNode(vmring, fb, new TGeoCombiTrans(0.0, 0.0, zOffset, 0));
135  } //for fb
136  } //if
137  }
138  } //for bl
139 
140  //printf("%5d chip(s) and %5d stave(s) total\n", chipGlobalCounter, staveGlobalCounter);
141 
142  // Color palette; FIXME: what about transparency?;
143  GetColorTable()->AddPatternMatch("WaterPipe", kYellow);
144  GetColorTable()->AddPatternMatch("Water", kBlue);
145  GetColorTable()->AddPatternMatch("StaveBracket", kOrange);
146  GetColorTable()->AddPatternMatch("Beam", kBlack);
147  GetColorTable()->AddPatternMatch("ColdPlate", kYellow);
148  GetColorTable()->AddPatternMatch("MimosaCore", kYellow);
149  GetColorTable()->AddPatternMatch("CellFlexLayer", kGreen+2);
150  GetColorTable()->AddPatternMatch("AluStrips", kGray);
151  GetColorTable()->AddPatternMatch("MountingRing", kMagenta+1);
152 
153  // Place this stuff as a whole into the top volume and write out;
154  FinalizeOutput(root, gdml, check);
155 
156  return 0;
157 } // VstGeoParData::ConstructGeometry()
158 
159 // ---------------------------------------------------------------------------------------
160