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

using ReturnType = std::unique_ptr< TGeoManager >
 
- 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 ()
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~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
 
std::string m_TGeoName
 
std::string m_TGeoTitle
 
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
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
- 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

using TGeoMgrFromDdd::ReturnType = std::unique_ptr<TGeoManager>

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 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
T getUntrackedParameter(std::string const &, T const &) const
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 696 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().

697 {
698  std::string mat_name = iMaterial.name().fullname();
699  TGeoMaterial *mat = nameToMaterial_[mat_name];
700 
701  if (mat == nullptr)
702  {
703  if (iMaterial.noOfConstituents() > 0)
704  {
705  TGeoMixture *mix = new TGeoMixture(mat_name.c_str(),
706  iMaterial.noOfConstituents(),
707  iMaterial.density()*cm3/g);
708  for (int i = 0; i < iMaterial.noOfConstituents(); ++i)
709  {
710  mix->AddElement(createMaterial(iMaterial.constituent(i).first),
711  iMaterial.constituent(i).second);
712  }
713  mat = mix;
714  }
715  else
716  {
717  mat = new TGeoMaterial(mat_name.c_str(),
718  iMaterial.a()*mole/g, iMaterial.z(),
719  iMaterial.density()*cm3/g);
720  }
721  nameToMaterial_[mat_name] = mat;
722  }
723 
724  return mat;
725 }
double a() const
returns the atomic mass
Definition: DDMaterial.cc:93
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
const N & name() const
Definition: DDBase.h:74
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:99
const std::string fullname() const
Definition: DDName.h:43
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:87
std::map< std::string, TGeoMaterial * > nameToMaterial_
double density() const
returns the density
Definition: DDMaterial.cc:104
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:82
TGeoShape * TGeoMgrFromDdd::createShape ( const std::string &  iName,
const DDSolid iSolid 
)
private

Definition at line 225 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(), h, 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().

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

Definition at line 667 of file TGeoMgrFromDdd.cc.

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

Referenced by produce().

670 {
671  TGeoVolume* v=nameToVolume_[iName];
672  if (v == nullptr)
673  {
674  TGeoShape* solid = createShape(iSolid.name().fullname(),
675  iSolid);
676  std::string mat_name = iMaterial.name().fullname();
677  TGeoMedium *geo_med = nameToMedium_[mat_name];
678  if (geo_med == nullptr)
679  {
680  TGeoMaterial *geo_mat = createMaterial(iMaterial);
681  geo_med = new TGeoMedium(mat_name.c_str(), 0, geo_mat);
682  nameToMedium_[mat_name] = geo_med;
683  }
684  if (solid)
685  {
686  v = new TGeoVolume(iName.c_str(),
687  solid,
688  geo_med);
689  }
690  nameToVolume_[iName] = v;
691  }
692  return v;
693 }
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
const N & name() const
Definition: DDBase.h:74
const std::string fullname() const
Definition: DDName.h:43
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 89 of file TGeoMgrFromDdd.cc.

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

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

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

Member Data Documentation

int TGeoMgrFromDdd::m_level
private

Definition at line 79 of file TGeoMgrFromDdd.h.

Referenced by produce().

std::string TGeoMgrFromDdd::m_TGeoName
private

Definition at line 81 of file TGeoMgrFromDdd.h.

std::string TGeoMgrFromDdd::m_TGeoTitle
private

Definition at line 82 of file TGeoMgrFromDdd.h.

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 86 of file TGeoMgrFromDdd.h.

Referenced by createMaterial(), and produce().

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

Definition at line 87 of file TGeoMgrFromDdd.h.

Referenced by createVolume(), and produce().

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

Definition at line 84 of file TGeoMgrFromDdd.h.

Referenced by createShape(), and produce().

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

Definition at line 85 of file TGeoMgrFromDdd.h.

Referenced by createVolume(), and produce().