CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
build.cc File Reference
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include "DetectorDescription/Core/interface/DDRotationMatrix.h"
#include "DetectorDescription/Core/interface/DDTranslation.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDExpandedView.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"
#include "DetectorDescription/Core/interface/DDMaterial.h"
#include "DetectorDescription/Core/interface/DDName.h"
#include "DetectorDescription/Core/interface/DDRoot.h"
#include "DetectorDescription/Core/interface/DDSolid.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DataFormats/Math/interface/GeantUnits.h"
#include "DetectorDescription/Parser/interface/DDLParser.h"
#include "DetectorDescription/Parser/interface/FIPConfiguration.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "Math/GenVector/AxisAngle.h"
#include "Math/GenVector/Cartesian3D.h"
#include "Math/GenVector/DisplacementVector3D.h"
#include "Math/GenVector/Rotation3D.h"
#include "Math/GenVector/RotationZ.h"

Go to the source code of this file.

Functions

void output (string filename)
 
void printRot (const DDRotationMatrix &rot)
 
void regressionTest_first (ClhepEvaluator &eval)
 
void regressionTest_setup (ClhepEvaluator &eval)
 
void testParser ()
 
void testrot ()
 

Function Documentation

void output ( string  filename)

load the new cpv

Definition at line 169 of file build.cc.

References angle_units::operators::convertRadToDeg(), gather_cfg::cout, DDExpandedView::logicalPart(), heppy_loop::loop, DDLogicalPart::material(), DDExpandedView::next(), DDLParser::parse(), FIPConfiguration::readConfig(), DDExpandedView::rotation(), DDLogicalPart::solid(), and DDExpandedView::translation().

169  {
170  ostream& os(cout);
171 
172  os << "Starting Regressiontest Output" << endl;
174  DDCompactView cpv;
175  cout << "main::initialize DDL parser" << endl;
176  DDLParser myP(cpv);
177 
178  cout << "main::about to set configuration" << endl;
179  FIPConfiguration cf(cpv);
180  cf.readConfig("DetectorDescription/RegressionTest/test/configuration.xml");
181 
182  cout << "main::about to start parsing" << endl;
183 
184  myP.parse(cf);
185 
186  cout << "main::completed Parser" << endl;
187 
188  DDExpandedView exv(cpv);
189  vector<DDTranslation> tvec;
190  bool loop = true;
191  std::cout << "Before the loop..." << std::endl;
192  while (loop) {
193  ROOT::Math::AxisAngle ra(exv.rotation());
194  os << exv.logicalPart() << endl
195  << " " << exv.logicalPart().material() << endl
196  << " " << exv.logicalPart().solid() << endl
197  << " " << exv.translation() << endl;
198  os << " " << ra.Axis() << convertRadToDeg(ra.Angle()) << endl;
199  tvec.emplace_back(exv.translation());
200  loop = exv.next();
201  }
202 
203  vector<DDTranslation>::iterator it = tvec.begin();
204  os << endl << "center points of all solids" << endl;
205  for (; it != tvec.end(); ++it) {
206  os << (*it).x() << " " << (*it).y() << " " << (*it).z() << endl;
207  }
208 }
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
FIPConfiguration reads in the configuration file for the DDParser.
tuple cout
Definition: gather_cfg.py:144
Provides an exploded view of the detector (tree-view)
void printRot ( const DDRotationMatrix rot)

Definition at line 235 of file build.cc.

References angle_units::operators::convertRadToDeg(), funct::cos(), gather_cfg::cout, and funct::sin().

Referenced by testrot().

235  {
236  std::cout << "rot asis\n" << rot << std::endl;
237  DD3Vector x, y, z;
238  rot.GetComponents(x, y, z);
239  std::cout << "components\n" << x << "\n" << y << "\n" << z << std::endl;
240  cout << "phiX=" << x.phi() << " or in degrees = " << convertRadToDeg(x.phi()) << endl;
241  cout << "thetaX=" << x.theta() << " or in degrees = " << convertRadToDeg(x.theta()) << endl;
242  cout << "phiY=" << y.phi() << " or in degrees = " << convertRadToDeg(y.phi()) << endl;
243  cout << "thetaY=" << y.theta() << " or in degrees = " << convertRadToDeg(y.theta()) << endl;
244  cout << "phiZ=" << z.phi() << " or in degrees = " << convertRadToDeg(z.phi()) << endl;
245  cout << "thetaZ=" << z.theta() << " or in degrees = " << convertRadToDeg(z.theta()) << endl;
246 
247  cout << "some factor/equations..." << endl;
248  cout << " sin(thetaX()) * cos(phiX()) = " << sin(x.theta()) * cos(x.phi()) << endl;
249 }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >> DD3Vector
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float float float z
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
uint16_t const *__restrict__ x
Definition: gpuClustering.h:39
tuple cout
Definition: gather_cfg.py:144
void regressionTest_first ( ClhepEvaluator eval)

