CMS 3D CMS Logo

Namespaces | 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/DDAlgoArguments.h"
#include "DetectorDescription/DDCMS/interface/DDNamespace.h"
#include "DetectorDescription/DDCMS/interface/DDParsingContext.h"
#include "DetectorDescription/DDCMS/interface/DDRegistry.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
 

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=",")
 

Function Documentation

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

Definition at line 618 of file DDDefinitions2Objects.cc.

References _CMU, cms::DDNamespace::addSolid(), cms::DDNamespace::attr(), EnergyCorrector::c, cms::DDNamespace::context, cms::DDParsingContext::debug_algorithms, cms::DDParsingContext::debug_placements, cms::DDParsingContext::debug_shapes, hiPixelPairStep_cff::deltaPhi, cms::DDParsingContext::description, heppy_report::description, cms::DDParsingContext::disabledAlgs, common_cff::doc, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, MillePedeFileConverter_cfg::e, dqm::qstatus::ERROR, cppFunctionSkipper::exception, HGCalGeometryMode::ExtrudedPolygon, alignmentValidation::fname, includes, MessageLogger_cfi::INFO, interestingEgammaIsoDetIdsSequence_cff::innerRadius, M_PI, dataset::name, interestingEgammaIsoDetIdsSequence_cff::outerRadius, phi, HGCalGeometryMode::Polyhedra, EnergyCorrector::pt, alignCSCRings::r, TCMET_cfi::radius, cms::DDNamespace::realName(), conversionPostprocessing_cfi::rMax, conversionPostprocessing_cfi::rMin, Scenarios_cff::scale, sd, cms::DDNamespace::solid(), theta(), HGCalGeometryMode::Trapezoid, x, y, and z.

618  {
619  cms::DDNamespace _ns(context);
620  xml_dim_t e(element);
621  string nam = e.nameStr();
622  Solid solids[2];
623  Solid boolean;
624  int cnt = 0;
625 
626  if ( e.hasChild(_CMU(rSolid)) ) { // Old version
627  for(xml_coll_t c(element, _CMU(rSolid)); cnt<2 && c; ++c, ++cnt)
628  solids[cnt] = _ns.solid(c.attr<string>(_U(name)));
629  }
630  else {
631  if ( (solids[0] = _ns.solid(e.attr<string>(_CMU(firstSolid)))).isValid() ) ++cnt;
632  if ( (solids[1] = _ns.solid(e.attr<string>(_CMU(secondSolid)))).isValid() ) ++cnt;
633  }
634  if ( cnt != 2 ) {
635  except("MyDDCMS","+++ Failed to create boolean solid %s. Found only %d parts.",nam.c_str(), cnt);
636  }
637  printout(_ns.context->debug_placements ? ALWAYS : DEBUG, "MyDDCMS",
638  "+++ BooleanSolid: %s Left: %-32s Right: %-32s",
639  nam.c_str(), solids[0]->GetName(), solids[1]->GetName());
640 
641  if ( solids[0].isValid() && solids[1].isValid() ) {
642  Transform3D trafo;
643  Converter<DDLTransform3D>(*context->description,context,&trafo)(element);
644  boolean = TYPE(solids[0],solids[1],trafo);
645  }
646  if ( !boolean.isValid() )
647  except("MyDDCMS","+++ FAILED to construct subtraction solid: %s",nam.c_str());
648  _ns.addSolid(nam,boolean);
649 }
#define DEBUG
#define _CMU(a)
Definition: DDXMLTags.h:173
dd4hep::Detector * description
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 1039 of file DDDefinitions2Objects.cc.

References GetRecoTauVFromDQM_MC_cff::next.

Referenced by splitNumeric(), and splitString().

1042 {
1043  while( first != last ) {
1044  const auto pos = std::find_first_of( first, last, s_first, s_last );
1045  binary_op( first, pos );
1046  if( pos == last ) break;
1047  first = std::next( pos );
1048  }
1049 }
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 1177 of file DDDefinitions2Objects.cc.

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

