CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
FWFFService Class Reference

#include <FWFFService.h>

Inheritance diagram for FWFFService:
CmsShowMainBase

Public Member Functions

void autoLoadNewEvent () override
 
void checkPosition () override
 
void display (const std::string &info="")
 
 FWFFService (const edm::ParameterSet &, edm::ActivityRegistry &)
 
TEveMagField * getMagField ()
 
void postBeginJob ()
 
void postBeginRun (const edm::Run &, const edm::EventSetup &)
 
void postEndJob ()
 
void postProcessEvent (const edm::Event &, const edm::EventSetup &)
 
void quit () override
 
void setupFieldForPropagator (TEveTrackPropagator *prop)
 
void stopPlaying () override
 
 ~FWFFService () override
 
- Public Member Functions inherited from CmsShowMainBase
FWModelChangeManagerchangeManager ()
 
virtual void checkKeyBindingsOnPLayEventsStateChanged ()
 
 CmsShowMainBase ()
 
FWColorManagercolorManager ()
 
const char * configFilename () const
 
FWConfigurationManagerconfigurationManager ()
 
void doFirstEvent ()
 
void doLastEvent ()
 
void doNextEvent ()
 
void doPreviousEvent ()
 
void draw ()
 
FWEventItemsManagereiManager ()
 
bool forward () const
 
const std::string & geometryFilename (void)
 
FWGeometrygetGeom ()
 
void goToRunEvent (edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t)
 
FWGUIManagerguiManager ()
 
bool isPlaying () const
 
void loadGeometry ()
 
bool loop () const
 
FWModelChangeManagermodelChangeManager ()
 
void partialLoadConfiguration (const std::string &config)
 
void partialWriteToConfigFile (const std::string &config)
 
void playBackward ()
 
void playForward ()
 
void registerPhysicsObject (const FWPhysicsObjectDesc &iItem)
 
void reloadConfiguration (const std::string &config)
 
FWSelectionManagerselectionManager ()
 
void setAutoSaveAllViewsFormat (const std::string &fmt)
 
void setAutoSaveAllViewsHeight (int x)
 
void setConfigFilename (const std::string &f)
 
void setGeometryFilename (const std::string &filename)
 
void setPlayDelay (Float_t val)
 
void setPlayLoop ()
 
void setSimGeometryFilename (const std::string &filename, const std::string &geoname)
 
void setup (FWNavigatorBase *navigator, fireworks::Context *context, FWJobMetadataManager *metadataManager)
 
void setupActions ()
 
void setupAutoLoad (float x)
 
void setupConfiguration ()
 
void setupDebugSupport ()
 
void setupViewManagers ()
 
void startAutoLoadTimer ()
 
CmsShowTaskExecutorstartupTasks ()
 
void stopAutoLoadTimer ()
 
void unsetPlayLoop ()
 
FWViewManagerManagerviewManager ()
 
void writePartialToConfigFile ()
 
void writeToConfigFile (const std::string &config)
 
void writeToCurrentConfigFile ()
 
virtual ~CmsShowMainBase () noexcept(false)
 

Private Member Functions

 FWFFService (const FWFFService &)=delete
 
const FWFFServiceoperator= (const FWFFService &)=delete
 

Private Attributes

bool m_AllowStep
 
FWFFHelper m_appHelper
 
std::unique_ptr< fireworks::Contextm_context
 
TEveManager * m_EveManager
 
bool m_firstTime
 
TEveMagField * m_MagField
 
std::unique_ptr< FWFFMetadataManagerm_metadataManager
 
std::unique_ptr< FWFFNavigatorm_navigator
 
TRint * m_Rint
 
bool m_ShowEvent
 

Additional Inherited Members

- Protected Member Functions inherited from CmsShowMainBase
fireworks::Contextcontext ()
 
virtual void eventChangedImp ()
 
void eventChangedSlot ()
 
void sendVersionInfo ()
 

Detailed Description

Definition at line 31 of file FWFFService.h.

Constructor & Destructor Documentation

◆ FWFFService() [1/2]

FWFFService::FWFFService ( const edm::ParameterSet ps,
edm::ActivityRegistry ar 
)

Definition at line 100 of file FWFFService.cc.

