19 #include "xercesc/parsers/XercesDOMParser.hpp"
20 #include "xercesc/dom/DOM.hpp"
21 #include "xercesc/sax/HandlerBase.hpp"
22 #include "xercesc/util/XMLString.hpp"
23 #include "xercesc/util/PlatformUtils.hpp"
24 #include "xercesc/util/XercesDefs.hpp"
25 XERCES_CPP_NAMESPACE_USE
56 : m_fileName(fileName),
57 dtGeometry_(dtGeometry),
58 cscGeometry_(cscGeometry),
59 gemGeometry_(gemGeometry),
60 dtGeometryIdeal_(dtGeometryIdeal),
61 cscGeometryIdeal_(cscGeometryIdeal),
62 gemGeometryIdeal_(gemGeometryIdeal) {
66 str_name = XMLString::transcode(
"name");
93 str_rawId = XMLString::transcode(
"rawId");
94 str_wheel = XMLString::transcode(
"wheel");
98 str_layer = XMLString::transcode(
"layer");
100 str_ring = XMLString::transcode(
"ring");
104 str_axisx = XMLString::transcode(
"axisx");
105 str_axisy = XMLString::transcode(
"axisy");
106 str_axisz = XMLString::transcode(
"axisz");
107 str_angle = XMLString::transcode(
"angle");
108 str_x = XMLString::transcode(
"x");
109 str_y = XMLString::transcode(
"y");
110 str_z = XMLString::transcode(
"z");
111 str_phix = XMLString::transcode(
"phix");
112 str_phiy = XMLString::transcode(
"phiy");
113 str_phiz = XMLString::transcode(
"phiz");
114 str_alpha = XMLString::transcode(
"alpha");
115 str_beta = XMLString::transcode(
"beta");
116 str_gamma = XMLString::transcode(
"gamma");
117 str_rphi = XMLString::transcode(
"rphi");
118 str_phi = XMLString::transcode(
"phi");
119 str_xx = XMLString::transcode(
"xx");
120 str_xy = XMLString::transcode(
"xy");
121 str_xz = XMLString::transcode(
"xz");
122 str_xa = XMLString::transcode(
"xa");
123 str_xb = XMLString::transcode(
"xb");
124 str_xc = XMLString::transcode(
"xc");
125 str_yy = XMLString::transcode(
"yy");
126 str_yz = XMLString::transcode(
"yz");
127 str_ya = XMLString::transcode(
"ya");
128 str_yb = XMLString::transcode(
"yb");
129 str_yc = XMLString::transcode(
"yc");
130 str_zz = XMLString::transcode(
"zz");
131 str_za = XMLString::transcode(
"za");
132 str_zb = XMLString::transcode(
"zb");
133 str_zc = XMLString::transcode(
"zc");
134 str_aa = XMLString::transcode(
"aa");
135 str_ab = XMLString::transcode(
"ab");
136 str_ac = XMLString::transcode(
"ac");
137 str_bb = XMLString::transcode(
"bb");
138 str_bc = XMLString::transcode(
"bc");
139 str_cc = XMLString::transcode(
"cc");
140 str_none = XMLString::transcode(
"none");
141 str_ideal = XMLString::transcode(
"ideal");
251 for (align::Alignables::const_iterator ali = alignables.begin(); ali != alignables.end(); ++ali) {
261 alignableNavigator[(*ali)->geomDetId().rawId()] = *ali;
270 align::Alignables::const_iterator alignable = alignables.begin();
271 align::Alignables::const_iterator ideal = ideals.begin();
273 while (alignable != alignables.end() && ideal != ideals.end()) {
274 alitoideal[*alignable] = *ideal;
276 fillAliToIdeal(alitoideal, (*alignable)->components(), (*ideal)->components());
282 if (alignable != alignables.end() || ideal != ideals.end()) {
284 <<
"alignable and ideal-alignable trees are out of sync (this should never happen)";
290 std::map<unsigned int, Alignable *> alignableNavigator;
296 std::map<unsigned int, Alignable *> ideal_alignableNavigator;
297 recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->DTBarrel());
298 recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->CSCEndcaps());
299 recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->GEMEndcaps());
303 }
catch (
const XMLException &toCatch) {
304 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw an exception on initialization." << std::endl;
307 XercesDOMParser *
parser =
new XercesDOMParser();
308 parser->setValidationScheme(XercesDOMParser::Val_Always);
310 XERCES_CPP_NAMESPACE::ErrorHandler *errHandler = (XERCES_CPP_NAMESPACE::ErrorHandler *)(
new HandlerBase());
311 parser->setErrorHandler(errHandler);
315 }
catch (
const XMLException &toCatch) {
316 char *message = XMLString::transcode(toCatch.getMessage());
317 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw this exception: " << message << std::endl;
318 }
catch (
const DOMException &toCatch) {
319 char *message = XMLString::transcode(toCatch.msg);
320 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw this exception: " << message << std::endl;
321 }
catch (
const SAXException &toCatch) {
322 char *message = XMLString::transcode(toCatch.getMessage());
323 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw this exception: " << message << std::endl;
326 DOMDocument *doc = parser->getDocument();
327 DOMElement *node_MuonAlignment = doc->getDocumentElement();
328 DOMNodeList *collections = doc->getElementsByTagName(
str_collection);
329 DOMNodeList *operations = doc->getElementsByTagName(
str_operation);
331 std::map<Alignable *, Alignable *> alitoideal;
337 std::map<std::string, std::map<Alignable *, bool> > alicollections;
338 for (
unsigned int i = 0;
i < collections->getLength();
i++) {
339 DOMElement *
collection = (DOMElement *)(collections->item(
i));
340 if (collection->getParentNode() == node_MuonAlignment) {
341 DOMNodeList *children = collection->getChildNodes();
343 DOMAttr *node_name = collection->getAttributeNode(
str_name);
344 if (node_name ==
nullptr) {
345 throw cms::Exception(
"XMLException") <<
"<collection> requires a name attribute" << std::endl;
347 char *ascii_name = XMLString::transcode(node_name->getValue());
351 std::map<Alignable *, bool> aliset;
352 for (
unsigned int j = 0;
j < children->getLength();
j++) {
353 DOMNode *node = children->item(
j);
355 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
356 Alignable *ali =
getNode(alignableNavigator, (DOMElement *)(node), alignableObjectId);
357 if (ali ==
nullptr) {
358 throw cms::Exception(
"XMLException") <<
"<collection> must contain only alignables" << std::endl;
365 alicollections[
name] = aliset;
369 for (
unsigned int i = 0;
i < operations->getLength();
i++) {
370 DOMElement *operation = (DOMElement *)(operations->item(
i));
371 if (operation->getParentNode() != node_MuonAlignment) {
372 throw cms::Exception(
"XMLException") <<
"All operations must be top-level elements" << std::endl;
375 DOMNodeList *children = operation->getChildNodes();
377 std::map<Alignable *, bool> aliset;
378 std::vector<DOMNode *> nodesToRemove;
379 for (
unsigned int j = 0;
j < children->getLength();
j++) {
380 DOMNode *node = children->item(
j);
382 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
383 Alignable *ali =
getNode(alignableNavigator, (DOMElement *)(node), alignableObjectId);
384 if (ali !=
nullptr) {
386 nodesToRemove.push_back(node);
390 DOMAttr *node_name = ((DOMElement *)(node))->getAttributeNode(
str_name);
391 if (node_name ==
nullptr) {
392 throw cms::Exception(
"XMLException") <<
"<collection> requires a name attribute" << std::endl;
394 char *ascii_name = XMLString::transcode(node_name->getValue());
398 std::map<std::string, std::map<Alignable *, bool> >::const_iterator alicollections_iter =
399 alicollections.find(name);
400 if (alicollections_iter == alicollections.end()) {
402 <<
"<collection name=\"" << name <<
"\"> hasn't been defined" << std::endl;
405 for (std::map<Alignable *, bool>::const_iterator aliiter = alicollections_iter->second.begin();
406 aliiter != alicollections_iter->second.end();
408 aliset[aliiter->first] =
true;
411 nodesToRemove.push_back(node);
421 for (std::vector<DOMNode *>::const_iterator node = nodesToRemove.begin(); node != nodesToRemove.end(); ++node) {
422 operation->removeChild(*node);
424 children = operation->getChildNodes();
426 for (
unsigned int j = 0;
j < children->getLength();
j++) {
427 DOMNode *node = children->item(
j);
428 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
434 do_setape((DOMElement *)(node), aliset, alitoideal);
462 char *message = XMLString::transcode(node->getNodeName());
463 throw cms::Exception(
"XMLException") <<
"Unrecognized operation: \"" << message <<
"\"" << std::endl;
475 delete ideal_alignableMuon;
476 return alignableMuon;
480 const XERCES_CPP_NAMESPACE::DOMElement *node,
521 std::map<unsigned int, Alignable *> &alignableNavigator,
522 const XERCES_CPP_NAMESPACE::DOMElement *node,
524 unsigned int rawId = 0;
526 DOMAttr *node_rawId = node->getAttributeNode(
str_rawId);
527 if (node_rawId !=
nullptr) {
529 rawId = XMLString::parseInt(node_rawId->getValue());
530 }
catch (
const XMLException &toCatch) {
531 throw cms::Exception(
"XMLException") <<
"Value of \"rawId\" must be an integer" << std::endl;
535 wheel = station = sector = superlayer = layer = 1;
538 DOMAttr *node_wheel = node->getAttributeNode(
str_wheel);
539 if (node_wheel ==
nullptr)
540 throw cms::Exception(
"XMLException") <<
"DT node is missing required \"wheel\" attribute" << std::endl;
542 wheel = XMLString::parseInt(node_wheel->getValue());
543 }
catch (
const XMLException &toCatch) {
544 throw cms::Exception(
"XMLException") <<
"Value of \"wheel\" must be an integer" << std::endl;
548 DOMAttr *node_station = node->getAttributeNode(
str_station);
549 if (node_station ==
nullptr)
550 throw cms::Exception(
"XMLException") <<
"DT node is missing required \"station\" attribute" << std::endl;
552 station = XMLString::parseInt(node_station->getValue());
553 }
catch (
const XMLException &toCatch) {
554 throw cms::Exception(
"XMLException") <<
"Value of \"station\" must be an integer" << std::endl;
558 DOMAttr *node_sector = node->getAttributeNode(
str_sector);
559 if (node_sector ==
nullptr)
560 throw cms::Exception(
"XMLException") <<
"DT node is missing required \"sector\" attribute" << std::endl;
562 sector = XMLString::parseInt(node_sector->getValue());
563 }
catch (
const XMLException &toCatch) {
564 throw cms::Exception(
"XMLException") <<
"Value of \"sector\" must be an integer" << std::endl;
568 DOMAttr *node_superlayer = node->getAttributeNode(
str_superlayer);
569 if (node_superlayer ==
nullptr)
571 <<
"DT node is missing required \"superlayer\" attribute" << std::endl;
573 superlayer = XMLString::parseInt(node_superlayer->getValue());
574 }
catch (
const XMLException &toCatch) {
575 throw cms::Exception(
"XMLException") <<
"Value of \"superlayer\" must be an integer" << std::endl;
579 DOMAttr *node_layer = node->getAttributeNode(
str_layer);
580 if (node_layer ==
nullptr)
581 throw cms::Exception(
"XMLException") <<
"DT node is missing required \"layer\" attribute" << std::endl;
583 layer = XMLString::parseInt(node_layer->getValue());
584 }
catch (
const XMLException &toCatch) {
585 throw cms::Exception(
"XMLException") <<
"Value of \"layer\" must be an integer" << std::endl;
594 DTLayerId layerId(wheel, station, sector, superlayer, layer);
595 rawId = layerId.
rawId();
598 Alignable *ali = alignableNavigator[rawId];
600 throw cms::Exception(
"XMLException") <<
"rawId \"" << rawId <<
"\" is not recognized" << std::endl;
605 if (ali ==
nullptr) {
607 <<
"rawId \"" << rawId <<
"\" is not a " << alignableObjectId.
idToString(structureType) << std::endl;
614 std::map<unsigned int, Alignable *> &alignableNavigator,
615 const XERCES_CPP_NAMESPACE::DOMElement *node,
619 DOMAttr *node_rawId = node->getAttributeNode(
str_rawId);
620 if (node_rawId !=
nullptr) {
622 rawId = XMLString::parseInt(node_rawId->getValue());
623 }
catch (
const XMLException &toCatch) {
624 throw cms::Exception(
"XMLException") <<
"Value of \"rawId\" must be an integer" << std::endl;
628 endcap = station = ring = chamber = layer = 1;
630 DOMAttr *node_endcap = node->getAttributeNode(
str_endcap);
631 if (node_endcap ==
nullptr)
632 throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"endcap\" attribute" << std::endl;
634 endcap = XMLString::parseInt(node_endcap->getValue());
635 }
catch (
const XMLException &toCatch) {
636 throw cms::Exception(
"XMLException") <<
"Value of \"endcap\" must be an integer" << std::endl;
642 DOMAttr *node_station = node->getAttributeNode(
str_station);
643 if (node_station ==
nullptr)
644 throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"station\" attribute" << std::endl;
646 station = XMLString::parseInt(node_station->getValue());
647 }
catch (
const XMLException &toCatch) {
648 throw cms::Exception(
"XMLException") <<
"Value of \"station\" must be an integer" << std::endl;
652 DOMAttr *node_ring = node->getAttributeNode(
str_ring);
653 if (node_ring ==
nullptr)
654 throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"ring\" attribute" << std::endl;
656 ring = XMLString::parseInt(node_ring->getValue());
657 }
catch (
const XMLException &toCatch) {
658 throw cms::Exception(
"XMLException") <<
"Value of \"ring\" must be an integer" << std::endl;
662 DOMAttr *node_chamber = node->getAttributeNode(
str_chamber);
663 if (node_chamber ==
nullptr)
664 throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"chamber\" attribute" << std::endl;
666 chamber = XMLString::parseInt(node_chamber->getValue());
667 }
catch (
const XMLException &toCatch) {
668 throw cms::Exception(
"XMLException") <<
"Value of \"chamber\" must be an integer" << std::endl;
672 DOMAttr *node_layer = node->getAttributeNode(
str_layer);
673 if (node_layer ==
nullptr)
674 throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"layer\" attribute" << std::endl;
676 layer = XMLString::parseInt(node_layer->getValue());
677 }
catch (
const XMLException &toCatch) {
678 throw cms::Exception(
"XMLException") <<
"Value of \"layer\" must be an integer" << std::endl;
686 CSCDetId layerId(endcap, station, ring, chamber, layer);
687 rawId = layerId.
rawId();
690 Alignable *ali = alignableNavigator[rawId];
692 throw cms::Exception(
"XMLException") <<
"rawId \"" << rawId <<
"\" is not recognized" << std::endl;
697 if (ali ==
nullptr) {
699 <<
"rawId \"" << rawId <<
"\" is not a " << alignableObjectId.
idToString(structureType) << std::endl;
706 std::map<unsigned int, Alignable *> &alignableNavigator,
707 const XERCES_CPP_NAMESPACE::DOMElement *node,
711 DOMAttr *node_rawId = node->getAttributeNode(
str_rawId);
712 if (node_rawId !=
nullptr) {
714 rawId = XMLString::parseInt(node_rawId->getValue());
715 }
catch (
const XMLException &toCatch) {
716 throw cms::Exception(
"XMLException") <<
"Value of \"rawId\" must be an integer" << std::endl;
720 endcap = station = ring = superChamber = chamber = 1;
722 DOMAttr *node_endcap = node->getAttributeNode(
str_endcap);
723 if (node_endcap ==
nullptr)
724 throw cms::Exception(
"XMLException") <<
"GEM node is missing required \"endcap\" attribute" << std::endl;
726 endcap = XMLString::parseInt(node_endcap->getValue());
727 }
catch (
const XMLException &toCatch) {
728 throw cms::Exception(
"XMLException") <<
"Value of \"endcap\" must be an integer" << std::endl;
732 DOMAttr *node_station = node->getAttributeNode(
str_station);
733 if (node_station ==
nullptr)
734 throw cms::Exception(
"XMLException") <<
"GEM node is missing required \"station\" attribute" << std::endl;
736 station = XMLString::parseInt(node_station->getValue());
737 }
catch (
const XMLException &toCatch) {
738 throw cms::Exception(
"XMLException") <<
"Value of \"station\" must be an integer" << std::endl;
742 DOMAttr *node_ring = node->getAttributeNode(
str_ring);
743 if (node_ring ==
nullptr)
744 throw cms::Exception(
"XMLException") <<
"GEM node is missing required \"ring\" attribute" << std::endl;
746 ring = XMLString::parseInt(node_ring->getValue());
747 }
catch (
const XMLException &toCatch) {
748 throw cms::Exception(
"XMLException") <<
"Value of \"ring\" must be an integer" << std::endl;
752 DOMAttr *node_superChamber = node->getAttributeNode(
str_chamber);
753 if (node_superChamber ==
nullptr)
755 <<
"GEM node is missing required \"superChamber\" attribute" << std::endl;
757 superChamber = XMLString::parseInt(node_superChamber->getValue());
758 }
catch (
const XMLException &toCatch) {
759 throw cms::Exception(
"XMLException") <<
"Value of \"superChamber\" must be an integer" << std::endl;
763 DOMAttr *node_chamber = node->getAttributeNode(
str_chamber);
764 if (node_chamber ==
nullptr)
765 throw cms::Exception(
"XMLException") <<
"GEM node is missing required \"chamber\" attribute" << std::endl;
767 chamber = XMLString::parseInt(node_chamber->getValue());
768 }
catch (
const XMLException &toCatch) {
769 throw cms::Exception(
"XMLException") <<
"Value of \"chamber\" must be an integer" << std::endl;
777 GEMDetId chamberId(endcap, station, ring, 0, chamber, 0);
778 rawId = chamberId.
rawId();
781 Alignable *ali = alignableNavigator[rawId];
783 throw cms::Exception(
"XMLException") <<
"rawId \"" << rawId <<
"\" is not recognized" << std::endl;
788 if (ali ==
nullptr) {
790 <<
"rawId \"" << rawId <<
"\" is not a " << alignableObjectId.
idToString(structureType) << std::endl;
797 unsigned int len = XMLString::stringLen(str);
798 char *cstr = XMLString::transcode(str);
799 std::stringstream errmessage;
800 errmessage <<
"Value of \"" << attribute <<
"\" must be a double, not \"" << cstr <<
"\"" << std::endl;
805 if (cstr[i] ==
'-') {
808 }
else if (cstr[i] ==
'+')
813 while (cstr[i] !=
'.' && cstr[i] !=
'e' && cstr[i] !=
'E' && i < len) {
814 if (cstr[i] <
'0' || cstr[i] >
'9') {
820 output += cstr[
i] -
'0';
824 if (cstr[i] ==
'.') {
828 while (cstr[i] !=
'e' && cstr[i] !=
'E' && i < len) {
829 if (cstr[i] <
'0' || cstr[i] >
'9') {
834 output += (cstr[
i] -
'0') * place;
840 if (cstr[i] ==
'e' || cstr[i] ==
'E') {
844 bool expminus =
false;
845 if (cstr[i] ==
'-') {
848 }
else if (cstr[i] ==
'+')
852 if (cstr[i] <
'0' || cstr[i] >
'9') {
858 exponent += cstr[
i] -
'0';
865 output *=
pow(10., exponent);
876 std::map<Alignable *, bool> &aliset,
877 std::map<Alignable *, Alignable *> &alitoideal)
const {
878 DOMAttr *node_relativeto = node->getAttributeNode(
str_relativeto);
879 if (node_relativeto ==
nullptr)
880 throw cms::Exception(
"XMLException") <<
"<setposition> is missing required \"relativeto\" attribute" << std::endl;
890 char *message = XMLString::transcode(node_relativeto->getValue());
891 throw cms::Exception(
"XMLException") <<
"relativeto must be \"none\", \"ideal\", or \"container\", not \""
892 << message <<
"\"" << std::endl;
895 for (std::map<Alignable *, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
904 if (relativeto == 0) {
907 else if (relativeto == 1) {
915 else if (relativeto == 2 && ali->
mother() !=
nullptr) {
920 oldrot = oldrot * globalRotation.
transposed();
923 double x = oldpos.
x();
924 double y = oldpos.
y();
925 double z = oldpos.
z();
927 double phix = atan2(oldrot.
yz(), oldrot.
zz());
928 double phiy = asin(-oldrot.
xz());
929 double phiz = atan2(oldrot.
xy(), oldrot.
xx());
932 double alpha = oldEulerAngles(1);
933 double beta = oldEulerAngles(2);
934 double gamma = oldEulerAngles(3);
938 DOMAttr *node_x = node->getAttributeNode(
str_x);
939 DOMAttr *node_y = node->getAttributeNode(
str_y);
940 DOMAttr *node_z = node->getAttributeNode(
str_z);
942 if (node_x !=
nullptr)
944 if (node_y !=
nullptr)
946 if (node_z !=
nullptr)
950 DOMAttr *node_phix = node->getAttributeNode(
str_phix);
951 DOMAttr *node_phiy = node->getAttributeNode(
str_phiy);
952 DOMAttr *node_phiz = node->getAttributeNode(
str_phiz);
953 DOMAttr *node_alpha = node->getAttributeNode(
str_alpha);
954 DOMAttr *node_beta = node->getAttributeNode(
str_beta);
955 DOMAttr *node_gamma = node->getAttributeNode(
str_gamma);
958 bool phixyz = (node_phix !=
nullptr || node_phiy !=
nullptr || node_phiz !=
nullptr);
959 bool alphabetagamma = (node_alpha !=
nullptr || node_beta !=
nullptr || node_gamma !=
nullptr);
960 if (phixyz && alphabetagamma)
962 <<
"<setposition> must either have phix, phiy, and phiz or alpha, beta, and gamma, but not both" << std::endl;
963 if (!phixyz && !alphabetagamma)
964 alphabetagamma =
true;
967 if (node_phix !=
nullptr)
969 if (node_phiy !=
nullptr)
971 if (node_phiz !=
nullptr)
980 rot = rotX * rotY * rotZ;
983 else if (alphabetagamma) {
984 if (node_alpha !=
nullptr)
985 alpha =
parseDouble(node_alpha->getValue(),
"alpha");
986 if (node_beta !=
nullptr)
988 if (node_gamma !=
nullptr)
989 gamma =
parseDouble(node_gamma->getValue(),
"gamma");
993 eulerAngles(1) =
alpha;
994 eulerAngles(2) =
beta;
995 eulerAngles(3) = gamma;
1002 if (relativeto == 0) {
1006 else if (relativeto == 1) {
1019 else if (relativeto == 2) {
1023 if (container !=
nullptr) {
1074 if (survey !=
nullptr) {
1075 matrix6x6 = survey->
errors();
1081 std::map<Alignable *, bool> &aliset,
1082 std::map<Alignable *, Alignable *> &alitoideal)
const {
1083 DOMAttr *node_xx = node->getAttributeNode(
str_xx);
1084 DOMAttr *node_xy = node->getAttributeNode(
str_xy);
1085 DOMAttr *node_xz = node->getAttributeNode(
str_xz);
1086 DOMAttr *node_xa = node->getAttributeNode(
str_xa);
1087 DOMAttr *node_xb = node->getAttributeNode(
str_xb);
1088 DOMAttr *node_xc = node->getAttributeNode(
str_xc);
1089 DOMAttr *node_yy = node->getAttributeNode(
str_yy);
1090 DOMAttr *node_yz = node->getAttributeNode(
str_yz);
1091 DOMAttr *node_ya = node->getAttributeNode(
str_ya);
1092 DOMAttr *node_yb = node->getAttributeNode(
str_yb);
1093 DOMAttr *node_yc = node->getAttributeNode(
str_yc);
1094 DOMAttr *node_zz = node->getAttributeNode(
str_zz);
1095 DOMAttr *node_za = node->getAttributeNode(
str_za);
1096 DOMAttr *node_zb = node->getAttributeNode(
str_zb);
1097 DOMAttr *node_zc = node->getAttributeNode(
str_zc);
1098 DOMAttr *node_aa = node->getAttributeNode(
str_aa);
1099 DOMAttr *node_ab = node->getAttributeNode(
str_ab);
1100 DOMAttr *node_ac = node->getAttributeNode(
str_ac);
1101 DOMAttr *node_bb = node->getAttributeNode(
str_bb);
1102 DOMAttr *node_bc = node->getAttributeNode(
str_bc);
1103 DOMAttr *node_cc = node->getAttributeNode(
str_cc);
1105 if (node_xx ==
nullptr)
1106 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xx\" attribute" << std::endl;
1107 if (node_xy ==
nullptr)
1108 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xy\" attribute" << std::endl;
1109 if (node_xz ==
nullptr)
1110 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xz\" attribute" << std::endl;
1111 if (node_xa ==
nullptr)
1112 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xa\" attribute" << std::endl;
1113 if (node_xb ==
nullptr)
1114 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xb\" attribute" << std::endl;
1115 if (node_xc ==
nullptr)
1116 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xc\" attribute" << std::endl;
1117 if (node_yy ==
nullptr)
1118 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yy\" attribute" << std::endl;
1119 if (node_yz ==
nullptr)
1120 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yz\" attribute" << std::endl;
1121 if (node_ya ==
nullptr)
1122 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"ya\" attribute" << std::endl;
1123 if (node_yb ==
nullptr)
1124 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yb\" attribute" << std::endl;
1125 if (node_yc ==
nullptr)
1126 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yc\" attribute" << std::endl;
1127 if (node_zz ==
nullptr)
1128 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"zz\" attribute" << std::endl;
1129 if (node_za ==
nullptr)
1130 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"za\" attribute" << std::endl;
1131 if (node_zb ==
nullptr)
1132 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"zb\" attribute" << std::endl;
1133 if (node_zc ==
nullptr)
1134 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"zc\" attribute" << std::endl;
1135 if (node_aa ==
nullptr)
1136 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"aa\" attribute" << std::endl;
1137 if (node_ab ==
nullptr)
1138 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"ab\" attribute" << std::endl;
1139 if (node_ac ==
nullptr)
1140 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"ac\" attribute" << std::endl;
1141 if (node_bb ==
nullptr)
1142 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"bb\" attribute" << std::endl;
1143 if (node_bc ==
nullptr)
1144 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"bc\" attribute" << std::endl;
1145 if (node_cc ==
nullptr)
1146 throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"cc\" attribute" << std::endl;
1149 matrix6x6(0, 0) =
parseDouble(node_xx->getValue(),
"xx");
1150 matrix6x6(0, 1) =
parseDouble(node_xy->getValue(),
"xy");
1151 matrix6x6(0, 2) =
parseDouble(node_xz->getValue(),
"xz");
1152 matrix6x6(0, 3) =
parseDouble(node_xa->getValue(),
"xa");
1153 matrix6x6(0, 4) =
parseDouble(node_xb->getValue(),
"xb");
1154 matrix6x6(0, 5) =
parseDouble(node_xc->getValue(),
"xc");
1155 matrix6x6(1, 1) =
parseDouble(node_yy->getValue(),
"yy");
1156 matrix6x6(1, 2) =
parseDouble(node_yz->getValue(),
"yz");
1157 matrix6x6(1, 3) =
parseDouble(node_ya->getValue(),
"ya");
1158 matrix6x6(1, 4) =
parseDouble(node_yb->getValue(),
"yb");
1159 matrix6x6(1, 5) =
parseDouble(node_yc->getValue(),
"yc");
1160 matrix6x6(2, 2) =
parseDouble(node_zz->getValue(),
"zz");
1161 matrix6x6(2, 3) =
parseDouble(node_za->getValue(),
"za");
1162 matrix6x6(2, 4) =
parseDouble(node_zb->getValue(),
"zb");
1163 matrix6x6(2, 5) =
parseDouble(node_zc->getValue(),
"zc");
1164 matrix6x6(3, 3) =
parseDouble(node_aa->getValue(),
"aa");
1165 matrix6x6(3, 4) =
parseDouble(node_ab->getValue(),
"ab");
1166 matrix6x6(3, 5) =
parseDouble(node_ac->getValue(),
"ac");
1167 matrix6x6(4, 4) =
parseDouble(node_bb->getValue(),
"bb");
1168 matrix6x6(4, 5) =
parseDouble(node_bc->getValue(),
"bc");
1169 matrix6x6(5, 5) =
parseDouble(node_cc->getValue(),
"cc");
1171 for (std::map<Alignable *, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1178 std::map<Alignable *, bool> &aliset,
1179 std::map<Alignable *, Alignable *> &alitoideal)
const {
1180 DOMAttr *node_xx = node->getAttributeNode(
str_xx);
1181 DOMAttr *node_xy = node->getAttributeNode(
str_xy);
1182 DOMAttr *node_xz = node->getAttributeNode(
str_xz);
1183 DOMAttr *node_xa = node->getAttributeNode(
str_xa);
1184 DOMAttr *node_xb = node->getAttributeNode(
str_xb);
1185 DOMAttr *node_xc = node->getAttributeNode(
str_xc);
1186 DOMAttr *node_yy = node->getAttributeNode(
str_yy);
1187 DOMAttr *node_yz = node->getAttributeNode(
str_yz);
1188 DOMAttr *node_ya = node->getAttributeNode(
str_ya);
1189 DOMAttr *node_yb = node->getAttributeNode(
str_yb);
1190 DOMAttr *node_yc = node->getAttributeNode(
str_yc);
1191 DOMAttr *node_zz = node->getAttributeNode(
str_zz);
1192 DOMAttr *node_za = node->getAttributeNode(
str_za);
1193 DOMAttr *node_zb = node->getAttributeNode(
str_zb);
1194 DOMAttr *node_zc = node->getAttributeNode(
str_zc);
1195 DOMAttr *node_aa = node->getAttributeNode(
str_aa);
1196 DOMAttr *node_ab = node->getAttributeNode(
str_ab);
1197 DOMAttr *node_ac = node->getAttributeNode(
str_ac);
1198 DOMAttr *node_bb = node->getAttributeNode(
str_bb);
1199 DOMAttr *node_bc = node->getAttributeNode(
str_bc);
1200 DOMAttr *node_cc = node->getAttributeNode(
str_cc);
1202 if (node_xx ==
nullptr)
1203 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xx\" attribute" << std::endl;
1204 if (node_xy ==
nullptr)
1205 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xy\" attribute" << std::endl;
1206 if (node_xz ==
nullptr)
1207 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xz\" attribute" << std::endl;
1208 if (node_xa ==
nullptr)
1209 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xa\" attribute" << std::endl;
1210 if (node_xb ==
nullptr)
1211 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xb\" attribute" << std::endl;
1212 if (node_xc ==
nullptr)
1213 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xc\" attribute" << std::endl;
1214 if (node_yy ==
nullptr)
1215 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yy\" attribute" << std::endl;
1216 if (node_yz ==
nullptr)
1217 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yz\" attribute" << std::endl;
1218 if (node_ya ==
nullptr)
1219 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"ya\" attribute" << std::endl;
1220 if (node_yb ==
nullptr)
1221 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yb\" attribute" << std::endl;
1222 if (node_yc ==
nullptr)
1223 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yc\" attribute" << std::endl;
1224 if (node_zz ==
nullptr)
1225 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"zz\" attribute" << std::endl;
1226 if (node_za ==
nullptr)
1227 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"za\" attribute" << std::endl;
1228 if (node_zb ==
nullptr)
1229 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"zb\" attribute" << std::endl;
1230 if (node_zc ==
nullptr)
1231 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"zc\" attribute" << std::endl;
1232 if (node_aa ==
nullptr)
1233 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"aa\" attribute" << std::endl;
1234 if (node_ab ==
nullptr)
1235 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"ab\" attribute" << std::endl;
1236 if (node_ac ==
nullptr)
1237 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"ac\" attribute" << std::endl;
1238 if (node_bb ==
nullptr)
1239 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"bb\" attribute" << std::endl;
1240 if (node_bc ==
nullptr)
1241 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"bc\" attribute" << std::endl;
1242 if (node_cc ==
nullptr)
1243 throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"cc\" attribute" << std::endl;
1246 matrix6x6(0, 0) =
parseDouble(node_xx->getValue(),
"xx");
1247 matrix6x6(0, 1) =
parseDouble(node_xy->getValue(),
"xy");
1248 matrix6x6(0, 2) =
parseDouble(node_xz->getValue(),
"xz");
1249 matrix6x6(0, 3) =
parseDouble(node_xa->getValue(),
"xa");
1250 matrix6x6(0, 4) =
parseDouble(node_xb->getValue(),
"xb");
1251 matrix6x6(0, 5) =
parseDouble(node_xc->getValue(),
"xc");
1252 matrix6x6(1, 1) =
parseDouble(node_yy->getValue(),
"yy");
1253 matrix6x6(1, 2) =
parseDouble(node_yz->getValue(),
"yz");
1254 matrix6x6(1, 3) =
parseDouble(node_ya->getValue(),
"ya");
1255 matrix6x6(1, 4) =
parseDouble(node_yb->getValue(),
"yb");
1256 matrix6x6(1, 5) =
parseDouble(node_yc->getValue(),
"yc");
1257 matrix6x6(2, 2) =
parseDouble(node_zz->getValue(),
"zz");
1258 matrix6x6(2, 3) =
parseDouble(node_za->getValue(),
"za");
1259 matrix6x6(2, 4) =
parseDouble(node_zb->getValue(),
"zb");
1260 matrix6x6(2, 5) =
parseDouble(node_zc->getValue(),
"zc");
1261 matrix6x6(3, 3) =
parseDouble(node_aa->getValue(),
"aa");
1262 matrix6x6(3, 4) =
parseDouble(node_ab->getValue(),
"ab");
1263 matrix6x6(3, 5) =
parseDouble(node_ac->getValue(),
"ac");
1264 matrix6x6(4, 4) =
parseDouble(node_bb->getValue(),
"bb");
1265 matrix6x6(4, 5) =
parseDouble(node_bc->getValue(),
"bc");
1266 matrix6x6(5, 5) =
parseDouble(node_cc->getValue(),
"cc");
1268 for (std::map<Alignable *, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1275 std::map<Alignable *, bool> &aliset,
1276 std::map<Alignable *, Alignable *> &alitoideal)
const {
1277 DOMAttr *node_x = node->getAttributeNode(
str_x);
1278 DOMAttr *node_y = node->getAttributeNode(
str_y);
1279 DOMAttr *node_z = node->getAttributeNode(
str_z);
1280 if (node_x ==
nullptr)
1281 throw cms::Exception(
"XMLException") <<
"<moveglobal> is missing required \"x\" attribute" << std::endl;
1282 if (node_y ==
nullptr)
1283 throw cms::Exception(
"XMLException") <<
"<moveglobal> is missing required \"y\" attribute" << std::endl;
1284 if (node_z ==
nullptr)
1285 throw cms::Exception(
"XMLException") <<
"<moveglobal> is missing required \"z\" attribute" << std::endl;
1292 for (std::map<Alignable *, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1301 if (survey !=
nullptr) {
1302 matrix6x6 = survey->
errors();
1309 std::map<Alignable *, bool> &aliset,
1310 std::map<Alignable *, Alignable *> &alitoideal)
const {
1311 DOMAttr *node_x = node->getAttributeNode(
str_x);
1312 DOMAttr *node_y = node->getAttributeNode(
str_y);
1313 DOMAttr *node_z = node->getAttributeNode(
str_z);
1314 if (node_x ==
nullptr)
1315 throw cms::Exception(
"XMLException") <<
"<movelocal> is missing required \"x\" attribute" << std::endl;
1316 if (node_y ==
nullptr)
1317 throw cms::Exception(
"XMLException") <<
"<movelocal> is missing required \"y\" attribute" << std::endl;
1318 if (node_z ==
nullptr)
1319 throw cms::Exception(
"XMLException") <<
"<movelocal> is missing required \"z\" attribute" << std::endl;
1326 for (std::map<Alignable *, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1330 ali->
move(globalVector);
1336 if (survey !=
nullptr) {
1337 matrix6x6 = survey->
errors();
1344 std::map<Alignable *, bool> &aliset,
1345 std::map<Alignable *, Alignable *> &alitoideal)
const {
1346 DOMAttr *node_axisx = node->getAttributeNode(
str_axisx);
1347 DOMAttr *node_axisy = node->getAttributeNode(
str_axisy);
1348 DOMAttr *node_axisz = node->getAttributeNode(
str_axisz);
1349 DOMAttr *node_angle = node->getAttributeNode(
str_angle);
1350 if (node_axisx ==
nullptr)
1351 throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"axisx\" attribute" << std::endl;
1352 if (node_axisy ==
nullptr)
1353 throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"axisy\" attribute" << std::endl;
1354 if (node_axisz ==
nullptr)
1355 throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"axisz\" attribute" << std::endl;
1356 if (node_angle ==
nullptr)
1357 throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"angle\" attribute" << std::endl;
1365 for (std::map<Alignable *, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1374 if (survey !=
nullptr) {
1375 matrix6x6 = survey->
errors();
1382 std::map<Alignable *, bool> &aliset,
1383 std::map<Alignable *, Alignable *> &alitoideal)
const {
1384 DOMAttr *node_rphi = node->getAttributeNode(
str_rphi);
1385 DOMAttr *node_phi = node->getAttributeNode(
str_phi);
1386 if (node_rphi ==
nullptr && node_phi ==
nullptr)
1387 throw cms::Exception(
"XMLException") <<
"<rotatebeamline> is missing required \"*phi\" attribute" << std::endl;
1388 if (node_rphi !=
nullptr && node_phi !=
nullptr)
1389 throw cms::Exception(
"XMLException") <<
"<rotatebeamline> can't have both an \"rphi\" and a \"phi\" attribute"
1393 if (node_rphi !=
nullptr) {
1394 value =
parseDouble(node_rphi->getValue(),
"rphi");
1399 for (std::map<Alignable *, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1405 double phi0 = pos.
phi();
1406 double deltaphi =
value;
1407 if (node_rphi !=
nullptr)
1408 deltaphi = value /
radius;
1412 radius * (
cos(phi0 + deltaphi) -
cos(phi0)), radius * (
sin(phi0 + deltaphi) -
sin(phi0)), 0.));
1418 if (survey !=
nullptr) {
1419 matrix6x6 = survey->
errors();
1426 std::map<Alignable *, bool> &aliset,
1427 std::map<Alignable *, Alignable *> &alitoideal)
const {
1428 DOMAttr *node_x = node->getAttributeNode(
str_x);
1429 DOMAttr *node_y = node->getAttributeNode(
str_y);
1430 DOMAttr *node_z = node->getAttributeNode(
str_z);
1431 DOMAttr *node_angle = node->getAttributeNode(
str_angle);
1432 if (node_x ==
nullptr)
1433 throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"x\" attribute" << std::endl;
1434 if (node_y ==
nullptr)
1435 throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"y\" attribute" << std::endl;
1436 if (node_z ==
nullptr)
1437 throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"z\" attribute" << std::endl;
1438 if (node_angle ==
nullptr)
1439 throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"angle\" attribute" << std::endl;
1446 for (std::map<Alignable *, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1452 double aprime = x /
sqrt(x * x + y * y + z * z);
1453 double bprime = y /
sqrt(x * x + y * y + z * z);
1454 double cprime = z /
sqrt(x * x + y * y + z * z);
1455 double q0 =
cos(angle / 2.);
1456 double q1 =
sin(angle / 2.) * aprime;
1457 double q2 =
sin(angle / 2.) * bprime;
1458 double q3 =
sin(angle / 2.) * cprime;
1460 double pos2x = (q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3) * pos.
x() + 2. * (q1 * q2 - q0 * q3) * pos.
y() +
1461 2. * (q1 * q3 + q0 * q2) * pos.
z();
1462 double pos2y = 2. * (q2 * q1 + q0 * q3) * pos.
x() + (q0 * q0 - q1 * q1 + q2 * q2 - q3 * q3) * pos.
y() +
1463 2. * (q2 * q3 - q0 * q1) * pos.
z();
1464 double pos2z = 2. * (q3 * q1 - q0 * q2) * pos.
x() + 2. * (q3 * q2 + q0 * q1) * pos.
y() +
1465 (q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3) * pos.
z();
1467 double movex = pos2x - pos.
x();
1468 double movey = pos2y - pos.
y();
1469 double movez = pos2z - pos.
z();
1476 if (survey !=
nullptr) {
1477 matrix6x6 = survey->
errors();
TkRotation< Scalar > RotationType
virtual void rotateAroundLocalAxis(const LocalVector &axis, Scalar radians)
Rotation around arbitratry local axis.
Sin< T >::type sin(const T &t)
align::Alignables DTBarrel()
const SurveyDet * survey() const
Return survey info.
Geom::Phi< T > phi() const
constexpr uint32_t rawId() const
get the raw id
const RotationType & globalRotation() const
Return the global orientation of the object.
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
const align::ErrorMatrix & errors() const
const AlignableObjectId & objectIdProvider() const
Return muon alignable object ID provider derived from the muon system geometry.
virtual void rotateAroundGlobalAxis(const GlobalVector &axis, Scalar radians)
Rotation around arbitratry global axis.
constexpr std::array< uint8_t, layerIndexSize > layer
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
Point3DBase< Scalar, GlobalTag > PositionType
align::Alignables CSCEndcaps()
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
Cos< T >::type cos(const T &t)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Allows conversion between type and name, and vice-versa.
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
AlgebraicVector EulerAngles
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const char * idToString(align::StructureType type) const
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
void setSurvey(const SurveyDet *)
Set survey info.
std::vector< Alignable * > Alignables
align::Alignables GEMEndcaps()
TkRotation transposed() const
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
const PositionType & globalPosition() const
Return the global position of the object.
math::Error< 6 >::type ErrorMatrix
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
Constructor of the full muon geometry.
const BasicVectorType & basicVector() const
Alignable * mother() const
Return pointer to container alignable (if any)
Power< A, B >::type pow(const A &a, const B &b)
T angle(T x1, T y1, T z1, T x2, T y2, T z2)