CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
DDLRotationAndReflection Class Referencefinal

DDLRotationAndReflection handles RotationCMSIM and ReflectionRotation elements. More...

#include <DDLRotationAndReflection.h>

Inheritance diagram for DDLRotationAndReflection:
DDXMLElement

Public Member Functions

 DDLRotationAndReflection (DDLElementRegistry *myreg)
 
int isLeftHanded (const DD3Vector &x, const DD3Vector &y, const DD3Vector &z, const std::string &nmspace)
 returns 1 = left handed rotation matrix, 0 = right-handed, -1 = not orthonormal. More...
 
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv) override
 Processing the element. More...
 
- Public Member Functions inherited from DDXMLElement
void appendText (const std::string &inText)
 append to the current (i.e. most recently added) More...
 
virtual std::vector< DDXMLAttribute >::const_iterator begin (void)
 
virtual void clear (void)
 clear this element's contents. More...
 
 DDXMLElement (DDLElementRegistry *myreg)
 Constructor. More...
 
 DDXMLElement (DDLElementRegistry *myreg, const bool &clearme)
 Constructor for autoClear element. More...
 
virtual std::vector< DDXMLAttribute >::const_iterator end (void)
 
virtual const std::string & get (const std::string &name, size_t aIndex=0) const
 Returns a specific value from the aIndex set of attributes. More...
 
virtual const std::string & getAttribute (const std::string &name) const
 Access to attributes by name. More...
 
virtual const DDXMLAttributegetAttributeSet (size_t aIndex=0) const
 Get a "row" of attributes, i.e. one attribute set. More...
 
