49 #include "TGeoManager.h"
51 #include "TGeoMatrix.h"
58 #include "TEveVector.h"
59 #include "TEveTrans.h"
64 typedef std::map< const float*, TGeoVolume*> CaloVolMap;
78 void AddLeafNode(TGeoVolume* mother, TGeoVolume* daughter,
const char*
name, TGeoMatrix* mtx )
80 int n = mother->GetNdaughters();
81 mother->AddNode(daughter, 1, mtx);
82 mother->GetNode(n)->SetName(name);
86 TGeoCombiTrans* createPlacement(
const GeomDet *det )
93 TGeoTranslation trans( posx, posy, posz );
100 const Double_t
matrix[9] = { detRot.
xx(), detRot.
yx(), detRot.
zx(),
101 detRot.
xy(), detRot.
yy(), detRot.
zy(),
102 detRot.
xz(), detRot.
yz(), detRot.
zz()
104 rotation.SetMatrix( matrix );
106 return new TGeoCombiTrans( trans, rotation );
117 if (mother->GetNdaughters()) {
118 TGeoNode* n = mother->FindNode(Form(
"%s_%d_1", prefix,
id));
119 if ( n ) res = n->GetVolume();
123 res =
new TGeoVolumeAssembly( Form(
"%s_%d", prefix,
id ));
125 mother->AddNode(res, 1);
134 if (mother->GetNdaughters()) {
135 TGeoNode* n = mother->FindNode(Form(
"%s_1",prefix));
136 if ( n ) res = n->GetVolume();
141 res =
new TGeoVolumeAssembly(prefix);
143 mother->AddNode(res, 1);
152 TGeoVolume* res =
GetDaughter(gGeoManager->GetTopVolume(), prefix, cidx);
159 Blue0 = 13, Blue1 = 24, Blue2 = 6,
160 Yellow0 = 3, Yellow1 = 16,
162 Red = 29, Orange0 = 79, Orange1 = 14,
173 std::map<ERecoDet, TGeoMedium*>::iterator it =
m_recoMedium.find(det);
186 color = GMCol::Green;
196 color = GMCol::Blue2;
206 color = GMCol::Yellow1;
216 color = GMCol::Yellow0;
222 color = GMCol::Blue2;
226 color = GMCol::Orange1;
230 color = GMCol::Blue2;
234 color = GMCol::Blue1;
237 printf(
"invalid medium id \n");
241 TGeoMaterial* mat =
new TGeoMaterial(name.c_str(), 0, 0, 0);
243 m_recoMedium[det] =
new TGeoMedium(name.c_str(), 0, mat);
244 mat->SetFillStyle(3000);
255 boost::shared_ptr<FWTGeoRecoGeometry>
268 TGeoManager*
geom =
new TGeoManager(
"cmsGeo",
"CMS Detector" );
269 if( 0 == gGeoIdentity )
271 gGeoIdentity =
new TGeoIdentity(
"Identity" );
277 TGeoMaterial *vacuum =
new TGeoMaterial(
"Vacuum", 0 ,0 ,0 );
286 return boost::shared_ptr<FWTGeoRecoGeometry>();
288 geom->SetTopVolume( top );
290 top->SetVisibility( kFALSE );
291 top->SetLineColor( kBlue );
311 geom->CloseGeometry();
313 geom->DefaultColors();
315 geom->CloseGeometry();
324 TGeoShape* shape = 0;
331 std::array< const float, 4 >
const & par = b2->
parameters ();
334 float hBottomEdge = par [0];
335 float hTopEdge = par [1];
336 float thickness = par [2];
337 float apothem = par [3];
341 << hBottomEdge <<
"_"
352 shape =
new TGeoTrap(
369 if( dynamic_cast<const RectangularPlaneBounds *> (b) != 0 )
388 shape =
new TGeoBBox( name.c_str(), width / 2., length / 2., thickness / 2. );
403 std::map<TGeoShape*, TGeoVolume*>::iterator vIt =
m_shapeToVolume.find(solid);
407 TGeoVolume* volume =
new TGeoVolume( name.c_str(),solid,
GetMedium(mid));
436 DetId detid = ( *it )->geographicalId();
437 unsigned int rawid = detid.
rawId();
446 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
464 PXFDetId detid = ( *it )->geographicalId();
478 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
497 TIBDetId detid(( *it )->geographicalId());
507 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
524 TIDDetId detid = ( *it )->geographicalId();
533 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
549 TOBDetId detid(( *it )->geographicalId());
558 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
575 TECDetId detid = ( *it )->geographicalId();
586 AddLeafNode(holder, child, name.c_str(), createPlacement( *it ));
609 for(
auto it = dtChamberGeom.begin(),
610 end = dtChamberGeom.end();
613 if(
auto chamber = dynamic_cast< const DTChamber *>(*it))
625 AddLeafNode(holder, child, name.c_str(), createPlacement( chamber));
634 for(
auto it = dtSuperLayerGeom.begin(),
635 end = dtSuperLayerGeom.end();
638 if(
auto * superlayer = dynamic_cast<const DTSuperLayer*>(*it))
651 AddLeafNode(holder, child, name.c_str(), createPlacement( superlayer));
659 for(
auto it = dtLayerGeom.begin(),
660 end = dtLayerGeom.end();
663 if(
auto layer = dynamic_cast<const DTLayer*>(*it))
679 AddLeafNode(holder, child, name.c_str(), createPlacement( layer));
690 throw cms::Exception(
"FatalError" ) <<
"Cannnot find CSCGeometry\n";
697 for(
auto it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it )
699 unsigned int rawid = (*it)->geographicalId();
705 TGeoVolume*
child = 0;
707 if(
auto chamber = dynamic_cast<const CSCChamber*>(*it))
709 else if(
auto * layer = dynamic_cast<const CSCLayer*>(*it))
721 AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
759 AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
763 edm::LogInfo(
"FWRecoGeometry") <<
"failed to produce GEM geometry " << exception.
what() << std::endl;
779 for(
auto it = rpcGeom->
rolls().begin(),
800 AddLeafNode(holder, child, name.c_str(), createPlacement(*it));
820 unsigned int rawid = roll->geographicalId().rawId();
832 AddLeafNode(holder, child, name.c_str(), createPlacement(roll));
840 edm::LogInfo(
"FWRecoGeometry") <<
"failed to produce ME0 geometry " << exception.
what() << std::endl;
858 CaloVolMap caloShapeMapP;
859 CaloVolMap caloShapeMapN;
860 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
868 if (!cell) { printf (
"HB not olique !!!\n");
continue; }
870 TGeoVolume* volume = 0;
871 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
872 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
873 if (volIt == caloShapeMap.end())
879 HepGeom::Vector3D<float> lCenter;
880 for(
int c = 0;
c < 8; ++
c)
884 static const int arr[] = { 1, 0, 3, 2, 5, 4, 7, 6 };
886 for (
int c = 0;
c < 8; ++
c) {
888 points[
c*2 + 0 ] = -(lc[arr[
c]].
z() - lCenter.z());
890 points[
c*2 + 0 ] = (lc[arr[
c]].z() - lCenter.z());
892 points[
c*2 + 1 ] = (lc[arr[
c]].y() - lCenter.y());
896 float dz = (lc[4].x() -lc[0].x()) * 0.5;
897 TGeoShape* solid =
new TGeoArb8(dz, &points[0]);
898 volume =
new TGeoVolume(
"hcal oblique prism", solid,
GetMedium(
kHCal));
899 caloShapeMap[cell->
param()] = volume;
903 volume = volIt->second;
907 HepGeom::Vector3D<float> gCenter;
909 for (
int c = 0;
c < 8; ++
c)
910 gCenter += HepGeom::Vector3D<float>(gc[
c].
x(), gc[
c].
y(), gc[
c].
z());
913 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
918 rotPhi.SetAngles(0, -cell->
phiPos()*TMath::RadToDeg(), 0);
919 rot.MultiplyBy(&rotPhi);
923 std::stringstream nname;
925 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr, rot));
938 CaloVolMap caloShapeMapP;
939 CaloVolMap caloShapeMapN;
946 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
951 if (!cell) { printf (
"EC not olique \n");
continue; }
953 TGeoVolume* volume = 0;
954 CaloVolMap& caloShapeMap = (cell->etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
955 CaloVolMap::iterator volIt = caloShapeMap.find(cell->param());
956 if ( volIt == caloShapeMap.end())
961 HepGeom::Vector3D<float> lCenter;
962 for(
int c = 0;
c < 8; ++
c)
970 static const int arrP[] = { 3, 2, 1, 0, 7, 6, 5, 4 };
971 static const int arrN[] = { 7, 6, 5, 4 ,3, 2, 1, 0};
972 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
975 for (
int c = 0;
c < 8; ++
c) {
976 points[
c*2 + 0 ] = lc[arr[
c]].x() - lCenter.x();
977 points[
c*2 + 1 ] = lc[arr[
c]].y() - lCenter.y();
980 float dz = (lc[4].z() -lc[0].z()) * 0.5;
981 TGeoShape* solid =
new TGeoArb8(dz, &points[0]);
982 volume =
new TGeoVolume(
"ecal oblique prism", solid,
GetMedium(
kHCal));
983 caloShapeMap[cell->param()] = volume;
987 volume = volIt->second;
991 HepGeom::Vector3D<float> gCenter;
993 for (
int c = 0;
c < 8; ++
c) {
994 gCenter += HepGeom::Vector3D<float>(gc[
c].x(), gc[
c].y(), gc[
c].z());
999 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1001 rot.SetAngles(cell->phiPos()*TMath::RadToDeg(), 0, 0);
1005 std::stringstream nname;
1007 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr, rot));
1020 for (
int i = 0;
i < 8; ++
i)
1021 gCenter += TEveVector(gc[
i].
x(), gc[
i].
y(), gc[
i].
z());
1024 TEveVector tgCenter;
1025 for (
int i = 4;
i < 8; ++
i)
1026 tgCenter += TEveVector(gc[
i].
x(), gc[
i].
y(), gc[
i].
z());
1030 TEveVector axis = tgCenter - gCenter;
1035 tr.GetBaseVec(1, v1t);
1038 TEveVector v1(v1t.x(), v1t.y(), v1t.z());
1039 double dot13 = axis.Dot(v1);
1040 TEveVector gd = axis;
1045 TMath::Cross(v1.Arr(), axis.Arr(), v2.Arr());
1046 TMath::Cross(axis.Arr(), v1.Arr(), v2.Arr());
1049 tr.SetBaseVec(1, v1.fX, v1.fY, v1.fZ);
1050 tr.SetBaseVec(2, v2.fX, v2.fY, v2.fZ);
1051 tr.SetBaseVec(3, axis.fX, axis.fY, axis.fZ);
1052 tr.Move3PF(gCenter.fX, gCenter.fY, gCenter.fZ);
1054 TGeoHMatrix*
out =
new TGeoHMatrix();
1055 tr.SetGeoHMatrix(*out);
1063 const HepGeom::Transform3D idtr;
1071 for(
int c = 0;
c < 8; ++
c )
1073 points[
c*2 ] = co[
c].x();
1074 points[
c*2+1] = co[
c].y();
1076 TGeoShape* solid =
new TGeoArb8(cell->
param()[0], points);
1089 CaloVolMap caloShapeMap;
1095 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
1099 if (!cell) { printf(
"ecalBarrel cell not a TruncatedPyramid !!\n");
return; }
1101 TGeoVolume* volume = 0;
1102 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1103 if ( volIt == caloShapeMap.end())
1106 caloShapeMap[cell->
param()] = volume;
1109 volume = volIt->second;
1114 std::stringstream nname;
1116 AddLeafNode(holder, volume, nname.str().c_str(), mtx);
1125 for( std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it)
1129 if (!cell) { printf(
"ecalEndcap cell not a TruncatedPyramid !!\n");
continue;}
1131 TGeoVolume* volume = 0;
1132 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1133 if ( volIt == caloShapeMap.end())
1137 caloShapeMap[cell->
param()] = volume;
1140 volume = volIt->second;
1145 std::stringstream nname;
1147 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)
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
boost::shared_ptr< FWTGeoRecoGeometry > produce(const FWTGeoRecoGeometryRecord &)
CornersVec const & getCorners() const
Returns the corner points of this cell's volume.
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)
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)