ATLAS Offline Software
Loading...
Searching...
No Matches
AGDD2GeoModelBuilder Class Reference

#include <AGDD2GeoModelBuilder.h>

Inheritance diagram for AGDD2GeoModelBuilder:
Collaboration diagram for AGDD2GeoModelBuilder:

Public Member Functions

 AGDD2GeoModelBuilder (AGDDDetectorStore &ds, AGDDVolumeStore &vs, AGDDSectionStore &ss, AliasStore &as, AGDDMaterialStore &ms)
 ~AGDD2GeoModelBuilder ()=default
GeoElement * CreateElement (const std::string &)
const GeoMaterial * CreateMaterial (const std::string &)
virtual void CreateElements () override
virtual void CreateMaterial () override
virtual void CreateBox (AGDDBox *) const override
virtual void CreateTrd (AGDDTrd *) const override
virtual void CreateTubs (AGDDTubs *) const override
virtual void CreateElcyl (AGDDElcyl *) const override
virtual void CreateCons (AGDDCons *) const override
virtual void CreatePcon (AGDDPcon *) const override
virtual void CreatePgon (AGDDPgon *) const override
virtual void CreateGvxy (AGDDGvxy *) const override
virtual void CreateSnake (AGDDSnake *) const override
virtual void CreateUnion (AGDDUnion *) const override
virtual void CreateIntersection (AGDDIntersection *) const override
virtual void CreateSubtraction (AGDDSubtraction *) const override
virtual void CreateBolt (AGDDBolt *) const override
virtual void CreateIbeam (AGDDIbeam *) const override
virtual void CreateUbeam (AGDDUbeam *) const override
virtual void CreateVolume (AGDDVolume *) override
virtual void CreateComposition (AGDDComposition *) override
virtual void SetMotherVolume (GeoPhysVol *v)
virtual void BuildAllVolumes ()
virtual void BuildFromSection (const std::string &) override
virtual void BuildFromVolume (const std::string &) override
virtual StoredMaterialManagerGetMaterialManager () const override

Private Member Functions

