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

Member Typedef Documentation

typedef boost::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 47 of file TGeoMgrFromDdd.cc.

References edm::ESProducer::setWhatProduced().

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

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

Member Function Documentation

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

Definition at line 646 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(), AlCaHLTBitMon_QueryRunRegistry::string, and DDMaterial::z().

Referenced by createVolume().

647 {
648  std::string mat_name = iMaterial.name().fullname();
649  TGeoMaterial *mat = nameToMaterial_[mat_name];
650 
651  if (mat == 0)
652  {
653  if (iMaterial.noOfConstituents() > 0)
654  {
655  TGeoMixture *mix = new TGeoMixture(mat_name.c_str(),
656  iMaterial.noOfConstituents(),
657  iMaterial.density()*cm3/g);
658  for (int i = 0; i < iMaterial.noOfConstituents(); ++i)
659  {
660  mix->AddElement(createMaterial(iMaterial.constituent(i).first),
661  iMaterial.constituent(i).second);
662  }
663  mat = mix;
664  }
665  else
666  {
667  mat = new TGeoMaterial(mat_name.c_str(),
668  iMaterial.a()*mole/g, iMaterial.z(),
669  iMaterial.density()*cm3/g);
670  }
671  nameToMaterial_[mat_name] = mat;
672  }
673 
674  return mat;
675 }
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: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: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 221 of file TGeoMgrFromDdd.cc.

References funct::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_, 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().

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

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

Referenced by produce().

620 {
621  TGeoVolume* v=nameToVolume_[iName];
622  if (v == 0)
623  {
624  TGeoShape* solid = createShape(iSolid.name().fullname(),
625  iSolid);
626  std::string mat_name = iMaterial.name().fullname();
627  TGeoMedium *geo_med = nameToMedium_[mat_name];
628  if (geo_med == 0)
629  {
630  TGeoMaterial *geo_mat = createMaterial(iMaterial);
631  geo_med = new TGeoMedium(mat_name.c_str(), 0, geo_mat);
632  nameToMedium_[mat_name] = geo_med;
633  }
634  if (solid)
635  {
636  v = new TGeoVolume(iName.c_str(),
637  solid,
638  geo_med);
639  }
640  nameToVolume_[iName] = v;
641  }
642  return v;
643 }
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
const N & name() const
Definition: DDBase.h:78
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_
const TGeoMgrFromDdd& TGeoMgrFromDdd::operator= ( const TGeoMgrFromDdd )
private
TGeoMgrFromDdd::ReturnType TGeoMgrFromDdd::produce ( const DisplayGeomRecord iRecord)

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

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

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().