CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonAlignmentInputXML Class Reference

#include <Alignment/MuonAlignment/interface/MuonAlignmentInputXML.h>

Inheritance diagram for MuonAlignmentInputXML:
MuonAlignmentInputMethod

Public Member Functions

 MuonAlignmentInputXML (const std::string &fileName)
 
AlignableMuonnewAlignableMuon (const edm::EventSetup &iSetup) const override
 
 ~MuonAlignmentInputXML () override
 
- Public Member Functions inherited from MuonAlignmentInputMethod
 MuonAlignmentInputMethod ()
 
virtual ~MuonAlignmentInputMethod ()
 

Private Member Functions

void do_moveglobal (const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
 
void do_movelocal (const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
 
void do_rotatebeamline (const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
 
void do_rotateglobalaxis (const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
 
void do_rotatelocal (const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
 
void do_setape (const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
 
void do_setposition (const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
 
void do_setsurveyerr (const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
 
void fillAliToIdeal (std::map< Alignable *, Alignable * > &alitoideal, const align::Alignables &alignables, const align::Alignables &ideals) const
 
AlignablegetCSCnode (align::StructureType structureType, std::map< unsigned int, Alignable * > &alignableNavigator, const XERCES_CPP_NAMESPACE::DOMElement *node, const AlignableObjectId &) const
 
AlignablegetDTnode (align::StructureType structureType, std::map< unsigned int, Alignable * > &alignableNavigator, const XERCES_CPP_NAMESPACE::DOMElement *node, const AlignableObjectId &) const
 
AlignablegetNode (std::map< unsigned int, Alignable * > &alignableNavigator, const XERCES_CPP_NAMESPACE::DOMElement *node, const AlignableObjectId &) const
 
 MuonAlignmentInputXML (const MuonAlignmentInputXML &)=delete
 
const MuonAlignmentInputXMLoperator= (const MuonAlignmentInputXML &)=delete
 
double parseDouble (const XMLCh *str, const char *attribute) const
 
void recursiveGetId (std::map< unsigned int, Alignable * > &alignableNavigator, const align::Alignables &alignables) const
 
void set_one_position (Alignable *ali, const align::PositionType &pos, const align::RotationType &rot) const
 

Private Attributes

std::string m_fileName
 
XMLCh * str_aa
 
XMLCh * str_ab
 
XMLCh * str_ac
 
XMLCh * str_alpha
 
XMLCh * str_angle
 
XMLCh * str_axisx
 
XMLCh * str_axisy
 
XMLCh * str_axisz
 
XMLCh * str_bb
 
XMLCh * str_bc
 
XMLCh * str_beta
 
XMLCh * str_cc
 
XMLCh * str_chamber
 
XMLCh * str_collection
 
XMLCh * str_container
 
XMLCh * str_CSCChamber
 
XMLCh * str_CSCEndcap
 
XMLCh * str_CSCLayer
 
XMLCh * str_CSCRing
 
XMLCh * str_CSCStation
 
XMLCh * str_DTBarrel
 
XMLCh * str_DTChamber
 
XMLCh * str_DTLayer
 
XMLCh * str_DTStation
 
XMLCh * str_DTSuperLayer
 
XMLCh * str_DTWheel
 
XMLCh * str_endcap
 
XMLCh * str_gamma
 
XMLCh * str_ideal
 
XMLCh * str_layer
 
XMLCh * str_moveglobal
 
XMLCh * str_movelocal
 
XMLCh * str_name
 
XMLCh * str_none
 
XMLCh * str_operation
 
XMLCh * str_phi
 
XMLCh * str_phix
 
XMLCh * str_phiy
 
XMLCh * str_phiz
 
XMLCh * str_rawId
 
XMLCh * str_relativeto
 
XMLCh * str_ring
 
XMLCh * str_rotatebeamline
 
XMLCh * str_rotateglobalaxis
 
XMLCh * str_rotatelocal
 
XMLCh * str_rphi
 
XMLCh * str_sector
 
XMLCh * str_setape
 
XMLCh * str_setposition
 
XMLCh * str_setsurveyerr
 
XMLCh * str_station
 
XMLCh * str_superlayer
 
XMLCh * str_wheel
 
XMLCh * str_x
 
XMLCh * str_xa
 
XMLCh * str_xb
 
XMLCh * str_xc
 
XMLCh * str_xx
 
XMLCh * str_xy
 
XMLCh * str_xz
 
XMLCh * str_y
 
XMLCh * str_ya
 
XMLCh * str_yb
 
XMLCh * str_yc
 
XMLCh * str_yy
 
XMLCh * str_yz
 
XMLCh * str_z
 
XMLCh * str_za
 
XMLCh * str_zb
 
XMLCh * str_zc
 
XMLCh * str_zz
 

Additional Inherited Members

- Protected Member Functions inherited from MuonAlignmentInputMethod
std::shared_ptr< CSCGeometryidealCSCGeometry (const edm::EventSetup &iSetup) const
 
std::shared_ptr< DTGeometryidealDTGeometry (const edm::EventSetup &iSetup) const
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 34 of file MuonAlignmentInputXML.h.

Constructor & Destructor Documentation

XERCES_CPP_NAMESPACE_USE MuonAlignmentInputXML::MuonAlignmentInputXML ( const std::string &  fileName)

Definition at line 47 of file MuonAlignmentInputXML.cc.

References str_aa, str_ab, str_ac, str_alpha, str_angle, str_axisx, str_axisy, str_axisz, str_bb, str_bc, str_beta, str_cc, str_chamber, str_collection, str_container, str_CSCChamber, str_CSCEndcap, str_CSCLayer, str_CSCRing, str_CSCStation, str_DTBarrel, str_DTChamber, str_DTLayer, str_DTStation, str_DTSuperLayer, str_DTWheel, str_endcap, str_gamma, str_ideal, str_layer, str_moveglobal, str_movelocal, str_name, str_none, str_operation, str_phi, str_phix, str_phiy, str_phiz, str_rawId, str_relativeto, str_ring, str_rotatebeamline, str_rotateglobalaxis, str_rotatelocal, str_rphi, str_sector, str_setape, str_setposition, str_setsurveyerr, str_station, str_superlayer, str_wheel, str_x, str_xa, str_xb, str_xc, str_xx, str_xy, str_xz, str_y, str_ya, str_yb, str_yc, str_yy, str_yz, str_z, str_za, str_zb, str_zc, str_zz, and cms::concurrency::xercesInitialize().

49 {
51  str_operation = XMLString::transcode("operation");
52  str_collection = XMLString::transcode("collection");
53  str_name = XMLString::transcode("name");
54  str_DTBarrel = XMLString::transcode("DTBarrel");
55  str_DTWheel = XMLString::transcode("DTWheel");
56  str_DTStation = XMLString::transcode("DTStation");
57  str_DTChamber = XMLString::transcode("DTChamber");
58  str_DTSuperLayer = XMLString::transcode("DTSuperLayer");
59  str_DTLayer = XMLString::transcode("DTLayer");
60  str_CSCEndcap = XMLString::transcode("CSCEndcap");
61  str_CSCStation = XMLString::transcode("CSCStation");
62  str_CSCRing = XMLString::transcode("CSCRing");
63  str_CSCChamber = XMLString::transcode("CSCChamber");
64  str_CSCLayer = XMLString::transcode("CSCLayer");
65  str_setposition = XMLString::transcode("setposition");
66  str_setape = XMLString::transcode("setape");
67  str_setsurveyerr = XMLString::transcode("setsurveyerr");
68  str_moveglobal = XMLString::transcode("moveglobal");
69  str_movelocal = XMLString::transcode("movelocal");
70  str_rotatelocal = XMLString::transcode("rotatelocal");
71  str_rotatebeamline = XMLString::transcode("rotatebeamline");
72  str_rotateglobalaxis = XMLString::transcode("rotateglobalaxis");
73  str_relativeto = XMLString::transcode("relativeto");
74  str_rawId = XMLString::transcode("rawId");
75  str_wheel = XMLString::transcode("wheel");
76  str_station = XMLString::transcode("station");
77  str_sector = XMLString::transcode("sector");
78  str_superlayer = XMLString::transcode("superlayer");
79  str_layer = XMLString::transcode("layer");
80  str_endcap = XMLString::transcode("endcap");
81  str_ring = XMLString::transcode("ring");
82  str_chamber = XMLString::transcode("chamber");
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");
121  str_container = XMLString::transcode("container");
122 }
void xercesInitialize()
Definition: Xerces.cc:18
MuonAlignmentInputXML::~MuonAlignmentInputXML ( )
override

Definition at line 129 of file MuonAlignmentInputXML.cc.

References fetchall_from_DQM_v2::release, str_aa, str_ab, str_ac, str_alpha, str_angle, str_axisx, str_axisy, str_axisz, str_bb, str_bc, str_beta, str_cc, str_chamber, str_collection, str_container, str_CSCChamber, str_CSCEndcap, str_CSCLayer, str_CSCRing, str_CSCStation, str_DTBarrel, str_DTChamber, str_DTLayer, str_DTStation, str_DTSuperLayer, str_DTWheel, str_endcap, str_gamma, str_ideal, str_layer, str_moveglobal, str_movelocal, str_name, str_none, str_operation, str_phi, str_phix, str_phiy, str_phiz, str_rawId, str_relativeto, str_ring, str_rotatebeamline, str_rotateglobalaxis, str_rotatelocal, str_rphi, str_sector, str_setape, str_setposition, str_setsurveyerr, str_station, str_superlayer, str_wheel, str_x, str_xa, str_xb, str_xc, str_xx, str_xy, str_xz, str_y, str_ya, str_yb, str_yc, str_yy, str_yz, str_z, str_za, str_zb, str_zc, str_zz, and cms::concurrency::xercesTerminate().

129  {
202 }
void xercesTerminate()
Definition: Xerces.cc:23
MuonAlignmentInputXML::MuonAlignmentInputXML ( const MuonAlignmentInputXML )
privatedelete

Member Function Documentation

void MuonAlignmentInputXML::do_moveglobal ( const XERCES_CPP_NAMESPACE::DOMElement *  node,
std::map< Alignable *, bool > &  aliset,
std::map< Alignable *, Alignable * > &  alitoideal 
) const
private

Definition at line 1062 of file MuonAlignmentInputXML.cc.

References SurveyDet::errors(), Exception, Alignable::move(), parseDouble(), Alignable::setSurvey(), str_x, str_y, str_z, Alignable::surface(), Alignable::survey(), x, y, and z.

Referenced by newAlignableMuon().

1062  {
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;
1069 
1070  double x = parseDouble(node_x->getValue(), "x");
1071  double y = parseDouble(node_y->getValue(), "y");
1072  double z = parseDouble(node_z->getValue(), "z");
1073  align::GlobalVector vect(x, y, z);
1074 
1075  for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1076  Alignable *ali = aliiter->first;
1077 
1078  ali->move(vect);
1079 
1080  align::ErrorMatrix matrix6x6 = ROOT::Math::SMatrixIdentity();
1081  matrix6x6 *= 1000.; // initial assumption: infinitely weak constraint
1082 
1083  const SurveyDet *survey = ali->survey();
1084  if (survey != nullptr) {
1085  matrix6x6 = survey->errors(); // save the constraint information
1086  }
1087  ali->setSurvey(new SurveyDet(ali->surface(), matrix6x6));
1088  } // end loop over alignables
1089 }
double parseDouble(const XMLCh *str, const char *attribute) const
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:225
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
const align::ErrorMatrix & errors() const
Definition: SurveyDet.h:73
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:343
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
void MuonAlignmentInputXML::do_movelocal ( const XERCES_CPP_NAMESPACE::DOMElement *  node,
std::map< Alignable *, bool > &  aliset,
std::map< Alignable *, Alignable * > &  alitoideal 
) const
private

Definition at line 1091 of file MuonAlignmentInputXML.cc.

References SurveyDet::errors(), Exception, Alignable::move(), parseDouble(), Alignable::setSurvey(), str_x, str_y, str_z, Alignable::surface(), Alignable::survey(), AlignableSurface::toGlobal(), x, y, and z.

Referenced by newAlignableMuon().

1091  {
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;
1098 
1099  double x = parseDouble(node_x->getValue(), "x");
1100  double y = parseDouble(node_y->getValue(), "y");
1101  double z = parseDouble(node_z->getValue(), "z");
1102  align::LocalVector vect(x, y, z);
1103 
1104  for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1105  Alignable *ali = aliiter->first;
1106 
1107  align::GlobalVector globalVector = ali->surface().toGlobal(vect);
1108  ali->move(globalVector);
1109 
1110  align::ErrorMatrix matrix6x6 = ROOT::Math::SMatrixIdentity();
1111  matrix6x6 *= 1000.; // initial assumption: infinitely weak constraint
1112 
1113  const SurveyDet *survey = ali->survey();
1114  if (survey != nullptr) {
1115  matrix6x6 = survey->errors(); // save the constraint information
1116  }
1117  ali->setSurvey(new SurveyDet(ali->surface(), matrix6x6));
1118  } // end loop over alignables
1119 }
double parseDouble(const XMLCh *str, const char *attribute) const
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:225
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
const align::ErrorMatrix & errors() const
Definition: SurveyDet.h:73
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:343
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
void MuonAlignmentInputXML::do_rotatebeamline ( const XERCES_CPP_NAMESPACE::DOMElement *  node,
std::map< Alignable *, bool > &  aliset,
std::map< Alignable *, Alignable * > &  alitoideal 
) const
private

Definition at line 1153 of file MuonAlignmentInputXML.cc.

References funct::cos(), SurveyDet::errors(), Exception, Alignable::move(), parseDouble(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), TCMET_cfi::radius, Alignable::rotateAroundGlobalZ(), Alignable::setSurvey(), funct::sin(), str_phi, str_rphi, Alignable::surface(), Alignable::survey(), AlignableSurface::toGlobal(), and relativeConstraints::value.

Referenced by newAlignableMuon().

1153  {
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;
1158 
1159  double value;
1160  if (node_rphi != nullptr) {
1161  value = parseDouble(node_rphi->getValue(), "rphi");
1162  }
1163  else {
1164  value = parseDouble(node_phi->getValue(), "phi");
1165  }
1166 
1167  for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1168  Alignable *ali = aliiter->first;
1169 
1171 
1172  double radius = pos.perp();
1173  double phi0 = pos.phi();
1174  double deltaphi = value;
1175  if (node_rphi != nullptr) deltaphi = value / radius;
1176 
1177  ali->rotateAroundGlobalZ(deltaphi);
1178  ali->move(align::GlobalVector(radius * (cos(phi0 + deltaphi) - cos(phi0)),
1179  radius * (sin(phi0 + deltaphi) - sin(phi0)),
1180  0.));
1181 
1182  align::ErrorMatrix matrix6x6 = ROOT::Math::SMatrixIdentity();
1183  matrix6x6 *= 1000.; // initial assumption: infinitely weak constraint
1184 
1185  const SurveyDet *survey = ali->survey();
1186  if (survey != nullptr) {
1187  matrix6x6 = survey->errors(); // save the constraint information
1188  }
1189  ali->setSurvey(new SurveyDet(ali->surface(), matrix6x6));
1190  } // end loop over alignables
1191 }
T perp() const
Definition: PV3DBase.h:72
double parseDouble(const XMLCh *str, const char *attribute) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:225
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
const align::ErrorMatrix & errors() const
Definition: SurveyDet.h:73
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
Definition: Alignable.cc:221
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:343
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
void MuonAlignmentInputXML::do_rotateglobalaxis ( const XERCES_CPP_NAMESPACE::DOMElement *  node,
std::map< Alignable *, bool > &  aliset,
std::map< Alignable *, Alignable * > &  alitoideal 
) const
private

Definition at line 1193 of file MuonAlignmentInputXML.cc.

References angle(), funct::cos(), SurveyDet::errors(), Exception, Alignable::move(), parseDouble(), q1, q2, Alignable::rotateAroundGlobalAxis(), Alignable::setSurvey(), funct::sin(), mathSSE::sqrt(), str_angle, str_x, str_y, str_z, Alignable::surface(), Alignable::survey(), AlignableSurface::toGlobal(), x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by newAlignableMuon().

1193  {
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;
1202 
1203  double x = parseDouble(node_x->getValue(), "x");
1204  double y = parseDouble(node_y->getValue(), "y");
1205  double z = parseDouble(node_z->getValue(), "z");
1206  double angle = parseDouble(node_angle->getValue(), "angle");
1207 
1208  for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1209  Alignable *ali = aliiter->first;
1211 
1212  ali->rotateAroundGlobalAxis(align::GlobalVector(x, y, z), angle);
1213 
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;
1221 
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();
1225 
1226  double movex = pos2x - pos.x();
1227  double movey = pos2y - pos.y();
1228  double movez = pos2z - pos.z();
1229  ali->move(align::GlobalVector(movex, movey, movez));
1230 
1231  align::ErrorMatrix matrix6x6 = ROOT::Math::SMatrixIdentity();
1232  matrix6x6 *= 1000.; // initial assumption: infinitely weak constraint
1233 
1234  const SurveyDet *survey = ali->survey();
1235  if (survey != nullptr) {
1236  matrix6x6 = survey->errors(); // save the constraint information
1237  }
1238  ali->setSurvey(new SurveyDet(ali->surface(), matrix6x6));
1239  } // end loop over alignables
1240 }
double parseDouble(const XMLCh *str, const char *attribute) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:225
T y() const
Definition: PV3DBase.h:63
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
const align::ErrorMatrix & errors() const
Definition: SurveyDet.h:73
virtual void rotateAroundGlobalAxis(const GlobalVector &axis, Scalar radians)
Rotation around arbitratry global axis.
Definition: Alignable.cc:151
double q2[4]
Definition: TauolaWrapper.h:88
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
double q1[4]
Definition: TauolaWrapper.h:87
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:343
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
T x() const
Definition: PV3DBase.h:62
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
void MuonAlignmentInputXML::do_rotatelocal ( const XERCES_CPP_NAMESPACE::DOMElement *  node,
std::map< Alignable *, bool > &  aliset,
std::map< Alignable *, Alignable * > &  alitoideal 
) const
private

Definition at line 1121 of file MuonAlignmentInputXML.cc.

References angle(), SurveyDet::errors(), Exception, parseDouble(), Alignable::rotateAroundLocalAxis(), Alignable::setSurvey(), str_angle, str_axisx, str_axisy, str_axisz, Alignable::surface(), Alignable::survey(), x, y, and z.

Referenced by newAlignableMuon().

1121  {
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;
1130 
1131  double x = parseDouble(node_axisx->getValue(), "x");
1132  double y = parseDouble(node_axisy->getValue(), "y");
1133  double z = parseDouble(node_axisz->getValue(), "z");
1134  double angle = parseDouble(node_angle->getValue(), "angle");
1135  align::LocalVector vect(x, y, z);
1136 
1137  for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1138  Alignable *ali = aliiter->first;
1139 
1140  ali->rotateAroundLocalAxis(vect, angle);
1141 
1142  align::ErrorMatrix matrix6x6 = ROOT::Math::SMatrixIdentity();
1143  matrix6x6 *= 1000.; // initial assumption: infinitely weak constraint
1144 
1145  const SurveyDet *survey = ali->survey();
1146  if (survey != nullptr) {
1147  matrix6x6 = survey->errors(); // save the constraint information
1148  }
1149  ali->setSurvey(new SurveyDet(ali->surface(), matrix6x6));
1150  } // end loop over alignables
1151 }
virtual void rotateAroundLocalAxis(const LocalVector &axis, Scalar radians)
Rotation around arbitratry local axis.
Definition: Alignable.cc:160
double parseDouble(const XMLCh *str, const char *attribute) const
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:225
const align::ErrorMatrix & errors() const
Definition: SurveyDet.h:73
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:343
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
void MuonAlignmentInputXML::do_setape ( const XERCES_CPP_NAMESPACE::DOMElement *  node,
std::map< Alignable *, bool > &  aliset,
std::map< Alignable *, Alignable * > &  alitoideal 
) const
private

Definition at line 914 of file MuonAlignmentInputXML.cc.

References Exception, parseDouble(), str_aa, str_ab, str_ac, str_bb, str_bc, str_cc, str_xa, str_xb, str_xc, str_xx, str_xy, str_xz, str_ya, str_yb, str_yc, str_yy, str_yz, str_za, str_zb, str_zc, and str_zz.

Referenced by newAlignableMuon().

914  {
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);
936 
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;
958 
959  align::ErrorMatrix matrix6x6;
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");
981 
982  for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
983  // this sets APEs at this level and (since 2nd argument is true) all lower levels
984  aliiter->first->setAlignmentPositionError(AlignmentPositionError(matrix6x6), true);
985  }
986 }
double parseDouble(const XMLCh *str, const char *attribute) const
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
void MuonAlignmentInputXML::do_setposition ( const XERCES_CPP_NAMESPACE::DOMElement *  node,
std::map< Alignable *, bool > &  aliset,
std::map< Alignable *, Alignable * > &  alitoideal 
) const
private

Definition at line 721 of file MuonAlignmentInputXML.cc.

References alpha, PV3DBase< T, PVType, FrameType >::basicVector(), beta, funct::cos(), equals(), Exception, CustomPhysics_cfi::gamma, Alignable::globalPosition(), Alignable::globalRotation(), python.rootplot.argparse::message, Alignable::mother(), parseDouble(), convertToXML_global_cfg::relativeto, makeMuonMisalignmentScenario::rot, set_one_position(), funct::sin(), str_alpha, str_beta, str_container, str_gamma, str_ideal, str_none, str_phix, str_phiy, str_phiz, str_relativeto, str_x, str_y, str_z, align::toAngles(), align::toMatrix(), TkRotation< T >::transposed(), x, PV3DBase< T, PVType, FrameType >::x(), TkRotation< T >::xx(), TkRotation< T >::xy(), TkRotation< T >::xz(), y, PV3DBase< T, PVType, FrameType >::y(), TkRotation< T >::yz(), z, PV3DBase< T, PVType, FrameType >::z(), and TkRotation< T >::zz().

Referenced by newAlignableMuon().

721  {
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;
724 
725  int relativeto = 0;
726  if (XMLString::equals(node_relativeto->getValue(), str_none)) {
727  relativeto = 0;
728  }
729  else if (XMLString::equals(node_relativeto->getValue(), str_ideal)) {
730  relativeto = 1;
731  }
732  else if (XMLString::equals(node_relativeto->getValue(), str_container)) {
733  relativeto = 2;
734  }
735  else {
736  char *message = XMLString::transcode(node_relativeto->getValue());
737  throw cms::Exception("XMLException") << "relativeto must be \"none\", \"ideal\", or \"container\", not \"" << message << "\"" << std::endl;
738  }
739 
740  for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
741  // first reconstruct the old position: how it would look in this coordinate system
742 
743  Alignable *ali = aliiter->first;
744  Alignable *ideal = alitoideal[ali];
745 
746  align::PositionType oldpos = ali->globalPosition();
747  align::RotationType oldrot = ali->globalRotation();
748 
749  if (relativeto == 0) {}
750 
751  else if (relativeto == 1) {
752  const align::PositionType& idealPosition = ideal->globalPosition();
753  align::RotationType idealRotation = ideal->globalRotation();
754 
755  oldpos = align::PositionType(idealRotation * (oldpos.basicVector() - idealPosition.basicVector()));
756  oldrot = oldrot * idealRotation.transposed();
757  }
758 
759  else if (relativeto == 2 && ali->mother() != nullptr) {
760  align::PositionType globalPosition = ali->mother()->globalPosition();
761  align::RotationType globalRotation = ali->mother()->globalRotation();
762 
763  oldpos = align::PositionType(globalRotation * (oldpos.basicVector() - globalPosition.basicVector()));
764  oldrot = oldrot * globalRotation.transposed();
765  }
766 
767  double x = oldpos.x();
768  double y = oldpos.y();
769  double z = oldpos.z();
770 
771  double phix = atan2(oldrot.yz(), oldrot.zz());
772  double phiy = asin(-oldrot.xz());
773  double phiz = atan2(oldrot.xy(), oldrot.xx());
774 
775  align::EulerAngles oldEulerAngles = align::toAngles(oldrot);
776  double alpha = oldEulerAngles(1);
777  double beta = oldEulerAngles(2);
778  double gamma = oldEulerAngles(3);
779 
780  // now get the new information; if it's incomplete, use the old position for those coordinates
781 
782  DOMAttr *node_x = node->getAttributeNode(str_x);
783  DOMAttr *node_y = node->getAttributeNode(str_y);
784  DOMAttr *node_z = node->getAttributeNode(str_z);
785 
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");
789  align::PositionType pos(x, y, z);
790 
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);
798 
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;
803 
804  if (phixyz) {
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");
808 
809  // the angle convention originally used in alignment, also known as "non-standard Euler angles with a Z-Y-X convention"
810  // this also gets the sign convention right
811  align::RotationType rotX( 1., 0., 0.,
812  0., cos(phix), sin(phix),
813  0., -sin(phix), cos(phix));
814  align::RotationType rotY( cos(phiy), 0., -sin(phiy),
815  0., 1., 0.,
816  sin(phiy), 0., cos(phiy));
817  align::RotationType rotZ( cos(phiz), sin(phiz), 0.,
818  -sin(phiz), cos(phiz), 0.,
819  0., 0., 1.);
820 
821  rot = rotX * rotY * rotZ;
822  }
823 
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");
828 
829  // standard Euler angles (how they're internally stored in the database)
830  align::EulerAngles eulerAngles(3);
831  eulerAngles(1) = alpha;
832  eulerAngles(2) = beta;
833  eulerAngles(3) = gamma;
834  rot = align::RotationType(align::toMatrix(eulerAngles));
835  }
836 
837  else assert(false); // see above
838 
839  if (relativeto == 0) {
840  set_one_position(aliiter->first, pos, rot);
841  } // end relativeto="none"
842 
843  else if (relativeto == 1) {
844  Alignable *ali = aliiter->first;
845  Alignable *ideal = alitoideal[ali];
846 
847  const align::PositionType& idealPosition = ideal->globalPosition();
848  align::RotationType idealRotation = ideal->globalRotation();
849  align::PositionType newpos = align::PositionType(idealRotation.transposed() * pos.basicVector() + idealPosition.basicVector());
850  align::RotationType newrot = rot * idealRotation;
851 
852  set_one_position(ali, newpos, newrot);
853  } // end relativeto="ideal"
854 
855  else if (relativeto == 2) {
856  Alignable *ali = aliiter->first;
857  Alignable *container = ali->mother();
858 
859  if (container != nullptr) {
860  const align::PositionType& globalPosition = container->globalPosition();
861  align::RotationType globalRotation = container->globalRotation();
862  align::PositionType newpos = align::PositionType(globalRotation.transposed() * pos.basicVector() + globalPosition.basicVector());
863  align::RotationType newrot = rot * globalRotation;
864  set_one_position(ali, newpos, newrot);
865  }
866  else {
867  set_one_position(ali, pos, rot);
868  }
869  } // end relativeto="container"
870 
871  } // end loop over alignables
872 }
T xx() const
const double beta
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
float alpha
Definition: AMPTWrapper.h:95
double parseDouble(const XMLCh *str, const char *attribute) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T y() const
Definition: PV3DBase.h:63
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:141
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:30
T xy() const
T zz() const
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:9
AlgebraicVector EulerAngles
Definition: Definitions.h:36
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
T xz() const
TkRotation transposed() const
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:42
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:138
void set_one_position(Alignable *ali, const align::PositionType &pos, const align::RotationType &rot) const
T x() const
Definition: PV3DBase.h:62
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:94
T yz() const
void MuonAlignmentInputXML::do_setsurveyerr ( const XERCES_CPP_NAMESPACE::DOMElement *  node,
std::map< Alignable *, bool > &  aliset,
std::map< Alignable *, Alignable * > &  alitoideal 
) const
private

