CMS 3D CMS Logo

Namespaces | Enumerations | Functions
DDDefinitions2Objects.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/DetectorHelper.h"
#include "DD4hep/DD4hepUnits.h"
#include "DD4hep/GeoHandler.h"
#include "DD4hep/Printout.h"
#include "DD4hep/Plugins.h"
#include "DD4hep/detail/SegmentationsInterna.h"
#include "DD4hep/detail/DetectorInterna.h"
#include "DD4hep/detail/ObjectsInterna.h"
#include "XML/Utilities.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include "DataFormats/Math/interface/GeantUnits.h"
#include "DetectorDescription/DDCMS/interface/DDAlgoArguments.h"
#include "DetectorDescription/DDCMS/interface/DDNamespace.h"
#include "DetectorDescription/DDCMS/interface/DDParsingContext.h"
#include "DetectorDescription/DDCMS/interface/DDDetector.h"
#include "TGeoManager.h"
#include "TGeoMaterial.h"
#include <climits>
#include <iostream>
#include <iomanip>
#include <map>
#include <utility>
#include "tbb/concurrent_unordered_map.h"
#include "tbb/concurrent_vector.h"

Go to the source code of this file.

Namespaces

 dd4hep
 

Enumerations

enum  DDAxes {
  DDAxes::x, DDAxes::y, DDAxes::z, DDAxes::rho,
  DDAxes::radial3D, DDAxes::phi, DDAxes::undefined
}
 

Functions

template<typename TYPE >
static void convert_boolean (cms::DDParsingContext *context, xml_h element)
 
template<class InputIt , class ForwardIt , class BinOp >
void for_each_token (InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last, BinOp binary_op)
 
static long load_dddefinition (Detector &det, xml_h element)
 Converter for <DDDefinition> tags. More...
 

Enumeration Type Documentation

enum DDAxes
strong
Enumerator
rho 
radial3D 
phi 
undefined 

Definition at line 1137 of file DDDefinitions2Objects.cc.

Function Documentation

template<typename TYPE >
static void convert_boolean ( cms::DDParsingContext context,
xml_h  element 
)
static

Definition at line 750 of file DDDefinitions2Objects.cc.

References cms::DDNamespace::addSolid(), cms::DDNamespace::attr(), EnergyCorrector::c, cms::DDNamespace::context(), DD_CMU, DEBUG, cms::DDParsingContext::debug_placements, cms::DDParsingContext::debug_shapes, hiPixelPairStep_cff::deltaPhi, cms::DDParsingContext::description, boostedTaus_cff::doc, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, MillePedeFileConverter_cfg::e, HGCalGeometryMode::ExtrudedPolygon, alignmentValidation::fname, includes, interestingEgammaIsoDetIdsSequence_cff::innerRadius, M_PI, interestingEgammaIsoDetIdsSequence_cff::outerRadius, phi, HGCalGeometryMode::Polyhedra, EnergyCorrector::pt, alignCSCRings::r, TCMET_cfi::radius, hfnoseDigiStudy_cfi::rMax, hfnoseDigiStudy_cfi::rMin, Scenarios_cff::scale, cms::DDNamespace::solid(), theta(), x, y, and z.

