30 #include "TGeoManager.h" 31 #include "TGeoMatrix.h" 32 #include "TGeoCompositeShape.h" 36 #include "TGeoBoolNode.h" 42 #include "Math/GenVector/RotationX.h" 44 #include "CLHEP/Units/GlobalSystemOfUnits.h" 59 m_level (pset.getUntrackedParameter<
int> (
"level", 10)),
60 m_verbose (pset.getUntrackedParameter<
bool>(
"verbose",
false)),
83 printf(
"TGeoFromDddService::postBeginRun\n");
90 printf(
"TGeoFromDddService::postEndRun\n");
108 edm::LogError(
"TGeoFromDddService") <<
"getGeoManager() -- EventSetup not present.\n";
113 edm::LogError(
"TGeoFromDddService") <<
"getGeoManager() -- creation failed.\n";
132 iRot.GetComponents(elements);
134 r.SetMatrix(elements);
136 TGeoTranslation
t(iTrans.x()/cm,
140 return new TGeoCombiTrans(
t,r);
163 TGeoManager *geo_mgr =
new TGeoManager(
"cmsGeo",
"CMS Detector");
165 if (gGeoIdentity ==
nullptr)
167 gGeoIdentity =
new TGeoIdentity(
"Identity");
170 std::cout <<
"about to initialize the DDCompactView walker" << std::endl;
178 TGeoVolume *top =
createVolume(info.first.name().fullname(),
180 info.first.material());
187 geo_mgr->SetTopVolume(top);
189 top->SetVisibility(kFALSE);
190 top->SetLineColor(kBlue);
192 std::vector<TGeoVolume*> parentStack;
193 parentStack.push_back(top);
195 if( ! walker.firstChild() ) {
205 for(
unsigned int i=0;
i<parentStack.size();++
i) {
208 std::cout << info.first.name()<<
" "<<info.second->copyno()<<
" " 212 bool childAlreadyExists = (
nullptr !=
nameToVolume_[info.first.name().fullname()]);
215 info.first.material());
216 if (
nullptr!=child && info.second !=
nullptr)
218 parentStack.back()->AddNode(child,
219 info.second->copyno(),
220 createPlacement(info.second->rotation(),
221 info.second->translation()));
222 child->SetLineColor(kBlue);
226 if ( info.second ==
nullptr ) {
230 if (
nullptr == child || childAlreadyExists || level ==
int(parentStack.size()))
234 child->SetLineColor(kRed);
237 if ( ! walker.nextSibling())
239 while (walker.parent())
241 parentStack.pop_back();
242 if (walker.nextSibling()) {
250 if (walker.firstChild())
252 parentStack.push_back(child);
256 if ( ! walker.nextSibling())
258 while (walker.parent())
260 parentStack.pop_back();
261 if (walker.nextSibling()) {
268 }
while ( ! parentStack.empty());
270 geo_mgr->CloseGeometry();
272 geo_mgr->DefaultColors();
287 if (rSolid ==
nullptr)
289 const std::vector<double>& params = iSolid.
parameters();
291 switch(iSolid.
shape())
294 rSolid =
new TGeoBBox(
301 rSolid =
new TGeoConeSeg(
309 params[6]/deg+params[5]/deg
314 rSolid=
new TGeoTubeSeg(
320 params[3]/deg + params[4]/deg);
324 rSolid=
new TGeoCtub(
330 params[3]/deg + params[4]/deg,
331 params[5],params[6],params[7],
332 params[8],params[9],params[10]);
335 rSolid =
new TGeoTrap(
350 rSolid =
new TGeoPcon(
354 (params.size()-2)/3) ;
356 std::vector<double>
temp(params.size()+1);
357 temp.reserve(params.size()+1);
358 temp[0]=params[0]/deg;
359 temp[1]=params[1]/deg;
360 temp[2]=(params.size()-2)/3;
362 for(std::vector<double>::iterator it=
temp.begin()+3;
367 rSolid->SetDimensions(&(*(
temp.begin())));
371 rSolid =
new TGeoPgon(
375 static_cast<int>(params[0]),
376 (params.size()-3)/3);
378 std::vector<double>
temp(params.size()+1);
379 temp[0]=params[1]/deg;
380 temp[1]=params[2]/deg;
382 temp[3]=(params.size()-3)/3;
383 std::copy(params.begin()+3,params.end(),temp.begin()+4);
384 for(std::vector<double>::iterator it=temp.begin()+4;
389 rSolid->SetDimensions(&(*(temp.begin())));
395 std::vector<double>
x = extrPgon.
xVec();
396 std::transform(x.begin(), x.end(), x.begin(),[](
double d) {
return d/cm; });
397 std::vector<double>
y = extrPgon.
yVec();
398 std::transform(y.begin(), y.end(), y.begin(),[](
double d) {
return d/cm; });
399 std::vector<double>
z = extrPgon.
zVec();
400 std::vector<double> zx = extrPgon.
zxVec();
401 std::vector<double> zy = extrPgon.
zyVec();
402 std::vector<double> zscale = extrPgon.
zscaleVec();
404 TGeoXtru* mySolid =
new TGeoXtru(z.size());
405 mySolid->DefinePolygon(x.size(), &(*x.begin()), &(*y.begin()));
406 for(
size_t i = 0;
i < params[0]; ++
i )
408 mySolid->DefineSection(
i, z[
i]/cm, zx[
i]/cm, zy[
i]/cm, zscale[
i]);
427 double openingAngle = 2.0*asin(x/r);
428 double h=pt.
y1()<pt.
y2()? pt.
y2() :pt.
y1();
430 double displacement=0;
435 startPhi = 270.-openingAngle/deg/2.0;
438 startPhi = 90. - openingAngle/deg/2.;
440 std::auto_ptr<TGeoShape> trap(
new TGeoTrd2(pt.
name().
name().c_str(),
446 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg(pt.
name().
name().c_str(),
452 TGeoSubtraction* sub =
new TGeoSubtraction(trap.release(),
454 createPlacement(s_rot,
458 rSolid =
new TGeoCompositeShape(iName.c_str(),
468 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
475 if(
nullptr != left.get() &&
476 nullptr != right.get() ) {
477 TGeoSubtraction* sub =
new TGeoSubtraction(left.release(),right.release(),
482 rSolid =
new TGeoCompositeShape(iName.c_str(),
491 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
500 if(
nullptr != left.get() &&
501 nullptr != right.get() ) {
502 TGeoUnion* boolS =
new TGeoUnion(left.release(),right.release(),
507 rSolid =
new TGeoCompositeShape(iName.c_str(),
516 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
523 if(
nullptr != left.get() &&
524 nullptr != right.get() ) {
525 TGeoIntersection* boolS =
new TGeoIntersection(left.release(),
531 rSolid =
new TGeoCompositeShape(iName.c_str(),
541 if (rSolid ==
nullptr)
543 std::cerr <<
"COULD NOT MAKE "<<iName<<std::endl;
560 if (geo_med ==
nullptr)
563 geo_med =
new TGeoMedium(mat_name.c_str(), 0, geo_mat);
568 v =
new TGeoVolume(iName.c_str(),
587 TGeoMixture *
mix =
new TGeoMixture(mat_name.c_str(),
599 mat =
new TGeoMaterial(mat_name.c_str(),
600 iMaterial.
a()*mole/
g, iMaterial.
z(),
void watchPostBeginRun(PostBeginRun::slot_type const &iSlot)
std::map< std::string, TGeoMaterial * > nameToMaterial_
double a() const
returns the atomic mass
TGeoManager * m_geoManager
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
typename math::Graph< DDLogicalPart, DDPosData * >::value_type value_type
double y2(void) const
half length along y on +z
const edm::EventSetup * m_eventSetup
DDMaterial is used to define and access material information.
TGeoVolume * createVolume(const std::string &iName, const DDSolid &iSolid, const DDMaterial &iMaterial)
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
std::vector< double > yVec(void) const
std::vector< double > zyVec(void) const
DDTranslation translation(void) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
A DDSolid represents the shape of a part.
double y1(void) const
half length along y on -z
std::map< std::string, TGeoVolume * > nameToVolume_
DDSolid solidB(void) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
std::vector< double > xVec(void) const
double z() const
retruns the atomic number
static const char *const name(DDSolidShape s)
DDRotation rotation(void) const
bool atMinusZ(void) const
true, if cut-out or rounding is on the -z side
double halfZ(void) const
half of the z-Axis
const std::string fullname() const
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
DDSolidShape shape(void) const
The type of the solid.
std::map< std::string, TGeoMedium * > nameToMedium_
void postBeginRun(const edm::Run &, const edm::EventSetup &)
DDSolid solidA(void) const
TGeoFromDddService(const edm::ParameterSet &, edm::ActivityRegistry &)
std::vector< double > zVec(void) const
std::vector< double > zxVec(void) const
double density() const
returns the density
virtual ~TGeoFromDddService()
TGeoMaterial * createMaterial(const DDMaterial &iMaterial)
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
TGeoManager * createManager(int level)
std::map< std::string, TGeoShape * > nameToShape_
void watchPostEndRun(PostEndRun::slot_type const &iSlot)
DDRotationMatrix * matrix()
double x2(void) const
half length along x on +z
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
std::vector< double > zscaleVec(void) const
const std::string & name() const
Returns the name.
TGeoManager * getGeoManager()
void postEndRun(const edm::Run &, const edm::EventSetup &)
TGeoShape * createShape(const std::string &iName, const DDSolid &iSolid)
double x1(void) const
half length along x on -z
double radius(void) const
radius of the cut-out (neg.) or rounding (pos.)