CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FW3DViewGeometry.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FW3DViewGeometry
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Thu Mar 25 22:06:57 CET 2010
11 // $Id: FW3DViewGeometry.cc,v 1.11 2010/09/21 11:39:03 amraktad Exp $
12 //
13 
14 // system include files
15 #include <sstream>
16 
17 // user include files
18 
19 #include "TEveManager.h"
20 #include "TEveGeoNode.h"
21 
27 
30 
31 //
32 // constants, enums and typedefs
33 //
34 
35 //
36 // static data member definitions
37 //
38 
39 //
40 // constructors and destructor
41 //
43  FWViewGeometryList(context, false),
44  m_muonBarrelElements(0),
45  m_muonEndcapElements(0),
46  m_pixelBarrelElements(0),
47  m_pixelEndcapElements(0),
48  m_trackerBarrelElements(0),
49  m_trackerEndcapElements(0)
50 {
51 
52  SetElementName("3D Geometry");
53 }
54 
55 // FW3DViewGeometry::FW3DViewGeometry(const FW3DViewGeometry& rhs)
56 // {
57 // // do actual copying here;
58 // }
59 
61 {
62 }
63 
64 
65 //
66 // member functions
67 //
68 
69 //
70 // const member functions
71 //
72 
73 //
74 // static member functions
75 //
76 
77 void
78 FW3DViewGeometry::showMuonBarrel( bool showMuonBarrel )
79 {
80  if( !m_muonBarrelElements && showMuonBarrel )
81  {
82  m_muonBarrelElements = new TEveElementList( "DT" );
83  for( Int_t iWheel = -2; iWheel <= 2; ++iWheel )
84  {
85  for ( Int_t iStation = 1; iStation <= 4; ++iStation )
86  {
87  // We display only the outer chambers to make the event look more
88  // prominent
89  if( iWheel == -2 || iWheel == 2 || iStation == 4 )
90  {
91  std::ostringstream s;
92  s << "Station" << iStation;
93  TEveElementList* cStation = new TEveElementList( s.str().c_str() );
94  m_muonBarrelElements->AddElement( cStation );
95  for( Int_t iSector = 1 ; iSector <= 14; ++iSector )
96  {
97  if( iStation < 4 && iSector > 12 ) continue;
98  DTChamberId id( iWheel, iStation, iSector );
99  TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
101  cStation->AddElement( shape );
102  }
103  }
104  }
105  }
106  AddElement( m_muonBarrelElements );
107  }
108 
110  {
111  m_muonBarrelElements->SetRnrState( showMuonBarrel );
112  gEve->Redraw3D();
113  }
114 }
115 
116 //______________________________________________________________________________
117 void
118 FW3DViewGeometry::showMuonEndcap( bool showMuonEndcap )
119 {
120  if( showMuonEndcap && !m_muonEndcapElements )
121  {
122  m_muonEndcapElements = new TEveElementList( "CSC" );
123  for( Int_t iEndcap = 1; iEndcap <= 2; ++iEndcap ) // 1=forward (+Z), 2=backward(-Z)
124  {
125  TEveElementList* cEndcap = 0;
126  if( iEndcap == 1 )
127  cEndcap = new TEveElementList( "Forward" );
128  else
129  cEndcap = new TEveElementList( "Backward" );
130  m_muonEndcapElements->AddElement( cEndcap );
131  // Actual CSC geometry:
132  // Station 1 has 4 rings with 36 chambers in each
133  // Station 2: ring 1 has 18 chambers, ring 2 has 36 chambers
134  // Station 3: ring 1 has 18 chambers, ring 2 has 36 chambers
135  // Station 4: ring 1 has 18 chambers
136  Int_t maxChambers = 36;
137  for( Int_t iStation = 1; iStation <= 4; ++iStation )
138  {
139  std::ostringstream s; s << "Station" << iStation;
140  TEveElementList* cStation = new TEveElementList( s.str().c_str() );
141  cEndcap->AddElement( cStation );
142  for( Int_t iRing = 1; iRing <= 4; ++iRing )
143  {
144  if( iStation > 1 && iRing > 2 ) continue;
145  if( iStation > 3 && iRing > 1 ) continue;
146  std::ostringstream s; s << "Ring" << iRing;
147  TEveElementList* cRing = new TEveElementList( s.str().c_str() );
148  cStation->AddElement( cRing );
149  ( iRing == 1 && iStation > 1 ) ? ( maxChambers = 18 ) : ( maxChambers = 36 );
150  for( Int_t iChamber = 1; iChamber <= maxChambers; ++iChamber )
151  {
152  Int_t iLayer = 0; // chamber
153  CSCDetId id( iEndcap, iStation, iRing, iChamber, iLayer );
154  TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
156  cRing->AddElement( shape );
157  }
158  }
159  }
160  }
161  AddElement( m_muonEndcapElements );
162  }
163 
165  {
166  m_muonEndcapElements->SetRnrState( showMuonEndcap );
167  gEve->Redraw3D();
168  }
169 }
170 
171 //______________________________________________________________________________
172 void
173 FW3DViewGeometry::showPixelBarrel( bool showPixelBarrel )
174 {
175  if( showPixelBarrel && !m_pixelBarrelElements )
176  {
177  m_pixelBarrelElements = new TEveElementList( "PixelBarrel" );
178  m_pixelBarrelElements->SetRnrState( showPixelBarrel );
179  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelBarrel );
180  for( std::vector<unsigned int>::const_iterator id = ids.begin();
181  id != ids.end(); ++id )
182  {
183  TEveGeoShape* shape = m_geom->getEveShape( *id );
185  m_pixelBarrelElements->AddElement( shape );
186  }
187  AddElement( m_pixelBarrelElements );
188  }
189 
191  {
192  m_pixelBarrelElements->SetRnrState( showPixelBarrel );
193  gEve->Redraw3D();
194  }
195 }
196 
197 //______________________________________________________________________________
198 void
199 FW3DViewGeometry::showPixelEndcap(bool showPixelEndcap )
200 {
201  if( showPixelEndcap && ! m_pixelEndcapElements )
202  {
203  m_pixelEndcapElements = new TEveElementList( "PixelEndcap" );
204  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelEndcap );
205  for( std::vector<unsigned int>::const_iterator id = ids.begin();
206  id != ids.end(); ++id )
207  {
208  TEveGeoShape* shape = m_geom->getEveShape( *id );
210  m_pixelEndcapElements->AddElement( shape );
211  }
212  AddElement( m_pixelEndcapElements );
213  }
214 
216  {
217  m_pixelEndcapElements->SetRnrState( showPixelEndcap );
218  gEve->Redraw3D();
219  }
220 }
221 
222 //______________________________________________________________________________
223 void
224 FW3DViewGeometry::showTrackerBarrel( bool showTrackerBarrel )
225 {
226  if( showTrackerBarrel && ! m_trackerBarrelElements )
227  {
228  m_trackerBarrelElements = new TEveElementList( "TrackerBarrel" );
229  m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
230  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TIB );
231  for( std::vector<unsigned int>::const_iterator id = ids.begin();
232  id != ids.end(); ++id )
233  {
234  TEveGeoShape* shape = m_geom->getEveShape( *id );
236  m_trackerBarrelElements->AddElement( shape );
237  }
239  for( std::vector<unsigned int>::const_iterator id = ids.begin();
240  id != ids.end(); ++id )
241  {
242  TEveGeoShape* shape = m_geom->getEveShape( *id );
244  m_trackerBarrelElements->AddElement( shape );
245  }
246  AddElement( m_trackerBarrelElements );
247  }
248 
250  {
251  m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
252  gEve->Redraw3D();
253  }
254 }
255 
256 //______________________________________________________________________________
257 void
258 FW3DViewGeometry::showTrackerEndcap( bool showTrackerEndcap )
259 {
260  if( showTrackerEndcap && ! m_trackerEndcapElements )
261  {
262  m_trackerEndcapElements = new TEveElementList( "TrackerEndcap" );
263  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TID );
264  for( std::vector<unsigned int>::const_iterator id = ids.begin();
265  id != ids.end(); ++id )
266  {
267  TEveGeoShape* shape = m_geom->getEveShape( *id );
269  m_trackerEndcapElements->AddElement( shape );
270  }
272  for( std::vector<unsigned int>::const_iterator id = ids.begin();
273  id != ids.end(); ++id )
274  {
275  TEveGeoShape* shape = m_geom->getEveShape( *id );
277  m_trackerEndcapElements->AddElement( shape );
278  }
279  AddElement( m_trackerEndcapElements );
280  }
281 
283  {
284  m_trackerEndcapElements->SetRnrState( showTrackerEndcap );
285  gEve->Redraw3D();
286  }
287 }
288 
289 
void showMuonBarrel(bool)
TEveElementList * m_pixelBarrelElements
virtual ~FW3DViewGeometry()
void showTrackerEndcap(bool)
void showTrackerBarrel(bool)
void addToCompound(TEveElement *el, FWGeomColorIndex idx, bool applyTransp=true) const
void showMuonEndcap(bool)
TEveElementList * m_pixelEndcapElements
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:251
TEveElementList * m_muonEndcapElements
TEveElementList * m_muonBarrelElements
const FWGeometry * m_geom
TEveElementList * m_trackerEndcapElements
TEveElementList * m_trackerBarrelElements
void showPixelBarrel(bool)
FW3DViewGeometry(const fireworks::Context &context)
void showPixelEndcap(bool)
std::vector< unsigned int > getMatchedIds(Detector det, SubDetector subdet) const
Definition: FWGeometry.cc:195
string s
Definition: asciidump.py:422