101  : CmsShowMainBase(),
102  m_navigator(new FWFFNavigator(*this)),
106  m_appHelper(ps, ar),
108  m_AllowStep(true),
109  m_ShowEvent(true),
110  m_firstTime(true) {
111  printf("FWFFService::FWFFService CTOR\n");
112 
113  setup(m_navigator.get(), m_context.get(), m_metadataManager.get());
114 
115  eiManager()->setContext(m_context.get());
116 
117  // By default, we look up geometry and configuration in the workarea, then
118  // in the release area then in the local directory. It is also possible to
119  // override those locations by using the displayConfigurationFilename and
120  // geometryFilename in the parameterset.
121  const char* releaseBase = std::getenv("CMSSW_RELEASE_BASE");
122  const char* workarea = std::getenv("CMSSW_BASE");
123  std::string displayConfigRelFilename = "/src/Fireworks/FWInterface/macros/ffw.fwc";
124  std::string geometryRelFilename = "/src/Fireworks/FWInterface/data/cmsGeom10.root";
125 
126  std::string displayConfigFilename = "ffw.fwc";
128 
129  if (releaseBase && access((releaseBase + displayConfigFilename).c_str(), R_OK) == 0)
130  displayConfigFilename = releaseBase + displayConfigRelFilename;
131  if (workarea && access((workarea + displayConfigRelFilename).c_str(), R_OK) == 0)
132  displayConfigFilename = workarea + displayConfigRelFilename;
133 
134  if (releaseBase && access((releaseBase + geometryRelFilename).c_str(), R_OK) == 0)
135  geometryFilename = releaseBase + geometryRelFilename;
136  if (workarea && access((workarea + geometryRelFilename).c_str(), R_OK) == 0)
137  geometryFilename = workarea + geometryRelFilename;
138 
139  displayConfigFilename = ps.getUntrackedParameter<std::string>("diplayConfigFilename", displayConfigFilename);
141 
143  setConfigFilename(displayConfigFilename);
144 
146 
147  if (!geometryFilename.empty()) {
148  f = std::bind(&CmsShowMainBase::loadGeometry, this);
149  startupTasks()->addTask(f);
150  }
151 
152  m_MagField = new CmsEveMagField();
153 
154  // ----------------------------------------------------------------
155 
158 
160 
162 }

References CmsShowTaskExecutor::addTask(), CmsShowMainBase::eiManager(), f, CmsShowMainBase::geometryFilename(), edm::ParameterSet::getUntrackedParameter(), CmsShowMainBase::loadGeometry(), m_context, m_MagField, m_metadataManager, m_navigator, postBeginJob(), postBeginRun(), postEndJob(), postProcessEvent(), CmsShowMainBase::setConfigFilename(), FWEventItemsManager::setContext(), CmsShowMainBase::setGeometryFilename(), CmsShowMainBase::setup(), CmsShowMainBase::startupTasks(), AlCaHLTBitMon_QueryRunRegistry::string, edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostBeginRun(), edm::ActivityRegistry::watchPostEndJob(), and edm::ActivityRegistry::watchPostProcessEvent().

◆ ~FWFFService()

FWFFService::~FWFFService ( )
override

Definition at line 164 of file FWFFService.cc.

164  {
165  printf("FWFFService::~FWFFService DTOR\n");
166 
167  delete m_MagField;
168 }

References m_MagField.

◆ FWFFService() [2/2]

FWFFService::FWFFService ( const FWFFService )
privatedelete

Member Function Documentation

◆ autoLoadNewEvent()

void FWFFService::autoLoadNewEvent ( )
inlineoverridevirtual

Implements CmsShowMainBase.

Definition at line 56 of file FWFFService.h.

56 {}

◆ checkPosition()

void FWFFService::checkPosition ( )
overridevirtual

Implements CmsShowMainBase.

Definition at line 196 of file FWFFService.cc.

196  {
197  if (loop() && isPlaying())
198  return;
199 
201 
202  if (m_navigator->isFirstEvent())
204 
205  if (m_navigator->isLastEvent()) {
206  guiManager()->disableNext();
207  // force enable play events action in --port mode
208  if (!guiManager()->playEventsAction()->isEnabled())
210  }
211 }

References FWGUIManager::disableNext(), FWGUIManager::disablePrevious(), CSGAction::enable(), CmsShowMainFrame::enableNavigatorControls(), FWGUIManager::getMainFrame(), CmsShowMainBase::guiManager(), CmsShowMainBase::isPlaying(), CmsShowMainBase::loop(), m_navigator, and FWGUIManager::playEventsAction().

Referenced by postProcessEvent().

◆ display()

void FWFFService::display ( const std::string &  info = "")

Definition at line 272 of file FWFFService.cc.

272  {
273  // Display whatever was registered so far, wait until user presses
274  // the "Step" button.
275 
276  if (m_AllowStep) {
277  gEve->Redraw3D();
278  m_Rint->Run(kTRUE);
279  }
280 }

