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/Algorithm/src/AlgoInit.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 182 of file build.cc.

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

183 {
184  ostream & os(cout);
185 
186  os << "Starting Regressiontest Output" << endl;
188  AlgoInit();
189  DDCompactView cpv;
190  cout << "main::initialize DDL parser" << endl;
191  DDLParser myP(cpv);// = DDLParser::instance();
192 
193  cout << "main::about to set configuration" << endl;
194  // myP->SetConfig("configuration.xml");
195  FIPConfiguration cf(cpv);
196  cf.readConfig("DetectorDescription/RegressionTest/test/configuration.xml");
197 
198  cout << "main::about to start parsing" << endl;
199 
200  myP.parse(cf);
201 
202  cout << "main::completed Parser" << endl;
203 
204  DDExpandedView exv(cpv);
205  vector<DDTranslation> tvec;
206  bool loop=true;
207  std::cout << "Before the loop..." << std::endl;
208  while(loop) {
209  ROOT::Math::AxisAngle ra(exv.rotation());
210  os << exv.logicalPart() << endl
211  << " " << exv.logicalPart().material() << endl
212  << " " << exv.logicalPart().solid() << endl
213  << " " << exv.translation() << endl;
214  os << " " << ra.Axis() << ra.Angle()/deg << endl;
215  tvec.push_back(exv.translation());
216  loop = exv.next();
217  }
218 
219  vector<DDTranslation>::iterator it = tvec.begin();
220  os << endl << "center points of all solids" << endl;
221  for (; it != tvec.end(); ++it) {
222  os << (*it).x() << " " << (*it).y() << " " << (*it).z() << endl;
223  }
224 }
type of data representation of DDCompactView
Definition: DDCompactView.h:81
void AlgoInit()
Definition: AlgoInit.cc:28
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:41
Provides an exploded view of the detector (tree-view)
void printRot ( const DDRotationMatrix rot)

Definition at line 256 of file build.cc.

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

Referenced by testrot().

