Skip to content

Commit

Permalink
Merge pull request #31978 from alja/gem2021
Browse files Browse the repository at this point in the history
Fireworks 11_2_X Updates for GEM detector visualization
  • Loading branch information
cmsbuild authored Oct 30, 2020
2 parents 5d5e0ee + 446c78a commit 8a7e27c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 46 deletions.
43 changes: 22 additions & 21 deletions Fireworks/Core/src/FW3DViewGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "Fireworks/Core/interface/TEveElementIter.h"
#include "Fireworks/Core/interface/Context.h"
#include "Fireworks/Core/interface/FWColorManager.h"
#include "Fireworks/Core/interface/fwLog.h"

#include "DataFormats/MuonDetId/interface/DTChamberId.h"
#include "DataFormats/MuonDetId/interface/CSCDetId.h"
Expand Down Expand Up @@ -184,46 +185,46 @@ void FW3DViewGeometry::showMuonEndcap(bool showMuonEndcap) {
}
}
}

// hardcoded gem and me0; need to find better way for different gem geometries
for (Int_t iRegion = GEMDetId::minRegionId; iRegion <= GEMDetId::maxRegionId; iRegion = iRegion + 2) {
for (Int_t iRegion = GEMDetId::minRegionId; iRegion <= GEMDetId::maxRegionId; iRegion += 2) {
TEveElementList* teEndcap = nullptr;
if (iRegion == 1)
teEndcap = new TEveElementList("GEM Forward");
else
teEndcap = new TEveElementList("GEM Backward");
teEndcap = new TEveElementList(Form("GEM Reg=%d", iRegion));
m_muonEndcapElements->AddElement(teEndcap);

int mxSt = m_geom->versionInfo().haveExtraDet("GE2") ? GEMDetId::maxStationId : 1;

for (Int_t iStation = GEMDetId::minStationId; iStation <= mxSt; ++iStation) {
int iStation = 1;
{
std::ostringstream s;
s << "Station" << iStation;
TEveElementList* cStation = new TEveElementList(s.str().c_str());
teEndcap->AddElement(cStation);

Int_t iRing = 1;
for (Int_t iLayer = GEMDetId::minLayerId; iLayer <= GEMDetId::maxLayerId; ++iLayer) {
int maxChamber = 36;
if (iStation >= 2)
maxChamber = 18;
int maxChamber = GEMDetId::maxChamberId;
std::ostringstream sl;
sl << "Layer" << iLayer;
TEveElementList* elayer = new TEveElementList(sl.str().c_str());
cStation->AddElement(elayer);

for (Int_t iChamber = 1; iChamber <= maxChamber; ++iChamber) {
int maxRoll = iChamber % 2 ? 9 : 10;
if (iStation == 2)
maxRoll = 8;
if (iStation == 3)
maxRoll = 12;

for (Int_t iRoll = GEMDetId::minRollId; iRoll <= maxRoll; ++iRoll) {
std::ostringstream cl;
cl << "Chamber" << iChamber;
TEveElementList* cha = new TEveElementList(cl.str().c_str());
elayer->AddElement(cha);

Int_t iRing = 1;
Int_t iRoll = 0;
try {
GEMDetId id(iRegion, iRing, iStation, iLayer, iChamber, iRoll);
TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
if (shape) {
shape->SetTitle(TString::Format(
"GEM: , Rng=%d, St=%d, Ch=%d Rl=%d\ndet-id=%u", iRing, iStation, iChamber, iRoll, id.rawId()));

cStation->AddElement(shape);
cha->AddElement(shape);
addToCompound(shape, kFWMuonEndcapLineColorIndex);
}
} catch (cms::Exception& e) {
fwLog(fwlog::kError) << "FW3DViewGeomtery " << e << std::endl;
}
}
}
Expand Down
43 changes: 18 additions & 25 deletions Fireworks/Core/src/FWRPZViewGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,39 +537,32 @@ void FWRPZViewGeometry::showGEM(bool show) {
m_GEMElements = new TEveElementList("GEM");

for (Int_t iRegion = GEMDetId::minRegionId; iRegion <= GEMDetId::maxRegionId; iRegion = iRegion + 2) {
int mxSt = m_geom->versionInfo().haveExtraDet("GE2") ? 3 : 1;

for (Int_t iStation = GEMDetId::minStationId; iStation <= mxSt; ++iStation) {
Int_t iRing = 1;
for (Int_t iLayer = GEMDetId::minLayerId; iLayer <= GEMDetId::maxLayerId; ++iLayer) {
int maxChamber = 36;
if (iStation >= 2)
maxChamber = 18;

for (Int_t iChamber = 1; iChamber <= maxChamber; ++iChamber) {
int maxRoll = iChamber % 2 ? 9 : 10;
if (iStation == 2)
maxRoll = 8;
if (iStation == 3)
maxRoll = 12;

for (Int_t iRoll = GEMDetId::minRollId; iRoll <= maxRoll; ++iRoll) {
GEMDetId id(iRegion, iRing, iStation, iLayer, iChamber, iRoll);
TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
if (shape) {
addToCompound(shape, kFWMuonEndcapLineColorIndex);
m_GEMElements->AddElement(shape);
gEve->AddToListTree(shape, true);
}
}
int iStation = 1;
int iRing = 1;
int iLayer = 1;

int carr[4] = {10, 11, 29, 30};
for (int i = 0; i < 4; ++i) {
int iChamber = carr[i];
int iRoll = 0;
try {
GEMDetId id(iRegion, iRing, iStation, iLayer, iChamber, iRoll);
TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
if (shape) {
addToCompound(shape, kFWMuonEndcapLineColorIndex);
m_GEMElements->AddElement(shape);
gEve->AddToListTree(shape, true);
}
} catch (cms::Exception& e) {
fwLog(fwlog::kError) << "FWRPZViewGeomtery " << e << std::endl;
}
}
}

AddElement(m_GEMElements);
importNew(m_GEMElements);
}

if (m_GEMElements) {
m_GEMElements->SetRnrState(show);
gEve->Redraw3D();
Expand Down

0 comments on commit 8a7e27c

Please sign in to comment.