00001
00002
00003 #include "VisFramework/VisEventSetup/interface/VisDTGeometryTwig.h"
00004 #include "VisFramework/VisEventSetup/interface/VisEventSetupService.h"
00005 #include "Iguana/Models/interface/IgTextRep.h"
00006 #include "Iguana/GLModels/interface/Ig3DRep.h"
00007 #include "Iguana/GLModels/interface/IgLegoRep.h"
00008 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00009 #include "Iguana/GLModels/interface/IgRZRep.h"
00010 #include "Iguana/Studio/interface/IgQtLock.h"
00011 #include <classlib/utils/DebugAids.h>
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 VisDTGeometryTwig::VisDTGeometryTwig (IgState *state, IgTwig *parent,
00024 const std::string &name ,
00025 const int wheel,
00026 const int sector,
00027 const int station)
00028 : VisQueuedTwig (state, parent, name),
00029 m_wheel (wheel),
00030 m_sector (sector),
00031 m_station (station),
00032 m_3dDet (NULL),
00033 m_rzDet (NULL),
00034 m_rphiDet (NULL),
00035 m_3Ddone (false),
00036 m_rzdone (false),
00037 m_rphidone (false),
00038 m_annotate (state, lat::CreateCallback (this, &VisDTGeometryTwig::invalidate))
00039 {}
00040
00042 VisDTGeometryTwig::~VisDTGeometryTwig (void)
00043 {
00044 if (m_3dDet != NULL) m_3dDet->unref ();
00045 if (m_rzDet != NULL) m_rzDet->unref ();
00046 if (m_rphiDet != NULL) m_rphiDet->unref ();
00047 }
00048
00049 void
00050 VisDTGeometryTwig::onNewEvent (const edm::Event &event,
00051 const edm::EventSetup &eventSetup)
00052 {
00053
00054 VisQueuedTwig::onNewEvent (event, eventSetup);
00055
00056 VisEventSetupService *esService = VisEventSetupService::get (state ());
00057 ASSERT (esService);
00058
00059 if (esService->muonGeomChanged ())
00060 invalidate ();
00061 }
00062
00063 void
00064 VisDTGeometryTwig::invalidate (void)
00065 {
00066 if (m_3dDet != NULL) m_3dDet->unref ();
00067 if (m_rzDet != NULL) m_rzDet->unref ();
00068 if (m_rphiDet != NULL) m_rphiDet->unref ();
00069 m_3Ddone = false;
00070 m_rzdone = false;
00071 m_rphidone = false;
00072
00073 VisQueuedTwig::onBaseInvalidate ();
00074 }
00075
00076 void
00077 VisDTGeometryTwig::update (IgTextRep *rep)
00078 {
00079
00080 VisQueuedTwig::update (rep);
00081
00082
00083 std::ostringstream text;
00084 text << "CMS DT Muon Geometry: ";
00085 text << this->name () << "<br>";
00086
00087 text << "<table width='100%' border=1>"
00088 << "<TR align = center>"
00089 << "<TH>#</TH>"
00090 << "<TH>Wheel/Station/Sector</TH>"
00091 << "<TH>Position</TH>"
00092 << "</TR>";
00093
00094 VisEventSetupService *esService = VisEventSetupService::get (state ());
00095 ASSERT (esService);
00096
00097 text << esService->dtTextRep (m_station, m_sector, m_wheel);
00098 text << "</table>";
00099
00100 IgQtLock ();
00101 rep->setText (text.str ());
00102 }
00103
00104 void
00105 VisDTGeometryTwig::update (Ig3DRep *rep)
00106 {
00107
00108 VisQueuedTwig::update (rep);
00109
00110 IgQtLock ();
00111 rep->clear ();
00112
00113 if (! m_3Ddone)
00114 {
00115 VisEventSetupService *esService = VisEventSetupService::get (state ());
00116 ASSERT (esService);
00117
00118 m_3dDet = esService->buildDTChambers (VisEventSetupService::FullDet, m_station, m_sector, m_wheel);
00119 if (m_3dDet == NULL) return;
00120
00121 if (m_annotate.value ())
00122 {
00123 SoSeparator *sep = esService->annotateDTChambers (VisEventSetupService::FullDet, m_station, m_sector, m_wheel);
00124 if (sep != NULL) m_3dDet->addChild (sep);
00125 }
00126
00127 m_3dDet->ref ();
00128 m_3Ddone = true;
00129 }
00130 rep->node ()->addChild (m_3dDet);
00131 }
00132
00133 void
00134 VisDTGeometryTwig::update (IgRPhiRep *rep)
00135 {
00136
00137 VisQueuedTwig::update (rep);
00138
00139 IgQtLock ();
00140 rep->clear ();
00141
00142 if (! m_rphidone)
00143 {
00144 VisEventSetupService *esService = VisEventSetupService::get (state ());
00145 ASSERT (esService);
00146
00147 m_rphiDet = esService->buildDTChambers (VisEventSetupService::RPhiDet, m_station, m_sector, m_wheel);
00148 if (m_rphiDet == NULL) return;
00149
00150 if (m_annotate.value ())
00151 {
00152 SoSeparator *sep = esService->annotateDTChambers (VisEventSetupService::RPhiDet, m_station, m_sector, m_wheel);
00153 if (sep != NULL) m_rphiDet->addChild (sep);
00154 }
00155
00156 m_rphiDet->ref ();
00157 m_rphidone = true;
00158 }
00159 rep->node ()->addChild (m_rphiDet);
00160 }
00161
00162 void
00163 VisDTGeometryTwig::update (IgRZRep *rep)
00164 {
00165
00166 VisQueuedTwig::update (rep);
00167
00168 IgQtLock ();
00169 rep->clear ();
00170
00171 if (! m_rzdone)
00172 {
00173 VisEventSetupService *esService = VisEventSetupService::get (state ());
00174 ASSERT (esService);
00175
00176 m_rzDet = esService->buildDTChambers (VisEventSetupService::RZDet, m_station, m_sector, m_wheel);
00177 if (m_rzDet == NULL) return;
00178
00179 if (m_annotate.value ())
00180 {
00181 SoSeparator *sep = esService->annotateDTChambers (VisEventSetupService::RZDet, m_station, m_sector, m_wheel);
00182 if (sep != NULL) m_rzDet->addChild (sep);
00183 }
00184
00185 m_rzDet->ref ();
00186 m_rzdone = true;
00187 }
00188 rep->node ()->addChild (m_rzDet);
00189 }