30 #include "TGeoManager.h"
31 #include "TGeoMatrix.h"
32 #include "TGeoCompositeShape.h"
36 #include "TGeoBoolNode.h"
41 #include "Math/GenVector/RotationX.h"
43 #include "CLHEP/Units/GlobalSystemOfUnits.h"
58 m_level (pset.getUntrackedParameter<int> (
"level", 10)),
59 m_verbose (pset.getUntrackedParameter<bool>(
"verbose",
false)),
82 printf(
"TGeoFromDddService::postBeginRun\n");
89 printf(
"TGeoFromDddService::postEndRun\n");
107 edm::LogError(
"TGeoFromDddService") <<
"getGeoManager() -- EventSetup not present.\n";
112 edm::LogError(
"TGeoFromDddService") <<
"getGeoManager() -- creation failed.\n";
131 iRot.GetComponents(elements);
133 r.SetMatrix(elements);
135 TGeoTranslation
t(iTrans.x()/cm,
139 return new TGeoCombiTrans(
t,r);
157 if ( ! viewH.isValid() )
162 TGeoManager *geo_mgr =
new TGeoManager(
"cmsGeo",
"CMS Detector");
164 if (gGeoIdentity == 0)
166 gGeoIdentity =
new TGeoIdentity(
"Identity");
169 std::cout <<
"about to initialize the DDCompactView walker" << std::endl;
179 info.first.material());
186 geo_mgr->SetTopVolume(
top);
188 top->SetVisibility(kFALSE);
189 top->SetLineColor(kBlue);
191 std::vector<TGeoVolume*> parentStack;
192 parentStack.push_back(
top);
194 if( ! walker.firstChild() ) {
204 for(
unsigned int i=0;
i<parentStack.size();++
i) {
207 std::cout << info.first.name()<<
" "<<info.second->copyno_<<
" "
211 bool childAlreadyExists = (0 !=
nameToVolume_[info.first.name().fullname()]);
214 info.first.material());
215 if (0!=child && info.second != 0)
217 parentStack.back()->AddNode(child,
218 info.second->copyno_,
219 createPlacement(info.second->rotation(),
220 info.second->translation()));
221 child->SetLineColor(kBlue);
225 if ( info.second == 0 ) {
229 if (0 == child || childAlreadyExists || level ==
int(parentStack.size()))
233 child->SetLineColor(kRed);
236 if ( ! walker.nextSibling())
238 while (walker.parent())
240 parentStack.pop_back();
241 if (walker.nextSibling()) {
249 if (walker.firstChild())
251 parentStack.push_back(child);
255 if ( ! walker.nextSibling())
257 while (walker.parent())
259 parentStack.pop_back();
260 if (walker.nextSibling()) {
267 }
while ( ! parentStack.empty());
269 geo_mgr->CloseGeometry();
271 geo_mgr->DefaultColors();
288 const std::vector<double>& params = iSolid.
parameters();
290 switch(iSolid.
shape())
293 rSolid =
new TGeoBBox(
300 rSolid =
new TGeoConeSeg(
308 params[6]/deg+params[5]/deg
313 rSolid=
new TGeoTubeSeg(
322 rSolid =
new TGeoTrap(
337 rSolid =
new TGeoPcon(
341 (params.size()-2)/3) ;
343 std::vector<double>
temp(params.size()+1);
344 temp.reserve(params.size()+1);
345 temp[0]=params[0]/deg;
346 temp[1]=params[1]/deg;
347 temp[2]=(params.size()-2)/3;
349 for(std::vector<double>::iterator it=
temp.begin()+3;
354 rSolid->SetDimensions(&(*(
temp.begin())));
358 rSolid =
new TGeoPgon(
362 static_cast<int>(params[0]),
363 (params.size()-3)/3);
365 std::vector<double>
temp(params.size()+1);
366 temp[0]=params[1]/deg;
367 temp[1]=params[2]/deg;
369 temp[3]=(params.size()-3)/3;
370 std::copy(params.begin()+3,params.end(),temp.begin()+4);
371 for(std::vector<double>::iterator it=temp.begin()+4;
376 rSolid->SetDimensions(&(*(temp.begin())));
386 double r = fabs(pt.
radius());
392 double openingAngle = 2.0*asin(x/r);
393 double h=pt.
y1()<pt.
y2()? pt.
y2() :pt.
y1();
395 double displacement=0;
400 startPhi = 270.-openingAngle/deg/2.0;
403 startPhi = 90. - openingAngle/deg/2.;
405 std::auto_ptr<TGeoShape> trap(
new TGeoTrd2(pt.
name().
name().c_str(),
411 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg(pt.
name().
name().c_str(),
417 TGeoSubtraction* sub =
new TGeoSubtraction(trap.release(),
419 createPlacement(s_rot,
423 rSolid =
new TGeoCompositeShape(iName.c_str(),
433 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
440 if( 0 != left.get() &&
442 TGeoSubtraction* sub =
new TGeoSubtraction(left.release(),right.release(),
447 rSolid =
new TGeoCompositeShape(iName.c_str(),
456 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
465 if( 0 != left.get() &&
467 TGeoUnion* boolS =
new TGeoUnion(left.release(),right.release(),
472 rSolid =
new TGeoCompositeShape(iName.c_str(),
481 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
488 if( 0 != left.get() &&
490 TGeoIntersection* boolS =
new TGeoIntersection(left.release(),
496 rSolid =
new TGeoCompositeShape(iName.c_str(),
508 std::cerr <<
"COULD NOT MAKE "<<iName<<std::endl;
528 geo_med =
new TGeoMedium(mat_name.c_str(), 0, geo_mat);
533 v =
new TGeoVolume(iName.c_str(),
552 TGeoMixture *
mix =
new TGeoMixture(mat_name.c_str(),
564 mat =
new TGeoMaterial(mat_name.c_str(),
565 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.
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)
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
double z() const
retruns the atomic number
static const char *const name(DDSolidShape s)
DDRotation rotation(void) const
graph< DDLogicalPart, DDPosData * >::value_type value_type
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.
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::map< std::string, TGeoMedium * > nameToMedium_
void postBeginRun(const edm::Run &, const edm::EventSetup &)
DDSolid solidA(void) const
TGeoFromDddService(const edm::ParameterSet &, edm::ActivityRegistry &)
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)
volatile std::atomic< bool > shutdown_flag false
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.
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.)