00001
00002 #define QT_NO_EMIT
00003 #include "VisFramework/VisEvent/interface/VisEventContentTwig.h"
00004 #include "VisFramework/VisConfigService/interface/VisConfigurationService.h"
00005 #include "VisFramework/VisFrameworkBase/interface/VisTwigFactroyService.h"
00006 #include "VisFramework/VisEvent/interface/xtypeinfo.h"
00007 #include "VisFramework/VisFrameworkBase/interface/VisEventSelector.h"
00008 #include "VisFramework/VisFrameworkBase/interface/debug.h"
00009 #include "DataFormats/Provenance/interface/ConstBranchDescription.h"
00010 #include "DataFormats/Provenance/interface/Provenance.h"
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "FWCore/Framework/interface/GenericHandle.h"
00014 #include "FWCore/Framework/interface/ConstProductRegistry.h"
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include "Iguana/Studio/interface/IgQtLock.h"
00017 #include "Iguana/Framework/interface/IgBrowserMethods.h"
00018 #include "Iguana/Framework/interface/IgRepSet.h"
00019 #include "Iguana/Framework/interface/xtypeinfo.h"
00020 #include "Iguana/Studio/interface/IgQtAppStatusBarService.h"
00021 #include "Iguana/Models/interface/IgTextRep.h"
00022 #include "Iguana/Models/interface/xtypeinfo.h"
00023 #include <qapplication.h>
00024 #include <iostream>
00025 #include <sstream>
00026 #include <iomanip>
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 VisEventContentTwig::VisEventContentTwig (IgState *state,
00039 IgTwig *parent,
00040 const std::string name ,
00041 bool traverse ,
00042 bool visible ,
00043 bool open )
00044 : IgCompoundTwig (parent),
00045 m_state (state),
00046 m_name (name),
00047 m_text ("No info")
00048 {
00049 ASSERT (parent);
00050 ASSERT (state);
00051 }
00052
00053 std::string
00054 VisEventContentTwig::name (void) const
00055 { return m_name; }
00056
00057 void
00058 VisEventContentTwig::name (const std::string &)
00059 { ASSERT (false); }
00060
00061 bool
00062 VisEventContentTwig::expand (void)
00063 {
00064 if (IgCompoundTwig::expand ())
00065 {
00066
00067
00068
00069 return true;
00070 }
00071
00072 return false;
00073 }
00074
00075 bool
00076 VisEventContentTwig::selfTraverse (void) const
00077 { return flag (TRAVERSE); }
00078
00079 void
00080 VisEventContentTwig::selfTraverse (bool value)
00081 { flag (TRAVERSE, value); }
00082
00083 bool
00084 VisEventContentTwig::selfVisible (void) const
00085 { return flag (VISIBLE); }
00086
00087 void
00088 VisEventContentTwig::selfVisible (bool value)
00089 { flag (VISIBLE, value); }
00090
00091 bool
00092 VisEventContentTwig::cascade (void) const
00093 { return flag (CASCADE); }
00094
00095 void
00096 VisEventContentTwig::cascade (bool value)
00097 { flag (CASCADE, value); }
00098
00099 void
00100 VisEventContentTwig::onPreEvent (const edm::EventID &eventID,
00101 const edm::Timestamp &timeStamp)
00102 {
00103 const edm::ParameterSet *pset = VisConfigurationService::pSet ();
00104 if(! pset)
00105 {
00106 edm::ParameterSet p;
00107 VisConfigurationService *visServise = new VisConfigurationService (p);
00108 pset = visServise->pSet ();
00109 delete visServise;
00110 }
00111
00112
00113
00114
00115
00116
00117 if (! children ())
00118
00119
00120 {
00121 edm::Service<edm::ConstProductRegistry> reg;
00122
00123 std::string friendlyName;
00124 std::string moduleLabel;
00125 std::string instanceName;
00126 std::string processName;
00127
00128 IgSimpleTwig *unknownTwigs = 0;
00129
00130 bool flag = pset->getUntrackedParameter<bool> ("UnknownDataCollections", true);
00131 if (flag)
00132 {
00133 unknownTwigs = new IgSimpleTwig (this, "Unknown Collection Types (load more iglets which knows how to represent them)");
00134 unknownTwigs->selfTraverse (false);
00135 unknownTwigs->selfVisible (false);
00136 unknownTwigs->cascade (false);
00137 }
00138
00139
00140 for (edm::ProductRegistry::ProductList::const_iterator it = reg->productList ().begin ();
00141 it != reg->productList ().end (); ++it)
00142 {
00143
00144
00145 edm::BranchDescription desc = it->second;
00146 friendlyName = desc.friendlyClassName ();
00147 moduleLabel = desc.moduleLabel ();
00148 instanceName = desc.productInstanceName ();
00149 processName = desc.processName ();
00150
00151 std::string twigName = friendlyName
00152 + std::string (":") + moduleLabel
00153 + std::string (":") + instanceName
00154 + std::string (":") + processName;
00155
00156
00157
00158
00159 VisEventSelector visSel (friendlyName, moduleLabel, instanceName, processName);
00160
00161 try
00162 {
00163 VisTwigFactroyService *tfService = VisTwigFactroyService::get (state ());
00164 if (tfService)
00165 {
00166 tfService->createTwig (friendlyName, state (), this, friendlyName, moduleLabel, instanceName, processName);
00167 }
00168 }
00169 catch (...)
00170 {
00171 if (flag)
00172 {
00173 ASSERT (unknownTwigs);
00174 IgSimpleTwig *twig = new IgSimpleTwig (unknownTwigs, twigName);
00175 twig->selfTraverse (false);
00176 twig->selfVisible (false);
00177 }
00178 }
00179 }
00180 }
00181 }
00182
00183 void
00184 VisEventContentTwig::onNewEvent (const edm::Event &event,
00185 const edm::EventSetup &eventSetup)
00186 {
00187 LOG (1, trace, LFfwvis, "VisEventContentTwig[" << name ()
00188 << "]::onNewEvent()\n");
00189
00190 m_text = QString ("Run # %1, event # %2")
00191 .arg (event.id ().run ())
00192 .arg (event.id ().event ()).latin1 ();
00193
00194 if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (state ()))
00195 sbar->setMessage (QString (m_text));
00196
00197 if (! this->cascade ())
00198 {
00199 this->cascade (true);
00200 if (! this->selfTraverse ())
00201 this->selfTraverse (true);
00202
00203 IgRepSet::invalidate (this, IgTwig::SELF_MASK | IgTwig::STRUCTURE_MASK);
00204 }
00205 }
00206
00207 MMM_DEFUN_FUNC(void,IgBrowserMethods::,doUpdate,
00208 (VisEventContentTwig *twig, IgTextRep *rep, unsigned))
00209 {
00210
00211 std::ostringstream text;
00212
00213 text << twig->name () << "<br>";
00214 rep->setText (text.str ());
00215 }