Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:18

0001 #include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h"
0002 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 using namespace cms;
0006 using namespace edm;
0007 
0008 const MuonBaseNumber MuonNumbering::geoHistoryToBaseNumber(const cms::ExpandedNodes& nodes) const {
0009   MuonBaseNumber num;
0010 
0011   int levelPart = get("level");
0012   int superPart = get("super");
0013   int basePart = get("base");
0014   int startCopyNo = get("xml_starts_with_copyno");
0015 
0016   // some consistency checks
0017   if (basePart != 1) {
0018     edm::LogError("Geometry") << "MuonNumbering finds unusual base constant: " << basePart;
0019   }
0020   if (superPart < 100) {
0021     edm::LogError("Geometry") << "MuonNumbering finds unusual super part: " << superPart
0022                               << " -- resetting super part to 100";
0023     superPart = 100;  // Reset to sensible value so calculations below don't go out of range
0024   }
0025   if (levelPart < 10 * superPart) {
0026     edm::LogError("Geometry") << "MuonNumbering finds unusual level constant: " << levelPart;
0027   }
0028   if ((startCopyNo != 0) && (startCopyNo != 1)) {
0029     edm::LogError("Geometry") << "MuonNumbering finds unusual start value for copy numbers: " << startCopyNo;
0030   }
0031   int ctr(0);
0032   for (auto const& it : nodes.tags) {
0033     int tag = it / levelPart;
0034     if (tag > 0) {
0035       int offset = nodes.offsets[ctr];
0036       int copyno = nodes.copyNos[ctr] + offset % superPart;
0037       int super = offset / superPart;
0038       num.addBase(tag, super, copyno - startCopyNo);
0039     }
0040     ++ctr;
0041   }
0042   return num;
0043 }
0044 
0045 const int MuonNumbering::get(const char* key) const {
0046   int result(0);
0047   auto const& it = values_.find(key);
0048   if (it != end(values_))
0049     result = it->second;
0050   return result;
0051 }
0052 
0053 void MuonNumbering::put(std::string_view str, int num) { values_.emplace(str, num); }
0054 
0055 #include "FWCore/Utilities/interface/typelookup.h"
0056 
0057 TYPELOOKUP_DATA_REG(MuonNumbering);