CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

FWFFService Class Reference

#include <FWFFService.h>

Inheritance diagram for FWFFService:
CmsShowMainBase

List of all members.

Public Member Functions

virtual void autoLoadNewEvent ()
virtual void checkPosition ()
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 ()
void setupFieldForPropagator (TEveTrackPropagator *prop)
virtual void stopPlaying ()
virtual ~FWFFService ()

Private Member Functions

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

Private Attributes

bool m_AllowStep
FWFFHelper m_appHelper
std::auto_ptr< fireworks::Contextm_context
TEveManager * m_EveManager
bool m_firstTime
TEveMagField * m_MagField
std::auto_ptr
< FWFFMetadataManager
m_metadataManager
std::auto_ptr< FWFFNavigatorm_navigator
TRint * m_Rint
bool m_ShowEvent

Detailed Description

Definition at line 34 of file FWFFService.h.


Constructor & Destructor Documentation

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

Definition at line 112 of file FWFFService.cc.

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(), edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostBeginRun(), edm::ActivityRegistry::watchPostEndJob(), and edm::ActivityRegistry::watchPostProcessEvent().

   : CmsShowMainBase(),
     m_navigator(new FWFFNavigator(*this)), 
     m_metadataManager(new FWFFMetadataManager()),
     m_context(new fireworks::Context(changeManager(),
                                      selectionManager(),
                                      eiManager(),
                                      colorManager(),
                                      m_metadataManager.get())),
     m_appHelper(ps, ar),
     m_Rint(m_appHelper.app()),
     m_AllowStep(true),
     m_ShowEvent(true),
     m_firstTime(true)
{
   printf("FWFFService::FWFFService CTOR\n");

   setup(m_navigator.get(), m_context.get(), m_metadataManager.get());

   eiManager()->setContext(m_context.get());

   // By default, we look up geometry and configuration in the workarea, then
   // in the release area then in the local directory.  It is also possible to
   // override those locations by using the displayConfigurationFilename and
   // geometryFilename in the parameterset.
   const char *releaseBase = getenv("CMSSW_RELEASE_BASE");
   const char *workarea = getenv("CMSSW_BASE");
   std::string displayConfigRelFilename = "/src/Fireworks/FWInterface/macros/ffw.fwc";
   std::string geometryRelFilename = "/src/Fireworks/FWInterface/data/cmsGeom10.root";

   std::string displayConfigFilename = "ffw.fwc";
   std::string geometryFilename;

   if (releaseBase && access((releaseBase + displayConfigFilename).c_str(), R_OK) == 0)
      displayConfigFilename = releaseBase + displayConfigRelFilename; 
   if (workarea && access((workarea + displayConfigRelFilename).c_str(), R_OK) == 0)
      displayConfigFilename = workarea + displayConfigRelFilename;   

   if (releaseBase && access((releaseBase + geometryRelFilename).c_str(), R_OK) == 0)
      geometryFilename = releaseBase + geometryRelFilename;
   if (workarea && access((workarea + geometryRelFilename).c_str(), R_OK) == 0)
      geometryFilename = workarea + geometryRelFilename;

   displayConfigFilename = ps.getUntrackedParameter<std::string>("diplayConfigFilename", displayConfigFilename);
   geometryFilename = ps.getUntrackedParameter<std::string>("geometryFilename", geometryFilename);

   setGeometryFilename(geometryFilename);
   setConfigFilename(displayConfigFilename);

   CmsShowTaskExecutor::TaskFunctor f;

   if (!geometryFilename.empty())
   {
      f=boost::bind(&CmsShowMainBase::loadGeometry,this);
      startupTasks()->addTask(f);
   }

   m_MagField = new CmsEveMagField();

   // ----------------------------------------------------------------

   ar.watchPostBeginJob(this, &FWFFService::postBeginJob);
   ar.watchPostEndJob(this, &FWFFService::postEndJob);

   ar.watchPostBeginRun(this, &FWFFService::postBeginRun);

   ar.watchPostProcessEvent(this, &FWFFService::postProcessEvent);
}
FWFFService::~FWFFService ( ) [virtual]

Definition at line 181 of file FWFFService.cc.

References m_MagField.

{
   printf("FWFFService::~FWFFService DTOR\n");

   delete m_MagField;
}
FWFFService::FWFFService ( const FWFFService ) [private]

Member Function Documentation

virtual void FWFFService::autoLoadNewEvent ( ) [inline, virtual]

Implements CmsShowMainBase.

Definition at line 60 of file FWFFService.h.

{}
void FWFFService::checkPosition ( ) [virtual]
void FWFFService::display ( const std::string &  info = "")

Definition at line 308 of file FWFFService.cc.

References m_AllowStep, and m_Rint.

{
   // Display whatever was registered so far, wait until user presses
   // the "Step" button.

   if (m_AllowStep)
   {
      gEve->Redraw3D();
      m_Rint->Run(kTRUE);
   }
}
TEveMagField * FWFFService::getMagField ( )

Definition at line 325 of file FWFFService.cc.

References m_MagField.

{
   return m_MagField;
}
const FWFFService& FWFFService::operator= ( const FWFFService ) [private]
void FWFFService::postBeginJob ( )

Definition at line 194 of file FWFFService.cc.

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

