00001 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
00002
00003
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include "FWCore/Utilities/interface/Exception.h"
00006
00007 #include "DetectorDescription/Core/interface/DDValue.h"
00008 #include "DetectorDescription/Core/interface/DDFilteredView.h"
00009
00010
00011
00012
00013 MuonDDDConstants::MuonDDDConstants( const DDCompactView& cpv ) {
00014
00015 std::string attribute = "OnlyForMuonNumbering";
00016 std::string value = "any";
00017 DDValue val(attribute, value, 0.0);
00018
00019 DDSpecificsFilter filter;
00020 filter.setCriteria(val,
00021 DDSpecificsFilter::not_equals,
00022 DDSpecificsFilter::AND,
00023 true,
00024 true
00025 );
00026 DDFilteredView fview(cpv);
00027 fview.addFilter(filter);
00028
00029 DDValue val2("level");
00030 const DDsvalues_type params(fview.mergedSpecifics());
00031
00032 fview.firstChild();
00033
00034 const DDsvalues_type mySpecs (fview.mergedSpecifics());
00035
00036 if ( mySpecs.size() < 25 ) {
00037 edm::LogError("MuonDDDConstants") << " MuonDDDConstants: Missing SpecPars from DetectorDescription." << std::endl;
00038 std::string msg = "MuonDDDConstants does not have the appropriate number of SpecPars associated";
00039 msg+= " with the part //MUON.";
00040 throw cms::Exception("GeometryBuildFailure", msg);
00041 }
00042
00043 DDsvalues_type::const_iterator bit = mySpecs.begin();
00044 DDsvalues_type::const_iterator eit = mySpecs.end();
00045 for ( ; bit != eit; ++bit ) {
00046 if ( bit->second.isEvaluated() ) {
00047 this->addValue( bit->second.name(), int(bit->second.doubles()[0]) );
00048
00049 }
00050
00051 }
00052
00053 }
00054
00055 MuonDDDConstants::~MuonDDDConstants() {
00056
00057 }
00058
00059 int MuonDDDConstants::getValue( const std::string& name ) const {
00060
00061
00062 if ( namesAndValues_.size() == 0 ) {
00063 std::cout << "MuonDDDConstants::getValue HAS NO VALUES!" << std::endl;
00064 throw cms::Exception("GeometryBuildFailure", "MuonDDDConstants does not have requested value for " + name);
00065 }
00066
00067 std::map<std::string, int>::const_iterator findIt = namesAndValues_.find(name);
00068
00069 if ( findIt == namesAndValues_.end() ) {
00070 std::cout << "MuonDDDConstants::getValue was asked for " << name << " and had NO clue!" << std::endl;
00071 throw cms::Exception("GeometryBuildFailure", "MuonDDDConstants does not have requested value for " + name);
00072 }
00073
00074 return findIt->second;
00075 }
00076
00077 void MuonDDDConstants::addValue(const std::string& name, const int& value) {
00078 namesAndValues_[name] = value;
00079 }
00080