StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiStarDetectorBuilder.cxx
1 #include <assert.h>
2 #include <stdexcept>
3 
4 #include "St_base/StMessMgr.h"
5 #include "Sti/Base/Factory.h"
6 #include "Sti/StiPlanarShape.h"
7 #include "Sti/StiCylindricalShape.h"
8 #include "Sti/StiMaterial.h"
9 #include "Sti/StiPlacement.h"
10 #include "Sti/StiDetector.h"
12 #include "Sti/Star/StiStarDetectorBuilder.h"
13 #include "TMath.h"
14 #include "TError.h"
15 #include "TSystem.h"
16 //________________________________________________________________________________
17 void StiStarDetectorBuilder::buildDetectors(StMaker&s) {
18  TGeoManager *geo = StiVMCToolKit::GetVMC();
19  assert(geo);
20  useVMCGeometry();
21  LOG_INFO << "StiStarDetectorBuilder::buildDetectors() : Done" << endm;
22 }
23 //________________________________________________________________________________
24 void StiStarDetectorBuilder::useVMCGeometry() {
25  _TpcRefSys = (gGeoManager->GetVolume("TpcRefSys" )!=0)
26  || (gGeoManager->GetVolume("TpcRefSys_1")!=0);
27  TGeoVolume *pipc = gGeoManager->GetVolume("PIPC");
28  if (!pipc) { //No volume (??)
29  Warning("StiStarDetectorBuilder::useVMCGeometry","No PIPC volume\n");
30  assert(0);
31  return;
32  }
33  // setNSectors(0,0);
34  _vacuumMaterial = add(new StiMaterial("Vacuum",0., 1., 0., 1e30, 0.) );
35  _gasMat = (add(new StiMaterial("Air",7.3, 14.61, 0.001205, 30420.*0.001205, 7.3*12.e-9)));
36  if (pipc->GetShape()->TestShapeBit(TGeoShape::kGeoTube)) {
37  OldBeamPipe();
38  } else {
39  HftBeamPipe();
40  }
41  TGeoVolume *osca = gGeoManager->GetVolume("OSCA");
42  if (osca) NewSuppCone();
43  TGeoVolume *fgtm = gGeoManager->GetVolume("FGTM");
44  if (fgtm) Fgt();
45 }
46 //________________________________________________________________________________
47 void StiStarDetectorBuilder::OldBeamPipe() {
48  LOG_INFO << "StiStarDetectorBuilder::buildDetectors() : Use VMC old beam pipe geometry" << endm;
49  SetCurrentDetectorBuilder(this);
50  const VolumeMap_t PipeVolumes[] = {
51  {"PIPE","the STAR beam pipe mother volume","HALL_1/CAVE_1/PIPE_%d","",""}, // pcon
52  // old beam pipe
53  {"PIPC","the Central Beam PIPe Volume","HALL_1/CAVE_1/PIPE_%d/PIPC_1","",""}, // tube
54  {"PVAC","the Vacuum Volume of Be section of pipe","HALL_1/CAVE_1/PIPE_%d/PIPC_1/PVAC_1","",""}, //tube
55  {"PIPO","Steel pipe from Be to 1st flanges","HALL_1/CAVE_1/PIPE_%d/PIPO_1/PVAO_1","",""}, //tube
56  {"PVAO","its cavity","HALL_1/CAVE_1/PIPE_%d/PIPO_1/PVAO_1","",""}, // tube
57  //{"SCON", "Support cone mother","HALL_1/CAVE_1/SVTT_1/SCON_1-2/*","",""},
58  {"SROD", "Support rod","HALL_1/CAVE_1/SVTT_1/SROD_1-2","",""},
59  {"SBSP", "Beampipe support mother","HALL_1/CAVE_1/SVTT_1/SBSP_1-2","",""},
60 #if 0
61  //{"FGTM", "Beampipe support mother","HALL_1/CAVE_1/FGTM_1","",""},
62  {"FGCM", "FGT nylon and Al ring","HALL_1/CAVE_1/FGTM_1","",""},
63  {"FGTH", "mother volume for FGT disk","HALL_1/CAVE_1/FGTM_1","",""},
64  {"FGTD", "mother volume for FGT disk","HALL_1/CAVE_1/FGTM_1","",""},
65  {"FGCN", "FGT nylon 1st ring","HALL_1/CAVE_1/FGTM_1","",""},
66  {"FGCT", "FGT inner cooling tube","HALL_1/CAVE_1/FGTM_1","",""}
67 #endif
68  };
69 
70  for (Int_t i = 1; i < 5; i += 2) {// loop over Be and Steel pipes
71  MakePipe(i, &PipeVolumes[i],&PipeVolumes[i+1]);
72  }
73  Int_t NoExtraVols = sizeof(PipeVolumes)/sizeof(VolumeMap_t);
74  TString pathT("HALL_1/CAVE_1");
75  TString path("");
76  for (Int_t i = 5; i < NoExtraVols; i++) {
77  gGeoManager->RestoreMasterVolume();
78  gGeoManager->CdTop();
79  gGeoManager->cd(pathT); path = pathT;
80  TGeoNode *nodeT = gGeoManager->GetCurrentNode();
81  if (! nodeT) continue;
82  StiVMCToolKit::LoopOverNodes(nodeT, path, PipeVolumes[i].name, MakeAverageVolume);
83  }
84 }
85 //________________________________________________________________________________
86 void StiStarDetectorBuilder::HftBeamPipe() {
87  LOG_INFO << "StiStarDetectorBuilder::buildDetectors() : Use VMC HFT beam pipe geometry" << endm;
88  SetCurrentDetectorBuilder(this);
89  const VolumeMap_t PipeVolumes[] = {
90  /* new beam pipe in IDSM
91  <Content>
92 
93  /CAVE/TpcRefSys/IDSM/PIPE, <!--Mother volume of the east section, pcon(4) -->
94  PIHE, <!--Hole inside the beam pipeof east section, pcon(4)>
95  PALQ, <!--East end tube, pcon(6) -->
96  PALR, <!--East transition tube, pcon(6)-->
97  SSCG, *3 <!-- Stainless Steel conflat flanges (ID 3 inches), tube -->
98  SSCF, <!-- Stainless Steel conflat flanges (ID 2 cm), tube -->
99  /CAVE/TpcRefSys/IDSM/PIPI, <!--Mother volume of the middle section Placed in IDSM, pcon(16)-->
100  PIHI, <!--Hole inside the beam pipe of middle section, tube -->
101  PALS, <!--East aluminium part, pcon(6) -->
102  PBES, <!--Berillium part, tube -->
103  PALI, <!--West aluminium part, pcon(6) -->
104  SSCF, *2 <!-- Stainless Steel conflat flanges (ID 2 cm), tube -->
105 
106  /CAVE/TpcRefSys/IDSM/PIPW, <!--Mother volume of the west section, pcon(4)-->
107  PIHW, <!--Hole inside the beam pipe of west section, pcon(4) -->
108  PALJ, <!--West transition tube, pcon(8)-->
109  PALK, <!--West end tube, pcon(8) -->
110  SSCG, *3 <!-- Stainless Steel conflat flanges (ID 3 inches), tube -->
111  /CAVE/PIPA, <!--outer East section, pcon(2) -->
112  PIPB, <!--outer east bellow section, tube -->
113  PVPB, <!--vacuum part of bellow, -->
114  PIPC, <!-- east outset steel section with cone and large radius, tube -->
115  PVPC, <!-- vacuum section, tube -->
116  PRIS, <!-- Bellow - used both east and west taken from PipeGeo.cml (tube)
117  PRID, *8 the Bellow Steel Rib Set (tube)
118  PRIB Rib of Steel Bellows (tube)
119  PFLO is the 1nd set of flanges at ~4.2 m from IR, tube
120  PFLT <!-- Flanges for bellow section, tube -->
121  /CAVE/PIWA, <!--outer West section, pcon(2) -->
122  PIWB, <!--outer West bellow section, tube -->
123  PVWB, <!--vacuum part of bellow, tube -->
124  PIWC, <!-- east outset steel section with cone and large radius, pcon(4) -->
125  PVWC, <!-- vacuum section, con(4) -->
126  PRWS <!-- West bellow section, tube
127  PRWD,*8 the Bellow Steel Rib Set, tube
128  PFLO is the 1nd set of flanges at ~4.2 m from IR, tube
129  PFLT <!-- Flanges for bellow section, tube
130 ================
131  */
132  //{"PIPI", "Mother volume of the middle section Placed in IDSM" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPI_1" ,"",""},
133  //{"PIHI", "Hole inside the beam pipe of middle section" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPI_1/PIHI_1" ,"",""},
134  {"PALS", "East aluminium part" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPI_1/PALS_1" ,"",""},
135  {"PBES", "Berillium part" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPI_1/PBES_1" ,"",""},
136  {"PALI", "West aluminium part" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPI_1/PALI_1" ,"",""},
137  {"SSCF", "Stainless Steel conflat flange" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPI_1/SSCF_%d","",""},
138  //{"PIPE", "Mother volume of the east sect" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPE_1" ,"",""},
139  //{"PIHE", "Hole inside the beam pipe of east sect" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPE_1/PIHE_1" ,"",""},
140  {"PALQ", "East end tube" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPE_1/PALQ_1" ,"",""},
141  {"PALR", "East transition tube" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPE_1/PALR_1" ,"",""},
142  {"SSCG", "Stainless Steel conflat flange" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPE_1/SSCG_%d","",""},
143  {"SSCF", "Stainless Steel conflat flange" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPE_1/SSCF_1" ,"",""},
144  //{"PIPW", "Mother volume of the west sect" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPW_1" ,"",""},
145  //{"PIHW", "Hole inside the beam pipe of west sect" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPW_1/PIHW_1" ,"",""},
146  {"PALJ", "West transition tube" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPW_1/PALJ_1" ,"",""},
147  {"PALK", "West end tube" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPW_1/PALK_1" ,"",""},
148  {"SSCG", "Stainless Steel conflat flange" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PIPW_1/SSCG_%d","",""},
149  {"PIPA", "outer East section" ,"/HALL_1/CAVE_1/PIPA_1" ,"",""},
150  {"PIPB", "outer east bellow section" ,"/HALL_1/CAVE_1/PIPA_1/PIPB_1" ,"",""},
151  {"PVPB", "vacuum part of bellow" ,"/HALL_1/CAVE_1/PIPA_1/PIPB_1/PVPB_1" ,"",""},
152  {"PIPC", "east outset steel section" ,"/HALL_1/CAVE_1/PIPA_1/PIPC_1" ,"",""},
153  {"PVPC", "vacuum section" ,"/HALL_1/CAVE_1/PIPA_1/PIPC_1/PVPC_1" ,"",""},
154  {"PRIS", "Bellow" ,"/HALL_1/CAVE_1/PIPA_1/PRIS_1" ,"",""},
155  //{"PRID", "the Bellow Steel Rib Set" ,"/HALL_1/CAVE_1/PIPA_1/PRIS_1/PRID_%d","",""},
156  {"PFLO", "is the 1nd set of flanges" ,"/HALL_1/CAVE_1/PIPA_1/PFLO_1" ,"",""},
157  {"PFLT", "Flanges for bellow section " ,"/HALL_1/CAVE_1/PIPA_1/PFLT_1" ,"",""},
158  {"PIWA", "outer West section" ,"/HALL_1/CAVE_1/PIWA_1" ,"",""},
159  {"PIWB", "outer West bellow section" ,"/HALL_1/CAVE_1/PIWA_1/PIWB_1" ,"",""},
160  {"PVWB", "vacuum part of bellow" ,"/HALL_1/CAVE_1/PIWA_1/PIWB_1/PVWB_1" ,"",""},
161  {"PIWC", "east outset steel section" ,"/HALL_1/CAVE_1/PIWA_1/PIWC_1" ,"",""},
162  {"PVWC", "vacuum section" ,"/HALL_1/CAVE_1/PIWA_1/PIWC_1/PVWC_1" ,"",""},
163  {"PRWS", "West bellow section" ,"/HALL_1/CAVE_1/PIWA_1/PRWS_1" ,"",""},
164  //{"PRWD", "the Bellow Steel Rib Set" ,"/HALL_1/CAVE_1/PIWA_1/PRWS_1/PRWD_%d","",""},
165  {"PFLO", "is the 1nd set of flange" ,"/HALL_1/CAVE_1/PIWA_1/PFLO_1" ,"",""},
166  {"PFLT", "Flanges for bellow section" ,"/HALL_1/CAVE_1/PIWA_1/PFLT_1" ,"",""},
167 #if 0
168  //{"FGTM", "Beampipe support mother" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/FGTM_1" ,"",""},
169  {"FGCM", "FGT nylon and Al ring" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/FGTM_1/FGCM_1" ,"",""},
170  {"FGTD", "mother volume for FGT disk" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/FGTM_1/FGTD_1" ,"",""},
171  {"FGCN", "FGT nylon 1st ring" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/FGTM_1/FGCN_1" ,"",""},
172  {"FGCT", "FGT inner cooling tube" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/FGTM_1/FGCT_1" ,"",""}
173 #endif
174  };
175  Int_t NVol = sizeof(PipeVolumes)/sizeof(VolumeMap_t);
176  for (Int_t i = 0; i < NVol; i++) {
177  TGeoVolume *pipe = gGeoManager->GetVolume(PipeVolumes[i].name);
178  if (!pipe) { //No volume (??)
179  Warning("StiStarDetectorBuilder::useVMCGeometry","No %s volume\n",PipeVolumes[i].name);
180  continue;
181  }
182  TString pathT(gSystem->DirName(PipeVolumes[i].path));
183  TString path("");
184  if (pipe->GetShape()->TestShapeBit(TGeoShape::kGeoTube)) {
185  TString pm(PipeVolumes[i].path);
186  TString pv;
187  if (i < NVol - 1 && PipeVolumes[i+1].name) {
188  pv = pm; pv += "/"; pv += PipeVolumes[i+1].name;pv += "_1";
189  }
190  if (i < NVol - 1 && pv == TString(PipeVolumes[i+1].path)) {// case tube with vacuum daughter
191  MakePipe(0, &PipeVolumes[i],&PipeVolumes[i+1]);
192  i++;
193  } else {
194  gGeoManager->RestoreMasterVolume();
195  gGeoManager->CdTop();
196  if (! _TpcRefSys) {
197  pathT.ReplaceAll("/TpcRefSys_1","");
198  pathT.ReplaceAll("/TpcRefSys", "");
199  }
200  gGeoManager->cd(pathT); path = pathT;
201  TGeoNode *nodeT = gGeoManager->GetCurrentNode();
202  if (! nodeT) continue;
203  StiVMCToolKit::LoopOverNodes(nodeT, path, PipeVolumes[i].name, MakeAverageVolume);
204  }
205  continue;
206  }
207  if (! pipe->GetShape()->TestShapeBit(TGeoShape::kGeoPcon)) {
208  Warning("StiStarDetectorBuilder::useVMCGeometry","Shape for %s volume is not recognized\n",PipeVolumes[i].name);
209  assert(0);
210  continue;
211  }
212  TGeoPcon *pcon = (TGeoPcon*) pipe->GetShape();
213  TGeoMaterial *pipeMaterial = pipe->GetMaterial();
214  Double_t PotI = StiVMCToolKit::GetPotI(pipeMaterial);
215  Double_t density = pipeMaterial->GetDensity();
216  _pipeMaterial = add(new StiMaterial(pipeMaterial->GetName(),
217  pipeMaterial->GetZ(),
218  pipeMaterial->GetA(),
219  density,
220  density*pipeMaterial->GetRadLen(),
221  PotI));
222  StiMaterial *_pipeMaterial2 = 0;
223  Double_t Rmax, Rmin, radius, dZ, Z;
224  Int_t Nz = pcon->GetNz();
225 #if 0
226  LOG_INFO << pathT.Data() << "\t" << PipeVolumes[i].name << endm;
227  for (Int_t k = 0; k < Nz; k++) {
228  LOG_INFO << k << "\tZ\t" << pcon->GetZ(k) << "\tRmin\t" << pcon->GetRmin(k) << "\tRmax\t" << pcon->GetRmax(k) <<
229  endm;
230  }
231 #endif
232  Int_t section = 0;
233  for (Int_t k = 0; k < Nz-1; k++) {// replace pcon by tubes
234  dZ = TMath::Abs(pcon->GetZ(k) - pcon->GetZ(k+1))/2;
235  if (dZ < 1e-7) continue;
236  Z = (pcon->GetZ(k) + pcon->GetZ(k+1))/2;
237  _pipeMaterial2 = _pipeMaterial;
238  if (pcon->GetRmin(k) == pcon->GetRmin(k+1) &&
239  pcon->GetRmax(k) == pcon->GetRmax(k+1)) {
240  Rmax = pcon->GetRmax(k);
241  Rmin = pcon->GetRmin(k);
242  radius = (Rmin + Rmax)/2;
243  } else {
244  Rmax = TMath::Max(pcon->GetRmax(k),pcon->GetRmax(k+1));
245  Rmin = TMath::Min(pcon->GetRmin(k),pcon->GetRmin(k+1));
246  Double_t scale = (pcon->GetRmax(k+1)*pcon->GetRmax(k+1) - pcon->GetRmin(k+1)*pcon->GetRmin(k+1) +
247  pcon->GetRmax(k )*pcon->GetRmax(k ) - pcon->GetRmin(k )*pcon->GetRmin(k ))/
248  (Rmax*Rmax - Rmin*Rmin);
249  Double_t dens = density*scale;
250  _pipeMaterial2 = add(new StiMaterial(pipeMaterial->GetName(),
251  pipeMaterial->GetZ(),
252  pipeMaterial->GetA(),
253  dens,
254  density*pipeMaterial->GetRadLen(),
255  PotI));
256  }
257  radius = (Rmin + Rmax)/2;
258  _beamPipeShape = new StiCylindricalShape;
259  TString comment(PipeVolumes[i].comment,15);
260  _beamPipeShape->setName(comment.Data());
261  _beamPipeShape->setThickness(Rmax-Rmin);
262  _beamPipeShape->setHalfDepth( dZ );
263  _beamPipeShape->setOpeningAngle( TMath::TwoPi() );
264  _beamPipeShape->setOuterRadius(Rmax);
265 
266  add(_beamPipeShape);
267  StiPlacement *p = new StiPlacement;
268  p->setZcenter(Z);
269  p->setLayerRadius(radius);
270  p->setLayerAngle(0);
271  p->setNormalRep(0, radius, 0.);
272  p->setRegion(StiPlacement::kMidRapidity);
273  TString nameP = PipeVolumes[i].name; nameP += "#"; section++; nameP += section;
274  nameP.ReplaceAll("HALL_1/CAVE_1/","");
275  nameP.ReplaceAll("/TpcRefSys_1","");
276  nameP.ReplaceAll("/TpcRefSys","");
277  nameP.ReplaceAll("/IDSM_1","");
278  nameP.Resize(30); nameP.Strip();
279  StiDetector *pipeVolume = _detectorFactory->getInstance();
280  pipeVolume->setName(nameP.Data());
281  pipeVolume->setIsOn(true);
282  pipeVolume->setIsActive(new StiNeverActiveFunctor);
283  pipeVolume->setIsContinuousMedium(false);
284  pipeVolume->setIsDiscreteScatterer(true);
285  pipeVolume->setShape(_beamPipeShape);
286  pipeVolume->setPlacement(p);
287  pipeVolume->setGas(_vacuumMaterial);
288  pipeVolume->setMaterial(_pipeMaterial2);
289  Int_t layer = getNRows();
290  add(layer,0,pipeVolume);
291  }
292  }
293 }
294 //________________________________________________________________________________
295 void StiStarDetectorBuilder::NewSuppCone() {
296  LOG_INFO << "StiStarDetectorBuilder::buildDetectors() : Use VMC Support Cone geometry" << endm;
297  SetCurrentDetectorBuilder(this);
298  const VolumeMap_t PipeVolumes[] = {
299  // cone
300  {"OSCA", "central CFiber tube" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/OSCA_1" ,"",""},
301  {"SUCB", "small Alu ring" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/SUCB_%d","",""},
302  {"SUCC", "CFiber cone section" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/SUCC_%d","",""},
303  {"SUCD", "large Al ring at cone" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/SUCD_%d","",""},
304  {"SUCE", "CFiber tube" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/SUCE_%d","",""},
305  {"SUCF", "large Alu ring" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/SUCF_%d","",""},
306  {"SUCG", "large Alu end disk" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/SUCG_%d","",""},
307  {"FGRL", "FGT rail" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/FGRL_%d","",""},
308  //{"FGHV", "FGT cables mixture" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/FGHV_%d","",""},
309  {"EFSA", "Electrostatic shroud" ,"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/EFSA_%d","",""}
310  };
311  Int_t NVol = sizeof(PipeVolumes)/sizeof(VolumeMap_t);
312  TString pathT("HALL_1/CAVE_1");
313  TString path("");
314  for (Int_t i = 0; i < NVol; i++) {
315  gGeoManager->RestoreMasterVolume();
316  gGeoManager->CdTop();
317  if (! _TpcRefSys) {
318  pathT.ReplaceAll("/TpcRefSys_1","");
319  pathT.ReplaceAll("/TpcRefSys" ,"");
320  }
321  gGeoManager->cd(pathT); path = pathT;
322  TGeoNode *nodeT = gGeoManager->GetCurrentNode();
323  if (! nodeT) continue;
324  StiVMCToolKit::LoopOverNodes(nodeT, path, PipeVolumes[i].name, MakeAverageVolume);
325  }
326 }
327 //________________________________________________________________________________
328 void StiStarDetectorBuilder::MakePipe(Int_t iflag, const VolumeMap_t *ptube,const VolumeMap_t *pvacu) {
329  // iflag = 0 a signle volume, iflag = 1 merge west and east sides, iflag > 1 keep west and east volume separate
330  if (! ptube || ! pvacu) return;
331  TGeoVolume *pipe = gGeoManager->GetVolume(ptube->name);
332  if (!pipe) { //No volume (??)
333  Warning("StiStarDetectorBuilder::useVMCGeometry","No %s volume\n",ptube->name);
334  assert(0);
335  return;
336  }
337  TGeoMaterial *pipeMaterial = pipe->GetMaterial();
338  Double_t PotI = StiVMCToolKit::GetPotI(pipeMaterial);
339  _pipeMaterial = add(new StiMaterial(pipeMaterial->GetName(),
340  pipeMaterial->GetZ(),
341  pipeMaterial->GetA(),
342  pipeMaterial->GetDensity(),
343  pipeMaterial->GetDensity()*pipeMaterial->GetRadLen(),
344  PotI));
345  TGeoTube *pipeShape = (TGeoTube *) pipe->GetShape();
346  Double_t Rmax = pipeShape->GetRmax();
347  Double_t Rmin = pipeShape->GetRmin();
348  Double_t dZ = pipeShape->GetDz();
349  if (Rmin < 1e-3 && pvacu->name) {
350  TGeoVolume *vac = gGeoManager->GetVolume(pvacu->name);
351  if (!vac) { //No volume (??)
352  Warning("StiStarDetectorBuilder::useVMCGeometry","No %s volume\n",pvacu->name);
353  assert(0);
354  return;
355  }
356  TGeoTube *vacShape = (TGeoTube *) vac->GetShape();
357  Rmin = vacShape->GetRmax();
358  }
359  Double_t radius = (Rmin + Rmax)/2;
360  _beamPipeShape = new StiCylindricalShape;
361 
362  TString comment(ptube->comment,15);
363  _beamPipeShape->setName(comment.Data());
364  _beamPipeShape->setThickness(Rmax-Rmin);
365  if (iflag == 1) _beamPipeShape->setHalfDepth( 2*dZ ); // merge two half of Be beam pipe
366  else _beamPipeShape->setHalfDepth( dZ );
367  _beamPipeShape->setOpeningAngle( TMath::TwoPi() );
368  _beamPipeShape->setOuterRadius(Rmax);
369  add(_beamPipeShape);
370  for (Int_t j = 0; j < 2; j++) { // placements
371  if (iflag <= 1 && j == 1) continue;
372  StiPlacement *p = new StiPlacement;
373  TString pathT = ptube->path;
374  if (pathT.Contains("%d")) pathT = Form(ptube->path,j+1);
375  TGeoPhysicalNode *nodeP = gGeoManager->MakePhysicalNode(pathT);
376  if (! nodeP) continue;
377  if (iflag == 1) p->setZcenter(0); // merge two half of Be beam pipe
378  else {
379  TGeoHMatrix *hmat = nodeP->GetMatrix();
380  Double_t *xyz = hmat->GetTranslation();
381  p->setZcenter(xyz[2]);
382  }
383  p->setLayerRadius(radius);
384  p->setLayerAngle(0);
385  p->setNormalRep(0, radius, 0.);
386  p->setRegion(StiPlacement::kMidRapidity);
387  StiDetector *pipeVolume = _detectorFactory->getInstance();
388  TString nameP = pathT.Data();
389  nameP.ReplaceAll("HALL_1/CAVE_1/","");
390  nameP.ReplaceAll("/TpcRefSys_1","");
391  nameP.ReplaceAll("/TpcRefSys","");
392  nameP.ReplaceAll("/IDSM","");
393  nameP.Resize(30); nameP.Strip();
394  pipeVolume->setName(nameP.Data());
395  pipeVolume->setIsOn(true);
396  pipeVolume->setIsActive(new StiNeverActiveFunctor);
397  pipeVolume->setIsContinuousMedium(false);
398  pipeVolume->setIsDiscreteScatterer(true);
399  pipeVolume->setShape(_beamPipeShape);
400  pipeVolume->setPlacement(p);
401  pipeVolume->setGas(_vacuumMaterial);
402  pipeVolume->setMaterial(_pipeMaterial);
403  Int_t layer = getNRows();
404  add(layer,0,pipeVolume);
405  }
406 }
407 //________________________________________________________________________________
408 void StiStarDetectorBuilder::Fgt() {
409  LOG_INFO << "StiStarDetectorBuilder::buildDetectors() : Use VMC old beam pipe geometry" << endm;
410  SetCurrentDetectorBuilder(this);
411  const VolumeMap_t FgtVolumes[] = {
412  //{"FGTM", "Beampipe support mother","HALL_1/CAVE_1/FGTM_1","",""},
413  {"FGCM", "FGT nylon and Al ring","HALL_1/CAVE_1/FGTM_1","",""},
414  {"FGTH", "mother volume for FGT disk","HALL_1/CAVE_1/FGTM_1","",""},
415  {"FGTD", "mother volume for FGT disk","HALL_1/CAVE_1/FGTM_1","",""},
416  {"FGCN", "FGT nylon 1st ring","HALL_1/CAVE_1/FGTM_1","",""},
417  {"FGCT", "FGT inner cooling tube","HALL_1/CAVE_1/FGTM_1","",""}
418  };
419  Int_t NoExtraVols = sizeof(FgtVolumes)/sizeof(VolumeMap_t);
420  TString pathT("HALL_1/CAVE_1");
421  TString path("");
422  for (Int_t i = 0; i < NoExtraVols; i++) {
423  gGeoManager->RestoreMasterVolume();
424  gGeoManager->CdTop();
425  gGeoManager->cd(pathT); path = pathT;
426  TGeoNode *nodeT = gGeoManager->GetCurrentNode();
427  if (! nodeT) continue;
428  StiVMCToolKit::LoopOverNodes(nodeT, path, FgtVolumes[i].name, MakeAverageVolume);
429  }
430 }
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
void setName(const string &newName)
Set the name of the object.
Definition: Named.cxx:15
Class implements an object which is never active.