CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
TGeoMgrFromDdd Class Reference
Inheritance diagram for TGeoMgrFromDdd:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

using ReturnType = std::unique_ptr< TGeoManager >
 

Public Member Functions

const TGeoMgrFromDddoperator= (const TGeoMgrFromDdd &)=delete
 
ReturnType produce (const DisplayGeomRecord &)
 
 TGeoMgrFromDdd (const edm::ParameterSet &)
 
 TGeoMgrFromDdd (const TGeoMgrFromDdd &)=delete
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESProxyIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

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)
 

Private Attributes

const bool m_fullname
 
const int m_level
 
std::string m_TGeoName
 
std::string m_TGeoTitle
 
const 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_
 
const edm::ESGetToken< DDCompactView, IdealGeometryRecordviewToken_
 

Additional Inherited Members

- Protected Types inherited from edm::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &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={})
 
void usesResources (std::vector< std::string > const &)
 
- 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 EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 

Detailed Description

Definition at line 49 of file TGeoMgrFromDdd.cc.

Member Typedef Documentation

◆ ReturnType

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

Definition at line 55 of file TGeoMgrFromDdd.cc.

Constructor & Destructor Documentation

◆ TGeoMgrFromDdd() [1/2]

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

Definition at line 90 of file TGeoMgrFromDdd.cc.

91  : m_level(pset.getUntrackedParameter<int>("level")),
92  m_verbose(pset.getUntrackedParameter<bool>("verbose")),
93  m_fullname(pset.getUntrackedParameter<bool>("fullName")),
94  viewToken_(setWhatProduced(this).consumes()) {}

◆ TGeoMgrFromDdd() [2/2]

TGeoMgrFromDdd::TGeoMgrFromDdd ( const TGeoMgrFromDdd )
delete

Member Function Documentation

◆ createManager()

TGeoManager* TGeoMgrFromDdd::createManager ( int  level)
private

◆ createMaterial()

TGeoMaterial * TGeoMgrFromDdd::createMaterial ( const DDMaterial iMaterial)
private

Definition at line 612 of file TGeoMgrFromDdd.cc.

612  {
613  std::string mat_name = m_fullname ? iMaterial.name().fullname() : iMaterial.name().name();
614  TGeoMaterial* mat = nameToMaterial_[mat_name];
615 
616  if (mat == nullptr) {
617  if (iMaterial.noOfConstituents() > 0) {
618  TGeoMixture* mix = new TGeoMixture(mat_name.c_str(), iMaterial.noOfConstituents(), iMaterial.density() * cm3 / g);
619  for (int i = 0; i < iMaterial.noOfConstituents(); ++i) {
620  mix->AddElement(createMaterial(iMaterial.constituent(i).first), iMaterial.constituent(i).second);
621  }
622  mat = mix;
623  } else {
624  mat = new TGeoMaterial(mat_name.c_str(), iMaterial.a() * mole / g, iMaterial.z(), iMaterial.density() * cm3 / g);
625  }
626  nameToMaterial_[mat_name] = mat;
627  }
628 
629  return mat;
630 }

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

Referenced by createVolume().

◆ createShape()

TGeoShape * TGeoMgrFromDdd::createShape ( const std::string &  iName,
const DDSolid iSolid 
)
private

Definition at line 237 of file TGeoMgrFromDdd.cc.

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