virtual const DDName getDDName (const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
 
const std::string getText (size_t tindex=0) const
 retrieve the text blob. More...
 
virtual std::vector< std::string > getVectorAttribute (const std::string &name)
 Returns a set of values as a std::vector of strings, given the attribute name. More...
 
virtual bool gotText (void) const
 gotText()? kind of like gotMilk? Yes = text has already been encountered. More...
 
virtual bool isEmpty (void) const
 Have any elements of this type been encountered but not processed? More...
 
void loadAttributes (const std::string &elemName, const std::vector< std::string > &names, const std::vector< std::string > &values, const std::string &nmspace, DDCompactView &cpv)
 Load the element attributes. More...
 
void loadText (const std::string &inText)
 Used to load both text and XML comments into this object. More...
 
std::vector< DDXMLAttribute >::const_iterator & operator++ (int inc)
 Allow the elements of this type to be iterated over using ++ operator. More...
 
const std::string & parent (void) const
 access to parent element name More...
 
virtual void preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Called by loadAttributes AFTER attributes are loaded. More...
 
void setParent (const std::string &pename)
 Set parent element name to central list of names. More...
 
void setSelf (const std::string &sename)
 Set self element name to central list of names. More...
 
virtual size_t size (void) const
 Number of elements accumulated. More...
 
virtual void stream (std::ostream &os) const
 Allow for the elements to have their own streaming method, but also provide a default. More...
 
void throwError (const std::string &keyMessage) const
 format std::string for throw an error. More...
 
virtual ~DDXMLElement (void)=default
 Destructor. More...
 

Private Member Functions

DD3Vector makeX (const std::string &nmspace)
 
DD3Vector makeY (const std::string &nmspace)
 
DD3Vector makeZ (const std::string &nmspace)
 

Additional Inherited Members

- Protected Attributes inherited from DDXMLElement
DDLElementRegistrymyRegistry_
 

Detailed Description

DDLRotationAndReflection handles RotationCMSIM and ReflectionRotation elements.

Author
Michael Case

DDLRotationAndReflection.h - description

begin: Tue Oct 30 2001 email: case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

This is the Rotation and Reflection element processor.

Definition at line 25 of file DDLRotationAndReflection.h.

Constructor & Destructor Documentation

◆ DDLRotationAndReflection()

DDLRotationAndReflection::DDLRotationAndReflection ( DDLElementRegistry myreg)

Definition at line 22 of file DDLRotationAndReflection.cc.

22 : DDXMLElement(myreg) {}
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
Definition: DDXMLElement.cc:14

Member Function Documentation

◆ isLeftHanded()

int DDLRotationAndReflection::isLeftHanded ( const DD3Vector x,
const DD3Vector y,
const DD3Vector z,
const std::string &  nmspace 
)

returns 1 = left handed rotation matrix, 0 = right-handed, -1 = not orthonormal.

Definition at line 79 of file DDLRotationAndReflection.cc.

References funct::abs(), RPCNoise_example::check, angle_units::operators::convertRadToDeg(), gather_cfg::cout, makeMEIFBenchmarkPlots::ev, DDLElementRegistry::evaluator(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDXMLElement::myRegistry_, runTheMatrix::ret, x, y, and z.

Referenced by processElement().

82  {
83  int ret = 0;
84 
85  // check for orthonormality and left-handedness
86 
87  double check = (x.Cross(y)).Dot(z);
88  double tol = 1.0e-3;
91 
92  if (1.0 - std::abs(check) > tol) {
93  std::cout << "DDLRotationAndReflection Coordinate axes forming rotation matrix " << getDDName(nmspace)
94  << " are not orthonormal.(tolerance=" << tol << " check=" << std::abs(check) << ")" << std::endl
95  << " thetaX=" << (atts.find("thetaX")->second) << ' '
96  << convertRadToDeg(ev.eval(nmspace, atts.find("thetaX")->second)) << std::endl
97  << " phiX=" << (atts.find("phiX")->second) << ' '
98  << convertRadToDeg(ev.eval(nmspace, atts.find("phiX")->second)) << std::endl
99  << " thetaY=" << (atts.find("thetaY")->second) << ' '
100  << convertRadToDeg(ev.eval(nmspace, atts.find("thetaY")->second)) << std::endl
101  << " phiY=" << (atts.find("phiY")->second) << ' '
102  << convertRadToDeg(ev.eval(nmspace, atts.find("phiY")->second)) << std::endl
103  << " thetaZ=" << (atts.find("thetaZ")->second) << ' '
104  << convertRadToDeg(ev.eval(nmspace, atts.find("thetaZ")->second)) << std::endl
105  << " phiZ=" << (atts.find("phiZ")->second) << ' '
106  << convertRadToDeg(ev.eval(nmspace, atts.find("phiZ")->second)) << std::endl
107  << " WAS NOT CREATED!" << std::endl;
108  ret = -1;
109  } else if (1.0 + check <= tol) {
110  ret = 1;
111  }
112  return ret;
113 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
ret
prodAgent to be discontinued
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
ClhepEvaluator & evaluator()
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:56

◆ makeX()

DD3Vector DDLRotationAndReflection::makeX ( const std::string &  nmspace)
private

Definition at line 115 of file DDLRotationAndReflection.cc.

References funct::cos(), makeMEIFBenchmarkPlots::ev, DDLElementRegistry::evaluator(), DDXMLElement::getAttributeSet(), DDXMLElement::myRegistry_, funct::sin(), DOFs::thetaX, and x.

Referenced by processElement().

115  {
116  DD3Vector x;
118  if (atts.find("thetaX") != atts.end()) {
120  double thetaX = ev.eval(nmspace, atts.find("thetaX")->second);
121  double phiX = ev.eval(nmspace, atts.find("phiX")->second);
122  // colx
123  x.SetX(sin(thetaX) * cos(phiX));
124  x.SetY(sin(thetaX) * sin(phiX));
125  x.SetZ(cos(thetaX));
126  }
127  return x;
128 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
ClhepEvaluator & evaluator()
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

◆ makeY()

DD3Vector DDLRotationAndReflection::makeY ( const std::string &  nmspace)
private

Definition at line 130 of file DDLRotationAndReflection.cc.

References funct::cos(), makeMEIFBenchmarkPlots::ev, DDLElementRegistry::evaluator(), DDXMLElement::getAttributeSet(), DDXMLElement::myRegistry_, funct::sin(), DOFs::thetaY, and y.

Referenced by processElement().

130  {
131  DD3Vector y;
133  if (atts.find("thetaY") != atts.end()) {
135  double thetaY = ev.eval(nmspace, atts.find("thetaY")->second);
136  double phiY = ev.eval(nmspace, atts.find("phiY")->second);
137 
138  // coly
139  y.SetX(sin(thetaY) * cos(phiY));
140  y.SetY(sin(thetaY) * sin(phiY));
141  y.SetZ(cos(thetaY));
142  }
143  return y;
144 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
ClhepEvaluator & evaluator()
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

◆ makeZ()

DD3Vector DDLRotationAndReflection::makeZ ( const std::string &  nmspace)
private

Definition at line 146 of file DDLRotationAndReflection.cc.

References funct::cos(), makeMEIFBenchmarkPlots::ev, DDLElementRegistry::evaluator(), DDXMLElement::getAttributeSet(), DDXMLElement::myRegistry_, funct::sin(), DOFs::thetaZ, and z.

Referenced by processElement().

146  {
147  DD3Vector z;
149  if (atts.find("thetaZ") != atts.end()) {
151  double thetaZ = ev.eval(nmspace, atts.find("thetaZ")->second);
152  double phiZ = ev.eval(nmspace, atts.find("phiZ")->second);
153 
154  // colz
155  z.SetX(sin(thetaZ) * cos(phiZ));
156  z.SetY(sin(thetaZ) * sin(phiZ));
157  z.SetZ(cos(thetaZ));
158  }
159  return z;
160 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
ClhepEvaluator & evaluator()
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

◆ processElement()

void DDLRotationAndReflection::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
)
overridevirtual

Processing the element.

The processElement method completes any necessary work to process the XML element.

For example, this can be used to call the DDCore to make the geometry in memory. There is a default for this so that if not declared in the inheriting class, no processing is done.

Reimplemented from DDXMLElement.

Definition at line 24 of file DDLRotationAndReflection.cc.

References DDXMLElement::clear(), DDrot(), DDrotReflect(), makeMEIFBenchmarkPlots::ev, DDLElementRegistry::evaluator(), DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), isLeftHanded(), makeX(), makeY(), makeZ(), mps_check::msg, DDXMLElement::myRegistry_, mergeVDriftHistosByStation::name, AlCaHLTBitMon_QueryRunRegistry::string, DDXMLElement::throwError(), x, y, and z.

24  {
25  DD3Vector x = makeX(nmspace);
26  DD3Vector y = makeY(nmspace);
27  DD3Vector z = makeZ(nmspace);
28 
30 
31  if ((name == "Rotation") && isLeftHanded(x, y, z, nmspace) == 0) {
32  DDRotation ddrot = DDrot(getDDName(nmspace), std::make_unique<DDRotationMatrix>(x, y, z));
33  } else if ((name == "Rotation") && isLeftHanded(x, y, z, nmspace) == 1) {
34  std::string msg("\nDDLRotationAndReflection attempted to make a");
35  msg += " left-handed rotation with a Rotation element. If";
36  msg += " you meant to make a reflection, use ReflectionRotation";
37  msg += " elements, otherwise, please check your matrix. Other";
38  msg += " errors may follow. Rotation matrix not created.";
39  edm::LogError("DetectorDescription_Parser_Rotation_and_Reflection")
40  << msg << std::endl; // this could become a throwWarning or something.
41  } else if (name == "ReflectionRotation" && isLeftHanded(x, y, z, nmspace) == 1) {
43  DDRotation ddrot = DDrotReflect(getDDName(nmspace),
44  ev.eval(nmspace, atts.find("thetaX")->second),
45  ev.eval(nmspace, atts.find("phiX")->second),
46  ev.eval(nmspace, atts.find("thetaY")->second),
47  ev.eval(nmspace, atts.find("phiY")->second),
48  ev.eval(nmspace, atts.find("thetaZ")->second),
49  ev.eval(nmspace, atts.find("phiZ")->second));
50  } else if (name == "ReflectionRotation" && isLeftHanded(x, y, z, nmspace) == 0) {
51  std::string msg("WARNING: Attempted to make a right-handed");
52  msg += " rotation using a ReflectionRotation element. ";
53  msg += " If you meant to make a Rotation, use Rotation";
54  msg += " elements, otherwise, please check your matrix.";
55  msg += " Other errors may follow. ReflectionRotation";
56  msg += " matrix not created.";
57  edm::LogError("DetectorDescription_Parser_Rotation_and_Reflection")
58  << msg << std::endl; // this could be a throwWarning or something.
59  } else {
60  std::string msg = "\nDDLRotationAndReflection::processElement tried to process wrong element.";
61  throwError(msg);
62  }
63  // after a rotation or reflection rotation has been processed, clear it
64  clear();
65 }
DDLElementRegistry * myRegistry_
Definition: DDXMLElement.h:173
Log< level::Error, false > LogError
DD3Vector makeZ(const std::string &nmspace)
std::map< std::string, std::string > DDXMLAttribute
Definition: DDXMLElement.h:45
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
DD3Vector makeX(const std::string &nmspace)
ClhepEvaluator & evaluator()
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
Definition: DDXMLElement.cc:54
DDRotation DDrotReflect(const DDName &name, double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Defines a rotation-reflection in the Geant3 way.
Definition: DDRotation.cc:101
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
int isLeftHanded(const DD3Vector &x, const DD3Vector &y, const DD3Vector &z, const std::string &nmspace)
returns 1 = left handed rotation matrix, 0 = right-handed, -1 = not orthonormal.
tuple msg
Definition: mps_check.py:286
virtual void clear(void)
clear this element&#39;s contents.
Definition: DDXMLElement.cc:40
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
Definition: DDXMLElement.cc:56
DD3Vector makeY(const std::string &nmspace)