256  {
257  std::cout << "rot asis\n" << rot << std::endl;
258  DD3Vector x,y,z; const_cast<DDRotationMatrix &>(rot).GetComponents(x,y,z);
259  std::cout << "components\n"
260  << x << "\n"
261  << y << "\n"
262  << z << std::endl;
263  cout << "phiX=" << x.phi() << " or in degrees = "
264  << x.phi()/deg << endl;
265  cout << "thetaX=" << x.theta() << " or in degrees = "
266  << x.theta()/deg << endl;
267  cout << "phiY=" << y.phi() << " or in degrees = "
268  << y.phi()/deg << endl;
269  cout << "thetaY=" << y.theta() << " or in degrees = "
270  << y.theta()/deg << endl;
271  cout << "phiZ=" << z.phi() << " or in degrees = "
272  << z.phi()/deg << endl;
273  cout << "thetaZ=" << z.theta() << " or in degrees = "
274  << z.theta()/deg << endl;
275 
276  cout << "some factor/equations..." << endl;
277  cout << " sin(thetaX()) * cos(phiX()) = "
278  << sin(x.theta()) * cos(x.phi()) << endl;
279 
280 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Definition: DDAxes.h:10
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:41
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void regressionTest_first ( )

load the new cpv

Definition at line 112 of file build.cc.

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

112  {
114  AlgoInit();
115  DDCompactView cpv;
116  cout << "main::initialize DDL parser" << endl;
117  DDLParser myP(cpv);// = DDLParser::instance();
118 
119  cout << "main::about to set configuration" << endl;
120 
122  string ns("first");
123  DDSolid support = DDSolidFactory::box(DDName("support",ns),
124  eval.eval(ns,"[setup:corner]/4."),
125  eval.eval(ns,"[setup:corner]/8."),
126  eval.eval(ns,"[setup:corner]/4.")
127  );
128  DDSolid sensor = DDSolidFactory::box(DDName("sensor",ns),
129  eval.eval(ns,"[setup:corner]/16."),
130  eval.eval(ns,"[setup:corner]/16."),
131  eval.eval(ns,"[setup:corner]/16.")
132  );
133 
134  DDLogicalPart supportLP(DDName("support",ns), // name
135  DDName("Oxygen","elements"), // material
136  DDName("support",ns)); // solid
137 
138  DDLogicalPart sensorLP(DDName("sensor",ns),
139  DDName("Nitrogen","elements"),
140  DDName("sensor",ns));
141 
142  DDLogicalPart part(DDName("group",ns),
143  DDName("Air","setup"),
144  DDName("group","setup")
145  );
146 
147  DDRotation r30(DDName("R30","setup"));
148  DDRotation r60(DDName("R60","setup"));
149  DDRotation r90(DDName("R90","setup"));
150  DDRotation unit(DDName("Unit","setup"));
151  DDTranslation t0;
152  DDTranslation t1(eval.eval(ns,"[setup:corner]/8."),
153  eval.eval(ns,"[setup:corner]/16."),
154  eval.eval(ns,"[setup:corner]/8.")
155  );
156  DDTranslation t2(eval.eval(ns,"[setup:corner]*1.25*cos(0.)"),
157  eval.eval(ns,"[setup:corner]*1.25*sin(0.)"),
158  eval.eval(ns,"0."));
159  DDTranslation t3(eval.eval(ns,"[setup:corner]*1.25*cos(30.*deg)"),
160  eval.eval(ns,"[setup:corner]*1.25*sin(30.*deg)"),
161  eval.eval(ns,"0."));
162  DDTranslation t4(eval.eval(ns,"[setup:corner]*1.25*cos(60.*deg)"),
163  eval.eval(ns,"[setup:corner]*1.25*sin(60.*deg)"),
164  eval.eval(ns,"0."));
165  DDTranslation t5(eval.eval(ns,"[setup:corner]*1.25*cos(90.*deg)"),
166  eval.eval(ns,"[setup:corner]*1.25*sin(90.*deg)"),
167  eval.eval(ns,"0."));
168 
169  cpv.position(sensorLP, supportLP, std::string("1"), t1, unit);
170  cpv.position(supportLP, part, std::string("1"), t2, unit);
171  cpv.position(supportLP, part, std::string("2"), t3, r30);
172  cpv.position(supportLP, part, std::string("3"), t4, r60);
173  cpv.position(supportLP, part, std::string("4"), t5, r90);
174 
175  DDRotationMatrix * rm = new DDRotationMatrix(ROOT::Math::AxisAngle(DD3Vector(1.,1.,1.),20.*deg));
176  DDRotation rw= DDrot(DDName("group", ns), rm);
177  DDLogicalPart ws(DDName("world","setup"));
178  cpv.position(part, ws, std::string("1"), t0, rw);
179 }
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:18
type of data representation of DDCompactView
Definition: DDCompactView.h:81
A DDSolid represents the shape of a part.
Definition: DDSolid.h:42
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()
void AlgoInit()
Definition: AlgoInit.cc:28
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
Interface of an Expression Evaluator.
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:95
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Definition: DDSolid.cc:522
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:94
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:64
virtual double eval(const std::string &ns, const std::string &expr)=0
evaluate an expression expr inside the local namespace
part
Definition: HCALResponse.h:21
tuple cout
Definition: gather_cfg.py:41
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void regressionTest_setup ( )

Definition at line 38 of file build.cc.

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

38  {
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 
55  DDSolidFactory::box(worldName, eval.eval(ns,"[length]/2."),
56  eval.eval(ns,"[length]/2."),
57  eval.eval(ns,"[length]/2."));
58 
59  DDLogicalPart(worldName, // name
60  airName, // material
61  worldName // solid
62  );
63 
64  DDMaterial air(airName,eval.eval(ns,"1.214*mg/cm3")); // mixture for Air
65  air.addMaterial(DDMaterial(nitrogenName),eval.eval(ns,"0.75"));
66  air.addMaterial(DDMaterial(oxygenName),eval.eval(ns,"0.25"));
67 
68  cout << air << endl;
69 
70  DDMaterial(nitrogenName, // name
71  eval.eval(ns,"7"), // Z
72  eval.eval(ns,"14.007*g/mole"), // A
73  eval.eval(ns,"0.808*g/cm3") ); // density
74 
75  DDMaterial(oxygenName, // name
76  eval.eval(ns,"8"), // Z
77  eval.eval(ns,"15.999*g/mole"), // A
78  eval.eval(ns,"1.43*g/cm3") ); // density
79 
80  cout << air << endl;
81 
82  // Some rotations in the x-y plane (Unit, 30,60,90 degs)
84  DDRotationMatrix * r30 = new DDRotationMatrix(ROOT::Math::RotationZ(30.*deg));
85  DDRotationMatrix * r60 = new DDRotationMatrix(ROOT::Math::RotationZ(60.*deg));
86  DDRotationMatrix * r90 = new DDRotationMatrix(ROOT::Math::RotationZ(90.*deg));
87 
88  DDrot(DDName("Unit",ns),r0);
89  DDrot(DDName("R30",ns),r30);
90  DDrot(DDName("R60",ns),r60);
91  DDrot(DDName("R90",ns),r90);
92 
93  DDSolid collectorSolid = DDSolidFactory::shapeless(DDName("group",ns));
94 
95  DDRootDef::instance().set(worldName);
96 }
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
virtual void set(const std::string &ns, const std::string &name, const std::string &valueExpr)=0
put a new variable named &#39;namespace:name&#39; into the dictionary of the evaluator
A DDSolid represents the shape of a part.
Definition: DDSolid.h:42
int addMaterial(const DDMaterial &m, double fm)
adds a material to the mixture proportional to its fraction-mass fm.
Definition: DDMaterial.cc:75
static value_type & instance()
Interface of an Expression Evaluator.
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:95
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Definition: DDSolid.cc:522
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:94
virtual double eval(const std::string &ns, const std::string &expr)=0
evaluate an expression expr inside the local namespace
static DDSolid shapeless(const DDName &name)
Definition: DDSolid.cc:849
tuple cout
Definition: gather_cfg.py:41
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void testParser ( )

Definition at line 226 of file build.cc.

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

227 {
228  try {
229  cout << "main:: initialize" << endl;
230  AlgoInit();
231  DDCompactView cpv;
232  cout << "main::initialize DDL parser" << endl;
233  DDLParser myP(cpv);// = DDLParser::instance();
234 
235  cout << "main::about to set configuration" << endl;
236  // myP->SetConfig("configuration.xml");
237  FIPConfiguration cf(cpv);
238  cf.readConfig("DetectorDescription/RegressionTest/test/configuration.xml");
239 
240  cout << "main::about to start parsing" << endl;
241 
242  myP.parse(cf);
243 
244  cout << "main::completed Parser" << endl;
245 
246  cout << endl << endl << "main::Start checking!" << endl << endl;
247 
248  }
249  catch (DDException& e)
250  {
251  cout << "main::PROBLEM:" << endl
252  << " " << e << endl;
253  }
254 }
An exception for DDD errors.
Definition: DDException.h:23
type of data representation of DDCompactView
Definition: DDCompactView.h:81
void AlgoInit()
Definition: AlgoInit.cc:28
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:41
void testrot ( )

Definition at line 282 of file build.cc.

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

283 {
284  // ExprEvalInterface & eval = ExprEval::instance();
285  {
286  ROOT::Math::AxisAngle aa(DD3Vector(1.,1.,1.), 20.*deg);
287  DDRotationMatrix rm(aa);
288  cout << "DD3Vector was " << DD3Vector(1.,1.,1.) << " and the rotation was 20*deg around that axis." << endl;
289  printRot(rm);
290  }
291  {
292  DDRotationMatrix rm(1,0,0, 0,-1,0, 0,0,1);
293  cout << "(1,0,0, 0,-1,0, 0,0,1)" << endl;
294  printRot(rm);
295  }
296 }
void printRot(const DDRotationMatrix &rot)
Definition: build.cc:256
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:41
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.