References funct::abs(), zMuMuMuonUserData::alpha, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, filterCSVwithJSON::copy, funct::cos(), dd4hep::createPlacement(), ztail::d, ddbox, ddcons, ddcuttubs, ddellipticaltube, ddextrudedpolygon, ddintersection, ddpolycone_rrz, ddpolyhedra_rrz, ddpseudotrap, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, dumpMFGeometry_cfg::delta, SiPixelRawToDigiRegional_cfi::deltaPhi, DDTorus::deltaPhi(), Exception, DDName::fullname(), mps_fire::i, LogDebug, m_fullname, DDRotation::matrix(), Skims_PA_cff::name, DDName::name(), DDBase< N, C >::name(), nameToShape_, CalibrationSummaryClient_cfi::params, DiDispStaMuonMonitor_cfi::pt, dttmaxenums::R, alignCSCRings::r, DDTorus::rMax(), DDTorus::rMin(), makeMuonMisalignmentScenario::rot, DDBooleanSolid::rotation(), DDTorus::rTorus(), alignCSCRings::s, funct::sin(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), mathSSE::sqrt(), DDTorus::startPhi(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, HcalDetIdTransform::transform(), DDBooleanSolid::translation(), groupFilesInBlocks::tt, x, DDExtrudedPolygon::xVec(), y, DDExtrudedPolygon::yVec(), z, DDExtrudedPolygon::zscaleVec(), DDExtrudedPolygon::zVec(), DDExtrudedPolygon::zxVec(), and DDExtrudedPolygon::zyVec().

Referenced by createVolume().

◆ createVolume()

TGeoVolume * TGeoMgrFromDdd::createVolume ( const std::string &  iName,
const DDSolid iSolid,
const DDMaterial iMaterial 
)
private

Definition at line 592 of file TGeoMgrFromDdd.cc.

592  {
593  TGeoVolume* v = nameToVolume_[iName];
594  if (v == nullptr) {
595  TGeoShape* solid =
596  m_fullname ? createShape(iSolid.name().fullname(), iSolid) : createShape(iSolid.name().name(), iSolid);
597  std::string mat_name = m_fullname ? iMaterial.name().fullname() : iMaterial.name().name();
598  TGeoMedium* geo_med = nameToMedium_[mat_name];
599  if (geo_med == nullptr) {
600  TGeoMaterial* geo_mat = createMaterial(iMaterial);
601  geo_med = new TGeoMedium(mat_name.c_str(), 0, geo_mat);
602  nameToMedium_[mat_name] = geo_med;
603  }
604  if (solid) {
605  v = new TGeoVolume(iName.c_str(), solid, geo_med);
606  }
607  nameToVolume_[iName] = v;
608  }
609  return v;
610 }

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

Referenced by produce().

◆ fillDescriptions()

void TGeoMgrFromDdd::fillDescriptions ( edm::ConfigurationDescriptions conf)
static

Definition at line 96 of file TGeoMgrFromDdd.cc.

96  {
98  desc.addUntracked<int>("level", 10)->setComment("How deep into the geometry hierarchy should the conversion go.");
99  desc.addUntracked<bool>("verbose", false);
100  desc.addUntracked<bool>("fullName", true)->setComment("use fillname() instead of name() when generating node names");
101 
102  conf.add("TGeoMgrFromDdd", desc);
103 }

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

◆ operator=()

const TGeoMgrFromDdd& TGeoMgrFromDdd::operator= ( const TGeoMgrFromDdd )
delete

◆ produce()

TGeoMgrFromDdd::ReturnType TGeoMgrFromDdd::produce ( const DisplayGeomRecord iRecord)

Definition at line 126 of file TGeoMgrFromDdd.cc.

126  {
127  using namespace edm;
128 
130 
131  if (!viewH.isValid()) {
132  return std::unique_ptr<TGeoManager>();
133  }
134 
135  TGeoManager* geo_mgr = new TGeoManager("cmsGeo", "CMS Detector");
136  // NOTE: the default constructor does not create the identity matrix
137  if (gGeoIdentity == nullptr) {
138  gGeoIdentity = new TGeoIdentity("Identity");
139  }
140 
141  std::cout << "about to initialize the DDCompactView walker"
142  << " with a root node " << viewH->root() << std::endl;
143 
144  auto walker = viewH->walker();
145  auto info = walker.current();
146 
147  // The top most item is actually the volume holding both the
148  // geometry AND the magnetic field volumes!
149  walker.firstChild();
150  if (!walker.firstChild()) {
151  return std::unique_ptr<TGeoManager>();
152  }
153 
154  TGeoVolume* top = (m_fullname ? createVolume(info.first.name().fullname(), info.first.solid(), info.first.material())
155  : createVolume(info.first.name().name(), info.first.solid(), info.first.material()));
156 
157  if (top == nullptr) {
158  return std::unique_ptr<TGeoManager>();
159  }
160 
161  geo_mgr->SetTopVolume(top);
162  // ROOT chokes unless colors are assigned
163  top->SetVisibility(kFALSE);
164  top->SetLineColor(kBlue);
165 
166  std::vector<TGeoVolume*> parentStack;
167  parentStack.push_back(top);
168 
169  do {
170  auto info = walker.current();
171 
172  if (m_verbose) {
173  for (unsigned int i = 0; i < parentStack.size(); ++i) {
174  std::cout << " ";
175  }
176  std::cout << info.first.name() << " " << info.second->copyno() << " "
177  << DDSolidShapesName::name(info.first.solid().shape()) << std::endl;
178  }
179 
180  std::string name = m_fullname ? info.first.name().fullname() : info.first.name().name();
181  bool childAlreadyExists = (nullptr != nameToVolume_[name]);
182  TGeoVolume* child = createVolume(name, info.first.solid(), info.first.material());
183  if (nullptr != child && info.second != nullptr) {
184  parentStack.back()->AddNode(
185  child, info.second->copyno(), createPlacement(info.second->rotation(), info.second->translation()));
186  child->SetLineColor(kBlue);
187  } else {
188  if (info.second == nullptr) {
189  break;
190  }
191  }
192  if (nullptr == child || childAlreadyExists || m_level == int(parentStack.size())) {
193  if (nullptr != child) {
194  child->SetLineColor(kRed);
195  }
196  //stop descending
197  if (!walker.nextSibling()) {
198  while (walker.parent()) {
199  parentStack.pop_back();
200  if (walker.nextSibling()) {
201  break;
202  }
203  }
204  }
205  } else {
206  if (walker.firstChild()) {
207  parentStack.push_back(child);
208  } else {
209  if (!walker.nextSibling()) {
210  while (walker.parent()) {
211  parentStack.pop_back();
212  if (walker.nextSibling()) {
213  break;
214  }
215  }
216  }
217  }
218  }
219  } while (!parentStack.empty());
220 
221  geo_mgr->CloseGeometry();
222 
223  geo_mgr->DefaultColors();
224 
225  nameToShape_.clear();
226  nameToVolume_.clear();
227  nameToMaterial_.clear();
228  nameToMedium_.clear();
229 
230  return std::unique_ptr<TGeoManager>(geo_mgr);
231 }

References gather_cfg::cout, dd4hep::createPlacement(), createVolume(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getTransientHandle(), mps_fire::i, info(), edm::ESHandleBase::isValid(), m_fullname, m_level, m_verbose, Skims_PA_cff::name, DDSolidShapesName::name(), nameToMaterial_, nameToMedium_, nameToShape_, nameToVolume_, DDCompactView::root(), AlCaHLTBitMon_QueryRunRegistry::string, viewToken_, and DDCompactView::walker().

Member Data Documentation

◆ m_fullname

const bool TGeoMgrFromDdd::m_fullname
private

Definition at line 78 of file TGeoMgrFromDdd.cc.

Referenced by createMaterial(), createShape(), createVolume(), and produce().

◆ m_level

const int TGeoMgrFromDdd::m_level
private

Definition at line 76 of file TGeoMgrFromDdd.cc.

Referenced by produce().

◆ m_TGeoName

std::string TGeoMgrFromDdd::m_TGeoName
private

Definition at line 79 of file TGeoMgrFromDdd.cc.

◆ m_TGeoTitle

std::string TGeoMgrFromDdd::m_TGeoTitle
private

Definition at line 80 of file TGeoMgrFromDdd.cc.

◆ m_verbose

const bool TGeoMgrFromDdd::m_verbose
private

Definition at line 77 of file TGeoMgrFromDdd.cc.

Referenced by produce().

◆ nameToMaterial_

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

Definition at line 84 of file TGeoMgrFromDdd.cc.

Referenced by createMaterial(), and produce().

◆ nameToMedium_

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

Definition at line 85 of file TGeoMgrFromDdd.cc.

Referenced by createVolume(), and produce().

◆ nameToShape_

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

Definition at line 82 of file TGeoMgrFromDdd.cc.

Referenced by createShape(), and produce().

◆ nameToVolume_

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

Definition at line 83 of file TGeoMgrFromDdd.cc.

Referenced by createVolume(), and produce().

◆ viewToken_

const edm::ESGetToken<DDCompactView, IdealGeometryRecord> TGeoMgrFromDdd::viewToken_
private

Definition at line 87 of file TGeoMgrFromDdd.cc.

Referenced by produce().

DDAxes::y
DDBase::def_type
std::pair< const N *, bool > def_type
Definition: DDBase.h:51
TGeoMgrFromDdd::nameToShape_
std::map< std::string, TGeoShape * > nameToShape_
Definition: TGeoMgrFromDdd.cc:82
mps_fire.i
i
Definition: mps_fire.py:428
DDEllipticalTube
Definition: DDSolid.h:352
DDSolidShape::ddtrap
DDSolidShape::ddtorus
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
DDMaterial::density
double density() const
returns the density
Definition: DDMaterial.cc:80
edm
HLT enums.
Definition: AlignableModifier.h:19
DDSolidShape::ddpseudotrap
DDSolidShape::ddpolyhedra_rrz
DDMaterial::z
double z() const
retruns the atomic number
Definition: DDMaterial.cc:78
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DDMaterial::noOfConstituents
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:72
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
DDMaterial::constituent
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:74
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
DDAxes::x
findQualityFiles.v
v
Definition: findQualityFiles.py:179
TGeoMgrFromDdd::nameToMaterial_
std::map< std::string, TGeoMaterial * > nameToMaterial_
Definition: TGeoMgrFromDdd.cc:84
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
DDTorus
Definition: DDSolid.h:295
DDPseudoTrap
Definition: DDSolid.h:106
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDBooleanSolid
Definition: DDSolid.h:173
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DDCompactView::walker
GraphWalker walker() const
Definition: DDCompactView.cc:61
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
h
DDTruncTubs
A truncated tube section.
Definition: DDSolid.h:128
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDSolidShape::ddtubs
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDSolidShape::ddtrunctubs
DDBase::name
const N & name() const
Definition: DDBase.h:59
DDAxes::z
edm::eventsetup::DependentRecordImplementation::getTransientHandle
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:92
DDMaterial::a
double a() const
returns the atomic mass
Definition: DDMaterial.cc:76
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
TGeoMgrFromDdd::createMaterial
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
Definition: TGeoMgrFromDdd.cc:612
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDSolidShapesName::name
static const char *const name(DDSolidShape s)
Definition: DDSolidShapes.h:32
TGeoMgrFromDdd::nameToVolume_
std::map< std::string, TGeoVolume * > nameToVolume_
Definition: TGeoMgrFromDdd.cc:83
DDSolidShape::ddellipticaltube
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
TGeoMgrFromDdd::m_level
const int m_level
Definition: TGeoMgrFromDdd.cc:76
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
DDSolidShape::ddcons
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDExtrudedPolygon
Definition: DDSolid.h:238
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
TGeoMgrFromDdd::createVolume
TGeoVolume * createVolume(const std::string &iName, const DDSolid &iSolid, const DDMaterial &iMaterial)
Definition: TGeoMgrFromDdd.cc:592
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDCompactView::root
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
Definition: DDCompactView.cc:63
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
TGeoMgrFromDdd::m_verbose
const bool m_verbose
Definition: TGeoMgrFromDdd.cc:77
DDRotationMatrix
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Definition: DDRotationMatrix.h:8
DDSolidShape::ddbox
Exception
Definition: hltDiff.cc:246
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDSolidShape::ddextrudedpolygon
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
TGeoMgrFromDdd::m_fullname
const bool m_fullname
Definition: TGeoMgrFromDdd.cc:78
TGeoMgrFromDdd::createShape
TGeoShape * createShape(const std::string &iName, const DDSolid &iSolid)
Definition: TGeoMgrFromDdd.cc:237
TGeoMgrFromDdd::nameToMedium_
std::map< std::string, TGeoMedium * > nameToMedium_
Definition: TGeoMgrFromDdd.cc:85
DDSolidShape::ddcuttubs
ztail.d
d
Definition: ztail.py:151
DDSolidShape::ddpolycone_rrz
DDName::fullname
const std::string fullname() const
Definition: DDName.h:40
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDSolidShape::ddsubtraction
DDSolidShape::ddintersection
child
Definition: simpleInheritance.h:11
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
GeneratorMix_cff.mix
mix
Definition: GeneratorMix_cff.py:6
dd4hep::createPlacement
TGeoCombiTrans * createPlacement(const Rotation3D &iRot, const Position &iTrans)
Definition: DDDefinitions2Objects.cc:109
dttmaxenums::R
Definition: DTTMax.h:29
DDSolidShape::ddunion
g
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
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
TGeoMgrFromDdd::viewToken_
const edm::ESGetToken< DDCompactView, IdealGeometryRecord > viewToken_
Definition: TGeoMgrFromDdd.cc:87