Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:18

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 //
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   SetElementName("RPZGeomShared");
0069 }
0070 
0071 // FWRPZViewGeometry::FWRPZViewGeometry(const FWRPZViewGeometry& rhs)
0072 // {
0073 //    // do actual copying here;
0074 // }
0075 
0076 FWRPZViewGeometry::~FWRPZViewGeometry() {
0077   m_rhoPhiGeo->DecDenyDestroy();
0078   m_rhoZGeo->DecDenyDestroy();
0079 }
0080 
0081 //______________________________________________________________________________
0082 
0083 void FWRPZViewGeometry::initStdGeoElements(const FWViewType::EType type) {
0084   if (m_geom->isEmpty())
0085     return;
0086 
0087   if (type == FWViewType::kRhoZ) {
0088     AddElement(makeMuonGeometryRhoZ());
0089     AddElement(makeCaloOutlineRhoZ());
0090   } else {
0091     AddElement(makeMuonGeometryRhoPhi());
0092     AddElement(makeCaloOutlineRhoPhi());
0093   }
0094 }
0095 
0096 //______________________________________________________________________________
0097 
0098 TEveElement* FWRPZViewGeometry::makeCaloOutlineRhoZ() {
0099   using namespace fireworks;
0100 
0101   float ri = m_context.caloZ2() * tan(2 * atan(exp(-m_context.caloMaxEta())));
0102 
0103   TEveStraightLineSet* el = new TEveStraightLineSet("TrackerRhoZoutline");
0104   el->SetPickable(kFALSE);
0105   addToCompound(el, kFWTrackerBarrelColorIndex, false);
0106 
0107   el->AddLine(0, m_context.caloR1(), -m_context.caloZ1(), 0, m_context.caloR1(), m_context.caloZ1());
0108   el->AddLine(0, -m_context.caloR1(), m_context.caloZ1(), 0, -m_context.caloR1(), -m_context.caloZ1());
0109 
0110   el->AddLine(0, -m_context.caloR2(), m_context.caloZ2(), 0, -ri, m_context.caloZ2());
0111   el->AddLine(0, ri, m_context.caloZ2(), 0, m_context.caloR2(), m_context.caloZ2());
0112 
0113   el->AddLine(0, -m_context.caloR2(), -m_context.caloZ2(), 0, -ri, -m_context.caloZ2());
0114   el->AddLine(0, ri, -m_context.caloZ2(), 0, m_context.caloR2(), -m_context.caloZ2());
0115 
0116   return el;
0117 }
0118 
0119 TEveElement* FWRPZViewGeometry::makeCaloOutlineRhoPhi() {
0120   TEveStraightLineSet* el = new TEveStraightLineSet("TrackerRhoPhi");
0121   addToCompound(el, kFWTrackerBarrelColorIndex, false);
0122 
0123   el->SetLineColor(m_context.colorManager()->geomColor(kFWTrackerBarrelColorIndex));
0124   const unsigned int nSegments = 100;
0125   const double r = m_context.caloR1();
0126   for (unsigned int i = 1; i <= nSegments; ++i)
0127     el->AddLine(r * sin(TMath::TwoPi() / nSegments * (i - 1)),
0128                 r * cos(TMath::TwoPi() / nSegments * (i - 1)),
0129                 0,
0130                 r * sin(TMath::TwoPi() / nSegments * i),
0131                 r * cos(TMath::TwoPi() / nSegments * i),
0132                 0);
0133 
0134   TEvePointSet* ref = new TEvePointSet("reference");
0135   ref->SetTitle("(0,0,0)");
0136   ref->SetMarkerStyle(4);
0137   ref->SetMarkerColor(kWhite);
0138   ref->SetNextPoint(0., 0., 0.);
0139   el->AddElement(ref);
0140 
0141   return el;
0142 }
0143 
0144 //______________________________________________________________________________
0145 
0146 TEveElement* FWRPZViewGeometry::makeMuonGeometryRhoPhi(void) {
0147   Int_t iWheel = 0;
0148 
0149   // rho-phi view
0150   TEveCompound* container = new TEveCompound("MuonRhoPhi");
0151 
0152   for (Int_t iStation = 1; iStation <= 4; ++iStation) {
0153     for (Int_t iSector = 1; iSector <= 14; ++iSector) {
0154       if (iStation < 4 && iSector > 12)
0155         continue;
0156       DTChamberId id(iWheel, iStation, iSector);
0157       TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
0158       if (shape) {
0159         shape->SetMainColor(m_colorComp[kFWMuonBarrelLineColorIndex]->GetMainColor());
0160         addToCompound(shape, kFWMuonBarrelLineColorIndex);
0161         container->AddElement(shape);
0162       }
0163     }
0164   }
0165   return container;
0166 }
0167 namespace {
0168 
0169   //void addLibe
0170 
0171 }
0172 //______________________________________________________________________________
0173 
0174 TEveElement* FWRPZViewGeometry::makeMuonGeometryRhoZ(void) {
0175   TEveElementList* container = new TEveElementList("MuonRhoZ");
0176 
0177   {
0178     TEveCompound* dtContainer = new TEveCompound("DT");
0179     for (Int_t iWheel = -2; iWheel <= 2; ++iWheel) {
0180       for (Int_t iStation = 1; iStation <= 4; ++iStation) {
0181         float min_rho(1000), max_rho(0), min_z(2000), max_z(-2000);
0182 
0183         // This will give us a quarter of DTs
0184         // which is enough for our projection
0185         for (Int_t iSector = 1; iSector <= 4; ++iSector) {
0186           DTChamberId id(iWheel, iStation, iSector);
0187           unsigned int rawid = id.rawId();
0188           FWGeometry::IdToInfoItr det = m_geom->find(rawid);
0189           if (det == m_geom->mapEnd())
0190             return container;
0191           estimateProjectionSizeDT(*det, min_rho, max_rho, min_z, max_z);
0192         }
0193         if (min_rho > max_rho || min_z > max_z)
0194           continue;
0195         TEveElement* se = makeShape(min_rho, max_rho, min_z, max_z);
0196         addToCompound(se, kFWMuonBarrelLineColorIndex);
0197         dtContainer->AddElement(se);
0198         se = makeShape(-max_rho, -min_rho, min_z, max_z);
0199         addToCompound(se, kFWMuonBarrelLineColorIndex);
0200         dtContainer->AddElement(se);
0201       }
0202     }
0203 
0204     container->AddElement(dtContainer);
0205   }
0206   {
0207     // addcsc
0208     TEveCompound* cscContainer = new TEveCompound("CSC");
0209     std::vector<CSCDetId> ids;
0210     for (int endcap = CSCDetId::minEndcapId(); endcap <= CSCDetId::maxEndcapId(); ++endcap) {
0211       for (int station = 1; station <= 4; ++station) {
0212         ids.push_back(CSCDetId(endcap, station, 2, 10, 0));  //outer ring up
0213         ids.push_back(CSCDetId(endcap, station, 2, 11, 0));  //outer ring up
0214 
0215         ids.push_back(CSCDetId(endcap, station, 2, 28, 0));  //outer ring down
0216         ids.push_back(CSCDetId(endcap, station, 2, 29, 0));  //outer ring down
0217 
0218         ids.push_back(CSCDetId(endcap, station, 1, 5, 0));  //inner ring up
0219         ids.push_back(CSCDetId(endcap, station, 1, 6, 0));  //inner ring up
0220 
0221         int off = (station == 1) ? 10 : 0;
0222         ids.push_back(CSCDetId(endcap, station, 1, 15 + off, 0));  //inner ring down
0223         ids.push_back(CSCDetId(endcap, station, 1, 16 + off, 0));  //inner ring down
0224       }
0225       ids.push_back(CSCDetId(endcap, 1, 3, 10, 0));  // ring 3 down
0226       ids.push_back(CSCDetId(endcap, 1, 3, 28, 0));  // ring 3 down
0227     }
0228     for (std::vector<CSCDetId>::iterator i = ids.begin(); i != ids.end(); ++i) {
0229       unsigned int rawid = i->rawId();
0230       TEveGeoShape* shape = m_geom->getEveShape(rawid);
0231       if (!shape)
0232         return cscContainer;
0233       addToCompound(shape, kFWMuonEndcapLineColorIndex);
0234       shape->SetName(Form(" e:%d r:%d s:%d chamber %d", i->endcap(), i->ring(), i->station(), i->chamber()));
0235       cscContainer->AddElement(shape);
0236     }
0237     container->AddElement(cscContainer);
0238   }
0239 
0240   return container;
0241 }
0242 
0243 //______________________________________________________________________________
0244 
0245 TEveGeoShape* FWRPZViewGeometry::makeShape(double min_rho, double max_rho, double min_z, double max_z) {
0246   TEveTrans t;
0247   t(1, 1) = 1;
0248   t(1, 2) = 0;
0249   t(1, 3) = 0;
0250   t(2, 1) = 0;
0251   t(2, 2) = 1;
0252   t(2, 3) = 0;
0253   t(3, 1) = 0;
0254   t(3, 2) = 0;
0255   t(3, 3) = 1;
0256   t(1, 4) = 0;
0257   t(2, 4) = (min_rho + max_rho) / 2;
0258   t(3, 4) = (min_z + max_z) / 2;
0259 
0260   TEveGeoShape* shape = new TEveGeoShape;
0261   shape->SetTransMatrix(t.Array());
0262 
0263   shape->SetRnrSelf(kTRUE);
0264   shape->SetRnrChildren(kTRUE);
0265   TGeoBBox* box = new TGeoBBox(0, (max_rho - min_rho) / 2, (max_z - min_z) / 2);
0266   shape->SetShape(box);
0267 
0268   return shape;
0269 }
0270 
0271 //______________________________________________________________________________
0272 
0273 void FWRPZViewGeometry::estimateProjectionSizeDT(
0274     const FWGeometry::GeomDetInfo& info, float& min_rho, float& max_rho, float& min_z, float& max_z) {
0275   // we will test 5 points on both sides ( +/- z)
0276   float local[3], global[3];
0277 
0278   float dX = info.shape[1];
0279   float dY = info.shape[2];
0280   float dZ = info.shape[3];
0281 
0282   local[0] = 0;
0283   local[1] = 0;
0284   local[2] = dZ;
0285   m_geom->localToGlobal(info, local, global);
0286   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0287 
0288   local[0] = dX;
0289   local[1] = dY;
0290   local[2] = dZ;
0291   m_geom->localToGlobal(info, local, global);
0292   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0293 
0294   local[0] = -dX;
0295   local[1] = dY;
0296   local[2] = dZ;
0297   m_geom->localToGlobal(info, local, global);
0298   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0299 
0300   local[0] = dX;
0301   local[1] = -dY;
0302   local[2] = dZ;
0303   m_geom->localToGlobal(info, local, global);
0304   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0305 
0306   local[0] = -dX;
0307   local[1] = -dY;
0308   local[2] = dZ;
0309   m_geom->localToGlobal(info, local, global);
0310   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0311 
0312   local[0] = 0;
0313   local[1] = 0;
0314   local[2] = -dZ;
0315   m_geom->localToGlobal(info, local, global);
0316   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0317 
0318   local[0] = dX;
0319   local[1] = dY;
0320   local[2] = -dZ;
0321   m_geom->localToGlobal(info, local, global);
0322   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0323 
0324   local[0] = -dX;
0325   local[1] = dY;
0326   local[2] = -dZ;
0327   m_geom->localToGlobal(info, local, global);
0328   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0329 
0330   local[0] = dX;
0331   local[1] = -dY;
0332   local[2] = -dZ;
0333   m_geom->localToGlobal(info, local, global);
0334   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0335 
0336   local[0] = -dX;
0337   local[1] = -dY;
0338   local[2] = -dZ;
0339   m_geom->localToGlobal(info, local, global);
0340   estimateProjectionSize(global, min_rho, max_rho, min_z, max_z);
0341 }
0342 
0343 void FWRPZViewGeometry::estimateProjectionSize(
0344     const float* global, float& min_rho, float& max_rho, float& min_z, float& max_z) {
0345   double rho = sqrt(global[0] * global[0] + global[1] * global[1]);
0346   if (min_rho > rho)
0347     min_rho = rho;
0348   if (max_rho < rho)
0349     max_rho = rho;
0350   if (min_z > global[2])
0351     min_z = global[2];
0352   if (max_z < global[2])
0353     max_z = global[2];
0354 }
0355 
0356 // ATODO:: check white vertex -> shouldn't be relative to background
0357 //         when detruction ?
0358 
0359 // ATODO why color is not set in 3D original, why cast to polygonsetprojected after projected ????
0360 // is geom color dynamic --- independent of projection manager
0361 
0362 // NOTE geomtry MuonRhoZAdanced renamed to  MuonRhoZ
0363 
0364 //==============================================================================
0365 //==============================================================================
0366 
0367 void FWRPZViewGeometry::showPixelBarrel(bool show) {
0368   if (!m_pixelBarrelElements && show) {
0369     m_pixelBarrelElements = new TEveElementList("PixelBarrel");
0370     AddElement(m_pixelBarrelElements);
0371     std::vector<unsigned int> ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::PixelBarrel);
0372     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0373       TEveGeoShape* shape = m_geom->getEveShape(*id);
0374       if (!shape)
0375         return;
0376       shape->SetTitle(Form("PixelBarrel %d", *id));
0377       addToCompound(shape, kFWPixelBarrelColorIndex);
0378       m_pixelBarrelElements->AddElement(shape);
0379     }
0380     importNew(m_pixelBarrelElements);
0381   }
0382 
0383   if (m_pixelBarrelElements) {
0384     m_pixelBarrelElements->SetRnrState(show);
0385     gEve->Redraw3D();
0386   }
0387 }
0388 
0389 void FWRPZViewGeometry::showPixelEndcap(bool show) {
0390   if (!m_pixelEndcapElements && show) {
0391     m_pixelEndcapElements = new TEveElementList("PixelEndcap");
0392 
0393     std::vector<unsigned int> ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::PixelEndcap);
0394     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0395       TEveGeoShape* shape = m_geom->getEveShape(*id);
0396       if (!shape)
0397         return;
0398       shape->SetTitle(Form("PixelEndCap %d", *id));
0399       addToCompound(shape, kFWPixelEndcapColorIndex);
0400       m_pixelEndcapElements->AddElement(shape);
0401     }
0402 
0403     AddElement(m_pixelEndcapElements);
0404     importNew(m_pixelEndcapElements);
0405   }
0406 
0407   if (m_pixelEndcapElements) {
0408     m_pixelEndcapElements->SetRnrState(show);
0409     gEve->Redraw3D();
0410   }
0411 }
0412 
0413 void FWRPZViewGeometry::showTrackerBarrel(bool show) {
0414   if (!m_trackerBarrelElements && show) {
0415     m_trackerBarrelElements = new TEveElementList("TrackerBarrel");
0416 
0417     std::vector<unsigned int> ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::TIB);
0418     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0419       TEveGeoShape* shape = m_geom->getEveShape(*id);
0420       if (!shape)
0421         return;
0422       addToCompound(shape, kFWTrackerBarrelColorIndex);
0423       m_trackerBarrelElements->AddElement(shape);
0424     }
0425     ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::TOB);
0426     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0427       TEveGeoShape* shape = m_geom->getEveShape(*id);
0428       if (!shape)
0429         return;
0430       shape->SetTitle(Form("TrackerBarrel %d", *id));
0431       addToCompound(shape, kFWTrackerBarrelColorIndex);
0432       m_trackerBarrelElements->AddElement(shape);
0433     }
0434 
0435     AddElement(m_trackerBarrelElements);
0436     importNew(m_trackerBarrelElements);
0437   }
0438 
0439   if (m_trackerBarrelElements) {
0440     m_trackerBarrelElements->SetRnrState(show);
0441     gEve->Redraw3D();
0442   }
0443 }
0444 
0445 void FWRPZViewGeometry::showTrackerEndcap(bool show) {
0446   if (!m_trackerEndcapElements && show) {
0447     m_trackerEndcapElements = new TEveElementList("TrackerEndcap");
0448 
0449     std::vector<unsigned int> ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::TID);
0450     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0451       TEveGeoShape* shape = m_geom->getEveShape(*id);
0452       addToCompound(shape, kFWTrackerEndcapColorIndex);
0453 
0454       if (!shape)
0455         return;
0456       m_trackerEndcapElements->AddElement(shape);
0457     }
0458     ids = m_geom->getMatchedIds(FWGeometry::Tracker, FWGeometry::TEC);
0459     for (std::vector<unsigned int>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
0460       TEveGeoShape* shape = m_geom->getEveShape(*id);
0461       shape->SetTitle(Form("TrackerEndcap %d", *id));
0462       if (!shape)
0463         return;
0464       addToCompound(shape, kFWTrackerEndcapColorIndex);
0465       m_trackerEndcapElements->AddElement(shape);
0466     }
0467 
0468     AddElement(m_trackerEndcapElements);
0469     importNew(m_trackerEndcapElements);
0470   }
0471 
0472   if (m_trackerEndcapElements) {
0473     m_trackerEndcapElements->SetRnrState(show);
0474     gEve->Redraw3D();
0475   }
0476 }
0477 
0478 //---------------------------------------------------------
0479 void FWRPZViewGeometry::showRpcEndcap(bool show) {
0480   if (!m_rpcEndcapElements && show) {
0481     m_rpcEndcapElements = new TEveElementList("RpcEndcap");
0482 
0483     std::vector<RPCDetId> ids;
0484     int mxSt = m_geom->versionInfo().haveExtraDet("RE4") ? 4 : 3;
0485     for (int region = -1; region <= 1; ++region) {
0486       if (region == 0)
0487         continue;
0488       for (int ring = 2; ring <= 3; ++ring) {
0489         for (int station = 1; station <= mxSt; ++station) {
0490           int sector = 1;
0491           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 1));
0492           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 2));
0493           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 3));
0494           if (ring == 2 && station == 1) {  // 2 layers in ring 2 station 1 up
0495             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 1));
0496             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 2));
0497             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 3));
0498           }
0499           sector = 5;
0500           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 1));
0501           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 2));
0502           ids.push_back(RPCDetId(region, ring, station, sector, 1, 1, 3));
0503 
0504           if (ring == 2 && station == 1) {  // 2 layers in ring 2 station 1 down
0505             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 1));
0506             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 2));
0507             ids.push_back(RPCDetId(region, ring, station, sector, 1, 2, 3));
0508           }
0509         }
0510       }
0511     }
0512 
0513     for (std::vector<RPCDetId>::iterator i = ids.begin(); i != ids.end(); ++i) {
0514       TEveGeoShape* shape = m_geom->getEveShape(i->rawId());
0515       if (!shape)
0516         return;
0517       addToCompound(shape, kFWMuonEndcapLineColorIndex);
0518       m_rpcEndcapElements->AddElement(shape);
0519       gEve->AddToListTree(shape, true);
0520     }
0521 
0522     AddElement(m_rpcEndcapElements);
0523     importNew(m_rpcEndcapElements);
0524   }
0525 
0526   if (m_rpcEndcapElements) {
0527     m_rpcEndcapElements->SetRnrState(show);
0528     gEve->Redraw3D();
0529   }
0530 }
0531 
0532 //______________________________________________________________________________
0533 
0534 void FWRPZViewGeometry::showGEM(bool show) {
0535   // hardcoded gem and me0; need to find better way for different gem geometries
0536   if (!m_GEMElements && show) {
0537     m_GEMElements = new TEveElementList("GEM");
0538 
0539     for (Int_t iRegion = GEMDetId::minRegionId; iRegion <= GEMDetId::maxRegionId; iRegion = iRegion + 2) {
0540       int iStation = 1;
0541       int iRing = 1;
0542       int iLayer = 1;
0543 
0544       int carr[4] = {10, 11, 29, 30};
0545       for (int i = 0; i < 4; ++i) {
0546         int iChamber = carr[i];
0547         int iRoll = 0;
0548         try {
0549           GEMDetId id(iRegion, iRing, iStation, iLayer, iChamber, iRoll);
0550           TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
0551           if (shape) {
0552             addToCompound(shape, kFWMuonEndcapLineColorIndex);
0553             m_GEMElements->AddElement(shape);
0554             gEve->AddToListTree(shape, true);
0555           }
0556         } catch (cms::Exception& e) {
0557           fwLog(fwlog::kError) << "FWRPZViewGeomtery " << e << std::endl;
0558         }
0559       }
0560     }
0561 
0562     AddElement(m_GEMElements);
0563     importNew(m_GEMElements);
0564   }
0565 
0566   if (m_GEMElements) {
0567     m_GEMElements->SetRnrState(show);
0568     gEve->Redraw3D();
0569   }
0570 }
0571 
0572 void FWRPZViewGeometry::showME0(bool show) {
0573   if (!m_ME0Elements && show) {
0574     m_ME0Elements = new TEveElementList("ME0");
0575 
0576     for (Int_t iRegion = ME0DetId::minRegionId; iRegion <= ME0DetId::maxRegionId; iRegion = iRegion + 2) {
0577       for (Int_t iLayer = 1; iLayer <= 6; ++iLayer) {
0578         for (Int_t iChamber = 1; iChamber <= 18; ++iChamber) {
0579           Int_t iRoll = 1;
0580           ME0DetId id(iRegion, iLayer, iChamber, iRoll);
0581           TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
0582           if (shape) {
0583             addToCompound(shape, kFWMuonEndcapLineColorIndex);
0584             m_ME0Elements->AddElement(shape);
0585             gEve->AddToListTree(shape, true);
0586           }
0587         }
0588       }
0589     }
0590 
0591     AddElement(m_ME0Elements);
0592     importNew(m_ME0Elements);
0593   }
0594   if (m_ME0Elements) {
0595     m_ME0Elements->SetRnrState(show);
0596     gEve->Redraw3D();
0597   }
0598 }
0599 
0600 //-------------------------------------
0601 
0602 void FWRPZViewGeometry::importNew(TEveElementList* x) {
0603   TEveProjected* proj = *BeginProjecteds();
0604   proj->GetManager()->SubImportElements(x, proj->GetProjectedAsElement());
0605 }