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.17 2013/02/08 16:46:56 yana 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 
33 //
34 // constants, enums and typedefs
35 //
36 
37 //
38 // static data member definitions
39 //
40 
41 //
42 // constructors and destructor
43 //
45  FWViewGeometryList(context, false),
46  m_muonBarrelElements(0), m_muonBarrelFullElements(0),
47  m_muonEndcapElements(0), m_muonEndcapFullElements(0),
48  m_pixelBarrelElements(0),
49  m_pixelEndcapElements(0),
50  m_trackerBarrelElements(0),
51  m_trackerEndcapElements(0)
52 {
53 
54  SetElementName("3D Geometry");
55 }
56 
57 // FW3DViewGeometry::FW3DViewGeometry(const FW3DViewGeometry& rhs)
58 // {
59 // // do actual copying here;
60 // }
61 
63 {
64 }
65 
66 
67 //
68 // member functions
69 //
70 
71 //
72 // const member functions
73 //
74 
75 //
76 // static member functions
77 //
78 
79 void
81 {
82  if( !m_muonBarrelElements && showMuonBarrel )
83  {
84  m_muonBarrelElements = new TEveElementList( "DT" );
85  for( Int_t iWheel = -2; iWheel <= 2; ++iWheel )
86  {
87  for ( Int_t iStation = 1; iStation <= 4; ++iStation )
88  {
89  // We display only the outer chambers to make the event look more
90  // prominent
91  if( iWheel == -2 || iWheel == 2 || iStation == 4 )
92  {
93  std::ostringstream s;
94  s << "Station" << iStation;
95  TEveElementList* cStation = new TEveElementList( s.str().c_str() );
96  m_muonBarrelElements->AddElement( cStation );
97  for( Int_t iSector = 1 ; iSector <= 14; ++iSector )
98  {
99  if( iStation < 4 && iSector > 12 ) continue;
100  DTChamberId id( iWheel, iStation, iSector );
101  TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
103  cStation->AddElement( shape );
104  }
105  }
106  }
107  }
108  AddElement( m_muonBarrelElements );
109  }
110 
112  {
113  m_muonBarrelElements->SetRnrState( showMuonBarrel );
114  gEve->Redraw3D();
115  }
116 }
117 
118 void
120 {
121  if (!m_muonBarrelFullElements && showMuonBarrel)
122  {
123  m_muonBarrelFullElements = new TEveElementList( "DT Full" );
124  for (Int_t iWheel = -2; iWheel <= 2; ++iWheel)
125  {
126  TEveElementList* cWheel = new TEveElementList(TString::Format("Wheel %d", iWheel));
127  m_muonBarrelFullElements->AddElement(cWheel);
128  for (Int_t iStation = 1; iStation <= 4; ++iStation)
129  {
130  TEveElementList* cStation = new TEveElementList(TString::Format("Station %d", iStation));
131  cWheel->AddElement(cStation);
132  for (Int_t iSector = 1 ; iSector <= 14; ++iSector)
133  {
134  if( iStation < 4 && iSector > 12 ) continue;
135  DTChamberId id( iWheel, iStation, iSector );
136  TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
137  shape->SetTitle(TString::Format("DT: W=%d, S=%d, Sec=%d\ndet-id=%u",
138  iWheel, iStation, iSector, id.rawId()));
140  cStation->AddElement(shape);
141  }
142  }
143  }
144  AddElement(m_muonBarrelFullElements);
145  }
146 
148  {
149  m_muonBarrelFullElements->SetRnrState(showMuonBarrel);
150  gEve->Redraw3D();
151  }
152 }
153 
154 //______________________________________________________________________________
155 void
156 FW3DViewGeometry::showMuonEndcap( bool showMuonEndcap )
157 {
158  if( showMuonEndcap && !m_muonEndcapElements )
159  {
160  m_muonEndcapElements = new TEveElementList( "CSC" );
161  for( Int_t iEndcap = 1; iEndcap <= 2; ++iEndcap ) // 1=forward (+Z), 2=backward(-Z)
162  {
163  TEveElementList* cEndcap = 0;
164  if( iEndcap == 1 )
165  cEndcap = new TEveElementList( "Forward" );
166  else
167  cEndcap = new TEveElementList( "Backward" );
168  m_muonEndcapElements->AddElement( cEndcap );
169  // Actual CSC geometry:
170  // Station 1 has 4 rings with 36 chambers in each
171  // Station 2: ring 1 has 18 chambers, ring 2 has 36 chambers
172  // Station 3: ring 1 has 18 chambers, ring 2 has 36 chambers
173  // Station 4: ring 1 has 18 chambers
174  Int_t maxChambers = 36;
175  for( Int_t iStation = 1; iStation <= 4; ++iStation )
176  {
177  std::ostringstream s; s << "Station" << iStation;
178  TEveElementList* cStation = new TEveElementList( s.str().c_str() );
179  cEndcap->AddElement( cStation );
180  for( Int_t iRing = 1; iRing <= 4; ++iRing )
181  {
182  if( iStation > 1 && iRing > 2 ) continue;
183  if( iStation > 3 && iRing > 1 ) continue;
184  std::ostringstream s; s << "Ring" << iRing;
185  TEveElementList* cRing = new TEveElementList( s.str().c_str() );
186  cStation->AddElement( cRing );
187  ( iRing == 1 && iStation > 1 ) ? ( maxChambers = 18 ) : ( maxChambers = 36 );
188  for( Int_t iChamber = 1; iChamber <= maxChambers; ++iChamber )
189  {
190  Int_t iLayer = 0; // chamber
191  CSCDetId id( iEndcap, iStation, iRing, iChamber, iLayer );
192  TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
193  shape->SetTitle(TString::Format("CSC: %s, S=%d, R=%d, C=%d\ndet-id=%u",
194  cEndcap->GetName(), iStation, iRing, iChamber, id.rawId()));
195 
197  cRing->AddElement( shape );
198  }
199  }
200  }
201  }
202  AddElement( m_muonEndcapElements );
203  }
204 
206  {
207  m_muonEndcapElements->SetRnrState( showMuonEndcap );
208  gEve->Redraw3D();
209  }
210 }
211 
212 //______________________________________________________________________________
213 void
214 FW3DViewGeometry::showPixelBarrel( bool showPixelBarrel )
215 {
216  if( showPixelBarrel && !m_pixelBarrelElements )
217  {
218  m_pixelBarrelElements = new TEveElementList( "PixelBarrel" );
219  m_pixelBarrelElements->SetRnrState( showPixelBarrel );
220  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelBarrel );
221  for( std::vector<unsigned int>::const_iterator id = ids.begin();
222  id != ids.end(); ++id )
223  {
224  TEveGeoShape* shape = m_geom->getEveShape( *id );
225  PXBDetId idid = PXBDetId( *id );
226  unsigned int layer = idid.layer();
227  unsigned int ladder = idid.ladder();
228  unsigned int module = idid.module();
229 
230  shape->SetTitle( TString::Format( "PixelBarrel %d: Layer=%u, Ladder=%u, Module=%u",
231  *id, layer, ladder, module ));
232 
234  m_pixelBarrelElements->AddElement( shape );
235  }
236  AddElement( m_pixelBarrelElements );
237  }
238 
240  {
241  m_pixelBarrelElements->SetRnrState( showPixelBarrel );
242  gEve->Redraw3D();
243  }
244 }
245 
246 //______________________________________________________________________________
247 void
248 FW3DViewGeometry::showPixelEndcap(bool showPixelEndcap )
249 {
250  if( showPixelEndcap && ! m_pixelEndcapElements )
251  {
252  m_pixelEndcapElements = new TEveElementList( "PixelEndcap" );
253  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelEndcap );
254  for( std::vector<unsigned int>::const_iterator id = ids.begin();
255  id != ids.end(); ++id )
256  {
257  TEveGeoShape* shape = m_geom->getEveShape( *id );
258  PXFDetId idid = PXFDetId( *id );
259  unsigned int side = idid.side();
260  unsigned int disk = idid.disk();
261  unsigned int blade = idid.blade();
262  unsigned int panel = idid.panel();
263  unsigned int module = idid.module();
264 
265  shape->SetTitle( TString::Format( "PixelEndcap %d: Side=%u, Disk=%u, Blade=%u, Panel=%u, Module=%u",
266  *id, side, disk, blade, panel, module ));
267 
269  m_pixelEndcapElements->AddElement( shape );
270  }
271  AddElement( m_pixelEndcapElements );
272  }
273 
275  {
276  m_pixelEndcapElements->SetRnrState( showPixelEndcap );
277  gEve->Redraw3D();
278  }
279 }
280 
281 //______________________________________________________________________________
282 void
283 FW3DViewGeometry::showTrackerBarrel( bool showTrackerBarrel )
284 {
285  if( showTrackerBarrel && ! m_trackerBarrelElements )
286  {
287  m_trackerBarrelElements = new TEveElementList( "TrackerBarrel" );
288  m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
289  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TIB );
290  for( std::vector<unsigned int>::const_iterator id = ids.begin();
291  id != ids.end(); ++id )
292  {
293  TEveGeoShape* shape = m_geom->getEveShape( *id );
295  m_trackerBarrelElements->AddElement( shape );
296  }
298  for( std::vector<unsigned int>::const_iterator id = ids.begin();
299  id != ids.end(); ++id )
300  {
301  TEveGeoShape* shape = m_geom->getEveShape( *id );
302  shape->SetTitle(Form("TrackerBarrel %d",*id));
304  m_trackerBarrelElements->AddElement( shape );
305  }
306  AddElement( m_trackerBarrelElements );
307  }
308 
310  {
311  m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
312  gEve->Redraw3D();
313  }
314 }
315 
316 //______________________________________________________________________________
317 void
318 FW3DViewGeometry::showTrackerEndcap( bool showTrackerEndcap )
319 {
320  if( showTrackerEndcap && ! m_trackerEndcapElements )
321  {
322  m_trackerEndcapElements = new TEveElementList( "TrackerEndcap" );
323  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TID );
324  for( std::vector<unsigned int>::const_iterator id = ids.begin();
325  id != ids.end(); ++id )
326  {
327  TEveGeoShape* shape = m_geom->getEveShape( *id );
329  m_trackerEndcapElements->AddElement( shape );
330  }
332  for( std::vector<unsigned int>::const_iterator id = ids.begin();
333  id != ids.end(); ++id )
334  {
335  TEveGeoShape* shape = m_geom->getEveShape( *id );
336 
337  shape->SetTitle(Form("TrackerEndcap %d",*id));
339  m_trackerEndcapElements->AddElement( shape );
340  }
341  AddElement( m_trackerEndcapElements );
342  }
343 
345  {
346  m_trackerEndcapElements->SetRnrState( showTrackerEndcap );
347  gEve->Redraw3D();
348  }
349 }
350 
351 
unsigned int panel() const
panel id
Definition: PXFDetId.h:52
void showMuonBarrel(long)
void showMuonBarrel(bool)
TEveElementList * m_pixelBarrelElements
virtual ~FW3DViewGeometry()
void showTrackerEndcap(bool)
unsigned int ladder() const
ladder id
Definition: PXBDetId.h:39
void showMuonBarrelFull(bool)
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
void showTrackerBarrel(bool)
unsigned int blade() const
blade id
Definition: PXFDetId.h:48
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
unsigned int module() const
det id
Definition: PXBDetId.h:43
unsigned int module() const
det id
Definition: PXFDetId.h:56
const FWGeometry * m_geom
unsigned int disk() const
disk id
Definition: PXFDetId.h:43
TEveElementList * m_trackerEndcapElements
TEveElementList * m_trackerBarrelElements
const fireworks::Context & context()
Definition: FWEveView.h:65
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
unsigned int side() const
positive or negative id
Definition: PXFDetId.h:38
Definition: vlib.h:209