Definition at line 988 of file MuonAlignmentInputXML.cc.

References Exception, parseDouble(), Alignable::setSurvey(), str_aa, str_ab, str_ac, str_bb, str_bc, str_cc, str_xa, str_xb, str_xc, str_xx, str_xy, str_xz, str_ya, str_yb, str_yc, str_yy, str_yz, str_za, str_zb, str_zc, str_zz, and Alignable::surface().

Referenced by newAlignableMuon().

988  {
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);
1010 
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;
1032 
1033  align::ErrorMatrix matrix6x6;
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");
1055 
1056  for (std::map<Alignable*, bool>::const_iterator aliiter = aliset.begin(); aliiter != aliset.end(); ++aliiter) {
1057  Alignable *ali = aliiter->first;
1058  ali->setSurvey(new SurveyDet(ali->surface(), matrix6x6));
1059  }
1060 }
double parseDouble(const XMLCh *str, const char *attribute) const
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:343
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
void MuonAlignmentInputXML::fillAliToIdeal ( std::map< Alignable *, Alignable * > &  alitoideal,
const align::Alignables alignables,
const align::Alignables ideals 
) const
private

Definition at line 231 of file MuonAlignmentInputXML.cc.

References Exception.

Referenced by newAlignableMuon().

231  {
232  align::Alignables::const_iterator alignable = alignables.begin();
233  align::Alignables::const_iterator ideal = ideals.begin();
234 
235  while (alignable != alignables.end() && ideal != ideals.end()) {
236  alitoideal[*alignable] = *ideal;
237 
238  fillAliToIdeal(alitoideal, (*alignable)->components(), (*ideal)->components());
239 
240  ++alignable;
241  ++ideal;
242  }
243 
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)";
246  }
247 }
void fillAliToIdeal(std::map< Alignable *, Alignable * > &alitoideal, const align::Alignables &alignables, const align::Alignables &ideals) const
Alignable * MuonAlignmentInputXML::getCSCnode ( align::StructureType  structureType,
std::map< unsigned int, Alignable * > &  alignableNavigator,
const XERCES_CPP_NAMESPACE::DOMElement *  node,
const AlignableObjectId alignableObjectId 
) const
private

