CMS 3D CMS Logo

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

◆ output()

void output ( string  filename)

load the new cpv

Definition at line 169 of file build.cc.

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 }

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().

◆ printRot()

void printRot ( const DDRotationMatrix rot)

Definition at line 235 of file build.cc.

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 }

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

Referenced by testrot().

◆ regressionTest_first()

void regressionTest_first ( ClhepEvaluator eval)

load the new cpv

Definition at line 111 of file build.cc.

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"));
143  eval.eval(ns, "[setup:corner]/8."), eval.eval(ns, "[setup:corner]/16."), eval.eval(ns, "[setup:corner]/8."));
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 }

References DDSolidFactory::box(), gather_cfg::cout, DDrot(), ClhepEvaluator::eval(), eostools::move(), DDCompactView::position(), submit::rm, AlCaHLTBitMon_QueryRunRegistry::string, FrontierCondition_GT_autoExpress_cfi::t0, RandomServiceHelper::t1, RandomServiceHelper::t2, RandomServiceHelper::t3, and unit().

◆ regressionTest_setup()

void regressionTest_setup ( ClhepEvaluator eval)

Definition at line 40 of file build.cc.

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 }

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

◆ testParser()

void testParser ( )

Definition at line 210 of file build.cc.

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 }

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

◆ testrot()

void testrot ( )

Definition at line 251 of file build.cc.

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 }

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

RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
DDrot
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
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DDRotationMatrix
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
Definition: DDRotationMatrix.h:8
DD3Vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
part
part
Definition: HCALResponse.h:20
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:148
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
vertices_cff.x
x
Definition: vertices_cff.py:29
submit.rm
rm
Definition: submit.py:77
DDExpandedView
Provides an exploded view of the detector (tree-view)
Definition: DDExpandedView.h:41
RandomServiceHelper.t3
t3
Definition: RandomServiceHelper.py:258
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDI::Singleton::instance
static value_type & instance()
heppy_loop.loop
loop
Definition: heppy_loop.py:28
DDLParser
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
printRot
void printRot(const DDRotationMatrix &rot)
Definition: build.cc:235
DDSolidFactory::shapeless
static DDSolid shapeless(const DDName &name)
Definition: DDSolid.cc:688
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
eostools.move
def move(src, dest)
Definition: eostools.py:511
ClhepEvaluator::set
void set(const std::string &ns, const std::string &name, const std::string &exprValue)
Definition: ClhepEvaluator.cc:42
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
cms::Exception
Definition: Exception.h:70
FIPConfiguration
FIPConfiguration reads in the configuration file for the DDParser.
Definition: FIPConfiguration.h:27
ClhepEvaluator::eval
double eval(const std::string &ns, const std::string &expr)
Definition: ClhepEvaluator.cc:85
DDSolidFactory::box
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:533
DDMaterial::addMaterial
int addMaterial(const DDMaterial &m, double fm)
adds a material to the mixture proportional to its fraction-mass fm.
Definition: DDMaterial.cc:63
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:66
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37