Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-05 04:09:54

0001 #include "Geometry/MuonNumbering/plugins/MuonGeometryConstantsBuild.h"
0002 #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 
0007 #include "DetectorDescription/Core/interface/DDValue.h"
0008 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0009 #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h"
0010 
0011 //#define EDM_ML_DEBUG
0012 
0013 bool MuonGeometryConstantsBuild::build(const DDCompactView* cpv, MuonGeometryConstants& php) {
0014 #ifdef EDM_ML_DEBUG
0015   edm::LogVerbatim("MuonGeom")
0016       << "MuonGeometryConstantsBuild;:build (const DDCompactView* cpv, MuonGeometryConstants& php)";
0017 #endif
0018   std::string attribute = "OnlyForMuonNumbering";
0019 
0020   DDSpecificsHasNamedValueFilter filter(attribute);
0021   DDFilteredView fview((*cpv), filter);
0022 
0023   DDValue val2("level");
0024   const DDsvalues_type params(fview.mergedSpecifics());
0025 
0026   fview.firstChild();
0027 
0028   const DDsvalues_type mySpecs(fview.mergedSpecifics());
0029 #ifdef EDM_ML_DEBUG
0030   edm::LogVerbatim("MuonGeom") << "MuonGeometryConstantsBuild::mySpecs.size() = " << mySpecs.size();
0031 #endif
0032   if (mySpecs.size() < 25) {
0033     edm::LogError("MuonGeometryConstantsBuild")
0034         << " MuonGeometryConstantsBuild: Missing SpecPars from DetectorDescription.";
0035     std::string msg =
0036         "MuonGeometryConstantsBuild does not have the appropriate number of SpecPars associated with the part //MUON.";
0037     throw cms::Exception("GeometryBuildFailure", msg);
0038   }
0039 
0040   DDsvalues_type::const_iterator bit = mySpecs.begin();
0041   DDsvalues_type::const_iterator eit = mySpecs.end();
0042   for (; bit != eit; ++bit) {
0043     if (bit->second.isEvaluated()) {
0044       php.addValue(bit->second.name(), static_cast<int>(bit->second.doubles()[0]));
0045 #ifdef EDM_ML_DEBUG
0046       edm::LogVerbatim("MuonGeom") << "MuonGeometryConstantsBuild::adding DDConstant of " << bit->second.name() << " = "
0047                                    << static_cast<int>(bit->second.doubles()[0]);
0048 #endif
0049     }
0050   }
0051   return true;
0052 }
0053 
0054 bool MuonGeometryConstantsBuild::build(const cms::DDCompactView* cpv, MuonGeometryConstants& php) {
0055 #ifdef EDM_ML_DEBUG
0056   edm::LogVerbatim("MuonGeom")
0057       << "MuonGeometryConstantsBuild;:build (const cms::DDCompactView* cpv, MuonGeometryConstants& php)";
0058 #endif
0059   cms::DDSpecParRegistry const& registry = cpv->specpars();
0060   auto it = registry.specpars.find("MuonCommonNumbering");
0061   if (it != end(registry.specpars)) {
0062     for (const auto& l : it->second.spars) {
0063       if (l.first == "OnlyForMuonNumbering") {
0064         for (const auto& k : it->second.numpars) {
0065           for (const auto& ik : k.second) {
0066             php.addValue(k.first, static_cast<int>(ik));
0067 #ifdef EDM_ML_DEBUG
0068             edm::LogVerbatim("MuonGeom") << "MuonGeometryConstantsBuild::adding DDConstant of " << k.first << " = "
0069                                          << static_cast<int>(ik);
0070 #endif
0071           }
0072         }
0073       }
0074     }
0075   }
0076 
0077   return true;
0078 }