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 &)
 
virtual ~TGeoMgrFromDdd ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()(false)
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer () noexcept(false)
 
- 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())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 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 48 of file TGeoMgrFromDdd.cc.

References edm::ESProducer::setWhatProduced().

49  : m_level( pset.getUntrackedParameter<int> ( "level", 10 )),
50  m_verbose( pset.getUntrackedParameter<bool>( "verbose", false ))
51 {
52  // The following line is needed to tell the framework what data is
53  // being produced.
54  setWhatProduced( this );
55 }
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  )
virtual

Definition at line 57 of file TGeoMgrFromDdd.cc.

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

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

Member Function Documentation

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

Definition at line 671 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().

672 {
673  std::string mat_name = iMaterial.name().fullname();
674  TGeoMaterial *mat = nameToMaterial_[mat_name];
675 
676  if (mat == 0)
677  {
678  if (iMaterial.noOfConstituents() > 0)
679  {
680  TGeoMixture *mix = new TGeoMixture(mat_name.c_str(),
681  iMaterial.noOfConstituents(),
682  iMaterial.density()*cm3/g);
683  for (int i = 0; i < iMaterial.noOfConstituents(); ++i)
684  {
685  mix->AddElement(createMaterial(iMaterial.constituent(i).first),
686  iMaterial.constituent(i).second);
687  }
688  mat = mix;
689  }
690  else
691  {
692  mat = new TGeoMaterial(mat_name.c_str(),
693  iMaterial.a()*mole/g, iMaterial.z(),
694  iMaterial.density()*cm3/g);
695  }
696  nameToMaterial_[mat_name] = mat;
697  }
698 
699  return mat;
700 }
double a() const
returns the atomic mass
Definition: DDMaterial.cc:97
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:103
const std::string fullname() const
Definition: DDName.h:53
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:91
std::map< std::string, TGeoMaterial * > nameToMaterial_
double density() const
returns the density
Definition: DDMaterial.cc:109
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:85
TGeoShape * TGeoMgrFromDdd::createShape ( const std::string &  iName,
const DDSolid iSolid 
)
private

Definition at line 222 of file TGeoMgrFromDdd.cc.

References funct::abs(), alpha, DDPseudoTrap::atMinusZ(), MessageLogger_cfi::cerr, popcon2dropbox::copy(), funct::cos(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), ddbox, ddcons, ddcuttubs, ddellipticaltube, ddintersection, ddpolycone_rrz, ddpolyhedra_rrz, ddpseudotrap, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, delta, MuonCkfTrajectoryBuilder_cfi::deltaPhi, DDTruncTubs::deltaPhi(), DDTorus::deltaPhi(), Exception, DDName::fullname(), DDPseudoTrap::halfZ(), LogDebug, DDRotation::matrix(), dataset::name, DDName::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, DDBooleanSolid::translation(), groupFilesInBlocks::tt, x, DDPseudoTrap::x1(), DDPseudoTrap::x2(), DDPseudoTrap::y1(), DDPseudoTrap::y2(), and DDTruncTubs::zHalf().

Referenced by createVolume().

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

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

Referenced by produce().

645 {
646  TGeoVolume* v=nameToVolume_[iName];
647  if (v == 0)
648  {
649  TGeoShape* solid = createShape(iSolid.name().fullname(),
650  iSolid);
651  std::string mat_name = iMaterial.name().fullname();
652  TGeoMedium *geo_med = nameToMedium_[mat_name];
653  if (geo_med == 0)
654  {
655  TGeoMaterial *geo_mat = createMaterial(iMaterial);
656  geo_med = new TGeoMedium(mat_name.c_str(), 0, geo_mat);
657  nameToMedium_[mat_name] = geo_med;
658  }
659  if (solid)
660  {
661  v = new TGeoVolume(iName.c_str(),
662  solid,
663  geo_med);
664  }
665  nameToVolume_[iName] = v;
666  }
667  return v;
668 }
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
const N & name() const
Definition: DDBase.h:78
const std::string fullname() const
Definition: DDName.h:53
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(), 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().

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