CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
EveService Class Reference

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

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 42 of file EveService.h.

Constructor & Destructor Documentation

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

Definition at line 119 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().

119  :
120  m_EveManager(0), m_Rint(0),
121  m_MagField(0),
122  m_AllowStep(true), m_ShowEvent(true),
124 {
125  printf("EveService::EveService CTOR\n");
126 
127  std::cout <<" gApplication "<< gApplication <<std::endl;
128  std::cout <<" is batch " << gROOT->IsBatch() <<std::endl;
129  std::cout <<" display " << gSystem->Getenv("DISPLAY") <<std::endl;
130 
131  const char* dummyArgvArray[] = {"cmsRun"};
132  char** dummyArgv = const_cast<char**>(dummyArgvArray);
133  int dummyArgc = 1;
134 
135  m_Rint = new TRint("App", &dummyArgc, dummyArgv);
136  assert(TApplication::GetApplications()->GetSize());
137 
138  gROOT->SetBatch(kFALSE);
139  std::cout<<"calling NeedGraphicsLibs()"<<std::endl;
140  TApplication::NeedGraphicsLibs();
141 
142  m_EveManager = TEveManager::Create();
143 
144  m_EveManager->AddEvent(new TEveEventManager("Event", "Event Data"));
145 
146  m_MagField = new CmsEveMagField();
147 
149 
150  // ----------------------------------------------------------------
151 
154 
156 
158 }
void watchPostBeginRun(PostBeginRun::slot_type const &iSlot)
void postBeginJob()
Definition: EveService.cc:172
TGLabel * m_StepLabel
Definition: EveService.h:97
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void postProcessEvent(const edm::Event &, const edm::EventSetup &)
Definition: EveService.cc:222
void postEndJob()
Definition: EveService.cc:180
TGTextButton * m_ContinueButton
Definition: EveService.h:95
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
TGTextButton * m_StepButton
Definition: EveService.h:96
bool m_ShowEvent
Definition: EveService.h:93
TEveManager * m_EveManager
Definition: EveService.h:87
void createEventNavigationGUI()
Definition: EveService.cc:314
bool m_AllowStep
Definition: EveService.h:92
void postBeginRun(const edm::Run &, const edm::EventSetup &)
Definition: EveService.cc:189
tuple cout
Definition: gather_cfg.py:121
TEveMagField * m_MagField
Definition: EveService.h:90
TRint * m_Rint
Definition: EveService.h:88
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
EveService::~EveService ( )
virtual

Definition at line 160 of file EveService.cc.

References m_MagField.

161 {
162  printf("EveService::~EveService DTOR\n");
163 
164  delete m_MagField;
165 }
TEveMagField * m_MagField
Definition: EveService.h:90
EveService::EveService ( const EveService )
private

Member Function Documentation

void EveService::AddElement ( TEveElement *  el)

Definition at line 281 of file EveService.cc.

References m_EveManager.

Referenced by DisplayGeom::analyze(), and DummyEvelyser::analyze().

282 {
283  m_EveManager->AddElement(el);
284 }
TEveManager * m_EveManager
Definition: EveService.h:87
void EveService::AddGlobalElement ( TEveElement *  el)

Definition at line 286 of file EveService.cc.

References m_EveManager.

Referenced by DisplayGeom::beginJob(), and DummyEvelyser::beginRun().

287 {
288  m_EveManager->AddGlobalElement(el);
289 }
TEveManager * m_EveManager
Definition: EveService.h:87
EveService::ClassDef ( EveService  ,
 
)
private
void EveService::createEventNavigationGUI ( )
protected

Definition at line 314 of file EveService.cc.

References f, m_ContinueButton, m_StepButton, and m_StepLabel.

Referenced by EveService().

