CMS 3D CMS Logo

VisTriggerResultsTwig.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
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 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00023 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00024 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00025 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00026 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00027 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00028 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
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 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00046 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
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     // Get debugging dump.
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                 // decision for each HL algorithm
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     // Get debugging dump.
00147     VisQueuedTwig::update (rep);
00148 
00149     IgQtLock ();
00150 
00151 //     if (m_hltresults.isValid ()) 
00152 //     {
00153 //      try
00154 //      {    
00155 //          //      for (std::vector<edm::Handle<edm::TriggerResults> >::iterator i = m_hltresults.begin (), 
00156 //          //                                                                 iEnd = m_hltresults.end (); 
00157 //          //           i != iEnd; ++i) 
00158 //          //      {
00159 //          if (m_hltresults.isValid ())
00160 //          {               
00161 //              const edm::TriggerResults c = *(m_hltresults).product ();
00162 //              std::vector<std::string>  hlNames = c.getTriggerNames ();
00163 
00164 //              QString triggerHeader;
00165                 
00166 //              for (std::vector<std::string>::const_iterator iName = hlNames.begin (), iNameEnd = hlNames.end (); iName != iNameEnd; ++iName)
00167 //              {
00168 //                  triggerHeader.append (*iName);
00169 //                  triggerHeader.append (": was run ");
00170 
00171 //                  // decision for each HL algorithm
00172 //                  int index = c.find (*iName);
00173 //                  c.wasrun (index) ? triggerHeader.append ("Yes") : triggerHeader.append ("No");    
00174 //                  triggerHeader.append ("; accept ");
00175 //                  c.accept (index) ? triggerHeader.append ("Yes") : triggerHeader.append ("No");
00176 //                  triggerHeader.append ("; error ");
00177 //                  c.error (index) ? triggerHeader.append ("Yes") : triggerHeader.append ("No");
00178 //                  triggerHeader.append (". ");    
00179 //              }
00180                 
00181 //              SoSeparator         *label = new SoSeparator;
00182 //              SoText2             *labelText = new SoText2;
00183 //              SoTranslation       *labelOffset = new SoTranslation;
00184 //              labelText->string = triggerHeader.latin1 ();
00185 //              labelOffset->translation
00186 //                  = SbVec3f (-0.6, 1, -0.6);
00187 //              label->addChild (labelOffset);
00188 //              label->addChild (labelText);
00189             
00190 //              rep->clear ();
00191 //              rep->node ()->addChild (label);
00192 //          }
00193 //         }
00194 //      catch (...) 
00195 //      {
00196 //      }
00197 //     }
00198 }
00199 
00200 void
00201 VisTriggerResultsTwig::update (IgTextRep *rep)
00202 {
00203     // Get debugging dump.
00204     VisQueuedTwig::update (rep);
00205 
00206     // Prepare the property description.
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 //     if (m_hltresults.isValid ()) 
00224 //     {
00225 //      try
00226 //      {    
00227 //          //      for (std::vector<edm::Handle<edm::TriggerResults> >::iterator i = m_hltresults.begin (), 
00228 //          //                                                                 iEnd = m_hltresults.end (); 
00229 //          //           i != iEnd; ++i) 
00230 //          //      {
00231 //          //          if ((*i).isValid ())
00232 //          //          {
00233                     
00234 //          const edm::TriggerResults c = *(m_hltresults).product ();
00235 //          std::vector<std::string>  hlNames = c.getTriggerNames ();
00236 
00237 //          QString triggerHeader;
00238                 
00239 //          for (std::vector<std::string>::const_iterator iName = hlNames.begin (), iNameEnd = hlNames.end (); iName != iNameEnd; ++iName)
00240 //          {
00241 //              text << "<TR align = right>"
00242 //                   << "<TD>" << std::setw (5) << std::setprecision (3) << *iName << "</TD>";
00243 
00244 // //           // decision for each HL algorithm
00245 // //           int index = c.find (*iName);
00246 // //           text << "<TD>" << std::setw (5) << std::setprecision (3);
00247                     
00248 // //           c.wasrun (index) ? (text << "Yes") : (text << "No");    
00249 // //           text << "</TD>";
00250 // //           c.accept (index) ? (text << "Yes") : (text << "No");
00251 // //           text << "</TD>";
00252 // //           c.error (index) ? (text << "Yes") : (text << "No");
00253 //              text << "</TD></TR>";
00254 //          }
00255 //      }
00256 //      catch (...) 
00257 //      {
00258 //          text << "No information available: an exception is caught.";
00259 //      }
00260 //     }
00261     text << "</table>";  
00262 
00263     IgQtLock ();
00264     rep->setText (text.str ());
00265 }

Generated on Tue Jun 9 17:50:29 2009 for CMSSW by  doxygen 1.5.4