CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
TGeoMgrFromDdd Class Reference

#include <Fireworks/Geometry/interface/TGeoMgrFromDdd.h>

Inheritance diagram for TGeoMgrFromDdd:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

typedef std::shared_ptr< TGeoManager > ReturnType
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 

Public Member Functions

ReturnType produce (const DisplayGeomRecord &)
 
 TGeoMgrFromDdd (const edm::ParameterSet &)
 
 ~TGeoMgrFromDdd () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 

Private Member Functions

TGeoManager * createManager (int level)
 
TGeoMaterial * createMaterial (const DDMaterial &iMaterial)
 
TGeoShape * createShape (const std::string &iName, const DDSolid &iSolid)
 
TGeoVolume * createVolume (const std::string &iName, const DDSolid &iSolid, const DDMaterial &iMaterial)
 
const TGeoMgrFromDddoperator= (const TGeoMgrFromDdd &)
 
 TGeoMgrFromDdd (const TGeoMgrFromDdd &)
 

Private Attributes

int m_level
 
bool m_verbose
 
std::map< std::string, TGeoMaterial * > nameToMaterial_
 
std::map< std::string, TGeoMedium * > nameToMedium_
 
std::map< std::string, TGeoShape * > nameToShape_
 
std::map< std::string, TGeoVolume * > nameToVolume_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 

Detailed Description

Description: [one line class summary]

Usage: <usage>

Definition at line 47 of file TGeoMgrFromDdd.h.

Member Typedef Documentation

typedef std::shared_ptr<TGeoManager> TGeoMgrFromDdd::ReturnType

Definition at line 53 of file TGeoMgrFromDdd.h.

Constructor & Destructor Documentation

TGeoMgrFromDdd::TGeoMgrFromDdd ( const edm::ParameterSet pset)

Definition at line 49 of file TGeoMgrFromDdd.cc.

References edm::ESProducer::setWhatProduced().

50  : m_level( pset.getUntrackedParameter<int> ( "level", 10 )),
51  m_verbose( pset.getUntrackedParameter<bool>( "verbose", false ))
52 {
53  // The following line is needed to tell the framework what data is
54  // being produced.
55  setWhatProduced( this );
56 }
T getUntrackedParameter(std::string const &, T const &) const
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
TGeoMgrFromDdd::~TGeoMgrFromDdd ( void  )
override

Definition at line 58 of file TGeoMgrFromDdd.cc.

References allElectronIsolations_cfi::elements, alignCSCRings::r, and lumiQTWidget::t.

59 {}
TGeoMgrFromDdd::TGeoMgrFromDdd ( const TGeoMgrFromDdd )
private

Member Function Documentation

TGeoManager* TGeoMgrFromDdd::createManager ( int  level)
private
TGeoMaterial * TGeoMgrFromDdd::createMaterial ( const DDMaterial iMaterial)
private

Definition at line 694 of file TGeoMgrFromDdd.cc.

References DDMaterial::a(), DDMaterial::constituent(), DDMaterial::density(), DDName::fullname(), g, mps_fire::i, ecalTB2006H4_GenSimDigiReco_cfg::mix, DDBase< N, C >::name(), nameToMaterial_, DDMaterial::noOfConstituents(), AlCaHLTBitMon_QueryRunRegistry::string, and DDMaterial::z().

Referenced by createVolume().