References m_AllowStep, and m_Rint.

◆ getMagField()

TEveMagField * FWFFService::getMagField ( )

Definition at line 286 of file FWFFService.cc.

286 { return m_MagField; }

References m_MagField.

◆ operator=()

const FWFFService& FWFFService::operator= ( const FWFFService )
privatedelete

◆ postBeginJob()

void FWFFService::postBeginJob ( )

Definition at line 174 of file FWFFService.cc.

174  {
175  printf("FWFFService::postBeginJob\n");
176  // We need to enter the GUI loop in order to
177  // have all the callbacks executed. The last callback will
178  // be responsible for returning the control to CMSSW.
179  assert(m_Rint);
181  f = std::bind(&TApplication::Terminate, m_Rint, 0);
182  startupTasks()->addTask(f);
183  // FIXME: do we really need to delay tasks like this?
185  m_Rint->Run(kTRUE);
186  // Show the GUI ...
187  gSystem->ProcessEvents();
188 }

References CmsShowTaskExecutor::addTask(), cms::cuda::assert(), f, m_Rint, CmsShowTaskExecutor::startDoingTasks(), and CmsShowMainBase::startupTasks().

Referenced by FWFFService().

◆ postBeginRun()

void FWFFService::postBeginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 214 of file FWFFService.cc.

214  {
215  // If the geometry was not picked up from a file, we try to get it from the
216  // EventSetup!
217  // FIXME: we need to check we execute only once because the view managers
218  // depend on geometry and they cannot be initialised more than once.
219  // This should actually be cleaned up so that the various view manager
220  // don't care about geometry.
221  // FIXME: we should actually be able to update the geometry when requested.
222  // this is not possible at the moment.
223  if (m_firstTime == true) {
224  if (m_context->getGeom() == nullptr) {
225  guiManager()->updateStatus("Loading geometry...");
227  iSetup.get<FWRecoGeometryRecord>().get(geoh);
228  getGeom().initMap(geoh.product()->idToName);
229  m_context->setGeom(&(getGeom()));
230  }
231 
234  setupActions();
235  m_firstTime = false;
236  }
237 
238  float current = 18160.0f;
239 
241  // bool res = iRun.getByType(runCond);
242  bool res = iRun.getByLabel("conditionsInEdm", runCond);
243  if (res && runCond.isValid()) {
244  printf("Got current from conds in edm %f\n", runCond->BAvgCurrent);
245  current = runCond->BAvgCurrent;
246  } else {
247  printf("Could not extract run-conditions get-result=%d, is-valid=%d\n", res, runCond.isValid());
248 
250  iSetup.get<RunInfoRcd>().get(sum);
251 
252  current = sum->m_avg_current;
253  printf("Got current from RunInfoRcd %f\n", sum->m_avg_current);
254  }
255 
256  static_cast<CmsEveMagField*>(m_MagField)->SetFieldByCurrent(current);
257 }

References edm::ConditionsInRunBlock::BAvgCurrent, edm::EventSetup::get(), get, edm::Run::getByLabel(), CmsShowMainBase::getGeom(), CmsShowMainBase::guiManager(), FWRecoGeometry::idToName, FWGeometry::initMap(), edm::HandleBase::isValid(), m_context, m_firstTime, m_MagField, edm::ESTransientHandle< T >::product(), CmsShowMainBase::setupActions(), CmsShowMainBase::setupConfiguration(), CmsShowMainBase::setupViewManagers(), and FWGUIManager::updateStatus().

Referenced by FWFFService().

◆ postEndJob()

void FWFFService::postEndJob ( )

Definition at line 190 of file FWFFService.cc.

190  {
191  printf("FWFFService::postEndJob\n");
192 
193  TEveManager::Terminate();
194 }

Referenced by FWFFService().

◆ postProcessEvent()

void FWFFService::postProcessEvent ( const edm::Event event,
const edm::EventSetup es 
)

Definition at line 260 of file FWFFService.cc.

260  {
261  printf("FWFFService::postProcessEvent: Starting GUI loop.\n");
262 
264  m_navigator->setCurrentEvent(&event);
265  checkPosition();
266  draw();
267  m_Rint->Run(kTRUE);
268 }

References checkPosition(), CmsShowMainBase::draw(), m_metadataManager, m_navigator, and m_Rint.

Referenced by FWFFService().

◆ quit()

void FWFFService::quit ( )
overridevirtual

Implements CmsShowMainBase.

Definition at line 290 of file FWFFService.cc.

