48 #include "TGeoManager.h"
50 #include "TGeoMatrix.h"
57 #include "TEveVector.h"
58 #include "TEveTrans.h"
63 typedef std::map< const float*, TGeoVolume*> CaloVolMap;
77 void AddLeafNode(TGeoVolume* mother, TGeoVolume* daughter,
const char*
name, TGeoMatrix* mtx )
79 int n = mother->GetNdaughters();
80 mother->AddNode(daughter, 1, mtx);
81 mother->GetNode(n)->SetName(name);
85 TGeoCombiTrans* createPlacement(
const GeomDet *det )
92 TGeoTranslation
trans( posx, posy, posz );
99 const Double_t
matrix[9] = { detRot.
xx(), detRot.
yx(), detRot.
zx(),
100 detRot.
xy(), detRot.
yy(), detRot.
zy(),
101 detRot.
xz(), detRot.
yz(), detRot.
zz()
103 rotation.SetMatrix( matrix );
105 return new TGeoCombiTrans(
trans, rotation );
116 if (mother->GetNdaughters()) {
117 TGeoNode* n = mother->FindNode(Form(
"%s_%d_1", prefix,
id));
118 if ( n ) res = n->GetVolume();
122 res =
new TGeoVolumeAssembly( Form(
"%s_%d", prefix,
id ));
124 mother->AddNode(res, 1);
133 if (mother->GetNdaughters()) {
134 TGeoNode* n = mother->FindNode(Form(
"%s_1",prefix));
135 if ( n ) res = n->GetVolume();
140 res =
new TGeoVolumeAssembly(prefix);
142 mother->AddNode(res, 1);
158 Blue0 = 13, Blue1 = 24, Blue2 = 6,
159 Yellow0 = 3, Yellow1 = 16,
161 Red = 29, Orange0 = 79, Orange1 = 14,
172 std::map<ERecoDet, TGeoMedium*>::iterator it =
m_recoMedium.find(det);
185 color = GMCol::Green;
195 color = GMCol::Blue2;
205 color = GMCol::Yellow1;
215 color = GMCol::Yellow0;
221 color = GMCol::Blue2;
225 color = GMCol::Orange1;
229 color = GMCol::Blue2;
233 color = GMCol::Blue1;
236 printf(
"invalid medium id \n");
240 TGeoMaterial* mat =
new TGeoMaterial(name.c_str(), 0, 0, 0);
242 m_recoMedium[det] =
new TGeoMedium(name.c_str(), 0, mat);
243 mat->SetFillStyle(3000);
254 boost::shared_ptr<FWTGeoRecoGeometry>
267 TGeoManager*
geom =
new TGeoManager(
"cmsGeo",
"CMS Detector" );
268 if( 0 == gGeoIdentity )
270 gGeoIdentity =
new TGeoIdentity(
"Identity" );
276 TGeoMaterial *vacuum =
new TGeoMaterial(
"Vacuum", 0 ,0 ,0 );
285 return boost::shared_ptr<FWTGeoRecoGeometry>();
287 geom->SetTopVolume( top );
289 top->SetVisibility( kFALSE );
290 top->SetLineColor( kBlue );
310 geom->CloseGeometry();
312 geom->DefaultColors();
314 geom->CloseGeometry();
323 TGeoShape* shape = 0;
330 std::array< const float, 4 >
const & par = b2->
parameters ();
333 float hBottomEdge = par [0];
334 float hTopEdge = par [1];
335 float thickness = par [2];
336 float apothem = par [3];
340 << hBottomEdge <<
"_"
351 shape =
new TGeoTrap(
368 if( dynamic_cast<const RectangularPlaneBounds *> (b) != 0 )
387 shape =
new TGeoBBox( name.c_str(), width / 2., length / 2., thickness / 2. );
402 std::map<TGeoShape*, TGeoVolume*>::iterator vIt =
m_shapeToVolume.find(solid);
406 TGeoVolume* volume =
new TGeoVolume( name.c_str(),solid,
GetMedium(mid));
436 unsigned int rawid = detid.
rawId();
445 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
477 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
506 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
532 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
557 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
585 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
608 for(
auto it = dtChamberGeom.begin(),
609 end = dtChamberGeom.end();
612 if(
auto chamber = dynamic_cast< const DTChamber *>(*it))
624 AddLeafNode(holder, child, name.c_str(), createPlacement( chamber));
633 for(
auto it = dtSuperLayerGeom.begin(),
634 end = dtSuperLayerGeom.end();
637 if(
auto * superlayer = dynamic_cast<const DTSuperLayer*>(*it))
650 AddLeafNode(holder, child, name.c_str(), createPlacement( superlayer));
658 for(
auto it = dtLayerGeom.begin(),
659 end = dtLayerGeom.end();
662 if(
auto layer = dynamic_cast<const DTLayer*>(*it))
678 AddLeafNode(holder, child, name.c_str(), createPlacement( layer));
689 throw cms::Exception(
"FatalError" ) <<
"Cannnot find CSCGeometry\n";
696 for(
auto it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it )
698 unsigned int rawid = (*it)->geographicalId();
704 TGeoVolume*
child = 0;
706 if(
auto chamber = dynamic_cast<const CSCChamber*>(*it))
708 else if(
auto * layer = dynamic_cast<const CSCLayer*>(*it))
720 AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
758 AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
762 edm::LogInfo(
"FWRecoGeometry") <<
"failed to produce GEM geometry " << exception.
what() << std::endl;
778 for(
auto it = rpcGeom->
rolls().begin(),
799 AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
859 CaloVolMap caloShapeMapP;
860 CaloVolMap caloShapeMapN;
861 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
869 if (!cell) { printf (
"HB not olique !!!\n");
continue; }
871 TGeoVolume* volume = 0;
872 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
873 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
874 if (volIt == caloShapeMap.end())
880 HepGeom::Vector3D<float> lCenter;
881 for(
int c = 0;
c < 8; ++
c)
885 static const int arr[] = { 1, 0, 3, 2, 5, 4, 7, 6 };
887 for (
int c = 0;
c < 8; ++
c) {
889 points[
c*2 + 0 ] = -(lc[arr[
c]].
z() - lCenter.z());
891 points[
c*2 + 0 ] = (lc[arr[
c]].z() - lCenter.z());
893 points[
c*2 + 1 ] = (lc[arr[
c]].y() - lCenter.y());
897 float dz = (lc[4].x() -lc[0].x()) * 0.5;
898 TGeoShape* solid =
new TGeoArb8(dz, &points[0]);
899 volume =
new TGeoVolume(
"hcal oblique prism", solid,
GetMedium(
kHCal));
900 caloShapeMap[cell->
param()] = volume;
904 volume = volIt->second;
908 HepGeom::Vector3D<float> gCenter;
910 for (
int c = 0;
c < 8; ++
c)
911 gCenter += HepGeom::Vector3D<float>(gc[
c].
x(), gc[
c].
y(), gc[
c].
z());
914 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
919 rotPhi.SetAngles(0, -cell->
phiPos()*TMath::RadToDeg(), 0);
920 rot.MultiplyBy(&rotPhi);
924 std::stringstream nname;
926 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr, rot));
939 CaloVolMap caloShapeMapP;
940 CaloVolMap caloShapeMapN;
947 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
952 if (!cell) { printf (
"EC not olique \n");
continue; }
954 TGeoVolume* volume = 0;
955 CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
956 CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
957 if ( volIt == caloShapeMap.end())
962 HepGeom::Vector3D<float> lCenter;
963 for(
int c = 0;
c < 8; ++
c)
971 static const int arrP[] = { 3, 2, 1, 0, 7, 6, 5, 4 };
972 static const int arrN[] = { 7, 6, 5, 4 ,3, 2, 1, 0};
973 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
976 for (
int c = 0;
c < 8; ++
c) {
977 points[
c*2 + 0 ] = lc[arr[
c]].x() - lCenter.x();
978 points[
c*2 + 1 ] = lc[arr[
c]].y() - lCenter.y();
981 float dz = (lc[4].z() -lc[0].z()) * 0.5;
982 TGeoShape* solid =
new TGeoArb8(dz, &points[0]);
983 volume =
new TGeoVolume(
"ecal oblique prism", solid,
GetMedium(
kHCal));
984 caloShapeMap[cell->param()] = volume;
988 volume = volIt->second;
992 HepGeom::Vector3D<float> gCenter;
994 for (
int c = 0;
c < 8; ++
c) {
995 gCenter += HepGeom::Vector3D<float>(gc[
c].x(), gc[
c].y(), gc[
c].z());
1000 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1002 rot.SetAngles(cell->phiPos()*TMath::RadToDeg(), 0, 0);
1006 std::stringstream nname;
1008 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr, rot));
1021 for (
int i = 0;
i < 8; ++
i)
1022 gCenter += TEveVector(gc[
i].
x(), gc[
i].
y(), gc[
i].
z());
1025 TEveVector tgCenter;
1026 for (
int i = 4;
i < 8; ++
i)
1027 tgCenter += TEveVector(gc[
i].
x(), gc[
i].
y(), gc[
i].
z());
1031 TEveVector axis = tgCenter - gCenter;
1036 tr.GetBaseVec(1, v1t);
1039 TEveVector v1(v1t.x(), v1t.y(), v1t.z());
1040 double dot13 = axis.Dot(v1);
1041 TEveVector gd = axis;
1046 TMath::Cross(v1.Arr(), axis.Arr(), v2.Arr());
1047 TMath::Cross(axis.Arr(), v1.Arr(), v2.Arr());
1050 tr.SetBaseVec(1, v1.fX, v1.fY, v1.fZ);
1051 tr.SetBaseVec(2, v2.fX, v2.fY, v2.fZ);
1052 tr.SetBaseVec(3, axis.fX, axis.fY, axis.fZ);
1053 tr.Move3PF(gCenter.fX, gCenter.fY, gCenter.fZ);
1055 TGeoHMatrix*
out =
new TGeoHMatrix();
1056 tr.SetGeoHMatrix(*out);
1064 const HepGeom::Transform3D idtr;
1072 for(
int c = 0;
c < 8; ++
c )
1074 points[
c*2 ] = co[
c].x();
1075 points[
c*2+1] = co[
c].y();
1077 TGeoShape* solid =
new TGeoArb8(cell->
param()[0], points);
1090 CaloVolMap caloShapeMap;
1096 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
1100 if (!cell) { printf(
"ecalBarrel cell not a TruncatedPyramid !!\n");
return; }
1102 TGeoVolume* volume = 0;
1103 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1104 if ( volIt == caloShapeMap.end())
1107 caloShapeMap[cell->
param()] = volume;
1110 volume = volIt->second;
1115 std::stringstream nname;
1117 AddLeafNode(holder, volume, nname.str().c_str(), mtx);
1126 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
1130 if (!cell) { printf(
"ecalEndcap cell not a TruncatedPyramid !!\n");
continue;}
1132 TGeoVolume* volume = 0;
1133 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1134 if ( volIt == caloShapeMap.end())
1138 caloShapeMap[cell->
param()] = volume;
1141 volume = volIt->second;
1146 std::stringstream nname;
1148 AddLeafNode(holder, volume, nname.str().c_str(), mtx);
virtual char const * what() const
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
TGeoMedium * m_dummyMedium
const TrackerGeometry * m_trackerGeom
virtual float length() const =0
virtual const std::array< const float, 4 > parameters() const
edm::ESHandle< CaloGeometry > m_caloGeom
edm::ESHandle< GlobalTrackingGeometry > m_geomRecord
int zside() const
get the z-side of the cell (1/-1)
TGeoShape * createShape(const GeomDet *det)
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
virtual ~FWTGeoRecoGeometryESProducer(void)
CaloCellGeometry::Pt3D Pt3D
const Bounds & bounds() const
std::map< TGeoShape *, TGeoVolume * > m_shapeToVolume
const Plane & surface() const
The nominal surface of the GeomDet.
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
unsigned int layer() const
layer id
uint32_t rawId() const
get the raw id
virtual float thickness() const =0
const DepRecordT & getRecord() const
TGeoMedium * GetMedium(ERecoDet)
const CCGFloat * param() const
CaloCellGeometry::Pt3D Pt3D
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
const DetContainer & detsTEC() const
TGeoHMatrix * getEcalTrans(CaloCellGeometry::CornersVec const &gc)
void addEcalCaloGeometry()
std::map< std::string, TGeoShape * > m_nameToShape
CaloCellGeometry::Pt3DVec Pt3DVec
int ieta() const
get the cell ieta
const DetContainer & detsPXB() const
unsigned int module() const
det id
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
DetId geographicalId() const
The label of this GeomDet.
void addHcalCaloGeometryBarrel()
int ieta() const
get the crystal ieta
std::map< ERecoDet, TGeoMedium * > m_recoMedium
const DetContainer & detsTIB() const
TGeoShape * makeEcalShape(const TruncatedPyramid *cell)
TGeoVolume * GetDaughter(TGeoVolume *mother, const char *prefix, ERecoDet cidx, int id)
boost::shared_ptr< FWTGeoRecoGeometry > produce(const FWTGeoRecoGeometryRecord &)
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
boost::shared_ptr< FWTGeoRecoGeometry > m_fwGeometry
void addPixelForwardGeometry()
FWTGeoRecoGeometryESProducer(const edm::ParameterSet &)
const DetContainer & detsPXF() const
const DetContainer & detsTOB() const
const RotationType & rotation() const
TGeoVolume * GetTopHolder(const char *prefix, ERecoDet cidx)
const CornersVec & getCorners() const
Returns the corner points of this cell's volume.
virtual float width() const =0
const PositionType & position() const
void addHcalCaloGeometryEndcap()
void addPixelBarrelGeometry()
CaloCellGeometry::Pt3DVec Pt3DVec
TGeoVolume * createVolume(const std::string &name, const GeomDet *det, ERecoDet=kDummy)
const DetContainer & detsTID() const
int zside() const
get the z-side of the crystal (1/-1)