Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:39

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   int ChamCounter = 0;
0049   while (doChamber) {
0050     ChamCounter++;
0051 
0052     // Loop on SLs
0053     bool doSL = fv.firstChild();
0054     int SLCounter = 0;
0055     while (doSL) {
0056       SLCounter++;
0057 
0058       bool doL = fv.firstChild();
0059       int LCounter = 0;
0060       // Loop on SLs
0061       while (doL) {
0062         LCounter++;
0063         //DTLayer* layer =
0064         buildLayer(fv, muonConstants, theLayerIdWiresMap);
0065 
0066         fv.parent();
0067         doL = fv.nextSibling();  // go to next layer
0068       }                          // layers
0069 
0070       fv.parent();
0071       doSL = fv.nextSibling();  // go to next SL
0072     }                           // sls
0073 
0074     fv.parent();
0075     doChamber = fv.nextSibling();  // go to next chamber
0076   }                                // chambers
0077 }
0078 
0079 void DTGeometryParserFromDDD::buildLayer(DDFilteredView& fv,
0080                                          const MuonGeometryConstants& muonConstants,
0081                                          map<DTLayerId, std::pair<unsigned int, unsigned int> >& theLayerIdWiresMap) {
0082   MuonGeometryNumbering mdddnum(muonConstants);
0083   DTNumberingScheme dtnum(muonConstants);
0084   int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
0085   DTLayerId layId(rawid);
0086 
0087   // Loop on wires
0088   bool doWire = fv.firstChild();
0089   int WCounter = 0;
0090   int firstWire = fv.copyno();
0091   while (doWire) {
0092     WCounter++;
0093     doWire = fv.nextSibling();  // next wire
0094   }
0095   theLayerIdWiresMap[layId] = (make_pair(firstWire, WCounter));
0096 }