const GeoMaterial * GetMMMaterial (const std::string &) const
double phi (const GeoTrf::Vector3D &vec) const
 phi method (cf.
double theta (const GeoTrf::Vector3D &vec) const
 theta method (cf.

Private Attributes

GeoPhysVol * m_mother
AGDDDetectorStorem_ds
AGDDVolumeStorem_vs
AGDDSectionStorem_ss
AliasStorem_as
AGDDMaterialStorem_ms

Detailed Description

Definition at line 42 of file AGDD2GeoModelBuilder.h.

Constructor & Destructor Documentation

◆ AGDD2GeoModelBuilder()

AGDD2GeoModelBuilder::AGDD2GeoModelBuilder ( AGDDDetectorStore & ds,
AGDDVolumeStore & vs,
AGDDSectionStore & ss,
AliasStore & as,
AGDDMaterialStore & ms )

Definition at line 68 of file AGDD2GeoModelBuilder.cxx.

72 :
74 m_mother(nullptr),
75 m_ds(ds),
76 m_vs(vs),
77 m_ss(ss),
78 m_as(as),
79 m_ms(ms)
80{
81}
static Double_t ss
AGDDMaterialStore & m_ms
AGDDDetectorStore & m_ds
AGDDSectionStore & m_ss

◆ ~AGDD2GeoModelBuilder()

AGDD2GeoModelBuilder::~AGDD2GeoModelBuilder ( )
default

Member Function Documentation

◆ BuildAllVolumes()

void AGDD2GeoModelBuilder::BuildAllVolumes ( )
virtual

Definition at line 561 of file AGDD2GeoModelBuilder.cxx.

562{
563 AGDDVolumeMap::const_iterator it;
564 GeoTrf::Transform3D trf = GeoTrf::Transform3D::Identity();
565
566 for (it=m_vs.begin();it!=m_vs.end();++it)
567 {
568 AGDDVolume* vol=(*it).second;
569 if (!vol->HasParent())
570 {
571 vol->CreateVolume(*this);
572 AGDDComposition *vv=dynamic_cast<AGDDComposition *>(vol);
573
574 if (vv)
575 {
576 GeoPhysVol *vvv=(GeoPhysVol*)(vol->GetVolume());
577 if (vvv)
578 {
579 if (!m_mother)
580 {
581 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
582 log<<MSG::WARNING<<"BuildAllVolumes() - mother not set!"<<endmsg;
583 return;
584 }
585 GeoTransform *gtrf=new GeoTransform(trf);
586 m_mother->add(gtrf);
587 m_mother->add(vvv);
588 }
589 }
590 }
591 }
592}
#define endmsg
bool HasParent() const
Definition AGDDVolume.h:30
void * GetVolume()
Definition AGDDVolume.h:32
virtual void CreateVolume(AGDDBuilder &)
Definition AGDDVolume.h:26
IMessageSvc * getMessageSvc(bool quiet=false)

◆ BuildFromSection()

void AGDD2GeoModelBuilder::BuildFromSection ( const std::string & s)
overridevirtual

Implements AGDDBuilder.

Definition at line 594 of file AGDD2GeoModelBuilder.cxx.

595{
596 GeoTrf::Transform3D trf = GeoTrf::Transform3D::Identity();
597
598 AGDDSection* sect=m_ss.GetSection(s);
599
600 bool bFlag=sect->IsToBeBuilt();
601 if (bFlag)
602 {
604 std::string topVolumeName=sect->TopVolume();
605 if (topVolumeName!="useless" && !topVolumeName.empty())
606 {
607 for (it=sect->VolumeBegin();it!=sect->VolumeEnd();++it)
608 {
609 AGDDVolume* vol=(*it).second;
610 if (vol->GetName()==topVolumeName)
611 {
612 vol->CreateVolume(*this);
613
614 AGDDComposition *vv=dynamic_cast<AGDDComposition *>(vol);
615
616 if (vv)
617 {
618 GeoPhysVol *vvv=(GeoPhysVol*)(vol->GetVolume());
619 if (vvv)
620 {
621 if (!m_mother) {
622 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
623 log<<MSG::WARNING<<"BuildFromSection() - mother not set!"<<endmsg;
624 return;
625 }
626 GeoTransform *gtrf=new GeoTransform(trf);
627 m_mother->add(gtrf);
628 m_mother->add(vvv);
629 }
630 }
631 }
632 }
633 }
634 else
635 for (it=sect->VolumeBegin();it!=sect->VolumeEnd();++it)
636 {
637 AGDDVolume* vol=(*it).second;
638 if (!vol->HasParent())
639 {
640 vol->CreateVolume(*this);
641 AGDDComposition *vv=dynamic_cast<AGDDComposition *>(vol);
642
643 if (vv)
644 {
645 GeoPhysVol *vvv=(GeoPhysVol*)(vol->GetVolume());
646 if (vvv)
647 {
648 if (!m_mother) {
649 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
650 log<<MSG::WARNING<<"BuildFromSection() - mother not set (no top volume)!"<<endmsg;
651 return;
652 }
653 GeoTransform *gtrf=new GeoTransform(trf);
654 m_mother->add(gtrf);
655 m_mother->add(vvv);
656 }
657 }
658 }
659 }
660 }
661 else {
662 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
663 log<<MSG::WARNING<<"BuildFromSection() - This section is flagged as not to be built!"<<endmsg;
664 }
665}
volumeList::const_iterator volumeIterator
Definition AGDDSection.h:15
void TopVolume(const std::string &n)
Definition AGDDSection.h:30
bool IsToBeBuilt() const
Definition AGDDSection.h:36
volumeIterator VolumeBegin()
Definition AGDDSection.h:37
volumeIterator VolumeEnd()
Definition AGDDSection.h:38
const std::string & GetName() const
Definition AGDDVolume.h:23

◆ BuildFromVolume()

void AGDD2GeoModelBuilder::BuildFromVolume ( const std::string & s)
overridevirtual

Implements AGDDBuilder.

Definition at line 666 of file AGDD2GeoModelBuilder.cxx.

667{
668 GeoTrf::Transform3D trf = GeoTrf::Transform3D::Identity();
669
670 AGDDVolume* vol=m_vs.GetVolume(s);
671 if (!vol) {
672 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
673 log<<MSG::WARNING<<"BuildFromVolume() - Volume "<<s<<" not found in the store! Exiting..."<<endmsg;
674 return;
675 }
676 vol->CreateVolume(*this);
677 GeoPhysVol *vvv=(GeoPhysVol*)(vol->GetVolume());
678 if (vvv)
679 {
680 if (!m_mother) {
681 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
682 log<<MSG::WARNING<<"BuildFromVolume() - mother not set!"<<endmsg;
683 return;
684 }
685 GeoTransform *gtrf=new GeoTransform(trf);
686 m_mother->add(gtrf);
687 m_mother->add(vvv);
688 }
689}

◆ CreateBolt()

void AGDD2GeoModelBuilder::CreateBolt ( AGDDBolt * b) const
overridevirtual

Implements AGDDBuilder.

Definition at line 691 of file AGDD2GeoModelBuilder.cxx.

692{
693 void *p=b->GetSolid();
694 if (!p)
695 {
696 GeoShape* solid=new GeoTubs(0,b->m_diameter/2.,b->m_length/2.,0.,360.*GeoModelKernelUnits::degree);
697
698 GeoPgon* s=new GeoPgon(0.,360*GeoModelKernelUnits::degree,6);
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);
702 b->SetSolid(solid);
703 }
704}
static std::map< double, LArWheelSliceSolid * > solid

◆ CreateBox()

void AGDD2GeoModelBuilder::CreateBox ( AGDDBox * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 204 of file AGDD2GeoModelBuilder.cxx.

205{
206 void *p=v->GetSolid();
207 if (!p)
208 {
209 GeoShape* solid=new GeoBox(v->x()/2.,v->y()/2.,std::abs(v->z())/2.);
210 v->SetSolid(solid);
211 }
212}

◆ CreateComposition()

void AGDD2GeoModelBuilder::CreateComposition ( AGDDComposition * v)
overridevirtual

Implements AGDDBuilder.

Definition at line 469 of file AGDD2GeoModelBuilder.cxx.

470{
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);
473
474 if (!v->GetVolume())
475 {
476 GeoLogVol *a=new GeoLogVol(v->GetName(),&*fakeVol,ether);
477 GeoPhysVol *a_phys=new GeoPhysVol(a);
478 v->SetVolume(a_phys);
479
480 for (int i=0;i<v->NrOfDaughter();i++)
481 {
482 AGDDPositioner* pos=v->GetDaughter(i);
483 AGDDVolume *vol=pos->GetVolume();
484 const std::string volName = vol->GetName();
485
486 bool isDetElement=vol->IsSensitiveVolume();
487 AGDDDetector *d=0;
488 AGDDDetectorPositioner *p=0;
489 std::string detFullTag="";
490 if (isDetElement)
491 {
492 d=m_ds.GetDetector(volName);
493 if (!d) {
494 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
495 log<<MSG::WARNING<<"CreateComposition() - Cannot retrieve Detector element for "<<volName<<endmsg;
496 }
497 p=dynamic_cast<AGDDDetectorPositioner *>(pos);
498 if (p) detFullTag=p->ID.detectorAddress;
499 else {
500 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
501 log<<MSG::WARNING<<"CreateComposition() - AGDDDetectorPositioner is nullptr"<<endmsg;
502 }
503 }
504 GeoTrf::Transform3D trf=pos->Transform();
505 GeoTransform *geotrf=new GeoTransform(trf);
506 void *temp=vol->GetVolume();
507
508 // GeoFullPhysVol are needed for detectors (corresponding to ReadoutElements)
509 GeoFullPhysVol* detVol=NULL;
510 if (!temp)
511 {
512 // if it's the first occurrence of this Volume, build it
513 vol->CreateVolume(*this);
514 if (isDetElement) {
515 detVol=(GeoFullPhysVol*)(vol->GetVolume());
516 if (p) p->theVolume=detVol;
517 }
518 }
519 else {
520 // if this Volume was already built, you can re-use it;
521 // however if it is a GeoFullPhysVol you need to clone it
522 // (in order to allow for a new and indipendent cached transform)
523 if (isDetElement)
524 {
525 detVol=(GeoFullPhysVol*)temp;
526 detVol=detVol->clone();
527 if (p) p->theVolume=detVol;
528 }
529 }
530
531 a_phys->add(geotrf);
532 if (isDetElement) a_phys->add(detVol);
533 else a_phys->add((GeoPhysVol*)(vol->GetVolume()));
534 }
535 }
536}
#define M_PI
static Double_t a
const GeoMaterial * GetMMMaterial(const std::string &) const
void IsSensitiveVolume(bool v)

◆ CreateCons()

void AGDD2GeoModelBuilder::CreateCons ( AGDDCons * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 312 of file AGDD2GeoModelBuilder.cxx.

313{
314 void *p=v->GetSolid();
315 if (!p)
316 {
317 GeoShape* solid=new GeoCons(v->rin1(),v->rin2(),v->rou1(),v->rou2(),v->z()/2.,v->phi0()*GeoModelKernelUnits::degree,v->dphi()*GeoModelKernelUnits::degree);
318 v->SetSolid(solid);
319 }
320}

◆ CreateElcyl()

void AGDD2GeoModelBuilder::CreateElcyl ( AGDDElcyl * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 331 of file AGDD2GeoModelBuilder.cxx.

332{
333 void *p=v->GetSolid();
334 if (!p)
335 {
336 GeoShape* solid=new GeoEllipticalTube(v->dx(),v->dy(),v->z()/2.);
337 v->SetSolid(solid);
338 }
339}

◆ CreateElement()

GeoElement * AGDD2GeoModelBuilder::CreateElement ( const std::string & name)

Definition at line 83 of file AGDD2GeoModelBuilder.cxx.

84{
85 AGDDElement *el=m_ms.GetElement(name);
86 if (el)
87 if (el->Extant())
88 return (GeoElement *)(el->GetElement());
89 else
90 {
91 el->Created(true);
92 GeoElement *g4el;
93 g4el=new GeoElement(el->GetName(),el->GetSymbol(),
94 double(el->GetZ()),el->GetA()*(GeoModelKernelUnits::gram/GeoModelKernelUnits::mole));
95 el->SetElement(g4el);
96 return g4el;
97 }
98 else
99 return nullptr;
100}

◆ CreateElements()

void AGDD2GeoModelBuilder::CreateElements ( )
overridevirtual

Implements AGDDBuilder.

Definition at line 188 of file AGDD2GeoModelBuilder.cxx.

189{
191 for (it=m_ms.ElementBegin();it!=m_ms.ElementEnd();++it)
192 {
193 CreateElement((*it).second->GetName());
194 }
195}
AGDDElementMap::const_iterator ElementIterator
GeoElement * CreateElement(const std::string &)

◆ CreateGvxy()

void AGDD2GeoModelBuilder::CreateGvxy ( AGDDGvxy * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 341 of file AGDD2GeoModelBuilder.cxx.

342{
343 void *p=v->GetSolid();
344 if (!p)
345 {
346 int nPoint=v->NrOfPoints();
347 GeoSimplePolygonBrep* solid;
348 solid = new GeoSimplePolygonBrep(v->GetDz()/2.);
349 double area=0;
350 v->SetPoint(v->GetPoint(0));
351 for (int i=0;i<nPoint;i++)
352 {
353 int iplus=i+1;
354 area+= v->GetPoint(i).x()*v->GetPoint(iplus).y()-v->GetPoint(iplus).x()*v->GetPoint(i).y();
355
356 }
357 bool clockwise=area<0?true:false;
358
359 TwoPoint pV;
360 for (int i=0;i<nPoint;i++)
361 {
362 if (clockwise) pV=v->GetPoint(nPoint-1-i);
363 else pV=v->GetPoint(i);
364 solid->addVertex(pV.x(),pV.y());
365 }
366 v->SetSolid(solid);
367 }
368}
double area(double R)
double x()
Definition TwoPoint.h:12
double y()
Definition TwoPoint.h:13

◆ CreateIbeam()

void AGDD2GeoModelBuilder::CreateIbeam ( AGDDIbeam * b) const
overridevirtual

Implements AGDDBuilder.

Definition at line 706 of file AGDD2GeoModelBuilder.cxx.

707{
708 void *p=b->GetSolid();
709 if (!p)
710 {
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);
725 b->SetSolid(solid);
726 }
727}

◆ CreateIntersection()

void AGDD2GeoModelBuilder::CreateIntersection ( AGDDIntersection * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 391 of file AGDD2GeoModelBuilder.cxx.

392{
393 int nPos=v->NrOfDaughter();
394 AGDDPositioner* pos=v->GetDaughter(0);
395 AGDDVolume *vol=pos->GetVolume();
396 vol->CreateSolid(*this);
397 GeoShape *sV=(GeoShape*)(vol->GetSolid());
398 sV=new GeoShapeShift(sV,pos->Transform());
399 for (int i=1;i<nPos;i++)
400 {
401 AGDDPositioner* pp=v->GetDaughter(i);
402 AGDDVolume *vv=pp->GetVolume();
403 vv->CreateSolid(*this);
404 GeoShape *nsV=(GeoShape*)(vv->GetSolid());
405 nsV=new GeoShapeShift(nsV,pp->Transform());
406 sV=new GeoShapeIntersection(sV,nsV);
407 }
408 v->SetMaterial(vol->GetMaterial());
409 v->SetSolid(sV);
410}
const GeoTrf::Transform3D & Transform() const
AGDDVolume * GetVolume()
virtual void CreateSolid(const AGDDBuilder &)
Definition AGDDVolume.h:25
const std::string & GetMaterial() const
Definition AGDDVolume.h:40
void * GetSolid()
Definition AGDDVolume.h:33

◆ CreateMaterial() [1/2]

void AGDD2GeoModelBuilder::CreateMaterial ( )
overridevirtual

Implements AGDDBuilder.

Definition at line 196 of file AGDD2GeoModelBuilder.cxx.

197{
199 for (it=m_ms.MaterialBegin();it!=m_ms.MaterialEnd();++it)
200 {
201 CreateMaterial((*it).second->GetName());
202 }
203}
AGDDMaterialMap::const_iterator MaterialIterator
virtual void CreateMaterial() override

◆ CreateMaterial() [2/2]

const GeoMaterial * AGDD2GeoModelBuilder::CreateMaterial ( const std::string & name)

Definition at line 101 of file AGDD2GeoModelBuilder.cxx.

102{
103
104// give priority to GeoModel's Material Manager in retrieving materials
105 const GeoMaterial* mmMaterial=GetMMMaterial(name);
106 if (mmMaterial)
107 {
108 return mmMaterial;
109 }
110
111 AGDDSimpleMaterial *mat=m_ms.GetMaterial(name);
112 if (mat)
113 if (mat->Extant())
114 return (GeoMaterial*)(mat->GetMaterial());
115 else
116 {
117 mat->Created(true);
118 material_type mtype=mat->GetMaterialType();
119 GeoMaterial *g4mat;
120 if (mtype==Material)
121 {
122 AGDDMaterial* nmat=dynamic_cast<AGDDMaterial*>(mat);
123 if (!nmat) {
124 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
125 log<<MSG::WARNING<<"CreateMaterial() - AGDDMaterial is nullptr"<<endmsg;
126 return nullptr;
127 }
128 g4mat=new GeoMaterial(nmat->GetName(),nmat->GetDensity()*(GeoModelKernelUnits::gram/GeoModelKernelUnits::cm3));
129 AGDDElement *el=m_ms.GetElement(nmat->GetName());
130 if (el)
131 {
132 if (!el->Extant()) CreateElement(el->GetName());
133 g4mat->add((GeoElement*)(el->GetElement()));
134 }
135 mat->SetMaterial(g4mat);
136 g4mat->lock();
137 return g4mat;
138 }
139 else if (mtype==Molecule)
140 {
141 AGDDMolecule* nmat=dynamic_cast<AGDDMolecule*>(mat);
142 if (!nmat) {
143 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
144 log<<MSG::WARNING<<"CreateMaterial() - AGDDMolecule is nullptr"<<endmsg;
145 return nullptr;
146 }
147 g4mat=new GeoMaterial(nmat->GetName(),nmat->GetDensity()*(GeoModelKernelUnits::gram/GeoModelKernelUnits::cm3));
148 for (int i=0;i<nmat->NComponents();i++)
149 {
150 AGDDElement *el=nmat->Element(i);
151 GeoElement* g4el=CreateElement(el->GetName());
152 g4mat->add(g4el,nmat->Composition(i));
153 }
154 mat->SetMaterial(g4mat);
155 g4mat->lock();
156 return g4mat;
157 }
158 else if (mtype==Mixture)
159 {
160 AGDDMixture* nmat=dynamic_cast<AGDDMixture*>(mat);
161 if (!nmat)
162 {
163 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
164 log<<MSG::WARNING<<"CreateMaterial() - AGDDMixture is nullptr"<<endmsg;
165 return nullptr;
166 }
167 g4mat=new GeoMaterial(nmat->GetName(),nmat->GetDensity()*(GeoModelKernelUnits::gram/GeoModelKernelUnits::cm3));
168 for (int i=0;i<nmat->NComponents();i++)
169 {
170 AGDDSimpleMaterial *el=nmat->Material(i);
171 const GeoMaterial* g4el=CreateMaterial(el->GetName());
172 g4mat->add(g4el,nmat->Composition(i));
173 }
174 mat->SetMaterial(g4mat);
175 g4mat->lock();
176 return g4mat;
177 }
178 else
179 {
180 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
181 log<<MSG::WARNING<<"CreateMaterial() - Unknown material type "<<mtype<<endmsg;
182 return nullptr;
183 }
184 }
185 else
186 return nullptr;
187}
material_type
@ Mixture
@ Molecule
@ Material
AGDDSimpleMaterial * Material(int i)
Definition AGDDMixture.h:23
double Composition(int i) const
Definition AGDDMixture.h:24
int NComponents() const
Definition AGDDMixture.h:22
AGDDElement * Element(int i)
int NComponents() const
int Composition(int i) const
double GetDensity() const
const std::string & GetName() const

◆ CreatePcon()

void AGDD2GeoModelBuilder::CreatePcon ( AGDDPcon * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 432 of file AGDD2GeoModelBuilder.cxx.

433{
434 void *p=v->GetSolid();
435 if (!p)
436 {
437 int nPlanes=v->NrOfPlanes();
438 GeoPcon* solid=new GeoPcon(v->Phi0()*GeoModelKernelUnits::degree,v->Dphi()*GeoModelKernelUnits::degree);
439 for (int i=0;i<nPlanes;i++)
440 {
441 double ri=v->Rin(i);
442 double ro=v->Rout(i);
443 double z=v->Z(i);
444 solid->addPlane(z,ri,ro);
445 }
446 v->SetSolid(solid);
447 }
448}
#define z

◆ CreatePgon()

void AGDD2GeoModelBuilder::CreatePgon ( AGDDPgon * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 450 of file AGDD2GeoModelBuilder.cxx.

451{
452 void *p=v->GetSolid();
453 if (!p)
454 {
455 int nPlanes=v->NrOfPlanes();
456 GeoPgon* solid=new GeoPgon(v->Phi0()*GeoModelKernelUnits::degree,v->Dphi()*GeoModelKernelUnits::degree,v->m_nbPhi);
457 for (int i=0;i<nPlanes;i++)
458 {
459 double ri=v->Rin(i);
460 double ro=v->Rout(i);
461 double z=v->Z(i);
462 solid->addPlane(z,ri,ro);
463 }
464 v->SetSolid(solid);
465 }
466}

◆ CreateSnake()

void AGDD2GeoModelBuilder::CreateSnake ( AGDDSnake * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 223 of file AGDD2GeoModelBuilder.cxx.

224{
225// here begins a nasty piece of code
226 static const GeoIntrusivePtr<const GeoBox> box1 = new GeoBox(1.*GeoModelKernelUnits::km,1*GeoModelKernelUnits::km,1*GeoModelKernelUnits::km);
227 static const GeoIntrusivePtr<const GeoShape> s1 = [&] {
228 GeoTrf::Vector3D v1(0,0,-1*GeoModelKernelUnits::km);
229 GeoTrf::Transform3D ttt1 = GeoTrf::Transform3D::Identity()*GeoTrf::Translation3D(v1);
230 return new GeoShapeShift (&*box1, ttt1);
231 }();
232 static const GeoIntrusivePtr<const GeoShape> s2 = [&] {
233 GeoTrf::Vector3D v2(0,0,+1*GeoModelKernelUnits::km);
234 GeoTrf::Transform3D ttt2 = GeoTrf::Transform3D::Identity()*GeoTrf::Translation3D(v2);
235 return new GeoShapeShift (&*box1, ttt2);
236 }();
237
238 double radius=v->Radius();
239 GeoTrf::Vector3D axis0(v->GetPoint(0)-v->GetPoint(1));
240 GeoTrf::Vector3D axis(v->GetPoint(1)-v->GetPoint(0));
241 GeoTrf::Vector3D axis1 = GeoTrf::Vector3D::Identity();
242 GeoTrf::Vector3D axis2(v->GetPoint(2)-v->GetPoint(1));
243 double length=axis.norm();
244 double angle1=0;
245 double angle2=std::abs(std::atan2(axis.cross(axis2).norm(), axis.dot(axis2)))/2;
246 double delta_l1=0;
247 double delta_l2=radius*std::tan(angle2);
248 double lengthnew=length+delta_l2;
249 GeoShape* solid=new GeoTubs(0.,radius,lengthnew/2.,0.,2.0*M_PI);
250
251 const GeoTrf::Vector3D vt(0.,0.,-lengthnew/2.+delta_l2+2.);
252 GeoTrf::Transform3D rrr = GeoTrf::RotateY3D(angle2)*GeoTrf::RotateZ3D(phi(axis2));
253 GeoShape *ssnew=new GeoShapeShift(&*s1,GeoTrf::Translation3D(vt)*rrr);
254
255 solid = new GeoShapeSubtraction(solid,ssnew);
256
257 GeoTrf::Vector3D vref(0.,0.,-lengthnew/2.);
258 GeoTrf::Transform3D tref = GeoTrf::Transform3D::Identity()*GeoTrf::Translation3D(vref);
259 solid=new GeoShapeShift(solid,tref);
260 GeoTrf::Transform3D r1 = GeoTrf::RotateZ3D(phi(axis0))*GeoTrf::RotateY3D(theta(axis0));
261 GeoTrf::Vector3D vtt(v->GetPoint(0).x(),v->GetPoint(0).y(),v->GetPoint(0).z());
262 solid=new GeoShapeShift(solid,GeoTrf::Translation3D(vtt)*r1);
263
264 for (int i=1;i<v->NrOfPoints()-1;i++)
265 {
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);
269
270 length=axis.norm();
271 angle1=std::abs(std::atan2(axis.cross(axis1).norm(), axis.dot(axis1)))/2;
272 delta_l1=radius*std::tan(angle1);
273 delta_l2=0;
274 if (i<(v->NrOfPoints()-2))
275 {
276 axis2=v->GetPoint(i+2)-v->GetPoint(i+1);
277 angle2=std::abs(std::atan2(axis.cross(axis2).norm(), axis.dot(axis2)))/2;
278 delta_l2=radius*std::tan(angle2);
279 }
280 length=axis.norm();
281 lengthnew=length+delta_l1+delta_l2;
282
283 GeoTrf::Vector3D vvref(0.,0.,-lengthnew/2+delta_l1);
284 GeoTrf::Transform3D ttref = GeoTrf::Transform3D::Identity()*GeoTrf::Translation3D(vvref);
285
286 GeoShape* ss=new GeoTubs(0.,radius,lengthnew/2.,0.,2.0*M_PI);
287
288 const GeoTrf::Vector3D vt1(0.,0.,+lengthnew/2.-delta_l1-2.);
289 const GeoTrf::Vector3D vt2(0.,0.,-lengthnew/2.+delta_l2+2.);
290 GeoTrf::Transform3D rrr1 = GeoTrf::RotateZ3D(-phi(axis1))*GeoTrf::RotateY3D(angle1);
291 GeoTrf::Transform3D rrr2 = GeoTrf::RotateZ3D(phi(axis2))*GeoTrf::RotateY3D(-angle2);
292 GeoTrf::Transform3D ttt1 = rrr1*GeoTrf::Translation3D(vt1);
293 GeoTrf::Transform3D ttt2 = rrr2*GeoTrf::Translation3D(vt2);
294 GeoShape *ssnew1=new GeoShapeShift(&*s2,ttt1);
295 ss = new GeoShapeSubtraction(ss,ssnew1);
296 if (i<(v->NrOfPoints()-2))
297 {
298 GeoShape *ssnew2=new GeoShapeShift(&*s1,ttt2);
299 ss = new GeoShapeSubtraction(ss,ssnew2);
300 }
301
302 ss=new GeoShapeShift(ss,ttref);
303
304 GeoTrf::Transform3D rr1 = GeoTrf::RotateZ3D(phi(axis0))*GeoTrf::RotateY3D(theta(axis0));
305 const GeoTrf::Vector3D vv(v->GetPoint(i).x(),v->GetPoint(i).y(),v->GetPoint(i).z());
306 ss=new GeoShapeShift(ss,GeoTrf::Translation3D(vv)*rr1);
307 solid=new GeoShapeUnion(solid,ss);
308 }
309 v->SetSolid(solid);
310}
Scalar phi() const
phi method
Scalar theta() const
theta method
double length(const pvec &v)

◆ CreateSubtraction()

void AGDD2GeoModelBuilder::CreateSubtraction ( AGDDSubtraction * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 411 of file AGDD2GeoModelBuilder.cxx.

412{
413 int nPos=v->NrOfDaughter();
414 AGDDPositioner* pos=v->GetDaughter(0);
415 AGDDVolume *vol=pos->GetVolume();
416 vol->CreateSolid(*this);
417 GeoShape *sV=(GeoShape*)(vol->GetSolid());
418 sV=new GeoShapeShift(sV,pos->Transform());
419 for (int i=1;i<nPos;i++)
420 {
421 AGDDPositioner* pp=v->GetDaughter(i);
422 AGDDVolume *vv=pp->GetVolume();
423 vv->CreateSolid(*this);
424 GeoShape *nsV=(GeoShape*)(vv->GetSolid());
425 nsV=new GeoShapeShift(nsV,pp->Transform());
426 sV=new GeoShapeSubtraction(sV,nsV);
427 }
428 v->SetMaterial(vol->GetMaterial());
429 v->SetSolid(sV);
430}

◆ CreateTrd()

void AGDD2GeoModelBuilder::CreateTrd ( AGDDTrd * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 213 of file AGDD2GeoModelBuilder.cxx.

214{
215 void *p=v->GetSolid();
216 if (!p)
217 {
218 GeoShape* solid=new GeoTrd(v->x1()/2.,v->x2()/2,v->y1()/2.,v->y2()/2.,v->z()/2.);
219 v->SetSolid(solid);
220 }
221}

◆ CreateTubs()

void AGDD2GeoModelBuilder::CreateTubs ( AGDDTubs * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 321 of file AGDD2GeoModelBuilder.cxx.

322{
323 void *p=v->GetSolid();
324 if (!p)
325 {
326 GeoShape* solid=new GeoTubs(v->rin(),v->rou(),v->z()/2.,v->phi0()*GeoModelKernelUnits::degree,v->dphi()*GeoModelKernelUnits::degree);
327 v->SetSolid(solid);
328 }
329}

◆ CreateUbeam()

void AGDD2GeoModelBuilder::CreateUbeam ( AGDDUbeam * b) const
overridevirtual

Implements AGDDBuilder.

Definition at line 729 of file AGDD2GeoModelBuilder.cxx.

730{
731 void *p=b->GetSolid();
732 if (!p)
733 {
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.);
744 b->SetSolid(solid);
745 }
746}

◆ CreateUnion()

void AGDD2GeoModelBuilder::CreateUnion ( AGDDUnion * v) const
overridevirtual

Implements AGDDBuilder.

Definition at line 370 of file AGDD2GeoModelBuilder.cxx.

371{
372 int nPos=v->NrOfDaughter();
373 AGDDPositioner* pos=v->GetDaughter(0);
374 AGDDVolume *vol=pos->GetVolume();
375 vol->CreateSolid(*this);
376 GeoShape *sV=(GeoShape*)(vol->GetSolid());
377 sV=new GeoShapeShift(sV,pos->Transform());
378 for (int i=1;i<nPos;i++)
379 {
380 AGDDPositioner* pp=v->GetDaughter(i);
381 AGDDVolume *vv=pp->GetVolume();
382 vv->CreateSolid(*this);
383 GeoShape *nsV=(GeoShape*)(vv->GetSolid());
384 nsV=new GeoShapeShift(nsV,pp->Transform());
385 sV=new GeoShapeUnion(sV,nsV);
386 }
387 v->SetMaterial(vol->GetMaterial());
388 v->SetColor(vol->GetColor());
389 v->SetSolid(sV);
390}
const std::string & GetColor() const
Definition AGDDVolume.h:39

◆ CreateVolume()

void AGDD2GeoModelBuilder::CreateVolume ( AGDDVolume * v)
overridevirtual

Implements AGDDBuilder.

Definition at line 538 of file AGDD2GeoModelBuilder.cxx.

539{
540 std::string alias = m_as.Alias(v->GetMaterial());
541 const GeoMaterial *mat=CreateMaterial(alias);
542
543 void* p=v->GetVolume();
544 if (!p)
545 {
546 GeoShape* sol=(GeoShape*)v->GetSolid();
547 if (!sol) {
548 MsgStream log(Athena::getMessageSvc(),"AGDD2GeoModelBuilder");
549 log<<MSG::WARNING<<"CreateVolume() - solid is nullptr!"<<endmsg;
550 }
551 else
552 {
553 GeoLogVol* lv=new GeoLogVol(v->GetName(),sol,mat);
554 GeoPhysVol *lv_phys=new GeoPhysVol(lv);
555
556 v->SetVolume(lv_phys);
557 }
558 }
559}

◆ GetMaterialManager()

StoredMaterialManager & AGDD2GeoModelBuilder::GetMaterialManager ( ) const
overridevirtual

Implements AGDDBuilder.

Definition at line 754 of file AGDD2GeoModelBuilder.cxx.

755{
756 static StoredMaterialManager* const matManager = []() {
757 ServiceHandle<StoreGateSvc> detStore ("DetectorStore", "AGDD2GeoModelBuilder");
758 StoredMaterialManager* mm = nullptr;
759 if (detStore->retrieve<StoredMaterialManager>(mm, "MATERIALS").isFailure()) {
760 std::abort();
761 }
762 return mm;
763 }();
764 return *matManager;
765}

◆ GetMMMaterial()

const GeoMaterial * AGDD2GeoModelBuilder::GetMMMaterial ( const std::string & name) const
private

Definition at line 748 of file AGDD2GeoModelBuilder.cxx.

749{
750 return GetMaterialManager().getMaterial(name);
751}
virtual StoredMaterialManager & GetMaterialManager() const override
virtual const GeoMaterial * getMaterial(const std::string &name)=0

◆ phi()

double AGDD2GeoModelBuilder::phi ( const GeoTrf::Vector3D & vec) const
inlineprivate

phi method (cf.

EventPrimitives/AmgMatrixBasePlugin.h)

Definition at line 95 of file AGDD2GeoModelBuilder.h.

95 {
96 if (vec.rows() < 2) return 0.;
97 return std::atan2(vec[1],vec[0]);
98 }
std::vector< size_t > vec

◆ SetMotherVolume()

virtual void AGDD2GeoModelBuilder::SetMotherVolume ( GeoPhysVol * v)
inlinevirtual

Definition at line 77 of file AGDD2GeoModelBuilder.h.

77{m_mother=v;}

◆ theta()

double AGDD2GeoModelBuilder::theta ( const GeoTrf::Vector3D & vec) const
inlineprivate

theta method (cf.

EventPrimitives/AmgMatrixBasePlugin.h)

Definition at line 100 of file AGDD2GeoModelBuilder.h.

100 {
101 if (vec.rows() < 3) return 0.;
102 return std::atan2(std::hypot(vec[0],vec[1]),vec[2]);
103 }

Member Data Documentation

◆ m_as

AliasStore& AGDD2GeoModelBuilder::m_as
private

Definition at line 89 of file AGDD2GeoModelBuilder.h.

◆ m_ds

AGDDDetectorStore& AGDD2GeoModelBuilder::m_ds
private

Definition at line 86 of file AGDD2GeoModelBuilder.h.

◆ m_mother

GeoPhysVol* AGDD2GeoModelBuilder::m_mother
private

Definition at line 85 of file AGDD2GeoModelBuilder.h.

◆ m_ms

AGDDMaterialStore& AGDD2GeoModelBuilder::m_ms
private

Definition at line 90 of file AGDD2GeoModelBuilder.h.

◆ m_ss

AGDDSectionStore& AGDD2GeoModelBuilder::m_ss
private

Definition at line 88 of file AGDD2GeoModelBuilder.h.

◆ m_vs

AGDDVolumeStore& AGDD2GeoModelBuilder::m_vs
private

Definition at line 87 of file AGDD2GeoModelBuilder.h.


The documentation for this class was generated from the following files: