31 #include "TGeoManager.h"
32 #include "TGeoMatrix.h"
33 #include "TGeoCompositeShape.h"
37 #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);
158 if ( ! viewH.isValid() )
163 TGeoManager *geo_mgr =
new TGeoManager(
"cmsGeo",
"CMS Detector");
165 if (gGeoIdentity == 0)
167 gGeoIdentity =
new TGeoIdentity(
"Identity");
170 std::cout <<
"about to initialize the DDCompactView walker" << std::endl;
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 = (0 !=
nameToVolume_[info.first.name().fullname()]);
215 info.first.material());
216 if (0!=child && info.second != 0)
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 == 0 ) {
230 if (0 == 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();
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(
323 rSolid =
new TGeoTrap(
338 rSolid =
new TGeoPcon(
342 (params.size()-2)/3) ;
344 std::vector<double>
temp(params.size()+1);
345 temp.reserve(params.size()+1);
346 temp[0]=params[0]/deg;
347 temp[1]=params[1]/deg;
348 temp[2]=(params.size()-2)/3;
350 for(std::vector<double>::iterator it=
temp.begin()+3;
355 rSolid->SetDimensions(&(*(
temp.begin())));
359 rSolid =
new TGeoPgon(
363 static_cast<int>(params[0]),
364 (params.size()-3)/3);
366 std::vector<double>
temp(params.size()+1);
367 temp[0]=params[1]/deg;
368 temp[1]=params[2]/deg;
370 temp[3]=(params.size()-3)/3;
371 std::copy(params.begin()+3,params.end(),temp.begin()+4);
372 for(std::vector<double>::iterator it=temp.begin()+4;
377 rSolid->SetDimensions(&(*(temp.begin())));
387 double r = fabs(pt.
radius());
393 double openingAngle = 2.0*asin(x/r);
394 double h=pt.
y1()<pt.
y2()? pt.
y2() :pt.
y1();
396 double displacement=0;
401 startPhi = 270.-openingAngle/deg/2.0;
404 startPhi = 90. - openingAngle/deg/2.;
406 std::auto_ptr<TGeoShape> trap(
new TGeoTrd2(pt.
name().
name().c_str(),
412 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg(pt.
name().
name().c_str(),
418 TGeoSubtraction* sub =
new TGeoSubtraction(trap.release(),
420 createPlacement(s_rot,
424 rSolid =
new TGeoCompositeShape(iName.c_str(),
434 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
441 if( 0 != left.get() &&
443 TGeoSubtraction* sub =
new TGeoSubtraction(left.release(),right.release(),
448 rSolid =
new TGeoCompositeShape(iName.c_str(),
457 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
466 if( 0 != left.get() &&
468 TGeoUnion* boolS =
new TGeoUnion(left.release(),right.release(),
473 rSolid =
new TGeoCompositeShape(iName.c_str(),
482 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
489 if( 0 != left.get() &&
491 TGeoIntersection* boolS =
new TGeoIntersection(left.release(),
497 rSolid =
new TGeoCompositeShape(iName.c_str(),
509 std::cerr <<
"COULD NOT MAKE "<<iName<<std::endl;
529 geo_med =
new TGeoMedium(mat_name.c_str(), 0, geo_mat);
534 v =
new TGeoVolume(iName.c_str(),
553 TGeoMixture *
mix =
new TGeoMixture(mat_name.c_str(),
565 mat =
new TGeoMaterial(mat_name.c_str(),
566 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
DDRotation rotation(void) const
graph< DDLogicalPart, DDPosData * >::value_type value_type
static const char * name(DDSolidShape s)
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 &)
double density() const
returns the density
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
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.
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.)