Go to the documentation of this file.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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 FW3DViewGeometry::FW3DViewGeometry(const fireworks::Context& context):
00043 FWViewGeometryList(context, false),
00044 m_muonBarrelElements(0),
00045 m_muonEndcapElements(0),
00046 m_pixelBarrelElements(0),
00047 m_pixelEndcapElements(0),
00048 m_trackerBarrelElements(0),
00049 m_trackerEndcapElements(0)
00050 {
00051
00052 SetElementName("3D Geometry");
00053 }
00054
00055
00056
00057
00058
00059
00060 FW3DViewGeometry::~FW3DViewGeometry()
00061 {
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 void
00078 FW3DViewGeometry::showMuonBarrel( bool showMuonBarrel )
00079 {
00080 if( !m_muonBarrelElements && showMuonBarrel )
00081 {
00082 m_muonBarrelElements = new TEveElementList( "DT" );
00083 for( Int_t iWheel = -2; iWheel <= 2; ++iWheel )
00084 {
00085 for ( Int_t iStation = 1; iStation <= 4; ++iStation )
00086 {
00087
00088
00089 if( iWheel == -2 || iWheel == 2 || iStation == 4 )
00090 {
00091 std::ostringstream s;
00092 s << "Station" << iStation;
00093 TEveElementList* cStation = new TEveElementList( s.str().c_str() );
00094 m_muonBarrelElements->AddElement( cStation );
00095 for( Int_t iSector = 1 ; iSector <= 14; ++iSector )
00096 {
00097 if( iStation < 4 && iSector > 12 ) continue;
00098 DTChamberId id( iWheel, iStation, iSector );
00099 TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
00100 addToCompound(shape, kFWMuonBarrelLineColorIndex);
00101 cStation->AddElement( shape );
00102 }
00103 }
00104 }
00105 }
00106 AddElement( m_muonBarrelElements );
00107 }
00108
00109 if( m_muonBarrelElements )
00110 {
00111 m_muonBarrelElements->SetRnrState( showMuonBarrel );
00112 gEve->Redraw3D();
00113 }
00114 }
00115
00116
00117 void
00118 FW3DViewGeometry::showMuonEndcap( bool showMuonEndcap )
00119 {
00120 if( showMuonEndcap && !m_muonEndcapElements )
00121 {
00122 m_muonEndcapElements = new TEveElementList( "CSC" );
00123 for( Int_t iEndcap = 1; iEndcap <= 2; ++iEndcap )
00124 {
00125 TEveElementList* cEndcap = 0;
00126 if( iEndcap == 1 )
00127 cEndcap = new TEveElementList( "Forward" );
00128 else
00129 cEndcap = new TEveElementList( "Backward" );
00130 m_muonEndcapElements->AddElement( cEndcap );
00131
00132
00133
00134
00135
00136 Int_t maxChambers = 36;
00137 for( Int_t iStation = 1; iStation <= 4; ++iStation )
00138 {
00139 std::ostringstream s; s << "Station" << iStation;
00140 TEveElementList* cStation = new TEveElementList( s.str().c_str() );
00141 cEndcap->AddElement( cStation );
00142 for( Int_t iRing = 1; iRing <= 4; ++iRing )
00143 {
00144 if( iStation > 1 && iRing > 2 ) continue;
00145 if( iStation > 3 && iRing > 1 ) continue;
00146 std::ostringstream s; s << "Ring" << iRing;
00147 TEveElementList* cRing = new TEveElementList( s.str().c_str() );
00148 cStation->AddElement( cRing );
00149 ( iRing == 1 && iStation > 1 ) ? ( maxChambers = 18 ) : ( maxChambers = 36 );
00150 for( Int_t iChamber = 1; iChamber <= maxChambers; ++iChamber )
00151 {
00152 Int_t iLayer = 0;
00153 CSCDetId id( iEndcap, iStation, iRing, iChamber, iLayer );
00154 TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
00155 addToCompound(shape, kFWMuonEndcapLineColorIndex);
00156 cRing->AddElement( shape );
00157 }
00158 }
00159 }
00160 }
00161 AddElement( m_muonEndcapElements );
00162 }
00163
00164 if( m_muonEndcapElements )
00165 {
00166 m_muonEndcapElements->SetRnrState( showMuonEndcap );
00167 gEve->Redraw3D();
00168 }
00169 }
00170
00171
00172 void
00173 FW3DViewGeometry::showPixelBarrel( bool showPixelBarrel )
00174 {
00175 if( showPixelBarrel && !m_pixelBarrelElements )
00176 {
00177 m_pixelBarrelElements = new TEveElementList( "PixelBarrel" );
00178 m_pixelBarrelElements->SetRnrState( showPixelBarrel );
00179 std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelBarrel );
00180 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00181 id != ids.end(); ++id )
00182 {
00183 TEveGeoShape* shape = m_geom->getEveShape( *id );
00184 addToCompound(shape, kFWPixelBarrelColorIndex);
00185 m_pixelBarrelElements->AddElement( shape );
00186 }
00187 AddElement( m_pixelBarrelElements );
00188 }
00189
00190 if( m_pixelBarrelElements )
00191 {
00192 m_pixelBarrelElements->SetRnrState( showPixelBarrel );
00193 gEve->Redraw3D();
00194 }
00195 }
00196
00197
00198 void
00199 FW3DViewGeometry::showPixelEndcap(bool showPixelEndcap )
00200 {
00201 if( showPixelEndcap && ! m_pixelEndcapElements )
00202 {
00203 m_pixelEndcapElements = new TEveElementList( "PixelEndcap" );
00204 std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelEndcap );
00205 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00206 id != ids.end(); ++id )
00207 {
00208 TEveGeoShape* shape = m_geom->getEveShape( *id );
00209 addToCompound(shape, kFWPixelEndcapColorIndex);
00210 m_pixelEndcapElements->AddElement( shape );
00211 }
00212 AddElement( m_pixelEndcapElements );
00213 }
00214
00215 if( m_pixelEndcapElements )
00216 {
00217 m_pixelEndcapElements->SetRnrState( showPixelEndcap );
00218 gEve->Redraw3D();
00219 }
00220 }
00221
00222
00223 void
00224 FW3DViewGeometry::showTrackerBarrel( bool showTrackerBarrel )
00225 {
00226 if( showTrackerBarrel && ! m_trackerBarrelElements )
00227 {
00228 m_trackerBarrelElements = new TEveElementList( "TrackerBarrel" );
00229 m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
00230 std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TIB );
00231 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00232 id != ids.end(); ++id )
00233 {
00234 TEveGeoShape* shape = m_geom->getEveShape( *id );
00235 addToCompound(shape, kFWTrackerBarrelColorIndex);
00236 m_trackerBarrelElements->AddElement( shape );
00237 }
00238 ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TOB );
00239 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00240 id != ids.end(); ++id )
00241 {
00242 TEveGeoShape* shape = m_geom->getEveShape( *id );
00243 addToCompound(shape, kFWTrackerBarrelColorIndex);
00244 m_trackerBarrelElements->AddElement( shape );
00245 }
00246 AddElement( m_trackerBarrelElements );
00247 }
00248
00249 if( m_trackerBarrelElements )
00250 {
00251 m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
00252 gEve->Redraw3D();
00253 }
00254 }
00255
00256
00257 void
00258 FW3DViewGeometry::showTrackerEndcap( bool showTrackerEndcap )
00259 {
00260 if( showTrackerEndcap && ! m_trackerEndcapElements )
00261 {
00262 m_trackerEndcapElements = new TEveElementList( "TrackerEndcap" );
00263 std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TID );
00264 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00265 id != ids.end(); ++id )
00266 {
00267 TEveGeoShape* shape = m_geom->getEveShape( *id );
00268 addToCompound(shape, kFWTrackerEndcapColorIndex);
00269 m_trackerEndcapElements->AddElement( shape );
00270 }
00271 ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TEC );
00272 for( std::vector<unsigned int>::const_iterator id = ids.begin();
00273 id != ids.end(); ++id )
00274 {
00275 TEveGeoShape* shape = m_geom->getEveShape( *id );
00276 addToCompound(shape, kFWTrackerEndcapColorIndex);
00277 m_trackerEndcapElements->AddElement( shape );
00278 }
00279 AddElement( m_trackerEndcapElements );
00280 }
00281
00282 if (m_trackerEndcapElements )
00283 {
00284 m_trackerEndcapElements->SetRnrState( showTrackerEndcap );
00285 gEve->Redraw3D();
00286 }
00287 }
00288
00289