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