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(
319 params[3]/deg + params[4]/deg);
323 rSolid=
new TGeoCtub(
329 params[3]/deg + params[4]/deg,
330 params[5],params[6],params[7],
331 params[8],params[9],params[10]);
334 rSolid =
new TGeoTrap(
349 rSolid =
new TGeoPcon(
353 (params.size()-2)/3) ;
355 std::vector<double>
temp(params.size()+1);
356 temp.reserve(params.size()+1);
357 temp[0]=params[0]/deg;
358 temp[1]=params[1]/deg;
359 temp[2]=(params.size()-2)/3;
361 for(std::vector<double>::iterator it=
temp.begin()+3;
366 rSolid->SetDimensions(&(*(
temp.begin())));
370 rSolid =
new TGeoPgon(
374 static_cast<int>(params[0]),
375 (params.size()-3)/3);
377 std::vector<double>
temp(params.size()+1);
378 temp[0]=params[1]/deg;
379 temp[1]=params[2]/deg;
381 temp[3]=(params.size()-3)/3;
382 std::copy(params.begin()+3,params.end(),temp.begin()+4);
383 for(std::vector<double>::iterator it=temp.begin()+4;
388 rSolid->SetDimensions(&(*(temp.begin())));
398 double r = fabs(pt.
radius());
404 double openingAngle = 2.0*asin(x/r);
405 double h=pt.
y1()<pt.
y2()? pt.
y2() :pt.
y1();
407 double displacement=0;
412 startPhi = 270.-openingAngle/deg/2.0;
415 startPhi = 90. - openingAngle/deg/2.;
417 std::auto_ptr<TGeoShape> trap(
new TGeoTrd2(pt.
name().
name().c_str(),
423 std::auto_ptr<TGeoShape> tubs(
new TGeoTubeSeg(pt.
name().
name().c_str(),
429 TGeoSubtraction* sub =
new TGeoSubtraction(trap.release(),
431 createPlacement(s_rot,
435 rSolid =
new TGeoCompositeShape(iName.c_str(),
445 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
452 if( 0 != left.get() &&
454 TGeoSubtraction* sub =
new TGeoSubtraction(left.release(),right.release(),
459 rSolid =
new TGeoCompositeShape(iName.c_str(),
468 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
477 if( 0 != left.get() &&
479 TGeoUnion* boolS =
new TGeoUnion(left.release(),right.release(),
484 rSolid =
new TGeoCompositeShape(iName.c_str(),
493 throw cms::Exception(
"GeomConvert") <<
"conversion to DDBooleanSolid failed";
500 if( 0 != left.get() &&
502 TGeoIntersection* boolS =
new TGeoIntersection(left.release(),
508 rSolid =
new TGeoCompositeShape(iName.c_str(),
520 std::cerr <<
"COULD NOT MAKE "<<iName<<std::endl;
540 geo_med =
new TGeoMedium(mat_name.c_str(), 0, geo_mat);
545 v =
new TGeoVolume(iName.c_str(),
564 TGeoMixture *
mix =
new TGeoMixture(mat_name.c_str(),
576 mat =
new TGeoMaterial(mat_name.c_str(),
577 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
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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.
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.)