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 // VST MAPS geometry description file; should have probably kept this stuff
5 // in geometry/MAPS/vst.C; but 1) I'm really tired of CINT bugs and restrictions,
6 // 2) this way I perfectly decouple input data and construction algorithms;
7 //
8 // FIXME: materials are hardcoded indeed; but I know, they are well defined ...;
9 //
10 
11 #include <iostream>
12 using namespace std;
13 
14 #include <TMath.h>
15 #include <TGeoTrd1.h>
16 #include <TGeoTube.h>
17 
18 #include <VstGeoParData.h>
19 
20 // ---------------------------------------------------------------------------------------
21 
22 int VstGeoParData::ConstructGeometry(bool root, bool gdml, bool check)
23 {
24  // FIXME: may want to put these into MapsGeoParData?!;
25  unsigned staveGlobalCounter = 0, chipGlobalCounter = 0;
26 
27  for(unsigned bl=0; bl<GetNumberOfLayers(); bl++) {
28  const VstBarrelLayer *blayer = GetBarrelLayer(bl);
29  MapsMimosaAssembly *mcell = blayer->mChipAssembly;
30 
31  staveGlobalCounter += blayer->mStaveNum;
32  chipGlobalCounter += blayer->mStaveNum*blayer->mMimosaChipNum;
33 
34  AddLogicalVolumeGroup(blayer->mStaveNum, 0, blayer->mMimosaChipNum);
35 
36  char mountingRingName[128];
37 
38  snprintf(mountingRingName, 128-1, "VstMountingRing%02d", bl);
39 
40  MapsStave *stave = ConstructStave(blayer->mMimosaChipNum, bl, mcell);
41 
42  // Yes, carelessly create one map per layer;
43  EicGeoMap *fgmap = CreateNewMap();
47  fgmap->AddGeantVolumeLevel(stave->GetName(), blayer->mStaveNum);
48 
50 
51  // Construct mapping table; no tricks like linear cell numbering and circular
52  // quadrant arrangement in say FEMC calorimeter construction -> may just use a separate loop;
53  for(unsigned st=0; st<blayer->mStaveNum; st++)
54  for(unsigned nn=0; nn<blayer->mMimosaChipNum; nn++) {
55  UInt_t geant[4] = {0, 0, nn, st}, logical[3] = {st, 0, nn};
56 
57  if (SetMappingTableEntry(fgmap, geant, bl, logical)) {
58  cout << "Failed to set mapping table entry!" << endl;
59  exit(0);
60  } //if
61  } //for st..nn
62 
63  {
64  double staveCenterRadius;
65 
66  // Place staves into master volume; FIXME: no extra hierarchy here?; well, otherwise
67  // would have to precisely calculate barrel TUBE volume inner/outer radius;
68  for(unsigned st=0; st<blayer->mStaveNum; st++) {
69  TGeoRotation *rw = new TGeoRotation();
70 
71  double degAngle = st*360.0/blayer->mStaveNum + blayer->mAsimuthalOffset;
72  double radAngle = degAngle*TMath::Pi()/180.0;
73 
74  {
75  double fullAngle = degAngle + blayer->mStaveSlope;
76  rw->SetAngles(90.0, 0.0 - fullAngle, 180.0, 0.0, 90.0, 90.0 - fullAngle);
77  }
78 
79  // ALICE TDR gives silicon chip center intallation radius (p.8); want to reproduce the
80  // geometry (and slope in particular) in order to cross-check material budget;
81  {
82  // Use sine theorem;
83  double alfa = blayer->mStaveSlope*TMath::Pi()/180.0;
84  double beta = asin(fabs(mMimosaOffset)*sin(alfa)/blayer->mRadius);
85  double gamma = TMath::Pi() - alfa - beta;
86  staveCenterRadius = blayer->mRadius*sin(gamma)/sin(alfa);
87  GetTopVolume()->AddNode(stave->GetVolume(), st,
88  new TGeoCombiTrans(0.1 * staveCenterRadius*sin(radAngle),
89  0.1 * staveCenterRadius*cos(radAngle), 0.0, rw));
90  }
91  } //for st
92 
93  // Construct a mounting ring; let it be there for all geometry types;
94  if (WithMountingRings())
95  {
96  TGeoTube *mring = new TGeoTube(mountingRingName,
97  0.1 * (staveCenterRadius + mMountingRingRadialOffset - mMountingRingRadialThickness/2),
98  0.1 * (staveCenterRadius + mMountingRingRadialOffset + mMountingRingRadialThickness/2),
100  TGeoVolume *vmring = new TGeoVolume(mountingRingName, mring, GetMedium(mCarbonFiberMaterial));
101 
102  // Place two rings;
103  for(unsigned fb=0; fb<2; fb++) {
104  double zOffset = (fb ? -1. : 1.)*(stave->GetLength()/2 + mMountingRingBeamLineThickness/2);
105 
106  GetTopVolume()->AddNode(vmring, fb, new TGeoCombiTrans(0.0, 0.0, 0.1 * zOffset, 0));
107  } //for fb
108  } //if
109  }
110  } //for bl
111 
112  printf("%5d chip(s) and %5d stave(s) total\n", chipGlobalCounter, staveGlobalCounter);
113 
114  // Place this stuff as a whole into the top volume and write out;
115  FinalizeOutput(root, gdml, check);
116 
117  return 0;
118 } // VstGeoParData::ConstructGeometry()
119 
120 // ---------------------------------------------------------------------------------------
121