750  {
751  cms::DDNamespace ns(context);
752  xml_dim_t e(element);
753  string nam = e.nameStr();
754  Solid solids[2];
755  Solid boolean;
756  int cnt = 0;
757 
758  if( e.hasChild(DD_CMU(rSolid)) ) { // Old version
759  for(xml_coll_t c(element, DD_CMU(rSolid)); cnt<2 && c; ++c, ++cnt)
760  solids[cnt] = ns.solid(c.attr<string>(_U(name)));
761  }
762  else {
763  if( (solids[0] = ns.solid(e.attr<string>(DD_CMU(firstSolid)))).isValid() ) ++cnt;
764  if( (solids[1] = ns.solid(e.attr<string>(DD_CMU(secondSolid)))).isValid() ) ++cnt;
765  }
766  if( cnt != 2 ) {
767  except("DD4CMS","+++ Failed to create boolean solid %s. Found only %d parts.",nam.c_str(), cnt);
768  }
769  printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS",
770  "+++ BooleanSolid: %s Left: %-32s Right: %-32s",
771  nam.c_str(), solids[0]->GetName(), solids[1]->GetName());
772 
773  if( solids[0].isValid() && solids[1].isValid() ) {
774  Transform3D trafo;
775  Converter<DDLTransform3D>(*context->description,context,&trafo)(element);
776  boolean = TYPE(solids[0],solids[1],trafo);
777  }
778  if( !boolean.isValid() )
779  except("DD4CMS","+++ FAILED to construct subtraction solid: %s",nam.c_str());
780  ns.addSolid(nam,boolean);
781 }
#define DEBUG
std::atomic< dd4hep::Detector * > description
#define DD_CMU(a)
Definition: DDXMLTags.h:188
template<class InputIt , class ForwardIt , class BinOp >
void for_each_token ( InputIt  first,
InputIt  last,
ForwardIt  s_first,
ForwardIt  s_last,
BinOp  binary_op 
)
static long load_dddefinition ( Detector &  det,
xml_h  element 
)
static

Converter for <DDDefinition> tags.

Unload all XML files after processing

This should be the end of all processing....close the geometry

Definition at line 1372 of file DDDefinitions2Objects.cc.

References cms::DDNamespace::addConstantNS(), cms::DDNamespace::addVolume(), DefaultClusterizer_cff::Algorithm, edmIntegrityCheck::d, DD_CMU, debug, boostedTaus_cff::doc, dqm::qstatus::ERROR, cppFunctionSkipper::exception, alignmentValidation::fname, MessageLogger_cfi::INFO, and pyrootRender::root.