315 {
316  const TString cls("EveService");
317 
318  TEveBrowser *browser = gEve->GetBrowser();
319  browser->StartEmbedding(TRootBrowser::kBottom);
320 
321  TGMainFrame *mf = new TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame);
322 
323  TGHorizontalFrame* f = new TGHorizontalFrame(mf);
324  mf->AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
325 
326  MkTxtButton(f, "Exit", 100, 2, 2)->
327  Connect("Clicked()", cls, this, "slotExit()");
328 
329  MkTxtButton(f, "Next Event", 100, 2, 2)->
330  Connect("Clicked()", cls, this, "slotNextEvent()");
331 
332  m_ContinueButton = MkTxtButton(f, "Continue", 100, 2, 2);
333  m_ContinueButton->Connect("Clicked()", cls, this, "slotContinue()");
334 
335  m_StepButton = MkTxtButton(f, "Step", 100, 2, 2);
336  m_StepButton->Connect("Clicked()", cls, this, "slotStep()");
337 
338  m_StepLabel = new TGLabel(mf, "");
339  m_StepLabel->SetTextJustify(kTextTop | kTextLeft);
340  mf->AddFrame(m_StepLabel, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));
341 
342  mf->SetCleanup(kDeepCleanup);
343  mf->Layout();
344  mf->MapSubwindows();
345  mf->MapWindow();
346 
347  browser->StopEmbedding("EventCtrl");
348 }
TGLabel * m_StepLabel
Definition: EveService.h:97
TGTextButton * m_ContinueButton
Definition: EveService.h:95
double f[11][100]
TGTextButton * m_StepButton
Definition: EveService.h:96
void EveService::display ( const std::string &  info = "")

Definition at line 243 of file EveService.cc.

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

Referenced by DummyEvelyser::analyze().

244 {
245  // Display whatever was registered so far, wait until user presses
246  // the "Step" button.
247 
248  if (m_AllowStep)
249  {
250  m_ContinueButton->SetEnabled(kTRUE);
251  m_StepButton->SetEnabled(kTRUE);
252  m_StepLabel->SetText(info.c_str());
253  gEve->Redraw3D();
254  m_Rint->Run(kTRUE);
255  }
256 }
static const TGPicture * info(bool iBackgroundIsBlack)
TGLabel * m_StepLabel
Definition: EveService.h:97
TGTextButton * m_ContinueButton
Definition: EveService.h:95
TGTextButton * m_StepButton
Definition: EveService.h:96
bool m_AllowStep
Definition: EveService.h:92
TRint * m_Rint
Definition: EveService.h:88
TEveMagField * EveService::getMagField ( )

Definition at line 268 of file EveService.cc.

References m_MagField.

269 {
270  return m_MagField;
271 }
TEveMagField * m_MagField
Definition: EveService.h:90
TEveManager * EveService::getManager ( )

Definition at line 262 of file EveService.cc.

References m_EveManager.

Referenced by DummyEvelyser::beginRun().

263 {
264  gEve = m_EveManager;
265  return m_EveManager;
266 }
TEveManager * m_EveManager
Definition: EveService.h:87
const EveService& EveService::operator= ( const EveService )
private
void EveService::postBeginJob ( )

Definition at line 172 of file EveService.cc.

Referenced by EveService().

173 {
174  printf("EveService::postBeginJob\n");
175 
176  // Show the GUI ...
177  gSystem->ProcessEvents();
178 }
void EveService::postBeginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)

Definition at line 189 of file EveService.cc.

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

Referenced by EveService().

190 {
191  float current = 18160.0f;
192 
193  try
194  {
196  bool res = iRun.getByLabel("conditionsInEdm", runCond);
197  if (res && runCond.isValid())
198  {
199  printf("Got current from conds in edm %f\n", runCond->BAvgCurrent);
200  current = runCond->BAvgCurrent;
201  }
202  else
203  {
204  printf("Could not extract run-conditions get-result=%d, is-valid=%d\n", res, runCond.isValid());
205 
207  iSetup.get<RunInfoRcd>().get(sum);
208 
209  current = sum->m_avg_current;
210  printf("Got current from RunInfoRcd %f\n", sum->m_avg_current);
211  }
212  }
213  catch (...)
214  {
215  printf("RunInfo not available \n");
216  }
217  static_cast<CmsEveMagField*>(m_MagField)->SetFieldByCurrent(current);
218 }
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:200
bool isValid() const
Definition: HandleBase.h:76
const T & get() const
Definition: EventSetup.h:55
TEveMagField * m_MagField
Definition: EveService.h:90
void EveService::postEndJob ( )

