CMS 3D CMS Logo

DTGeometryParserFromDDD.cc
Go to the documentation of this file.
1 
8 
9 using namespace std;
10 
11 
12 DTGeometryParserFromDDD::DTGeometryParserFromDDD(const DDCompactView* cview, const MuonDDDConstants& muonConstants, map<DTLayerId,std::pair<unsigned int,unsigned int> > &theLayerIdWiresMap ){
13 
14  try {
15  std::string attribute = "MuStructure";
16  std::string value = "MuonBarrelDT";
17 
18  // Asking only for the Muon DTs
19  DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
20  DDFilteredView fview(*cview,filter);
21 
22  parseGeometry(fview, muonConstants, theLayerIdWiresMap);
23  }
24  catch (const cms::Exception & e ) {
25  std::cerr << "DTGeometryParserFromDDD::build() : DDD Exception: something went wrong during XML parsing!" << std::endl
26  << " Message: " << e << std::endl
27  << " Terminating execution ... " << std::endl;
28  throw;
29  }
30  catch (const exception & e) {
31  std::cerr << "DTGeometryParserFromDDD::build() : an unexpected exception occured: " << e.what() << std::endl;
32  throw;
33  }
34  catch (...) {
35  std::cerr << "DTGeometryParserFromDDD::build() : An unexpected exception occured!" << std::endl
36  << " Terminating execution ... " << std::endl;
37  std::unexpected();
38  }
39 }
40 
42 }
43 
44 void DTGeometryParserFromDDD::parseGeometry(DDFilteredView& fv, const MuonDDDConstants& muonConstants, map<DTLayerId,std::pair<unsigned int,unsigned int> > &theLayerIdWiresMap ) {
45 
46  bool doChamber = fv.firstChild();
47 
48  // Loop on chambers
49  int ChamCounter=0;
50  while (doChamber){
51  ChamCounter++;
52 
53  // Loop on SLs
54  bool doSL = fv.firstChild();
55  int SLCounter=0;
56  while (doSL) {
57  SLCounter++;
58 
59  bool doL = fv.firstChild();
60  int LCounter=0;
61  // Loop on SLs
62  while (doL) {
63  LCounter++;
64  //DTLayer* layer =
65  buildLayer(fv, muonConstants, theLayerIdWiresMap);
66 
67  fv.parent();
68  doL = fv.nextSibling(); // go to next layer
69  } // layers
70 
71  fv.parent();
72  doSL = fv.nextSibling(); // go to next SL
73  } // sls
74 
75  fv.parent();
76  doChamber = fv.nextSibling(); // go to next chamber
77  } // chambers
78 
79 }
80 
81 
83  map<DTLayerId,std::pair<unsigned int,unsigned int> > &theLayerIdWiresMap ) {
84  MuonDDDNumbering mdddnum(muonConstants);
85  DTNumberingScheme dtnum(muonConstants);
86  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
87  DTLayerId layId(rawid);
88 
89  // Loop on wires
90  bool doWire = fv.firstChild();
91  int WCounter=0;
92  int firstWire=fv.copyno();
93  while (doWire) {
94  WCounter++;
95  doWire = fv.nextSibling(); // next wire
96  }
97  theLayerIdWiresMap[layId] = (make_pair(firstWire,WCounter));
98 }
99 
bool parent()
set the current node to the parent node ...
void parseGeometry(DDFilteredView &fv, const MuonDDDConstants &muonConstants, std::map< DTLayerId, std::pair< unsigned int, unsigned int > > &theLayerIdWiresMap)
bool nextSibling()
set the current node to the next sibling ...
DTGeometryParserFromDDD(const DDCompactView *cview, const MuonDDDConstants &muonConstants, std::map< DTLayerId, std::pair< unsigned int, unsigned int > > &theLayerIdWiresMap)
Constructor.
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
int copyno() const
Copy number associated with the current node.
Definition: value.py:1
int getDetId(const MuonBaseNumber &num) const
bool firstChild()
set the current node to the first child ...
MuonBaseNumber geoHistoryToBaseNumber(const DDGeoHistory &history)
void buildLayer(DDFilteredView &fv, const MuonDDDConstants &muonConstants, std::map< DTLayerId, std::pair< unsigned int, unsigned int > > &theLayerIdWiresMap)