00001
00002
00003 #include "VisFramework/VisEventSetup/interface/VisCaloGeometryTwig.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 VisCaloGeometryTwig::VisCaloGeometryTwig (IgState *state, IgTwig *parent,
00024 const std::string &name,
00025 const std::string detId, const int subdetn)
00026 : VisQueuedTwig (state, parent, name),
00027 m_detId (detId),
00028 m_subdetn (subdetn),
00029 m_3dDet (NULL),
00030 m_rzDet (NULL),
00031 m_rphiDet (NULL),
00032 m_legoDet (NULL),
00033 m_3Ddone (false),
00034 m_rzdone (false),
00035 m_rphidone (false),
00036 m_legodone (false),
00037 m_annotate (state, lat::CreateCallback (this, &VisCaloGeometryTwig::invalidate)),
00038 m_scale (state, lat::CreateCallback (this, &VisCaloGeometryTwig::invalidate))
00039 {}
00040
00042 VisCaloGeometryTwig::~VisCaloGeometryTwig (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 if (m_legoDet != NULL) m_legoDet->unref ();
00048 }
00049
00050 void
00051 VisCaloGeometryTwig::onNewEvent (const edm::Event &event,
00052 const edm::EventSetup &eventSetup)
00053 {
00054
00055 VisQueuedTwig::onNewEvent (event, eventSetup);
00056
00057 VisEventSetupService *esService = VisEventSetupService::get (state ());
00058 ASSERT (esService);
00059
00060 if (esService->caloGeomChanged ())
00061 invalidate ();
00062 }
00063
00064 void
00065 VisCaloGeometryTwig::invalidate (void)
00066 {
00067 if (m_3dDet != NULL) m_3dDet->unref ();
00068 if (m_rzDet != NULL) m_rzDet->unref ();
00069 if (m_rphiDet != NULL) m_rphiDet->unref ();
00070 if (m_legoDet != NULL) m_legoDet->unref ();
00071 m_3Ddone = false;
00072 m_rzdone = false;
00073 m_rphidone = false;
00074 m_legodone = false;
00075
00076 VisQueuedTwig::onBaseInvalidate ();
00077 }
00078
00079 void
00080 VisCaloGeometryTwig::update (IgTextRep *rep)
00081 {
00082
00083 VisQueuedTwig::update (rep);
00084
00085
00086 std::ostringstream text;
00087 text << "CMS Calo Geometry: ";
00088 text << this->name () << "<br>";
00089
00090 text << "<table width='100%' border=1>"
00091 << "<TR align = center>"
00092 << "<TH>#</TH>"
00093 << "<TH>id(dec)</TH>"
00094 << "<TH>Position</TH>"
00095 << "</TR>";
00096
00097 if (m_subdetn != -1)
00098 {
00099 VisEventSetupService *esService = VisEventSetupService::get (state ());
00100 ASSERT (esService);
00101 text << esService->caloTextRep (m_detId, m_subdetn);
00102 }
00103 else
00104 text << "<TR align = right><TD COLSPAN = 3>Only LEGO view is available for this twig.</TD></TR>";
00105 text << "</table>";
00106
00107 IgQtLock ();
00108 rep->setText (text.str ());
00109 }
00110
00111 void
00112 VisCaloGeometryTwig::update (Ig3DRep *rep)
00113 {
00114
00115 VisQueuedTwig::update (rep);
00116
00117 IgQtLock ();
00118 rep->clear ();
00119
00120 if (m_subdetn != -1)
00121 {
00122 if (! m_3Ddone)
00123 {
00124 VisEventSetupService *esService = VisEventSetupService::get (state ());
00125 ASSERT (esService);
00126
00127 m_3dDet = esService->buildCaloDet (VisEventSetupService::FullDet, m_detId, m_subdetn);
00128 if (m_3dDet == NULL) return;
00129
00130 if (m_annotate.value ())
00131 {
00132 SoSeparator *sep = esService->annotateCaloDet (VisEventSetupService::FullDet, m_detId, m_subdetn);
00133 if (sep != NULL) m_3dDet->addChild (sep);
00134 }
00135
00136 m_3dDet->ref ();
00137 m_3Ddone = true;
00138 }
00139 rep->node ()->addChild (m_3dDet);
00140 }
00141 }
00142
00143 void
00144 VisCaloGeometryTwig::update (IgRPhiRep *rep)
00145 {
00146
00147 VisQueuedTwig::update (rep);
00148
00149 IgQtLock ();
00150 rep->clear ();
00151
00152 if (m_subdetn != -1)
00153 {
00154 if (! m_rphidone)
00155 {
00156 VisEventSetupService *esService = VisEventSetupService::get (state ());
00157 ASSERT (esService);
00158
00159 m_rphiDet = esService->buildCaloDet (VisEventSetupService::RPhiDet, m_detId, m_subdetn);
00160 if (m_rphiDet == NULL) return;
00161
00162 if (m_annotate.value ())
00163 {
00164 SoSeparator *sep = esService->annotateCaloDet (VisEventSetupService::RPhiDet, m_detId, m_subdetn);
00165 if (sep != NULL) m_rphiDet->addChild (sep);
00166 }
00167
00168 m_rphiDet->ref ();
00169 m_rphidone = true;
00170 }
00171 rep->node ()->addChild (m_rphiDet);
00172 }
00173 }
00174
00175 void
00176 VisCaloGeometryTwig::update (IgRZRep *rep)
00177 {
00178
00179 VisQueuedTwig::update (rep);
00180
00181 IgQtLock ();
00182 rep->clear ();
00183
00184 if (m_subdetn != -1)
00185 {
00186 if (! m_rzdone)
00187 {
00188 VisEventSetupService *esService = VisEventSetupService::get (state ());
00189 ASSERT (esService);
00190
00191 m_rzDet = esService->buildCaloDet (VisEventSetupService::RZDet, m_detId, m_subdetn);
00192 if (m_rzDet == NULL) return;
00193
00194 if (m_annotate.value ())
00195 {
00196 SoSeparator *sep = esService->annotateCaloDet (VisEventSetupService::RZDet, m_detId, m_subdetn);
00197 if (sep != NULL) m_rzDet->addChild (sep);
00198 }
00199
00200 m_rzDet->ref ();
00201 m_rzdone = true;
00202 }
00203 rep->node ()->addChild (m_rzDet);
00204 }
00205 }
00206
00207 void
00208 VisCaloGeometryTwig::update (IgLegoRep *rep)
00209 {
00210
00211 VisQueuedTwig::update (rep);
00212
00213 IgQtLock ();
00214 rep->clear ();
00215
00216 if ((! m_legodone) && (m_subdetn == -1))
00217 {
00218 VisEventSetupService *esService = VisEventSetupService::get (state ());
00219 ASSERT (esService);
00220
00221 m_legoDet = esService->buildLegoDet (m_scale.value ());
00222 m_legoDet->ref ();
00223 m_legodone = true;
00224 }
00225
00226 if (m_legoDet != NULL)
00227 rep->node ()->addChild (m_legoDet);
00228 }