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

void output ( string  filename)

load the new cpv

Definition at line 181 of file build.cc.

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

182 {
183  ostream & os(cout);
184 
185  os << "Starting Regressiontest Output" << endl;
187  DDCompactView cpv;
188  cout << "main::initialize DDL parser" << endl;
189  DDLParser myP(cpv);
190 
191  cout << "main::about to set configuration" << endl;
192  FIPConfiguration cf(cpv);
193  cf.readConfig("DetectorDescription/RegressionTest/test/configuration.xml");
194 
195  cout << "main::about to start parsing" << endl;
196 
197  myP.parse(cf);
198 
199  cout << "main::completed Parser" << endl;
200 
201  DDExpandedView exv(cpv);
202  vector<DDTranslation> tvec;
203  bool loop=true;
204  std::cout << "Before the loop..." << std::endl;
205  while(loop) {
206  ROOT::Math::AxisAngle ra(exv.rotation());
207  os << exv.logicalPart() << endl
208  << " " << exv.logicalPart().material() << endl
209  << " " << exv.logicalPart().solid() << endl
210  << " " << exv.translation() << endl;
211  os << " " << ra.Axis() << convertRadToDeg( ra.Angle() ) << endl;
212  tvec.emplace_back(exv.translation());
213  loop = exv.next();
214  }
215 
216  vector<DDTranslation>::iterator it = tvec.begin();
217  os << endl << "center points of all solids" << endl;
218  for (; it != tvec.end(); ++it) {
219  os << (*it).x() << " " << (*it).y() << " " << (*it).z() << endl;
220  }
221 }
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
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 252 of file build.cc.

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

Referenced by testrot().