Definition at line 552 of file MuonAlignmentInputXML.cc.

References align::AlignableCSCChamber, align::AlignableCSCEndcap, align::AlignableCSCRing, align::AlignableCSCStation, Alignable::alignableObjectId(), relativeConstraints::chamber, makeMuonMisalignmentScenario::endcap, Exception, AlignableObjectId::idToString(), Alignable::mother(), DetId::rawId(), relativeConstraints::ring, relativeConstraints::station, str_chamber, str_endcap, str_layer, str_rawId, str_ring, and str_station.

Referenced by getNode().

554  {
555  unsigned int rawId;
556 
557  DOMAttr *node_rawId = node->getAttributeNode(str_rawId);
558  if (node_rawId != nullptr) {
559  try {
560  rawId = XMLString::parseInt(node_rawId->getValue());
561  }
562  catch (const XMLException &toCatch) {
563  throw cms::Exception("XMLException") << "Value of \"rawId\" must be an integer" << std::endl;
564  }
565  }
566  else {
567  int endcap, station, ring, chamber, layer;
568  endcap = station = ring = chamber = layer = 1;
569 
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;
572  try {
573  endcap = XMLString::parseInt(node_endcap->getValue());
574  }
575  catch (const XMLException &toCatch) {
576  throw cms::Exception("XMLException") << "Value of \"endcap\" must be an integer" << std::endl;
577  }
578  if (endcap == -1) endcap = 2;
579 
580  if (structureType != align::AlignableCSCEndcap) {
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;
583  try {
584  station = XMLString::parseInt(node_station->getValue());
585  }
586  catch (const XMLException &toCatch) {
587  throw cms::Exception("XMLException") << "Value of \"station\" must be an integer" << std::endl;
588  }
589 
590  if (structureType != align::AlignableCSCStation) {
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;
593  try {
594  ring = XMLString::parseInt(node_ring->getValue());
595  }
596  catch (const XMLException &toCatch) {
597  throw cms::Exception("XMLException") << "Value of \"ring\" must be an integer" << std::endl;
598  }
599 
600  if (structureType != align::AlignableCSCRing) {
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;
603  try {
604  chamber = XMLString::parseInt(node_chamber->getValue());
605  }
606  catch (const XMLException &toCatch) {
607  throw cms::Exception("XMLException") << "Value of \"chamber\" must be an integer" << std::endl;
608  }
609 
610  if (structureType != align::AlignableCSCChamber) {
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;
613  try {
614  layer = XMLString::parseInt(node_layer->getValue());
615  }
616  catch (const XMLException &toCatch) {
617  throw cms::Exception("XMLException") << "Value of \"layer\" must be an integer" << std::endl;
618  }
619 
620  } // end if we need a layer number
621  } // end if we need a chamber number
622  } // end if we need a ring number
623  } // end if we need a station number
624 
625  CSCDetId layerId(endcap, station, ring, chamber, layer);
626  rawId = layerId.rawId();
627  } // end if it's specified by endcap, station, ring, chamber, layer
628 
629  Alignable *ali = alignableNavigator[rawId];
630  if (ali == nullptr) throw cms::Exception("XMLException") << "rawId \"" << rawId << "\" is not recognized" << std::endl;
631 
632  while (ali->alignableObjectId() != structureType) {
633  ali = ali->mother();
634 
635  if (ali == nullptr) {
636  throw cms::Exception("XMLException")
637  << "rawId \"" << rawId << "\" is not a "
638  << alignableObjectId.idToString(structureType) << std::endl;
639  }
640  }
641  return ali;
642 }
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const char * idToString(align::StructureType type) const
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:94
Alignable * MuonAlignmentInputXML::getDTnode ( align::StructureType  structureType,
std::map< unsigned int, Alignable * > &  alignableNavigator,
const XERCES_CPP_NAMESPACE::DOMElement *  node,
const AlignableObjectId alignableObjectId 
) const
private