290  {
291  gSystem->ExitLoop();
292  printf("FWFFService exiting on user request.\n");
293 
294  // Throwing exception here is bad because:
295  // a) it does not work when in a "debug step";
296  // b) does not restore terminal state.
297  // So we do exit instead for now.
298  // throw cms::Exception("UserTerminationRequest");
299  gSystem->Exit(0);
300 }

◆ setupFieldForPropagator()

void FWFFService::setupFieldForPropagator ( TEveTrackPropagator *  prop)

Definition at line 288 of file FWFFService.cc.

288 { prop->SetMagFieldObj(m_MagField, kFALSE); }

References m_MagField.

◆ stopPlaying()

void FWFFService::stopPlaying ( )
inlineoverridevirtual

Reimplemented from CmsShowMainBase.

Definition at line 55 of file FWFFService.h.

55 {}

Member Data Documentation

◆ m_AllowStep

bool FWFFService::m_AllowStep
private

Definition at line 76 of file FWFFService.h.

Referenced by display().

◆ m_appHelper

FWFFHelper FWFFService::m_appHelper
private

Definition at line 70 of file FWFFService.h.

◆ m_context

std::unique_ptr<fireworks::Context> FWFFService::m_context
private

Definition at line 68 of file FWFFService.h.

Referenced by FWFFService(), and postBeginRun().

◆ m_EveManager

TEveManager* FWFFService::m_EveManager
private

Definition at line 71 of file FWFFService.h.

◆ m_firstTime

bool FWFFService::m_firstTime
private

Definition at line 78 of file FWFFService.h.

Referenced by postBeginRun().

◆ m_MagField

TEveMagField* FWFFService::m_MagField
private

◆ m_metadataManager

std::unique_ptr<FWFFMetadataManager> FWFFService::m_metadataManager
private

Definition at line 67 of file FWFFService.h.

Referenced by FWFFService(), and postProcessEvent().

◆ m_navigator

std::unique_ptr<FWFFNavigator> FWFFService::m_navigator
private

Definition at line 66 of file FWFFService.h.

Referenced by checkPosition(), FWFFService(), and postProcessEvent().

◆ m_Rint

TRint* FWFFService::m_Rint
private

Definition at line 72 of file FWFFService.h.

Referenced by display(), postBeginJob(), and postProcessEvent().

◆ m_ShowEvent

bool FWFFService::m_ShowEvent
private

Definition at line 77 of file FWFFService.h.