load the new cpv

Definition at line 111 of file build.cc.

References DDSolidFactory::box(), gather_cfg::cout, DDrot(), ClhepEvaluator::eval(), eostools::move(), DDCompactView::position(), eostools::rm(), AlCaHLTBitMon_QueryRunRegistry::string, FrontierCondition_GT_autoExpress_cfi::t0, unit(), and gpuVertexFinder::ws.

111  {
113  DDCompactView cpv;
114  cout << "main::initialize DDL parser" << endl;
115  DDLParser myP(cpv);
116 
117  cout << "main::about to set configuration" << endl;
118 
119  string ns("first");
120  DDSolid support = DDSolidFactory::box(DDName("support", ns),
121  eval.eval(ns, "[setup:corner]/4."),
122  eval.eval(ns, "[setup:corner]/8."),
123  eval.eval(ns, "[setup:corner]/4."));
124  DDSolid sensor = DDSolidFactory::box(DDName("sensor", ns),
125  eval.eval(ns, "[setup:corner]/16."),
126  eval.eval(ns, "[setup:corner]/16."),
127  eval.eval(ns, "[setup:corner]/16."));
128 
129  DDLogicalPart supportLP(DDName("support", ns), // name
130  DDName("Oxygen", "elements"), // material
131  DDName("support", ns)); // solid
132 
133  DDLogicalPart sensorLP(DDName("sensor", ns), DDName("Nitrogen", "elements"), DDName("sensor", ns));
134 
135  DDLogicalPart part(DDName("group", ns), DDName("Air", "setup"), DDName("group", "setup"));
136 
137  DDRotation r30(DDName("R30", "setup"));
138  DDRotation r60(DDName("R60", "setup"));
139  DDRotation r90(DDName("R90", "setup"));
140  DDRotation unit(DDName("Unit", "setup"));
142  DDTranslation t1(
143  eval.eval(ns, "[setup:corner]/8."), eval.eval(ns, "[setup:corner]/16."), eval.eval(ns, "[setup:corner]/8."));
144  DDTranslation t2(
145  eval.eval(ns, "[setup:corner]*1.25*cos(0.)"), eval.eval(ns, "[setup:corner]*1.25*sin(0.)"), eval.eval(ns, "0."));
146  DDTranslation t3(eval.eval(ns, "[setup:corner]*1.25*cos(30.*deg)"),
147  eval.eval(ns, "[setup:corner]*1.25*sin(30.*deg)"),
148  eval.eval(ns, "0."));
149  DDTranslation t4(eval.eval(ns, "[setup:corner]*1.25*cos(60.*deg)"),
150  eval.eval(ns, "[setup:corner]*1.25*sin(60.*deg)"),
151  eval.eval(ns, "0."));
152  DDTranslation t5(eval.eval(ns, "[setup:corner]*1.25*cos(90.*deg)"),
153  eval.eval(ns, "[setup:corner]*1.25*sin(90.*deg)"),
154  eval.eval(ns, "0."));
155 
156  cpv.position(sensorLP, supportLP, std::string("1"), t1, unit);
157  cpv.position(supportLP, part, std::string("1"), t2, unit);
158  cpv.position(supportLP, part, std::string("2"), t3, r30);
159  cpv.position(supportLP, part, std::string("3"), t4, r60);
160  cpv.position(supportLP, part, std::string("4"), t5, r90);
161 
162  std::unique_ptr<DDRotationMatrix> rm =
163  std::make_unique<DDRotationMatrix>(ROOT::Math::AxisAngle(DD3Vector(1., 1., 1.), 20._deg));
164  DDRotation rw = DDrot(DDName("group", ns), std::move(rm));
165  DDLogicalPart ws(DDName("world", "setup"));
166  cpv.position(part, ws, std::string("1"), t0, rw);
167 }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >> DD3Vector
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
auto &__restrict__ ws
def move
Definition: eostools.py:511
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
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
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
Definition: DDSolid.cc:547
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
part
Definition: HCALResponse.h:20
double eval(const std::string &ns, const std::string &expr)
tuple cout
Definition: gather_cfg.py:144
def rm
Definition: eostools.py:363
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Basic3DVector unit() const
void regressionTest_setup ( ClhepEvaluator eval)

Definition at line 40 of file build.cc.

References DDMaterial::addMaterial(), DDSolidFactory::box(), gather_cfg::cout, DDrot(), ClhepEvaluator::eval(), DDI::Singleton< I >::instance(), eostools::move(), ClhepEvaluator::set(), and DDSolidFactory::shapeless().

