CMS 3D CMS Logo

Functions
build.cc File Reference
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include "CLHEP/Units/SystemOfUnits.h"
#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 "DetectorDescription/Core/interface/ClhepEvaluator.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 ()
 
void regressionTest_setup ()
 
void testParser ()
 
void testrot ()
 

Function Documentation

void output ( string  filename)

load the new cpv

Definition at line 184 of file build.cc.

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

185 {
186  ostream & os(cout);
187 
188  os << "Starting Regressiontest Output" << endl;
190  DDCompactView cpv;
191  cout << "main::initialize DDL parser" << endl;
192  DDLParser myP(cpv);
193 
194  cout << "main::about to set configuration" << endl;
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.emplace_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:90
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:62
FIPConfiguration reads in the configuration file for the DDParser.
Provides an exploded view of the detector (tree-view)
void printRot ( const DDRotationMatrix rot)

Definition at line 255 of file build.cc.

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

Referenced by testrot().

255  {
256  std::cout << "rot asis\n" << rot << std::endl;
257  DD3Vector x,y,z;
258  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
float float float z
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
void regressionTest_first ( )

load the new cpv

Definition at line 115 of file build.cc.

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

115  {
117  DDCompactView cpv;
118  cout << "main::initialize DDL parser" << endl;
119  DDLParser myP(cpv);
120 
121  cout << "main::about to set configuration" << endl;
122 
124  string ns("first");
125  DDSolid support = DDSolidFactory::box(DDName("support",ns),
126  eval.eval(ns,"[setup:corner]/4."),
127  eval.eval(ns,"[setup:corner]/8."),
128  eval.eval(ns,"[setup:corner]/4.")
129  );
130  DDSolid sensor = DDSolidFactory::box(DDName("sensor",ns),
131  eval.eval(ns,"[setup:corner]/16."),
132  eval.eval(ns,"[setup:corner]/16."),
133  eval.eval(ns,"[setup:corner]/16.")
134  );
135 
136  DDLogicalPart supportLP(DDName("support",ns), // name
137  DDName("Oxygen","elements"), // material
138  DDName("support",ns)); // solid
139 
140  DDLogicalPart sensorLP(DDName("sensor",ns),
141  DDName("Nitrogen","elements"),
142  DDName("sensor",ns));
143 
144  DDLogicalPart part(DDName("group",ns),
145  DDName("Air","setup"),
146  DDName("group","setup")
147  );
148 
149  DDRotation r30(DDName("R30","setup"));
150  DDRotation r60(DDName("R60","setup"));
151  DDRotation r90(DDName("R90","setup"));
152  DDRotation unit(DDName("Unit","setup"));
154  DDTranslation t1(eval.eval(ns,"[setup:corner]/8."),
155  eval.eval(ns,"[setup:corner]/16."),
156  eval.eval(ns,"[setup:corner]/8.")
157  );
158  DDTranslation t2(eval.eval(ns,"[setup:corner]*1.25*cos(0.)"),
159  eval.eval(ns,"[setup:corner]*1.25*sin(0.)"),
160  eval.eval(ns,"0."));
161  DDTranslation t3(eval.eval(ns,"[setup:corner]*1.25*cos(30.*deg)"),
162  eval.eval(ns,"[setup:corner]*1.25*sin(30.*deg)"),
163  eval.eval(ns,"0."));
164  DDTranslation t4(eval.eval(ns,"[setup:corner]*1.25*cos(60.*deg)"),
165  eval.eval(ns,"[setup:corner]*1.25*sin(60.*deg)"),
166  eval.eval(ns,"0."));
167  DDTranslation t5(eval.eval(ns,"[setup:corner]*1.25*cos(90.*deg)"),
168  eval.eval(ns,"[setup:corner]*1.25*sin(90.*deg)"),
169  eval.eval(ns,"0."));
170 
171  cpv.position(sensorLP, supportLP, std::string("1"), t1, unit);
172  cpv.position(supportLP, part, std::string("1"), t2, unit);
173  cpv.position(supportLP, part, std::string("2"), t3, r30);
174  cpv.position(supportLP, part, std::string("3"), t4, r60);
175  cpv.position(supportLP, part, std::string("4"), t5, r90);
176 
177  DDRotationMatrix * rm = new DDRotationMatrix(ROOT::Math::AxisAngle(DD3Vector(1.,1.,1.),20.*deg));
178  DDRotation rw= DDrot(DDName("group", ns), rm);
179  DDLogicalPart ws(DDName("world","setup"));
180  cpv.position(part, ws, std::string("1"), t0, rw);
181 }
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
type of data representation of DDCompactView
Definition: DDCompactView.h:90
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
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
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
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:819
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:62
part
Definition: HCALResponse.h:20
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
double eval(const std::string &ns, const std::string &expr)
rm
Definition: submit.py:76
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void regressionTest_setup ( )

Definition at line 41 of file build.cc.

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

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

Definition at line 226 of file build.cc.

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

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

Definition at line 282 of file build.cc.

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

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