47 #include "TGeoManager.h" 49 #include "TGeoMatrix.h" 56 #include "TEveVector.h" 57 #include "TEveTrans.h" 61 typedef std::map<const float*, TGeoVolume*> CaloVolMap;
64 m_tracker =
pset.getUntrackedParameter<
bool>(
"Tracker",
true);
65 m_muon =
pset.getUntrackedParameter<
bool>(
"Muon",
true);
66 m_gem =
pset.getUntrackedParameter<
bool>(
"GEM",
false);
67 m_calo =
pset.getUntrackedParameter<
bool>(
"Calo",
true);
88 void AddLeafNode(TGeoVolume* mother, TGeoVolume* daughter,
const char*
name, TGeoMatrix* mtx) {
89 int n = mother->GetNdaughters();
90 mother->AddNode(daughter, 1, mtx);
91 mother->GetNode(
n)->SetName(
name);
101 TGeoTranslation trans(posx, posy, posz);
108 const Double_t
matrix[9] = {detRot.
xx(),
119 return new TGeoCombiTrans(trans,
rotation);
126 TGeoVolume*
res =
nullptr;
127 if (mother->GetNdaughters()) {
128 TGeoNode*
n = mother->FindNode(Form(
"%s_%d_1",
prefix,
id));
130 res =
n->GetVolume();
134 res =
new TGeoVolumeAssembly(Form(
"%s_%d",
prefix,
id));
136 mother->AddNode(
res, 1);
143 TGeoVolume*
res =
nullptr;
144 if (mother->GetNdaughters()) {
145 TGeoNode*
n = mother->FindNode(Form(
"%s_1",
prefix));
147 res =
n->GetVolume();
154 mother->AddNode(
res, 1);
186 std::map<ERecoDet, TGeoMedium*>::iterator it =
m_recoMedium.find(det);
197 color = GMCol::Green;
207 color = GMCol::Blue2;
217 color = GMCol::Yellow1;
227 color = GMCol::Yellow0;
233 color = GMCol::Blue2;
237 color = GMCol::Orange1;
241 color = GMCol::Green;
245 color = GMCol::Blue2;
249 color = GMCol::Blue1;
252 printf(
"invalid medium id \n");
256 TGeoMaterial* mat =
new TGeoMaterial(
name.c_str(), 0, 0, 0);
259 mat->SetFillStyle(3000);
270 auto fwTGeoRecoGeometry = std::make_unique<FWTGeoRecoGeometry>();
276 TGeoManager*
geom =
new TGeoManager(
"cmsGeo",
"CMS Detector");
277 if (
nullptr == gGeoIdentity) {
278 gGeoIdentity =
new TGeoIdentity(
"Identity");
281 fwTGeoRecoGeometry->manager(
geom);
284 TGeoMaterial* vacuum =
new TGeoMaterial(
"Vacuum", 0, 0, 0);
289 if (
nullptr == top) {
290 return std::unique_ptr<FWTGeoRecoGeometry>();
292 geom->SetTopVolume(top);
294 top->SetVisibility(kFALSE);
295 top->SetLineColor(kBlue);
336 geom->CloseGeometry();
338 geom->DefaultColors();
340 geom->CloseGeometry();
342 return fwTGeoRecoGeometry;
347 TGeoShape*
shape =
nullptr;
353 std::array<const float, 4>
const& par =
b2->parameters();
356 float hBottomEdge = par[0];
357 float hTopEdge = par[1];
359 float apothem = par[3];
362 s <<
"T_" << hBottomEdge <<
"_" << hTopEdge <<
"_" <<
thickness <<
"_" << apothem;
368 if (
nullptr ==
shape) {
385 if (dynamic_cast<const RectangularPlaneBounds*>(
b) !=
nullptr) {
398 if (
nullptr ==
shape) {
412 std::map<TGeoShape*, TGeoVolume*>::iterator vIt =
m_shapeToVolume.find(solid);
416 TGeoVolume* volume =
new TGeoVolume(
name.c_str(), solid,
GetMedium(mid));
437 DetId detid = it->geographicalId();
457 DetId detid = it->geographicalId();
463 std::string name = Form(
"PXF D:%d, B:%d, P:%d, S:%d", disk, blade, panel, side);
480 DetId detid = it->geographicalId();
500 DetId detid = it->geographicalId();
520 DetId detid = it->geographicalId();
540 DetId detid = it->geographicalId();
571 for (
auto it = dtChamberGeom.begin(),
end = dtChamberGeom.end(); it !=
end; ++it) {
572 if (
auto chamber = dynamic_cast<const DTChamber*>(*it)) {
592 for (
auto it = dtSuperLayerGeom.begin(),
end = dtSuperLayerGeom.end(); it !=
end; ++it) {
593 if (
auto* superlayer = dynamic_cast<const DTSuperLayer*>(*it)) {
613 for (
auto it = dtLayerGeom.begin(),
end = dtLayerGeom.end(); it !=
end; ++it) {
614 if (
auto layer = dynamic_cast<const DTLayer*>(*it)) {
637 throw cms::Exception(
"FatalError") <<
"Cannnot find CSCGeometry\n";
643 for (
auto it = cscGeom.begin(), itEnd = cscGeom.end(); it != itEnd; ++it) {
644 unsigned int rawid = (*it)->geographicalId();
650 TGeoVolume*
child =
nullptr;
652 if (
auto chamber = dynamic_cast<const CSCChamber*>(*it))
654 else if (
auto*
layer = dynamic_cast<const CSCLayer*>(*it))
691 TGeoVolume* holder =
GetDaughter(assembly,
"SuperChamber Region",
kMuonGEM, detid.region());
724 edm::LogInfo(
"FWRecoGeometry") <<
"failed to produce GEM geometry " <<
exception.what() << std::endl;
736 for (
auto it = rpcGeom->
rolls().begin(),
end = rpcGeom->
rolls().end(); it !=
end; ++it) {
768 unsigned int rawid = roll->geographicalId().rawId();
784 edm::LogInfo(
"FWRecoGeometry") <<
"failed to produce ME0 geometry " <<
exception.what() << std::endl;
798 CaloVolMap caloShapeMapP;
799 CaloVolMap caloShapeMapN;
800 for (std::vector<DetId>::const_iterator it =
vid.begin(),
end =
vid.end(); it !=
end; ++it) {
807 printf(
"HB not oblique !!!\n");
811 TGeoVolume* volume =
nullptr;
812 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
813 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
814 if (volIt == caloShapeMap.end()) {
819 HepGeom::Vector3D<float> lCenter;
820 for (
int c = 0;
c < 8; ++
c)
824 static const int arr[] = {1, 0, 3, 2, 5, 4, 7, 6};
826 for (
int c = 0;
c < 8; ++
c) {
828 points[
c * 2 + 0] = -(lc[arr[
c]].
z() - lCenter.z());
830 points[
c * 2 + 0] = (lc[arr[
c]].z() - lCenter.z());
831 points[
c * 2 + 1] = (lc[arr[
c]].y() - lCenter.y());
835 float dz = (lc[4].x() - lc[0].x()) * 0.5;
836 TGeoShape* solid =
new TGeoArb8(
dz, &
points[0]);
837 volume =
new TGeoVolume(
"hcal oblique prism", solid,
GetMedium(
kHCal));
838 caloShapeMap[cell->
param()] = volume;
840 volume = volIt->second;
843 HepGeom::Vector3D<float> gCenter;
845 for (
int c = 0;
c < 8; ++
c)
846 gCenter += HepGeom::Vector3D<float>(gc[
c].
x(), gc[
c].
y(), gc[
c].
z());
849 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
854 rotPhi.SetAngles(0, -cell->
phiPos() * TMath::RadToDeg(), 0);
855 rot.MultiplyBy(&rotPhi);
859 std::stringstream nname;
861 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr,
rot));
869 CaloVolMap caloShapeMapP;
870 CaloVolMap caloShapeMapN;
877 for (std::vector<DetId>::const_iterator it =
vid.begin(),
end =
vid.end(); it !=
end; ++it) {
883 printf(
"EC not oblique \n");
887 TGeoVolume* volume =
nullptr;
888 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
889 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
890 if (volIt == caloShapeMap.end()) {
894 HepGeom::Vector3D<float> lCenter;
895 for (
int c = 0;
c < 8; ++
c)
902 static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
903 static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
904 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
907 for (
int c = 0;
c < 8; ++
c) {
908 points[
c * 2 + 0] = lc[arr[
c]].x() - lCenter.x();
909 points[
c * 2 + 1] = lc[arr[
c]].y() - lCenter.y();
912 float dz = (lc[4].z() - lc[0].z()) * 0.5;
913 TGeoShape* solid =
new TGeoArb8(
dz, &
points[0]);
914 volume =
new TGeoVolume(
"ecal oblique prism", solid,
GetMedium(
kHCal));
915 caloShapeMap[cell->
param()] = volume;
917 volume = volIt->second;
920 HepGeom::Vector3D<float> gCenter;
922 for (
int c = 0;
c < 8; ++
c) {
923 gCenter += HepGeom::Vector3D<float>(gc[
c].x(), gc[
c].y(), gc[
c].z());
928 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
930 rot.SetAngles(cell->
phiPos() * TMath::RadToDeg(), 0, 0);
934 std::stringstream nname;
936 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr,
rot));
943 CaloVolMap caloShapeMapP;
944 CaloVolMap caloShapeMapN;
951 for (std::vector<DetId>::const_iterator it =
vid.begin(),
end =
vid.end(); it !=
end; ++it) {
957 printf(
"EC not oblique \n");
961 TGeoVolume* volume =
nullptr;
962 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
963 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
964 if (volIt == caloShapeMap.end()) {
968 HepGeom::Vector3D<float> lCenter;
969 for (
int c = 0;
c < 8; ++
c)
972 static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
973 static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
974 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
977 for (
int c = 0;
c < 8; ++
c) {
978 points[
c * 2 + 0] = lc[arr[
c]].x() - lCenter.x();
979 points[
c * 2 + 1] = lc[arr[
c]].y() - lCenter.y();
982 float dz = (lc[4].z() - lc[0].z()) * 0.5;
983 TGeoShape* solid =
new TGeoArb8(
dz, &
points[0]);
984 volume =
new TGeoVolume(
"ecal oblique prism", solid,
GetMedium(
kHCal));
985 caloShapeMap[cell->
param()] = volume;
987 volume = volIt->second;
989 HepGeom::Vector3D<float> gCenter;
991 for (
int c = 0;
c < 8; ++
c) {
992 gCenter += HepGeom::Vector3D<float>(gc[
c].x(), gc[
c].y(), gc[
c].z());
996 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
998 rot.SetAngles(cell->
phiPos() * TMath::RadToDeg(), 0, 0);
1002 std::stringstream nname;
1004 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr,
rot));
1009 CaloVolMap caloShapeMapP;
1010 CaloVolMap caloShapeMapN;
1017 for (std::vector<DetId>::const_iterator it =
vid.begin(),
end =
vid.end(); it !=
end; ++it) {
1023 printf(
"EC not Z prism \n");
1027 TGeoVolume* volume =
nullptr;
1028 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
1029 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1030 if (volIt == caloShapeMap.end()) {
1034 HepGeom::Vector3D<float> lCenter;
1035 for (
int c = 0;
c < 8; ++
c)
1038 static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
1039 static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
1040 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
1043 for (
int c = 0;
c < 8; ++
c) {
1044 points[
c * 2 + 0] = lc[arr[
c]].x() - lCenter.x();
1045 points[
c * 2 + 1] = lc[arr[
c]].y() - lCenter.y();
1048 float dz = (lc[4].z() - lc[0].z()) * 0.5;
1049 TGeoShape* solid =
new TGeoArb8(
dz, &
points[0]);
1050 volume =
new TGeoVolume(
"ecal oblique prism", solid,
GetMedium(
kHCal));
1051 caloShapeMap[cell->
param()] = volume;
1053 volume = volIt->second;
1055 HepGeom::Vector3D<float> gCenter;
1057 for (
int c = 0;
c < 8; ++
c) {
1058 gCenter += HepGeom::Vector3D<float>(gc[
c].x(), gc[
c].y(), gc[
c].z());
1062 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1064 rot.SetAngles(cell->
phiPos() * TMath::RadToDeg(), 0, 0);
1068 std::stringstream nname;
1070 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr,
rot));
1075 CaloVolMap caloShapeMapP;
1076 CaloVolMap caloShapeMapN;
1082 for (std::vector<DetId>::const_iterator it =
vid.begin(),
end =
vid.end(); it !=
end; ++it) {
1087 printf(
"EC not oblique \n");
1090 TGeoVolume* volume =
nullptr;
1091 CaloVolMap& caloShapeMap = (cell->
etaPos() > 0) ? caloShapeMapP : caloShapeMapN;
1092 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1093 if (volIt == caloShapeMap.end()) {
1097 HepGeom::Vector3D<float> lCenter;
1098 for (
int c = 0;
c < 8; ++
c)
1102 static const int arrP[] = {3, 2, 1, 0, 7, 6, 5, 4};
1103 static const int arrN[] = {7, 6, 5, 4, 3, 2, 1, 0};
1104 const int* arr = (detid.
ieta() > 0) ? &arrP[0] : &arrN[0];
1107 for (
int c = 0;
c < 8; ++
c) {
1108 points[
c * 2 + 0] = lc[arr[
c]].x() - lCenter.x();
1109 points[
c * 2 + 1] = lc[arr[
c]].y() - lCenter.y();
1112 float dz = (lc[4].z() - lc[0].z()) * 0.5;
1113 TGeoShape* solid =
new TGeoArb8(
dz, &
points[0]);
1115 caloShapeMap[cell->
param()] = volume;
1117 volume = volIt->second;
1120 HepGeom::Vector3D<float> gCenter;
1122 for (
int c = 0;
c < 8; ++
c) {
1123 gCenter += HepGeom::Vector3D<float>(gc[
c].x(), gc[
c].y(), gc[
c].z());
1127 TGeoTranslation gtr(gCenter.x(), gCenter.y(), gCenter.z());
1129 rot.SetAngles(cell->
phiPos() * TMath::RadToDeg(), 0, 0);
1133 std::stringstream nname;
1135 AddLeafNode(holder, volume, nname.str().c_str(),
new TGeoCombiTrans(gtr,
rot));
1143 for (
int i = 0;
i < 8; ++
i)
1144 gCenter += TEveVector(gc[
i].
x(), gc[
i].
y(), gc[
i].
z());
1147 TEveVector tgCenter;
1148 for (
int i = 4;
i < 8; ++
i)
1149 tgCenter += TEveVector(gc[
i].
x(), gc[
i].
y(), gc[
i].
z());
1152 TEveVector axis = tgCenter - gCenter;
1157 tr.GetBaseVec(1, v1t);
1159 TEveVector v1(v1t.x(), v1t.y(), v1t.z());
1160 double dot13 = axis.Dot(v1);
1161 TEveVector gd = axis;
1166 TMath::Cross(v1.Arr(), axis.Arr(), v2.Arr());
1167 TMath::Cross(axis.Arr(), v1.Arr(), v2.Arr());
1170 tr.SetBaseVec(1, v1.fX, v1.fY, v1.fZ);
1171 tr.SetBaseVec(2, v2.fX, v2.fY, v2.fZ);
1172 tr.SetBaseVec(3, axis.fX, axis.fY, axis.fZ);
1173 tr.Move3PF(gCenter.fX, gCenter.fY, gCenter.fZ);
1175 TGeoHMatrix*
out =
new TGeoHMatrix();
1176 tr.SetGeoHMatrix(*
out);
1183 const HepGeom::Transform3D idtr;
1191 for (
int c = 0;
c < 8; ++
c) {
1195 TGeoShape* solid =
new TGeoArb8(cell->
param()[0],
points);
1203 CaloVolMap caloShapeMap;
1209 for (std::vector<DetId>::const_iterator it =
vid.begin(),
end =
vid.end(); it !=
end; ++it) {
1214 printf(
"ecalBarrel cell not a TruncatedPyramid !!\n");
1218 TGeoVolume* volume =
nullptr;
1219 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1220 if (volIt == caloShapeMap.end()) {
1222 caloShapeMap[cell->
param()] = volume;
1224 volume = volIt->second;
1229 std::stringstream nname;
1231 AddLeafNode(holder, volume, nname.str().c_str(), mtx);
1239 for (std::vector<DetId>::const_iterator it =
vid.begin(),
end =
vid.end(); it !=
end; ++it) {
1244 printf(
"ecalEndcap cell not a TruncatedPyramid !!\n");
1248 TGeoVolume* volume =
nullptr;
1249 CaloVolMap::iterator volIt = caloShapeMap.find(cell->
param());
1250 if (volIt == caloShapeMap.end()) {
1252 caloShapeMap[cell->
param()] = volume;
1254 volume = volIt->second;
1259 std::stringstream nname;
1261 AddLeafNode(holder, volume, nname.str().c_str(), mtx);
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
const DetContainer & detsTIB() const
TGeoMedium * m_dummyMedium
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
const TrackerGeometry * m_trackerGeom
unsigned int pxbLayer(const DetId &id) const
unsigned int tibSide(const DetId &id) const
const CaloGeometry * m_caloGeom
const GlobalTrackingGeometry * m_trackingGeom
virtual float length() const =0
unsigned int tobSide(const DetId &id) const
virtual float phiPos() const
constexpr int zside() const
get the z-side of the cell (1/-1)
unsigned int pxfBlade(const DetId &id) const
const DetContainer & detsPXB() const
unsigned int tibOrder(const DetId &id) const
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
unsigned int tibModule(const DetId &id) const
unsigned int tidSide(const DetId &id) const
uint32_t cc[maxCellsPerHit]
TGeoShape * createShape(const GeomDet *det)
std::string print(DetId detid) const
unsigned int tidWheel(const DetId &id) const
CaloCellGeometry::Pt3D Pt3D
const DetContainer & detsPXF() const
unsigned int pxbLadder(const DetId &id) const
TGeoCombiTrans * createPlacement(const Rotation3D &iRot, const Position &iTrans)
unsigned int side(const DetId &id) const
std::map< TGeoShape *, TGeoVolume * > m_shapeToVolume
__host__ __device__ VT * co
unsigned int tecRing(const DetId &id) const
ring id
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > m_trackingGeomToken
void addCaloTowerGeometry()
int ieta() const
get the crystal ieta
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
virtual float thickness() const =0
unsigned int tecModule(const DetId &id) const
TGeoMedium * GetMedium(ERecoDet)
virtual float etaPos() const
const TrackerTopology * m_trackerTopology
const DetContainer & detsTOB() const
CaloCellGeometry::Pt3D Pt3D
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
void addHcalCaloGeometryOuter()
TGeoHMatrix * getEcalTrans(CaloCellGeometry::CornersVec const &gc)
static const int SubdetId
constexpr int ieta() const
get the cell ieta
void addEcalCaloGeometry()
std::map< std::string, TGeoShape * > m_nameToShape
CaloCellGeometry::Pt3DVec Pt3DVec
unsigned int pxfDisk(const DetId &id) const
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
void addHcalCaloGeometryBarrel()
unsigned int tecOrder(const DetId &id) const
int zside() const
get the z-side of the crystal (1/-1)
std::map< ERecoDet, TGeoMedium * > m_recoMedium
DetId geographicalId() const
The label of this GeomDet.
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > m_trackerTopologyToken
TGeoShape * makeEcalShape(const TruncatedPyramid *cell)
TGeoVolume * GetDaughter(TGeoVolume *mother, const char *prefix, ERecoDet cidx, int id)
unsigned int pxfPanel(const DetId &id) const
Log< level::Info, false > LogInfo
virtual const DetContainer & dets() const =0
Returm a vector of all GeomDet (including all GeomDetUnits)
std::unique_ptr< FWTGeoRecoGeometry > produce(const FWTGeoRecoGeometryRecord &)
const Plane & surface() const
The nominal surface of the GeomDet.
const PositionType & position() const
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
int ieta() const
get the tower ieta
CaloCellGeometry::Pt3D Pt3D
unsigned int tobRod(const DetId &id) const
CaloCellGeometry::Pt3DVec Pt3DVec
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
void addPixelForwardGeometry()
~FWTGeoRecoGeometryESProducer(void) override
int zside() const
get the z-side of the tower (1/-1)
FWTGeoRecoGeometryESProducer(const edm::ParameterSet &)
void addHcalCaloGeometryForward()
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
unsigned int tidRing(const DetId &id) const
CornersVec const & getCorners() const
Returns the corner points of this cell's volume.
const DetContainer & detsTEC() const
const RotationType & rotation() const
unsigned int tobModule(const DetId &id) const
TGeoVolume * GetTopHolder(const char *prefix, ERecoDet cidx)
unsigned int pxbModule(const DetId &id) const
virtual float width() const =0
void addHcalCaloGeometryEndcap()
void addPixelBarrelGeometry()
const std::vector< const GEMSuperChamber * > & superChambers() const
Return a vector of all GEM super chambers.
const CCGFloat * param() const
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
CaloCellGeometry::Pt3DVec Pt3DVec
TGeoVolume * createVolume(const std::string &name, const GeomDet *det, ERecoDet=kDummy)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > m_caloGeomToken
const DetContainer & detsTID() const
const Bounds & bounds() const
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.