00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <sstream>
00016
00017
00018
00019 #include "TEveManager.h"
00020 #include "TEveGeoNode.h"
00021
00022 #include "Fireworks/Core/interface/FW3DViewGeometry.h"
00023 #include "Fireworks/Core/interface/FWGeometry.h"
00024 #include "Fireworks/Core/interface/TEveElementIter.h"
00025 #include "Fireworks/Core/interface/Context.h"
00026 #include "Fireworks/Core/interface/FWColorManager.h"
00027
00028 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00029 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00030
00031 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
00032 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 FW3DViewGeometry::FW3DViewGeometry(const fireworks::Context& context):
00045 FWViewGeometryList(context, false),
00046 m_muonBarrelElements(0), m_muonBarrelFullElements(0),
00047 m_muonEndcapElements(0), m_muonEndcapFullElements(0),
00048 m_pixelBarrelElements(0),
00049 m_pixelEndcapElements(0),
00050 m_trackerBarrelElements(0),
00051 m_trackerEndcapElements(0)
00052 {
00053
00054 SetElementName("3D Geometry");
00055 }
00056
00057
00058
00059
00060
00061
00062 FW3DViewGeometry::~FW3DViewGeometry()
00063 {
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 void
00080 FW3DViewGeometry::showMuonBarrel( bool showMuonBarrel )
00081 {
00082 if( !m_muonBarrelElements && showMuonBarrel )
00083 {
00084 m_muonBarrelElements = new TEveElementList( "DT" );
00085 for( Int_t iWheel = -2; iWheel <= 2; ++iWheel )
00086 {
00087 for ( Int_t iStation = 1; iStation <= 4; ++iStation )
00088 {
00089
00090
00091 if( iWheel == -2 || iWheel == 2 || iStation == 4 )
00092 {
00093 std::ostringstream s;
00094 s << "Station" << iStation;
00095 TEveElementList* cStation = new TEveElementList( s.str().c_str() );
00096 m_muonBarrelElements->AddElement( cStation );
00097 for( Int_t iSector = 1 ; iSector <= 14; ++iSector )
00098 {
00099 if( iStation < 4 && iSector > 12 ) continue;
00100 DTChamberId id( iWheel, iStation, iSector );
00101 TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
00102 addToCompound(shape, kFWMuonBarrelLineColorIndex);
00103 cStation->AddElement( shape );
00104 }
00105 }
00106 }
00107 }
00108 AddElement( m_muonBarrelElements );
00109 }
00110
00111 if( m_muonBarrelElements )
00112 {
00113 m_muonBarrelElements->SetRnrState( showMuonBarrel );
00114 gEve->Redraw3D();
00115 }
00116 }
00117
00118 void
00119 FW3DViewGeometry::showMuonBarrelFull(bool showMuonBarrel)
00120 {
00121 if (!m_muonBarrelFullElements && showMuonBarrel)
00122 {
00123 m_muonBarrelFullElements = new TEveElementList( "DT Full" );
00124 for (Int_t iWheel = -2; iWheel <= 2; ++iWheel)
00125 {
00126 TEveElementList* cWheel = new TEveElementList(TString::Format("Wheel %d", iWheel));
00127 m_muonBarrelFullElements->AddElement(cWheel);
00128 for (Int_t iStation = 1; iStation <= 4; ++iStation)
00129 {
00130 TEveElementList* cStation = new TEveElementList(TString::Format("Station %d", iStation));
00131 cWheel->AddElement(cStation);
00132 for (Int_t iSector = 1 ; iSector <= 14; ++iSector)
00133 {
00134 if( iStation < 4 && iSector > 12 ) continue;
00135 DTChamberId id( iWheel, iStation, iSector );
00136 TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
00137 shape->SetTitle(TString::Format("DT: W=%d, S=%d, Sec=%d\ndet-id=%u",
00138 iWheel, iStation, iSector, id.rawId()));
00139 addToCompound(shape, kFWMuonBarrelLineColorIndex);
00140 cStation->AddElement(shape);
00141 }
00142 }
00143 }
00144 AddElement(m_muonBarrelFullElements);
00145 }
00146
00147 if (m_muonBarrelFullElements)
00148 {
00149 m_muonBarrelFullElements->SetRnrState(showMuonBarrel);
00150 gEve->Redraw3D();
00151 }
00152 }
00153
00154
00155 void
00156 FW3DViewGeometry::showMuonEndcap( bool showMuonEndcap )
00157 {
00158 if( showMuonEndcap && !m_muonEndcapElements )
00159 {
00160 m_muonEndcapElements = new TEveElementList( "CSC" );
00161 for( Int_t iEndcap = 1; iEndcap <= 2; ++iEndcap )
00162 {
00163 TEveElementList* cEndcap = 0;
00164 if( iEndcap == 1 )
00165 cEndcap = new TEveElementList( "Forward" );
00166 else
00167 cEndcap = new TEveElementList( "Backward" );
00168 m_muonEndcapElements->AddElement( cEndcap );
00169
00170
00171
00172
00173
00174 Int_t maxChambers = 36;
00175 for( Int_t iStation = 1; iStation <= 4; ++iStation )
00176 {
00177 std::ostringstream s; s << "Station" << iStation;
00178 TEveElementList* cStation = new TEveElementList( s.str().c_str() );
00179 cEndcap->AddElement( cStation );
00180 for( Int_t iRing = 1; iRing <= 4; ++iRing )
00181 {
00182 if( iStation > 1 && iRing > 2 ) continue;
00183 if( iStation > 3 && iRing > 1 ) continue;
00184 std::ostringstream s; s << "Ring" << iRing;
00185 TEveElementList* cRing = new TEveElementList( s.str().c_str() );
00186 cStation->AddElement( cRing );
00187 ( iRing == 1 && iStation > 1 ) ? ( maxChambers = 18 ) : ( maxChambers = 36 );
00188 for( Int_t iChamber = 1; iChamber <= maxChambers; ++iChamber )
00189 {
00190 Int_t iLayer = 0;
00191 CSCDetId id( iEndcap, iStation, iRing, iChamber, iLayer );
00192 TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
00193 shape->SetTitle(TString::Format("CSC: %s, S=%d, R=%d, C=%d\ndet-id=%u",
00194 cEndcap->GetName(), iStation, iRing, iChamber, id.rawId()));
00195
00196 addToCompound(shape, kFWMuonEndcapLineColorIndex);
00197 cRing->AddElement( shape );
00198 }
00199 }
00200 }
00201 }
00202 AddElement( m_muonEndcapElements );
00203 }
00204
00205 if( m_muonEndcapElements )
00206 {
00207 m_muonEndcapElements->SetRnrState( showMuonEndcap );
00208 gEve->Redraw3D();
00209 }
00210 }
00211
00212
00213 void
00214 FW3DViewGeometry::showPixelBarrel( bool showPixelBarrel )
00215 {
00216 if( showPixelBarrel && !m_pixelBarrelElements )
00217 {
00218 m_pixelBarrelElements = new TEveElementList( "PixelBarrel" );
00219 m_pixelBarrelElements->SetRnrState( showPixelBarrel );
00220 std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelBarrel );
00221 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00222 id != ids.end(); ++id )
00223 {
00224 TEveGeoShape* shape = m_geom->getEveShape( *id );
00225 PXBDetId idid = PXBDetId( *id );
00226 unsigned int layer = idid.layer();
00227 unsigned int ladder = idid.ladder();
00228 unsigned int module = idid.module();
00229
00230 shape->SetTitle( TString::Format( "PixelBarrel %d: Layer=%u, Ladder=%u, Module=%u",
00231 *id, layer, ladder, module ));
00232
00233 addToCompound(shape, kFWPixelBarrelColorIndex);
00234 m_pixelBarrelElements->AddElement( shape );
00235 }
00236 AddElement( m_pixelBarrelElements );
00237 }
00238
00239 if( m_pixelBarrelElements )
00240 {
00241 m_pixelBarrelElements->SetRnrState( showPixelBarrel );
00242 gEve->Redraw3D();
00243 }
00244 }
00245
00246
00247 void
00248 FW3DViewGeometry::showPixelEndcap(bool showPixelEndcap )
00249 {
00250 if( showPixelEndcap && ! m_pixelEndcapElements )
00251 {
00252 m_pixelEndcapElements = new TEveElementList( "PixelEndcap" );
00253 std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelEndcap );
00254 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00255 id != ids.end(); ++id )
00256 {
00257 TEveGeoShape* shape = m_geom->getEveShape( *id );
00258 PXFDetId idid = PXFDetId( *id );
00259 unsigned int side = idid.side();
00260 unsigned int disk = idid.disk();
00261 unsigned int blade = idid.blade();
00262 unsigned int panel = idid.panel();
00263 unsigned int module = idid.module();
00264
00265 shape->SetTitle( TString::Format( "PixelEndcap %d: Side=%u, Disk=%u, Blade=%u, Panel=%u, Module=%u",
00266 *id, side, disk, blade, panel, module ));
00267
00268 addToCompound(shape, kFWPixelEndcapColorIndex);
00269 m_pixelEndcapElements->AddElement( shape );
00270 }
00271 AddElement( m_pixelEndcapElements );
00272 }
00273
00274 if( m_pixelEndcapElements )
00275 {
00276 m_pixelEndcapElements->SetRnrState( showPixelEndcap );
00277 gEve->Redraw3D();
00278 }
00279 }
00280
00281
00282 void
00283 FW3DViewGeometry::showTrackerBarrel( bool showTrackerBarrel )
00284 {
00285 if( showTrackerBarrel && ! m_trackerBarrelElements )
00286 {
00287 m_trackerBarrelElements = new TEveElementList( "TrackerBarrel" );
00288 m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
00289 std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TIB );
00290 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00291 id != ids.end(); ++id )
00292 {
00293 TEveGeoShape* shape = m_geom->getEveShape( *id );
00294 addToCompound(shape, kFWTrackerBarrelColorIndex);
00295 m_trackerBarrelElements->AddElement( shape );
00296 }
00297 ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TOB );
00298 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00299 id != ids.end(); ++id )
00300 {
00301 TEveGeoShape* shape = m_geom->getEveShape( *id );
00302 shape->SetTitle(Form("TrackerBarrel %d",*id));
00303 addToCompound(shape, kFWTrackerBarrelColorIndex);
00304 m_trackerBarrelElements->AddElement( shape );
00305 }
00306 AddElement( m_trackerBarrelElements );
00307 }
00308
00309 if( m_trackerBarrelElements )
00310 {
00311 m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
00312 gEve->Redraw3D();
00313 }
00314 }
00315
00316
00317 void
00318 FW3DViewGeometry::showTrackerEndcap( bool showTrackerEndcap )
00319 {
00320 if( showTrackerEndcap && ! m_trackerEndcapElements )
00321 {
00322 m_trackerEndcapElements = new TEveElementList( "TrackerEndcap" );
00323 std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TID );
00324 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00325 id != ids.end(); ++id )
00326 {
00327 TEveGeoShape* shape = m_geom->getEveShape( *id );
00328 addToCompound(shape, kFWTrackerEndcapColorIndex);
00329 m_trackerEndcapElements->AddElement( shape );
00330 }
00331 ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TEC );
00332 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00333 id != ids.end(); ++id )
00334 {
00335 TEveGeoShape* shape = m_geom->getEveShape( *id );
00336
00337 shape->SetTitle(Form("TrackerEndcap %d",*id));
00338 addToCompound(shape, kFWTrackerEndcapColorIndex);
00339 m_trackerEndcapElements->AddElement( shape );
00340 }
00341 AddElement( m_trackerEndcapElements );
00342 }
00343
00344 if (m_trackerEndcapElements )
00345 {
00346 m_trackerEndcapElements->SetRnrState( showTrackerEndcap );
00347 gEve->Redraw3D();
00348 }
00349 }
00350
00351