47 #include "TGeoManager.h" 49 #include "TGeoMatrix.h" 56 #include "TEveVector.h" 57 #include "TEveTrans.h" 61 typedef std::map<const float*, TGeoVolume*> CaloVolMap;
75 void AddLeafNode(TGeoVolume* mother, TGeoVolume* daughter,
const char*
name, TGeoMatrix* mtx) {
76 int n = mother->GetNdaughters();
77 mother->AddNode(daughter, 1, mtx);
78 mother->GetNode(n)->SetName(name);
88 TGeoTranslation trans(posx, posy, posz);
95 const Double_t
matrix[9] = {detRot.
xx(),
104 rotation.SetMatrix(matrix);
106 return new TGeoCombiTrans(trans, rotation);
113 TGeoVolume*
res =
nullptr;
114 if (mother->GetNdaughters()) {
115 TGeoNode*
n = mother->FindNode(Form(
"%s_%d_1", prefix,
id));
117 res = n->GetVolume();
121 res =
new TGeoVolumeAssembly(Form(
"%s_%d", prefix,
id));
123 mother->AddNode(res, 1);
130 TGeoVolume*
res =
nullptr;
131 if (mother->GetNdaughters()) {
132 TGeoNode*
n = mother->FindNode(Form(
"%s_1", prefix));
134 res = n->GetVolume();
139 res =
new TGeoVolumeAssembly(prefix);
141 mother->AddNode(res, 1);
173 std::map<ERecoDet, TGeoMedium*>::iterator it =
m_recoMedium.find(det);
184 color = GMCol::Green;
194 color = GMCol::Blue2;
204 color = GMCol::Yellow1;
214 color = GMCol::Yellow0;
220 color = GMCol::Blue2;
224 color = GMCol::Orange1;
228 color = GMCol::Green;
232 color = GMCol::Blue2;
236 color = GMCol::Blue1;
239 printf(
"invalid medium id \n");
243 TGeoMaterial* mat =
new TGeoMaterial(
name.c_str(), 0, 0, 0);
246 mat->SetFillStyle(3000);
257 auto fwTGeoRecoGeometry = std::make_unique<FWTGeoRecoGeometry>();
265 TGeoManager*
geom =
new TGeoManager(
"cmsGeo",
"CMS Detector");
266 if (
nullptr == gGeoIdentity) {
267 gGeoIdentity =
new TGeoIdentity(
"Identity");
270 fwTGeoRecoGeometry->manager(geom);
273 TGeoMaterial* vacuum =
new TGeoMaterial(
"Vacuum", 0, 0, 0);
276 TGeoVolume* top = geom->MakeBox(
"CMS",
m_dummyMedium, 270., 270., 120.);
278 if (
nullptr == top) {
279 return std::unique_ptr<FWTGeoRecoGeometry>();
281 geom->SetTopVolume(top);
283 top->SetVisibility(kFALSE);
284 top->SetLineColor(kBlue);
324 geom->CloseGeometry();
326 geom->DefaultColors();
328 geom->CloseGeometry();
330 return fwTGeoRecoGeometry;
335 TGeoShape* shape =
nullptr;
341 std::array<const float, 4>
const& par = b2->
parameters();
344 float hBottomEdge = par[0];
345 float hTopEdge = par[1];
347 float apothem = par[3];
350 s <<
"T_" << hBottomEdge <<
"_" << hTopEdge <<
"_" << thickness <<
"_" << apothem;
356 if (
nullptr == shape) {
357 shape =
new TGeoTrap(name.c_str(),
373 if (dynamic_cast<const RectangularPlaneBounds*>(b) !=
nullptr) {
380 s <<
"R_" << width <<
"_" << length <<
"_" <<
thickness;
386 if (
nullptr == shape) {
387 shape =
new TGeoBBox(name.c_str(), width / 2., length / 2., thickness / 2.);
400 std::map<TGeoShape*, TGeoVolume*>::iterator vIt =
m_shapeToVolume.find(solid);
404 TGeoVolume* volume =
new TGeoVolume(name.c_str(), solid,
GetMedium(mid));
425 DetId detid = it->geographicalId();
430 std::string name = Form(
"PXB Ly:%d, Md:%d Ld:%d ", layer, module, ladder);
445 DetId detid = it->geographicalId();
451 std::string name = Form(
"PXF D:%d, B:%d, P:%d, S:%d", disk, blade, panel, side);
468 DetId detid = it->geographicalId();
488 DetId detid = it->geographicalId();
508 DetId detid = it->geographicalId();
528 DetId detid = it->geographicalId();
559 for (
auto it = dtChamberGeom.begin(),
end = dtChamberGeom.end(); it !=
end; ++it) {
560 if (
auto chamber = dynamic_cast<const DTChamber*>(*it)) {
580 for (
auto it = dtSuperLayerGeom.begin(),
end = dtSuperLayerGeom.end(); it !=
end; ++it) {
581 if (
auto* superlayer = dynamic_cast<const DTSuperLayer*>(*it)) {
601 for (
auto it = dtLayerGeom.begin(),
end = dtLayerGeom.end(); it !=
end; ++it) {
602 if (
auto layer = dynamic_cast<const DTLayer*>(*it)) {
625 throw cms::Exception(
"FatalError") <<
"Cannnot find CSCGeometry\n";
631 for (
auto it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it) {
632 unsigned int rawid = (*it)->geographicalId();
638 TGeoVolume*
child =
nullptr;
640 if (
auto chamber = dynamic_cast<const CSCChamber*>(*it))
642 else if (
auto* layer = dynamic_cast<const CSCLayer*>(*it))
679 TGeoVolume* holder =
GetDaughter(assembly,
"SuperChamber Region",
kMuonGEM, detid.region());
712 edm::LogInfo(
"FWRecoGeometry") <<
"failed to produce GEM geometry " << exception.
what() << std::endl;
724 for (
auto it = rpcGeom->
rolls().begin(),
end = rpcGeom->
rolls().end(); it !=
end; ++it) {
756 unsigned int rawid = roll->geographicalId().rawId();
772 edm::LogInfo(
"FWRecoGeometry") <<
"failed to produce ME0 geometry " << exception.
what() << std::endl;
786 CaloVolMap caloShapeMapP;
787 CaloVolMap caloShapeMapN;
788 for (std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it) {
795 printf(
"HB not oblique !!!\n");
799 TGeoVolume* volume =
nullptr;
800 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
801 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
802 if (volIt == caloShapeMap.end()) {
807 HepGeom::Vector3D<float> lCenter;
808 for (
int c = 0;
c < 8; ++
c)
812 static const int arr[] = {1, 0, 3, 2, 5, 4, 7, 6};
814 for (
int c = 0;
c < 8; ++
c) {
816 points[
c * 2 + 0] = -(lc[arr[
c]].
z() - lCenter.z());
818 points[
c * 2 + 0] = (lc[arr[
c]].z() - lCenter.z());
819 points[
c * 2 + 1] = (lc[arr[
c]].y() - lCenter.y());
823 float dz = (lc[4].x() - lc[0].x()) * 0.5;
824 TGeoShape* solid =
new TGeoArb8(dz, &points[0]);
825 volume =
new TGeoVolume(
"hcal oblique prism", solid,
GetMedium(
kHCal));
826 caloShapeMap[cell->
param()] = volume;
828 volume = volIt->second;
831 HepGeom::Vector3D<float> gCenter;
833 for (
int c = 0;
c < 8; ++
c)
834 gCenter += HepGeom::Vector3D<float>(gc[
c].
x(), gc[
c].
y(), gc[
c].
z());
837 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
842 rotPhi.SetAngles(0, -cell->
phiPos() * TMath::RadToDeg(), 0);
843 rot.MultiplyBy(&rotPhi);
847 std::stringstream nname;
849 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr, rot));
857 CaloVolMap caloShapeMapP;
858 CaloVolMap caloShapeMapN;
865 for (std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it) {
871 printf(
"EC not oblique \n");
875 TGeoVolume* volume =
nullptr;
876 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
877 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
878 if (volIt == caloShapeMap.end()) {
882 HepGeom::Vector3D<float> lCenter;
883 for (
int c = 0;
c < 8; ++
c)
890 static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
891 static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
892 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
895 for (
int c = 0;
c < 8; ++
c) {
896 points[
c * 2 + 0] = lc[arr[
c]].x() - lCenter.x();
897 points[
c * 2 + 1] = lc[arr[
c]].y() - lCenter.y();
900 float dz = (lc[4].z() - lc[0].z()) * 0.5;
901 TGeoShape* solid =
new TGeoArb8(dz, &points[0]);
902 volume =
new TGeoVolume(
"ecal oblique prism", solid,
GetMedium(
kHCal));
903 caloShapeMap[cell->
param()] = volume;
905 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());
916 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
918 rot.SetAngles(cell->
phiPos() * TMath::RadToDeg(), 0, 0);
922 std::stringstream nname;
924 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr, rot));
931 CaloVolMap caloShapeMapP;
932 CaloVolMap caloShapeMapN;
939 for (std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it) {
945 printf(
"EC not oblique \n");
949 TGeoVolume* volume =
nullptr;
950 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
951 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
952 if (volIt == caloShapeMap.end()) {
956 HepGeom::Vector3D<float> lCenter;
957 for (
int c = 0;
c < 8; ++
c)
960 static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
961 static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
962 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
965 for (
int c = 0;
c < 8; ++
c) {
966 points[
c * 2 + 0] = lc[arr[
c]].x() - lCenter.x();
967 points[
c * 2 + 1] = lc[arr[
c]].y() - lCenter.y();
970 float dz = (lc[4].z() - lc[0].z()) * 0.5;
971 TGeoShape* solid =
new TGeoArb8(dz, &points[0]);
972 volume =
new TGeoVolume(
"ecal oblique prism", solid,
GetMedium(
kHCal));
973 caloShapeMap[cell->
param()] = volume;
975 volume = volIt->second;
977 HepGeom::Vector3D<float> gCenter;
979 for (
int c = 0;
c < 8; ++
c) {
980 gCenter += HepGeom::Vector3D<float>(gc[
c].x(), gc[
c].y(), gc[
c].z());
984 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
986 rot.SetAngles(cell->
phiPos() * TMath::RadToDeg(), 0, 0);
990 std::stringstream nname;
992 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr, rot));
997 CaloVolMap caloShapeMapP;
998 CaloVolMap caloShapeMapN;
1005 for (std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it) {
1011 printf(
"EC not Z prism \n");
1015 TGeoVolume* volume =
nullptr;
1016 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
1017 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1018 if (volIt == caloShapeMap.end()) {
1022 HepGeom::Vector3D<float> lCenter;
1023 for (
int c = 0;
c < 8; ++
c)
1026 static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
1027 static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
1028 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
1031 for (
int c = 0;
c < 8; ++
c) {
1032 points[
c * 2 + 0] = lc[arr[
c]].x() - lCenter.x();
1033 points[
c * 2 + 1] = lc[arr[
c]].y() - lCenter.y();
1036 float dz = (lc[4].z() - lc[0].z()) * 0.5;
1037 TGeoShape* solid =
new TGeoArb8(dz, &points[0]);
1038 volume =
new TGeoVolume(
"ecal oblique prism", solid,
GetMedium(
kHCal));
1039 caloShapeMap[cell->
param()] = volume;
1041 volume = volIt->second;
1043 HepGeom::Vector3D<float> gCenter;
1045 for (
int c = 0;
c < 8; ++
c) {
1046 gCenter += HepGeom::Vector3D<float>(gc[
c].x(), gc[
c].y(), gc[
c].z());
1050 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1052 rot.SetAngles(cell->
phiPos() * TMath::RadToDeg(), 0, 0);
1056 std::stringstream nname;
1058 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr, rot));
1063 CaloVolMap caloShapeMapP;
1064 CaloVolMap caloShapeMapN;
1070 for (std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it) {
1075 printf(
"EC not oblique \n");
1078 TGeoVolume* volume =
nullptr;
1079 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
1080 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1081 if (volIt == caloShapeMap.end()) {
1085 HepGeom::Vector3D<float> lCenter;
1086 for (
int c = 0;
c < 8; ++
c)
1090 static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
1091 static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
1092 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
1095 for (
int c = 0;
c < 8; ++
c) {
1096 points[
c * 2 + 0] = lc[arr[
c]].x() - lCenter.x();
1097 points[
c * 2 + 1] = lc[arr[
c]].y() - lCenter.y();
1100 float dz = (lc[4].z() - lc[0].z()) * 0.5;
1101 TGeoShape* solid =
new TGeoArb8(dz, &points[0]);
1103 caloShapeMap[cell->
param()] = volume;
1105 volume = volIt->second;
1108 HepGeom::Vector3D<float> gCenter;
1110 for (
int c = 0;
c < 8; ++
c) {
1111 gCenter += HepGeom::Vector3D<float>(gc[
c].x(), gc[
c].y(), gc[
c].z());
1115 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1117 rot.SetAngles(cell->
phiPos() * TMath::RadToDeg(), 0, 0);
1121 std::stringstream nname;
1123 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr, rot));
1131 for (
int i = 0;
i < 8; ++
i)
1132 gCenter += TEveVector(gc[
i].
x(), gc[
i].
y(), gc[
i].
z());
1135 TEveVector tgCenter;
1136 for (
int i = 4;
i < 8; ++
i)
1137 tgCenter += TEveVector(gc[
i].
x(), gc[
i].
y(), gc[
i].
z());
1140 TEveVector axis = tgCenter - gCenter;
1145 tr.GetBaseVec(1, v1t);
1147 TEveVector v1(v1t.x(), v1t.y(), v1t.z());
1148 double dot13 = axis.Dot(v1);
1149 TEveVector gd = axis;
1154 TMath::Cross(v1.Arr(), axis.Arr(), v2.Arr());
1155 TMath::Cross(axis.Arr(), v1.Arr(), v2.Arr());
1158 tr.SetBaseVec(1, v1.fX, v1.fY, v1.fZ);
1159 tr.SetBaseVec(2, v2.fX, v2.fY, v2.fZ);
1160 tr.SetBaseVec(3, axis.fX, axis.fY, axis.fZ);
1161 tr.Move3PF(gCenter.fX, gCenter.fY, gCenter.fZ);
1163 TGeoHMatrix*
out =
new TGeoHMatrix();
1164 tr.SetGeoHMatrix(*out);
1171 const HepGeom::Transform3D idtr;
1179 for (
int c = 0;
c < 8; ++
c) {
1180 points[
c * 2] = co[
c].x();
1181 points[
c * 2 + 1] = co[
c].y();
1183 TGeoShape* solid =
new TGeoArb8(cell->
param()[0],
points);
1191 CaloVolMap caloShapeMap;
1197 for (std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it) {
1202 printf(
"ecalBarrel cell not a TruncatedPyramid !!\n");
1206 TGeoVolume* volume =
nullptr;
1207 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1208 if (volIt == caloShapeMap.end()) {
1210 caloShapeMap[cell->
param()] = volume;
1212 volume = volIt->second;
1217 std::stringstream nname;
1219 AddLeafNode(holder, volume, nname.str().c_str(), mtx);
1227 for (std::vector<DetId>::const_iterator it = vid.begin(),
end = vid.end(); it !=
end; ++it) {
1232 printf(
"ecalEndcap cell not a TruncatedPyramid !!\n");
1236 TGeoVolume* volume =
nullptr;
1237 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1238 if (volIt == caloShapeMap.end()) {
1240 caloShapeMap[cell->
param()] = volume;
1242 volume = volIt->second;
1247 std::stringstream nname;
1249 AddLeafNode(holder, volume, nname.str().c_str(), mtx);
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
TGeoMedium * m_dummyMedium
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
T getUntrackedParameter(std::string const &, T const &) const
const TrackerGeometry * m_trackerGeom
virtual float length() const =0
const CaloGeometry * m_caloGeom
unsigned int tidRing(const DetId &id) const
virtual const std::array< const float, 4 > parameters() const
edm::ESHandle< GlobalTrackingGeometry > m_geomRecord
int zside() const
get the z-side of the cell (1/-1)
TGeoShape * createShape(const GeomDet *det)
unsigned int pxfDisk(const DetId &id) const
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
unsigned int tecRing(const DetId &id) const
ring id
CaloCellGeometry::Pt3D Pt3D
unsigned int pxbLadder(const DetId &id) const
unsigned int side(const DetId &id) const
const Bounds & bounds() const
unsigned int tidWheel(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
char const * what() const override
TGeoCombiTrans * createPlacement(const Rotation3D &iRot, const Position &iTrans)
std::string print(DetId detid) const
std::map< TGeoShape *, TGeoVolume * > m_shapeToVolume
const Plane & surface() const
The nominal surface of the GeomDet.
void addCaloTowerGeometry()
virtual float width() const =0
unsigned int tibSide(const DetId &id) const
TGeoMedium * GetMedium(ERecoDet)
const CCGFloat * param() const
unsigned int tidSide(const DetId &id) const
const TrackerTopology * m_trackerTopology
CaloCellGeometry::Pt3D Pt3D
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
const DetContainer & detsTEC() const
void addHcalCaloGeometryOuter()
TGeoHMatrix * getEcalTrans(CaloCellGeometry::CornersVec const &gc)
static const int SubdetId
void addEcalCaloGeometry()
std::map< std::string, TGeoShape * > m_nameToShape
const DepRecordT getRecord() const
CaloCellGeometry::Pt3DVec Pt3DVec
unsigned int tobSide(const DetId &id) const
int ieta() const
get the cell ieta
const DetContainer & detsPXB() const
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
DetId geographicalId() const
The label of this GeomDet.
void addHcalCaloGeometryBarrel()
int ieta() const
get the crystal ieta
std::map< ERecoDet, TGeoMedium * > m_recoMedium
virtual const DetContainer & dets() const =0
Returm a vector of all GeomDet (including all GeomDetUnits)
unsigned int tibModule(const DetId &id) const
const DetContainer & detsTIB() const
TGeoShape * makeEcalShape(const TruncatedPyramid *cell)
TGeoVolume * GetDaughter(TGeoVolume *mother, const char *prefix, ERecoDet cidx, int id)
unsigned int pxbLayer(const DetId &id) const
unsigned int tecModule(const DetId &id) const
const std::vector< const GEMSuperChamber * > & superChambers() const
Return a vector of all GEM super chambers.
std::unique_ptr< FWTGeoRecoGeometry > produce(const FWTGeoRecoGeometryRecord &)
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
virtual float thickness() const =0
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
int zside() const
get the z-side of the tower (1/-1)
CaloCellGeometry::Pt3D Pt3D
unsigned int tecOrder(const DetId &id) const
unsigned int tobModule(const DetId &id) const
CaloCellGeometry::Pt3DVec Pt3DVec
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...
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
void addPixelForwardGeometry()
~FWTGeoRecoGeometryESProducer(void) override
FWTGeoRecoGeometryESProducer(const edm::ParameterSet &)
const DetContainer & detsPXF() const
void addHcalCaloGeometryForward()
const DetContainer & detsTOB() const
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
const RotationType & rotation() const
TGeoVolume * GetTopHolder(const char *prefix, ERecoDet cidx)
int ieta() const
get the tower ieta
unsigned int tobRod(const DetId &id) const
const PositionType & position() const
void addHcalCaloGeometryEndcap()
T const * product() const
void addPixelBarrelGeometry()
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
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)
unsigned int tibOrder(const DetId &id) const