File indexing completed on 2024-04-06 12:15:18
0001 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
0002
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "FWCore/Utilities/interface/Exception.h"
0005
0006 #include "DetectorDescription/Core/interface/DDValue.h"
0007 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0008
0009
0010
0011 MuonDDDConstants::MuonDDDConstants(const DDCompactView& cpv) {
0012 #ifdef EDM_ML_DEBUG
0013 edm::LogVerbatim("MuonGeom") << "MuonDDDConstants;:MuonDDDConstants ( const DDCompactView& cpv ) constructor ";
0014 #endif
0015 std::string attribute = "OnlyForMuonNumbering";
0016
0017 DDSpecificsHasNamedValueFilter filter(attribute);
0018 DDFilteredView fview(cpv, filter);
0019
0020 DDValue val2("level");
0021 const DDsvalues_type params(fview.mergedSpecifics());
0022
0023 fview.firstChild();
0024
0025 const DDsvalues_type mySpecs(fview.mergedSpecifics());
0026 #ifdef EDM_ML_DEBUG
0027 edm::LogVerbatim("MuonGeom") << "MuonDDDConstants::mySpecs.size() = " << mySpecs.size();
0028 #endif
0029 if (mySpecs.size() < 25) {
0030 edm::LogError("MuonDDDConstants") << " MuonDDDConstants: Missing SpecPars from DetectorDescription.";
0031 std::string msg =
0032 "MuonDDDConstants does not have the appropriate number of SpecPars associated with the part //MUON.";
0033 throw cms::Exception("GeometryBuildFailure", msg);
0034 }
0035
0036 DDsvalues_type::const_iterator bit = mySpecs.begin();
0037 DDsvalues_type::const_iterator eit = mySpecs.end();
0038 for (; bit != eit; ++bit) {
0039 if (bit->second.isEvaluated()) {
0040 this->addValue(bit->second.name(), int(bit->second.doubles()[0]));
0041 #ifdef EDM_ML_DEBUG
0042 edm::LogVerbatim("MuonGeom") << "MuonDDDConstants::adding DDConstant of " << bit->second.name() << " = "
0043 << int(bit->second.doubles()[0]);
0044 #endif
0045 }
0046 }
0047 }
0048
0049 int MuonDDDConstants::getValue(const std::string& name) const {
0050 #ifdef EDM_ML_DEBUG
0051 edm::LogVerbatim("MuonGeom") << "about to look for ... " << name << std::endl;
0052 #endif
0053 if (namesAndValues_.empty()) {
0054 edm::LogWarning("MuonGeom") << "MuonDDDConstants::getValue HAS NO VALUES!";
0055 throw cms::Exception("GeometryBuildFailure", "MuonDDDConstants does not have requested value for " + name);
0056 }
0057
0058 std::map<std::string, int>::const_iterator findIt = namesAndValues_.find(name);
0059
0060 if (findIt == namesAndValues_.end()) {
0061 edm::LogWarning("MuonGeom") << "MuonDDDConstants::getValue was asked for " << name << " and had NO clue!";
0062 throw cms::Exception("GeometryBuildFailure", "MuonDDDConstants does not have requested value for " + name);
0063 }
0064 #ifdef EDM_ML_DEBUG
0065 edm::LogVerbatim("MuonGeom") << "MuonDDDConstants::Value for " << name << " is " << findIt->second;
0066 #endif
0067 return findIt->second;
0068 }
0069
0070 void MuonDDDConstants::addValue(const std::string& name, const int& value) { namesAndValues_[name] = value; }