FWFFService::m_Rint
TRint * m_Rint
Definition: FWFFService.h:72
fireworks::Context
Definition: Context.h:41
CmsShowMainBase::changeManager
FWModelChangeManager * changeManager()
Definition: CmsShowMainBase.h:54
CmsShowMainBase::setupConfiguration
void setupConfiguration()
Definition: CmsShowMainBase.cc:322
FWFFService::postEndJob
void postEndJob()
Definition: FWFFService.cc:190
edm::ESTransientHandle::product
T const * product() const
Definition: ESTransientHandle.h:51
CmsShowMainBase::loadGeometry
void loadGeometry()
Definition: CmsShowMainBase.cc:395
FWRecoGeometryRecord
Definition: FWRecoGeometryRecord.h:9
FWFFService::m_metadataManager
std::unique_ptr< FWFFMetadataManager > m_metadataManager
Definition: FWFFService.h:67
CmsShowMainBase::guiManager
FWGUIManager * guiManager()
Definition: CmsShowMainBase.h:61
FWFFService::m_ShowEvent
bool m_ShowEvent
Definition: FWFFService.h:77
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
FWRecoGeometry::idToName
FWRecoGeom::InfoMap idToName
Definition: FWRecoGeometry.h:14
CmsShowMainFrame::enableNavigatorControls
void enableNavigatorControls()
Definition: CmsShowMainFrame.cc:567
FWFFService::postProcessEvent
void postProcessEvent(const edm::Event &, const edm::EventSetup &)
Definition: FWFFService.cc:260
FWFFHelper::app
TRint * app()
Definition: FWFFHelper.h:14
FWGUIManager::playEventsAction
CSGContinuousAction * playEventsAction()
Definition: FWGUIManager.cc:350
CmsShowMainBase::loop
bool loop() const
Definition: CmsShowMainBase.h:107
FWFFService::postBeginRun
void postBeginRun(const edm::Run &, const edm::EventSetup &)
Definition: FWFFService.cc:214
FWFFService::postBeginJob
void postBeginJob()
Definition: FWFFService.cc:174
cms::cuda::assert
assert(be >=bs)
CmsShowMainBase::setup
void setup(FWNavigatorBase *navigator, fireworks::Context *context, FWJobMetadataManager *metadataManager)
Definition: CmsShowMainBase.cc:199
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
CmsShowMainBase::setConfigFilename
void setConfigFilename(const std::string &f)
Definition: CmsShowMainBase.h:74
FWGUIManager::getMainFrame
CmsShowMainFrame * getMainFrame() const
Definition: FWGUIManager.h:197
FWGUIManager::updateStatus
void updateStatus(const char *status)
Definition: FWGUIManager.cc:367
edm::ActivityRegistry::watchPostEndJob
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
Definition: ActivityRegistry.h:170
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
CmsShowMainBase::setupActions
void setupActions()
Definition: CmsShowMainBase.cc:74
FWFFService::m_navigator
std::unique_ptr< FWFFNavigator > m_navigator
Definition: FWFFService.h:66
CmsShowMainBase::CmsShowMainBase
CmsShowMainBase()
Definition: CmsShowMainBase.cc:50
edm::ConditionsInRunBlock::BAvgCurrent
float BAvgCurrent
Definition: ConditionsInEdm.h:27
FWFFService::m_context
std::unique_ptr< fireworks::Context > m_context
Definition: FWFFService.h:68
edm::ESHandle
Definition: DTSurvey.h:22
edm::ActivityRegistry::watchPostBeginJob
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
Definition: ActivityRegistry.h:158
CmsShowMainBase::colorManager
FWColorManager * colorManager()
Definition: CmsShowMainBase.h:55
CmsShowMainBase::isPlaying
bool isPlaying() const
Definition: CmsShowMainBase.h:118
CmsShowMainBase::draw
void draw()
Definition: CmsShowMainBase.cc:176
CmsShowMainBase::startupTasks
CmsShowTaskExecutor * startupTasks()
Definition: CmsShowMainBase.h:66
RunInfoRcd
Definition: RunSummaryRcd.h:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CmsShowMainBase::geometryFilename
const std::string & geometryFilename(void)
Definition: CmsShowMainBase.h:91
FWGUIManager::disablePrevious
void disablePrevious()
Definition: FWGUIManager.cc:358
FWFFService::m_AllowStep
bool m_AllowStep
Definition: FWFFService.h:76
FWFFService::m_MagField
TEveMagField * m_MagField
Definition: FWFFService.h:74
CmsShowMainBase::setupViewManagers
void setupViewManagers()
Definition: CmsShowMainBase.cc:110
FWFFMetadataUpdateRequest
Definition: FWFFMetadataUpdateRequest.h:7
FWGUIManager::disableNext
void disableNext()
Definition: FWGUIManager.cc:360
CmsShowMainBase::setGeometryFilename
void setGeometryFilename(const std::string &filename)
Definition: CmsShowMainBase.h:90
edm::ActivityRegistry::watchPostBeginRun
void watchPostBeginRun(PostBeginRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:563
CmsShowMainBase::selectionManager
FWSelectionManager * selectionManager()
Definition: CmsShowMainBase.h:59
FWGeometry::initMap
void initMap(const FWRecoGeom::InfoMap &map)
Definition: FWGeometry.cc:203
get
#define get
res
Definition: Electron.h:6
FWFFNavigator
Definition: FWFFNavigator.h:11
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
CmsShowTaskExecutor::startDoingTasks
void startDoingTasks() override
Definition: CmsShowTaskExecutor.cc:55
FWEventItemsManager::setContext
void setContext(fireworks::Context *)
Definition: FWEventItemsManager.cc:294
CmsShowTaskExecutor::TaskFunctor
std::function< void()> TaskFunctor
Definition: CmsShowTaskExecutor.h:35
CmsShowTaskExecutor::addTask
void addTask(const TaskFunctor &iTask)
Definition: CmsShowTaskExecutor.cc:53
FWFFMetadataManager
Definition: FWFFMetadataManager.h:11
FWFFService::m_firstTime
bool m_firstTime
Definition: FWFFService.h:78
edm::ActivityRegistry::watchPostProcessEvent
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:547
edm::Run::getByLabel
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:283
CmsShowMainBase::eiManager
FWEventItemsManager * eiManager()
Definition: CmsShowMainBase.h:57
FWFFService::m_appHelper
FWFFHelper m_appHelper
Definition: FWFFService.h:70
CSGAction::enable
void enable()
Definition: CSGAction.cc:269
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
CmsShowMainBase::getGeom
FWGeometry & getGeom()
Definition: CmsShowMainBase.h:92
FWFFService::checkPosition
void checkPosition() override
Definition: FWFFService.cc:196