Definition at line 180 of file EveService.cc.

Referenced by EveService().

181 {
182  printf("EveService::postEndJob\n");
183 
184  TEveManager::Terminate();
185 }
void EveService::postProcessEvent ( const edm::Event ,
const edm::EventSetup  
)

Definition at line 222 of file EveService.cc.

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

Referenced by EveService().

223 {
224  printf("EveService::postProcessEvent: Starting GUI loop.\n");
225 
226  m_StepButton->SetEnabled(kFALSE);
227  m_ContinueButton->SetEnabled(kFALSE);
228  m_StepLabel->SetText("");
229 
230  if (m_ShowEvent)
231  {
232  gEve->Redraw3D();
233  m_Rint->Run(kTRUE);
234  }
235  m_ShowEvent = true;
236  m_AllowStep = true;
237 
238  gEve->GetCurrentEvent()->DestroyElements();
239 }
TGLabel * m_StepLabel
Definition: EveService.h:97
TGTextButton * m_ContinueButton
Definition: EveService.h:95
TGTextButton * m_StepButton
Definition: EveService.h:96
bool m_ShowEvent
Definition: EveService.h:93
bool m_AllowStep
Definition: EveService.h:92
TRint * m_Rint
Definition: EveService.h:88
void EveService::setupFieldForPropagator ( TEveTrackPropagator *  prop)

Definition at line 272 of file EveService.cc.

References m_MagField.

Referenced by DummyEvelyser::beginJob().

273 {
274  prop->SetMagFieldObj(m_MagField, kFALSE);
275 }
TEveMagField * m_MagField
Definition: EveService.h:90
void EveService::slotContinue ( )

Definition at line 371 of file EveService.cc.

References m_AllowStep.

372 {
373  gSystem->ExitLoop();
374  m_AllowStep = false;
375 }
bool m_AllowStep
Definition: EveService.h:92
void EveService::slotExit ( )

Definition at line 350 of file EveService.cc.

351 {
352  gSystem->ExitLoop();
353  printf("EveService exiting on user request.\n");
354 
355  // Throwing exception here is bad because:
356  // a) it does not work when in a "debug step";
357  // b) does not restore terminal state.
358  // So we do exit instead for now.
359  // throw cms::Exception("UserTerminationRequest");
360 
361  gSystem->Exit(0);
362 }
void EveService::slotNextEvent ( )

Definition at line 364 of file EveService.cc.

References m_AllowStep, and m_ShowEvent.

365 {
366  gSystem->ExitLoop();
367  m_ShowEvent = false;
368  m_AllowStep = false;
369 }
bool m_ShowEvent
Definition: EveService.h:93
bool m_AllowStep
Definition: EveService.h:92
void EveService::slotStep ( )

Definition at line 377 of file EveService.cc.

378 {
379  gSystem->ExitLoop();
380 }

Member Data Documentation

bool EveService::m_AllowStep
private

Definition at line 92 of file EveService.h.

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

TGTextButton* EveService::m_ContinueButton
private

Definition at line 95 of file EveService.h.

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

TEveManager* EveService::m_EveManager
private

Definition at line 87 of file EveService.h.

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

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

Definition at line 88 of file EveService.h.

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

bool EveService::m_ShowEvent
private

Definition at line 93 of file EveService.h.

Referenced by postProcessEvent(), and slotNextEvent().

TGTextButton* EveService::m_StepButton
private

Definition at line 96 of file EveService.h.

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

TGLabel* EveService::m_StepLabel
private

Definition at line 97 of file EveService.h.

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