CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/Geometry/MuonNumbering/src/MuonDDDConstants.cc

Go to the documentation of this file.
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 //#define LOCAL_DEBUG
00012 
00013 MuonDDDConstants::MuonDDDConstants( const DDCompactView& cpv ) {
00014 #ifdef LOCAL_DEBUG
00015   std::cout << "MuonDDDConstants;:MuonDDDConstants ( const DDCompactView& cpv ) constructor " << std::endl;
00016 #endif
00017   std::string attribute = "OnlyForMuonNumbering"; 
00018   std::string value     = "any";
00019   DDValue val(attribute, value, 0.0);
00020   
00021   DDSpecificsFilter filter;
00022   filter.setCriteria(val,
00023                      DDSpecificsFilter::not_equals,
00024                      DDSpecificsFilter::AND, 
00025                      true, // compare strings otherwise doubles
00026                      true  // use merged-specifics or simple-specifics
00027                      );
00028   DDFilteredView fview(cpv);
00029   fview.addFilter(filter);
00030   
00031   DDValue val2("level");
00032   const DDsvalues_type params(fview.mergedSpecifics());
00033   
00034   fview.firstChild();
00035   
00036   const DDsvalues_type mySpecs (fview.mergedSpecifics());
00037 #ifdef LOCAL_DEBUG
00038   std::cout << "mySpecs.size() = " << mySpecs.size() << std::endl;
00039 #endif
00040   if ( mySpecs.size() < 25 ) {
00041     edm::LogError("MuonDDDConstants") << " MuonDDDConstants: Missing SpecPars from DetectorDescription." << std::endl;
00042     std::string msg = "MuonDDDConstants does not have the appropriate number of SpecPars associated";
00043     msg+= " with the part //MUON.";
00044     throw cms::Exception("GeometryBuildFailure", msg);
00045   }
00046 
00047   DDsvalues_type::const_iterator bit = mySpecs.begin();
00048   DDsvalues_type::const_iterator eit = mySpecs.end();
00049   for ( ; bit != eit; ++bit ) {
00050     if ( bit->second.isEvaluated() ) {
00051       this->addValue( bit->second.name(), int(bit->second.doubles()[0]) );
00052 #ifdef LOCAL_DEBUG
00053       std::cout << "adding DDConstant of " << bit->second.name() << " = " << int(bit->second.doubles()[0]) << std::endl;
00054 #endif
00055     }
00056     //    std::cout << "DDConstant of " << bit->second.name() << " = " << bit->second.strings()[0] << std::endl;
00057   }
00058   
00059 }
00060 
00061 MuonDDDConstants::~MuonDDDConstants() { 
00062   //  std::cout << "destructed!!!" << std::endl;
00063 }
00064 
00065 int MuonDDDConstants::getValue( const std::string& name ) const {
00066 #ifdef LOCAL_DEBUG
00067   std::cout << "about to look for ... " << name << std::endl;
00068 #endif
00069   if ( namesAndValues_.size() == 0 ) {
00070     std::cout << "MuonDDDConstants::getValue HAS NO VALUES!" << std::endl;
00071     throw cms::Exception("GeometryBuildFailure", "MuonDDDConstants does not have requested value for " + name);
00072   }
00073 
00074   std::map<std::string, int>::const_iterator findIt = namesAndValues_.find(name);
00075 
00076   if ( findIt == namesAndValues_.end() ) {
00077     std::cout << "MuonDDDConstants::getValue was asked for " << name << " and had NO clue!" << std::endl;
00078     throw cms::Exception("GeometryBuildFailure", "MuonDDDConstants does not have requested value for " + name);
00079   }
00080 
00081   return findIt->second;
00082 }
00083 
00084 void MuonDDDConstants::addValue(const std::string& name, const int& value) {
00085   namesAndValues_[name] = value;
00086 }
00087