CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CmsShowMainBase.cc
Go to the documentation of this file.
2 
27 
29 
30 #include "TGLWidget.h"
31 #include "TGMsgBox.h"
32 #include "TROOT.h"
33 #include "TSystem.h"
34 #include "TStopwatch.h"
35 #include "TTimer.h"
36 #include "TEveManager.h"
37 
38 #include <boost/bind.hpp>
39 
41  :
42  m_changeManager(new FWModelChangeManager),
43  m_colorManager( new FWColorManager(m_changeManager.get())),
44  m_configurationManager(new FWConfigurationManager),
45  m_eiManager(new FWEventItemsManager(m_changeManager.get())),
46  m_guiManager(0),
47  m_selectionManager(new FWSelectionManager(m_changeManager.get())),
48  m_startupTasks(new CmsShowTaskExecutor),
49  m_viewManager(new FWViewManagerManager(m_changeManager.get(), m_colorManager.get())),
50  m_autoLoadTimer(new SignalTimer()),
51  m_navigatorPtr(0),
52  m_metadataManagerPtr(0),
53  m_contextPtr(0),
54  m_autoLoadTimerRunning(kFALSE),
55  m_forward(true),
56  m_isPlaying(false),
57  m_loop(false),
58  m_playDelay(3.f)
59 {
60 }
61 
63 {
64  //avoids a seg fault from eve which happens if eve is terminated after the GUI is gone
65  m_selectionManager->clearSelection();
66 }
67 
68 void
70 {
71  m_guiManager->writeToPresentConfigurationFile_.connect(sigc::mem_fun(*this, &CmsShowMainBase::writeToCurrentConfigFile));
72 
73  // init TGSlider state before signals are connected
74  m_guiManager->setDelayBetweenEvents(m_playDelay);
75 
76  m_navigatorPtr->newEvent_.connect(boost::bind(&CmsShowMainBase::eventChangedSlot, this));
77  if (m_guiManager->getAction(cmsshow::sNextEvent) != 0)
78  m_guiManager->getAction(cmsshow::sNextEvent)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::doNextEvent));
79  if (m_guiManager->getAction(cmsshow::sPreviousEvent) != 0)
80  m_guiManager->getAction(cmsshow::sPreviousEvent)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::doPreviousEvent));
81  if (m_guiManager->getAction(cmsshow::sGotoFirstEvent) != 0)
82  m_guiManager->getAction(cmsshow::sGotoFirstEvent)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::doFirstEvent));
83  if (m_guiManager->getAction(cmsshow::sGotoLastEvent) != 0)
84  m_guiManager->getAction(cmsshow::sGotoLastEvent)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::doLastEvent));
85  if (m_guiManager->getAction(cmsshow::sQuit) != 0)
86  m_guiManager->getAction(cmsshow::sQuit)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::quit));
87 
88  m_guiManager->changedEventId_.connect(boost::bind(&CmsShowMainBase::goToRunEvent,this,_1,_2,_3));
89  m_guiManager->playEventsAction()->started_.connect(sigc::mem_fun(*this, &CmsShowMainBase::playForward));
90  m_guiManager->playEventsBackwardsAction()->started_.connect(sigc::mem_fun(*this,&CmsShowMainBase::playBackward));
91  m_guiManager->loopAction()->started_.connect(sigc::mem_fun(*this,&CmsShowMainBase::setPlayLoopImp));
92  m_guiManager->loopAction()->stopped_.connect(sigc::mem_fun(*this,&CmsShowMainBase::unsetPlayLoopImp));
93  m_guiManager->changedDelayBetweenEvents_.connect(boost::bind(&CmsShowMainBase::setPlayDelay,this,_1));
94  m_guiManager->playEventsAction()->stopped_.connect(sigc::mem_fun(*this,&CmsShowMainBase::stopPlaying));
95  m_guiManager->playEventsBackwardsAction()->stopped_.connect(sigc::mem_fun(*this,&CmsShowMainBase::stopPlaying));
96 
97  m_autoLoadTimer->timeout_.connect(boost::bind(&CmsShowMainBase::autoLoadNewEvent, this));
98 }
99 
100 void
102 {
103  guiManager()->updateStatus("Setting up view manager...");
104 
105  boost::shared_ptr<FWViewManagerBase> eveViewManager(new FWEveViewManager(guiManager()));
106  eveViewManager->setContext(m_contextPtr);
107  viewManager()->add(eveViewManager);
108 
109  boost::shared_ptr<FWTableViewManager> tableViewManager(new FWTableViewManager(guiManager()));
110  configurationManager()->add(std::string("Tables"), tableViewManager.get());
111  viewManager()->add(tableViewManager);
112  eiManager()->goingToClearItems_.connect(boost::bind(&FWTableViewManager::removeAllItems, tableViewManager.get()));
113 
114  boost::shared_ptr<FWTriggerTableViewManager> triggerTableViewManager(new FWTriggerTableViewManager(guiManager()));
115  configurationManager()->add(std::string("TriggerTables"), triggerTableViewManager.get());
116  configurationManager()->add(std::string("L1TriggerTables"), triggerTableViewManager.get()); // AMT: added for backward compatibilty
117  triggerTableViewManager->setContext(m_contextPtr);
118  viewManager()->add(triggerTableViewManager);
119 
120 
121  // Unfortunately, due to the plugin mechanism, we need to delay
122  // until here the creation of the FWJobMetadataManager, because
123  // otherwise the supportedTypesAndRepresentations map is empty.
124  // FIXME: should we have a signal for whenever the above mentioned map
125  // changes? Can that actually happer (maybe if we add support
126  // for loading plugins on the fly??).
127  m_metadataManagerPtr->initReps(viewManager()->supportedTypesAndRepresentations());
128 }
129 
130 void
132 {
133  eventChangedImp();
134 }
135 
136 void
138 {
140 }
141 
142 void
144 {
146  checkPosition();
147  draw();
148 }
149 
150 void
152 {
154  checkPosition();
155  draw();
156 }
157 
158 void
160 {
162  checkPosition();
163  draw();
164 }
165 void
167 {
169  checkPosition();
170  draw();
171 }
172 
173 void
175 {
176  m_navigatorPtr->goToRunEvent(run, lumi, event);
177  checkPosition();
178  draw();
179 }
180 
181 
182 void
184 {
185  m_guiManager->updateStatus("loading event ...");
186 
188  {
190  }
192 
193  TStopwatch sw;
194  m_viewManager->eventBegin();
196  m_viewManager->eventEnd();
197  sw.Stop();
198  fwLog(fwlog::kDebug) << "CmsShowMainBase::draw CpuTime " << sw.CpuTime()
199  <<" RealTime " << sw.RealTime() << std::endl;
200 
201  if (!m_autoSaveAllViewsFormat.empty())
202  {
203  m_guiManager->updateStatus("auto saving images ...");
204  m_guiManager->exportAllViews(m_autoSaveAllViewsFormat);
205  }
206 
207  m_guiManager->clearStatus();
208 }
209 
210 void
212  fireworks::Context *context,
213  FWJobMetadataManager *metadataManager)
214 {
215  m_navigatorPtr = navigator;
216  m_contextPtr = context;
217  m_metadataManagerPtr = metadataManager;
218 
219  m_colorManager->initialize();
222 
223  m_eiManager->newItem_.connect(boost::bind(&FWModelChangeManager::newItemSlot,
224  m_changeManager.get(), _1) );
225 
226  m_eiManager->newItem_.connect(boost::bind(&FWViewManagerManager::registerEventItem,
227  m_viewManager.get(), _1));
228  m_configurationManager->add("EventItems",m_eiManager.get());
229  m_configurationManager->add("GUI",m_guiManager.get());
230  m_configurationManager->add("EventNavigator", m_navigatorPtr);
231  m_configurationManager->add("CommonPreferences", m_contextPtr->commonPrefs()); // must be after GUIManager in alphabetical order
232 
233  m_guiManager->writeToConfigurationFile_.connect(boost::bind(&CmsShowMainBase::writeToConfigFile,
234  this,_1));
235 
236  m_guiManager->loadFromConfigurationFile_.connect(boost::bind(&CmsShowMainBase::reloadConfiguration,
237  this, _1));
238  std::string macPath(gSystem->Getenv("CMSSW_BASE"));
239  macPath += "/src/Fireworks/Core/macros";
240  const char* base = gSystem->Getenv("CMSSW_RELEASE_BASE");
241  if(0!=base) {
242  macPath+=":";
243  macPath +=base;
244  macPath +="/src/Fireworks/Core/macros";
245  }
246  gROOT->SetMacroPath((std::string("./:")+macPath).c_str());
247 
248  m_startupTasks->tasksCompleted_.connect(boost::bind(&FWGUIManager::clearStatus,
249  m_guiManager.get()) );
250 }
251 
252 void
254 {
257 }
258 
259 void
261 {
263 }
264 
265 void
267 {
268  if (config.empty())
269  return;
270 
272 
273  std::string msg = "Reloading configuration "
274  + config + "...";
275  fwLog(fwlog::kDebug) << msg << std::endl;
276  m_guiManager->updateStatus(msg.c_str());
277  m_guiManager->subviewDestroyAll();
278  m_eiManager->clearItems();
280  try
281  {
282  gEve->DisableRedraw();
283  m_configurationManager->readFromFile(config);
284  gEve->EnableRedraw();
285  }
286  catch (std::runtime_error &e)
287  {
288  Int_t chosen;
289  new TGMsgBox(gClient->GetDefaultRoot(),
290  gClient->GetDefaultRoot(),
291  "Bad configuration",
292  ("Configuration " + config + " cannot be parsed.").c_str(),
293  kMBIconExclamation,
294  kMBCancel,
295  &chosen);
296  }
298  {
299  Int_t chosen;
300  new TGMsgBox(gClient->GetDefaultRoot(),
301  gClient->GetDefaultRoot(),
302  "Bad configuration",
303  ("Configuration " + config + " cannot be parsed.").c_str(),
304  kMBIconExclamation,
305  kMBCancel,
306  &chosen);
307  }
308  m_guiManager->updateStatus("");
309 }
310 
311 void
313 {
314  m_playDelay = x;
315  m_guiManager->setDelayBetweenEvents(m_playDelay);
316  if (!m_guiManager->playEventsAction()->isEnabled())
317  m_guiManager->playEventsAction()->enable();
318 
319  m_guiManager->playEventsAction()->switchMode();
320 }
321 
322 void
324 {
325  m_autoLoadTimer->SetTime((Long_t)(m_playDelay*1000));
326  m_autoLoadTimer->Reset();
327  m_autoLoadTimer->TurnOn();
328  m_autoLoadTimerRunning = kTRUE;
329 }
330 
331 void
333 {
334  m_autoLoadTimer->TurnOff();
335  m_autoLoadTimerRunning = kFALSE;
336 }
337 
338 void
340 {
341  m_guiManager->updateStatus("Setting up configuration...");
342  if(m_configFileName.empty() ) {
343  fwLog(fwlog::kInfo) << "no configuration is loaded." << std::endl;
344  m_guiManager->getMainFrame()->MapSubwindows();
345  m_guiManager->getMainFrame()->Layout();
346  m_guiManager->getMainFrame()->MapRaised();
347  m_configFileName = "newconfig.fwc";
348  m_guiManager->createView("Rho Phi");
349  m_guiManager->createView("Rho Z");
350  }
351  else {
352  char* whereConfig = gSystem->Which(TROOT::GetMacroPath(), m_configFileName.c_str(), kReadPermission);
353  if(0==whereConfig) {
354  fwLog(fwlog::kInfo) <<"unable to load configuration file '"<<m_configFileName<<"' will load default instead."<<std::endl;
355  whereConfig = gSystem->Which(TROOT::GetMacroPath(), "default.fwc", kReadPermission);
356  assert(whereConfig && "Default configuration cannot be found. Malformed Fireworks installation?");
357  }
358  m_configFileName = whereConfig;
359 
360  delete [] whereConfig;
361  try
362  {
363  gEve->DisableRedraw();
365  gEve->EnableRedraw();
366  }
367  catch (std::runtime_error &e)
368  {
369  fwLog(fwlog::kError) <<"Unable to load configuration file '"
370  << m_configFileName
371  << "' which was specified on command line. Quitting."
372  << std::endl;
373  exit(1);
374  }
376  {
377  fwLog(fwlog::kError) <<"Unable to load configuration file '"
378  << m_configFileName
379  << "' which was specified on command line. Quitting."
380  << std::endl;
381  exit(1);
382  }
383  }
384  /*
385  if(not m_configFileName.empty() ) {
386  //when the program quits we will want to save the configuration automatically
387  m_guiManager->goingToQuit_.connect(
388  boost::bind(&FWConfigurationManager::writeToFile,
389  m_configurationManager.get(),
390  m_configFileName));
391  }
392  */
393 }
394 
395 
396 void
398 {
399  m_playDelay = val;
400 }
401 
402 void
404 {
405  m_guiManager->updateStatus("Setting up Eve debug window...");
406  m_guiManager->openEveBrowserForDebugging();
407 }
408 
409 void
411 {
412  if(!m_loop) {
413  setPlayLoopImp();
414  m_guiManager->loopAction()->activated();
415  }
416 }
417 
418 void
420 {
421  if(m_loop) {
423  m_guiManager->loopAction()->stop();
424  }
425 }
426 
427 void
429 {
430  m_loop = true;
431 }
432 
433 void
435 {
436  m_loop = false;
437 }
438 
439 void
441 {
442  m_eiManager->add(iItem);
443 }
444 
445 void
447 {
448  m_forward = true;
449  m_isPlaying = true;
450  guiManager()->enableActions(kFALSE);
452 }
453 
454 void
456 {
457  m_forward = false;
458  m_isPlaying = true;
459  guiManager()->enableActions(kFALSE);
461 }
462 
463 void
465 { // prepare geometry service
466  // ATTN: this should be made configurable
467  try
468  {
469  guiManager()->updateStatus("Loading geometry...");
472  }
473  catch (const std::runtime_error& iException)
474  {
475  fwLog(fwlog::kError) << "CmsShowMain::loadGeometry() caught exception: \n"
476  << m_geometryFilename << " "
477  << iException.what() << std::endl;
478  exit(0);
479  }
480 }
tuple base
Main Program
Definition: newFWLiteAna.py:92
void registerEventItem(const FWEventItem *iItem)
virtual void goToRunEvent(edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t)=0
std::auto_ptr< FWConfigurationManager > m_configurationManager
std::string m_geometryFilename
FWGUIManager * guiManager()
void setGeom(const FWGeometry *x)
Definition: Context.h:52
void writeToConfigFile(const std::string &config)
unsigned int EventNumber_t
Definition: EventID.h:30
virtual void nextEvent()=0
tuple lumi
Definition: fjr2json.py:41
FWEventItemsManager * eiManager()
void initReps(const FWTypeToRepresentations &iTypeAndReps)
void initEveElements()
Definition: Context.cc:96
std::auto_ptr< FWSelectionManager > m_selectionManager
std::auto_ptr< FWEventItemsManager > m_eiManager
void setup(FWNavigatorBase *navigator, fireworks::Context *context, FWJobMetadataManager *metadataManager)
void updateStatus(const char *status)
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
void enableActions(bool enable=true)
virtual void checkPosition()=0
void checkBeamSpot(const edm::EventBase *event)
Definition: FWBeamSpot.cc:5
const std::string sNextEvent
Definition: ActionsList.cc:5
virtual ~CmsShowMainBase()
void setupAutoLoad(float x)
FWNavigatorBase * m_navigatorPtr
void newItemSlot(FWEventItem *)
FWBeamSpot * getBeamSpot() const
Definition: Context.h:79
void reloadConfiguration(const std::string &config)
FWMagField * getField() const
Definition: Context.h:78
virtual void firstEvent()=0
std::auto_ptr< SignalTimer > m_autoLoadTimer
void loadMap(const char *fileName)
Definition: FWGeometry.cc:65
void setPlayDelay(Float_t val)
virtual void eventChangedImp()
virtual void quit()=0
FWJobMetadataManager * m_metadataManagerPtr
double f[11][100]
const std::string sGotoLastEvent
Definition: ActionsList.cc:4
ESource getSource() const
Definition: FWMagField.h:34
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual void previousEvent()=0
virtual const edm::EventBase * getCurrentEvent() const =0
std::auto_ptr< CmsShowTaskExecutor > m_startupTasks
void eventChangedCallback()
void clearStatus()
void checkFieldInfo(const edm::EventBase *)
Definition: FWMagField.cc:172
FWViewManagerManager * viewManager()
virtual void autoLoadNewEvent()=0
void add(boost::shared_ptr< FWViewManagerBase >)
#define fwLog(_level_)
Definition: fwLog.h:51
const std::string sGotoFirstEvent
Definition: ActionsList.cc:3
fireworks::Context * m_contextPtr
CmsShowCommon * commonPrefs() const
Definition: Context.cc:179
void add(const std::string &iName, FWConfigurable *)
does not take ownership
virtual void stopPlaying()=0
const std::string sPreviousEvent
Definition: ActionsList.cc:6
FWConfigurationManager * configurationManager()
void writeToCurrentConfigFile()
std::string m_autoSaveAllViewsFormat
tuple config
Definition: cmsDriver.py:17
std::auto_ptr< FWModelChangeManager > m_changeManager
void registerPhysicsObject(const FWPhysicsObjectDesc &iItem)
unsigned int RunNumber_t
Definition: EventRange.h:32
const std::string sQuit
Definition: ActionsList.cc:22
void goToRunEvent(edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t)
std::auto_ptr< FWViewManagerManager > m_viewManager
std::auto_ptr< FWColorManager > m_colorManager
sigc::signal< void > goingToClearItems_
std::auto_ptr< FWGUIManager > m_guiManager
T get(const Candidate &c)
Definition: component.h:56
virtual void lastEvent()=0
sigc::signal< void > newEvent_
std::string m_configFileName