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(nullptr),
37 m_materialManager(nullptr),
70 GeoTube* dummytube=
new GeoTube(0., 4711., 4711.);
71 GeoLogVol* dummyBeamPipe =
new GeoLogVol(
"BeamPipe",dummytube,ether);
76 if (bpipeEnvelope->size() != 0) {
82 GeoLogVol* lvMotherCentral =
new GeoLogVol(
"BeamPipeCentral",envelopes.
centralShape,air);
83 GeoPhysVol* pvMotherCentral =
new GeoPhysVol(lvMotherCentral);
88 GeoLogVol* lvMotherFwd =
new GeoLogVol(
"BeamPipeFwd",envelopes.
fwdShape,air);
89 GeoPhysVol* pvMotherFwdPlus =
new GeoPhysVol(lvMotherFwd);
90 GeoPhysVol* pvMotherFwdMinus =
new GeoPhysVol(lvMotherFwd);
100 GeoNameTag *
tag =
new GeoNameTag(
"BeamPipe");
105 if (bpipePosition->size() != 0) {
111 if (
m_mode==
"AssemblyBeamPipe"){
114 theBeamPipe->add(
tag);
115 theBeamPipe->add(
new GeoTransform(GeoTrf::Translate3D(beamx,beamy,beamz)));
116 theBeamPipe->add(pvMotherCentral);
119 theBeamPipe->add(
tag);
120 theBeamPipe->add(pvMotherFwdPlus);
123 theBeamPipe->add(
tag);
125 theBeamPipe->add(pvMotherFwdMinus);
127 const GeoShape *shape = envelopes.
bpShape;
128 GeoLogVol* lvMother =
new GeoLogVol(
"BeamPipe",shape,air);
129 GeoPhysVol* pvMother =
new GeoPhysVol(lvMother);
131 pvMother->add(theBeamPipe);
134 world->add(pvMother);
141 world->add(
new GeoTransform(GeoTrf::Translate3D(beamx,beamy,beamz)));
142 world->add(pvMotherCentral);
146 world->add(pvMotherFwdPlus);
151 world->add(pvMotherFwdMinus);
161 bool central = (region == 0);
165 GeoPhysVol* pvMotherSection =
nullptr;
166 bool addToFirstSection =
true;
172 for (
unsigned int itemp=0; itemp<bpipeSections->size(); itemp++)
174 std::string material = (*bpipeSections)[itemp]->getString(
"MATERIAL");
175 double rMin1 = (*bpipeSections)[itemp]->getDouble(
"RMIN1") *
Gaudi::Units::mm;
176 double rMax1 = (*bpipeSections)[itemp]->getDouble(
"RMAX1") *
Gaudi::Units::mm;
177 double rMin2 = (*bpipeSections)[itemp]->getDouble(
"RMIN2") *
Gaudi::Units::mm;
178 double rMax2 = (*bpipeSections)[itemp]->getDouble(
"RMAX2") *
Gaudi::Units::mm;
181 int secNum = (*bpipeSections)[itemp]->getInt(
"SECNUM");
183 double zmin =
z - dZ;
184 double zmax =
z + dZ;
203 std::ostringstream
os;
209 os << std::setw(2) << std::setfill(
'0') << secNum;
210 std::string
name =
os.str();
224 if((rMin1==rMin2)&&(rMax1==rMax2)) {
225 shape =
new GeoTube(rMin1,rMax1,dZnew);
228 shape =
new GeoCons(rMin1,rMin2,
236 if (
mat ==
nullptr) {
243 GeoLogVol* lvSection =
new GeoLogVol(
name,shape,
mat);
244 GeoIntrusivePtr<GeoPhysVol> pvSection{
new GeoPhysVol(lvSection)};
251 pvMotherSection = pvSection;
258 if (addToFirstSection && secNum != 1) {
259 double rAve = 0.5*(rMin1+rMax1);
260 addToFirstSection = (znew > zminSec1 && znew < zmaxSec1 &&
261 rAve > rminSec1 && rAve < rmaxSec1);
265 GeoTransform* tfSection =
nullptr;
266 if (znew != 0 && (secNum==1 || !addToFirstSection)) tfSection =
new GeoTransform(GeoTrf::TranslateZ3D(znew));
267 GeoIntrusivePtr<GeoNameTag> ntSection{
new GeoNameTag(
name)};
269 if (addToFirstSection && secNum!=1) {
270 if (!pvMotherSection) {
272 gLog << MSG::ERROR <<
"Logic error building beam pipe." <<
endmsg;
276 pvMotherSection->add(ntSection);
277 pvMotherSection->add(pvSection);
282 if (tfSection)
parent->add(tfSection);
287 if(central &&
z!=0.) {
289 GeoTransform* tfSectionRot =
nullptr;
292 tfSectionRot =
new GeoTransform(GeoTrf::TranslateZ3D(-znew));
295 tfSectionRot =
new GeoTransform(GeoTrf::TranslateZ3D(-znew)*GeoTrf::RotateY3D(180*
Gaudi::Units::deg));
298 parent->add(tfSectionRot);
323 std::vector<EnvelopeEntry> centralEntry;
324 std::vector<EnvelopeEntry> fwdEntry;
326 for (
unsigned int i=0;
i<bpipeEnvelope->size();
i++) {
331 centralEntry.push_back(
entry);
333 fwdEntry.push_back(
entry);
338 if (!fwdEntry.empty()) {
339 rFwd = fwdEntry[0].r();
340 }
else if (!centralEntry.empty()) {
341 rFwd = centralEntry[0].r();
343 std::cout <<
"Unexpected condition when building beam pipe." << std::endl;
347 if (centralEntry.empty()) {
354 for (
int i=centralEntry.size()-1;
i>=0;
i--) {
355 double z = centralEntry[
i].z();
356 double r = centralEntry[
i].r();
357 pcone->addPlane(-
z,0,
r);
359 for (
unsigned int i=0;
i<centralEntry.size();
i++) {
360 double z = centralEntry[
i].z();
361 double r = centralEntry[
i].r();
362 pcone->addPlane(
z,0,
r);
373 if (fwdEntry.empty()) {
378 for (
unsigned int i=0;
i<fwdEntry.size();
i++) {
379 double z = fwdEntry[
i].z();
380 double r = fwdEntry[
i].r();
381 pcone->addPlane(
z,0,
r);
389 for (
int i=fwdEntry.size()-1;
i>=0;
i--) {
390 double z = fwdEntry[
i].z();
391 double r = fwdEntry[
i].r();
392 Pcone->addPlane(-
z,0,
r);
396 for (
unsigned int i=0;
i<fwdEntry.size();
i++) {
397 double z = fwdEntry[
i].z();
398 double r = fwdEntry[
i].r();
399 Pcone->addPlane(
z,0,
r);
430 bpipeEnvPcone->addPlane(ilen,0,iir);
431 bpipeEnvPcone->addPlane(ilen,0,cir);
432 bpipeEnvPcone->addPlane(clen,0,cir);
433 bpipeEnvPcone->addPlane(clen,0,mir);
434 bpipeEnvPcone->addPlane(totlen,0,mir);