1177  {
1178  static cms::DDParsingContext context(&det);
1179  cms::DDNamespace _ns(context);
1180  xml_elt_t dddef(element);
1181  string fname = xml::DocumentHandler::system_path(element);
1182  bool open_geometry = dddef.hasChild(_CMU(open_geometry));
1183  bool close_geometry = dddef.hasChild(_CMU(close_geometry));
1184 
1185  xml_coll_t(dddef, _U(debug)).for_each(Converter<debug>(det,&context));
1186 
1187  // Here we define the order how XML elements are processed.
1188  // Be aware of dependencies. This can only defined once.
1189  // At the end it is a limitation of DOM....
1190  printout(INFO,"MyDDCMS","+++ Processing the CMS detector description %s",fname.c_str());
1191 
1192  xml::Document doc;
1193  Converter<print_xml_doc> print_doc(det,&context);
1194  try {
1195  DDRegistry res;
1196  print_doc((doc=dddef.document()).root());
1197  xml_coll_t(dddef, _CMU(DisabledAlgo)).for_each(Converter<disabled_algo>(det,&context,&res));
1198  xml_coll_t(dddef, _CMU(ConstantsSection)).for_each(Converter<ConstantsSection>(det,&context,&res));
1199  xml_coll_t(dddef, _CMU(VisSection)).for_each(Converter<vissection>(det,&context));
1200  xml_coll_t(dddef, _CMU(RotationSection)).for_each(Converter<RotationSection>(det,&context));
1201  xml_coll_t(dddef, _CMU(MaterialSection)).for_each(Converter<MaterialSection>(det,&context));
1202 
1203  xml_coll_t(dddef, _CMU(IncludeSection)).for_each(_CMU(Include), Converter<include_load>(det,&context,&res));
1204 
1205  for(xml::Document d : res.includes ) {
1206  print_doc((doc=d).root());
1207  Converter<include_constants>(det,&context,&res)((doc=d).root());
1208  }
1209  // Before we continue, we have to resolve all constants NOW!
1210  Converter<DDRegistry>(det,&context,&res)(dddef);
1211  // Now we can process the include files one by one.....
1212  for(xml::Document d : res.includes ) {
1213  print_doc((doc=d).root());
1214  xml_coll_t(d.root(),_CMU(MaterialSection)).for_each(Converter<MaterialSection>(det,&context));
1215  }
1216  if ( open_geometry ) {
1217  context.geo_inited = true;
1218  det.init();
1219  _ns.addVolume(det.worldVolume());
1220  }
1221  for(xml::Document d : res.includes ) {
1222  print_doc((doc=d).root());
1223  xml_coll_t(d.root(),_CMU(RotationSection)).for_each(Converter<RotationSection>(det,&context));
1224  }
1225  for(xml::Document d : res.includes ) {
1226  print_doc((doc=d).root());
1227  xml_coll_t(d.root(), _CMU(SolidSection)).for_each(Converter<SolidSection>(det,&context));
1228  }
1229  for(xml::Document d : res.includes ) {
1230  print_doc((doc=d).root());
1231  xml_coll_t(d.root(), _CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det,&context));
1232  }
1233  for(xml::Document d : res.includes ) {
1234  print_doc((doc=d).root());
1235  xml_coll_t(d.root(), _CMU(Algorithm)).for_each(Converter<DDLAlgorithm>(det,&context));
1236  }
1237  for(xml::Document d : res.includes ) {
1238  print_doc((doc=d).root());
1239  xml_coll_t(d.root(), _CMU(PosPartSection)).for_each(Converter<PosPartSection>(det,&context));
1240  }
1241 
1243  for(xml::Document d : res.includes ) Converter<include_unload>(det,&context,&res)(d.root());
1244 
1245  print_doc((doc=dddef.document()).root());
1246  // Now process the actual geometry items
1247  xml_coll_t(dddef, _CMU(SolidSection)).for_each(Converter<SolidSection>(det,&context));
1248  xml_coll_t(dddef, _CMU(LogicalPartSection)).for_each(Converter<LogicalPartSection>(det,&context));
1249  xml_coll_t(dddef, _CMU(Algorithm)).for_each(Converter<DDLAlgorithm>(det,&context));
1250  xml_coll_t(dddef, _CMU(PosPartSection)).for_each(Converter<PosPartSection>(det,&context));
1251  }
1252  catch(const exception& e) {
1253  printout(ERROR,"MyDDCMS","Exception while processing xml source:%s",doc.uri().c_str());
1254  printout(ERROR,"MyDDCMS","----> %s", e.what());
1255  throw;
1256  }
1257 
1259  if ( close_geometry ) {
1260  det.endDocument();
1261  }
1262  printout(INFO,"DDDefinition","+++ Finished processing %s",fname.c_str());
1263  return 1;
1264 }
#define _CMU(a)
Definition: DDXMLTags.h:173
Definition: Electron.h:6
#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 1052 of file DDDefinitions2Objects.cc.

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

Referenced by splitString().

1053 {
1054  vector<double> output;
1055 
1056  for_each_token( cbegin( str ), cend( str ),
1057  cbegin( delims ), cend( delims ),
1058  [&output] ( auto first, auto second ) {
1059  if( first != second ) {
1060  output.emplace_back(stod(string( first, second )));
1061  }
1062  });
1063  return output;
1064 }
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 1067 of file DDDefinitions2Objects.cc.

References _CMU, cms::DDNamespace::attr(), cms::DDNamespace::context, KineDebug3::count(), gather_cfg::cout, 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_visattr, cms::DDParsingContext::debug_volumes, 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(), splitNumeric(), findQualityFiles::v, and x.

1068 {
1069  vector<string> output;
1070 
1071  for_each_token( cbegin( str ), cend( str ),
1072  cbegin( delims ), cend( delims ),
1073  [&output] ( auto first, auto second ) {
1074  if( first != second ) {
1075  output.emplace_back( first, second );
1076  }
1077  });
1078  return output;
1079 }
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 49 of file DDDefinitions2Objects.cc.

std::vector<xml::Document> includes

Definition at line 48 of file DDDefinitions2Objects.cc.

Referenced by convert_boolean().

std::map<std::string, std::string> originalConst

Definition at line 49 of file DDDefinitions2Objects.cc.

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

Definition at line 49 of file DDDefinitions2Objects.cc.