00001
00002
00003 #include "VisReco/VisHcal/interface/VisHFDataFrameTwig.h"
00004 #include "VisReco/VisHcal/interface/VisHcalSubdetector.h"
00005 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00006 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00007 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00008 #include "DataFormats/HcalDigi/interface/HFDataFrame.h"
00009 #include "FWCore/Framework/interface/Event.h"
00010 #include "FWCore/Framework/interface/EventSetup.h"
00011 #include "Iguana/Framework/interface/IgRepSet.h"
00012 #include "Iguana/Models/interface/IgTextRep.h"
00013 #include "Iguana/GLModels/interface/Ig3DRep.h"
00014 #include "Iguana/GLModels/interface/IgLegoRep.h"
00015 #include "Iguana/GLModels/interface/IgRZRep.h"
00016 #include "Iguana/Studio/interface/IgQtLock.h"
00017 #include <Inventor/nodes/SoSeparator.h>
00018 #include <qstring.h>
00019 #include <iostream>
00020 #include <iomanip>
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 namespace
00031 {
00032 VisQueuedTwig *
00033 createThisTwig (IgState *state, IgTwig *parent,
00034 const std::string &name,
00035 const std::string &friendlyName,
00036 const std::string &modLabel,
00037 const std::string &instanceName,
00038 const std::string &processName)
00039 {
00040 return new VisHFDataFrameTwig (state, parent, "HF data frames (" + name + ")",
00041 friendlyName, modLabel, instanceName, processName);
00042 }
00043 }
00044
00045
00046
00047 VisHFDataFrameTwig::VisHFDataFrameTwig (IgState *state, IgTwig *parent,
00048 const std::string &name ,
00049 const std::string &friendlyName ,
00050 const std::string &moduleLabel ,
00051 const std::string &instanceName ,
00052 const std::string &processName )
00053 : VisQueuedTwig (state, parent, name),
00054 m_name (name),
00055 m_friendlyName (friendlyName),
00056 m_moduleLabel (moduleLabel),
00057 m_instanceName (instanceName),
00058 m_processName (processName),
00059 m_text ("no info")
00060 {
00061 VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00062 if (! tfService)
00063 {
00064 tfService = new VisTwigFactroyService (state);
00065 }
00066 edm::TypeID digiHitCollID (typeid (HFDigiCollection));
00067 tfService->registerTwig (digiHitCollID.friendlyClassName (), &createThisTwig);
00068
00069 }
00070
00071 void
00072 VisHFDataFrameTwig::onNewEvent (const edm::Event &event,
00073 const edm::EventSetup &eventSetup)
00074 {
00075 VisQueuedTwig::onBaseInvalidate ();
00076 m_digis.clear ();
00077
00078 m_text = (QString ("Run # %1, event # %2")
00079 .arg (event.id ().run ())
00080 .arg (event.id ().event ()).latin1 ());
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 std::vector<edm::Handle<HFDigiCollection> > digis;
00096 try
00097 {
00098 if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00099 {
00100 VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00101 event.getMany (visSel, digis);
00102 }
00103 else
00104 {
00105 event.getManyByType (digis);
00106 }
00107 }
00108 catch (...)
00109 {
00110 }
00111 if (! digis.empty ())
00112 {
00113 for (std::vector<edm::Handle<HFDigiCollection> >::iterator i = digis.begin (), iEnd = digis.end (); i != iEnd; ++i)
00114 {
00115 const HFDigiCollection& c = *(*i);
00116 for (std::vector<HFDataFrame>::const_iterator idigi = c.begin (), idigiEnd = c.end ();
00117 idigi != idigiEnd; ++idigi)
00118 {
00119 m_digis.push_back (*idigi);
00120 }
00121 }
00122 }
00123
00124 IgRepSet::invalidate (this, SELF_MASK);
00125 }
00126
00127 void
00128 VisHFDataFrameTwig::update (IgTextRep *rep)
00129 {
00130
00131 VisQueuedTwig::update (rep);
00132
00133
00134 std::ostringstream text;
00135 text << m_name << " from ";
00136 text << m_text << "<br>";
00137
00138 text << "<table width='100%' border=1>"
00139 << "<TR align = center>"
00140 << "<TH>Number</TH>"
00141 << "<TH>Subdetector</TH>"
00142 << "<TH>ietaAbs</TH>"
00143 << "<TH>ieta</TH>"
00144 << "<TH>iphi [rad]</TH>"
00145 << "<TH>Depth</TH>"
00146 << "</TR>";
00147 text << setiosflags (std::ios::showpoint | std::ios::fixed);
00148 text.setf (std::ios::right, std::ios::adjustfield);
00149
00150 int nDigis = 0;
00151 try
00152 {
00153 for (std::vector<HFDataFrame>::const_iterator i = m_digis.begin (), iEnd = m_digis.end (); i != iEnd; ++i)
00154 {
00155 text << "<TR align = right>"
00156 << "<TD>" << std::setw (3) << nDigis++ << "</TD>"
00157 << "<TD>" << std::setw (2) << VisHcalSubdetector::subDetName ((*i).id ().subdet ()) << "</TD>"
00158 << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).id ().ietaAbs () << "</TD>"
00159 << "<TD>" << std::setw (6) << std::setprecision (3) << (*i).id ().ieta () << "</TD>"
00160 << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).id ().iphi () << "</TD>"
00161 << "<TD>" << std::setw (5) << std::setprecision (3) << (*i).id ().depth() << "</TD>"
00162 << "</TR>";
00163 }
00164 }
00165 catch (...)
00166 {
00167 text << "No " << m_name << " HF digis.<br>";
00168 }
00169 text << "</table>";
00170
00171
00172 IgQtLock ();
00173 rep->setText (text.str ());
00174 }
00175
00176 void
00177 VisHFDataFrameTwig::update (Ig3DRep *rep)
00178 {
00179
00180 VisQueuedTwig::update (rep);
00181
00182 IgQtLock ();
00183 rep->clear ();
00184
00185 SoSeparator *sep = new SoSeparator;
00186
00187 rep->node ()->addChild (sep);
00188 }
00189
00190 void
00191 VisHFDataFrameTwig::update (IgRZRep *rep)
00192 {
00193
00194 VisQueuedTwig::update (rep);
00195
00196 IgQtLock ();
00197 rep->clear ();
00198
00199 SoSeparator *sep = new SoSeparator;
00200
00201 rep->node ()->addChild (sep);
00202 }
00203
00204 void
00205 VisHFDataFrameTwig::update (IgLegoRep *rep)
00206 {
00207
00208 VisQueuedTwig::update (rep);
00209
00210 IgQtLock ();
00211 rep->clear ();
00212
00213 SoSeparator *sep = new SoSeparator;
00214
00215 rep->node ()->addChild (sep);
00216 }