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.16 2011/09/27 17:22:17 matevz 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), m_muonBarrelFullElements(0),
45  m_muonEndcapElements(0), m_muonEndcapFullElements(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 void
118 {
119  if (!m_muonBarrelFullElements && showMuonBarrel)
120  {
121  m_muonBarrelFullElements = new TEveElementList( "DT Full" );
122  for (Int_t iWheel = -2; iWheel <= 2; ++iWheel)
123  {
124  TEveElementList* cWheel = new TEveElementList(TString::Format("Wheel %d", iWheel));
125  m_muonBarrelFullElements->AddElement(cWheel);
126  for (Int_t iStation = 1; iStation <= 4; ++iStation)
127  {
128  TEveElementList* cStation = new TEveElementList(TString::Format("Station %d", iStation));
129  cWheel->AddElement(cStation);
130  for (Int_t iSector = 1 ; iSector <= 14; ++iSector)
131  {
132  if( iStation < 4 && iSector > 12 ) continue;
133  DTChamberId id( iWheel, iStation, iSector );
134  TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
135  shape->SetTitle(TString::Format("DT: W=%d, S=%d, Sec=%d\ndet-id=%u",
136  iWheel, iStation, iSector, id.rawId()));
138  cStation->AddElement(shape);
139  }
140  }
141  }
142  AddElement(m_muonBarrelFullElements);
143  }
144 
146  {
147  m_muonBarrelFullElements->SetRnrState(showMuonBarrel);
148  gEve->Redraw3D();
149  }
150 }
151 
152 //______________________________________________________________________________
153 void
154 FW3DViewGeometry::showMuonEndcap( bool showMuonEndcap )
155 {
156  if( showMuonEndcap && !m_muonEndcapElements )
157  {
158  m_muonEndcapElements = new TEveElementList( "CSC" );
159  for( Int_t iEndcap = 1; iEndcap <= 2; ++iEndcap ) // 1=forward (+Z), 2=backward(-Z)
160  {
161  TEveElementList* cEndcap = 0;
162  if( iEndcap == 1 )
163  cEndcap = new TEveElementList( "Forward" );
164  else
165  cEndcap = new TEveElementList( "Backward" );
166  m_muonEndcapElements->AddElement( cEndcap );
167  // Actual CSC geometry:
168  // Station 1 has 4 rings with 36 chambers in each
169  // Station 2: ring 1 has 18 chambers, ring 2 has 36 chambers
170  // Station 3: ring 1 has 18 chambers, ring 2 has 36 chambers
171  // Station 4: ring 1 has 18 chambers
172  Int_t maxChambers = 36;
173  for( Int_t iStation = 1; iStation <= 4; ++iStation )
174  {
175  std::ostringstream s; s << "Station" << iStation;
176  TEveElementList* cStation = new TEveElementList( s.str().c_str() );
177  cEndcap->AddElement( cStation );
178  for( Int_t iRing = 1; iRing <= 4; ++iRing )
179  {
180  if( iStation > 1 && iRing > 2 ) continue;
181  if( iStation > 3 && iRing > 1 ) continue;
182  std::ostringstream s; s << "Ring" << iRing;
183  TEveElementList* cRing = new TEveElementList( s.str().c_str() );
184  cStation->AddElement( cRing );
185  ( iRing == 1 && iStation > 1 ) ? ( maxChambers = 18 ) : ( maxChambers = 36 );
186  for( Int_t iChamber = 1; iChamber <= maxChambers; ++iChamber )
187  {
188  Int_t iLayer = 0; // chamber
189  CSCDetId id( iEndcap, iStation, iRing, iChamber, iLayer );
190  TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
191  shape->SetTitle(TString::Format("CSC: %s, S=%d, R=%d, C=%d\ndet-id=%u",
192  cEndcap->GetName(), iStation, iRing, iChamber, id.rawId()));
193 
195  cRing->AddElement( shape );
196  }
197  }
198  }
199  }
200  AddElement( m_muonEndcapElements );
201  }
202 
204  {
205  m_muonEndcapElements->SetRnrState( showMuonEndcap );
206  gEve->Redraw3D();
207  }
208 }
209 
210 //______________________________________________________________________________
211 void
212 FW3DViewGeometry::showPixelBarrel( bool showPixelBarrel )
213 {
214  if( showPixelBarrel && !m_pixelBarrelElements )
215  {
216  m_pixelBarrelElements = new TEveElementList( "PixelBarrel" );
217  m_pixelBarrelElements->SetRnrState( showPixelBarrel );
218  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelBarrel );
219  for( std::vector<unsigned int>::const_iterator id = ids.begin();
220  id != ids.end(); ++id )
221  {
222  TEveGeoShape* shape = m_geom->getEveShape( *id );
223  shape->SetTitle(Form("PixelBarrel %d",*id));
225  m_pixelBarrelElements->AddElement( shape );
226  }
227  AddElement( m_pixelBarrelElements );
228  }
229 
231  {
232  m_pixelBarrelElements->SetRnrState( showPixelBarrel );
233  gEve->Redraw3D();
234  }
235 }
236 
237 //______________________________________________________________________________
238 void
239 FW3DViewGeometry::showPixelEndcap(bool showPixelEndcap )
240 {
241  if( showPixelEndcap && ! m_pixelEndcapElements )
242  {
243  m_pixelEndcapElements = new TEveElementList( "PixelEndcap" );
244  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelEndcap );
245  for( std::vector<unsigned int>::const_iterator id = ids.begin();
246  id != ids.end(); ++id )
247  {
248  TEveGeoShape* shape = m_geom->getEveShape( *id );
249 
250  shape->SetTitle(Form("PixelEndCap %d",*id));
252  m_pixelEndcapElements->AddElement( shape );
253  }
254  AddElement( m_pixelEndcapElements );
255  }
256 
258  {
259  m_pixelEndcapElements->SetRnrState( showPixelEndcap );
260  gEve->Redraw3D();
261  }
262 }
263 
264 //______________________________________________________________________________
265 void
266 FW3DViewGeometry::showTrackerBarrel( bool showTrackerBarrel )
267 {
268  if( showTrackerBarrel && ! m_trackerBarrelElements )
269  {
270  m_trackerBarrelElements = new TEveElementList( "TrackerBarrel" );
271  m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
272  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TIB );
273  for( std::vector<unsigned int>::const_iterator id = ids.begin();
274  id != ids.end(); ++id )
275  {
276  TEveGeoShape* shape = m_geom->getEveShape( *id );
278  m_trackerBarrelElements->AddElement( shape );
279  }
281  for( std::vector<unsigned int>::const_iterator id = ids.begin();
282  id != ids.end(); ++id )
283  {
284  TEveGeoShape* shape = m_geom->getEveShape( *id );
285 
286  shape->SetTitle(Form("TrackerBarrel %d",*id));
288  m_trackerBarrelElements->AddElement( shape );
289  }
290  AddElement( m_trackerBarrelElements );
291  }
292 
294  {
295  m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
296  gEve->Redraw3D();
297  }
298 }
299 
300 //______________________________________________________________________________
301 void
302 FW3DViewGeometry::showTrackerEndcap( bool showTrackerEndcap )
303 {
304  if( showTrackerEndcap && ! m_trackerEndcapElements )
305  {
306  m_trackerEndcapElements = new TEveElementList( "TrackerEndcap" );
307  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TID );
308  for( std::vector<unsigned int>::const_iterator id = ids.begin();
309  id != ids.end(); ++id )
310  {
311  TEveGeoShape* shape = m_geom->getEveShape( *id );
313  m_trackerEndcapElements->AddElement( shape );
314  }
316  for( std::vector<unsigned int>::const_iterator id = ids.begin();
317  id != ids.end(); ++id )
318  {
319  TEveGeoShape* shape = m_geom->getEveShape( *id );
320 
321  shape->SetTitle(Form("TrackerEndcap %d",*id));
323  m_trackerEndcapElements->AddElement( shape );
324  }
325  AddElement( m_trackerEndcapElements );
326  }
327 
329  {
330  m_trackerEndcapElements->SetRnrState( showTrackerEndcap );
331  gEve->Redraw3D();
332  }
333 }
334 
335 
void showMuonBarrel(bool)
TEveElementList * m_pixelBarrelElements
virtual ~FW3DViewGeometry()
void showTrackerEndcap(bool)
void showMuonBarrelFull(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:250
TEveElementList * m_muonEndcapElements
TEveElementList * m_muonBarrelElements
const FWGeometry * m_geom
TEveElementList * m_trackerEndcapElements
TEveElementList * m_trackerBarrelElements
void showPixelBarrel(bool)
TEveElementList * m_muonBarrelFullElements
FW3DViewGeometry(const fireworks::Context &context)
void showPixelEndcap(bool)
std::vector< unsigned int > getMatchedIds(Detector det, SubDetector subdet) const
Definition: FWGeometry.cc:194