CMS 3D CMS Logo

Namespaces | Typedefs | 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 "DetectorDescription/DDCMS/interface/DDUnits.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 <set>
#include <map>
#include <utility>

Go to the source code of this file.

Namespaces

 dd4hep
 

Typedefs

using DDVectorsMap = cms::DDDetector::DDVectorsMap
 

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...
 
vector< double > splitNumeric (const string &str, const string &delims=",")
 
vector< string > splitString (const string &str, const string &delims=",")
 

Typedef Documentation

Definition at line 33 of file DDDefinitions2Objects.cc.

Enumeration Type Documentation

enum DDAxes
strong
Enumerator
rho 
radial3D 
phi 
undefined 

Definition at line 1095 of file DDDefinitions2Objects.cc.

Function Documentation

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

Definition at line 708 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, common_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.

708  {
709  cms::DDNamespace ns(context);
710  xml_dim_t e(element);
711  string nam = e.nameStr();
712  Solid solids[2];
713  Solid boolean;
714  int cnt = 0;
715 
716  if( e.hasChild(DD_CMU(rSolid)) ) { // Old version
717  for(xml_coll_t c(element, DD_CMU(rSolid)); cnt<2 && c; ++c, ++cnt)
718  solids[cnt] = ns.solid(c.attr<string>(_U(name)));
719  }
720  else {
721  if( (solids[0] = ns.solid(e.attr<string>(DD_CMU(firstSolid)))).isValid() ) ++cnt;
722  if( (solids[1] = ns.solid(e.attr<string>(DD_CMU(secondSolid)))).isValid() ) ++cnt;
723  }
724  if( cnt != 2 ) {
725  except("DD4CMS","+++ Failed to create boolean solid %s. Found only %d parts.",nam.c_str(), cnt);
726  }
727  printout(ns.context()->debug_placements ? ALWAYS : DEBUG, "DD4CMS",
728  "+++ BooleanSolid: %s Left: %-32s Right: %-32s",
729  nam.c_str(), solids[0]->GetName(), solids[1]->GetName());
730 
731  if( solids[0].isValid() && solids[1].isValid() ) {
732  Transform3D trafo;
733  Converter<DDLTransform3D>(*context->description,context,&trafo)(element);
734  boolean = TYPE(solids[0],solids[1],trafo);
735  }
736  if( !boolean.isValid() )
737  except("DD4CMS","+++ FAILED to construct subtraction solid: %s",nam.c_str());
738  ns.addSolid(nam,boolean);
739 }
#define DEBUG
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 
)

Definition at line 1234 of file DDDefinitions2Objects.cc.

References GetRecoTauVFromDQM_MC_cff::next.

Referenced by splitNumeric(), and splitString().

1237 {
1238  while( first != last ) {
1239  const auto pos = std::find_first_of( first, last, s_first, s_last );
1240  binary_op( first, pos );
1241  if( pos == last ) break;
1242  first = std::next( pos );
1243  }
1244 }
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 1370 of file DDDefinitions2Objects.cc.

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

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

Definition at line 1247 of file DDDefinitions2Objects.cc.

References plotBeamSpotDB::first, for_each_token(), convertSQLitetoXML_cfg::output, and edm::second().

Referenced by splitString().

1248 {
1249  vector<double> output;
1250 
1251  for_each_token( cbegin( str ), cend( str ),
1252  cbegin( delims ), cend( delims ),
1253  [&output] ( auto first, auto second ) {
1254  if( first != second ) {
1255  output.emplace_back(stod(string( first, second )));
1256  }
1257  });
1258  return output;
1259 }
U second(std::pair< T, U > const &p)
#define str(s)
void for_each_token(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last, BinOp binary_op)
vector<string> splitString ( const string &  str,
const string &  delims = "," 
)

Definition at line 1262 of file DDDefinitions2Objects.cc.

References cms::DDNamespace::attr(), cms::DDNamespace::context(), DD_CMU, DEBUG, cms::DDParsingContext::debug_algorithms, cms::DDParsingContext::debug_constants, cms::DDParsingContext::debug_includes, cms::DDParsingContext::debug_materials, cms::DDParsingContext::debug_namespaces, cms::DDParsingContext::debug_placements, cms::DDParsingContext::debug_rotations, cms::DDParsingContext::debug_shapes, cms::DDParsingContext::debug_specpars, cms::DDParsingContext::debug_visattr, cms::DDParsingContext::debug_volumes, cms::DDParsingContext::description, MillePedeFileConverter_cfg::e, dqm::qstatus::ERROR, plotBeamSpotDB::first, alignmentValidation::fname, for_each_token(), mps_fire::i, training_settings::idx, gen::n, dataset::name, convertSQLitetoXML_cfg::output, alignCSCRings::r, PhysicsTools::registry, cuy::rep, mps_update::results, edm::second(), cms::DDNamespace::setContext(), splitNumeric(), and findQualityFiles::v.

1263 {
1264  vector<string> output;
1265 
1266  for_each_token( cbegin( str ), cend( str ),
1267  cbegin( delims ), cend( delims ),
1268  [&output] ( auto first, auto second ) {
1269  if( first != second ) {
1270  output.emplace_back( first, second );
1271  }
1272  });
1273  return output;
1274 }
U second(std::pair< T, U > const &p)
#define str(s)
void for_each_token(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last, BinOp binary_op)

Variable Documentation

std::map<std::string, std::string> allConst

Definition at line 51 of file DDDefinitions2Objects.cc.

std::vector<xml::Document> includes
std::map<std::string, std::string> originalConst

Definition at line 51 of file DDDefinitions2Objects.cc.

std::map<std::string, std::string> unresolvedConst

Definition at line 51 of file DDDefinitions2Objects.cc.