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 
28 
30 
31 #include "TGLWidget.h"
32 #include "TGMsgBox.h"
33 #include "TROOT.h"
34 #include "TSystem.h"
35 #include "TStopwatch.h"
36 #include "TTimer.h"
37 #include "TEveManager.h"
38 
39 #include <boost/bind.hpp>
40 
42  :
43  m_changeManager(new FWModelChangeManager),
44  m_colorManager( new FWColorManager(m_changeManager.get())),
45  m_configurationManager(new FWConfigurationManager),
46  m_eiManager(new FWEventItemsManager(m_changeManager.get())),
47  m_guiManager(0),
48  m_selectionManager(new FWSelectionManager(m_changeManager.get())),
49  m_startupTasks(new CmsShowTaskExecutor),
50  m_viewManager(new FWViewManagerManager(m_changeManager.get(), m_colorManager.get())),
51  m_autoLoadTimer(new SignalTimer()),
52  m_navigatorPtr(0),
53  m_metadataManagerPtr(0),
54  m_contextPtr(0),
55  m_autoLoadTimerRunning(kFALSE),
56  m_forward(true),
57  m_isPlaying(false),
58  m_loop(false),
59  m_playDelay(3.f)
60 {
61 }
62 
64 {
65 }
66 
67 void
69 {
70  m_guiManager->writeToPresentConfigurationFile_.connect(sigc::mem_fun(*this, &CmsShowMainBase::writeToCurrentConfigFile));
71 
72  // init TGSlider state before signals are connected
73  m_guiManager->setDelayBetweenEvents(m_playDelay);
74 
75  m_navigatorPtr->newEvent_.connect(boost::bind(&CmsShowMainBase::eventChangedSlot, this));
76  if (m_guiManager->getAction(cmsshow::sNextEvent) != 0)
77  m_guiManager->getAction(cmsshow::sNextEvent)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::doNextEvent));
78  if (m_guiManager->getAction(cmsshow::sPreviousEvent) != 0)
79  m_guiManager->getAction(cmsshow::sPreviousEvent)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::doPreviousEvent));
80  if (m_guiManager->getAction(cmsshow::sGotoFirstEvent) != 0)
81  m_guiManager->getAction(cmsshow::sGotoFirstEvent)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::doFirstEvent));
82  if (m_guiManager->getAction(cmsshow::sGotoLastEvent) != 0)
83  m_guiManager->getAction(cmsshow::sGotoLastEvent)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::doLastEvent));
84  if (m_guiManager->getAction(cmsshow::sQuit) != 0)
85  m_guiManager->getAction(cmsshow::sQuit)->activated.connect(sigc::mem_fun(*this, &CmsShowMainBase::quit));
86 
87  m_guiManager->changedEventId_.connect(boost::bind(&CmsShowMainBase::goToRunEvent,this,_1,_2,_3));
88  m_guiManager->playEventsAction()->started_.connect(sigc::mem_fun(*this, &CmsShowMainBase::playForward));
89  m_guiManager->playEventsBackwardsAction()->started_.connect(sigc::mem_fun(*this,&CmsShowMainBase::playBackward));
90  m_guiManager->loopAction()->started_.connect(sigc::mem_fun(*this,&CmsShowMainBase::setPlayLoopImp));
91  m_guiManager->loopAction()->stopped_.connect(sigc::mem_fun(*this,&CmsShowMainBase::unsetPlayLoopImp));
92  m_guiManager->changedDelayBetweenEvents_.connect(boost::bind(&CmsShowMainBase::setPlayDelay,this,_1));
93  m_guiManager->playEventsAction()->stopped_.connect(sigc::mem_fun(*this,&CmsShowMainBase::stopPlaying));
94  m_guiManager->playEventsBackwardsAction()->stopped_.connect(sigc::mem_fun(*this,&CmsShowMainBase::stopPlaying));
95 
96  m_autoLoadTimer->timeout_.connect(boost::bind(&CmsShowMainBase::autoLoadNewEvent, this));
97 }
98 
99 void
101 {
102  guiManager()->updateStatus("Setting up view manager...");
103 
104  boost::shared_ptr<FWViewManagerBase> eveViewManager(new FWEveViewManager(guiManager()));
105  eveViewManager->setContext(m_contextPtr);
106  viewManager()->add(eveViewManager);
107 
108  boost::shared_ptr<FWTableViewManager> tableViewManager(new FWTableViewManager(guiManager()));
109  configurationManager()->add(std::string("Tables"), tableViewManager.get());
110  viewManager()->add(tableViewManager);
111  eiManager()->goingToClearItems_.connect(boost::bind(&FWTableViewManager::removeAllItems, tableViewManager.get()));
112 
113  boost::shared_ptr<FWTriggerTableViewManager> triggerTableViewManager(new FWTriggerTableViewManager(guiManager()));
114  configurationManager()->add(std::string("TriggerTables"), triggerTableViewManager.get());
115  configurationManager()->add(std::string("L1TriggerTables"), triggerTableViewManager.get()); // AMT: added for backward compatibilty
116  triggerTableViewManager->setContext(m_contextPtr);
117  viewManager()->add(triggerTableViewManager);
118 
119  boost::shared_ptr<FWGeometryTableViewManager> geoTableViewManager(new FWGeometryTableViewManager(guiManager(), m_simGeometryFilename));
120  geoTableViewManager->setContext(m_contextPtr);
121  viewManager()->add(geoTableViewManager);
122 
123 
124  // Unfortunately, due to the plugin mechanism, we need to delay
125  // until here the creation of the FWJobMetadataManager, because
126  // otherwise the supportedTypesAndRepresentations map is empty.
127  // FIXME: should we have a signal for whenever the above mentioned map
128  // changes? Can that actually happer (maybe if we add support
129  // for loading plugins on the fly??).
130  m_metadataManagerPtr->initReps(viewManager()->supportedTypesAndRepresentations());
131 }
132 
133 void
135 {
136  eventChangedImp();
137 }
138 
139 void
141 {
143 }
144 
145 void
147 {
149  checkPosition();
150  draw();
151 }
152 
153 void
155 {
157  checkPosition();
158  draw();
159 }
160 
161 void
163 {
165  checkPosition();
166  draw();
167 }
168 void
170 {
172  checkPosition();
173  draw();
174 }
175 
176 void
178 {
179  m_navigatorPtr->goToRunEvent(run, lumi, event);
180  checkPosition();
181  draw();
182 }
183 
184 
185 void
187 {
188  m_guiManager->updateStatus("loading event ...");
189 
191  {
193  }
195 
196  TStopwatch sw;
197  m_viewManager->eventBegin();
199  m_viewManager->eventEnd();
200  sw.Stop();
201  fwLog(fwlog::kDebug) << "CmsShowMainBase::draw CpuTime " << sw.CpuTime()
202  <<" RealTime " << sw.RealTime() << std::endl;
203 
204  if (!m_autoSaveAllViewsFormat.empty())
205  {
206  m_guiManager->updateStatus("auto saving images ...");
207  m_guiManager->exportAllViews(m_autoSaveAllViewsFormat);
208  }
209 
210  m_guiManager->clearStatus();
211 }
212 
213 void
215  fireworks::Context *context,
216  FWJobMetadataManager *metadataManager)
217 {
218  m_navigatorPtr = navigator;
219  m_contextPtr = context;
220  m_metadataManagerPtr = metadataManager;
221 
222  m_colorManager->initialize();
225 
226  m_eiManager->newItem_.connect(boost::bind(&FWModelChangeManager::newItemSlot,
227  m_changeManager.get(), _1) );
228 
229  m_eiManager->newItem_.connect(boost::bind(&FWViewManagerManager::registerEventItem,
230  m_viewManager.get(), _1));
231  m_configurationManager->add("EventItems",m_eiManager.get());
232  m_configurationManager->add("GUI",m_guiManager.get());
233  m_configurationManager->add("EventNavigator", m_navigatorPtr);
234  m_configurationManager->add("CommonPreferences", m_contextPtr->commonPrefs()); // must be after GUIManager in alphabetical order
235 
236  m_guiManager->writeToConfigurationFile_.connect(boost::bind(&CmsShowMainBase::writeToConfigFile,
237  this,_1));
238 
239  m_guiManager->loadFromConfigurationFile_.connect(boost::bind(&CmsShowMainBase::reloadConfiguration,
240  this, _1));
241  std::string macPath(gSystem->Getenv("CMSSW_BASE"));
242  macPath += "/src/Fireworks/Core/macros";
243  const char* base = gSystem->Getenv("CMSSW_RELEASE_BASE");
244  if(0!=base) {
245  macPath+=":";
246  macPath +=base;
247  macPath +="/src/Fireworks/Core/macros";
248  }
249  gROOT->SetMacroPath((std::string("./:")+macPath).c_str());
250 
251  m_startupTasks->tasksCompleted_.connect(boost::bind(&FWGUIManager::clearStatus,
252  m_guiManager.get()) );
253 }
254 
255 void
257 {
260 }
261 
262 void
264 {
266 }
267 
268 void
270 {
271  if (config.empty())
272  return;
273 
275 
276  std::string msg = "Reloading configuration "
277  + config + "...";
278  fwLog(fwlog::kDebug) << msg << std::endl;
279  m_guiManager->updateStatus(msg.c_str());
280  m_guiManager->subviewDestroyAll();
281  m_eiManager->clearItems();
283  try
284  {
285  gEve->DisableRedraw();
286  m_configurationManager->readFromFile(config);
287  gEve->EnableRedraw();
288  }
289  catch (std::runtime_error &e)
290  {
291  Int_t chosen;
292  new TGMsgBox(gClient->GetDefaultRoot(),
293  gClient->GetDefaultRoot(),
294  "Bad configuration",
295  ("Configuration " + config + " cannot be parsed.").c_str(),
296  kMBIconExclamation,
297  kMBCancel,
298  &chosen);
299  }
301  {
302  Int_t chosen;
303  new TGMsgBox(gClient->GetDefaultRoot(),
304  gClient->GetDefaultRoot(),
305  "Bad configuration",
306  ("Configuration " + config + " cannot be parsed.").c_str(),
307  kMBIconExclamation,
308  kMBCancel,
309  &chosen);
310  }
311  m_guiManager->updateStatus("");
312 }
313 
314 void
316 {
317  m_playDelay = x;
318  m_guiManager->setDelayBetweenEvents(m_playDelay);
319  if (!m_guiManager->playEventsAction()->isEnabled())
320  m_guiManager->playEventsAction()->enable();
321 
322  m_guiManager->playEventsAction()->switchMode();
323 }
324 
325 void
327 {
328  m_autoLoadTimer->SetTime((Long_t)(m_playDelay*1000));
329  m_autoLoadTimer->Reset();
330  m_autoLoadTimer->TurnOn();
331  m_autoLoadTimerRunning = kTRUE;
332 }
333 
334 void
336 {
337  m_autoLoadTimer->TurnOff();
338  m_autoLoadTimerRunning = kFALSE;
339 }
340 
341 void
343 {
344  m_guiManager->updateStatus("Setting up configuration...");
345  if(m_configFileName.empty() ) {
346  fwLog(fwlog::kInfo) << "no configuration is loaded." << std::endl;
347  m_guiManager->getMainFrame()->MapSubwindows();
348  m_guiManager->getMainFrame()->Layout();
349  m_guiManager->getMainFrame()->MapRaised();
350  m_configFileName = "newconfig.fwc";
351  m_guiManager->createView("Rho Phi");
352  m_guiManager->createView("Rho Z");
353  }
354  else {
355  char* whereConfig = gSystem->Which(TROOT::GetMacroPath(), m_configFileName.c_str(), kReadPermission);
356  if(0==whereConfig) {
357  fwLog(fwlog::kInfo) <<"unable to load configuration file '"<<m_configFileName<<"' will load default instead."<<std::endl;
358  whereConfig = gSystem->Which(TROOT::GetMacroPath(), "default.fwc", kReadPermission);
359  assert(whereConfig && "Default configuration cannot be found. Malformed Fireworks installation?");
360  }
361  m_configFileName = whereConfig;
362 
363  delete [] whereConfig;
364  try
365  {
366  gEve->DisableRedraw();
368  gEve->EnableRedraw();
369  }
370  catch (std::runtime_error &e)
371  {
372  fwLog(fwlog::kError) <<"Unable to load configuration file '"
373  << m_configFileName
374  << "' which was specified on command line. Quitting."
375  << std::endl;
376  exit(1);
377  }
379  {
380  fwLog(fwlog::kError) <<"Unable to load configuration file '"
381  << m_configFileName
382  << "' which was specified on command line. Quitting."
383  << std::endl;
384  exit(1);
385  }
386  }
387  /*
388  if(not m_configFileName.empty() ) {
389  //when the program quits we will want to save the configuration automatically
390  m_guiManager->goingToQuit_.connect(
391  boost::bind(&FWConfigurationManager::writeToFile,
392  m_configurationManager.get(),
393  m_configFileName));
394  }
395  */
396 }
397 
398 
399 void
401 {
402  m_playDelay = val;
403 }
404 
405 void
407 {
408  m_guiManager->updateStatus("Setting up Eve debug window...");
409  m_guiManager->openEveBrowserForDebugging();
410 }
411 
412 void
414 {
415  if(!m_loop) {
416  setPlayLoopImp();
417  m_guiManager->loopAction()->activated();
418  }
419 }
420 
421 void
423 {
424  if(m_loop) {
426  m_guiManager->loopAction()->stop();
427  }
428 }
429 
430 void
432 {
433  m_loop = true;
434 }
435 
436 void
438 {
439  m_loop = false;
440 }
441 
442 void
444 {
445  m_eiManager->add(iItem);
446 }
447 
448 void
450 {
451  m_forward = true;
452  m_isPlaying = true;
453  guiManager()->enableActions(kFALSE);
455 }
456 
457 void
459 {
460  m_forward = false;
461  m_isPlaying = true;
462  guiManager()->enableActions(kFALSE);
464 }
465 
466 void
468 { // prepare geometry service
469  // ATTN: this should be made configurable
470  try
471  {
472  guiManager()->updateStatus("Loading geometry...");
475  }
476  catch (const std::runtime_error& iException)
477  {
478  fwLog(fwlog::kError) << "CmsShowMain::loadGeometry() caught exception: \n"
479  << m_geometryFilename << " "
480  << iException.what() << std::endl;
481  exit(0);
482  }
483 }
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< 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:6
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
std::string m_simGeometryFilename
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
std::auto_ptr< FWModelChangeManager > m_changeManager
void registerPhysicsObject(const FWPhysicsObjectDesc &iItem)
unsigned int RunNumber_t
Definition: EventRange.h:32
Definition: DDAxes.h:10
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