CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

EveService Class Reference

#include <Fireworks/Geometry/interface/EveService.h>

List of all members.

Public Member Functions

void AddElement (TEveElement *el)
void AddGlobalElement (TEveElement *el)
void display (const std::string &info="")
 EveService (const edm::ParameterSet &, edm::ActivityRegistry &)
TEveMagField * getMagField ()
TEveManager * getManager ()
void postBeginJob ()
void postBeginRun (const edm::Run &, const edm::EventSetup &)
void postEndJob ()
void postProcessEvent (const edm::Event &, const edm::EventSetup &)
void setupFieldForPropagator (TEveTrackPropagator *prop)
void slotContinue ()
void slotExit ()
void slotNextEvent ()
void slotStep ()
virtual ~EveService ()

Protected Member Functions

void createEventNavigationGUI ()

Private Member Functions

 ClassDef (EveService, 0)
 EveService (const EveService &)
const EveServiceoperator= (const EveService &)

Private Attributes

bool m_AllowStep
TGTextButton * m_ContinueButton
TEveManager * m_EveManager
TEveMagField * m_MagField
TRint * m_Rint
bool m_ShowEvent
TGTextButton * m_StepButton
TGLabel * m_StepLabel

Detailed Description

Description: [one line class summary]

Usage: <usage>

Definition at line 43 of file EveService.h.


Constructor & Destructor Documentation

EveService::EveService ( const edm::ParameterSet ,
edm::ActivityRegistry ar 
)

Definition at line 120 of file EveService.cc.

References gather_cfg::cout, createEventNavigationGUI(), m_EveManager, m_MagField, m_Rint, postBeginJob(), postBeginRun(), postEndJob(), postProcessEvent(), edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostBeginRun(), edm::ActivityRegistry::watchPostEndJob(), and edm::ActivityRegistry::watchPostProcessEvent().

                                                                      :
   m_EveManager(0), m_Rint(0),
   m_MagField(0),
   m_AllowStep(true), m_ShowEvent(true),
   m_ContinueButton(0), m_StepButton(0), m_StepLabel(0)
{
   printf("EveService::EveService CTOR\n");

   std::cout <<" gApplication "<< gApplication <<std::endl;
   std::cout <<" is batch "    << gROOT->IsBatch() <<std::endl;
   std::cout <<" display "     << gSystem->Getenv("DISPLAY") <<std::endl;

   const char* dummyArgvArray[] = {"cmsRun"};
   char**      dummyArgv = const_cast<char**>(dummyArgvArray);
   int         dummyArgc = 1;

   m_Rint = new TRint("App", &dummyArgc, dummyArgv);
   assert(TApplication::GetApplications()->GetSize());
  
   gROOT->SetBatch(kFALSE);
   std::cout<<"calling NeedGraphicsLibs()"<<std::endl;
   TApplication::NeedGraphicsLibs();

   m_EveManager = TEveManager::Create();

   m_EveManager->AddEvent(new TEveEventManager("Event", "Event Data"));

   m_MagField = new CmsEveMagField();

   createEventNavigationGUI();

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

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

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

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

Definition at line 161 of file EveService.cc.

References m_MagField.

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

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

Member Function Documentation

void EveService::AddElement ( TEveElement *  el)

Definition at line 284 of file EveService.cc.

References m_EveManager.

{
  m_EveManager->AddElement(el);
}
void EveService::AddGlobalElement ( TEveElement *  el)

Definition at line 289 of file EveService.cc.

References m_EveManager.

{
  m_EveManager->AddGlobalElement(el);
}
EveService::ClassDef ( EveService  ,
 
) [private]
void EveService::createEventNavigationGUI ( ) [protected]

Definition at line 317 of file EveService.cc.

References f, m_ContinueButton, m_StepButton, and m_StepLabel.

Referenced by EveService().

{
   const TString cls("EveService");

   TEveBrowser *browser = gEve->GetBrowser();
   browser->StartEmbedding(TRootBrowser::kBottom);

   TGMainFrame *mf = new TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame);

   TGHorizontalFrame* f = new TGHorizontalFrame(mf);
   mf->AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));

   MkTxtButton(f, "Exit", 100, 2, 2)->
      Connect("Clicked()", cls, this, "slotExit()");

   MkTxtButton(f, "Next Event", 100, 2, 2)->
      Connect("Clicked()", cls, this, "slotNextEvent()");

   m_ContinueButton = MkTxtButton(f, "Continue", 100, 2, 2);
   m_ContinueButton->Connect("Clicked()", cls, this, "slotContinue()");

   m_StepButton = MkTxtButton(f, "Step", 100, 2, 2);
   m_StepButton->Connect("Clicked()", cls, this, "slotStep()");
   
   m_StepLabel = new TGLabel(mf, "");
   m_StepLabel->SetTextJustify(kTextTop | kTextLeft);
   mf->AddFrame(m_StepLabel, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));

   mf->SetCleanup(kDeepCleanup);
   mf->Layout();
   mf->MapSubwindows();
   mf->MapWindow();

   browser->StopEmbedding("EventCtrl");
}
void EveService::display ( const std::string &  info = "")

