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 //
12 
13 // system include files
14 #include <sstream>
15 
16 // user include files
17 
18 #include "TEveManager.h"
19 #include "TEveGeoNode.h"
20 #include "TEveCompound.h"
21 
27 
32 
35 //
36 // constants, enums and typedefs
37 //
38 
39 //
40 // static data member definitions
41 //
42 
43 //
44 // constructors and destructor
45 //
47  FWViewGeometryList(context, false),
48  m_muonBarrelElements(0), m_muonBarrelFullElements(0),
49  m_muonEndcapElements(0), m_muonEndcapFullElements(0),
50  m_pixelBarrelElements(0),
51  m_pixelEndcapElements(0),
52  m_trackerBarrelElements(0),
53  m_trackerEndcapElements(0)
54 {
55 
56  SetElementName("3D Geometry");
57 }
58 
59 // FW3DViewGeometry::FW3DViewGeometry(const FW3DViewGeometry& rhs)
60 // {
61 // // do actual copying here;
62 // }
63 
65 {
66 }
67 
68 
69 //
70 // member functions
71 //
72 
73 //
74 // const member functions
75 //
76 
77 //
78 // static member functions
79 //
80 
81 void
83 {
84  if( !m_muonBarrelElements && showMuonBarrel )
85  {
86  m_muonBarrelElements = new TEveElementList( "DT" );
87  for( Int_t iWheel = -2; iWheel <= 2; ++iWheel )
88  {
89  for ( Int_t iStation = 1; iStation <= 4; ++iStation )
90  {
91  // We display only the outer chambers to make the event look more
92  // prominent
93  if( iWheel == -2 || iWheel == 2 || iStation == 4 )
94  {
95  std::ostringstream s;
96  s << "Station" << iStation;
97  TEveElementList* cStation = new TEveElementList( s.str().c_str() );
98  m_muonBarrelElements->AddElement( cStation );
99  for( Int_t iSector = 1 ; iSector <= 14; ++iSector )
100  {
101  if( iStation < 4 && iSector > 12 ) continue;
102  DTChamberId id( iWheel, iStation, iSector );
103  TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
105  cStation->AddElement( shape );
106  }
107  }
108  }
109  }
110  AddElement( m_muonBarrelElements );
111  }
112 
114  {
115  m_muonBarrelElements->SetRnrState( showMuonBarrel );
116  gEve->Redraw3D();
117  }
118 }
119 
120 void
122 {
123  if (!m_muonBarrelFullElements && showMuonBarrel)
124  {
125  m_muonBarrelFullElements = new TEveElementList( "DT Full" );
126  for (Int_t iWheel = -2; iWheel <= 2; ++iWheel)
127  {
128  TEveElementList* cWheel = new TEveElementList(TString::Format("Wheel %d", iWheel));
129  m_muonBarrelFullElements->AddElement(cWheel);
130  for (Int_t iStation = 1; iStation <= 4; ++iStation)
131  {
132  TEveElementList* cStation = new TEveElementList(TString::Format("Station %d", iStation));
133  cWheel->AddElement(cStation);
134  for (Int_t iSector = 1 ; iSector <= 14; ++iSector)
135  {
136  if( iStation < 4 && iSector > 12 ) continue;
137  DTChamberId id( iWheel, iStation, iSector );
138  TEveGeoShape* shape = m_geom->getEveShape(id.rawId());
139  shape->SetTitle(TString::Format("DT: W=%d, S=%d, Sec=%d\ndet-id=%u",
140  iWheel, iStation, iSector, id.rawId()));
142  cStation->AddElement(shape);
143  }
144  }
145  }
146  AddElement(m_muonBarrelFullElements);
147  }
148 
150  {
151  m_muonBarrelFullElements->SetRnrState(showMuonBarrel);
152  gEve->Redraw3D();
153  }
154 }
155 
156 //______________________________________________________________________________
157 void
158 FW3DViewGeometry::showMuonEndcap( bool showMuonEndcap )
159 {
160  if( showMuonEndcap && !m_muonEndcapElements )
161  {
162  m_muonEndcapElements = new TEveElementList( "EndCap" );
163 
164  for( Int_t iEndcap = 1; iEndcap <= 2; ++iEndcap ) // 1=forward (+Z), 2=backward(-Z)
165  {
166  TEveElementList* cEndcap = 0;
167  if( iEndcap == 1 )
168  cEndcap = new TEveElementList( "CSC Forward" );
169  else
170  cEndcap = new TEveElementList( "CSC Backward" );
171  m_muonEndcapElements->AddElement( cEndcap );
172  // Actual CSC geometry:
173  // Station 1 has 4 rings with 36 chambers in each
174  // Station 2: ring 1 has 18 chambers, ring 2 has 36 chambers
175  // Station 3: ring 1 has 18 chambers, ring 2 has 36 chambers
176  // Station 4: ring 1 has 18 chambers
177  Int_t maxChambers = 36;
178  for( Int_t iStation = 1; iStation <= 4; ++iStation )
179  {
180  std::ostringstream s; s << "Station" << iStation;
181  TEveElementList* cStation = new TEveElementList( s.str().c_str() );
182  cEndcap->AddElement( cStation );
183  for( Int_t iRing = 1; iRing <= 4; ++iRing )
184  {
185  if( iStation > 1 && iRing > 2 ) continue;
186  if( iStation > 3 && iRing > 1 ) continue;
187  std::ostringstream s; s << "Ring" << iRing;
188  TEveElementList* cRing = new TEveElementList( s.str().c_str() );
189  cStation->AddElement( cRing );
190  ( iRing == 1 && iStation > 1 ) ? ( maxChambers = 18 ) : ( maxChambers = 36 );
191  for( Int_t iChamber = 1; iChamber <= maxChambers; ++iChamber )
192  {
193  Int_t iLayer = 0; // chamber
194  CSCDetId id( iEndcap, iStation, iRing, iChamber, iLayer );
195  TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
196  shape->SetTitle(TString::Format("CSC: %s, S=%d, R=%d, C=%d\ndet-id=%u",
197  cEndcap->GetName(), iStation, iRing, iChamber, id.rawId()));
198 
200  cRing->AddElement( shape );
201  }
202  }
203  }
204  }
205  // hardcoded gem and me0; need to find better way for different gem geometries
206  for( Int_t iRegion = GEMDetId::minRegionId; iRegion <= GEMDetId::maxRegionId; iRegion= iRegion+2){
207  TEveElementList* teEndcap = 0;
208  if( iRegion == 1 )
209  teEndcap = new TEveElementList( "GEM Forward" );
210  else
211  teEndcap = new TEveElementList( "GEM Backward" );
212  m_muonEndcapElements->AddElement( teEndcap );
213 
214  int mxSt = m_geom->versionInfo().haveExtraDet("GE2") ? 3:1;
215 
216  for( Int_t iStation = GEMDetId::minStationId; iStation <= mxSt; ++iStation ){
217  std::ostringstream s; s << "Station" << iStation;
218  TEveElementList* cStation = new TEveElementList( s.str().c_str() );
219  teEndcap->AddElement( cStation );
220 
221  Int_t iRing = 1;
222  for( Int_t iLayer = GEMDetId::minLayerId; iLayer <= GEMDetId::maxLayerId ; ++iLayer ){
223  int maxChamber = 36;
224  if (iStation >= 2) maxChamber = 18;
225 
226  for( Int_t iChamber = 1; iChamber <= maxChamber; ++iChamber ){
227  int maxRoll = iChamber%2 ? 9:10;
228  if (iStation == 2) maxRoll = 8;
229  if (iStation == 3) maxRoll = 12;
230 
231  for (Int_t iRoll = GEMDetId::minRollId; iRoll <= maxRoll ; ++iRoll ){
232  GEMDetId id( iRegion, iRing, iStation, iLayer, iChamber, iRoll );
233  TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
234  if (shape){
235  shape->SetTitle(TString::Format("GEM: , Rng=%d, St=%d, Ch=%d Rl=%d\ndet-id=%u",
236  iRing, iStation, iChamber, iRoll, id.rawId()));
237 
238  cStation->AddElement( shape );
240  }
241  }
242  }
243  }
244  }
245  }
246 
247  // adding me0
248  if (m_geom->versionInfo().haveExtraDet("ME0") ){
249  for( Int_t iRegion = ME0DetId::minRegionId; iRegion <= ME0DetId::maxRegionId; iRegion= iRegion+2 ){
250  TEveElementList* teEndcap = 0;
251  if( iRegion == 1 )
252  teEndcap = new TEveElementList( "ME0 Forward" );
253  else
254  teEndcap = new TEveElementList( "ME0 Backward" );
255  m_muonEndcapElements->AddElement( teEndcap );
256 
257  for( Int_t iLayer = 1; iLayer <= 6 ; ++iLayer ){
258  std::ostringstream s; s << "Layer" << iLayer;
259  TEveElementList* cLayer = new TEveElementList( s.str().c_str() );
260  teEndcap->AddElement( cLayer );
261 
262  for( Int_t iChamber = 1; iChamber <= 18; ++iChamber ){
263  Int_t iRoll = 1;
264  // for (Int_t iRoll = ME0DetId::minRollId; iRoll <= ME0DetId::maxRollId ; ++iRoll ){
265  ME0DetId id( iRegion, iLayer, iChamber, iRoll );
266  TEveGeoShape* shape = m_geom->getEveShape( id.rawId() );
267  if (shape){
268  shape->SetTitle(TString::Format("ME0: , Ch=%d Rl=%d\ndet-id=%u",
269  iChamber, iRoll, id.rawId()));
270 
272  cLayer->AddElement( shape );
273  }
274  }
275  }
276  }
277  }
278 
279  AddElement( m_muonEndcapElements );
280  }
281 
283  {
284  m_muonEndcapElements->SetRnrState( showMuonEndcap );
285  gEve->Redraw3D();
286  }
287 }
288 
289 //______________________________________________________________________________
290 void
291 FW3DViewGeometry::showPixelBarrel( bool showPixelBarrel )
292 {
293  if( showPixelBarrel && !m_pixelBarrelElements )
294  {
295  m_pixelBarrelElements = new TEveElementList( "PixelBarrel" );
296  m_pixelBarrelElements->SetRnrState( showPixelBarrel );
297  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelBarrel );
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  PXBDetId idid = PXBDetId( *id );
303  unsigned int layer = idid.layer();
304  unsigned int ladder = idid.ladder();
305  unsigned int module = idid.module();
306 
307  shape->SetTitle( TString::Format( "PixelBarrel %d: Layer=%u, Ladder=%u, Module=%u",
308  *id, layer, ladder, module ));
309 
311  m_pixelBarrelElements->AddElement( shape );
312  }
313  AddElement( m_pixelBarrelElements );
314  }
315 
317  {
318  m_pixelBarrelElements->SetRnrState( showPixelBarrel );
319  gEve->Redraw3D();
320  }
321 }
322 
323 //______________________________________________________________________________
324 void
325 FW3DViewGeometry::showPixelEndcap(bool showPixelEndcap )
326 {
327  if( showPixelEndcap && ! m_pixelEndcapElements )
328  {
329  m_pixelEndcapElements = new TEveElementList( "PixelEndcap" );
330  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::PixelEndcap );
331  for( std::vector<unsigned int>::const_iterator id = ids.begin();
332  id != ids.end(); ++id )
333  {
334  TEveGeoShape* shape = m_geom->getEveShape( *id );
335  PXFDetId idid = PXFDetId( *id );
336  unsigned int side = idid.side();
337  unsigned int disk = idid.disk();
338  unsigned int blade = idid.blade();
339  unsigned int panel = idid.panel();
340  unsigned int module = idid.module();
341 
342  shape->SetTitle( TString::Format( "PixelEndcap %d: Side=%u, Disk=%u, Blade=%u, Panel=%u, Module=%u",
343  *id, side, disk, blade, panel, module ));
344 
346  m_pixelEndcapElements->AddElement( shape );
347  }
348  AddElement( m_pixelEndcapElements );
349  }
350 
352  {
353  m_pixelEndcapElements->SetRnrState( showPixelEndcap );
354  gEve->Redraw3D();
355  }
356 }
357 
358 //______________________________________________________________________________
359 void
360 FW3DViewGeometry::showTrackerBarrel( bool showTrackerBarrel )
361 {
362  if( showTrackerBarrel && ! m_trackerBarrelElements )
363  {
364  m_trackerBarrelElements = new TEveElementList( "TrackerBarrel" );
365  m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
366  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TIB );
367  for( std::vector<unsigned int>::const_iterator id = ids.begin();
368  id != ids.end(); ++id )
369  {
370  TEveGeoShape* shape = m_geom->getEveShape( *id );
372  m_trackerBarrelElements->AddElement( shape );
373  }
375  for( std::vector<unsigned int>::const_iterator id = ids.begin();
376  id != ids.end(); ++id )
377  {
378  TEveGeoShape* shape = m_geom->getEveShape( *id );
379  shape->SetTitle(Form("TrackerBarrel %d",*id));
381  m_trackerBarrelElements->AddElement( shape );
382  }
383  AddElement( m_trackerBarrelElements );
384  }
385 
387  {
388  m_trackerBarrelElements->SetRnrState( showTrackerBarrel );
389  gEve->Redraw3D();
390  }
391 }
392 
393 //______________________________________________________________________________
394 void
395 FW3DViewGeometry::showTrackerEndcap( bool showTrackerEndcap )
396 {
397  if( showTrackerEndcap && ! m_trackerEndcapElements )
398  {
399  m_trackerEndcapElements = new TEveElementList( "TrackerEndcap" );
400  std::vector<unsigned int> ids = m_geom->getMatchedIds( FWGeometry::Tracker, FWGeometry::TID );
401  for( std::vector<unsigned int>::const_iterator id = ids.begin();
402  id != ids.end(); ++id )
403  {
404  TEveGeoShape* shape = m_geom->getEveShape( *id );
406  m_trackerEndcapElements->AddElement( shape );
407  }
409  for( std::vector<unsigned int>::const_iterator id = ids.begin();
410  id != ids.end(); ++id )
411  {
412  TEveGeoShape* shape = m_geom->getEveShape( *id );
413 
414  shape->SetTitle(Form("TrackerEndcap %d",*id));
416  m_trackerEndcapElements->AddElement( shape );
417  }
418  AddElement( m_trackerEndcapElements );
419  }
420 
422  {
423  m_trackerEndcapElements->SetRnrState( showTrackerEndcap );
424  gEve->Redraw3D();
425  }
426 }
427 
428 
unsigned int panel() const
panel id
Definition: PXFDetId.h:52
void showMuonBarrel(long)
void showMuonBarrel(bool)
TEveElementList * m_pixelBarrelElements
virtual ~FW3DViewGeometry()
void showTrackerEndcap(bool)
static const int minRegionId
Definition: GEMDetId.h:90
unsigned int ladder() const
ladder id
Definition: PXBDetId.h:39
static const int maxRegionId
Definition: ME0DetId.h:87
void showMuonBarrelFull(bool)
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
const VersionInfo & versionInfo() const
Definition: FWGeometry.h:117
void showTrackerBarrel(bool)
static const int maxLayerId
Definition: GEMDetId.h:103
unsigned int blade() const
blade id
Definition: PXFDetId.h:48
void addToCompound(TEveElement *el, FWGeomColorIndex idx, bool applyTransp=true) const
static const int minRegionId
Definition: ME0DetId.h:86
bool haveExtraDet(const char *) const
Definition: FWGeometry.cc:379
void showMuonEndcap(bool)
TEveElementList * m_pixelEndcapElements
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:253
TEveElementList * m_muonEndcapElements
TEveElementList * m_muonBarrelElements
static const int minRollId
Definition: GEMDetId.h:105
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:67
static const int minStationId
Definition: GEMDetId.h:96
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:197
unsigned int side() const
positive or negative id
Definition: PXFDetId.h:38
static const int minLayerId
Definition: GEMDetId.h:102
volatile std::atomic< bool > shutdown_flag false
static const int maxRegionId
Definition: GEMDetId.h:91
Definition: vlib.h:208