00001
00002
00003 #include "VisReco/VisTrigger/interface/VisTriggerResultsTwig.h"
00004 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00005 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00006 #include "VisFramework/VisFrameworkBase/interface/debug.h"
00007 #include "DataFormats/Common/interface/TriggerResults.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 #include "Iguana/Studio/interface/IgQtLock.h"
00011 #include "Iguana/GLModels/interface/Ig3DRep.h"
00012 #include "Iguana/Models/interface/IgTextRep.h"
00013 #include <Inventor/nodes/SoSeparator.h>
00014 #include <Inventor/nodes/SoText2.h>
00015 #include <Inventor/nodes/SoTranslation.h>
00016 #include <Inventor/SbLinear.h>
00017 #include <qstring.h>
00018 #include <sstream>
00019 #include <iomanip>
00020 #include <iostream>
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 VisTriggerResultsTwig (state, parent, name,
00041 friendlyName, modLabel, instanceName, processName);
00042 }
00043 }
00044
00045
00046
00047
00048 VisTriggerResultsTwig::VisTriggerResultsTwig (IgState *state, IgTwig *parent,
00049 const std::string &name ,
00050 const std::string &friendlyName ,
00051 const std::string &moduleLabel ,
00052 const std::string &instanceName ,
00053 const std::string &processName )
00054 : VisQueuedTwig (state, parent, name),
00055 m_state (state),
00056 m_text ("no info"),
00057 m_friendlyName (friendlyName),
00058 m_moduleLabel (moduleLabel),
00059 m_instanceName (instanceName),
00060 m_processName (processName)
00061 {
00062 VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00063 if (! tfService)
00064 {
00065 tfService = new VisTwigFactroyService (state);
00066 }
00067 edm::TypeID triggerID (typeid (edm::TriggerResults));
00068 tfService->registerTwig (triggerID.friendlyClassName (), &createThisTwig);
00069 }
00070
00071 void
00072 VisTriggerResultsTwig::onNewEvent (const edm::Event &event,
00073 const edm::EventSetup &eventSetup)
00074 {
00075
00076 VisQueuedTwig::onNewEvent (event, eventSetup);
00077
00078 m_hlNames.clear ();
00079
00080 m_text = (QString ("Run # %1, event # %2")
00081 .arg (event.id ().run ())
00082 .arg (event.id ().event ()).latin1 ());
00083
00084 try
00085 {
00086 event.getByType (m_hltresults);
00087 if (m_hltresults.isValid ())
00088 {
00089 const edm::TriggerResults c = *(m_hltresults).product ();
00090 m_hlNames = c.getTriggerNames ();
00091
00092 std::cout << "edm::TriggerResults: " << m_hlNames.size () << std::endl;
00093
00094 QString triggerHeader;
00095
00096 for (std::vector<std::string>::const_iterator iName = m_hlNames.begin (),
00097 iNameEnd = m_hlNames.end ();
00098 iName != iNameEnd; ++iName)
00099 {
00100 std::cout << (*iName) << std::endl;
00101
00102 triggerHeader.append (*iName);
00103 triggerHeader.append (": was run ");
00104
00105
00106 int index = c.find (*iName);
00107 c.wasrun (index) ? triggerHeader.append ("Yes") : triggerHeader.append ("No");
00108 triggerHeader.append ("; accept ");
00109 c.accept (index) ? triggerHeader.append ("Yes") : triggerHeader.append ("No");
00110 triggerHeader.append ("; error ");
00111 c.error (index) ? triggerHeader.append ("Yes") : triggerHeader.append ("No");
00112 triggerHeader.append (". <br>");
00113
00114 std::cout << triggerHeader.latin1 () << std::endl;
00115 m_decision = triggerHeader;
00116 }
00117 }
00118 }
00119 catch (cms::Exception& e)
00120 {
00121 if (this->m_onCmsException)
00122 this->m_onCmsException (&e);
00123 }
00124 catch (lat::Error &e)
00125 {
00126 if (this->m_onError)
00127 this->m_onError (&e);
00128 }
00129 catch (std::exception &e)
00130 {
00131 if (this->m_onException)
00132 this->m_onException (&e);
00133 }
00134 catch (...)
00135 {
00136 if (this->m_onUnhandledException)
00137 this->m_onUnhandledException ();
00138 }
00139
00140 VisQueuedTwig::onBaseInvalidate ();
00141 }
00142
00143 void
00144 VisTriggerResultsTwig::update (Ig3DRep *rep)
00145 {
00146
00147 VisQueuedTwig::update (rep);
00148
00149 IgQtLock ();
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 }
00199
00200 void
00201 VisTriggerResultsTwig::update (IgTextRep *rep)
00202 {
00203
00204 VisQueuedTwig::update (rep);
00205
00206
00207 std::ostringstream text;
00208
00209 text << m_text;
00210
00211 text << setiosflags (std::ios::showpoint | std::ios::fixed);
00212 text.setf (std::ios::right, std::ios::adjustfield);
00213 text << "<table width='100%' border=1>"
00214 << "<TR align = center>"
00215 << "<TH>Name</TH>"
00216 << "<TH>Was run</TH>"
00217 << "<TH>Accept</TH>"
00218 << "<TH>Error</TH>"
00219 << "</TR>";
00220
00221 text << "<TR><TH>" << m_decision.latin1 () << "</TH></TR>";
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 text << "</table>";
00262
00263 IgQtLock ();
00264 rep->setText (text.str ());
00265 }