Definition at line 459 of file MuonAlignmentInputXML.cc.

References align::AlignableDTBarrel, align::AlignableDTChamber, align::AlignableDTStation, align::AlignableDTSuperLayer, align::AlignableDTWheel, Alignable::alignableObjectId(), Exception, AlignableObjectId::idToString(), Alignable::mother(), DetId::rawId(), relativeConstraints::station, str_layer, str_rawId, str_sector, str_station, str_superlayer, str_wheel, and makeMuonMisalignmentScenario::wheel.

Referenced by getNode().

461  {
462  unsigned int rawId = 0;
463 
464  DOMAttr *node_rawId = node->getAttributeNode(str_rawId);
465  if (node_rawId != nullptr) {
466  try {
467  rawId = XMLString::parseInt(node_rawId->getValue());
468  }
469  catch (const XMLException &toCatch) {
470  throw cms::Exception("XMLException") << "Value of \"rawId\" must be an integer" << std::endl;
471  }
472  }
473  else {
474  int wheel, station, sector, superlayer, layer;
475  wheel = station = sector = superlayer = layer = 1;
476 
477  if (structureType != align::AlignableDTBarrel) {
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;
480  try {
481  wheel = XMLString::parseInt(node_wheel->getValue());
482  }
483  catch (const XMLException &toCatch) {
484  throw cms::Exception("XMLException") << "Value of \"wheel\" must be an integer" << std::endl;
485  }
486 
487  if (structureType != align::AlignableDTWheel) {
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;
490  try {
491  station = XMLString::parseInt(node_station->getValue());
492  }
493  catch (const XMLException &toCatch) {
494  throw cms::Exception("XMLException") << "Value of \"station\" must be an integer" << std::endl;
495  }
496 
497  if (structureType != align::AlignableDTStation) {
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;
500  try {
501  sector = XMLString::parseInt(node_sector->getValue());
502  }
503  catch (const XMLException &toCatch) {
504  throw cms::Exception("XMLException") << "Value of \"sector\" must be an integer" << std::endl;
505  }
506 
507  if (structureType != align::AlignableDTChamber) {
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;
510  try {
511  superlayer = XMLString::parseInt(node_superlayer->getValue());
512  }
513  catch (const XMLException &toCatch) {
514  throw cms::Exception("XMLException") << "Value of \"superlayer\" must be an integer" << std::endl;
515  }
516 
517  if (structureType != align::AlignableDTSuperLayer) {
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;
520  try {
521  layer = XMLString::parseInt(node_layer->getValue());
522  }
523  catch (const XMLException &toCatch) {
524  throw cms::Exception("XMLException") << "Value of \"layer\" must be an integer" << std::endl;
525  }
526 
527  } // end if we need a layer number
528  } // end if we need a superlayer number
529  } // end if we need a sector number
530  } // end if we need a station number
531  } // end if we need a wheel number
532 
533  DTLayerId layerId(wheel, station, sector, superlayer, layer);
534  rawId = layerId.rawId();
535  } // end if it's specified by wheel, station, sector, superlayer, layer
536 
537  Alignable *ali = alignableNavigator[rawId];
538  if (ali == nullptr) throw cms::Exception("XMLException") << "rawId \"" << rawId << "\" is not recognized" << std::endl;
539 
540  while (ali->alignableObjectId() != structureType) {
541  ali = ali->mother();
542 
543  if (ali == nullptr) {
544  throw cms::Exception("XMLException")
545  << "rawId \"" << rawId << "\" is not a "
546  << alignableObjectId.idToString(structureType) << std::endl;
547  }
548  }
549  return ali;
550 }
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const char * idToString(align::StructureType type) const
Alignable * mother() const
Return pointer to container alignable (if any)
Definition: Alignable.h:94
Alignable * MuonAlignmentInputXML::getNode ( std::map< unsigned int, Alignable * > &  alignableNavigator,
const XERCES_CPP_NAMESPACE::DOMElement *  node,
const AlignableObjectId alignableObjectId 
) const
private

