ATLAS Offline Software
AGDD2GeoModelBuilder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
10 #include "AGDDKernel/TwoPoint.h"
13 #include "AGDDKernel/AGDDSection.h"
14 #include "AGDDKernel/AliasStore.h"
15 
16 #include "AGDDModel/AGDDBox.h"
17 #include "AGDDModel/AGDDTubs.h"
18 #include "AGDDModel/AGDDElcyl.h"
19 #include "AGDDModel/AGDDTrd.h"
20 #include "AGDDModel/AGDDCons.h"
21 #include "AGDDModel/AGDDPcon.h"
22 #include "AGDDModel/AGDDPgon.h"
24 #include "AGDDModel/AGDDColor.h"
25 #include "AGDDModel/AGDDGvxy.h"
26 #include "AGDDModel/AGDDSnake.h"
27 #include "AGDDModel/AGDDUnion.h"
32 #include "AGDDModel/AGDDMaterial.h"
33 #include "AGDDModel/AGDDMolecule.h"
34 #include "AGDDModel/AGDDMixture.h"
35 #include "AGDDModel/AGDDElement.h"
36 #include "AGDDModel/AGDDBolt.h"
37 #include "AGDDModel/AGDDIbeam.h"
38 #include "AGDDModel/AGDDUbeam.h"
39 
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"
55 
56 #include "StoreGate/StoreGateSvc.h"
57 #include "GaudiKernel/ISvcLocator.h"
58 #include "GaudiKernel/Bootstrap.h"
59 #include "GaudiKernel/MsgStream.h"
62 
63 #include <iostream>
64 #include <sstream>
65 #include <vector>
66 #include <cmath>
67 
69  AGDDVolumeStore& vs,
71  AliasStore& as,
73  AGDDBuilder(),
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 }
82 
83 GeoElement* AGDD2GeoModelBuilder::CreateElement(const std::string& name)
84 {
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 }
101 const GeoMaterial* AGDD2GeoModelBuilder::CreateMaterial(const std::string& name)
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 
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));
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  {
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 }
189 {
191  for (it=m_ms.ElementBegin();it!=m_ms.ElementEnd();++it)
192  {
193  CreateElement((*it).second->GetName());
194  }
195 }
197 {
199  for (it=m_ms.MaterialBegin();it!=m_ms.MaterialEnd();++it)
200  {
201  CreateMaterial((*it).second->GetName());
202  }
203 }
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 }
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 }
222 
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 = [&] {
229  GeoTrf::Transform3D ttt1 = GeoTrf::Transform3D::Identity()*GeoTrf::Translation3D(v1);
230  return new GeoShapeShift (&*box1, ttt1);
231  }();
232  static const GeoIntrusivePtr<const GeoShape> s2 = [&] {
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);
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 }
311 
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 }
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 }
330 
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 }
340 
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 }
369 
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 }
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 }
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 }
431 
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 }
449 
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 }
467 
468 
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;
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 }
537 
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 }
560 
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 }
593 
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 }
666 void AGDD2GeoModelBuilder::BuildFromVolume(const std::string& s)
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 }
690 
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 }
705 
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 }
728 
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 }
747 
748 const GeoMaterial* AGDD2GeoModelBuilder::GetMMMaterial(const std::string& name) const
749 {
751 }
752 
753 
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 }
AGDDComposition.h
AGDD2GeoModelBuilder::CreateBox
virtual void CreateBox(AGDDBox *) const override
Definition: AGDD2GeoModelBuilder.cxx:204
AGDDMolecule
Definition: AGDDMolecule.h:16
AGDDVolume::HasParent
bool HasParent() const
Definition: AGDDVolume.h:30
AGDDDetectorStore.h
ReadCellNoiseFromCoolCompare.s1
s1
Definition: ReadCellNoiseFromCoolCompare.py:378
checkxAOD.ds
ds
Definition: Tools/PyUtils/bin/checkxAOD.py:257
AliasStore
Definition: AliasStore.h:11
AGDD2GeoModelBuilder::CreateUbeam
virtual void CreateUbeam(AGDDUbeam *) const override
Definition: AGDD2GeoModelBuilder.cxx:729
AGDDPcon.h
Molecule
@ Molecule
Definition: MaterialTypes.h:8
AGDDMixture::Composition
double Composition(int i) const
Definition: AGDDMixture.h:24
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
AGDD2GeoModelBuilder::CreateElement
GeoElement * CreateElement(const std::string &)
Definition: AGDD2GeoModelBuilder.cxx:83
AGDDUnion.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
AliasStore::Alias
std::string Alias(const std::string &)
Definition: AliasStore.cxx:18
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
AGDD2GeoModelBuilder::CreateGvxy
virtual void CreateGvxy(AGDDGvxy *) const override
Definition: AGDD2GeoModelBuilder.cxx:341
AGDDComposition
Definition: AGDDComposition.h:13
AGDDVolume::GetSolid
void * GetSolid()
Definition: AGDDVolume.h:33
AGDD2GeoModelBuilder::CreatePcon
virtual void CreatePcon(AGDDPcon *) const override
Definition: AGDD2GeoModelBuilder.cxx:432
hist_file_dump.d
d
Definition: hist_file_dump.py:137
AGDD2GeoModelBuilder::CreateElcyl
virtual void CreateElcyl(AGDDElcyl *) const override
Definition: AGDD2GeoModelBuilder.cxx:331
AGDDTubs
Definition: AGDDTubs.h:13
AGDD2GeoModelBuilder::CreateUnion
virtual void CreateUnion(AGDDUnion *) const override
Definition: AGDD2GeoModelBuilder.cxx:370
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:53
AGDDVolumeStore
Definition: AGDDVolumeStore.h:15
AGDDDetectorPositioner
Definition: AGDDDetectorPositioner.h:39
AGDDIntersection.h
yodamerge_tmp.axis
list axis
Definition: yodamerge_tmp.py:241
AGDD2GeoModelBuilder::m_ms
AGDDMaterialStore & m_ms
Definition: AGDD2GeoModelBuilder.h:90
skel.it
it
Definition: skel.GENtoEVGEN.py:423
cm3
#define cm3
AGDDMolecule.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
AGDDVolumeStore.h
AGDDSectionStore.h
AGDDSection::VolumeEnd
volumeIterator VolumeEnd()
Definition: AGDDSection.h:38
ElementIterator
AGDDElementMap::const_iterator ElementIterator
Definition: AGDDMaterialStore.h:21
AGDD2GeoModelBuilder::phi
double phi(const GeoTrf::Vector3D &vec) const
phi method (cf.
Definition: AGDD2GeoModelBuilder.h:95
AGDD2GeoModelBuilder::GetMaterialManager
virtual StoredMaterialManager & GetMaterialManager() const override
Definition: AGDD2GeoModelBuilder.cxx:754
AGDDPositioner::Transform
const GeoTrf::Transform3D & Transform() const
Definition: AGDDPositioner.cxx:25
AGDDMaterialStore::GetMaterial
AGDDSimpleMaterial * GetMaterial(std::string)
Definition: AGDDMaterialStore.cxx:41
AGDDBolt
Definition: AGDDBolt.h:13
AGDDElcyl.h
AGDDPgon.h
AGDDMaterialStore::MaterialBegin
MaterialIterator MaterialBegin()
Definition: AGDDMaterialStore.h:34
AGDDVolume::GetVolume
void * GetVolume()
Definition: AGDDVolume.h:32
python.SystemOfUnits.gram
int gram
Definition: SystemOfUnits.py:165
AGDD2GeoModelBuilder::CreateSubtraction
virtual void CreateSubtraction(AGDDSubtraction *) const override
Definition: AGDD2GeoModelBuilder.cxx:411
AGDDMaterialStore.h
AGDDTubs.h
AGDD2GeoModelBuilder::CreateCons
virtual void CreateCons(AGDDCons *) const override
Definition: AGDD2GeoModelBuilder.cxx:312
AGDD2GeoModelBuilder::GetMMMaterial
const GeoMaterial * GetMMMaterial(const std::string &) const
Definition: AGDD2GeoModelBuilder.cxx:748
AGDDVolume::CreateVolume
virtual void CreateVolume(AGDDBuilder &)
Definition: AGDDVolume.h:26
TwoPoint
Definition: TwoPoint.h:8
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
AGDDSection::VolumeBegin
volumeIterator VolumeBegin()
Definition: AGDDSection.h:37
AGDDDetectorStore::GetDetector
AGDDDetector * GetDetector(const std::string &s)
Definition: AGDDDetectorStore.h:21
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AGDDSectionStore::GetSection
AGDDSection * GetSection(const std::string &)
Definition: AGDDSectionStore.cxx:13
AGDDPositioner
Definition: AGDDPositioner.h:18
AGDD2GeoModelBuilder::CreateTrd
virtual void CreateTrd(AGDDTrd *) const override
Definition: AGDD2GeoModelBuilder.cxx:213
AGDDUbeam.h
AGDD2GeoModelBuilder::CreateTubs
virtual void CreateTubs(AGDDTubs *) const override
Definition: AGDD2GeoModelBuilder.cxx:321
TwoPoint::y
double y()
Definition: TwoPoint.h:13
AGDDSectionStore
Definition: AGDDSectionStore.h:15
AGDDDetector
Definition: AGDDDetector.h:15
AGDDBuilder
Definition: AGDDBuilder.h:31
AliasStore.h
TwoPoint.h
AGDDVolumeStore::GetVolume
AGDDVolume * GetVolume(std::string)
Definition: AGDDVolumeStore.cxx:25
AGDD2GeoModelBuilder::AGDD2GeoModelBuilder
AGDD2GeoModelBuilder(AGDDDetectorStore &ds, AGDDVolumeStore &vs, AGDDSectionStore &ss, AliasStore &as, AGDDMaterialStore &ms)
Definition: AGDD2GeoModelBuilder.cxx:68
AGDDSection::TopVolume
void TopVolume(const std::string &n)
Definition: AGDDSection.h:30
AGDDCons
Definition: AGDDCons.h:13
AGDDMolecule::NComponents
int NComponents() const
Definition: AGDDMolecule.h:22
AGDDGvxy
Definition: AGDDGvxy.h:14
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
AGDDVolume::GetColor
const std::string & GetColor() const
Definition: AGDDVolume.h:39
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
AGDDSnake.h
AGDDMaterial
Definition: AGDDMaterial.h:15
AGDDIntersection
Definition: AGDDIntersection.h:13
AGDDVolume::IsSensitiveVolume
void IsSensitiveVolume(bool v)
Definition: AGDDVolume.cxx:27
COOLRates.alias
alias
Definition: COOLRates.py:1172
AGDDDetectorPositioner.h
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
AGDDSimpleMaterial::GetName
std::string GetName() const
Definition: AGDDSimpleMaterial.cxx:23
AGDD2GeoModelBuilder::CreatePgon
virtual void CreatePgon(AGDDPgon *) const override
Definition: AGDD2GeoModelBuilder.cxx:450
AGDD2GeoModelBuilder::m_as
AliasStore & m_as
Definition: AGDD2GeoModelBuilder.h:89
AGDD2GeoModelBuilder::BuildFromVolume
virtual void BuildFromVolume(const std::string &) override
Definition: AGDD2GeoModelBuilder.cxx:666
AGDDBox.h
AGDDGvxy.h
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
AGDDUnion
Definition: AGDDUnion.h:13
AGDDMaterialStore
Definition: AGDDMaterialStore.h:23
AGDDIbeam.h
AGDDCons.h
AGDDSubtraction
Definition: AGDDSubtraction.h:13
AGDD2GeoModelBuilder::CreateBolt
virtual void CreateBolt(AGDDBolt *) const override
Definition: AGDD2GeoModelBuilder.cxx:691
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
MaterialIterator
AGDDMaterialMap::const_iterator MaterialIterator
Definition: AGDDMaterialStore.h:20
AGDD2GeoModelBuilder::m_vs
AGDDVolumeStore & m_vs
Definition: AGDD2GeoModelBuilder.h:87
AGDD2GeoModelBuilder::BuildFromSection
virtual void BuildFromSection(const std::string &) override
Definition: AGDD2GeoModelBuilder.cxx:594
AGDDSimpleMaterial
Definition: AGDDSimpleMaterial.h:14
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
AGDDTrd.h
AGDDSimpleMaterial::GetDensity
double GetDensity() const
Definition: AGDDSimpleMaterial.h:27
AGDDVolume::CreateSolid
virtual void CreateSolid(const AGDDBuilder &)
Definition: AGDDVolume.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AGDDMaterialStore::MaterialEnd
MaterialIterator MaterialEnd()
Definition: AGDDMaterialStore.h:35
AGDDMixture.h
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
StoredMaterialManager.h
AGDDMaterialStore::ElementEnd
ElementIterator ElementEnd()
Definition: AGDDMaterialStore.h:37
AGDDSection
Definition: AGDDSection.h:17
AGDDMixture::NComponents
int NComponents() const
Definition: AGDDMixture.h:22
AGDDSection::IsToBeBuilt
bool IsToBeBuilt() const
Definition: AGDDSection.h:36
validateBDTTau.vt
vt
Definition: validateBDTTau.py:43
AGDDMaterial.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
AGDDElement.h
AGDDColor.h
AGDDDetectorStore
Definition: AGDDDetectorStore.h:18
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
AGDDElement
Definition: AGDDElement.h:11
TwoPoint::x
double x()
Definition: TwoPoint.h:12
AGDD2GeoModelBuilder::CreateIbeam
virtual void CreateIbeam(AGDDIbeam *) const override
Definition: AGDD2GeoModelBuilder.cxx:706
AGDDDetector.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
python.PyAthena.v
v
Definition: PyAthena.py:157
AGDD2GeoModelBuilder.h
AGDDMixture::Material
AGDDSimpleMaterial * Material(int i)
Definition: AGDDMixture.h:23
AGDD2GeoModelBuilder::m_ds
AGDDDetectorStore & m_ds
Definition: AGDD2GeoModelBuilder.h:86
AGDDMixture
Definition: AGDDMixture.h:16
a
TList * a
Definition: liststreamerinfos.cxx:10
Mixture
@ Mixture
Definition: MaterialTypes.h:8
AGDD2GeoModelBuilder::CreateVolume
virtual void CreateVolume(AGDDVolume *) override
Definition: AGDD2GeoModelBuilder.cxx:538
AGDD2GeoModelBuilder::CreateIntersection
virtual void CreateIntersection(AGDDIntersection *) const override
Definition: AGDD2GeoModelBuilder.cxx:391
AGDDBolt.h
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
StoredMaterialManager::getMaterial
virtual const GeoMaterial * getMaterial(const std::string &name)=0
AGDDVolume::GetName
const std::string & GetName() const
Definition: AGDDVolume.h:23
mole
#define mole
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
AGDD2GeoModelBuilder::CreateElements
virtual void CreateElements() override
Definition: AGDD2GeoModelBuilder.cxx:188
AGDDIbeam
Definition: AGDDIbeam.h:13
AGDDVolume
Definition: AGDDVolume.h:16
volumeIterator
volumeList::const_iterator volumeIterator
Definition: AGDDSection.h:15
material_type
material_type
Definition: MaterialTypes.h:8
AGDDSubtraction.h
AGDD2GeoModelBuilder::theta
double theta(const GeoTrf::Vector3D &vec) const
theta method (cf.
Definition: AGDD2GeoModelBuilder.h:100
AGDD2GeoModelBuilder::CreateMaterial
virtual void CreateMaterial() override
Definition: AGDD2GeoModelBuilder.cxx:196
AGDD2GeoModelBuilder::m_ss
AGDDSectionStore & m_ss
Definition: AGDD2GeoModelBuilder.h:88
CaloLCW_tf.trf
trf
Definition: CaloLCW_tf.py:20
area
double area(double R)
Definition: ConvertStaveServices.cxx:42
AGDDMaterialStore::GetElement
AGDDElement * GetElement(std::string)
Definition: AGDDMaterialStore.cxx:51
AGDDTrd
Definition: AGDDTrd.h:13
AGDDPcon
Definition: AGDDPcon.h:13
AGDDMaterialStore::ElementBegin
ElementIterator ElementBegin()
Definition: AGDDMaterialStore.h:36
AGDDSnake
Definition: AGDDSnake.h:14
AGDDPgon
Definition: AGDDPgon.h:13
AGDDBox
Definition: AGDDBox.h:13
PlotCalibFromCool.vv
vv
Definition: PlotCalibFromCool.py:716
AGDDPositioner::GetVolume
AGDDVolume * GetVolume()
Definition: AGDDPositioner.cxx:29
AGDDSection.h
Material
@ Material
Definition: MaterialTypes.h:8
StoreGateSvc.h
AGDDMolecule::Element
AGDDElement * Element(int i)
Definition: AGDDMolecule.h:23
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
python.SystemOfUnits.km
int km
Definition: SystemOfUnits.py:95
AGDDUbeam
Definition: AGDDUbeam.h:13
AGDDColorStore.h
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
AGDDMolecule::Composition
int Composition(int i) const
Definition: AGDDMolecule.h:24
AGDD2GeoModelBuilder::CreateSnake
virtual void CreateSnake(AGDDSnake *) const override
Definition: AGDD2GeoModelBuilder.cxx:223
AGDD2GeoModelBuilder::m_mother
GeoPhysVol * m_mother
Definition: AGDD2GeoModelBuilder.h:85
AGDDElcyl
Definition: AGDDElcyl.h:13
AGDD2GeoModelBuilder::BuildAllVolumes
virtual void BuildAllVolumes()
Definition: AGDD2GeoModelBuilder.cxx:561
ServiceHandle< StoreGateSvc >
AGDD2GeoModelBuilder::CreateComposition
virtual void CreateComposition(AGDDComposition *) override
Definition: AGDD2GeoModelBuilder.cxx:469
AGDDVolume::GetMaterial
const std::string & GetMaterial() const
Definition: AGDDVolume.h:40