40  {
41  string ns = "setup"; // current namespace faking the filename 'setup.xml'
42 
43  // length of a side of world cube
44  eval.set(ns, "length", "20.*m");
45 
46  // center of a corner in the cube
47  eval.set(ns, "corner", "[length]/4.");
48 
49  // world-solid
50  DDName worldName("world", ns);
51  DDName airName("Air", ns);
52  DDName nitrogenName("Nitrogen", "elements");
53  DDName oxygenName("Oxygen", "elements");
54 
56  worldName, eval.eval(ns, "[length]/2."), eval.eval(ns, "[length]/2."), eval.eval(ns, "[length]/2."));
57 
58  DDLogicalPart(worldName, // name
59  airName, // material
60  worldName // solid
61  );
62 
63  DDMaterial air(airName, eval.eval(ns, "1.214*mg/cm3")); // mixture for Air
64  air.addMaterial(DDMaterial(nitrogenName), eval.eval(ns, "0.75"));
65  air.addMaterial(DDMaterial(oxygenName), eval.eval(ns, "0.25"));
66 
67  cout << air << endl;
68 
69  DDMaterial(nitrogenName, // name
70  eval.eval(ns, "7"), // Z
71  eval.eval(ns, "14.007*g/mole"), // A
72  eval.eval(ns, "0.808*g/cm3")); // density
73 
74  DDMaterial(oxygenName, // name
75  eval.eval(ns, "8"), // Z
76  eval.eval(ns, "15.999*g/mole"), // A
77  eval.eval(ns, "1.43*g/cm3")); // density
78 
79  cout << air << endl;
80 
81  // Some rotations in the x-y plane (Unit, 30,60,90 degs)
82  std::unique_ptr<DDRotationMatrix> r0 = std::make_unique<DDRotationMatrix>();
83  std::unique_ptr<DDRotationMatrix> r30 = std::make_unique<DDRotationMatrix>(ROOT::Math::RotationZ(30._deg));
84  std::unique_ptr<DDRotationMatrix> r60 = std::make_unique<DDRotationMatrix>(ROOT::Math::RotationZ(60._deg));
85  std::unique_ptr<DDRotationMatrix> r90 = std::make_unique<DDRotationMatrix>(ROOT::Math::RotationZ(90._deg));
86 
87  DDrot(DDName("Unit", ns), std::move(r0));
88  DDrot(DDName("R30", ns), std::move(r30));
89  DDrot(DDName("R60", ns), std::move(r60));
90  DDrot(DDName("R90", ns), std::move(r90));
91 
92  DDSolid collectorSolid = DDSolidFactory::shapeless(DDName("group", ns));
93 
94  DDRootDef::instance().set(worldName);
95 }
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
int addMaterial(const DDMaterial &m, double fm)
adds a material to the mixture proportional to its fraction-mass fm.
Definition: DDMaterial.cc:63
static value_type & instance()
def move
Definition: eostools.py:511
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
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
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
Definition: DDSolid.cc:547
static DDSolid shapeless(const DDName &name)
Definition: DDSolid.cc:702
void set(const std::string &ns, const std::string &name, const std::string &exprValue)
double eval(const std::string &ns, const std::string &expr)
tuple cout
Definition: gather_cfg.py:144
void testParser ( )

Definition at line 210 of file build.cc.

References gather_cfg::cout, alignCSCRings::e, DDLParser::parse(), and FIPConfiguration::readConfig().

210  {
211  try {
212  cout << "main:: initialize" << endl;
213  DDCompactView cpv;
214  cout << "main::initialize DDL parser" << endl;
215  DDLParser myP(cpv);
216 
217  cout << "main::about to set configuration" << endl;
218 
219  FIPConfiguration cf(cpv);
220  cf.readConfig("DetectorDescription/RegressionTest/test/configuration.xml");
221 
222  cout << "main::about to start parsing" << endl;
223 
224  myP.parse(cf);
225 
226  cout << "main::completed Parser" << endl;
227 
228  cout << endl << endl << "main::Start checking!" << endl << endl;
229 
230  } catch (cms::Exception& e) {
231  cout << "main::PROBLEM:" << endl << " " << e << endl;
232  }
233 }
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
FIPConfiguration reads in the configuration file for the DDParser.
tuple cout
Definition: gather_cfg.py:144
void testrot ( )

Definition at line 251 of file build.cc.

References gather_cfg::cout, printRot(), and eostools::rm().

251  {
252  {
253  ROOT::Math::AxisAngle aa(DD3Vector(1., 1., 1.), 20._deg);
254  DDRotationMatrix rm(aa);
255  cout << "DD3Vector was " << DD3Vector(1., 1., 1.) << " and the rotation was 20*deg around that axis." << endl;
256  printRot(rm);
257  }
258  {
259  DDRotationMatrix rm(1, 0, 0, 0, -1, 0, 0, 0, 1);
260  cout << "(1,0,0, 0,-1,0, 0,0,1)" << endl;
261  printRot(rm);
262  }
263 }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >> DD3Vector
void printRot(const DDRotationMatrix &rot)
Definition: build.cc:235
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
tuple cout
Definition: gather_cfg.py:144
def rm
Definition: eostools.py:363