#include <cmath>
#include "CLHEP/Units/SystemOfUnits.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/Core/interface/DDPosPart.h"
#include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
#include <Math/RotationX.h>
#include <Math/RotationY.h>
#include <Math/RotationZ.h>
#include <Math/AxisAngle.h>
#include <iostream>
#include <fstream>
#include <vector>
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDExpandedView.h"
#include "DetectorDescription/Parser/interface/DDLParser.h"
#include "DetectorDescription/Parser/interface/DDLConfiguration.h"
#include "DetectorDescription/Algorithm/src/AlgoInit.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 () |
void output | ( | string | filename | ) |
Definition at line 198 of file build.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), it, DDExpandedView::logicalPart(), python::cmstools::loop(), DDLogicalPart::material(), DDExpandedView::next(), DDExpandedView::rotation(), DDLogicalPart::solid(), and DDExpandedView::translation().
00199 { 00200 ostream & os(cout); 00201 00202 os << "Starting Regressiontest Output" << endl; 00203 DDCompactView cpv; 00204 DDExpandedView exv(cpv); 00205 vector<DDTranslation> tvec; 00206 bool loop=true; 00207 while(loop) { 00208 ROOT::Math::AxisAngle ra(exv.rotation()); 00209 os << exv.logicalPart() << endl 00210 << " " << exv.logicalPart().material() << endl 00211 << " " << exv.logicalPart().solid() << endl 00212 << " " << exv.translation() << endl; 00213 os << " " << ra.Axis() << ra.Angle()/deg << endl; 00214 tvec.push_back(exv.translation()); 00215 loop = exv.next(); 00216 } 00217 00218 vector<DDTranslation>::iterator it = tvec.begin(); 00219 os << endl << "center points of all solids" << endl; 00220 for (; it != tvec.end(); ++it) { 00221 os << (*it).x() << " " << (*it).y() << " " << (*it).z() << endl; 00222 } 00223 }
void printRot | ( | const DDRotationMatrix & | rot | ) |
Definition at line 258 of file build.cc.
References funct::cos(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), funct::sin(), x, y, and z.
Referenced by testrot().
00258 { 00259 std::cout << "rot asis\n" << rot << std::endl; 00260 DD3Vector x,y,z; const_cast<DDRotationMatrix &>(rot).GetComponents(x,y,z); 00261 std::cout << "components\n" 00262 << x << "\n" 00263 << y << "\n" 00264 << z << std::endl; 00265 cout << "phiX=" << x.phi() << " or in degrees = " 00266 << x.phi()/deg << endl; 00267 cout << "thetaX=" << x.theta() << " or in degrees = " 00268 << x.theta()/deg << endl; 00269 cout << "phiY=" << y.phi() << " or in degrees = " 00270 << y.phi()/deg << endl; 00271 cout << "thetaY=" << y.theta() << " or in degrees = " 00272 << y.theta()/deg << endl; 00273 cout << "phiZ=" << z.phi() << " or in degrees = " 00274 << z.phi()/deg << endl; 00275 cout << "thetaZ=" << z.theta() << " or in degrees = " 00276 << z.theta()/deg << endl; 00277 00278 cout << "some factor/equations..." << endl; 00279 cout << " sin(thetaX()) * cos(phiX()) = " 00280 << sin(x.theta()) * cos(x.phi()) << endl; 00281 00282 }
void regressionTest_first | ( | ) |
Definition at line 105 of file build.cc.
References DDSolidFactory::box(), DDpos(), DDrot(), ExprEvalInterface::eval(), and DDI::Singleton< I >::instance().
00105 { 00106 ExprEvalInterface & eval = ExprEval::instance(); 00107 string ns("first"); 00108 DDSolid support = DDSolidFactory::box(DDName("support",ns), 00109 eval.eval(ns,"[setup:corner]/4."), 00110 eval.eval(ns,"[setup:corner]/8."), 00111 eval.eval(ns,"[setup:corner]/4.") 00112 ); 00113 DDSolid sensor = DDSolidFactory::box(DDName("sensor",ns), 00114 eval.eval(ns,"[setup:corner]/16."), 00115 eval.eval(ns,"[setup:corner]/16."), 00116 eval.eval(ns,"[setup:corner]/16.") 00117 ); 00118 00119 DDLogicalPart supportLP(DDName("support",ns), // name 00120 DDName("Oxygen","elements"), // material 00121 DDName("support",ns)); // solid 00122 00123 DDLogicalPart sensorLP(DDName("sensor",ns), 00124 DDName("Nitrogen","elements"), 00125 DDName("sensor",ns)); 00126 00127 DDpos(DDName("sensor",ns), // child 00128 DDName("support",ns), // parent 00129 "1", 00130 DDTranslation(eval.eval(ns,"[setup:corner]/8."), 00131 eval.eval(ns,"[setup:corner]/16."), 00132 eval.eval(ns,"[setup:corner]/8.") 00133 ), 00134 DDRotation(DDName("Unit","setup")) 00135 ); 00136 00137 00138 DDLogicalPart part(DDName("group",ns), 00139 DDName("Air","setup"), 00140 DDName("group","setup") 00141 ); 00142 00143 00144 DDpos(DDName("support",ns), 00145 DDName("group",ns), 00146 "1", 00147 DDTranslation(eval.eval(ns,"[setup:corner]*1.25*cos(0.)"), 00148 eval.eval(ns,"[setup:corner]*1.25*sin(0.)"), 00149 eval.eval(ns,"0.")), 00150 DDRotation(DDName("Unit","setup")) 00151 ); 00152 00153 DDpos(DDName("support",ns), 00154 DDName("group",ns), 00155 "2", 00156 DDTranslation(eval.eval(ns,"[setup:corner]*1.25*cos(30.*deg)"), 00157 eval.eval(ns,"[setup:corner]*1.25*sin(30.*deg)"), 00158 eval.eval(ns,"0.")), 00159 DDRotation(DDName("R30","setup")) 00160 ); 00161 00162 DDpos(DDName("support",ns), 00163 DDName("group",ns), 00164 "3", 00165 DDTranslation(eval.eval(ns,"[setup:corner]*1.25*cos(60.*deg)"), 00166 eval.eval(ns,"[setup:corner]*1.25*sin(60.*deg)"), 00167 eval.eval(ns,"0.")), 00168 DDRotation(DDName("R60","setup")) 00169 ); 00170 00171 DDpos(DDName("support",ns), 00172 DDName("group",ns), 00173 "4", 00174 DDTranslation(eval.eval(ns,"[setup:corner]*1.25*cos(90.*deg)"), 00175 eval.eval(ns,"[setup:corner]*1.25*sin(90.*deg)"), 00176 eval.eval(ns,"0.")), 00177 DDRotation(DDName("R90","setup")) 00178 ); 00179 00180 00181 00182 DDRotationMatrix * rm = new DDRotationMatrix(ROOT::Math::AxisAngle(DD3Vector(1.,1.,1.),20.*deg)); 00183 DDpos(DDName("group",ns), 00184 DDName("world","setup"), 00185 "1", 00186 DDTranslation(), 00187 DDrot(DDName("group",ns), rm) 00188 ); 00189 00190 }
void regressionTest_setup | ( | ) |
Definition at line 31 of file build.cc.
References DDSolidFactory::box(), GenMuonPlsPt100GeV_cfg::cout, DDrot(), lat::endl(), ExprEvalInterface::eval(), DDI::Singleton< I >::instance(), ExprEvalInterface::set(), and DDSolidFactory::shapeless().
00031 { 00032 ExprEvalInterface & eval = ExprEval::instance(); 00033 00034 string ns = "setup"; // current namespace faking the filename 'setup.xml' 00035 00036 // length of a side of world cube 00037 eval.set(ns,"length","20.*m"); 00038 00039 // center of a corner in the cube 00040 eval.set(ns,"corner","[length]/4."); 00041 00042 // world-solid 00043 DDName worldName("world",ns); 00044 DDName airName("Air",ns); 00045 DDName nitrogenName("Nitrogen","elements"); 00046 DDName oxygenName("Oxygen","elements"); 00047 00048 DDSolidFactory::box(worldName, eval.eval(ns,"[length]/2."), 00049 eval.eval(ns,"[length]/2."), 00050 eval.eval(ns,"[length]/2.")); 00051 00052 DDLogicalPart(worldName, // name 00053 airName, // material 00054 worldName // solid 00055 ); 00056 00057 DDMaterial air(airName,eval.eval(ns,"1.214*mg/cm3")); // mixture for Air 00058 air.addMaterial(DDMaterial(nitrogenName),eval.eval(ns,"0.75")); 00059 air.addMaterial(DDMaterial(oxygenName),eval.eval(ns,"0.25")); 00060 00061 cout << air << endl; 00062 00063 DDMaterial(nitrogenName, // name 00064 eval.eval(ns,"7"), // Z 00065 eval.eval(ns,"14.007*g/mole"), // A 00066 eval.eval(ns,"0.808*g/cm3") ); // density 00067 00068 DDMaterial(oxygenName, // name 00069 eval.eval(ns,"8"), // Z 00070 eval.eval(ns,"15.999*g/mole"), // A 00071 eval.eval(ns,"1.43*g/cm3") ); // density 00072 00073 cout << air << endl; 00074 00075 // Some rotations in the x-y plane (Unit, 30,60,90 degs) 00076 DDRotationMatrix * r0 = new DDRotationMatrix(); 00077 DDRotationMatrix * r30 = new DDRotationMatrix(ROOT::Math::RotationZ(30.*deg)); 00078 DDRotationMatrix * r60 = new DDRotationMatrix(ROOT::Math::RotationZ(60.*deg)); 00079 DDRotationMatrix * r90 = new DDRotationMatrix(ROOT::Math::RotationZ(90.*deg)); 00080 00081 DDrot(DDName("Unit",ns),r0); 00082 DDrot(DDName("R30",ns),r30); 00083 DDrot(DDName("R60",ns),r60); 00084 DDrot(DDName("R90",ns),r90); 00085 00086 DDSolid collectorSolid = DDSolidFactory::shapeless(DDName("group",ns)); 00087 00088 DDRootDef::instance().set(worldName); 00089 }
void testParser | ( | ) |
Definition at line 228 of file build.cc.
References AlgoInit(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), DDLParser::instance(), DDLParser::parse(), and DDLConfiguration::readConfig().
00229 { 00230 try { 00231 cout << "main:: initialize" << endl; 00232 AlgoInit(); 00233 00234 cout << "main::initialize DDL parser" << endl; 00235 DDLParser* myP = DDLParser::instance(); 00236 00237 cout << "main::about to set configuration" << endl; 00238 // myP->SetConfig("configuration.xml"); 00239 DDLConfiguration cf; 00240 cf.readConfig("configuration.xml"); 00241 00242 cout << "main::about to start parsing" << endl; 00243 00244 myP->parse(cf); 00245 00246 cout << "main::completed Parser" << endl; 00247 00248 cout << endl << endl << "main::Start checking!" << endl << endl; 00249 00250 } 00251 catch (DDException& e) 00252 { 00253 cout << "main::PROBLEM:" << endl 00254 << " " << e << endl; 00255 } 00256 }
void testrot | ( | ) |
Definition at line 284 of file build.cc.
References aa, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and printRot().
00285 { 00286 // ExprEvalInterface & eval = ExprEval::instance(); 00287 { 00288 ROOT::Math::AxisAngle aa(DD3Vector(1.,1.,1.), 20.*deg); 00289 DDRotationMatrix rm(aa); 00290 cout << "DD3Vector was " << DD3Vector(1.,1.,1.) << " and the rotation was 20*deg around that axis." << endl; 00291 printRot(rm); 00292 } 00293 { 00294 DDRotationMatrix rm(1,0,0, 0,-1,0, 0,0,1); 00295 cout << "(1,0,0, 0,-1,0, 0,0,1)" << endl; 00296 printRot(rm); 00297 } 00298 }