CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 boost::shared_ptr
< TGeoManager > 
ReturnType
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair
< DataKey, boost::shared_ptr
< DataProxy > > > 
KeyedProxies
 
typedef std::vector
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 

Public Member Functions

ReturnType produce (const DisplayGeomRecord &)
 
 TGeoMgrFromDdd (const edm::ParameterSet &)
 
virtual ~TGeoMgrFromDdd ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- 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 ()
 

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::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_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 48 of file TGeoMgrFromDdd.h.

Member Typedef Documentation

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

Definition at line 54 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.

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 647 of file TGeoMgrFromDdd.cc.

References DDMaterial::a(), DDMaterial::constituent(), DDMaterial::density(), DDName::fullname(), g, i, reco_application_tbsim_DetSim-Digi_cfg::mix, DDBase< N, C >::name(), nameToMaterial_, DDMaterial::noOfConstituents(), and DDMaterial::z().

Referenced by createVolume().

648 {
649  std::string mat_name = iMaterial.name().fullname();
650  TGeoMaterial *mat = nameToMaterial_[mat_name];
651 
652  if (mat == 0)
653  {
654  if (iMaterial.noOfConstituents() > 0)
655  {
656  TGeoMixture *mix = new TGeoMixture(mat_name.c_str(),
657  iMaterial.noOfConstituents(),
658  iMaterial.density()*cm3/g);
659  for (int i = 0; i < iMaterial.noOfConstituents(); ++i)
660  {
661  mix->AddElement(createMaterial(iMaterial.constituent(i).first),
662  iMaterial.constituent(i).second);
663  }
664  mat = mix;
665  }
666  else
667  {
668  mat = new TGeoMaterial(mat_name.c_str(),
669  iMaterial.a()*mole/g, iMaterial.z(),
670  iMaterial.density()*cm3/g);
671  }
672  nameToMaterial_[mat_name] = mat;
673  }
674 
675  return mat;
676 }
double a() const
returns the atomic mass
Definition: DDMaterial.cc:97
int i
Definition: DBlmapReader.cc:9
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
const N & name() const
Definition: DDBase.h:82
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:56
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:89
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:83
TGeoShape * TGeoMgrFromDdd::createShape ( const std::string &  iName,
const DDSolid iSolid 
)
private

Definition at line 222 of file TGeoMgrFromDdd.cc.

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

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

Referenced by produce().

621 {
622  TGeoVolume* v=nameToVolume_[iName];
623  if (v == 0)
624  {
625  TGeoShape* solid = createShape(iSolid.name().fullname(),
626  iSolid);
627  std::string mat_name = iMaterial.name().fullname();
628  TGeoMedium *geo_med = nameToMedium_[mat_name];
629  if (geo_med == 0)
630  {
631  TGeoMaterial *geo_mat = createMaterial(iMaterial);
632  geo_med = new TGeoMedium(mat_name.c_str(), 0, geo_mat);
633  nameToMedium_[mat_name] = geo_med;
634  }
635  if (solid)
636  {
637  v = new TGeoVolume(iName.c_str(),
638  solid,
639  geo_med);
640  }
641  nameToVolume_[iName] = v;
642  }
643  return v;
644 }
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
const N & name() const
Definition: DDBase.h:82
const std::string fullname() const
Definition: DDName.h:56
TGeoShape * createShape(const std::string &iName, const DDSolid &iSolid)
std::map< std::string, TGeoVolume * > nameToVolume_
std::map< std::string, TGeoMedium * > nameToMedium_
mathSSE::Vec4< T > v
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(), i, info, 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 boost::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 boost::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 boost::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 boost::shared_ptr<TGeoManager>(geo_mgr);
214 }
int i
Definition: DBlmapReader.cc:9
graph< DDLogicalPart, DDPosData * >::value_type value_type
Definition: graphwalker.h:38
static const char * name(DDSolidShape s)
Definition: DDSolidShapes.h:21
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_
std::map< std::string, TGeoMedium * > nameToMedium_
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

int TGeoMgrFromDdd::m_level
private

Definition at line 80 of file TGeoMgrFromDdd.h.

Referenced by produce().

bool TGeoMgrFromDdd::m_verbose
private

Definition at line 81 of file TGeoMgrFromDdd.h.

Referenced by produce().

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

Definition at line 85 of file TGeoMgrFromDdd.h.

Referenced by createMaterial(), and produce().

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

Definition at line 86 of file TGeoMgrFromDdd.h.

Referenced by createVolume(), and produce().

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

Definition at line 83 of file TGeoMgrFromDdd.h.

Referenced by createShape(), and produce().

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

Definition at line 84 of file TGeoMgrFromDdd.h.

Referenced by createVolume(), and produce().