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" 48 : m_fileName(fileName)
53 str_name = XMLString::transcode(
"name");
74 str_rawId = XMLString::transcode(
"rawId");
75 str_wheel = XMLString::transcode(
"wheel");
79 str_layer = XMLString::transcode(
"layer");
81 str_ring = XMLString::transcode(
"ring");
83 str_axisx = XMLString::transcode(
"axisx");
84 str_axisy = XMLString::transcode(
"axisy");
85 str_axisz = XMLString::transcode(
"axisz");
86 str_angle = XMLString::transcode(
"angle");
87 str_x = XMLString::transcode(
"x");
88 str_y = XMLString::transcode(
"y");
89 str_z = XMLString::transcode(
"z");
90 str_phix = XMLString::transcode(
"phix");
91 str_phiy = XMLString::transcode(
"phiy");
92 str_phiz = XMLString::transcode(
"phiz");
93 str_alpha = XMLString::transcode(
"alpha");
94 str_beta = XMLString::transcode(
"beta");
95 str_gamma = XMLString::transcode(
"gamma");
96 str_rphi = XMLString::transcode(
"rphi");
97 str_phi = XMLString::transcode(
"phi");
98 str_xx = XMLString::transcode(
"xx");
99 str_xy = XMLString::transcode(
"xy");
100 str_xz = XMLString::transcode(
"xz");
101 str_xa = XMLString::transcode(
"xa");
102 str_xb = XMLString::transcode(
"xb");
103 str_xc = XMLString::transcode(
"xc");
104 str_yy = XMLString::transcode(
"yy");
105 str_yz = XMLString::transcode(
"yz");
106 str_ya = XMLString::transcode(
"ya");
107 str_yb = XMLString::transcode(
"yb");
108 str_yc = XMLString::transcode(
"yc");
109 str_zz = XMLString::transcode(
"zz");
110 str_za = XMLString::transcode(
"za");
111 str_zb = XMLString::transcode(
"zb");
112 str_zc = XMLString::transcode(
"zc");
113 str_aa = XMLString::transcode(
"aa");
114 str_ab = XMLString::transcode(
"ab");
115 str_ac = XMLString::transcode(
"ac");
116 str_bb = XMLString::transcode(
"bb");
117 str_bc = XMLString::transcode(
"bc");
118 str_cc = XMLString::transcode(
"cc");
119 str_none = XMLString::transcode(
"none");
120 str_ideal = XMLString::transcode(
"ideal");
221 for (align::Alignables::const_iterator ali = alignables.begin(); ali != alignables.end(); ++ali) {
225 alignableNavigator[(*ali)->geomDetId().rawId()] = *ali;
232 align::Alignables::const_iterator alignable = alignables.begin();
233 align::Alignables::const_iterator ideal = ideals.begin();
235 while (alignable != alignables.end() && ideal != ideals.end()) {
236 alitoideal[*alignable] = *ideal;
238 fillAliToIdeal(alitoideal, (*alignable)->components(), (*ideal)->components());
244 if (alignable != alignables.end() || ideal != ideals.end()) {
245 throw cms::Exception(
"Alignment") <<
"alignable and ideal-alignable trees are out of sync (this should never happen)";
254 std::map<unsigned int, Alignable*> alignableNavigator;
259 std::map<unsigned int, Alignable*> ideal_alignableNavigator;
260 recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->DTBarrel());
261 recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->CSCEndcaps());
266 catch (
const XMLException &toCatch) {
267 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw an exception on initialization." << std::endl;
270 XercesDOMParser *
parser =
new XercesDOMParser();
271 parser->setValidationScheme(XercesDOMParser::Val_Always);
273 XERCES_CPP_NAMESPACE::ErrorHandler *errHandler = (XERCES_CPP_NAMESPACE::ErrorHandler*)(
new HandlerBase());
274 parser->setErrorHandler(errHandler);
279 catch (
const XMLException &toCatch) {
280 char *
message = XMLString::transcode(toCatch.getMessage());
281 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw this exception: " << message << std::endl;
283 catch (
const DOMException &toCatch) {
284 char *
message = XMLString::transcode(toCatch.msg);
285 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw this exception: " << message << std::endl;
287 catch (
const SAXException &toCatch) {
288 char *
message = XMLString::transcode(toCatch.getMessage());
289 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw this exception: " << message << std::endl;
292 DOMDocument *
doc = parser->getDocument();
293 DOMElement *node_MuonAlignment = doc->getDocumentElement();
294 DOMNodeList *collections = doc->getElementsByTagName(
str_collection);
295 DOMNodeList *operations = doc->getElementsByTagName(
str_operation);
297 std::map<Alignable*, Alignable*> alitoideal;
302 std::map<std::string, std::map<Alignable*, bool> > alicollections;
303 for (
unsigned int i = 0;
i < collections->getLength();
i++) {
304 DOMElement *
collection = (DOMElement*)(collections->item(
i));
305 if (collection->getParentNode() == node_MuonAlignment) {
306 DOMNodeList *
children = collection->getChildNodes();
308 DOMAttr *node_name = collection->getAttributeNode(
str_name);
309 if (node_name ==
nullptr) {
310 throw cms::Exception(
"XMLException") <<
"<collection> requires a name attribute" << std::endl;
312 char *ascii_name = XMLString::transcode(node_name->getValue());
316 std::map<Alignable*, bool> aliset;
317 for (
unsigned int j = 0; j < children->getLength(); j++) {
318 DOMNode *node = children->item(j);
320 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
321 Alignable *ali =
getNode(alignableNavigator, (DOMElement*)(node), alignableObjectId);
322 if (ali ==
nullptr) {
323 throw cms::Exception(
"XMLException") <<
"<collection> must contain only alignables" << std::endl;
330 alicollections[
name] = aliset;
334 for (
unsigned int i = 0;
i < operations->getLength();
i++) {
335 DOMElement *operation = (DOMElement*)(operations->item(
i));
336 if (operation->getParentNode() != node_MuonAlignment) {
337 throw cms::Exception(
"XMLException") <<
"All operations must be top-level elements" << std::endl;
340 DOMNodeList *
children = operation->getChildNodes();
342 std::map<Alignable*, bool> aliset;
343 std::vector<DOMNode*> nodesToRemove;
344 for (
unsigned int j = 0; j < children->getLength(); j++) {
345 DOMNode *node = children->item(j);
347 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
348 Alignable *ali =
getNode(alignableNavigator, (DOMElement*)(node), alignableObjectId);
349 if (ali !=
nullptr) {
351 nodesToRemove.push_back(node);
355 DOMAttr *node_name = ((DOMElement*)(node))->getAttributeNode(
str_name);
356 if (node_name ==
nullptr) {
357 throw cms::Exception(
"XMLException") <<
"<collection> requires a name attribute" << std::endl;
359 char *ascii_name = XMLString::transcode(node_name->getValue());
363 std::map<std::string, std::map<Alignable*, bool> >::const_iterator alicollections_iter = alicollections.find(name);
364 if (alicollections_iter == alicollections.end()) {
365 throw cms::Exception(
"XMLException") <<
"<collection name=\"" << name <<
"\"> hasn't been defined" << std::endl;
368 for (std::map<Alignable*, bool>::const_iterator aliiter = alicollections_iter->second.begin();
369 aliiter != alicollections_iter->second.end();
371 aliset[aliiter->first] =
true;
374 nodesToRemove.push_back(node);
383 for (std::vector<DOMNode*>::const_iterator node = nodesToRemove.begin(); node != nodesToRemove.end(); ++node) {
384 operation->removeChild(*node);
386 children = operation->getChildNodes();
388 for (
unsigned int j = 0; j < children->getLength(); j++) {
389 DOMNode *node = children->item(j);
390 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
397 do_setape((DOMElement*)(node), aliset, alitoideal);
425 char *
message = XMLString::transcode(node->getNodeName());
426 throw cms::Exception(
"XMLException") <<
"Unrecognized operation: \"" << message <<
"\"" << std::endl;
438 delete ideal_alignableMuon;
439 return alignableMuon;
443 const XERCES_CPP_NAMESPACE::DOMElement *node,
460 std::map<unsigned int, Alignable*> &alignableNavigator,
const XERCES_CPP_NAMESPACE::DOMElement *node,
462 unsigned int rawId = 0;
464 DOMAttr *node_rawId = node->getAttributeNode(
str_rawId);
465 if (node_rawId !=
nullptr) {
467 rawId = XMLString::parseInt(node_rawId->getValue());
469 catch (
const XMLException &toCatch) {
470 throw cms::Exception(
"XMLException") <<
"Value of \"rawId\" must be an integer" << std::endl;
475 wheel = station = sector = superlayer = layer = 1;
478 DOMAttr *node_wheel = node->getAttributeNode(
str_wheel);
479 if (node_wheel ==
nullptr)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"wheel\" attribute" << std::endl;
481 wheel = XMLString::parseInt(node_wheel->getValue());
483 catch (
const XMLException &toCatch) {
484 throw cms::Exception(
"XMLException") <<
"Value of \"wheel\" must be an integer" << std::endl;
488 DOMAttr *node_station = node->getAttributeNode(
str_station);
489 if (node_station ==
nullptr)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"station\" attribute" << std::endl;
491 station = XMLString::parseInt(node_station->getValue());
493 catch (
const XMLException &toCatch) {
494 throw cms::Exception(
"XMLException") <<
"Value of \"station\" must be an integer" << std::endl;
498 DOMAttr *node_sector = node->getAttributeNode(
str_sector);
499 if (node_sector ==
nullptr)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"sector\" attribute" << std::endl;
501 sector = XMLString::parseInt(node_sector->getValue());
503 catch (
const XMLException &toCatch) {
504 throw cms::Exception(
"XMLException") <<
"Value of \"sector\" must be an integer" << std::endl;
508 DOMAttr *node_superlayer = node->getAttributeNode(
str_superlayer);
509 if (node_superlayer ==
nullptr)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"superlayer\" attribute" << std::endl;
511 superlayer = XMLString::parseInt(node_superlayer->getValue());
513 catch (
const XMLException &toCatch) {
514 throw cms::Exception(
"XMLException") <<
"Value of \"superlayer\" must be an integer" << std::endl;
518 DOMAttr *node_layer = node->getAttributeNode(
str_layer);
519 if (node_layer ==
nullptr)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"layer\" attribute" << std::endl;
521 layer = XMLString::parseInt(node_layer->getValue());
523 catch (
const XMLException &toCatch) {
524 throw cms::Exception(
"XMLException") <<
"Value of \"layer\" must be an integer" << std::endl;
533 DTLayerId layerId(wheel, station, sector, superlayer, layer);
534 rawId = layerId.
rawId();
537 Alignable *ali = alignableNavigator[rawId];
538 if (ali ==
nullptr)
throw cms::Exception(
"XMLException") <<
"rawId \"" << rawId <<
"\" is not recognized" << std::endl;
543 if (ali ==
nullptr) {
545 <<
"rawId \"" << rawId <<
"\" is not a " 546 << alignableObjectId.
idToString(structureType) << std::endl;
553 std::map<unsigned int, Alignable*> &alignableNavigator,
const XERCES_CPP_NAMESPACE::DOMElement *node,
557 DOMAttr *node_rawId = node->getAttributeNode(
str_rawId);
558 if (node_rawId !=
nullptr) {
560 rawId = XMLString::parseInt(node_rawId->getValue());
562 catch (
const XMLException &toCatch) {
563 throw cms::Exception(
"XMLException") <<
"Value of \"rawId\" must be an integer" << std::endl;
568 endcap = station = ring = chamber = layer = 1;
570 DOMAttr *node_endcap = node->getAttributeNode(
str_endcap);
571 if (node_endcap ==
nullptr)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"endcap\" attribute" << std::endl;
573 endcap = XMLString::parseInt(node_endcap->getValue());
575 catch (
const XMLException &toCatch) {
576 throw cms::Exception(
"XMLException") <<
"Value of \"endcap\" must be an integer" << std::endl;
578 if (endcap == -1) endcap = 2;
581 DOMAttr *node_station = node->getAttributeNode(
str_station);
582 if (node_station ==
nullptr)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"station\" attribute" << std::endl;
584 station = XMLString::parseInt(node_station->getValue());
586 catch (
const XMLException &toCatch) {
587 throw cms::Exception(
"XMLException") <<
"Value of \"station\" must be an integer" << std::endl;
591 DOMAttr *node_ring = node->getAttributeNode(
str_ring);
592 if (node_ring ==
nullptr)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"ring\" attribute" << std::endl;
594 ring = XMLString::parseInt(node_ring->getValue());
596 catch (
const XMLException &toCatch) {
597 throw cms::Exception(
"XMLException") <<
"Value of \"ring\" must be an integer" << std::endl;
601 DOMAttr *node_chamber = node->getAttributeNode(
str_chamber);
602 if (node_chamber ==
nullptr)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"chamber\" attribute" << std::endl;
604 chamber = XMLString::parseInt(node_chamber->getValue());
606 catch (
const XMLException &toCatch) {
607 throw cms::Exception(
"XMLException") <<
"Value of \"chamber\" must be an integer" << std::endl;
611 DOMAttr *node_layer = node->getAttributeNode(
str_layer);
612 if (node_layer ==
nullptr)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"layer\" attribute" << std::endl;
614 layer = XMLString::parseInt(node_layer->getValue());
616 catch (
const XMLException &toCatch) {
617 throw cms::Exception(
"XMLException") <<
"Value of \"layer\" must be an integer" << std::endl;
625 CSCDetId layerId(endcap, station, ring, chamber, layer);
626 rawId = layerId.
rawId();
629 Alignable *ali = alignableNavigator[rawId];
630 if (ali ==
nullptr)
throw cms::Exception(
"XMLException") <<
"rawId \"" << rawId <<
"\" is not recognized" << std::endl;
635 if (ali ==
nullptr) {
637 <<
"rawId \"" << rawId <<
"\" is not a " 638 << alignableObjectId.
idToString(structureType) << std::endl;
645 unsigned int len = XMLString::stringLen(str);
646 char *cstr = XMLString::transcode(str);
647 std::stringstream errmessage;
648 errmessage <<
"Value of \"" << attribute <<
"\" must be a double, not \"" << cstr <<
"\"" << std::endl;
653 if (cstr[i] ==
'-') {
657 else if (cstr[i] ==
'+') i++;
661 while (cstr[i] !=
'.' && cstr[i] !=
'e' && cstr[i] !=
'E' && i < len) {
662 if (cstr[i] <
'0' || cstr[i] >
'9') {
668 output += cstr[
i] -
'0';
672 if (cstr[i] ==
'.') {
676 while (cstr[i] !=
'e' && cstr[i] !=
'E' && i < len) {
677 if (cstr[i] <
'0' || cstr[i] >
'9') {
682 output += (cstr[
i] -
'0') * place;
688 if (cstr[i] ==
'e' || cstr[i] ==
'E') {
692 bool expminus =
false;
693 if (cstr[i] ==
'-') {
697 else if (cstr[i] ==
'+') i++;
700 if (cstr[i] <
'0' || cstr[i] >
'9') {
706 exponent += cstr[
i] -
'0';
710 if (expminus) exponent *= -1;
712 output *=
pow(10., exponent);
715 if (minus) output *= -1.;
722 DOMAttr *node_relativeto = node->getAttributeNode(
str_relativeto);
723 if (node_relativeto ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setposition> is missing required \"relativeto\" attribute" << std::endl;
736 char *
message = XMLString::transcode(node_relativeto->getValue());
737 throw cms::Exception(
"XMLException") <<
"relativeto must be \"none\", \"ideal\", or \"container\", not \"" << message <<
"\"" << std::endl;
740 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
749 if (relativeto == 0) {}
751 else if (relativeto == 1) {
759 else if (relativeto == 2 && ali->
mother() !=
nullptr) {
764 oldrot = oldrot * globalRotation.
transposed();
767 double x = oldpos.
x();
768 double y = oldpos.
y();
769 double z = oldpos.
z();
771 double phix = atan2(oldrot.
yz(), oldrot.
zz());
772 double phiy = asin(-oldrot.
xz());
773 double phiz = atan2(oldrot.
xy(), oldrot.
xx());
776 double alpha = oldEulerAngles(1);
777 double beta = oldEulerAngles(2);
778 double gamma = oldEulerAngles(3);
782 DOMAttr *node_x = node->getAttributeNode(
str_x);
783 DOMAttr *node_y = node->getAttributeNode(
str_y);
784 DOMAttr *node_z = node->getAttributeNode(
str_z);
786 if (node_x !=
nullptr) x =
parseDouble(node_x->getValue(),
"x");
787 if (node_y !=
nullptr) y =
parseDouble(node_y->getValue(),
"y");
788 if (node_z !=
nullptr) z =
parseDouble(node_z->getValue(),
"z");
791 DOMAttr *node_phix = node->getAttributeNode(
str_phix);
792 DOMAttr *node_phiy = node->getAttributeNode(
str_phiy);
793 DOMAttr *node_phiz = node->getAttributeNode(
str_phiz);
794 DOMAttr *node_alpha = node->getAttributeNode(
str_alpha);
795 DOMAttr *node_beta = node->getAttributeNode(
str_beta);
796 DOMAttr *node_gamma = node->getAttributeNode(
str_gamma);
799 bool phixyz = (node_phix !=
nullptr || node_phiy !=
nullptr || node_phiz !=
nullptr);
800 bool alphabetagamma = (node_alpha !=
nullptr || node_beta !=
nullptr || node_gamma !=
nullptr);
801 if (phixyz && alphabetagamma)
throw cms::Exception(
"XMLException") <<
"<setposition> must either have phix, phiy, and phiz or alpha, beta, and gamma, but not both" << std::endl;
802 if (!phixyz && !alphabetagamma) alphabetagamma =
true;
805 if (node_phix !=
nullptr) phix =
parseDouble(node_phix->getValue(),
"phix");
806 if (node_phiy !=
nullptr) phiy =
parseDouble(node_phiy->getValue(),
"phiy");
807 if (node_phiz !=
nullptr) phiz =
parseDouble(node_phiz->getValue(),
"phiz");
813 0., -
sin(phix),
cos(phix));
816 sin(phiy), 0.,
cos(phiy));
818 -
sin(phiz),
cos(phiz), 0.,
821 rot = rotX * rotY * rotZ;
824 else if (alphabetagamma) {
825 if (node_alpha !=
nullptr) alpha =
parseDouble(node_alpha->getValue(),
"alpha");
826 if (node_beta !=
nullptr) beta =
parseDouble(node_beta->getValue(),
"beta");
827 if (node_gamma !=
nullptr) gamma =
parseDouble(node_gamma->getValue(),
"gamma");
831 eulerAngles(1) =
alpha;
832 eulerAngles(2) =
beta;
833 eulerAngles(3) =
gamma;
839 if (relativeto == 0) {
843 else if (relativeto == 1) {
855 else if (relativeto == 2) {
859 if (container !=
nullptr) {
908 if (survey !=
nullptr) {
909 matrix6x6 = survey->
errors();
914 void MuonAlignmentInputXML::do_setape(
const XERCES_CPP_NAMESPACE::DOMElement *node, std::map<Alignable*, bool> &aliset, std::map<Alignable*, Alignable*> &alitoideal)
const {
915 DOMAttr *node_xx = node->getAttributeNode(
str_xx);
916 DOMAttr *node_xy = node->getAttributeNode(
str_xy);
917 DOMAttr *node_xz = node->getAttributeNode(
str_xz);
918 DOMAttr *node_xa = node->getAttributeNode(
str_xa);
919 DOMAttr *node_xb = node->getAttributeNode(
str_xb);
920 DOMAttr *node_xc = node->getAttributeNode(
str_xc);
921 DOMAttr *node_yy = node->getAttributeNode(
str_yy);
922 DOMAttr *node_yz = node->getAttributeNode(
str_yz);
923 DOMAttr *node_ya = node->getAttributeNode(
str_ya);
924 DOMAttr *node_yb = node->getAttributeNode(
str_yb);
925 DOMAttr *node_yc = node->getAttributeNode(
str_yc);
926 DOMAttr *node_zz = node->getAttributeNode(
str_zz);
927 DOMAttr *node_za = node->getAttributeNode(
str_za);
928 DOMAttr *node_zb = node->getAttributeNode(
str_zb);
929 DOMAttr *node_zc = node->getAttributeNode(
str_zc);
930 DOMAttr *node_aa = node->getAttributeNode(
str_aa);
931 DOMAttr *node_ab = node->getAttributeNode(
str_ab);
932 DOMAttr *node_ac = node->getAttributeNode(
str_ac);
933 DOMAttr *node_bb = node->getAttributeNode(
str_bb);
934 DOMAttr *node_bc = node->getAttributeNode(
str_bc);
935 DOMAttr *node_cc = node->getAttributeNode(
str_cc);
937 if (node_xx ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xx\" attribute" << std::endl;
938 if (node_xy ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xy\" attribute" << std::endl;
939 if (node_xz ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xz\" attribute" << std::endl;
940 if (node_xa ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xa\" attribute" << std::endl;
941 if (node_xb ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xb\" attribute" << std::endl;
942 if (node_xc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xc\" attribute" << std::endl;
943 if (node_yy ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yy\" attribute" << std::endl;
944 if (node_yz ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yz\" attribute" << std::endl;
945 if (node_ya ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"ya\" attribute" << std::endl;
946 if (node_yb ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yb\" attribute" << std::endl;
947 if (node_yc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yc\" attribute" << std::endl;
948 if (node_zz ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"zz\" attribute" << std::endl;
949 if (node_za ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"za\" attribute" << std::endl;
950 if (node_zb ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"zb\" attribute" << std::endl;
951 if (node_zc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"zc\" attribute" << std::endl;
952 if (node_aa ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"aa\" attribute" << std::endl;
953 if (node_ab ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"ab\" attribute" << std::endl;
954 if (node_ac ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"ac\" attribute" << std::endl;
955 if (node_bb ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"bb\" attribute" << std::endl;
956 if (node_bc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"bc\" attribute" << std::endl;
957 if (node_cc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"cc\" attribute" << std::endl;
960 matrix6x6(0,0) =
parseDouble(node_xx->getValue(),
"xx");
961 matrix6x6(0,1) =
parseDouble(node_xy->getValue(),
"xy");
962 matrix6x6(0,2) =
parseDouble(node_xz->getValue(),
"xz");
963 matrix6x6(0,3) =
parseDouble(node_xa->getValue(),
"xa");
964 matrix6x6(0,4) =
parseDouble(node_xb->getValue(),
"xb");
965 matrix6x6(0,5) =
parseDouble(node_xc->getValue(),
"xc");
966 matrix6x6(1,1) =
parseDouble(node_yy->getValue(),
"yy");
967 matrix6x6(1,2) =
parseDouble(node_yz->getValue(),
"yz");
968 matrix6x6(1,3) =
parseDouble(node_ya->getValue(),
"ya");
969 matrix6x6(1,4) =
parseDouble(node_yb->getValue(),
"yb");
970 matrix6x6(1,5) =
parseDouble(node_yc->getValue(),
"yc");
971 matrix6x6(2,2) =
parseDouble(node_zz->getValue(),
"zz");
972 matrix6x6(2,3) =
parseDouble(node_za->getValue(),
"za");
973 matrix6x6(2,4) =
parseDouble(node_zb->getValue(),
"zb");
974 matrix6x6(2,5) =
parseDouble(node_zc->getValue(),
"zc");
975 matrix6x6(3,3) =
parseDouble(node_aa->getValue(),
"aa");
976 matrix6x6(3,4) =
parseDouble(node_ab->getValue(),
"ab");
977 matrix6x6(3,5) =
parseDouble(node_ac->getValue(),
"ac");
978 matrix6x6(4,4) =
parseDouble(node_bb->getValue(),
"bb");
979 matrix6x6(4,5) =
parseDouble(node_bc->getValue(),
"bc");
980 matrix6x6(5,5) =
parseDouble(node_cc->getValue(),
"cc");
982 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
989 DOMAttr *node_xx = node->getAttributeNode(
str_xx);
990 DOMAttr *node_xy = node->getAttributeNode(
str_xy);
991 DOMAttr *node_xz = node->getAttributeNode(
str_xz);
992 DOMAttr *node_xa = node->getAttributeNode(
str_xa);
993 DOMAttr *node_xb = node->getAttributeNode(
str_xb);
994 DOMAttr *node_xc = node->getAttributeNode(
str_xc);
995 DOMAttr *node_yy = node->getAttributeNode(
str_yy);
996 DOMAttr *node_yz = node->getAttributeNode(
str_yz);
997 DOMAttr *node_ya = node->getAttributeNode(
str_ya);
998 DOMAttr *node_yb = node->getAttributeNode(
str_yb);
999 DOMAttr *node_yc = node->getAttributeNode(
str_yc);
1000 DOMAttr *node_zz = node->getAttributeNode(
str_zz);
1001 DOMAttr *node_za = node->getAttributeNode(
str_za);
1002 DOMAttr *node_zb = node->getAttributeNode(
str_zb);
1003 DOMAttr *node_zc = node->getAttributeNode(
str_zc);
1004 DOMAttr *node_aa = node->getAttributeNode(
str_aa);
1005 DOMAttr *node_ab = node->getAttributeNode(
str_ab);
1006 DOMAttr *node_ac = node->getAttributeNode(
str_ac);
1007 DOMAttr *node_bb = node->getAttributeNode(
str_bb);
1008 DOMAttr *node_bc = node->getAttributeNode(
str_bc);
1009 DOMAttr *node_cc = node->getAttributeNode(
str_cc);
1011 if (node_xx ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xx\" attribute" << std::endl;
1012 if (node_xy ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xy\" attribute" << std::endl;
1013 if (node_xz ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xz\" attribute" << std::endl;
1014 if (node_xa ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xa\" attribute" << std::endl;
1015 if (node_xb ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xb\" attribute" << std::endl;
1016 if (node_xc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xc\" attribute" << std::endl;
1017 if (node_yy ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yy\" attribute" << std::endl;
1018 if (node_yz ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yz\" attribute" << std::endl;
1019 if (node_ya ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"ya\" attribute" << std::endl;
1020 if (node_yb ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yb\" attribute" << std::endl;
1021 if (node_yc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yc\" attribute" << std::endl;
1022 if (node_zz ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"zz\" attribute" << std::endl;
1023 if (node_za ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"za\" attribute" << std::endl;
1024 if (node_zb ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"zb\" attribute" << std::endl;
1025 if (node_zc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"zc\" attribute" << std::endl;
1026 if (node_aa ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"aa\" attribute" << std::endl;
1027 if (node_ab ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"ab\" attribute" << std::endl;
1028 if (node_ac ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"ac\" attribute" << std::endl;
1029 if (node_bb ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"bb\" attribute" << std::endl;
1030 if (node_bc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"bc\" attribute" << std::endl;
1031 if (node_cc ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"cc\" attribute" << std::endl;
1034 matrix6x6(0,0) =
parseDouble(node_xx->getValue(),
"xx");
1035 matrix6x6(0,1) =
parseDouble(node_xy->getValue(),
"xy");
1036 matrix6x6(0,2) =
parseDouble(node_xz->getValue(),
"xz");
1037 matrix6x6(0,3) =
parseDouble(node_xa->getValue(),
"xa");
1038 matrix6x6(0,4) =
parseDouble(node_xb->getValue(),
"xb");
1039 matrix6x6(0,5) =
parseDouble(node_xc->getValue(),
"xc");
1040 matrix6x6(1,1) =
parseDouble(node_yy->getValue(),
"yy");
1041 matrix6x6(1,2) =
parseDouble(node_yz->getValue(),
"yz");
1042 matrix6x6(1,3) =
parseDouble(node_ya->getValue(),
"ya");
1043 matrix6x6(1,4) =
parseDouble(node_yb->getValue(),
"yb");
1044 matrix6x6(1,5) =
parseDouble(node_yc->getValue(),
"yc");
1045 matrix6x6(2,2) =
parseDouble(node_zz->getValue(),
"zz");
1046 matrix6x6(2,3) =
parseDouble(node_za->getValue(),
"za");
1047 matrix6x6(2,4) =
parseDouble(node_zb->getValue(),
"zb");
1048 matrix6x6(2,5) =
parseDouble(node_zc->getValue(),
"zc");
1049 matrix6x6(3,3) =
parseDouble(node_aa->getValue(),
"aa");
1050 matrix6x6(3,4) =
parseDouble(node_ab->getValue(),
"ab");
1051 matrix6x6(3,5) =
parseDouble(node_ac->getValue(),
"ac");
1052 matrix6x6(4,4) =
parseDouble(node_bb->getValue(),
"bb");
1053 matrix6x6(4,5) =
parseDouble(node_bc->getValue(),
"bc");
1054 matrix6x6(5,5) =
parseDouble(node_cc->getValue(),
"cc");
1056 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1063 DOMAttr *node_x = node->getAttributeNode(
str_x);
1064 DOMAttr *node_y = node->getAttributeNode(
str_y);
1065 DOMAttr *node_z = node->getAttributeNode(
str_z);
1066 if (node_x ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<moveglobal> is missing required \"x\" attribute" << std::endl;
1067 if (node_y ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<moveglobal> is missing required \"y\" attribute" << std::endl;
1068 if (node_z ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<moveglobal> is missing required \"z\" attribute" << std::endl;
1075 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1084 if (survey !=
nullptr) {
1085 matrix6x6 = survey->
errors();
1092 DOMAttr *node_x = node->getAttributeNode(
str_x);
1093 DOMAttr *node_y = node->getAttributeNode(
str_y);
1094 DOMAttr *node_z = node->getAttributeNode(
str_z);
1095 if (node_x ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<movelocal> is missing required \"x\" attribute" << std::endl;
1096 if (node_y ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<movelocal> is missing required \"y\" attribute" << std::endl;
1097 if (node_z ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<movelocal> is missing required \"z\" attribute" << std::endl;
1104 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1108 ali->
move(globalVector);
1114 if (survey !=
nullptr) {
1115 matrix6x6 = survey->
errors();
1122 DOMAttr *node_axisx = node->getAttributeNode(
str_axisx);
1123 DOMAttr *node_axisy = node->getAttributeNode(
str_axisy);
1124 DOMAttr *node_axisz = node->getAttributeNode(
str_axisz);
1125 DOMAttr *node_angle = node->getAttributeNode(
str_angle);
1126 if (node_axisx ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"axisx\" attribute" << std::endl;
1127 if (node_axisy ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"axisy\" attribute" << std::endl;
1128 if (node_axisz ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"axisz\" attribute" << std::endl;
1129 if (node_angle ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"angle\" attribute" << std::endl;
1137 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1146 if (survey !=
nullptr) {
1147 matrix6x6 = survey->
errors();
1154 DOMAttr *node_rphi = node->getAttributeNode(
str_rphi);
1155 DOMAttr *node_phi = node->getAttributeNode(
str_phi);
1156 if (node_rphi ==
nullptr && node_phi ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotatebeamline> is missing required \"*phi\" attribute" << std::endl;
1157 if (node_rphi !=
nullptr && node_phi !=
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotatebeamline> can't have both an \"rphi\" and a \"phi\" attribute" << std::endl;
1160 if (node_rphi !=
nullptr) {
1161 value =
parseDouble(node_rphi->getValue(),
"rphi");
1167 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1173 double phi0 = pos.
phi();
1174 double deltaphi =
value;
1175 if (node_rphi !=
nullptr) deltaphi = value /
radius;
1179 radius * (
sin(phi0 + deltaphi) -
sin(phi0)),
1186 if (survey !=
nullptr) {
1187 matrix6x6 = survey->
errors();
1194 DOMAttr *node_x = node->getAttributeNode(
str_x);
1195 DOMAttr *node_y = node->getAttributeNode(
str_y);
1196 DOMAttr *node_z = node->getAttributeNode(
str_z);
1197 DOMAttr *node_angle = node->getAttributeNode(
str_angle);
1198 if (node_x ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"x\" attribute" << std::endl;
1199 if (node_y ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"y\" attribute" << std::endl;
1200 if (node_z ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"z\" attribute" << std::endl;
1201 if (node_angle ==
nullptr)
throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"angle\" attribute" << std::endl;
1208 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1214 double aprime = x/
sqrt(x*x + y*y + z*z);
1215 double bprime = y/
sqrt(x*x + y*y + z*z);
1216 double cprime = z/
sqrt(x*x + y*y + z*z);
1217 double q0 =
cos(angle/2.);
1218 double q1 =
sin(angle/2.) * aprime;
1219 double q2 =
sin(angle/2.) * bprime;
1220 double q3 =
sin(angle/2.) * cprime;
1222 double pos2x = (q0*q0 + q1*q1 - q2*q2 - q3*q3) * pos.
x() + 2.*(q1*q2 - q0*q3) * pos.
y() + 2.*(q1*q3 + q0*
q2) * pos.
z();
1223 double pos2y = 2.*(q2*q1 + q0*q3) * pos.
x() + (q0*q0 - q1*q1 + q2*q2 - q3*q3) * pos.
y() + 2.*(q2*q3 - q0*
q1) * pos.
z();
1224 double pos2z = 2.*(q3*q1 - q0*
q2) * pos.
x() + 2.*(q3*q2 + q0*
q1) * pos.
y() + (q0*q0 - q1*q1 - q2*q2 + q3*q3) * pos.
z();
1226 double movex = pos2x - pos.
x();
1227 double movey = pos2y - pos.
y();
1228 double movez = pos2z - pos.
z();
1235 if (survey !=
nullptr) {
1236 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
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.
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
uint32_t rawId() const
get the raw id
Point3DBase< Scalar, GlobalTag > PositionType
align::Alignables CSCEndcaps()
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
Cos< T >::type cos(const T &t)
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
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)