695 {
696  std::string mat_name = iMaterial.name().fullname();
697  TGeoMaterial *mat = nameToMaterial_[mat_name];
698 
699  if (mat == nullptr)
700  {
701  if (iMaterial.noOfConstituents() > 0)
702  {
703  TGeoMixture *mix = new TGeoMixture(mat_name.c_str(),
704  iMaterial.noOfConstituents(),
705  iMaterial.density()*cm3/g);
706  for (int i = 0; i < iMaterial.noOfConstituents(); ++i)
707  {
708  mix->AddElement(createMaterial(iMaterial.constituent(i).first),
709  iMaterial.constituent(i).second);
710  }
711  mat = mix;
712  }
713  else
714  {
715  mat = new TGeoMaterial(mat_name.c_str(),
716  iMaterial.a()*mole/g, iMaterial.z(),
717  iMaterial.density()*cm3/g);
718  }
719  nameToMaterial_[mat_name] = mat;
720  }
721 
722  return mat;
723 }
double a() const
returns the atomic mass
Definition: DDMaterial.cc:96
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
const N & name() const
Definition: DDBase.h:78
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
double z() const
retruns the atomic number
Definition: DDMaterial.cc:102
const std::string fullname() const
Definition: DDName.h:52
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:90
std::map< std::string, TGeoMaterial * > nameToMaterial_
double density() const
returns the density
Definition: DDMaterial.cc:108
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:84
TGeoShape * TGeoMgrFromDdd::createShape ( const std::string &  iName,
const DDSolid iSolid 
)
private

Definition at line 223 of file TGeoMgrFromDdd.cc.

