Go to the documentation of this file.00001
00008 #include "DTGeometryParserFromDDD.h"
00009 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00010
00011 using namespace std;
00012
00013
00014 DTGeometryParserFromDDD::DTGeometryParserFromDDD(const DDCompactView* cview, const MuonDDDConstants& muonConstants, map<DTLayerId,std::pair<unsigned int,unsigned int> > &theLayerIdWiresMap ){
00015
00016 try {
00017 std::string attribute = "MuStructure";
00018 std::string value = "MuonBarrelDT";
00019 DDValue val(attribute, value, 0.0);
00020
00021
00022 DDSpecificsFilter filter;
00023 filter.setCriteria(val,
00024 DDSpecificsFilter::matches,
00025 DDSpecificsFilter::AND,
00026 true,
00027 true
00028 );
00029 DDFilteredView fview(*cview);
00030 fview.addFilter(filter);
00031
00032 parseGeometry(fview, muonConstants, theLayerIdWiresMap);
00033 }
00034 catch (const DDException & e ) {
00035 std::cerr << "DTGeometryParserFromDDD::build() : DDD Exception: something went wrong during XML parsing!" << std::endl
00036 << " Message: " << e << std::endl
00037 << " Terminating execution ... " << std::endl;
00038 throw;
00039 }
00040 catch (const exception & e) {
00041 std::cerr << "DTGeometryParserFromDDD::build() : an unexpected exception occured: " << e.what() << std::endl;
00042 throw;
00043 }
00044 catch (...) {
00045 std::cerr << "DTGeometryParserFromDDD::build() : An unexpected exception occured!" << std::endl
00046 << " Terminating execution ... " << std::endl;
00047 std::unexpected();
00048 }
00049 }
00050
00051 DTGeometryParserFromDDD::~DTGeometryParserFromDDD(){
00052 }
00053
00054 void DTGeometryParserFromDDD::parseGeometry(DDFilteredView& fv, const MuonDDDConstants& muonConstants, map<DTLayerId,std::pair<unsigned int,unsigned int> > &theLayerIdWiresMap ) {
00055
00056 bool doChamber = fv.firstChild();
00057
00058
00059 int ChamCounter=0;
00060 while (doChamber){
00061 ChamCounter++;
00062
00063
00064 bool doSL = fv.firstChild();
00065 int SLCounter=0;
00066 while (doSL) {
00067 SLCounter++;
00068
00069 bool doL = fv.firstChild();
00070 int LCounter=0;
00071
00072 while (doL) {
00073 LCounter++;
00074
00075 buildLayer(fv, muonConstants, theLayerIdWiresMap);
00076
00077 fv.parent();
00078 doL = fv.nextSibling();
00079 }
00080
00081 fv.parent();
00082 doSL = fv.nextSibling();
00083 }
00084
00085 fv.parent();
00086 doChamber = fv.nextSibling();
00087 }
00088
00089 }
00090
00091
00092 void DTGeometryParserFromDDD::buildLayer(DDFilteredView& fv, const MuonDDDConstants& muonConstants,
00093 map<DTLayerId,std::pair<unsigned int,unsigned int> > &theLayerIdWiresMap ) {
00094 MuonDDDNumbering mdddnum(muonConstants);
00095 DTNumberingScheme dtnum(muonConstants);
00096 int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
00097 DTLayerId layId(rawid);
00098
00099
00100 bool doWire = fv.firstChild();
00101 int WCounter=0;
00102 int firstWire=fv.copyno();
00103 while (doWire) {
00104 WCounter++;
00105 doWire = fv.nextSibling();
00106 }
00107 theLayerIdWiresMap[layId] = (make_pair(firstWire,WCounter));
00108 }
00109