1372  {
1373  cms::DDParsingContext context(&det);
1374  cms::DDNamespace ns(context);
1375  ns.addConstantNS("world_x", "5*m", "number");
1376  ns.addConstantNS("world_y", "5*m", "number");
1377  ns.addConstantNS("world_z", "5*m", "number");
1378  ns.addConstantNS("Air", "materials:Air", "string");
1379  ns.addConstantNS("Vacuum", "materials:Vacuum", "string");
1380  ns.addConstantNS("fm", "1e-12*m", "number");
1381 
1382  xml_elt_t dddef(element);
1383  string fname = xml::DocumentHandler::system_path(element);
1384  bool open_geometry = dddef.hasChild(DD_CMU(open_geometry));
1385  bool close_geometry = dddef.hasChild(DD_CMU(close_geometry));
1386 
1387  xml_coll_t(dddef, _U(debug)).for_each(Converter<debug>(det,&context));
1388 
1389  // Here we define the order how XML elements are processed.
1390  // Be aware of dependencies. This can only defined once.
1391  // At the end it is a limitation of DOM....
1392  printout(INFO,"DD4CMS","+++ Processing the CMS detector description %s",fname.c_str());
1393 
1394  xml::Document doc;
1395  Converter<print_xml_doc> print_doc(det,&context);
1396  try {
1397  DDRegistry res;
1398  print_doc((doc=dddef.document()).root());
1399  xml_coll_t(dddef, DD_CMU(DisabledAlgo)).for_each(Converter<disabled_algo>(det,&context,&res));
1400  xml_coll_t(dddef, DD_CMU(ConstantsSection)).for_each(Converter<ConstantsSection>(det,&context,&res));
1401  xml_coll_t(dddef, DD_CMU(VisSection)).for_each(Converter<vissection>(det,&context));
1402  xml_coll_t(dddef, DD_CMU(RotationSection)).for_each(Converter<RotationSection>(det,&context));
1403  xml_coll_t(dddef, DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det,&context));
1404 
1405  xml_coll_t(dddef, DD_CMU(IncludeSection)).for_each(DD_CMU(Include), Converter<include_load>(det,&context,&res));
1406 
1407  for(xml::Document d : res.includes) {
1408  print_doc((doc=d).root());
1409  Converter<include_constants>(det,&context,&res)((doc=d).root());
1410  }
1411  // Before we continue, we have to resolve all constants NOW!
1412  Converter<DDRegistry>(det,&context,&res)(dddef);
1413  // Now we can process the include files one by one.....
1414  for(xml::Document d : res.includes) {
1415  print_doc((doc=d).root());
1416  xml_coll_t(d.root(),DD_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det,&context));
1417  }
1418  if(open_geometry) {
1419  context.geo_inited = true;
1420  det.init();
1421  ns.addVolume(det.worldVolume());
1422  }
1423  for(xml::Document d : res.includes) {
1424  print_doc((doc=d).root());
1425  xml_coll_t(d.root(),DD_CMU(RotationSection)).for_each(Converter<RotationSection>(det,&context));
1426  }
1427  for(xml::Document d : res.includes) {
1428  print_doc((doc=d).root());
1429  xml_coll_t(d.root(), DD_CMU(SolidSection)).for_each(Converter<SolidSection>(det,&context));
1430  }
1431  for(xml::Document d : res.includes) {
1432  print_doc((doc=d).root());
1433  xml_coll_t(d.root(), DD_CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det,&context));
1434  }
1435  for(xml::Document d : res.includes) {
1436  print_doc((doc=d).root());
1437  xml_coll_t(d.root(), DD_CMU(Algorithm)).for_each(Converter<DDLAlgorithm>(det,&context));
1438  }
1439  for(xml::Document d : res.includes) {
1440  print_doc((doc=d).root());
1441  xml_coll_t(d.root(), DD_CMU(PosPartSection)).for_each(Converter<PosPartSection>(det,&context));
1442  }
1443  for(xml::Document d : res.includes) {
1444  print_doc((doc=d).root());
1445  xml_coll_t(d.root(), DD_CMU(SpecParSection)).for_each(Converter<SpecParSection>(det,&context));
1446  }
1447 
1449  for(xml::Document d : res.includes) Converter<include_unload>(det,&context,&res)(d.root());
1450 
1451  print_doc((doc=dddef.document()).root());
1452  // Now process the actual geometry items
1453  xml_coll_t(dddef, DD_CMU(SolidSection)).for_each(Converter<SolidSection>(det,&context));
1454  xml_coll_t(dddef, DD_CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det,&context));
1455  xml_coll_t(dddef, DD_CMU(Algorithm)).for_each(Converter<DDLAlgorithm>(det,&context));
1456  xml_coll_t(dddef, DD_CMU(PosPartSection)).for_each(Converter<PosPartSection>(det,&context));
1457  xml_coll_t(dddef, DD_CMU(SpecParSection)).for_each(Converter<SpecParSection>(det,&context));
1458  }
1459  catch(const exception& e) {
1460  printout(ERROR,"DD4CMS","Exception while processing xml source:%s",doc.uri().c_str());
1461  printout(ERROR,"DD4CMS","----> %s", e.what());
1462  throw;
1463  }
1464 
1466  if(close_geometry) {
1467  det.endDocument();
1468  }
1469  printout(INFO,"DDDefinition","+++ Finished processing %s",fname.c_str());
1470  return 1;
1471 }
Definition: Electron.h:6
#define DD_CMU(a)
Definition: DDXMLTags.h:188
#define debug
Definition: HDRShower.cc:19
string fname
main script
static const int ERROR

Variable Documentation

tbb::concurrent_unordered_map<std::string, std::string> allConst

Definition at line 52 of file DDDefinitions2Objects.cc.

tbb::concurrent_vector<xml::Document> includes
tbb::concurrent_unordered_map<std::string, std::string> originalConst

Definition at line 52 of file DDDefinitions2Objects.cc.

tbb::concurrent_unordered_map<std::string, std::string> unresolvedConst

Definition at line 52 of file DDDefinitions2Objects.cc.