File indexing completed on 2024-09-07 04:34:56
0001
0002
0003
0004
0005
0006 #include "DTGeometryParserFromDDD.h"
0007 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
0008
0009 using namespace std;
0010
0011 DTGeometryParserFromDDD::DTGeometryParserFromDDD(
0012 const DDCompactView* cview,
0013 const MuonGeometryConstants& muonConstants,
0014 map<DTLayerId, std::pair<unsigned int, unsigned int> >& theLayerIdWiresMap) {
0015 try {
0016 std::string attribute = "MuStructure";
0017 std::string value = "MuonBarrelDT";
0018
0019
0020 DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
0021 DDFilteredView fview(*cview, filter);
0022
0023 parseGeometry(fview, muonConstants, theLayerIdWiresMap);
0024 } catch (const cms::Exception& e) {
0025 std::cerr << "DTGeometryParserFromDDD::build() : DDD Exception: something went wrong during XML parsing!"
0026 << std::endl
0027 << " Message: " << e << std::endl;
0028 throw;
0029 } catch (const exception& e) {
0030 std::cerr << "DTGeometryParserFromDDD::build() : an unexpected exception occured: " << e.what() << std::endl;
0031 throw;
0032 } catch (...) {
0033 std::cerr << "DTGeometryParserFromDDD::build() : An unexpected exception occured!" << std::endl;
0034 throw;
0035 }
0036 }
0037
0038 DTGeometryParserFromDDD::~DTGeometryParserFromDDD() {}
0039
0040 void DTGeometryParserFromDDD::parseGeometry(DDFilteredView& fv,
0041 const MuonGeometryConstants& muonConstants,
0042 map<DTLayerId, std::pair<unsigned int, unsigned int> >& theLayerIdWiresMap) {
0043 bool doChamber = fv.firstChild();
0044
0045
0046 while (doChamber) {
0047
0048 bool doSL = fv.firstChild();
0049 while (doSL) {
0050 bool doL = fv.firstChild();
0051
0052 while (doL) {
0053
0054 buildLayer(fv, muonConstants, theLayerIdWiresMap);
0055
0056 fv.parent();
0057 doL = fv.nextSibling();
0058 }
0059
0060 fv.parent();
0061 doSL = fv.nextSibling();
0062 }
0063
0064 fv.parent();
0065 doChamber = fv.nextSibling();
0066 }
0067 }
0068
0069 void DTGeometryParserFromDDD::buildLayer(DDFilteredView& fv,
0070 const MuonGeometryConstants& muonConstants,
0071 map<DTLayerId, std::pair<unsigned int, unsigned int> >& theLayerIdWiresMap) {
0072 MuonGeometryNumbering mdddnum(muonConstants);
0073 DTNumberingScheme dtnum(muonConstants);
0074 int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
0075 DTLayerId layId(rawid);
0076
0077
0078 bool doWire = fv.firstChild();
0079 int WCounter = 0;
0080 int firstWire = fv.copyno();
0081 while (doWire) {
0082 WCounter++;
0083 doWire = fv.nextSibling();
0084 }
0085 theLayerIdWiresMap[layId] = (make_pair(firstWire, WCounter));
0086 }