8 #include "GeoModelKernel/GeoMaterial.h"
9 #include "GeoModelKernel/GeoPcon.h"
10 #include "GeoModelKernel/GeoTube.h"
11 #include "GeoModelKernel/GeoCons.h"
12 #include "GeoModelKernel/GeoLogVol.h"
13 #include "GeoModelKernel/GeoNameTag.h"
14 #include "GeoModelKernel/GeoPhysVol.h"
15 #include "GeoModelKernel/GeoFullPhysVol.h"
16 #include "GeoModelKernel/GeoTransform.h"
17 #include "GeoModelKernel/GeoDefinitions.h"
26 #include "GaudiKernel/MsgStream.h"
27 #include "GaudiKernel/SystemOfUnits.h"
36 :m_detectorManager(0),
71 GeoTube* dummytube=
new GeoTube(0., 4711., 4711.);
72 GeoLogVol* dummyBeamPipe =
new GeoLogVol(
"BeamPipe",dummytube,ether);
77 if (bpipeEnvelope->size() != 0) {
83 GeoLogVol* lvMotherCentral =
new GeoLogVol(
"BeamPipeCentral",envelopes.
centralShape,air);
84 GeoPhysVol* pvMotherCentral =
new GeoPhysVol(lvMotherCentral);
89 GeoLogVol* lvMotherFwd =
new GeoLogVol(
"BeamPipeFwd",envelopes.
fwdShape,air);
90 GeoPhysVol* pvMotherFwdPlus =
new GeoPhysVol(lvMotherFwd);
91 GeoPhysVol* pvMotherFwdMinus =
new GeoPhysVol(lvMotherFwd);
101 GeoNameTag *
tag =
new GeoNameTag(
"BeamPipe");
106 if (bpipePosition->size() != 0) {
112 if (
m_mode==
"AssemblyBeamPipe"){
115 theBeamPipe->add(
tag);
116 theBeamPipe->add(
new GeoTransform(GeoTrf::Translate3D(beamx,beamy,beamz)));
117 theBeamPipe->add(pvMotherCentral);
120 theBeamPipe->add(
tag);
121 theBeamPipe->add(pvMotherFwdPlus);
124 theBeamPipe->add(
tag);
126 theBeamPipe->add(pvMotherFwdMinus);
128 const GeoShape *shape = envelopes.
bpShape;
129 GeoLogVol* lvMother =
new GeoLogVol(
"BeamPipe",shape,air);
130 GeoPhysVol* pvMother =
new GeoPhysVol(lvMother);
132 pvMother->add(theBeamPipe);
135 world->add(pvMother);
142 world->add(
new GeoTransform(GeoTrf::Translate3D(beamx,beamy,beamz)));
143 world->add(pvMotherCentral);
147 world->add(pvMotherFwdPlus);
152 world->add(pvMotherFwdMinus);
162 bool central = (region == 0);
166 GeoPhysVol* pvMotherSection = 0;
167 bool addToFirstSection =
true;
173 for (
unsigned int itemp=0; itemp<bpipeSections->size(); itemp++)
175 std::string material = (*bpipeSections)[itemp]->getString(
"MATERIAL");
176 double rMin1 = (*bpipeSections)[itemp]->getDouble(
"RMIN1") *
Gaudi::Units::mm;
177 double rMax1 = (*bpipeSections)[itemp]->getDouble(
"RMAX1") *
Gaudi::Units::mm;
178 double rMin2 = (*bpipeSections)[itemp]->getDouble(
"RMIN2") *
Gaudi::Units::mm;
179 double rMax2 = (*bpipeSections)[itemp]->getDouble(
"RMAX2") *
Gaudi::Units::mm;
182 int secNum = (*bpipeSections)[itemp]->getInt(
"SECNUM");
184 double zmin =
z - dZ;
185 double zmax =
z + dZ;
204 std::ostringstream
os;
210 os << std::setw(2) << std::setfill(
'0') << secNum;
211 std::string
name =
os.str();
225 if((rMin1==rMin2)&&(rMax1==rMax2)) {
226 shape =
new GeoTube(rMin1,rMax1,dZnew);
229 shape =
new GeoCons(rMin1,rMin2,
244 GeoLogVol* lvSection =
new GeoLogVol(
name,shape,
mat);
245 GeoIntrusivePtr<GeoPhysVol> pvSection{
new GeoPhysVol(lvSection)};
252 pvMotherSection = pvSection;
259 if (addToFirstSection && secNum != 1) {
260 double rAve = 0.5*(rMin1+rMax1);
261 addToFirstSection = (znew > zminSec1 && znew < zmaxSec1 &&
262 rAve > rminSec1 && rAve < rmaxSec1);
266 GeoTransform* tfSection = 0;
267 if (znew != 0 && (secNum==1 || !addToFirstSection)) tfSection =
new GeoTransform(GeoTrf::TranslateZ3D(znew));
268 GeoIntrusivePtr<GeoNameTag> ntSection{
new GeoNameTag(
name)};
270 if (addToFirstSection && secNum!=1) {
271 if (!pvMotherSection) {
273 gLog << MSG::ERROR <<
"Logic error building beam pipe." <<
endmsg;
277 pvMotherSection->add(ntSection);
278 pvMotherSection->add(pvSection);
283 if (tfSection)
parent->add(tfSection);
288 if(central &&
z!=0.) {
290 GeoTransform* tfSectionRot = 0;
293 tfSectionRot =
new GeoTransform(GeoTrf::TranslateZ3D(-znew));
296 tfSectionRot =
new GeoTransform(GeoTrf::TranslateZ3D(-znew)*GeoTrf::RotateY3D(180*
Gaudi::Units::deg));
299 parent->add(tfSectionRot);
324 std::vector<EnvelopeEntry> centralEntry;
325 std::vector<EnvelopeEntry> fwdEntry;
327 for (
unsigned int i=0;
i<bpipeEnvelope->size();
i++) {
332 centralEntry.push_back(
entry);
334 fwdEntry.push_back(
entry);
339 if (fwdEntry.size()) {
340 rFwd = fwdEntry[0].r();
341 }
else if (centralEntry.size()) {
342 rFwd = centralEntry[0].r();
344 std::cout <<
"Unexpected condition when building beam pipe." << std::endl;
348 if (centralEntry.size() == 0) {
355 for (
int i=centralEntry.size()-1;
i>=0;
i--) {
356 double z = centralEntry[
i].z();
357 double r = centralEntry[
i].r();
358 pcone->addPlane(-
z,0,
r);
360 for (
unsigned int i=0;
i<centralEntry.size();
i++) {
361 double z = centralEntry[
i].z();
362 double r = centralEntry[
i].r();
363 pcone->addPlane(
z,0,
r);
374 if (fwdEntry.size() == 0) {
379 for (
unsigned int i=0;
i<fwdEntry.size();
i++) {
380 double z = fwdEntry[
i].z();
381 double r = fwdEntry[
i].r();
382 pcone->addPlane(
z,0,
r);
390 for (
int i=fwdEntry.size()-1;
i>=0;
i--) {
391 double z = fwdEntry[
i].z();
392 double r = fwdEntry[
i].r();
393 Pcone->addPlane(-
z,0,
r);
397 for (
unsigned int i=0;
i<fwdEntry.size();
i++) {
398 double z = fwdEntry[
i].z();
399 double r = fwdEntry[
i].r();
400 Pcone->addPlane(
z,0,
r);
431 bpipeEnvPcone->addPlane(ilen,0,iir);
432 bpipeEnvPcone->addPlane(ilen,0,cir);
433 bpipeEnvPcone->addPlane(clen,0,cir);
434 bpipeEnvPcone->addPlane(clen,0,mir);
435 bpipeEnvPcone->addPlane(totlen,0,mir);