Definition at line 246 of file EveService.cc.

References m_AllowStep, m_ContinueButton, m_Rint, m_StepButton, and m_StepLabel.

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

   if (m_AllowStep)
   {
      m_ContinueButton->SetEnabled(kTRUE);
      m_StepButton->SetEnabled(kTRUE);
      m_StepLabel->SetText(info.c_str());
      gEve->Redraw3D();
      m_Rint->Run(kTRUE);
   }
}
TEveMagField * EveService::getMagField ( )

Definition at line 271 of file EveService.cc.

References m_MagField.

{
   return m_MagField;
}
TEveManager * EveService::getManager ( )

Definition at line 265 of file EveService.cc.

References m_EveManager.

{
   gEve = m_EveManager;
   return m_EveManager;
}
const EveService& EveService::operator= ( const EveService ) [private]
void EveService::postBeginJob ( )

Definition at line 173 of file EveService.cc.

Referenced by EveService().

{
   printf("EveService::postBeginJob\n");

   // Show the GUI ...
   gSystem->ProcessEvents();
}
void EveService::postBeginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 190 of file EveService.cc.

References cond::rpcobimon::current, edm::EventSetup::get(), edm::Run::getByType(), edm::HandleBase::isValid(), and m_MagField.

Referenced by EveService().

{
   float current = 18160.0f;

   try 
   {
      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);
      }
   }
   catch (...) 
   {
      printf("RunInfo not available \n");
   }
   static_cast<CmsEveMagField*>(m_MagField)->SetFieldByCurrent(current);
}
void EveService::postEndJob ( )

Definition at line 181 of file EveService.cc.

Referenced by EveService().

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

   TEveManager::Terminate();
}
void EveService::postProcessEvent ( const edm::Event ,
const edm::EventSetup  
)

Definition at line 225 of file EveService.cc.

References m_AllowStep, m_ContinueButton, m_Rint, m_ShowEvent, m_StepButton, and m_StepLabel.

Referenced by EveService().

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

   m_StepButton->SetEnabled(kFALSE);
   m_ContinueButton->SetEnabled(kFALSE);
   m_StepLabel->SetText("");

   if (m_ShowEvent)
   {
     gEve->Redraw3D();
     m_Rint->Run(kTRUE);
   }
   m_ShowEvent = true;
   m_AllowStep = true;

   gEve->GetCurrentEvent()->DestroyElements();
}
void EveService::setupFieldForPropagator ( TEveTrackPropagator *  prop)

Definition at line 275 of file EveService.cc.

References m_MagField.

{
   prop->SetMagFieldObj(m_MagField, kFALSE);
}
void EveService::slotContinue ( )

Definition at line 374 of file EveService.cc.

References m_AllowStep.

{
   gSystem->ExitLoop();
   m_AllowStep = false;
}
void EveService::slotExit ( )

Definition at line 353 of file EveService.cc.

{
   gSystem->ExitLoop();
   printf("EveService 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 EveService::slotNextEvent ( )

Definition at line 367 of file EveService.cc.

References m_AllowStep, and m_ShowEvent.

{
   gSystem->ExitLoop();
   m_ShowEvent = false;
   m_AllowStep = false;
}
void EveService::slotStep ( )

Definition at line 380 of file EveService.cc.

{
   gSystem->ExitLoop();
}

Member Data Documentation

bool EveService::m_AllowStep [private]

Definition at line 93 of file EveService.h.

Referenced by display(), postProcessEvent(), slotContinue(), and slotNextEvent().

TGTextButton* EveService::m_ContinueButton [private]

Definition at line 96 of file EveService.h.

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

TEveManager* EveService::m_EveManager [private]

Definition at line 88 of file EveService.h.

Referenced by AddElement(), AddGlobalElement(), EveService(), and getManager().

TEveMagField* EveService::m_MagField [private]
TRint* EveService::m_Rint [private]

Definition at line 89 of file EveService.h.

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

bool EveService::m_ShowEvent [private]

Definition at line 94 of file EveService.h.

Referenced by postProcessEvent(), and slotNextEvent().

TGTextButton* EveService::m_StepButton [private]

Definition at line 97 of file EveService.h.

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

TGLabel* EveService::m_StepLabel [private]

Definition at line 98 of file EveService.h.

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