Referenced by FWFFService().

{
   printf("FWFFService::postBeginJob\n");
   // We need to enter the GUI loop in order to 
   // have all the callbacks executed. The last callback will
   // be responsible for returning the control to CMSSW. 
   assert(m_Rint);
   CmsShowTaskExecutor::TaskFunctor f;
   f=boost::bind(&TApplication::Terminate, m_Rint, 0);
   startupTasks()->addTask(f);
   // FIXME: do we really need to delay tasks like this?
   startupTasks()->startDoingTasks(); 
   m_Rint->Run(kTRUE);
   // Show the GUI ...
   gSystem->ProcessEvents();
}
void FWFFService::postBeginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 241 of file FWFFService.cc.

References cond::rpcobimon::current, edm::EventSetup::get(), edm::Run::getByType(), CmsShowMainBase::getGeom(), CmsShowMainBase::guiManager(), 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().

{
   // If the geometry was not picked up from a file, we try to get it from the
   // EventSetup!
   // FIXME: we need to check we execute only once because the view managers
   //        depend on geometry and they cannot be initialised more than once.
   //        This should actually be cleaned up so that the various view manager
   //        don't care about geometry.
   // FIXME: we should actually be able to update the geometry when requested.
   //        this is not possible at the moment.
   if (m_firstTime == true)
   {
      if (m_context->getGeom() == 0)
      {
         guiManager()->updateStatus("Loading geometry...");
         edm::ESTransientHandle<FWRecoGeometry> geoh;
         iSetup.get<FWRecoGeometryRecord>().get(geoh);
         getGeom().initMap(geoh.product()->idToName);
         m_context->setGeom(&(getGeom()));
      }

      setupViewManagers();
      setupConfiguration();
      setupActions();
      m_firstTime = false;
   }

   float current = 18160.0f;

   edm::Handle<edm::ConditionsInRunBlock> runCond;
   bool res = iRun.getByType(runCond);
   //bool res = run.getByLabel("conditionsInEdm", runCond, "", "");
   if (res && runCond.isValid())
   {
      printf("Got current from conds in edm %f\n", runCond->BAvgCurrent);
      current = runCond->BAvgCurrent;
   }
   else
   {
      printf("Could not extract run-conditions get-result=%d, is-valid=%d\n", res, runCond.isValid());

      edm::ESHandle<RunInfo> sum;
      iSetup.get<RunInfoRcd>().get(sum);

      current = sum->m_avg_current;
      printf("Got current from RunInfoRcd %f\n", sum->m_avg_current);
   }

   static_cast<CmsEveMagField*>(m_MagField)->SetFieldByCurrent(current);
}
void FWFFService::postEndJob ( )

Definition at line 212 of file FWFFService.cc.

Referenced by FWFFService().

{
   printf("FWFFService::postEndJob\n");

   TEveManager::Terminate();
}
void FWFFService::postProcessEvent ( const edm::Event event,
const edm::EventSetup es 
)

Definition at line 294 of file FWFFService.cc.

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

Referenced by FWFFService().

{
   printf("FWFFService::postProcessEvent: Starting GUI loop.\n");

   m_metadataManager->update(new FWFFMetadataUpdateRequest(event));
   m_navigator->setCurrentEvent(&event);
   checkPosition();
   draw();
   m_Rint->Run(kTRUE);
}
void FWFFService::quit ( ) [virtual]

Implements CmsShowMainBase.

Definition at line 337 of file FWFFService.cc.

{
   gSystem->ExitLoop();
   printf("FWFFService exiting on user request.\n");

   // Throwing exception here is bad because:
   //   a) it does not work when in a "debug step";
   //   b) does not restore terminal state.
   // So we do exit instead for now.
   // throw cms::Exception("UserTerminationRequest");
   gSystem->Exit(0);
}
void FWFFService::setupFieldForPropagator ( TEveTrackPropagator *  prop)

Definition at line 331 of file FWFFService.cc.

References m_MagField.

{
   prop->SetMagFieldObj(m_MagField, kFALSE);
}
virtual void FWFFService::stopPlaying ( ) [inline, virtual]

Implements CmsShowMainBase.

Definition at line 59 of file FWFFService.h.

{}

Member Data Documentation

bool FWFFService::m_AllowStep [private]

Definition at line 80 of file FWFFService.h.

Referenced by display().

Definition at line 73 of file FWFFService.h.

std::auto_ptr<fireworks::Context> FWFFService::m_context [private]

Definition at line 71 of file FWFFService.h.

Referenced by FWFFService(), and postBeginRun().

TEveManager* FWFFService::m_EveManager [private]

Definition at line 74 of file FWFFService.h.

bool FWFFService::m_firstTime [private]

Definition at line 82 of file FWFFService.h.

Referenced by postBeginRun().

TEveMagField* FWFFService::m_MagField [private]

Definition at line 70 of file FWFFService.h.

Referenced by FWFFService(), and postProcessEvent().

std::auto_ptr<FWFFNavigator> FWFFService::m_navigator [private]

Definition at line 69 of file FWFFService.h.

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

TRint* FWFFService::m_Rint [private]

Definition at line 75 of file FWFFService.h.

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

bool FWFFService::m_ShowEvent [private]

Definition at line 81 of file FWFFService.h.