test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
build.cc File Reference
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include "DetectorDescription/Parser/interface/DDLParser.h"
#include "DetectorDescription/Parser/interface/FIPConfiguration.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDExpandedView.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include "DetectorDescription/Core/interface/DDRoot.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"
#include "DetectorDescription/Core/interface/DDMaterial.h"
#include "DetectorDescription/Core/interface/DDSolid.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
#include <Math/RotationZ.h>
#include <Math/AxisAngle.h>

Go to the source code of this file.

Functions

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

Function Documentation

void output ( string  filename)

load the new cpv

Definition at line 180 of file build.cc.

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

181 {
182  ostream & os(cout);
183 
184  os << "Starting Regressiontest Output" << endl;
186  DDCompactView cpv;
187  cout << "main::initialize DDL parser" << endl;
188  DDLParser myP(cpv);
189 
190  cout << "main::about to set configuration" << endl;
191  FIPConfiguration cf(cpv);
192  cf.readConfig("DetectorDescription/RegressionTest/test/configuration.xml");
193 
194  cout << "main::about to start parsing" << endl;
195 
196  myP.parse(cf);
197 
198  cout << "main::completed Parser" << endl;
199 
200  DDExpandedView exv(cpv);
201  vector<DDTranslation> tvec;
202  bool loop=true;
203  std::cout << "Before the loop..." << std::endl;
204  while(loop) {
205  ROOT::Math::AxisAngle ra(exv.rotation());
206  os << exv.logicalPart() << endl
207  << " " << exv.logicalPart().material() << endl
208  << " " << exv.logicalPart().solid() << endl
209  << " " << exv.translation() << endl;
210  os << " " << ra.Axis() << ra.Angle()/deg << endl;
211  tvec.push_back(exv.translation());
212  loop = exv.next();
213  }
214 
215  vector<DDTranslation>::iterator it = tvec.begin();
216  os << endl << "center points of all solids" << endl;
217  for (; it != tvec.end(); ++it) {
218  os << (*it).x() << " " << (*it).y() << " " << (*it).z() << endl;
219  }
220 }
int loop
CMSSW
type of data representation of DDCompactView
Definition: DDCompactView.h:77
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:64
FIPConfiguration reads in the configuration file for the DDParser.
tuple cout
Definition: gather_cfg.py:121
Provides an exploded view of the detector (tree-view)
void printRot ( const DDRotationMatrix rot)

Definition at line 251 of file build.cc.

References funct::cos(), gather_cfg::cout, funct::sin(), and x().

Referenced by testrot().

251  {
252  std::cout << "rot asis\n" << rot << std::endl;
253  DD3Vector x,y,z;
254  rot.GetComponents(x,y,z);
255  std::cout << "components\n"
256  << x << "\n"
257  << y << "\n"
258  << z << std::endl;
259  cout << "phiX=" << x.phi() << " or in degrees = "
260  << x.phi()/deg << endl;
261  cout << "thetaX=" << x.theta() << " or in degrees = "
262  << x.theta()/deg << endl;
263  cout << "phiY=" << y.phi() << " or in degrees = "
264  << y.phi()/deg << endl;
265  cout << "thetaY=" << y.theta() << " or in degrees = "
266  << y.theta()/deg << endl;
267  cout << "phiZ=" << z.phi() << " or in degrees = "
268  << z.phi()/deg << endl;
269  cout << "thetaZ=" << z.theta() << " or in degrees = "
270  << z.theta()/deg << endl;
271 
272  cout << "some factor/equations..." << endl;
273  cout << " sin(thetaX()) * cos(phiX()) = "
274  << sin(x.theta()) * cos(x.phi()) << endl;
275 
276 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
float float float z
T x() const
Cartesian x coordinate.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tuple cout
Definition: gather_cfg.py:121
void regressionTest_first ( )

load the new cpv

Definition at line 111 of file build.cc.

References DDSolidFactory::box(), gather_cfg::cout, DDrot(), ClhepEvaluator::eval(), DDI::Singleton< I >::instance(), DDCompactView::position(), submit::rm, AlCaHLTBitMon_QueryRunRegistry::string, and csvLumiCalc::unit.

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 
120  string ns("first");
121  DDSolid support = DDSolidFactory::box(DDName("support",ns),
122  eval.eval(ns,"[setup:corner]/4."),
123  eval.eval(ns,"[setup:corner]/8."),
124  eval.eval(ns,"[setup:corner]/4.")
125  );
126  DDSolid sensor = DDSolidFactory::box(DDName("sensor",ns),
127  eval.eval(ns,"[setup:corner]/16."),
128  eval.eval(ns,"[setup:corner]/16."),
129  eval.eval(ns,"[setup:corner]/16.")
130  );
131 
132  DDLogicalPart supportLP(DDName("support",ns), // name
133  DDName("Oxygen","elements"), // material
134  DDName("support",ns)); // solid
135 
136  DDLogicalPart sensorLP(DDName("sensor",ns),
137  DDName("Nitrogen","elements"),
138  DDName("sensor",ns));
139 
140  DDLogicalPart part(DDName("group",ns),
141  DDName("Air","setup"),
142  DDName("group","setup")
143  );
144 
145  DDRotation r30(DDName("R30","setup"));
146  DDRotation r60(DDName("R60","setup"));
147  DDRotation r90(DDName("R90","setup"));
148  DDRotation unit(DDName("Unit","setup"));
149  DDTranslation t0;
150  DDTranslation t1(eval.eval(ns,"[setup:corner]/8."),
151  eval.eval(ns,"[setup:corner]/16."),
152  eval.eval(ns,"[setup:corner]/8.")
153  );
154  DDTranslation t2(eval.eval(ns,"[setup:corner]*1.25*cos(0.)"),
155  eval.eval(ns,"[setup:corner]*1.25*sin(0.)"),
156  eval.eval(ns,"0."));
157  DDTranslation t3(eval.eval(ns,"[setup:corner]*1.25*cos(30.*deg)"),
158  eval.eval(ns,"[setup:corner]*1.25*sin(30.*deg)"),
159  eval.eval(ns,"0."));
160  DDTranslation t4(eval.eval(ns,"[setup:corner]*1.25*cos(60.*deg)"),
161  eval.eval(ns,"[setup:corner]*1.25*sin(60.*deg)"),
162  eval.eval(ns,"0."));
163  DDTranslation t5(eval.eval(ns,"[setup:corner]*1.25*cos(90.*deg)"),
164  eval.eval(ns,"[setup:corner]*1.25*sin(90.*deg)"),
165  eval.eval(ns,"0."));
166 
167  cpv.position(sensorLP, supportLP, std::string("1"), t1, unit);
168  cpv.position(supportLP, part, std::string("1"), t2, unit);
169  cpv.position(supportLP, part, std::string("2"), t3, r30);
170  cpv.position(supportLP, part, std::string("3"), t4, r60);
171  cpv.position(supportLP, part, std::string("4"), t5, r90);
172 
173  DDRotationMatrix * rm = new DDRotationMatrix(ROOT::Math::AxisAngle(DD3Vector(1.,1.,1.),20.*deg));
174  DDRotation rw= DDrot(DDName("group", ns), rm);
175  DDLogicalPart ws(DDName("world","setup"));
176  cpv.position(part, ws, std::string("1"), t0, rw);
177 }
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:14
type of data representation of DDCompactView
Definition: DDCompactView.h:77
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
static value_type & instance()
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
string unit
Definition: csvLumiCalc.py:46
string rm
Definition: submit.py:76
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
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:519
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:64
part
Definition: HCALResponse.h:20
double eval(const std::string &ns, const std::string &expr)
tuple cout
Definition: gather_cfg.py:121
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void regressionTest_setup ( )

