Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-05-10 03:53:10

0001 /** \file
0002  *
0003  *  \author S. Bolognesi - INFN To 
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     // Asking only for the Muon DTs
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               << "  Terminating execution ... " << std::endl;
0029     throw;
0030   } catch (const exception& e) {
0031     std::cerr << "DTGeometryParserFromDDD::build() : an unexpected exception occured: " << e.what() << std::endl;
0032     throw;
0033   } catch (...) {
0034     std::cerr << "DTGeometryParserFromDDD::build() : An unexpected exception occured!" << std::endl
0035               << "  Terminating execution ... " << std::endl;
0036     std::unexpected();
0037   }
0038 }
0039 
0040 DTGeometryParserFromDDD::~DTGeometryParserFromDDD() {}
0041 
0042 void DTGeometryParserFromDDD::parseGeometry(DDFilteredView& fv,
0043                                             const MuonGeometryConstants& muonConstants,
0044                                             map<DTLayerId, std::pair<unsigned int, unsigned int> >& theLayerIdWiresMap) {
0045   bool doChamber = fv.firstChild();
0046 
0047   // Loop on chambers
0048   while (doChamber) {
0049     // Loop on SLs
0050     bool doSL = fv.firstChild();
0051     while (doSL) {
0052       bool doL = fv.firstChild();
0053       // Loop on SLs
0054       while (doL) {
0055         //DTLayer* layer =
0056         buildLayer(fv, muonConstants, theLayerIdWiresMap);
0057 
0058         fv.parent();
0059         doL = fv.nextSibling();  // go to next layer
0060       }                          // layers
0061 
0062       fv.parent();
0063       doSL = fv.nextSibling();  // go to next SL
0064     }                           // sls
0065 
0066     fv.parent();
0067     doChamber = fv.nextSibling();  // go to next chamber
0068   }                                // chambers
0069 }
0070 
0071 void DTGeometryParserFromDDD::buildLayer(DDFilteredView& fv,
0072                                          const MuonGeometryConstants& muonConstants,
0073                                          map<DTLayerId, std::pair<unsigned int, unsigned int> >& theLayerIdWiresMap) {
0074   MuonGeometryNumbering mdddnum(muonConstants);
0075   DTNumberingScheme dtnum(muonConstants);
0076   int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
0077   DTLayerId layId(rawid);
0078 
0079   // Loop on wires
0080   bool doWire = fv.firstChild();
0081   int WCounter = 0;
0082   int firstWire = fv.copyno();
0083   while (doWire) {
0084     WCounter++;
0085     doWire = fv.nextSibling();  // next wire
0086   }
0087   theLayerIdWiresMap[layId] = (make_pair(firstWire, WCounter));
0088 }