Definition at line 442 of file MuonAlignmentInputXML.cc.

References align::AlignableCSCChamber, align::AlignableCSCEndcap, align::AlignableCSCRing, align::AlignableCSCStation, align::AlignableDetUnit, align::AlignableDTBarrel, align::AlignableDTChamber, align::AlignableDTStation, align::AlignableDTSuperLayer, align::AlignableDTWheel, equals(), getCSCnode(), getDTnode(), str_CSCChamber, str_CSCEndcap, str_CSCLayer, str_CSCRing, str_CSCStation, str_DTBarrel, str_DTChamber, str_DTLayer, str_DTStation, str_DTSuperLayer, and str_DTWheel.

Referenced by newAlignableMuon().

444  {
445  if (XMLString::equals(node->getNodeName(), str_DTBarrel)) return getDTnode(align::AlignableDTBarrel, alignableNavigator, node, alignableObjectId);
446  else if (XMLString::equals(node->getNodeName(), str_DTWheel)) return getDTnode(align::AlignableDTWheel, alignableNavigator, node, alignableObjectId);
447  else if (XMLString::equals(node->getNodeName(), str_DTStation)) return getDTnode(align::AlignableDTStation, alignableNavigator, node, alignableObjectId);
448  else if (XMLString::equals(node->getNodeName(), str_DTChamber)) return getDTnode(align::AlignableDTChamber, alignableNavigator, node, alignableObjectId);
449  else if (XMLString::equals(node->getNodeName(), str_DTSuperLayer)) return getDTnode(align::AlignableDTSuperLayer, alignableNavigator, node, alignableObjectId);
450  else if (XMLString::equals(node->getNodeName(), str_DTLayer)) return getDTnode(align::AlignableDetUnit, alignableNavigator, node, alignableObjectId);
451  else if (XMLString::equals(node->getNodeName(), str_CSCEndcap)) return getCSCnode(align::AlignableCSCEndcap, alignableNavigator, node, alignableObjectId);
452  else if (XMLString::equals(node->getNodeName(), str_CSCStation)) return getCSCnode(align::AlignableCSCStation, alignableNavigator, node, alignableObjectId);
453  else if (XMLString::equals(node->getNodeName(), str_CSCRing)) return getCSCnode(align::AlignableCSCRing, alignableNavigator, node, alignableObjectId);
454  else if (XMLString::equals(node->getNodeName(), str_CSCChamber)) return getCSCnode(align::AlignableCSCChamber, alignableNavigator, node, alignableObjectId);
455  else if (XMLString::equals(node->getNodeName(), str_CSCLayer)) return getCSCnode(align::AlignableDetUnit, alignableNavigator, node, alignableObjectId);
456  else return nullptr;
457 }
Alignable * getCSCnode(align::StructureType structureType, std::map< unsigned int, Alignable * > &alignableNavigator, const XERCES_CPP_NAMESPACE::DOMElement *node, const AlignableObjectId &) const
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
Alignable * getDTnode(align::StructureType structureType, std::map< unsigned int, Alignable * > &alignableNavigator, const XERCES_CPP_NAMESPACE::DOMElement *node, const AlignableObjectId &) const
AlignableMuon * MuonAlignmentInputXML::newAlignableMuon ( const edm::EventSetup iSetup) const
overridevirtual