References funct::abs(), alpha, DDPseudoTrap::atMinusZ(), MessageLogger_cfi::cerr, popcon2dropbox::copy(), funct::cos(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), edmIntegrityCheck::d, ddbox, ddcons, ddcuttubs, ddellipticaltube, ddextrudedpolygon, ddintersection, ddpolycone_rrz, ddpolyhedra_rrz, ddpseudotrap, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, delta, hiPixelPairStep_cff::deltaPhi, DDTruncTubs::deltaPhi(), DDTorus::deltaPhi(), Exception, DDName::fullname(), DDPseudoTrap::halfZ(), mps_fire::i, LogDebug, DDRotation::matrix(), DDName::name(), dataset::name, DDBase< N, C >::name(), nameToShape_, EnergyCorrector::pt, dttmaxenums::R, alignCSCRings::r, DDPseudoTrap::radius(), DDTruncTubs::rIn(), DDTorus::rMax(), DDTorus::rMin(), makeMuonMisalignmentScenario::rot, DDBooleanSolid::rotation(), DDTruncTubs::rOut(), DDTorus::rTorus(), alignCSCRings::s, funct::sin(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), mathSSE::sqrt(), DDTruncTubs::startPhi(), DDTorus::startPhi(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, create_public_lumi_plots::transform, DDBooleanSolid::translation(), groupFilesInBlocks::tt, x, DDPseudoTrap::x1(), DDPseudoTrap::x2(), DDExtrudedPolygon::xVec(), y, DDPseudoTrap::y1(), DDPseudoTrap::y2(), DDExtrudedPolygon::yVec(), z, DDTruncTubs::zHalf(), DDExtrudedPolygon::zscaleVec(), DDExtrudedPolygon::zVec(), DDExtrudedPolygon::zxVec(), and DDExtrudedPolygon::zyVec().

Referenced by createVolume().

225 {
226  LogDebug("TGeoMgrFromDdd::createShape") << "with name: " << iName << " and solid: " << iSolid;
227 
228  DDBase<DDName, DDI::Solid*>::def_type defined( iSolid.isDefined());
229  if( !defined.first ) throw cms::Exception("TGeoMgrFromDdd::createShape * solid " + iName + " is not declared * " );
230  if( !defined.second ) throw cms::Exception("TGeoMgrFromDdd::createShape * solid " + defined.first->name() + " is not defined *" );
231 
232  TGeoShape* rSolid= nameToShape_[iName];
233  if (rSolid == nullptr)
234  {
235  const std::vector<double>& params = iSolid.parameters();
236  switch(iSolid.shape())
237  {
238  case ddbox:
239  rSolid = new TGeoBBox(
240  iName.c_str(),
241  params[0]/cm,
242  params[1]/cm,
243  params[2]/cm);
244  break;
245  case ddcons:
246  rSolid = new TGeoConeSeg(
247  iName.c_str(),
248  params[0]/cm,
249  params[1]/cm,
250  params[2]/cm,
251  params[3]/cm,
252  params[4]/cm,
253  params[5]/deg,
254  params[6]/deg+params[5]/deg
255  );
256  break;
257  case ddtubs:
258  //Order in params is zhalf,rIn,rOut,startPhi,deltaPhi
259  rSolid= new TGeoTubeSeg(
260  iName.c_str(),
261  params[1]/cm,
262  params[2]/cm,
263  params[0]/cm,
264  params[3]/deg,
265  params[3]/deg + params[4]/deg);
266  break;
267  case ddcuttubs:
268  //Order in params is zhalf,rIn,rOut,startPhi,deltaPhi,lx,ly,lz,tx,ty,tz
269  rSolid= new TGeoCtub(
270  iName.c_str(),
271  params[1]/cm,
272  params[2]/cm,
273  params[0]/cm,
274  params[3]/deg,
275  params[3]/deg + params[4]/deg,
276  params[5],params[6],params[7],
277  params[8],params[9],params[10]);
278  break;
279  case ddtrap:
280  rSolid =new TGeoTrap(
281  iName.c_str(),
282  params[0]/cm, //dz
283  params[1]/deg, //theta
284  params[2]/deg, //phi
285  params[3]/cm, //dy1
286  params[4]/cm, //dx1
287  params[5]/cm, //dx2
288  params[6]/deg, //alpha1
289  params[7]/cm, //dy2
290  params[8]/cm, //dx3
291  params[9]/cm, //dx4
292  params[10]/deg);//alpha2
293  break;
294  case ddpolycone_rrz:
295  rSolid = new TGeoPcon(
296  iName.c_str(),
297  params[0]/deg,
298  params[1]/deg,
299  (params.size()-2)/3) ;
300  {
301  std::vector<double> temp(params.size()+1);
302  temp.reserve(params.size()+1);
303  temp[0]=params[0]/deg;
304  temp[1]=params[1]/deg;
305  temp[2]=(params.size()-2)/3;
306  std::copy(params.begin()+2,params.end(),temp.begin()+3);
307  for(std::vector<double>::iterator it=temp.begin()+3;
308  it != temp.end();
309  ++it) {
310  *it /=cm;
311  }
312  rSolid->SetDimensions(&(*(temp.begin())));
313  }
314  break;
315  case ddpolyhedra_rrz:
316  rSolid = new TGeoPgon(
317  iName.c_str(),
318  params[1]/deg,
319  params[2]/deg,
320  static_cast<int>(params[0]),
321  (params.size()-3)/3);
322  {
323  std::vector<double> temp(params.size()+1);
324  temp[0]=params[1]/deg;
325  temp[1]=params[2]/deg;
326  temp[2]=params[0];
327  temp[3]=(params.size()-3)/3;
328  std::copy(params.begin()+3,params.end(),temp.begin()+4);
329  for(std::vector<double>::iterator it=temp.begin()+4;
330  it != temp.end();
331  ++it) {
332  *it /=cm;
333  }
334  rSolid->SetDimensions(&(*(temp.begin())));
335  }
336  break;
337  case ddextrudedpolygon:
338  {
339  DDExtrudedPolygon extrPgon(iSolid);
340  std::vector<double> x = extrPgon.xVec();
341  std::transform(x.begin(), x.end(), x.begin(),[](double d) { return d/cm; });
342  std::vector<double> y = extrPgon.yVec();
343  std::transform(y.begin(), y.end(), y.begin(),[](double d) { return d/cm; });
344  std::vector<double> z = extrPgon.zVec();
345  std::vector<double> zx = extrPgon.zxVec();
346  std::vector<double> zy = extrPgon.zyVec();
347  std::vector<double> zscale = extrPgon.zscaleVec();
348 
349  TGeoXtru* mySolid = new TGeoXtru(z.size());
350  mySolid->DefinePolygon(x.size(), &(*x.begin()), &(*y.begin()));
351  for( size_t i = 0; i < params[0]; ++i )
352  {
353  mySolid->DefineSection( i, z[i]/cm, zx[i]/cm, zy[i]/cm, zscale[i]);
354  }
355 
356  rSolid = mySolid;
357  }
358  break;
359  case ddpseudotrap:
360  {
361  //implementation taken from SimG4Core/Geometry/src/DDG4SolidConverter.cc
362  const static DDRotationMatrix s_rot( ROOT::Math::RotationX( 90.*deg ));
363  DDPseudoTrap pt( iSolid );
364 
365  double r = pt.radius();
366  bool atMinusZ = pt.atMinusZ();
367  double x = 0;
368  double h = 0;
369  bool intersec = false; // union or intersection solid
370 
371  if( atMinusZ )
372  {
373  x = pt.x1(); // tubs radius
374  }
375  else
376  {
377  x = pt.x2(); // tubs radius
378  }
379  double halfOpeningAngle = asin( x / std::abs( r ))/deg;
380  double displacement = 0;
381  double startPhi = 0;
382  /* calculate the displacement of the tubs w.r.t. to the trap,
383  determine the opening angle of the tubs */
384  double delta = sqrt( r * r - x * x );
385 
386  if( r < 0 && std::abs( r ) >= x )
387  {
388  intersec = true; // intersection solid
389  h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
390  h += h/20.; // enlarge a bit - for subtraction solid
391  if( atMinusZ )
392  {
393  displacement = - pt.halfZ() - delta;
394  startPhi = 90. - halfOpeningAngle;
395  }
396  else
397  {
398  displacement = pt.halfZ() + delta;
399  startPhi = -90.- halfOpeningAngle;
400  }
401  }
402  else if( r > 0 && std::abs( r ) >= x )
403  {
404  if( atMinusZ )
405  {
406  displacement = - pt.halfZ() + delta;
407  startPhi = 270.- halfOpeningAngle;
408  h = pt.y1();
409  }
410  else
411  {
412  displacement = pt.halfZ() - delta;
413  startPhi = 90. - halfOpeningAngle;
414  h = pt.y2();
415  }
416  }
417  else
418  {
419  throw cms::Exception( "Check parameters of the PseudoTrap! name=" + pt.name().name());
420  }
421 
422  std::auto_ptr<TGeoShape> trap( new TGeoTrd2( pt.name().name().c_str(),
423  pt.x1()/cm,
424  pt.x2()/cm,
425  pt.y1()/cm,
426  pt.y2()/cm,
427  pt.halfZ()/cm ));
428 
429  std::auto_ptr<TGeoShape> tubs( new TGeoTubeSeg( pt.name().name().c_str(),
430  0.,
431  std::abs(r)/cm, // radius cannot be negative!!!
432  h/cm,
433  startPhi,
434  startPhi + halfOpeningAngle * 2. ));
435  if( intersec )
436  {
437  TGeoSubtraction* sub = new TGeoSubtraction( trap.release(),
438  tubs.release(),
439  nullptr,
440  createPlacement( s_rot,
441  DDTranslation( 0.,
442  0.,
443  displacement )));
444  rSolid = new TGeoCompositeShape( iName.c_str(),
445  sub );
446  }
447  else
448  {
449  std::auto_ptr<TGeoShape> box( new TGeoBBox( 1.1*x/cm, 1.1*h/cm, sqrt(r*r-x*x)/cm ));
450 
451  TGeoSubtraction* sub = new TGeoSubtraction( tubs.release(),
452  box.release(),
453  nullptr,
454  createPlacement( s_rot,
455  DDTranslation( 0.,
456  0.,
457  0. )));
458 
459  std::auto_ptr<TGeoShape> tubicCap( new TGeoCompositeShape( iName.c_str(), sub ));
460 
461  TGeoUnion* boolS = new TGeoUnion( trap.release(),
462  tubicCap.release(),
463  nullptr,
464  createPlacement( s_rot,
465  DDTranslation( 0.,
466  0.,
467  displacement )));
468 
469  rSolid = new TGeoCompositeShape( iName.c_str(),
470  boolS );
471  }
472 
473  break;
474  }
475  case ddtorus:
476  {
477  DDTorus solid( iSolid );
478  rSolid = new TGeoTorus( iName.c_str(),
479  solid.rTorus()/cm,
480  solid.rMin()/cm,
481  solid.rMax()/cm,
482  solid.startPhi()/deg,
483  solid.deltaPhi()/deg);
484  break;
485  }
486  case ddsubtraction:
487  {
488  DDBooleanSolid boolSolid(iSolid);
489  if(!boolSolid) {
490  throw cms::Exception("GeomConvert") <<"conversion to DDBooleanSolid failed";
491  }
492 
493  std::auto_ptr<TGeoShape> left( createShape(boolSolid.solidA().name().fullname(),
494  boolSolid.solidA()) );
495  std::auto_ptr<TGeoShape> right( createShape(boolSolid.solidB().name().fullname(),
496  boolSolid.solidB()));
497  if( nullptr != left.get() &&
498  nullptr != right.get() ) {
499  TGeoSubtraction* sub = new TGeoSubtraction(left.release(),right.release(),
500  nullptr,
501  createPlacement(
502  *(boolSolid.rotation().matrix()),
503  boolSolid.translation()));
504  rSolid = new TGeoCompositeShape(iName.c_str(),
505  sub);
506  }
507  break;
508  }
509  case ddtrunctubs:
510  {
511  DDTruncTubs tt( iSolid );
512  if( !tt )
513  {
514  throw cms::Exception( "GeomConvert" ) << "conversion to DDTruncTubs failed";
515  }
516  double rIn( tt.rIn());
517  double rOut( tt.rOut());
518  double zHalf( tt.zHalf());
519  double startPhi( tt.startPhi());
520  double deltaPhi( tt.deltaPhi());
521  double cutAtStart( tt.cutAtStart());
522  double cutAtDelta( tt.cutAtDelta());
523  bool cutInside( bool( tt.cutInside()));
524  std::string name = tt.name().name();
525 
526  // check the parameters
527  if( rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0 )
528  {
529  std::string s = "TruncTubs " + std::string( tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
530  throw cms::Exception( s );
531  }
532  if( rIn >= rOut )
533  {
534  std::string s = "TruncTubs " + std::string( tt.name().fullname()) + ": rIn<rOut violated!";
535  throw cms::Exception(s);
536  }
537  if( startPhi != 0. )
538  {
539  std::string s= "TruncTubs " + std::string( tt.name().fullname()) + ": startPhi != 0 not supported!";
540  throw cms::Exception( s );
541  }
542 
543  startPhi = 0.;
544  double r( cutAtStart );
545  double R( cutAtDelta );
546 
547  // Note: startPhi is always 0.0
548  std::auto_ptr<TGeoShape> tubs( new TGeoTubeSeg( name.c_str(), rIn/cm, rOut/cm, zHalf/cm, startPhi, deltaPhi/deg ));
549 
550  double boxX( rOut ), boxY( rOut ); // exaggerate dimensions - does not matter, it's subtracted!
551 
552  // width of the box > width of the tubs
553  double boxZ( 1.1 * zHalf );
554 
555  // angle of the box w.r.t. tubs
556  double cath = r - R * cos( deltaPhi );
557  double hypo = sqrt( r * r + R * R - 2. * r * R * cos( deltaPhi ));
558  double cos_alpha = cath / hypo;
559  double alpha = -acos( cos_alpha );
560 
561  // rotationmatrix of box w.r.t. tubs
562  TGeoRotation rot;
563  rot.RotateX( 90 );
564  rot.RotateZ( alpha/deg );
565 
566  // center point of the box
567  double xBox;
568  if( !cutInside )
569  {
570  xBox = r + boxX / sin( fabs( alpha ));
571  }
572  else
573  {
574  xBox = - ( boxX / sin( fabs( alpha )) - r );
575  }
576  std::auto_ptr<TGeoShape> box( new TGeoBBox( name.c_str(), boxX/cm, boxZ/cm, boxY/cm ));
577 
578  TGeoTranslation trans( xBox/cm, 0., 0.);
579 
580  TGeoSubtraction* sub = new TGeoSubtraction( tubs.release(),
581  box.release(),
582  nullptr, new TGeoCombiTrans( trans, rot ));
583 
584  rSolid = new TGeoCompositeShape( iName.c_str(),
585  sub );
586  break;
587  }
588  case ddunion:
589  {
590  DDBooleanSolid boolSolid(iSolid);
591  if(!boolSolid) {
592  throw cms::Exception("GeomConvert") <<"conversion to DDBooleanSolid failed";
593  }
594 
595  std::auto_ptr<TGeoShape> left( createShape(boolSolid.solidA().name().fullname(),
596  boolSolid.solidA()) );
597  std::auto_ptr<TGeoShape> right( createShape(boolSolid.solidB().name().fullname(),
598  boolSolid.solidB()));
599  //DEBUGGING
600  //break;
601  if( nullptr != left.get() &&
602  nullptr != right.get() ) {
603  TGeoUnion* boolS = new TGeoUnion(left.release(),right.release(),
604  nullptr,
605  createPlacement(
606  *(boolSolid.rotation().matrix()),
607  boolSolid.translation()));
608  rSolid = new TGeoCompositeShape(iName.c_str(),
609  boolS);
610  }
611  break;
612  }
613  case ddintersection:
614  {
615  DDBooleanSolid boolSolid(iSolid);
616  if(!boolSolid) {
617  throw cms::Exception("GeomConvert") <<"conversion to DDBooleanSolid failed";
618  }
619 
620  std::auto_ptr<TGeoShape> left( createShape(boolSolid.solidA().name().fullname(),
621  boolSolid.solidA()) );
622  std::auto_ptr<TGeoShape> right( createShape(boolSolid.solidB().name().fullname(),
623  boolSolid.solidB()));
624  if( nullptr != left.get() &&
625  nullptr != right.get() ) {
626  TGeoIntersection* boolS = new TGeoIntersection(left.release(),
627  right.release(),
628  nullptr,
629  createPlacement(
630  *(boolSolid.rotation().matrix()),
631  boolSolid.translation()));
632  rSolid = new TGeoCompositeShape(iName.c_str(),
633  boolS);
634  }
635  break;
636  }
637  case ddellipticaltube:
638  {
639  DDEllipticalTube eSolid(iSolid);
640  if(!eSolid) {
641  throw cms::Exception("GeomConvert") <<"conversion to DDEllipticalTube failed";
642  }
643  rSolid = new TGeoEltu(iName.c_str(),
644  params[0]/cm,
645  params[1]/cm,
646  params[2]/cm);
647  break;
648  }
649  default:
650  break;
651  }
652  nameToShape_[iName]=rSolid;
653  }
654  if (rSolid == nullptr)
655  {
656  std::cerr <<"COULD NOT MAKE "<<iName<<" of a shape "<<iSolid<<std::endl;
657  }
658 
659  LogDebug("TGeoMgrFromDdd::createShape") << "solid " << iName << " has been created.";
660 
661  return rSolid;
662 }
#define LogDebug(id)
dbl * delta
Definition: mlp_gen.cc:36
Definition: DDBase.h:10
float alpha
Definition: AMPTWrapper.h:95
A truncated tube section.
Definition: DDSolid.h:134
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::map< std::string, TGeoShape * > nameToShape_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TGeoShape * createShape(const std::string &iName, const DDSolid &iSolid)
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
TGeoVolume * TGeoMgrFromDdd::createVolume ( const std::string &  iName,
const DDSolid iSolid,
const DDMaterial iMaterial 
)
private

Definition at line 665 of file TGeoMgrFromDdd.cc.

References createMaterial(), createShape(), DDName::fullname(), DDBase< N, C >::name(), nameToMedium_, nameToVolume_, AlCaHLTBitMon_QueryRunRegistry::string, and findQualityFiles::v.

Referenced by produce().

668 {
669  TGeoVolume* v=nameToVolume_[iName];
670  if (v == nullptr)
671  {
672  TGeoShape* solid = createShape(iSolid.name().fullname(),
673  iSolid);
674  std::string mat_name = iMaterial.name().fullname();
675  TGeoMedium *geo_med = nameToMedium_[mat_name];
676  if (geo_med == nullptr)
677  {
678  TGeoMaterial *geo_mat = createMaterial(iMaterial);
679  geo_med = new TGeoMedium(mat_name.c_str(), 0, geo_mat);
680  nameToMedium_[mat_name] = geo_med;
681  }
682  if (solid)
683  {
684  v = new TGeoVolume(iName.c_str(),
685  solid,
686  geo_med);
687  }
688  nameToVolume_[iName] = v;
689  }
690  return v;
691 }
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
const N & name() const
Definition: DDBase.h:78
const std::string fullname() const
Definition: DDName.h:52
TGeoShape * createShape(const std::string &iName, const DDSolid &iSolid)
std::map< std::string, TGeoVolume * > nameToVolume_
std::map< std::string, TGeoMedium * > nameToMedium_
const TGeoMgrFromDdd& TGeoMgrFromDdd::operator= ( const TGeoMgrFromDdd )
private
TGeoMgrFromDdd::ReturnType TGeoMgrFromDdd::produce ( const DisplayGeomRecord iRecord)

Definition at line 90 of file TGeoMgrFromDdd.cc.

References gather_cfg::cout, createVolume(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), DDCompactView::graph(), mps_fire::i, info(), edm::ESHandleBase::isValid(), m_level, m_verbose, DDSolidShapesName::name(), nameToMaterial_, nameToMedium_, nameToShape_, and nameToVolume_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

91 {
92  using namespace edm;
93 
95  iRecord.getRecord<IdealGeometryRecord>().get(viewH);
96 
97  if ( ! viewH.isValid()) {
98  return std::shared_ptr<TGeoManager>();
99  }
100 
101  TGeoManager *geo_mgr = new TGeoManager("cmsGeo","CMS Detector");
102  // NOTE: the default constructor does not create the identity matrix
103  if (gGeoIdentity == nullptr)
104  {
105  gGeoIdentity = new TGeoIdentity("Identity");
106  }
107 
108  std::cout << "about to initialize the DDCompactView walker" << std::endl;
109  DDCompactView::walker_type walker(viewH->graph());
110  DDCompactView::walker_type::value_type info = walker.current();
111 
112  // The top most item is actually the volume holding both the
113  // geometry AND the magnetic field volumes!
114  walker.firstChild();
115  if( ! walker.firstChild()) {
116  return std::shared_ptr<TGeoManager>();
117  }
118 
119  TGeoVolume *top = createVolume(info.first.name().fullname(),
120  info.first.solid(),
121  info.first.material());
122  if (top == nullptr) {
123  return std::shared_ptr<TGeoManager>();
124  }
125 
126  geo_mgr->SetTopVolume(top);
127  // ROOT chokes unless colors are assigned
128  top->SetVisibility(kFALSE);
129  top->SetLineColor(kBlue);
130 
131  std::vector<TGeoVolume*> parentStack;
132  parentStack.push_back(top);
133 
134  do
135  {
136  DDCompactView::walker_type::value_type info = walker.current();
137 
138  if (m_verbose)
139  {
140  for(unsigned int i=0; i<parentStack.size();++i) {
141  std::cout <<" ";
142  }
143  std::cout << info.first.name()<<" "<<info.second->copyno()<<" "
144  << DDSolidShapesName::name(info.first.solid().shape())<<std::endl;
145  }
146 
147  bool childAlreadyExists = (nullptr != nameToVolume_[info.first.name().fullname()]);
148  TGeoVolume *child = createVolume(info.first.name().fullname(),
149  info.first.solid(),
150  info.first.material());
151  if (nullptr!=child && info.second != nullptr)
152  {
153  parentStack.back()->AddNode(child,
154  info.second->copyno(),
155  createPlacement(info.second->rotation(),
156  info.second->translation()));
157  child->SetLineColor(kBlue);
158  }
159  else
160  {
161  if ( info.second == nullptr ) {
162  break;
163  }
164  }
165  if (nullptr == child || childAlreadyExists || m_level == int(parentStack.size()))
166  {
167  if (nullptr!=child)
168  {
169  child->SetLineColor(kRed);
170  }
171  //stop descending
172  if ( ! walker.nextSibling())
173  {
174  while (walker.parent())
175  {
176  parentStack.pop_back();
177  if (walker.nextSibling()) {
178  break;
179  }
180  }
181  }
182  }
183  else
184  {
185  if (walker.firstChild())
186  {
187  parentStack.push_back(child);
188  }
189  else
190  {
191  if ( ! walker.nextSibling())
192  {
193  while (walker.parent())
194  {
195  parentStack.pop_back();
196  if (walker.nextSibling()) {
197  break;
198  }
199  }
200  }
201  }
202  }
203  } while ( ! parentStack.empty());
204 
205  geo_mgr->CloseGeometry();
206 
207  geo_mgr->DefaultColors();
208 
209  nameToShape_.clear();
210  nameToVolume_.clear();
211  nameToMaterial_.clear();
212  nameToMedium_.clear();
213 
214  return std::shared_ptr<TGeoManager>(geo_mgr);
215 }
static const TGPicture * info(bool iBackgroundIsBlack)
typename math::Graph< DDLogicalPart, DDPosData * >::value_type value_type
Definition: GraphWalker.h:29
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:22
TGeoVolume * createVolume(const std::string &iName, const DDSolid &iSolid, const DDMaterial &iMaterial)
std::map< std::string, TGeoShape * > nameToShape_
std::map< std::string, TGeoMaterial * > nameToMaterial_
std::map< std::string, TGeoVolume * > nameToVolume_
HLT enums.
std::map< std::string, TGeoMedium * > nameToMedium_
bool isValid() const
Definition: ESHandle.h:47

Member Data Documentation

int TGeoMgrFromDdd::m_level
private

Definition at line 79 of file TGeoMgrFromDdd.h.

Referenced by produce().

bool TGeoMgrFromDdd::m_verbose
private

Definition at line 80 of file TGeoMgrFromDdd.h.

Referenced by produce().

std::map<std::string, TGeoMaterial*> TGeoMgrFromDdd::nameToMaterial_
private

Definition at line 84 of file TGeoMgrFromDdd.h.

Referenced by createMaterial(), and produce().

std::map<std::string, TGeoMedium*> TGeoMgrFromDdd::nameToMedium_
private

Definition at line 85 of file TGeoMgrFromDdd.h.

Referenced by createVolume(), and produce().

std::map<std::string, TGeoShape*> TGeoMgrFromDdd::nameToShape_
private

Definition at line 82 of file TGeoMgrFromDdd.h.

Referenced by createShape(), and produce().

std::map<std::string, TGeoVolume*> TGeoMgrFromDdd::nameToVolume_
private

Definition at line 83 of file TGeoMgrFromDdd.h.

Referenced by createVolume(), and produce().