18 #include "xercesc/parsers/XercesDOMParser.hpp"
19 #include "xercesc/dom/DOM.hpp"
20 #include "xercesc/sax/HandlerBase.hpp"
21 #include "xercesc/util/XMLString.hpp"
22 #include "xercesc/util/PlatformUtils.hpp"
23 #include "xercesc/util/XercesDefs.hpp"
24 XERCES_CPP_NAMESPACE_USE
46 : m_fileName(fileName)
50 str_name = XMLString::transcode(
"name");
71 str_rawId = XMLString::transcode(
"rawId");
72 str_wheel = XMLString::transcode(
"wheel");
76 str_layer = XMLString::transcode(
"layer");
78 str_ring = XMLString::transcode(
"ring");
80 str_axisx = XMLString::transcode(
"axisx");
81 str_axisy = XMLString::transcode(
"axisy");
82 str_axisz = XMLString::transcode(
"axisz");
83 str_angle = XMLString::transcode(
"angle");
84 str_x = XMLString::transcode(
"x");
85 str_y = XMLString::transcode(
"y");
86 str_z = XMLString::transcode(
"z");
87 str_phix = XMLString::transcode(
"phix");
88 str_phiy = XMLString::transcode(
"phiy");
89 str_phiz = XMLString::transcode(
"phiz");
90 str_alpha = XMLString::transcode(
"alpha");
91 str_beta = XMLString::transcode(
"beta");
92 str_gamma = XMLString::transcode(
"gamma");
93 str_rphi = XMLString::transcode(
"rphi");
94 str_phi = XMLString::transcode(
"phi");
95 str_xx = XMLString::transcode(
"xx");
96 str_xy = XMLString::transcode(
"xy");
97 str_xz = XMLString::transcode(
"xz");
98 str_xa = XMLString::transcode(
"xa");
99 str_xb = XMLString::transcode(
"xb");
100 str_xc = XMLString::transcode(
"xc");
101 str_yy = XMLString::transcode(
"yy");
102 str_yz = XMLString::transcode(
"yz");
103 str_ya = XMLString::transcode(
"ya");
104 str_yb = XMLString::transcode(
"yb");
105 str_yc = XMLString::transcode(
"yc");
106 str_zz = XMLString::transcode(
"zz");
107 str_za = XMLString::transcode(
"za");
108 str_zb = XMLString::transcode(
"zb");
109 str_zc = XMLString::transcode(
"zc");
110 str_aa = XMLString::transcode(
"aa");
111 str_ab = XMLString::transcode(
"ab");
112 str_ac = XMLString::transcode(
"ac");
113 str_bb = XMLString::transcode(
"bb");
114 str_bc = XMLString::transcode(
"bc");
115 str_cc = XMLString::transcode(
"cc");
116 str_none = XMLString::transcode(
"none");
117 str_ideal = XMLString::transcode(
"ideal");
217 for (std::vector<Alignable*>::const_iterator ali = alignables.begin(); ali != alignables.end(); ++ali) {
221 alignableNavigator[(*ali)->geomDetId().rawId()] = *ali;
228 std::vector<Alignable*>::const_iterator alignable = alignables.begin();
229 std::vector<Alignable*>::const_iterator ideal = ideals.begin();
231 while (alignable != alignables.end() && ideal != ideals.end()) {
232 alitoideal[*alignable] = *ideal;
234 fillAliToIdeal(alitoideal, (*alignable)->components(), (*ideal)->components());
240 if (alignable != alignables.end() || ideal != ideals.end()) {
241 throw cms::Exception(
"Alignment") <<
"alignable and ideal-alignable trees are out of sync (this should never happen)";
250 std::map<unsigned int, Alignable*> alignableNavigator;
255 std::map<unsigned int, Alignable*> ideal_alignableNavigator;
256 recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->DTBarrel());
257 recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->CSCEndcaps());
260 XMLPlatformUtils::Initialize();
262 catch (
const XMLException &toCatch) {
263 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw an exception on initialization." << std::endl;
266 XercesDOMParser *
parser =
new XercesDOMParser();
267 parser->setValidationScheme(XercesDOMParser::Val_Always);
269 ErrorHandler *errHandler = (ErrorHandler*)(
new HandlerBase());
270 parser->setErrorHandler(errHandler);
275 catch (
const XMLException &toCatch) {
276 char *
message = XMLString::transcode(toCatch.getMessage());
277 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw this exception: " << message << std::endl;
279 catch (
const DOMException &toCatch) {
280 char *
message = XMLString::transcode(toCatch.msg);
281 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw this exception: " << message << std::endl;
283 catch (
const SAXException &toCatch) {
284 char *
message = XMLString::transcode(toCatch.getMessage());
285 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw this exception: " << message << std::endl;
288 throw cms::Exception(
"XMLException") <<
"Xerces XML parser threw an unknown exception" << std::endl;
291 DOMDocument *
doc = parser->getDocument();
292 DOMElement *node_MuonAlignment = doc->getDocumentElement();
293 DOMNodeList *collections = doc->getElementsByTagName(
str_collection);
294 DOMNodeList *operations = doc->getElementsByTagName(
str_operation);
296 std::map<Alignable*, Alignable*> alitoideal;
300 std::map<std::string, std::map<Alignable*, bool> > alicollections;
301 for (
unsigned int i = 0;
i < collections->getLength();
i++) {
302 DOMElement *
collection = (DOMElement*)(collections->item(
i));
303 if (collection->getParentNode() == node_MuonAlignment) {
304 DOMNodeList *children = collection->getChildNodes();
306 DOMAttr *node_name = collection->getAttributeNode(
str_name);
307 if (node_name ==
NULL) {
308 throw cms::Exception(
"XMLException") <<
"<collection> requires a name attribute" << std::endl;
310 char *ascii_name = XMLString::transcode(node_name->getValue());
311 std::string
name(ascii_name);
314 std::map<Alignable*, bool> aliset;
315 for (
unsigned int j = 0;
j < children->getLength();
j++) {
316 DOMNode *
node = children->item(
j);
318 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
321 throw cms::Exception(
"XMLException") <<
"<collection> must contain only alignables" << std::endl;
328 alicollections[
name] = aliset;
332 for (
unsigned int i = 0;
i < operations->getLength();
i++) {
333 DOMElement *operation = (DOMElement*)(operations->item(
i));
334 if (operation->getParentNode() != node_MuonAlignment) {
335 throw cms::Exception(
"XMLException") <<
"All operations must be top-level elements" << std::endl;
338 DOMNodeList *children = operation->getChildNodes();
340 std::map<Alignable*, bool> aliset;
341 std::vector<DOMNode*> nodesToRemove;
342 for (
unsigned int j = 0;
j < children->getLength();
j++) {
343 DOMNode *
node = children->item(
j);
345 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
349 nodesToRemove.push_back(node);
352 else if (XMLString::equals(node->getNodeName(),
str_collection)) {
353 DOMAttr *node_name = ((DOMElement*)(node))->getAttributeNode(
str_name);
354 if (node_name ==
NULL) {
355 throw cms::Exception(
"XMLException") <<
"<collection> requires a name attribute" << std::endl;
357 char *ascii_name = XMLString::transcode(node_name->getValue());
358 std::string
name(ascii_name);
361 std::map<std::string, std::map<Alignable*, bool> >::const_iterator alicollections_iter = alicollections.find(name);
362 if (alicollections_iter == alicollections.end()) {
363 throw cms::Exception(
"XMLException") <<
"<collection name=\"" << name <<
"\"> hasn't been defined" << std::endl;
366 for (std::map<Alignable*, bool>::const_iterator aliiter = alicollections_iter->second.begin();
367 aliiter != alicollections_iter->second.end();
369 aliset[aliiter->first] =
true;
372 nodesToRemove.push_back(node);
381 for (std::vector<DOMNode*>::const_iterator
node = nodesToRemove.begin();
node != nodesToRemove.end(); ++
node) {
382 operation->removeChild(*
node);
384 children = operation->getChildNodes();
386 for (
unsigned int j = 0;
j < children->getLength();
j++) {
387 DOMNode *
node = children->item(
j);
388 if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
394 else if (XMLString::equals(node->getNodeName(),
str_setape)) {
395 do_setape((DOMElement*)(node), aliset, alitoideal);
402 else if (XMLString::equals(node->getNodeName(),
str_moveglobal)) {
406 else if (XMLString::equals(node->getNodeName(),
str_movelocal)) {
423 char *
message = XMLString::transcode(node->getNodeName());
424 throw cms::Exception(
"XMLException") <<
"Unrecognized operation: \"" << message <<
"\"" << std::endl;
434 XMLPlatformUtils::Terminate();
436 delete ideal_alignableMuon;
437 return alignableMuon;
456 unsigned int rawId = 0;
458 DOMAttr *node_rawId = node->getAttributeNode(
str_rawId);
459 if (node_rawId !=
NULL) {
461 rawId = XMLString::parseInt(node_rawId->getValue());
463 catch (
const XMLException &toCatch) {
464 throw cms::Exception(
"XMLException") <<
"Value of \"rawId\" must be an integer" << std::endl;
468 int wheel,
station, sector, superlayer, layer;
469 wheel = station = sector = superlayer = layer = 1;
472 DOMAttr *node_wheel = node->getAttributeNode(
str_wheel);
473 if (node_wheel ==
NULL)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"wheel\" attribute" << std::endl;
475 wheel = XMLString::parseInt(node_wheel->getValue());
477 catch (
const XMLException &toCatch) {
478 throw cms::Exception(
"XMLException") <<
"Value of \"wheel\" must be an integer" << std::endl;
482 DOMAttr *node_station = node->getAttributeNode(
str_station);
483 if (node_station ==
NULL)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"station\" attribute" << std::endl;
485 station = XMLString::parseInt(node_station->getValue());
487 catch (
const XMLException &toCatch) {
488 throw cms::Exception(
"XMLException") <<
"Value of \"station\" must be an integer" << std::endl;
492 DOMAttr *node_sector = node->getAttributeNode(
str_sector);
493 if (node_sector ==
NULL)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"sector\" attribute" << std::endl;
495 sector = XMLString::parseInt(node_sector->getValue());
497 catch (
const XMLException &toCatch) {
498 throw cms::Exception(
"XMLException") <<
"Value of \"sector\" must be an integer" << std::endl;
502 DOMAttr *node_superlayer = node->getAttributeNode(
str_superlayer);
503 if (node_superlayer ==
NULL)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"superlayer\" attribute" << std::endl;
505 superlayer = XMLString::parseInt(node_superlayer->getValue());
507 catch (
const XMLException &toCatch) {
508 throw cms::Exception(
"XMLException") <<
"Value of \"superlayer\" must be an integer" << std::endl;
512 DOMAttr *node_layer = node->getAttributeNode(
str_layer);
513 if (node_layer ==
NULL)
throw cms::Exception(
"XMLException") <<
"DT node is missing required \"layer\" attribute" << std::endl;
515 layer = XMLString::parseInt(node_layer->getValue());
517 catch (
const XMLException &toCatch) {
518 throw cms::Exception(
"XMLException") <<
"Value of \"layer\" must be an integer" << std::endl;
527 DTLayerId layerId(wheel, station, sector, superlayer, layer);
528 rawId = layerId.
rawId();
531 Alignable *ali = alignableNavigator[rawId];
532 if (ali ==
NULL)
throw cms::Exception(
"XMLException") <<
"rawId \"" << rawId <<
"\" is not recognized" << std::endl;
552 DOMAttr *node_rawId = node->getAttributeNode(
str_rawId);
553 if (node_rawId !=
NULL) {
555 rawId = XMLString::parseInt(node_rawId->getValue());
557 catch (
const XMLException &toCatch) {
558 throw cms::Exception(
"XMLException") <<
"Value of \"rawId\" must be an integer" << std::endl;
563 endcap = station = ring = chamber = layer = 1;
565 DOMAttr *node_endcap = node->getAttributeNode(
str_endcap);
566 if (node_endcap ==
NULL)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"endcap\" attribute" << std::endl;
568 endcap = XMLString::parseInt(node_endcap->getValue());
570 catch (
const XMLException &toCatch) {
571 throw cms::Exception(
"XMLException") <<
"Value of \"endcap\" must be an integer" << std::endl;
573 if (endcap == -1) endcap = 2;
576 DOMAttr *node_station = node->getAttributeNode(
str_station);
577 if (node_station ==
NULL)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"station\" attribute" << std::endl;
579 station = XMLString::parseInt(node_station->getValue());
581 catch (
const XMLException &toCatch) {
582 throw cms::Exception(
"XMLException") <<
"Value of \"station\" must be an integer" << std::endl;
586 DOMAttr *node_ring = node->getAttributeNode(
str_ring);
587 if (node_ring ==
NULL)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"ring\" attribute" << std::endl;
589 ring = XMLString::parseInt(node_ring->getValue());
591 catch (
const XMLException &toCatch) {
592 throw cms::Exception(
"XMLException") <<
"Value of \"ring\" must be an integer" << std::endl;
596 DOMAttr *node_chamber = node->getAttributeNode(
str_chamber);
597 if (node_chamber ==
NULL)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"chamber\" attribute" << std::endl;
599 chamber = XMLString::parseInt(node_chamber->getValue());
601 catch (
const XMLException &toCatch) {
602 throw cms::Exception(
"XMLException") <<
"Value of \"chamber\" must be an integer" << std::endl;
606 DOMAttr *node_layer = node->getAttributeNode(
str_layer);
607 if (node_layer ==
NULL)
throw cms::Exception(
"XMLException") <<
"CSC node is missing required \"layer\" attribute" << std::endl;
609 layer = XMLString::parseInt(node_layer->getValue());
611 catch (
const XMLException &toCatch) {
612 throw cms::Exception(
"XMLException") <<
"Value of \"layer\" must be an integer" << std::endl;
620 CSCDetId layerId(endcap, station, ring, chamber, layer);
621 rawId = layerId.
rawId();
624 Alignable *ali = alignableNavigator[rawId];
625 if (ali ==
NULL)
throw cms::Exception(
"XMLException") <<
"rawId \"" << rawId <<
"\" is not recognized" << std::endl;
642 unsigned int len = XMLString::stringLen(str);
643 char *cstr = XMLString::transcode(str);
644 std::stringstream errmessage;
645 errmessage <<
"Value of \"" << attribute <<
"\" must be a double, not \"" << cstr <<
"\"" << std::endl;
650 if (cstr[i] ==
'-') {
654 else if (cstr[i] ==
'+') i++;
658 while (cstr[i] !=
'.' && cstr[i] !=
'e' && cstr[i] !=
'E' && i < len) {
659 if (cstr[i] <
'0' || cstr[i] >
'9') {
665 output += cstr[
i] -
'0';
669 if (cstr[i] ==
'.') {
673 while (cstr[i] !=
'e' && cstr[i] !=
'E' && i < len) {
674 if (cstr[i] <
'0' || cstr[i] >
'9') {
679 output += (cstr[
i] -
'0') * place;
685 if (cstr[i] ==
'e' || cstr[i] ==
'E') {
689 bool expminus =
false;
690 if (cstr[i] ==
'-') {
694 else if (cstr[i] ==
'+') i++;
697 if (cstr[i] <
'0' || cstr[i] >
'9') {
703 exponent += cstr[
i] -
'0';
707 if (expminus) exponent *= -1;
709 output *=
pow(10., exponent);
712 if (minus) output *= -1.;
719 DOMAttr *node_relativeto = node->getAttributeNode(
str_relativeto);
720 if (node_relativeto ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setposition> is missing required \"relativeto\" attribute" << std::endl;
723 if (XMLString::equals(node_relativeto->getValue(),
str_none)) {
726 else if (XMLString::equals(node_relativeto->getValue(),
str_ideal)) {
729 else if (XMLString::equals(node_relativeto->getValue(),
str_container)) {
733 char *
message = XMLString::transcode(node_relativeto->getValue());
734 throw cms::Exception(
"XMLException") <<
"relativeto must be \"none\", \"ideal\", or \"container\", not \"" << message <<
"\"" << std::endl;
737 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
746 if (relativeto == 0) {}
748 else if (relativeto == 1) {
756 else if (relativeto == 2 && ali->
mother() !=
NULL) {
761 oldrot = oldrot * globalRotation.
transposed();
764 double x = oldpos.
x();
765 double y = oldpos.
y();
766 double z = oldpos.
z();
768 double phix = atan2(oldrot.
yz(), oldrot.
zz());
769 double phiy = asin(-oldrot.
xz());
770 double phiz = atan2(oldrot.
xy(), oldrot.
xx());
773 double alpha = oldEulerAngles(1);
774 double beta = oldEulerAngles(2);
775 double gamma = oldEulerAngles(3);
779 DOMAttr *node_x = node->getAttributeNode(
str_x);
780 DOMAttr *node_y = node->getAttributeNode(
str_y);
781 DOMAttr *node_z = node->getAttributeNode(
str_z);
788 DOMAttr *node_phix = node->getAttributeNode(
str_phix);
789 DOMAttr *node_phiy = node->getAttributeNode(
str_phiy);
790 DOMAttr *node_phiz = node->getAttributeNode(
str_phiz);
791 DOMAttr *node_alpha = node->getAttributeNode(
str_alpha);
792 DOMAttr *node_beta = node->getAttributeNode(
str_beta);
793 DOMAttr *node_gamma = node->getAttributeNode(
str_gamma);
796 bool phixyz = (node_phix !=
NULL || node_phiy !=
NULL || node_phiz !=
NULL);
797 bool alphabetagamma = (node_alpha !=
NULL || node_beta !=
NULL || node_gamma !=
NULL);
798 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;
799 if (!phixyz && !alphabetagamma) alphabetagamma =
true;
802 if (node_phix !=
NULL) phix =
parseDouble(node_phix->getValue(),
"phix");
803 if (node_phiy !=
NULL) phiy =
parseDouble(node_phiy->getValue(),
"phiy");
804 if (node_phiz !=
NULL) phiz =
parseDouble(node_phiz->getValue(),
"phiz");
810 0., -
sin(phix),
cos(phix));
813 sin(phiy), 0.,
cos(phiy));
815 -
sin(phiz),
cos(phiz), 0.,
818 rot = rotX * rotY * rotZ;
821 else if (alphabetagamma) {
822 if (node_alpha !=
NULL) alpha =
parseDouble(node_alpha->getValue(),
"alpha");
823 if (node_beta !=
NULL) beta =
parseDouble(node_beta->getValue(),
"beta");
824 if (node_gamma !=
NULL) gamma =
parseDouble(node_gamma->getValue(),
"gamma");
828 eulerAngles(1) =
alpha;
829 eulerAngles(2) =
beta;
830 eulerAngles(3) = gamma;
836 if (relativeto == 0) {
840 else if (relativeto == 1) {
852 else if (relativeto == 2) {
856 if (container !=
NULL) {
905 if (survey !=
NULL) {
906 matrix6x6 = survey->
errors();
912 DOMAttr *node_xx = node->getAttributeNode(
str_xx);
913 DOMAttr *node_xy = node->getAttributeNode(
str_xy);
914 DOMAttr *node_xz = node->getAttributeNode(
str_xz);
915 DOMAttr *node_yy = node->getAttributeNode(
str_yy);
916 DOMAttr *node_yz = node->getAttributeNode(
str_yz);
917 DOMAttr *node_zz = node->getAttributeNode(
str_zz);
919 if (node_xx ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xx\" attribute" << std::endl;
920 if (node_xy ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xy\" attribute" << std::endl;
921 if (node_xz ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"xz\" attribute" << std::endl;
922 if (node_yy ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yy\" attribute" << std::endl;
923 if (node_yz ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"yz\" attribute" << std::endl;
924 if (node_zz ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setape> is missing required \"zz\" attribute" << std::endl;
926 CLHEP::HepSymMatrix matrix3x3(3);
927 matrix3x3(1,1) =
parseDouble(node_xx->getValue(),
"xx");
928 matrix3x3(1,2) =
parseDouble(node_xy->getValue(),
"xy");
929 matrix3x3(1,3) =
parseDouble(node_xz->getValue(),
"xz");
930 matrix3x3(2,2) =
parseDouble(node_yy->getValue(),
"yy");
931 matrix3x3(2,3) =
parseDouble(node_yz->getValue(),
"yz");
932 matrix3x3(3,3) =
parseDouble(node_zz->getValue(),
"zz");
934 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
941 DOMAttr *node_xx = node->getAttributeNode(
str_xx);
942 DOMAttr *node_xy = node->getAttributeNode(
str_xy);
943 DOMAttr *node_xz = node->getAttributeNode(
str_xz);
944 DOMAttr *node_xa = node->getAttributeNode(
str_xa);
945 DOMAttr *node_xb = node->getAttributeNode(
str_xb);
946 DOMAttr *node_xc = node->getAttributeNode(
str_xc);
947 DOMAttr *node_yy = node->getAttributeNode(
str_yy);
948 DOMAttr *node_yz = node->getAttributeNode(
str_yz);
949 DOMAttr *node_ya = node->getAttributeNode(
str_ya);
950 DOMAttr *node_yb = node->getAttributeNode(
str_yb);
951 DOMAttr *node_yc = node->getAttributeNode(
str_yc);
952 DOMAttr *node_zz = node->getAttributeNode(
str_zz);
953 DOMAttr *node_za = node->getAttributeNode(
str_za);
954 DOMAttr *node_zb = node->getAttributeNode(
str_zb);
955 DOMAttr *node_zc = node->getAttributeNode(
str_zc);
956 DOMAttr *node_aa = node->getAttributeNode(
str_aa);
957 DOMAttr *node_ab = node->getAttributeNode(
str_ab);
958 DOMAttr *node_ac = node->getAttributeNode(
str_ac);
959 DOMAttr *node_bb = node->getAttributeNode(
str_bb);
960 DOMAttr *node_bc = node->getAttributeNode(
str_bc);
961 DOMAttr *node_cc = node->getAttributeNode(
str_cc);
963 if (node_xx ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xx\" attribute" << std::endl;
964 if (node_xy ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xy\" attribute" << std::endl;
965 if (node_xz ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xz\" attribute" << std::endl;
966 if (node_xa ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xa\" attribute" << std::endl;
967 if (node_xb ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xb\" attribute" << std::endl;
968 if (node_xc ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"xc\" attribute" << std::endl;
969 if (node_yy ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yy\" attribute" << std::endl;
970 if (node_yz ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yz\" attribute" << std::endl;
971 if (node_ya ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"ya\" attribute" << std::endl;
972 if (node_yb ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yb\" attribute" << std::endl;
973 if (node_yc ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"yc\" attribute" << std::endl;
974 if (node_zz ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"zz\" attribute" << std::endl;
975 if (node_za ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"za\" attribute" << std::endl;
976 if (node_zb ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"zb\" attribute" << std::endl;
977 if (node_zc ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"zc\" attribute" << std::endl;
978 if (node_aa ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"aa\" attribute" << std::endl;
979 if (node_ab ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"ab\" attribute" << std::endl;
980 if (node_ac ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"ac\" attribute" << std::endl;
981 if (node_bb ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"bb\" attribute" << std::endl;
982 if (node_bc ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"bc\" attribute" << std::endl;
983 if (node_cc ==
NULL)
throw cms::Exception(
"XMLException") <<
"<setsurveyerr> is missing required \"cc\" attribute" << std::endl;
986 matrix6x6(0,0) =
parseDouble(node_xx->getValue(),
"xx");
987 matrix6x6(0,1) =
parseDouble(node_xy->getValue(),
"xy");
988 matrix6x6(0,2) =
parseDouble(node_xz->getValue(),
"xz");
989 matrix6x6(0,3) =
parseDouble(node_xa->getValue(),
"xa");
990 matrix6x6(0,4) =
parseDouble(node_xb->getValue(),
"xb");
991 matrix6x6(0,5) =
parseDouble(node_xc->getValue(),
"xc");
992 matrix6x6(1,1) =
parseDouble(node_yy->getValue(),
"yy");
993 matrix6x6(1,2) =
parseDouble(node_yz->getValue(),
"yz");
994 matrix6x6(1,3) =
parseDouble(node_ya->getValue(),
"ya");
995 matrix6x6(1,4) =
parseDouble(node_yb->getValue(),
"yb");
996 matrix6x6(1,5) =
parseDouble(node_yc->getValue(),
"yc");
997 matrix6x6(2,2) =
parseDouble(node_zz->getValue(),
"zz");
998 matrix6x6(2,3) =
parseDouble(node_za->getValue(),
"za");
999 matrix6x6(2,4) =
parseDouble(node_zb->getValue(),
"zb");
1000 matrix6x6(2,5) =
parseDouble(node_zc->getValue(),
"zc");
1001 matrix6x6(3,3) =
parseDouble(node_aa->getValue(),
"aa");
1002 matrix6x6(3,4) =
parseDouble(node_ab->getValue(),
"ab");
1003 matrix6x6(3,5) =
parseDouble(node_ac->getValue(),
"ac");
1004 matrix6x6(4,4) =
parseDouble(node_bb->getValue(),
"bb");
1005 matrix6x6(4,5) =
parseDouble(node_bc->getValue(),
"bc");
1006 matrix6x6(5,5) =
parseDouble(node_cc->getValue(),
"cc");
1008 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1015 DOMAttr *node_x = node->getAttributeNode(
str_x);
1016 DOMAttr *node_y = node->getAttributeNode(
str_y);
1017 DOMAttr *node_z = node->getAttributeNode(
str_z);
1018 if (node_x ==
NULL)
throw cms::Exception(
"XMLException") <<
"<moveglobal> is missing required \"x\" attribute" << std::endl;
1019 if (node_y ==
NULL)
throw cms::Exception(
"XMLException") <<
"<moveglobal> is missing required \"y\" attribute" << std::endl;
1020 if (node_z ==
NULL)
throw cms::Exception(
"XMLException") <<
"<moveglobal> is missing required \"z\" attribute" << std::endl;
1027 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1036 if (survey !=
NULL) {
1037 matrix6x6 = survey->
errors();
1044 DOMAttr *node_x = node->getAttributeNode(
str_x);
1045 DOMAttr *node_y = node->getAttributeNode(
str_y);
1046 DOMAttr *node_z = node->getAttributeNode(
str_z);
1047 if (node_x ==
NULL)
throw cms::Exception(
"XMLException") <<
"<movelocal> is missing required \"x\" attribute" << std::endl;
1048 if (node_y ==
NULL)
throw cms::Exception(
"XMLException") <<
"<movelocal> is missing required \"y\" attribute" << std::endl;
1049 if (node_z ==
NULL)
throw cms::Exception(
"XMLException") <<
"<movelocal> is missing required \"z\" attribute" << std::endl;
1056 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1060 ali->
move(globalVector);
1066 if (survey !=
NULL) {
1067 matrix6x6 = survey->
errors();
1074 DOMAttr *node_axisx = node->getAttributeNode(
str_axisx);
1075 DOMAttr *node_axisy = node->getAttributeNode(
str_axisy);
1076 DOMAttr *node_axisz = node->getAttributeNode(
str_axisz);
1077 DOMAttr *node_angle = node->getAttributeNode(
str_angle);
1078 if (node_axisx ==
NULL)
throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"axisx\" attribute" << std::endl;
1079 if (node_axisy ==
NULL)
throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"axisy\" attribute" << std::endl;
1080 if (node_axisz ==
NULL)
throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"axisz\" attribute" << std::endl;
1081 if (node_angle ==
NULL)
throw cms::Exception(
"XMLException") <<
"<rotatelocal> is missing required \"angle\" attribute" << std::endl;
1089 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1098 if (survey !=
NULL) {
1099 matrix6x6 = survey->
errors();
1106 DOMAttr *node_rphi = node->getAttributeNode(
str_rphi);
1107 DOMAttr *node_phi = node->getAttributeNode(
str_phi);
1108 if (node_rphi ==
NULL && node_phi ==
NULL)
throw cms::Exception(
"XMLException") <<
"<rotatebeamline> is missing required \"*phi\" attribute" << std::endl;
1109 if (node_rphi !=
NULL && node_phi !=
NULL)
throw cms::Exception(
"XMLException") <<
"<rotatebeamline> can't have both an \"rphi\" and a \"phi\" attribute" << std::endl;
1112 if (node_rphi !=
NULL) {
1113 value =
parseDouble(node_rphi->getValue(),
"rphi");
1119 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1125 double phi0 = pos.
phi();
1126 double deltaphi =
value;
1127 if (node_rphi !=
NULL) deltaphi = value /
radius;
1131 radius * (
sin(phi0 + deltaphi) -
sin(phi0)),
1138 if (survey !=
NULL) {
1139 matrix6x6 = survey->
errors();
1146 DOMAttr *node_x = node->getAttributeNode(
str_x);
1147 DOMAttr *node_y = node->getAttributeNode(
str_y);
1148 DOMAttr *node_z = node->getAttributeNode(
str_z);
1149 DOMAttr *node_angle = node->getAttributeNode(
str_angle);
1150 if (node_x ==
NULL)
throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"x\" attribute" << std::endl;
1151 if (node_y ==
NULL)
throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"y\" attribute" << std::endl;
1152 if (node_z ==
NULL)
throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"z\" attribute" << std::endl;
1153 if (node_angle ==
NULL)
throw cms::Exception(
"XMLException") <<
"<rotateglobalaxis> is missing required \"angle\" attribute" << std::endl;
1160 for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1166 double aprime = x/
sqrt(x*x + y*y + z*z);
1167 double bprime = y/
sqrt(x*x + y*y + z*z);
1168 double cprime = z/
sqrt(x*x + y*y + z*z);
1169 double q0 =
cos(angle/2.);
1170 double q1 =
sin(angle/2.) * aprime;
1171 double q2 =
sin(angle/2.) * bprime;
1172 double q3 =
sin(angle/2.) * cprime;
1174 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();
1175 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();
1176 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();
1178 double movex = pos2x - pos.
x();
1179 double movey = pos2y - pos.
y();
1180 double movez = pos2z - pos.
z();
1187 if (survey !=
NULL) {
1188 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)
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
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
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
std::vector< Alignable * > CSCEndcaps()
Cos< T >::type cos(const T &t)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
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.
std::vector< Alignable * > DTBarrel()
AlgebraicVector EulerAngles
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
void setSurvey(const SurveyDet *)
Set survey info.
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)
Global3DVector GlobalVector
T angle(T x1, T y1, T z1, T x2, T y2, T z2)