252  {
253  std::cout << "rot asis\n" << rot << std::endl;
254  DD3Vector x,y,z;
255  rot.GetComponents(x,y,z);
256  std::cout << "components\n"
257  << x << "\n"
258  << y << "\n"
259  << z << std::endl;
260  cout << "phiX=" << x.phi() << " or in degrees = "
261  << convertRadToDeg( x.phi() ) << endl;
262  cout << "thetaX=" << x.theta() << " or in degrees = "
263  << convertRadToDeg( x.theta() ) << endl;
264  cout << "phiY=" << y.phi() << " or in degrees = "
265  << convertRadToDeg( y.phi() ) << endl;
266  cout << "thetaY=" << y.theta() << " or in degrees = "
267  << convertRadToDeg( y.theta() ) << endl;
268  cout << "phiZ=" << z.phi() << " or in degrees = "
269  << convertRadToDeg( z.phi() ) << endl;
270  cout << "thetaZ=" << z.theta() << " or in degrees = "
271  << convertRadToDeg( z.theta() ) << endl;
272 
273  cout << "some factor/equations..." << endl;
274  cout << " sin(thetaX()) * cos(phiX()) = "
275  << sin(x.theta()) * cos(x.phi()) << endl;
276 
277 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
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 ( ClhepEvaluator eval)

load the new cpv

Definition at line 113 of file build.cc.

References DDSolidFactory::box(), gather_cfg::cout, DDrot(), ClhepEvaluator::eval(), eostools::move(), DDCompactView::position(), submit::rm, AlCaHLTBitMon_QueryRunRegistry::string, cscNeutronWriter_cfi::t0, and csvLumiCalc::unit.

113  {
115  DDCompactView cpv;
116  cout << "main::initialize DDL parser" << endl;
117  DDLParser myP(cpv);
118 
119  cout << "main::about to set configuration" << endl;
120 
121  string ns("first");
122  DDSolid support = DDSolidFactory::box(DDName("support",ns),
123  eval.eval(ns,"[setup:corner]/4."),
124  eval.eval(ns,"[setup:corner]/8."),
125  eval.eval(ns,"[setup:corner]/4.")
126  );
127  DDSolid sensor = DDSolidFactory::box(DDName("sensor",ns),
128  eval.eval(ns,"[setup:corner]/16."),
129  eval.eval(ns,"[setup:corner]/16."),
130  eval.eval(ns,"[setup:corner]/16.")
131  );
132 
133  DDLogicalPart supportLP(DDName("support",ns), // name
134  DDName("Oxygen","elements"), // material
135  DDName("support",ns)); // solid
136 
137  DDLogicalPart sensorLP(DDName("sensor",ns),
138  DDName("Nitrogen","elements"),
139  DDName("sensor",ns));
140 
141  DDLogicalPart part(DDName("group",ns),
142  DDName("Air","setup"),
143  DDName("group","setup")
144  );
145 
146  DDRotation r30(DDName("R30","setup"));
147  DDRotation r60(DDName("R60","setup"));
148  DDRotation r90(DDName("R90","setup"));
149  DDRotation unit(DDName("Unit","setup"));
151  DDTranslation t1(eval.eval(ns,"[setup:corner]/8."),
152  eval.eval(ns,"[setup:corner]/16."),
153  eval.eval(ns,"[setup:corner]/8.")
154  );
155  DDTranslation t2(eval.eval(ns,"[setup:corner]*1.25*cos(0.)"),
156  eval.eval(ns,"[setup:corner]*1.25*sin(0.)"),
157  eval.eval(ns,"0."));
158  DDTranslation t3(eval.eval(ns,"[setup:corner]*1.25*cos(30.*deg)"),
159  eval.eval(ns,"[setup:corner]*1.25*sin(30.*deg)"),
160  eval.eval(ns,"0."));
161  DDTranslation t4(eval.eval(ns,"[setup:corner]*1.25*cos(60.*deg)"),
162  eval.eval(ns,"[setup:corner]*1.25*sin(60.*deg)"),
163  eval.eval(ns,"0."));
164  DDTranslation t5(eval.eval(ns,"[setup:corner]*1.25*cos(90.*deg)"),
165  eval.eval(ns,"[setup:corner]*1.25*sin(90.*deg)"),
166  eval.eval(ns,"0."));
167 
168  cpv.position(sensorLP, supportLP, std::string("1"), t1, unit);
169  cpv.position(supportLP, part, std::string("1"), t2, unit);
170  cpv.position(supportLP, part, std::string("2"), t3, r30);
171  cpv.position(supportLP, part, std::string("3"), t4, r60);
172  cpv.position(supportLP, part, std::string("4"), t5, r90);
173 
174  std::unique_ptr<DDRotationMatrix> rm = std::make_unique<DDRotationMatrix>( ROOT::Math::AxisAngle( DD3Vector( 1., 1., 1. ), 20._deg ));
175  DDRotation rw = DDrot( DDName( "group", ns ), std::move( rm ));
176  DDLogicalPart ws( DDName( "world", "setup" ));
177  cpv.position( part, ws, std::string( "1" ), t0, rw );
178 }
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
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:80
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:704
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
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:77
def move(src, dest)
Definition: eostools.py:511
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 
42  string ns = "setup"; // current namespace faking the filename 'setup.xml'
43 
44  // length of a side of world cube
45  eval.set(ns,"length","20.*m");
46 
47  // center of a corner in the cube
48  eval.set(ns,"corner","[length]/4.");
49 
50  // world-solid
51  DDName worldName("world",ns);
52  DDName airName("Air",ns);
53  DDName nitrogenName("Nitrogen","elements");
54  DDName oxygenName("Oxygen","elements");
55 
56  DDSolidFactory::box(worldName, eval.eval(ns,"[length]/2."),
57  eval.eval(ns,"[length]/2."),
58  eval.eval(ns,"[length]/2."));
59 
60  DDLogicalPart(worldName, // name
61  airName, // material
62  worldName // solid
63  );
64 
65  DDMaterial air(airName,eval.eval(ns,"1.214*mg/cm3")); // mixture for Air
66  air.addMaterial(DDMaterial(nitrogenName),eval.eval(ns,"0.75"));
67  air.addMaterial(DDMaterial(oxygenName),eval.eval(ns,"0.25"));
68 
69  cout << air << endl;
70 
71  DDMaterial(nitrogenName, // name
72  eval.eval(ns,"7"), // Z
73  eval.eval(ns,"14.007*g/mole"), // A
74  eval.eval(ns,"0.808*g/cm3") ); // density
75 
76  DDMaterial(oxygenName, // name
77  eval.eval(ns,"8"), // Z
78  eval.eval(ns,"15.999*g/mole"), // A
79  eval.eval(ns,"1.43*g/cm3") ); // density
80 
81  cout << air << endl;
82 
83  // Some rotations in the x-y plane (Unit, 30,60,90 degs)
84  std::unique_ptr<DDRotationMatrix> r0 = std::make_unique<DDRotationMatrix>();
85  std::unique_ptr<DDRotationMatrix> r30 = std::make_unique<DDRotationMatrix>(ROOT::Math::RotationZ( 30._deg ));
86  std::unique_ptr<DDRotationMatrix> r60 = std::make_unique<DDRotationMatrix>(ROOT::Math::RotationZ( 60._deg ));
87  std::unique_ptr<DDRotationMatrix> r90 = std::make_unique<DDRotationMatrix>(ROOT::Math::RotationZ( 90._deg ));
88 
89  DDrot( DDName( "Unit", ns ), std::move( r0 ));
90  DDrot( DDName( "R30", ns ), std::move( r30 ));
91  DDrot( DDName( "R60", ns ), std::move( r60 ));
92  DDrot( DDName( "R90", ns ), std::move( r90 ));
93 
94  DDSolid collectorSolid = DDSolidFactory::shapeless( DDName( "group", ns ));
95 
96  DDRootDef::instance().set( worldName );
97 }
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
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:72
static value_type & instance()
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:80
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:704
static DDSolid shapeless(const DDName &name)
Definition: DDSolid.cc:909
void set(const std::string &ns, const std::string &name, const std::string &exprValue)
double eval(const std::string &ns, const std::string &expr)
def move(src, dest)
Definition: eostools.py:511
void testParser ( )

Definition at line 223 of file build.cc.

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

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

Definition at line 279 of file build.cc.

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

280 {
281  {
282  ROOT::Math::AxisAngle aa(DD3Vector(1.,1.,1.), 20._deg);
283  DDRotationMatrix rm(aa);
284  cout << "DD3Vector was " << DD3Vector(1.,1.,1.) << " and the rotation was 20*deg around that axis." << endl;
285  printRot(rm);
286  }
287  {
288  DDRotationMatrix rm(1,0,0, 0,-1,0, 0,0,1);
289  cout << "(1,0,0, 0,-1,0, 0,0,1)" << endl;
290  printRot(rm);
291  }
292 }
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void printRot(const DDRotationMatrix &rot)
Definition: build.cc:252
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:77