Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-02-07 02:57:49

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWRPZViewGeometry
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Alja Mrak-Tadel
0010 //         Created:  Thu Mar 25 20:33:06 CET 2010
0011 //
0012 
0013 // system include files
0014 #include <iostream>
0015 #include <cassert>
0016 
0017 // user include files
0018 #include "TGeoBBox.h"
0019 
0020 #include "TEveElement.h"
0021 #include "TEveCompound.h"
0022 #include "TEveScene.h"
0023 #include "TEvePointSet.h"
0024 #include "TEveStraightLineSet.h"
0025 #include "TEveGeoNode.h"
0026 #include "TEveGeoShape.h"
0027 #include "TEveManager.h"
0028 #include "TEveProjectionManager.h"
0029 
0030 #include "Fireworks/Core/interface/FWRPZViewGeometry.h"
0031 #include "Fireworks/Core/interface/FWGeometry.h"
0032 #include "Fireworks/Core/interface/FWColorManager.h"
0033 #include "Fireworks/Core/interface/Context.h"
0034 #include "Fireworks/Core/interface/fwLog.h"
0035 
0036 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0037 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0038 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
0039 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
0040 #include "DataFormats/MuonDetId/interface/ME0DetId.h"
0041 
0042 #include "DataFormats/ForwardDetId/interface/MTDDetId.h"
0043 
0044 //
0045 // constants, enums and typedefs
0046 //
0047 
0048 //
0049 // static data member definitions
0050 //
0051 
0052 //
0053 // constructors and destructor
0054 //
0055 FWRPZViewGeometry::FWRPZViewGeometry(const fireworks::Context& context)
0056     : FWViewGeometryList(context),
0057 
0058       m_rhoPhiGeo(nullptr),
0059       m_rhoZGeo(nullptr),
0060 
0061       m_pixelBarrelElements(nullptr),
0062       m_pixelEndcapElements(nullptr),
0063       m_trackerBarrelElements(nullptr),
0064       m_trackerEndcapElements(nullptr),
0065       m_rpcEndcapElements(nullptr),
0066       m_GEMElements(nullptr),
0067       m_ME0Elements(nullptr),
0068       m_mtdBarrelElements(nullptr),
0069       m_mtdEndcapElements(nullptr) {
0070   SetElementName("RPZGeomShared");
0071 }
0072 
0073 // FWRPZViewGeometry::FWRPZViewGeometry(const FWRPZViewGeometry& rhs)
0074 // {
0075 //    // do actual copying here;
0076 // }
0077 
0078 FWRPZViewGeometry::~FWRPZViewGeometry() {
0079   m_rhoPhiGeo->DecDenyDestroy();
0080   m_rhoZGeo->DecDenyDestroy();
0081 }
0082 
0083 //______________________________________________________________________________
0084 
0085 void FWRPZViewGeometry::initStdGeoElements(const FWViewType::EType type) {
0086   if (m_geom->isEmpty())
0087     return;
0088 
0089   if (type == FWViewType::kRhoZ) {
0090     AddElement(makeMuonGeometryRhoZ());
0091     AddElement(makeCaloOutlineRhoZ());
0092   } else {
0093     AddElement(makeMuonGeometryRhoPhi());
0094     AddElement(makeCaloOutlineRhoPhi());
0095   }
0096 }
0097 
0098 //______________________________________________________________________________
0099 
0100 TEveElement* FWRPZViewGeometry::makeCaloOutlineRhoZ() {
0101   using namespace fireworks;
0102 
0103   float ri = m_context.caloZ2() * tan(2 * atan(exp(-m_context.caloMaxEta())));
0104 
0105   TEveStraightLineSet* el = new TEveStraightLineSet("TrackerRhoZoutline");
0106   el->SetPickable(kFALSE);
0107   addToCompound(el, kFWTrackerBarrelColorIndex, false);
0108 
0109   el->AddLine(0, m_context.caloR1(), -m_context.caloZ1(), 0, m_context.caloR1(), m_context.caloZ1());
0110   el->AddLine(0, -m_context.caloR1(), m_context.caloZ1(), 0, -m_context.caloR1(), -m_context.caloZ1());
0111 
0112   el->AddLine(0, -m_context.caloR2(), m_context.caloZ2(), 0, -ri, m_context.caloZ2());
0113   el->AddLine(0, ri, m_context.caloZ2(), 0, m_context.caloR2(), m_context.caloZ2());
0114 
0115   el->AddLine(0, -m_context.caloR2(), -m_context.caloZ2(), 0, -ri, -m_context.caloZ2());
0116   el->AddLine(0, ri, -m_context.caloZ2(), 0, m_context.caloR2(), -m_context.caloZ2());
0117 
0118   return el;
0119 }
0120 
0121 TEveElement* FWRPZViewGeometry::makeCaloOutlineRhoPhi() {
0122   TEveStraightLineSet* el = new TEveStraightLineSet("TrackerRhoPhi");
0123   addToCompound(el, kFWTrackerBarrelColorIndex, false);
0124 
0125   el->SetLineColor(m_context.colorManager()->geomColor(kFWTrackerBarrelColorIndex));
0126   const unsigned int nSegments = 100;
0127   const double r = m_context.caloR1();
0128   for (unsigned int i = 1; i <= nSegments; ++i)
0129     el->AddLine(r * sin(TMath::TwoPi() / nSegments * (i - 1)),
0130                 r * cos(TMath::TwoPi() / nSegments * (i - 1)),
0131                 0,
0132                 r * sin(TMath::TwoPi() / nSegments * i),
0133                 r * cos(TMath::TwoPi() / nSegments * i),
0134                 0);
0135 
0136   TEvePointSet* ref = new TEvePointSet("reference");
0137   ref->SetTitle("(0,0,0)");
0138   ref->SetMarkerStyle(4);
0139   ref->SetMarkerColor(kWhite);
0140   ref->SetNextPoint(0., 0., 0.);
0141   el->AddElement(ref);
0142 
0143   return el;
0144 }
0145 
0146 //______________________________________________________________________________
0147 
0148 TEveElement* FWRPZViewGeometry::makeMuonGeometryRhoPhi(void) {
0149   Int_t iWheel = 0;
0150 
0151   // rho-phi view
0152   TEveCompound* container = new TEveCompound("MuonRhoPhi");
0153 
0154   for (Int_t iStation = 1; iStation <= 4; ++iStation) {
0155     for (Int_t iSector = 1; iSector <= 14; ++iSector) {
0156       if (iStation < 4 && iSector > 12)
0157         continue;
0158       DTChamberId id(iWheel, iStation, iSector);
0159       TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
0160       if (shape) {
0161         shape->SetMainColor(m_colorComp[kFWMuonBarrelLineColorIndex]->GetMainColor());
0162         addToCompound(shape, kFWMuonBarrelLineColorIndex);
0163         container->AddElement(shape);
0164       }
0165     }
0166   }
0167   return container;
0168 }
0169 namespace {
0170 
0171   //void addLibe
0172 
0173 }
0174 //______________________________________________________________________________
0175 
0176 TEveElement* FWRPZViewGeometry::makeMuonGeometryRhoZ(void) {
0177   TEveElementList* container = new TEveElementList("MuonRhoZ");
0178 
0179   {
0180     TEveCompound* dtContainer = new TEveCompound("DT");
0181     for (Int_t iWheel = -2; iWheel <= 2; ++iWheel) {
0182       for (Int_t iStation = 1; iStation <= 4; ++iStation) {
0183         float min_rho(1000), max_rho(0), min_z(2000), max_z(-2000);
0184 
0185         // This will give us a quarter of DTs
0186         // which is enough for our projection
0187         for (Int_t iSector = 1; iSector <= 4; ++iSector) {
0188           DTChamberId id(iWheel, iStation, iSector);
0189           unsigned int rawid = id.rawId();
0190           FWGeometry::IdToInfoItr det = m_geom->find(rawid);
0191           if (det == m_geom->mapEnd())
0192             return container;
0193           estimateProjectionSizeDT(*det, min_rho, max_rho, min_z, max_z);
0194         }
0195         if (min_rho > max_rho || min_z > max_z)
0196           continue;
0197         TEveElement* se = makeShape(min_rho, max_rho, min_z, max_z);
0198         addToCompound(se, kFWMuonBarrelLineColorIndex);
0199         dtContainer->AddElement(se);
0200         se = makeShape(-max_rho, -min_rho, min_z, max_z);
0201         addToCompound(se, kFWMuonBarrelLineColorIndex);
0202         dtContainer->AddElement(se);
0203       }
0204     }
0205 
0206     container->AddElement(dtContainer);
0207   }
0208   {
0209     // addcsc
0210     TEveCompound* cscContainer = new TEveCompound("CSC");
0211     std::vector<CSCDetId> ids;
0212     for (int endcap = CSCDetId::minEndcapId(); endcap <= CSCDetId::maxEndcapId(); ++endcap) {
0213       for (int station = 1; station <= 4; ++station) {
0214         ids.push_back(CSCDetId(endcap, station, 2, 10, 0));  //outer ring up
0215         ids.push_back(CSCDetId(endcap, station, 2, 11, 0));  //outer ring up
0216 
0217         ids.push_back(CSCDetId(endcap, station, 2, 28, 0));  //outer ring down
0218         ids.push_back(CSCDetId(endcap, station, 2, 29, 0));  //outer ring down
0219 
0220         ids.push_back(CSCDetId(endcap, station, 1, 5, 0));  //inner ring up
0221         ids.push_back(CSCDetId(endcap, station, 1, 6, 0));  //inner ring up
0222 
0223         int off = (station == 1) ? 10 : 0;
0224         ids.push_back(CSCDetId(endcap, station, 1, 15 + off, 0));  //inner ring down
0225         ids.push_back(CSCDetId(endcap, station, 1, 16 + off, 0));  //inner ring down
0226       }
0227       ids.push_back(CSCDetId(endcap, 1, 3, 10, 0));  // ring 3 down
0228       ids.push_back(CSCDetId(endcap, 1, 3, 28, 0));  // ring 3 down
0229     }
0230     for (std::vector<CSCDetId>::iterator i = ids.begin(); i != ids.end(); ++i) {
0231       unsigned int rawid = i->rawId();
0232       TEveGeoShape* shape = m_geom->getEveShape(rawid);
0233       if (!shape)
0234         return cscContainer;
0235       addToCompound(shape, kFWMuonEndcapLineColorIndex);
0236       shape->SetName(Form(" e:%d r:%d s:%d chamber %d", i->endcap(), i->ring(), i->station(), i->chamber()));
0237       cscContainer->AddElement(shape);
0238     }
0239     container->AddElement(cscContainer);
0240   }
0241 
0242   return container;
0243 }
0244 
0245 //______________________________________________________________________________
0246 
0247 TEveGeoShape* FWRPZViewGeometry::makeShape(double min_rho, double max_rho, double min_z, double max_z) {
0248   TEveTrans t;
0249   t(1, 1) = 1;
0250   t(1, 2) = 0;
0251   t(1, 3) = 0;
0252   t(2, 1) = 0;
0253   t(2, 2) = 1;
0254   t(2, 3) = 0;
0255   t(3, 1) = 0;
0256   t(3, 2) = 0;
0257   t(3, 3) = 1;
0258   t(1, 4) = 0;
0259   t(2, 4) = (min_rho + max_rho) / 2;
0260   t(3, 4) = (min_z + max_z) / 2;
0261 
0262   TEveGeoShape* shape = new TEveGeoShape;
0263   shape->SetTransMatrix(t.Array());
0264 
0265   shape->SetRnrSelf(kTRUE);
0266   shape->SetRnrChildren(kTRUE);
0267   TGeoBBox* box = new TGeoBBox(0, (max_rho - min_rho) / 2, (max_z - min_z) / 2);
0268   shape->SetShape(box);
0269 
0270   return shape;
0271 }
0272 
0273 //______________________________________________________________________________
0274 
0275 void FWRPZViewGeometry::estimateProjectionSizeDT(
0276     const FWGeometry::GeomDetInfo& info, float& min_rho, float& max_rho, float& min_z, float& max_z) {
0277   // we will test 5 points on both sides ( +/- z)
0278   float local[3], global[3];
0279 
0280   float dX = info.shape[1];
0281   float dY = info.shape[2];
0282   float dZ = info.shape[3];
0283 
0284   local[0] = 0;
0285   local[1] = 0;
0286   local[2] = dZ;
0287   m_geom->localToGlobal(info, local, global);
0288   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0289 
0290   local[0] = dX;
0291   local[1] = dY;
0292   local[2] = dZ;
0293   m_geom->localToGlobal(info, local, global);
0294   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0295 
0296   local[0] = -dX;
0297   local[1] = dY;
0298   local[2] = dZ;
0299   m_geom->localToGlobal(info, local, global);
0300   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0301 
0302   local[0] = dX;
0303   local[1] = -dY;
0304   local[2] = dZ;
0305   m_geom->localToGlobal(info, local, global);
0306   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0307 
0308   local[0] = -dX;
0309   local[1] = -dY;
0310   local[2] = dZ;
0311   m_geom->localToGlobal(info, local, global);
0312   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0313 
0314   local[0] = 0;
0315   local[1] = 0;
0316   local[2] = -dZ;
0317   m_geom->localToGlobal(info, local, global);
0318   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0319 
0320   local[0] = dX;
0321   local[1] = dY;
0322   local[2] = -dZ;
0323   m_geom->localToGlobal(info, local, global);
0324   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0325 
0326   local[0] = -dX;
0327   local[1] = dY;
0328   local[2] = -dZ;
0329   m_geom->localToGlobal(info, local, global);
0330   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0331 
0332   local[0] = dX;
0333   local[1] = -dY;
0334   local[2] = -dZ;
0335   m_geom->localToGlobal(info, local, global);
0336   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0337 
0338   local[0] = -dX;
0339   local[1] = -dY;
0340   local[2] = -dZ;
0341   m_geom->localToGlobal(info, local, global);
0342   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0343 }
0344 
0345 void FWRPZViewGeometry::estimateProjectionSize(
0346     const float* global, float& min_rho, float& max_rho, float& min_z, float& max_z) {
0347   double rho = sqrt(global[0] * global[0] + global[1] * global[1]);
0348   if (min_rho > rho)
0349     min_rho = rho;
0350   if (max_rho < rho)
0351     max_rho = rho;
0352   if (min_z > global[2])
0353     min_z = global[2];
0354   if (max_z < global[2])
0355     max_z = global[2];
0356 }
0357 
0358 // ATODO:: check white vertex -> shouldn't be relative to background
0359 //         when detruction ?
0360 
0361 // ATODO why color is not set in 3D original, why cast to polygonsetprojected after projected ????
0362 // is geom color dynamic --- independent of projection manager
0363 
0364 // NOTE geomtry MuonRhoZAdanced renamed to  MuonRhoZ
0365 
0366 //==============================================================================
0367 //==============================================================================
0368 
0369 void FWRPZViewGeometry::showPixelBarrel(bool show) {
0370   if (!m_pixelBarrelElements && show) {
0371     m_pixelBarrelElements = new TEveElementList("PixelBarrel");
0372     AddElement(m_pixelBarrelElements);
0373     std::vector<unsigned int> ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::PixelBarrel);
0374     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0375       TEveGeoShape* shape = m_geom->getEveShape(*id);
0376       if (!shape)
0377         return;
0378       shape->SetTitle(Form("PixelBarrel %d", *id));
0379       addToCompound(shape, kFWPixelBarrelColorIndex);
0380       m_pixelBarrelElements->AddElement(shape);
0381     }
0382     importNew(m_pixelBarrelElements);
0383   }
0384 
0385   if (m_pixelBarrelElements) {
0386     m_pixelBarrelElements->SetRnrState(show);
0387     gEve->Redraw3D();
0388   }
0389 }
0390 
0391 void FWRPZViewGeometry::showPixelEndcap(bool show) {
0392   if (!m_pixelEndcapElements && show) {
0393     m_pixelEndcapElements = new TEveElementList("PixelEndcap");
0394 
0395     std::vector<unsigned int> ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::PixelEndcap);
0396     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0397       TEveGeoShape* shape = m_geom->getEveShape(*id);
0398       if (!shape)
0399         return;
0400       shape->SetTitle(Form("PixelEndCap %d", *id));
0401       addToCompound(shape, kFWPixelEndcapColorIndex);
0402       m_pixelEndcapElements->AddElement(shape);
0403     }
0404 
0405     AddElement(m_pixelEndcapElements);
0406     importNew(m_pixelEndcapElements);
0407   }
0408 
0409   if (m_pixelEndcapElements) {
0410     m_pixelEndcapElements->SetRnrState(show);
0411     gEve->Redraw3D();
0412   }
0413 }
0414 
0415 void FWRPZViewGeometry::showTrackerBarrel(bool show) {
0416   if (!m_trackerBarrelElements && show) {
0417     m_trackerBarrelElements = new TEveElementList("TrackerBarrel");
0418 
0419     std::vector<unsigned int> ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::TIB);
0420     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0421       TEveGeoShape* shape = m_geom->getEveShape(*id);
0422       if (!shape)
0423         return;
0424       addToCompound(shape, kFWTrackerBarrelColorIndex);
0425       m_trackerBarrelElements->AddElement(shape);
0426     }
0427     ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::TOB);
0428     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0429       TEveGeoShape* shape = m_geom->getEveShape(*id);
0430       if (!shape)
0431         return;
0432       shape->SetTitle(Form("TrackerBarrel %d", *id));
0433       addToCompound(shape, kFWTrackerBarrelColorIndex);
0434       m_trackerBarrelElements->AddElement(shape);
0435     }
0436 
0437     AddElement(m_trackerBarrelElements);
0438     importNew(m_trackerBarrelElements);
0439   }
0440 
0441   if (m_trackerBarrelElements) {
0442     m_trackerBarrelElements->SetRnrState(show);
0443     gEve->Redraw3D();
0444   }
0445 }
0446 
0447 void FWRPZViewGeometry::showTrackerEndcap(bool show) {
0448   if (!m_trackerEndcapElements && show) {
0449     m_trackerEndcapElements = new TEveElementList("TrackerEndcap");
0450 
0451     std::vector<unsigned int> ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::TID);
0452     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0453       TEveGeoShape* shape = m_geom->getEveShape(*id);
0454       addToCompound(shape, kFWTrackerEndcapColorIndex);
0455 
0456       if (!shape)
0457         return;
0458       m_trackerEndcapElements->AddElement(shape);
0459     }
0460     ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::TEC);
0461     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0462       TEveGeoShape* shape = m_geom->getEveShape(*id);
0463       shape->SetTitle(Form("TrackerEndcap %d", *id));
0464       if (!shape)
0465         return;
0466       addToCompound(shape, kFWTrackerEndcapColorIndex);
0467       m_trackerEndcapElements->AddElement(shape);
0468     }
0469 
0470     AddElement(m_trackerEndcapElements);
0471     importNew(m_trackerEndcapElements);
0472   }
0473 
0474   if (m_trackerEndcapElements) {
0475     m_trackerEndcapElements->SetRnrState(show);
0476     gEve->Redraw3D();
0477   }
0478 }
0479 
0480 //---------------------------------------------------------
0481 void FWRPZViewGeometry::showRpcEndcap(bool show) {
0482   if (!m_rpcEndcapElements && show) {
0483     m_rpcEndcapElements = new TEveElementList("RpcEndcap");
0484 
0485     std::vector<RPCDetId> ids;
0486     int mxSt = m_geom->versionInfo().haveExtraDet("RE4") ? 4 : 3;
0487     for (int region = -1; region <= 1; ++region) {
0488       if (region == 0)
0489         continue;
0490       for (int ring = 2; ring <= 3; ++ring) {
0491         for (int station = 1; station <= mxSt; ++station) {
0492           int sector = 1;
0493           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 1));
0494           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 2));
0495           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 3));
0496           if (ring == 2 && station == 1) {  // 2 layers in ring 2 station 1 up
0497             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 1));
0498             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 2));
0499             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 3));
0500           }
0501           sector = 5;
0502           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 1));
0503           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 2));
0504           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 3));
0505 
0506           if (ring == 2 && station == 1) {  // 2 layers in ring 2 station 1 down
0507             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 1));
0508             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 2));
0509             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 3));
0510           }
0511         }
0512       }
0513     }
0514 
0515     for (std::vector<RPCDetId>::iterator i = ids.begin(); i != ids.end(); ++i) {
0516       TEveGeoShape* shape = m_geom->getEveShape(i->rawId());
0517       if (!shape)
0518         return;
0519       addToCompound(shape, kFWMuonEndcapLineColorIndex);
0520       m_rpcEndcapElements->AddElement(shape);
0521       gEve->AddToListTree(shape, true);
0522     }
0523 
0524     AddElement(m_rpcEndcapElements);
0525     importNew(m_rpcEndcapElements);
0526   }
0527 
0528   if (m_rpcEndcapElements) {
0529     m_rpcEndcapElements->SetRnrState(show);
0530     gEve->Redraw3D();
0531   }
0532 }
0533 
0534 //______________________________________________________________________________
0535 
0536 void FWRPZViewGeometry::showGEM(bool show) {
0537   // hardcoded gem and me0; need to find better way for different gem geometries
0538   if (!m_GEMElements && show) {
0539     m_GEMElements = new TEveElementList("GEM");
0540 
0541     for (Int_t iRegion = GEMDetId::minRegionId; iRegion <= GEMDetId::maxRegionId; iRegion = iRegion + 2) {
0542       int iStation = 1;
0543       int iRing = 1;
0544       int iLayer = 1;
0545 
0546       int carr[4] = {10, 11, 29, 30};
0547       for (int i = 0; i < 4; ++i) {
0548         int iChamber = carr[i];
0549         int iRoll = 0;
0550         try {
0551           GEMDetId id(iRegion, iRing, iStation, iLayer, iChamber, iRoll);
0552           TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
0553           if (shape) {
0554             addToCompound(shape, kFWMuonEndcapLineColorIndex);
0555             m_GEMElements->AddElement(shape);
0556             gEve->AddToListTree(shape, true);
0557           }
0558         } catch (cms::Exception& e) {
0559           fwLog(fwlog::kError) << "FWRPZViewGeomtery " << e << std::endl;
0560         }
0561       }
0562     }
0563 
0564     AddElement(m_GEMElements);
0565     importNew(m_GEMElements);
0566   }
0567 
0568   if (m_GEMElements) {
0569     m_GEMElements->SetRnrState(show);
0570     gEve->Redraw3D();
0571   }
0572 }
0573 
0574 void FWRPZViewGeometry::showME0(bool show) {
0575   if (!m_ME0Elements && show) {
0576     m_ME0Elements = new TEveElementList("ME0");
0577 
0578     for (Int_t iRegion = ME0DetId::minRegionId; iRegion <= ME0DetId::maxRegionId; iRegion = iRegion + 2) {
0579       for (Int_t iLayer = 1; iLayer <= 6; ++iLayer) {
0580         for (Int_t iChamber = 1; iChamber <= 18; ++iChamber) {
0581           Int_t iRoll = 1;
0582           ME0DetId id(iRegion, iLayer, iChamber, iRoll);
0583           TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
0584           if (shape) {
0585             addToCompound(shape, kFWMuonEndcapLineColorIndex);
0586             m_ME0Elements->AddElement(shape);
0587             gEve->AddToListTree(shape, true);
0588           }
0589         }
0590       }
0591     }
0592 
0593     AddElement(m_ME0Elements);
0594     importNew(m_ME0Elements);
0595   }
0596   if (m_ME0Elements) {
0597     m_ME0Elements->SetRnrState(show);
0598     gEve->Redraw3D();
0599   }
0600 }
0601 
0602 //______________________________________________________________________________
0603 
0604 void FWRPZViewGeometry::showMtdBarrel(bool show) {
0605   if (!m_mtdBarrelElements && show) {
0606     m_mtdBarrelElements = new TEveElementList("MtdBarrel");
0607 
0608     std::vector<unsigned int> ids = m_geom->getMatchedIds(FWGeometry::Forward, FWGeometry::PixelBarrel);
0609     for (std::vector<unsigned int>::const_iterator mtdId = ids.begin(); mtdId != ids.end(); ++mtdId) {
0610       MTDDetId id(*mtdId);
0611       if (id.mtdSubDetector() != MTDDetId::MTDType::BTL)
0612         continue;
0613 
0614       TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
0615       shape->SetTitle(Form("MTD barrel %d", id.rawId()));
0616 
0617       addToCompound(shape, kFWMtdBarrelColorIndex);
0618       m_mtdBarrelElements->AddElement(shape);
0619     }
0620 
0621     AddElement(m_mtdBarrelElements);
0622     importNew(m_mtdBarrelElements);
0623   }
0624 
0625   if (m_mtdBarrelElements) {
0626     m_mtdBarrelElements->SetRnrState(show);
0627     gEve->Redraw3D();
0628   }
0629 }
0630 
0631 void FWRPZViewGeometry::showMtdEndcap(bool show) {
0632   if (!m_mtdEndcapElements && show) {
0633     m_mtdEndcapElements = new TEveElementList("MtdEndcap");
0634 
0635     TEveElement* disk1ZposUp =
0636         makeShape(m_context.mtdEtlR1(), m_context.mtdEtlR2(), m_context.mtdEtlZ1(1), m_context.mtdEtlZ2(1));
0637     addToCompound(disk1ZposUp, kFWMtdEndcapColorIndex);
0638     m_mtdEndcapElements->AddElement(disk1ZposUp);
0639     TEveElement* disk1ZposDw =
0640         makeShape(-m_context.mtdEtlR1(), -m_context.mtdEtlR2(), m_context.mtdEtlZ1(1), m_context.mtdEtlZ2(1));
0641     addToCompound(disk1ZposDw, kFWMtdEndcapColorIndex);
0642     m_mtdEndcapElements->AddElement(disk1ZposDw);
0643 
0644     TEveElement* disk2ZposUp =
0645         makeShape(m_context.mtdEtlR1(), m_context.mtdEtlR2(), m_context.mtdEtlZ1(2), m_context.mtdEtlZ2(2));
0646     addToCompound(disk2ZposUp, kFWMtdEndcapColorIndex);
0647     m_mtdEndcapElements->AddElement(disk2ZposUp);
0648     TEveElement* disk2ZposDw =
0649         makeShape(-m_context.mtdEtlR1(), -m_context.mtdEtlR2(), m_context.mtdEtlZ1(2), m_context.mtdEtlZ2(2));
0650     addToCompound(disk2ZposDw, kFWMtdEndcapColorIndex);
0651     m_mtdEndcapElements->AddElement(disk2ZposDw);
0652 
0653     TEveElement* disk1ZnegUp =
0654         makeShape(m_context.mtdEtlR1(), m_context.mtdEtlR2(), -m_context.mtdEtlZ1(1), -m_context.mtdEtlZ2(1));
0655     addToCompound(disk1ZnegUp, kFWMtdEndcapColorIndex);
0656     m_mtdEndcapElements->AddElement(disk1ZnegUp);
0657     TEveElement* disk1ZnegDw =
0658         makeShape(-m_context.mtdEtlR1(), -m_context.mtdEtlR2(), -m_context.mtdEtlZ1(1), -m_context.mtdEtlZ2(1));
0659     addToCompound(disk1ZnegDw, kFWMtdEndcapColorIndex);
0660     m_mtdEndcapElements->AddElement(disk1ZnegDw);
0661 
0662     TEveElement* disk2ZnegUp =
0663         makeShape(m_context.mtdEtlR1(), m_context.mtdEtlR2(), -m_context.mtdEtlZ1(2), -m_context.mtdEtlZ2(2));
0664     addToCompound(disk2ZnegUp, kFWMtdEndcapColorIndex);
0665     m_mtdEndcapElements->AddElement(disk2ZnegUp);
0666     TEveElement* disk2ZnegDw =
0667         makeShape(-m_context.mtdEtlR1(), -m_context.mtdEtlR2(), -m_context.mtdEtlZ1(2), -m_context.mtdEtlZ2(2));
0668     addToCompound(disk2ZnegDw, kFWMtdEndcapColorIndex);
0669     m_mtdEndcapElements->AddElement(disk2ZnegDw);
0670 
0671     AddElement(m_mtdEndcapElements);
0672     importNew(m_mtdEndcapElements);
0673   }
0674 
0675   if (m_mtdEndcapElements) {
0676     m_mtdEndcapElements->SetRnrState(show);
0677     gEve->Redraw3D();
0678   }
0679 }
0680 
0681 //-------------------------------------
0682 
0683 void FWRPZViewGeometry::importNew(TEveElementList* x) {
0684   TEveProjected* proj = *BeginProjecteds();
0685   proj->GetManager()->SubImportElements(x, proj->GetProjectedAsElement());
0686 }