CMS 3D CMS Logo

VisGenMETTwig.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "DataFormats/METReco/interface/GenMET.h"
00004 #include "VisReco/VisMETReco/interface/VisGenMETTwig.h"
00005 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00006 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "Iguana/Models/interface/IgTextRep.h"
00010 #include "Iguana/GLModels/interface/Ig3DRep.h"
00011 #include "Iguana/GLModels/interface/IgLegoRep.h"
00012 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00013 #include "Iguana/GLModels/interface/IgRZRep.h"
00014 #include "Iguana/Framework/interface/IgRepSet.h"
00015 #include "Iguana/Studio/interface/IgQtLock.h"
00016 #include <Inventor/nodes/SoMaterial.h>
00017 #include <Inventor/nodes/SoSeparator.h>
00018 #include <qstring.h>
00019 #include <classlib/utils/DebugAids.h>
00020 #include <iostream>
00021 #include <iomanip>
00022 
00023 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00024 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00025 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00026 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00027 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00028 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00029 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00030 
00031 namespace 
00032 {
00033     VisQueuedTwig *
00034     createThisTwig (IgState *state, IgTwig *parent,
00035                     const std::string &name,
00036                     const std::string &friendlyName,
00037                     const std::string &modLabel,
00038                     const std::string &instanceName,
00039                     const std::string &processName)
00040     {
00041         return new VisGenMETTwig (state, parent, "Gen MET (" + name + ")", 
00042                                   friendlyName, modLabel, instanceName, processName);
00043     }
00044 }
00045 
00046 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00047 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00048 
00049 VisGenMETTwig::VisGenMETTwig (IgState *state, IgTwig *parent,
00050                               const std::string &name /* = "" */,
00051                               const std::string &friendlyName /* = "" */,
00052                               const std::string &moduleLabel /* = "" */,
00053                               const std::string &instanceName /* = "" */,
00054                               const std::string &processName /* = "" */)
00055     : VisQueuedTwig (state, parent, name),
00056       m_name (name),
00057       m_friendlyName (friendlyName),
00058       m_moduleLabel (moduleLabel),
00059       m_instanceName (instanceName),
00060       m_processName (processName),
00061       m_text ("no info")
00062 {
00063     VisTwigFactroyService *tfService = VisTwigFactroyService::get (state);
00064     if (! tfService)
00065     {
00066         tfService = new VisTwigFactroyService (state);
00067     }
00068     edm::TypeID metCollID (typeid (GenMETCollection));
00069     tfService->registerTwig (metCollID.friendlyClassName (), &createThisTwig);
00070 }
00071 
00072 void
00073 VisGenMETTwig::onNewEvent (const edm::Event &event,
00074                            const edm::EventSetup &eventSetup)
00075 {
00076     // Get debugging dump.
00077     VisQueuedTwig::onNewEvent (event, eventSetup);
00078 
00079     m_text = (QString ("Run # %1, event # %2")
00080               .arg (event.id ().run ())
00081               .arg (event.id ().event ()).latin1 ());
00082     
00083     try
00084     {
00085         if ((! m_friendlyName.empty ()) || (! m_moduleLabel.empty ()) || (! m_instanceName.empty ()) || (! m_processName.empty ()))
00086         {
00087             VisEventSelector visSel (m_friendlyName, m_moduleLabel, m_instanceName, m_processName);
00088             event.getMany (visSel, m_handles);
00089         }
00090         else
00091         {
00092             event.getManyByType (m_handles);
00093         }
00094     }
00095     catch (cms::Exception& e)
00096     {
00097         if (this->m_onCmsException)
00098             this->m_onCmsException (&e);
00099     }
00100     catch (lat::Error &e) 
00101     {
00102         if (this->m_onError)
00103             this->m_onError (&e);
00104     }
00105     catch (std::exception &e) 
00106     {
00107         if (this->m_onException)
00108             this->m_onException (&e);
00109     }
00110     catch (...) 
00111     {
00112         if (this->m_onUnhandledException)
00113             this->m_onUnhandledException ();
00114     }
00115     
00116     VisQueuedTwig::onBaseInvalidate ();
00117 }
00118 
00119 void
00120 VisGenMETTwig::update (IgTextRep *rep)
00121 {
00122     // Get debugging dump.
00123     VisQueuedTwig::update (rep);
00124 
00125     // Prepare property description.
00126     std::ostringstream  text;
00127     text << m_name << " from ";
00128     text << m_text << "<br>";
00129 
00130     text << "<table width='100%' border=1>"
00131          << "<TR align = center>"
00132          << "<TH>Number</TH>"
00133          << "<TH>Et</TH>"
00134          << "<TH>Phi</TH>"
00135          << "</TR>";
00136     text << setiosflags (std::ios::showpoint | std::ios::fixed);
00137     text.setf (std::ios::right, std::ios::adjustfield);
00138     
00139     int nmets = 0;
00140     if (! m_handles.empty ())
00141     {
00142         try 
00143         {
00144             for (std::vector<edm::Handle<GenMETCollection> >::iterator i = m_handles.begin (), iEnd = m_handles.end (); 
00145                  i != iEnd; ++i) 
00146             {
00147                 const GenMETCollection *met = (*i).product ();
00148                 const GenMET caloMET = met->front ();
00149                 Float_t phi = caloMET.phi ();
00150                 Float_t pt = caloMET.pt (); 
00151 
00152                 text << "<TR align = right>"
00153                      << "<TD>" << std::setw (3) << ++nmets << "</TD>"
00154                      << "<TD>" << std::setw (5) << std::setprecision (3) << pt << "</TD>"
00155                      << "<TD>" << std::setw (5) << std::setprecision (3) << phi << "</TD>"
00156                      << "</TR>";
00157             }
00158         }
00159         catch (cms::Exception& e)
00160         {
00161             if (this->m_onCmsException)
00162                 this->m_onCmsException (&e);
00163         }
00164         catch (lat::Error &e) 
00165         {
00166             if (this->m_onError)
00167                 this->m_onError (&e);
00168         }
00169         catch (std::exception &e) 
00170         {
00171             if (this->m_onException)
00172                 this->m_onException (&e);
00173         }
00174         catch (...) 
00175         {
00176             if (this->m_onUnhandledException)
00177                 this->m_onUnhandledException ();
00178         }
00179     }
00180 
00181     text << "</table>";
00182     
00183     // Send it over.
00184     IgQtLock ();
00185     rep->setText (text.str ());
00186 }
00187 
00188 void
00189 VisGenMETTwig::update (Ig3DRep *rep)
00190 {
00191     // Get debugging dump.
00192     VisQueuedTwig::update (rep);
00193 
00194     IgQtLock ();
00195     rep->clear ();
00196 
00197     SoSeparator *sep = new SoSeparator;
00198 
00199     SoMaterial *mat = new SoMaterial;
00200     mat->diffuseColor.setValue (1, 0, 0);
00201     sep->addChild (mat);
00202     
00203     rep->node ()->addChild (sep);
00204 }
00205 
00206 void
00207 VisGenMETTwig::update (IgLegoRep *rep)
00208 {
00209     // Get debugging dump.
00210     VisQueuedTwig::update (rep);
00211 
00212     IgQtLock ();
00213     rep->clear ();
00214 }
00215 
00216 void
00217 VisGenMETTwig::update (IgRPhiRep *rep)
00218 {
00219     // Get debugging dump.
00220     VisQueuedTwig::update (rep);
00221 
00222     IgQtLock ();
00223     rep->clear ();
00224 }
00225 
00226 void
00227 VisGenMETTwig::update (IgRZRep *rep)
00228 {
00229     // Get debugging dump.
00230     VisQueuedTwig::update (rep);
00231 
00232     IgQtLock ();
00233     rep->clear ();
00234 }
00235 

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