40 #include "GeoModelKernel/Units.h"
41 #include "GeoModelKernel/GeoBox.h"
42 #include "GeoModelKernel/GeoTubs.h"
43 #include "GeoModelKernel/GeoEllipticalTube.h"
44 #include "GeoModelKernel/GeoTrd.h"
45 #include "GeoModelKernel/GeoCons.h"
46 #include "GeoModelKernel/GeoPcon.h"
47 #include "GeoModelKernel/GeoPgon.h"
48 #include "GeoModelKernel/GeoSimplePolygonBrep.h"
49 #include "GeoModelKernel/GeoShapeUnion.h"
50 #include "GeoModelKernel/GeoShapeIntersection.h"
51 #include "GeoModelKernel/GeoShapeSubtraction.h"
52 #include "GeoModelKernel/GeoShapeShift.h"
53 #include "GeoModelKernel/GeoTransform.h"
54 #include "GeoModelKernel/GeoIntrusivePtr.h"
57 #include "GaudiKernel/ISvcLocator.h"
58 #include "GaudiKernel/Bootstrap.h"
59 #include "GaudiKernel/MsgStream.h"
88 return (GeoElement *)(
el->GetElement());
93 g4el=
new GeoElement(
el->GetName(),
el->GetSymbol(),
114 return (GeoMaterial*)(
mat->GetMaterial());
125 log<<MSG::WARNING<<
"CreateMaterial() - AGDDMaterial is nullptr"<<
endmsg;
133 g4mat->add((GeoElement*)(
el->GetElement()));
135 mat->SetMaterial(g4mat);
144 log<<MSG::WARNING<<
"CreateMaterial() - AGDDMolecule is nullptr"<<
endmsg;
154 mat->SetMaterial(g4mat);
164 log<<MSG::WARNING<<
"CreateMaterial() - AGDDMixture is nullptr"<<
endmsg;
174 mat->SetMaterial(g4mat);
181 log<<MSG::WARNING<<
"CreateMaterial() - Unknown material type "<<mtype<<
endmsg;
206 void *
p=
v->GetSolid();
209 GeoShape* solid=
new GeoBox(
v->x()/2.,
v->y()/2.,std::abs(
v->z())/2.);
215 void *
p=
v->GetSolid();
218 GeoShape* solid=
new GeoTrd(
v->x1()/2.,
v->x2()/2,
v->y1()/2.,
v->y2()/2.,
v->z()/2.);
227 static const GeoIntrusivePtr<const GeoShape>
s1 = [&] {
230 return new GeoShapeShift (&*box1, ttt1);
232 static const GeoIntrusivePtr<const GeoShape>
s2 = [&] {
235 return new GeoShapeShift (&*box1, ttt2);
245 double angle2=std::abs(std::atan2(
axis.cross(axis2).norm(),
axis.dot(axis2)))/2;
248 double lengthnew=
length+delta_l2;
249 GeoShape* solid=
new GeoTubs(0.,
radius,lengthnew/2.,0.,2.0*
M_PI);
255 solid =
new GeoShapeSubtraction(solid,ssnew);
259 solid=
new GeoShapeShift(solid,tref);
264 for (
int i=1;
i<
v->NrOfPoints()-1;
i++)
266 axis0=
v->GetPoint(
i)-
v->GetPoint(
i+1);
267 axis=
v->GetPoint(
i+1)-
v->GetPoint(
i);
268 axis1=
v->GetPoint(
i)-
v->GetPoint(
i-1);
271 angle1=std::abs(std::atan2(
axis.cross(axis1).norm(),
axis.dot(axis1)))/2;
274 if (
i<(
v->NrOfPoints()-2))
276 axis2=
v->GetPoint(
i+2)-
v->GetPoint(
i+1);
277 angle2=std::abs(std::atan2(
axis.cross(axis2).norm(),
axis.dot(axis2)))/2;
281 lengthnew=
length+delta_l1+delta_l2;
286 GeoShape*
ss=
new GeoTubs(0.,
radius,lengthnew/2.,0.,2.0*
M_PI);
294 GeoShape *ssnew1=
new GeoShapeShift(&*
s2,ttt1);
295 ss =
new GeoShapeSubtraction(
ss,ssnew1);
296 if (
i<(
v->NrOfPoints()-2))
298 GeoShape *ssnew2=
new GeoShapeShift(&*
s1,ttt2);
299 ss =
new GeoShapeSubtraction(
ss,ssnew2);
302 ss=
new GeoShapeShift(
ss,ttref);
307 solid=
new GeoShapeUnion(solid,
ss);
314 void *
p=
v->GetSolid();
323 void *
p=
v->GetSolid();
333 void *
p=
v->GetSolid();
336 GeoShape* solid=
new GeoEllipticalTube(
v->dx(),
v->dy(),
v->z()/2.);
343 void *
p=
v->GetSolid();
346 int nPoint=
v->NrOfPoints();
347 GeoSimplePolygonBrep* solid;
348 solid =
new GeoSimplePolygonBrep(
v->GetDz()/2.);
350 v->SetPoint(
v->GetPoint(0));
351 for (
int i=0;
i<nPoint;
i++)
354 area+=
v->GetPoint(
i).x()*
v->GetPoint(iplus).y()-
v->GetPoint(iplus).x()*
v->GetPoint(
i).y();
357 bool clockwise=
area<0?
true:
false;
360 for (
int i=0;
i<nPoint;
i++)
362 if (clockwise) pV=
v->GetPoint(nPoint-1-
i);
363 else pV=
v->GetPoint(
i);
364 solid->addVertex(pV.
x(),pV.
y());
372 int nPos=
v->NrOfDaughter();
376 GeoShape *sV=(GeoShape*)(vol->
GetSolid());
377 sV=
new GeoShapeShift(sV,
pos->Transform());
378 for (
int i=1;
i<nPos;
i++)
382 vv->CreateSolid(*
this);
383 GeoShape *nsV=(GeoShape*)(
vv->GetSolid());
384 nsV=
new GeoShapeShift(nsV,pp->
Transform());
385 sV=
new GeoShapeUnion(sV,nsV);
393 int nPos=
v->NrOfDaughter();
397 GeoShape *sV=(GeoShape*)(vol->
GetSolid());
398 sV=
new GeoShapeShift(sV,
pos->Transform());
399 for (
int i=1;
i<nPos;
i++)
403 vv->CreateSolid(*
this);
404 GeoShape *nsV=(GeoShape*)(
vv->GetSolid());
405 nsV=
new GeoShapeShift(nsV,pp->
Transform());
406 sV=
new GeoShapeIntersection(sV,nsV);
413 int nPos=
v->NrOfDaughter();
417 GeoShape *sV=(GeoShape*)(vol->
GetSolid());
418 sV=
new GeoShapeShift(sV,
pos->Transform());
419 for (
int i=1;
i<nPos;
i++)
423 vv->CreateSolid(*
this);
424 GeoShape *nsV=(GeoShape*)(
vv->GetSolid());
425 nsV=
new GeoShapeShift(nsV,pp->
Transform());
426 sV=
new GeoShapeSubtraction(sV,nsV);
434 void *
p=
v->GetSolid();
437 int nPlanes=
v->NrOfPlanes();
439 for (
int i=0;
i<nPlanes;
i++)
442 double ro=
v->Rout(
i);
444 solid->addPlane(
z,ri,ro);
452 void *
p=
v->GetSolid();
455 int nPlanes=
v->NrOfPlanes();
457 for (
int i=0;
i<nPlanes;
i++)
460 double ro=
v->Rout(
i);
462 solid->addPlane(
z,ri,ro);
471 static const GeoMaterial *
const ether =
GetMMMaterial(
"special::Ether");
472 static const GeoIntrusivePtr<const GeoShape> fakeVol =
new GeoTubs(0.,500.,1000.,0.,2.0*
M_PI);
476 GeoLogVol *
a=
new GeoLogVol(
v->GetName(),&*fakeVol,ether);
477 GeoPhysVol *a_phys=
new GeoPhysVol(
a);
478 v->SetVolume(a_phys);
480 for (
int i=0;
i<
v->NrOfDaughter();
i++)
484 const std::string volName = vol->
GetName();
489 std::string detFullTag=
"";
495 log<<MSG::WARNING<<
"CreateComposition() - Cannot retrieve Detector element for "<<volName<<
endmsg;
498 if (
p) detFullTag=
p->ID.detectorAddress;
501 log<<MSG::WARNING<<
"CreateComposition() - AGDDDetectorPositioner is nullptr"<<
endmsg;
505 GeoTransform *geotrf=
new GeoTransform(
trf);
509 GeoFullPhysVol* detVol=NULL;
515 detVol=(GeoFullPhysVol*)(vol->
GetVolume());
516 if (
p)
p->theVolume=detVol;
525 detVol=(GeoFullPhysVol*)temp;
526 detVol=detVol->clone();
527 if (
p)
p->theVolume=detVol;
532 if (isDetElement) a_phys->add(detVol);
533 else a_phys->add((GeoPhysVol*)(vol->
GetVolume()));
543 void*
p=
v->GetVolume();
546 GeoShape* sol=(GeoShape*)
v->GetSolid();
549 log<<MSG::WARNING<<
"CreateVolume() - solid is nullptr!"<<
endmsg;
553 GeoLogVol* lv=
new GeoLogVol(
v->GetName(),sol,
mat);
554 GeoPhysVol *lv_phys=
new GeoPhysVol(lv);
556 v->SetVolume(lv_phys);
563 AGDDVolumeMap::const_iterator
it;
576 GeoPhysVol *vvv=(GeoPhysVol*)(vol->
GetVolume());
582 log<<MSG::WARNING<<
"BuildAllVolumes() - mother not set!"<<
endmsg;
585 GeoTransform *gtrf=
new GeoTransform(
trf);
604 std::string topVolumeName=sect->
TopVolume();
605 if (topVolumeName!=
"useless" && !topVolumeName.empty())
610 if (vol->
GetName()==topVolumeName)
618 GeoPhysVol *vvv=(GeoPhysVol*)(vol->
GetVolume());
623 log<<MSG::WARNING<<
"BuildFromSection() - mother not set!"<<
endmsg;
626 GeoTransform *gtrf=
new GeoTransform(
trf);
645 GeoPhysVol *vvv=(GeoPhysVol*)(vol->
GetVolume());
650 log<<MSG::WARNING<<
"BuildFromSection() - mother not set (no top volume)!"<<
endmsg;
653 GeoTransform *gtrf=
new GeoTransform(
trf);
663 log<<MSG::WARNING<<
"BuildFromSection() - This section is flagged as not to be built!"<<
endmsg;
673 log<<MSG::WARNING<<
"BuildFromVolume() - Volume "<<
s<<
" not found in the store! Exiting..."<<
endmsg;
677 GeoPhysVol *vvv=(GeoPhysVol*)(vol->
GetVolume());
682 log<<MSG::WARNING<<
"BuildFromVolume() - mother not set!"<<
endmsg;
685 GeoTransform *gtrf=
new GeoTransform(
trf);
693 void *
p=
b->GetSolid();
699 s->addPlane(-
b->m_length/2.,0,
b->m_headDiameter/2.);
700 s->addPlane(-
b->m_length/2.+
b->m_headLength,0,
b->m_headDiameter/2.);
701 solid=
new GeoShapeUnion(solid,
s);
708 void *
p=
b->GetSolid();
711 GeoSimplePolygonBrep* solid;
712 solid =
new GeoSimplePolygonBrep(
b->GetLength()/2.);
713 solid->addVertex(
b->m_width/2.,
b->m_height/2);
714 solid->addVertex(-
b->m_width/2.,
b->m_height/2);
715 solid->addVertex(-
b->m_width/2.,
b->m_smallHeight/2);
716 solid->addVertex(-
b->m_smallWidth/2.,
b->m_smallHeight/2);
717 solid->addVertex(-
b->m_smallWidth/2.,-
b->m_smallHeight/2);
718 solid->addVertex(-
b->m_width/2.,-
b->m_smallHeight/2);
719 solid->addVertex(-
b->m_width/2.,-
b->m_height/2);
720 solid->addVertex(
b->m_width/2.,-
b->m_height/2);
721 solid->addVertex(
b->m_width/2.,-
b->m_smallHeight/2);
722 solid->addVertex(
b->m_smallWidth/2.,-
b->m_smallHeight/2);
723 solid->addVertex(
b->m_smallWidth/2.,
b->m_smallHeight/2);
724 solid->addVertex(
b->m_width/2.,
b->m_smallHeight/2);
731 void *
p=
b->GetSolid();
734 GeoSimplePolygonBrep* solid;
735 solid =
new GeoSimplePolygonBrep(
b->GetLength()/2.);
736 solid->addVertex(
b->m_width/2.,
b->m_smallHeight/2.);
737 solid->addVertex(-
b->m_width/2.,
b->m_smallHeight/2.);
738 solid->addVertex(-
b->m_width/2.,-
b->m_height+
b->m_smallHeight/2.);
739 solid->addVertex(-
b->m_width/2.+
b->m_smallWidth,-
b->m_height+
b->m_smallHeight/2.);
740 solid->addVertex(-
b->m_width/2.+
b->m_smallWidth,-
b->m_smallHeight/2.);
741 solid->addVertex(
b->m_width/2.-
b->m_smallWidth,-
b->m_smallHeight/2.);
742 solid->addVertex(
b->m_width/2.-
b->m_smallWidth,-
b->m_height+
b->m_smallHeight/2.);
743 solid->addVertex(
b->m_width/2.,-
b->m_height+
b->m_smallHeight/2.);