Reimplemented from MuonAlignmentInputMethod.

Definition at line 249 of file MuonAlignmentInputXML.cc.

References align::AlignableMuon, class-composition::children, universalConfigTemplate::collection, AlignableMuon::CSCEndcaps(), do_moveglobal(), do_movelocal(), do_rotatebeamline(), do_rotateglobalaxis(), do_rotatelocal(), do_setape(), do_setposition(), do_setsurveyerr(), common_cff::doc, AlignableMuon::DTBarrel(), equals(), Exception, fillAliToIdeal(), getNode(), mps_fire::i, MuonAlignmentInputMethod::idealCSCGeometry(), MuonAlignmentInputMethod::idealDTGeometry(), m_fileName, python.rootplot.argparse::message, dataset::name, AlignableMuon::objectIdProvider(), createfilelist::parser, recursiveGetId(), fetchall_from_DQM_v2::release, str_collection, str_moveglobal, str_movelocal, str_name, str_operation, str_rotatebeamline, str_rotateglobalaxis, str_rotatelocal, str_setape, str_setposition, str_setsurveyerr, AlCaHLTBitMon_QueryRunRegistry::string, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

249  {
250  std::shared_ptr<DTGeometry> dtGeometry = idealDTGeometry(iSetup);
251  std::shared_ptr<CSCGeometry> cscGeometry = idealCSCGeometry(iSetup);
252 
253  AlignableMuon *alignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry));
254  std::map<unsigned int, Alignable*> alignableNavigator; // real AlignableNavigators don't have const methods
255  recursiveGetId(alignableNavigator, alignableMuon->DTBarrel());
256  recursiveGetId(alignableNavigator, alignableMuon->CSCEndcaps());
257 
258  AlignableMuon *ideal_alignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry));
259  std::map<unsigned int, Alignable*> ideal_alignableNavigator; // real AlignableNavigators don't have const methods
260  recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->DTBarrel());
261  recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->CSCEndcaps());
262 
263  try {
265  }
266  catch (const XMLException &toCatch) {
267  throw cms::Exception("XMLException") << "Xerces XML parser threw an exception on initialization." << std::endl;
268  }
269 
270  XercesDOMParser *parser = new XercesDOMParser();
271  parser->setValidationScheme(XercesDOMParser::Val_Always);
272 
273  XERCES_CPP_NAMESPACE::ErrorHandler *errHandler = (XERCES_CPP_NAMESPACE::ErrorHandler*)(new HandlerBase());
274  parser->setErrorHandler(errHandler);
275 
276  try {
277  parser->parse(m_fileName.c_str());
278  }
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;
282  }
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;
286  }
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;
290  }
291 
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);
296 
297  std::map<Alignable*, Alignable*> alitoideal;
298  fillAliToIdeal(alitoideal, alignableMuon->DTBarrel(), ideal_alignableMuon->DTBarrel());
299  fillAliToIdeal(alitoideal, alignableMuon->CSCEndcaps(), ideal_alignableMuon->CSCEndcaps());
300 
301  const auto& alignableObjectId = alignableMuon->objectIdProvider();
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();
307 
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;
311  }
312  char *ascii_name = XMLString::transcode(node_name->getValue());
313  std::string name(ascii_name);
314  XMLString::release(&ascii_name);
315 
316  std::map<Alignable*, bool> aliset;
317  for (unsigned int j = 0; j < children->getLength(); j++) {
318  DOMNode *node = children->item(j);
319 
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;
324  }
325 
326  aliset[ali] = true;
327  } // end if this node is an element
328  } // end loop over collection's children
329 
330  alicollections[name] = aliset;
331  } // end if this is a top-level collection
332  } // end loop over collections
333 
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;
338  }
339 
340  DOMNodeList *children = operation->getChildNodes();
341 
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);
346 
347  if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
348  Alignable *ali = getNode(alignableNavigator, (DOMElement*)(node), alignableObjectId);
349  if (ali != nullptr) {
350  aliset[ali] = true;
351  nodesToRemove.push_back(node);
352  } // end if this node is an alignable
353 
354  else if (XMLString::equals(node->getNodeName(), str_collection)) {
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;
358  }
359  char *ascii_name = XMLString::transcode(node_name->getValue());
360  std::string name(ascii_name);
361  XMLString::release(&ascii_name);
362 
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;
366  }
367 
368  for (std::map<Alignable*, bool>::const_iterator aliiter = alicollections_iter->second.begin();
369  aliiter != alicollections_iter->second.end();
370  ++aliiter) {
371  aliset[aliiter->first] = true;
372  } // end loop over alignables in this collection
373 
374  nodesToRemove.push_back(node);
375  } // end if this node is a collection
376 
377  else {} // anything else? assume it's a position/rotation directive
378 
379  } // end if node is node is an element
380  } // end first loop over operation's children
381 
382  // from now on, we only want to see position/rotation directives
383  for (std::vector<DOMNode*>::const_iterator node = nodesToRemove.begin(); node != nodesToRemove.end(); ++node) {
384  operation->removeChild(*node);
385  }
386  children = operation->getChildNodes();
387 
388  for (unsigned int j = 0; j < children->getLength(); j++) {
389  DOMNode *node = children->item(j);
390  if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
391 
392  if (XMLString::equals(node->getNodeName(), str_setposition)) {
393  do_setposition((DOMElement*)(node), aliset, alitoideal);
394  }
395 
396  else if (XMLString::equals(node->getNodeName(), str_setape)) {
397  do_setape((DOMElement*)(node), aliset, alitoideal);
398  }
399 
400  else if (XMLString::equals(node->getNodeName(), str_setsurveyerr)) {
401  do_setsurveyerr((DOMElement*)(node), aliset, alitoideal);
402  }
403 
404  else if (XMLString::equals(node->getNodeName(), str_moveglobal)) {
405  do_moveglobal((DOMElement*)(node), aliset, alitoideal);
406  }
407 
408  else if (XMLString::equals(node->getNodeName(), str_movelocal)) {
409  do_movelocal((DOMElement*)(node), aliset, alitoideal);
410  }
411 
412  else if (XMLString::equals(node->getNodeName(), str_rotatelocal)) {
413  do_rotatelocal((DOMElement*)(node), aliset, alitoideal);
414  }
415 
416  else if (XMLString::equals(node->getNodeName(), str_rotatebeamline)) {
417  do_rotatebeamline((DOMElement*)(node), aliset, alitoideal);
418  }
419 
420  else if (XMLString::equals(node->getNodeName(), str_rotateglobalaxis)) {
421  do_rotateglobalaxis((DOMElement*)(node), aliset, alitoideal);
422  }
423 
424  else {
425  char *message = XMLString::transcode(node->getNodeName());
426  throw cms::Exception("XMLException") << "Unrecognized operation: \"" << message << "\"" << std::endl;
427  }
428 
429  } // end if node is an element
430  } // end second loop over operation's children
431  } // end loop over operations
432 
433  delete parser;
434  delete errHandler;
435 
437 
438  delete ideal_alignableMuon;
439  return alignableMuon;
440 }
void do_setsurveyerr(const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
Alignable * getNode(std::map< unsigned int, Alignable * > &alignableNavigator, const XERCES_CPP_NAMESPACE::DOMElement *node, const AlignableObjectId &) const
void do_rotatelocal(const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
void xercesTerminate()
Definition: Xerces.cc:23
align::Alignables DTBarrel()
std::shared_ptr< DTGeometry > idealDTGeometry(const edm::EventSetup &iSetup) const
void do_movelocal(const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
void do_moveglobal(const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
void xercesInitialize()
Definition: Xerces.cc:18
const AlignableObjectId & objectIdProvider() const
Return muon alignable object ID provider derived from the muon system geometry.
Definition: AlignableMuon.h:85
void do_rotatebeamline(const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
std::shared_ptr< CSCGeometry > idealCSCGeometry(const edm::EventSetup &iSetup) const
align::Alignables CSCEndcaps()
void recursiveGetId(std::map< unsigned int, Alignable * > &alignableNavigator, const align::Alignables &alignables) const
void do_setape(const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
void do_rotateglobalaxis(const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
void fillAliToIdeal(std::map< Alignable *, Alignable * > &alitoideal, const align::Alignables &alignables, const align::Alignables &ideals) const
void do_setposition(const XERCES_CPP_NAMESPACE::DOMElement *node, std::map< Alignable *, bool > &aliset, std::map< Alignable *, Alignable * > &alitoideal) const
Constructor of the full muon geometry.
Definition: AlignableMuon.h:37
const MuonAlignmentInputXML& MuonAlignmentInputXML::operator= ( const MuonAlignmentInputXML )
privatedelete
double MuonAlignmentInputXML::parseDouble ( const XMLCh *  str,
const char *  attribute 
) const
private

Definition at line 644 of file MuonAlignmentInputXML.cc.

References Exception, dedxEstimators_cff::exponent, mps_fire::i, reco::HaloData::minus, convertSQLitetoXML_cfg::output, funct::pow(), and fetchall_from_DQM_v2::release.

Referenced by do_moveglobal(), do_movelocal(), do_rotatebeamline(), do_rotateglobalaxis(), do_rotatelocal(), do_setape(), do_setposition(), and do_setsurveyerr().

644  {
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;
649 
650  unsigned int i = 0;
651 
652  bool minus = false;
653  if (cstr[i] == '-') {
654  minus = true;
655  i++;
656  }
657  else if (cstr[i] == '+') i++;
658 
659  double output = 0.;
660 
661  while (cstr[i] != '.' && cstr[i] != 'e' && cstr[i] != 'E' && i < len) {
662  if (cstr[i] < '0' || cstr[i] > '9') {
663  XMLString::release(&cstr);
664  throw cms::Exception("XMLException") << errmessage.str();
665  }
666 
667  output *= 10;
668  output += cstr[i] - '0';
669  i++;
670  }
671 
672  if (cstr[i] == '.') {
673  double place = 0.1;
674  i++;
675 
676  while (cstr[i] != 'e' && cstr[i] != 'E' && i < len) {
677  if (cstr[i] < '0' || cstr[i] > '9') {
678  XMLString::release(&cstr);
679  throw cms::Exception("XMLException") << errmessage.str();
680  }
681 
682  output += (cstr[i] - '0') * place;
683  place /= 10.;
684  i++;
685  }
686  }
687 
688  if (cstr[i] == 'e' || cstr[i] == 'E') {
689  i++;
690 
691  int exponent = 0;
692  bool expminus = false;
693  if (cstr[i] == '-') {
694  expminus = true;
695  i++;
696  }
697  else if (cstr[i] == '+') i++;
698 
699  while (i < len) {
700  if (cstr[i] < '0' || cstr[i] > '9') {
701  XMLString::release(&cstr);
702  throw cms::Exception("XMLException") << errmessage.str();
703  }
704 
705  exponent *= 10;
706  exponent += cstr[i] - '0';
707  i++;
708  }
709 
710  if (expminus) exponent *= -1;
711 
712  output *= pow(10., exponent);
713  }
714 
715  if (minus) output *= -1.;
716 
717  XMLString::release(&cstr);
718  return output;
719 }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void MuonAlignmentInputXML::recursiveGetId ( std::map< unsigned int, Alignable * > &  alignableNavigator,
const align::Alignables alignables 
) const
private

Definition at line 220 of file MuonAlignmentInputXML.cc.

References align::AlignableCSCChamber, align::AlignableCSCLayer, align::AlignableDet, align::AlignableDetUnit, align::AlignableDTChamber, align::AlignableDTLayer, and align::AlignableDTSuperLayer.

Referenced by newAlignableMuon().

220  {
221  for (align::Alignables::const_iterator ali = alignables.begin(); ali != alignables.end(); ++ali) {
222  if ((*ali)->alignableObjectId() == align::AlignableDetUnit || (*ali)->alignableObjectId() == align::AlignableDet ||
223  (*ali)->alignableObjectId() == align::AlignableDTChamber || (*ali)->alignableObjectId() == align::AlignableDTSuperLayer || (*ali)->alignableObjectId() == align::AlignableDTLayer ||
224  (*ali)->alignableObjectId() == align::AlignableCSCChamber || (*ali)->alignableObjectId() == align::AlignableCSCLayer) {
225  alignableNavigator[(*ali)->geomDetId().rawId()] = *ali;
226  }
227  recursiveGetId(alignableNavigator, (*ali)->components());
228  }
229 }
void recursiveGetId(std::map< unsigned int, Alignable * > &alignableNavigator, const align::Alignables &alignables) const
void MuonAlignmentInputXML::set_one_position ( Alignable ali,
const align::PositionType pos,
const align::RotationType rot 
) const
private

Definition at line 874 of file MuonAlignmentInputXML.cc.

References SurveyDet::errors(), Alignable::globalPosition(), Alignable::globalRotation(), Alignable::move(), TkRotation< T >::multiplyInverse(), align::rectify(), Alignable::rotateInGlobalFrame(), Alignable::setSurvey(), Alignable::surface(), and Alignable::survey().

Referenced by do_setposition().

874  {
875  const align::PositionType& oldpos = ali->globalPosition();
876  const align::RotationType& oldrot = ali->globalRotation();
877 
878  // shift needed to move from current to new position
879  align::GlobalVector posDiff = pos - oldpos;
880  align::RotationType rotDiff = oldrot.multiplyInverse(rot);
881  align::rectify(rotDiff); // correct for rounding errors
882  ali->move(posDiff);
883  ali->rotateInGlobalFrame(rotDiff);
884 
885 // // check for consistency
886 // const align::PositionType& newpos = ali->globalPosition();
887 // const align::RotationType& newrot = ali->globalRotation();
888 // align::GlobalVector posDiff2 = pos - newpos;
889 // align::RotationType rotDiff2 = newrot.multiplyInverse(rot);
890 // align::rectify(rotDiff2); // correct for rounding errors
891 
892 // if (fabs(posDiff2.x()) > 1e-6 || fabs(posDiff2.y()) > 1e-6 || fabs(posDiff2.z()) > 1e-6) {
893 // std::cout << "zeropos " << posDiff2 << std::endl;
894 // }
895 // if (fabs(rotDiff2.xx() - 1.) > 1e-4 ||
896 // fabs(rotDiff2.yy() - 1.) > 1e-4 ||
897 // fabs(rotDiff2.zz() - 1.) > 1e-4 ||
898 // fabs(rotDiff2.xy()) > 1e-8 ||
899 // fabs(rotDiff2.xz()) > 1e-8 ||
900 // fabs(rotDiff2.yz()) > 1e-8) {
901 // std::cout << "zerorot " << rotDiff2 << std::endl;
902 // }
903 
904  align::ErrorMatrix matrix6x6 = ROOT::Math::SMatrixIdentity();
905  matrix6x6 *= 1000.; // initial assumption: infinitely weak constraint
906 
907  const SurveyDet *survey = ali->survey();
908  if (survey != nullptr) {
909  matrix6x6 = survey->errors(); // save the constraint information
910  }
911  ali->setSurvey(new SurveyDet(ali->surface(), matrix6x6));
912 }
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:225
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:141
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
const align::ErrorMatrix & errors() const
Definition: SurveyDet.h:73
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
Definition: Utilities.cc:198
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:343
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:138
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const

Member Data Documentation

std::string MuonAlignmentInputXML::m_fileName
private

Definition at line 73 of file MuonAlignmentInputXML.h.

Referenced by newAlignableMuon().

XMLCh* MuonAlignmentInputXML::str_aa
private
XMLCh* MuonAlignmentInputXML::str_ab
private
XMLCh* MuonAlignmentInputXML::str_ac
private
XMLCh* MuonAlignmentInputXML::str_alpha
private
XMLCh* MuonAlignmentInputXML::str_angle
private
XMLCh* MuonAlignmentInputXML::str_axisx
private
XMLCh* MuonAlignmentInputXML::str_axisy
private
XMLCh* MuonAlignmentInputXML::str_axisz
private
XMLCh* MuonAlignmentInputXML::str_bb
private
XMLCh* MuonAlignmentInputXML::str_bc
private
XMLCh* MuonAlignmentInputXML::str_beta
private
XMLCh* MuonAlignmentInputXML::str_cc
private
XMLCh* MuonAlignmentInputXML::str_chamber
private
XMLCh* MuonAlignmentInputXML::str_collection
private
XMLCh* MuonAlignmentInputXML::str_container
private
XMLCh* MuonAlignmentInputXML::str_CSCChamber
private

Definition at line 87 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_CSCEndcap
private

Definition at line 84 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_CSCLayer
private

Definition at line 88 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_CSCRing
private

Definition at line 86 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_CSCStation
private

Definition at line 85 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_DTBarrel
private

Definition at line 78 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_DTChamber
private

Definition at line 81 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_DTLayer
private

Definition at line 83 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_DTStation
private

Definition at line 80 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_DTSuperLayer
private

Definition at line 82 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_DTWheel
private

Definition at line 79 of file MuonAlignmentInputXML.h.

Referenced by getNode(), MuonAlignmentInputXML(), and ~MuonAlignmentInputXML().

XMLCh* MuonAlignmentInputXML::str_endcap
private
XMLCh* MuonAlignmentInputXML::str_gamma
private
XMLCh* MuonAlignmentInputXML::str_ideal
private
XMLCh* MuonAlignmentInputXML::str_layer
private
XMLCh* MuonAlignmentInputXML::str_moveglobal
private
XMLCh* MuonAlignmentInputXML::str_movelocal
private
XMLCh* MuonAlignmentInputXML::str_name
private
XMLCh* MuonAlignmentInputXML::str_none
private
XMLCh* MuonAlignmentInputXML::str_operation
private
XMLCh* MuonAlignmentInputXML::str_phi
private
XMLCh* MuonAlignmentInputXML::str_phix
private
XMLCh* MuonAlignmentInputXML::str_phiy
private
XMLCh* MuonAlignmentInputXML::str_phiz
private
XMLCh* MuonAlignmentInputXML::str_rawId
private
XMLCh* MuonAlignmentInputXML::str_relativeto
private
XMLCh* MuonAlignmentInputXML::str_ring
private
XMLCh* MuonAlignmentInputXML::str_rotatebeamline
private
XMLCh* MuonAlignmentInputXML::str_rotateglobalaxis
private
XMLCh* MuonAlignmentInputXML::str_rotatelocal
private
XMLCh* MuonAlignmentInputXML::str_rphi
private
XMLCh* MuonAlignmentInputXML::str_sector
private
XMLCh* MuonAlignmentInputXML::str_setape
private
XMLCh* MuonAlignmentInputXML::str_setposition
private
XMLCh* MuonAlignmentInputXML::str_setsurveyerr
private
XMLCh* MuonAlignmentInputXML::str_station
private
XMLCh* MuonAlignmentInputXML::str_superlayer
private
XMLCh* MuonAlignmentInputXML::str_wheel
private
XMLCh* MuonAlignmentInputXML::str_x
private
XMLCh* MuonAlignmentInputXML::str_xa
private
XMLCh* MuonAlignmentInputXML::str_xb
private
XMLCh* MuonAlignmentInputXML::str_xc
private
XMLCh* MuonAlignmentInputXML::str_xx
private
XMLCh* MuonAlignmentInputXML::str_xy
private
XMLCh* MuonAlignmentInputXML::str_xz
private
XMLCh* MuonAlignmentInputXML::str_y
private
XMLCh* MuonAlignmentInputXML::str_ya
private
XMLCh* MuonAlignmentInputXML::str_yb
private
XMLCh* MuonAlignmentInputXML::str_yc
private
XMLCh* MuonAlignmentInputXML::str_yy
private
XMLCh* MuonAlignmentInputXML::str_yz
private
XMLCh* MuonAlignmentInputXML::str_z
private
XMLCh* MuonAlignmentInputXML::str_za
private
XMLCh* MuonAlignmentInputXML::str_zb
private
XMLCh* MuonAlignmentInputXML::str_zc
private
XMLCh* MuonAlignmentInputXML::str_zz
private