Definition at line 37 of file build.cc.

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

37  {
39 
40  string ns = "setup"; // current namespace faking the filename 'setup.xml'
41 
42  // length of a side of world cube
43  eval.set(ns,"length","20.*m");
44 
45  // center of a corner in the cube
46  eval.set(ns,"corner","[length]/4.");
47 
48  // world-solid
49  DDName worldName("world",ns);
50  DDName airName("Air",ns);
51  DDName nitrogenName("Nitrogen","elements");
52  DDName oxygenName("Oxygen","elements");
53 
54  DDSolidFactory::box(worldName, eval.eval(ns,"[length]/2."),
55  eval.eval(ns,"[length]/2."),
56  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)
83  DDRotationMatrix * r30 = new DDRotationMatrix(ROOT::Math::RotationZ(30.*deg));
84  DDRotationMatrix * r60 = new DDRotationMatrix(ROOT::Math::RotationZ(60.*deg));
85  DDRotationMatrix * r90 = new DDRotationMatrix(ROOT::Math::RotationZ(90.*deg));
86 
87  DDrot(DDName("Unit",ns),r0);
88  DDrot(DDName("R30",ns),r30);
89  DDrot(DDName("R60",ns),r60);
90  DDrot(DDName("R90",ns),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:41
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:14
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
int addMaterial(const DDMaterial &m, double fm)
adds a material to the mixture proportional to its fraction-mass fm.
Definition: DDMaterial.cc:72
static value_type & instance()
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
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:519
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
static DDSolid shapeless(const DDName &name)
Definition: DDSolid.cc:846
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:121
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void testParser ( )

Definition at line 222 of file build.cc.

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

223 {
224  try {
225  cout << "main:: initialize" << endl;
226  DDCompactView cpv;
227  cout << "main::initialize DDL parser" << endl;
228  DDLParser myP(cpv);
229 
230  cout << "main::about to set configuration" << endl;
231 
232  FIPConfiguration cf(cpv);
233  cf.readConfig("DetectorDescription/RegressionTest/test/configuration.xml");
234 
235  cout << "main::about to start parsing" << endl;
236 
237  myP.parse(cf);
238 
239  cout << "main::completed Parser" << endl;
240 
241  cout << endl << endl << "main::Start checking!" << endl << endl;
242 
243  }
244  catch (cms::Exception& e)
245  {
246  cout << "main::PROBLEM:" << endl
247  << " " << e << endl;
248  }
249 }
type of data representation of DDCompactView
Definition: DDCompactView.h:77
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:64
FIPConfiguration reads in the configuration file for the DDParser.
tuple cout
Definition: gather_cfg.py:121
void testrot ( )

Definition at line 278 of file build.cc.

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

279 {
280  {
281  ROOT::Math::AxisAngle aa(DD3Vector(1.,1.,1.), 20.*deg);
282  DDRotationMatrix rm(aa);
283  cout << "DD3Vector was " << DD3Vector(1.,1.,1.) << " and the rotation was 20*deg around that axis." << endl;
284  printRot(rm);
285  }
286  {
287  DDRotationMatrix rm(1,0,0, 0,-1,0, 0,0,1);
288  cout << "(1,0,0, 0,-1,0, 0,0,1)" << endl;
289  printRot(rm);
290  }
291 }
void printRot(const DDRotationMatrix &rot)
Definition: build.cc:251
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
string rm
Definition: submit.py:76
tuple cout
Definition: gather_cfg.py:121
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.