EventDisplay3DService_service.cc
Go to the documentation of this file.
1 //
2 // - Event display service used with the EventDisplay3D module to start up the
3 // TApplication and allow forward, backward, and jump-to navigation of events
4 // in the root input file. This is a very much simplified version based on
5 // Nova's event display service by Mark Messier.
6 //
7 
9 #include "nuevdb/EventDisplayBase/NavState.h"
10 
11 // ART includes
12 #include "art_root_io/RootInput.h"
13 
14 // ROOT includes
15 #include "TApplication.h"
16 #include "TEveManager.h"
17 
18 // C++ includes
19 #include <iostream>
20 
21 namespace gar
22 {
23  namespace evd3d
24  {
27  {
28  (void)pset;
31  }
32 
33  //......................................................................
34 
36  std::vector<art::Worker*> const&)
37  {
38  fInputSource = input_source;
39  }
40 
41  //......................................................................
42 
44  {
45  if(gEve){
46  gEve->Redraw3D(kFALSE,kTRUE);
47  }else{
48  mf::LogWarning("EvtDisplayService") << "TeveManager is not properly initialized.";
49  gApplication->SetReturnFromRun(kFALSE);
50  gApplication->Terminate(0);
51  }
52 
53  gApplication->Run(kTRUE);
54  if(!gEve){
55  gApplication->SetReturnFromRun(kFALSE);
56  gApplication->Terminate(0);
57  }
58 
59  art::RootInput* rootInput = dynamic_cast<art::RootInput*>(fInputSource);
60  if(!rootInput){
61  throw cet::exception("EvtDisplayService")
62  << "Random access for the EvtDisplay requires a RootInput source for proper operation.\n";
63  }
64 
65  // Figure out where to go in the input stream from here
66  switch (evdb::NavState::Which()) {
67  case evdb::kNEXT_EVENT: {
68  // Contrary to appearances, this is *not* a NOP: it ensures run and
69  // subRun are (re-)read as necessary if we've been doing random
70  // access. Come the revolution ...
71  //
72  // 2011/04/10 CG.
73  rootInput->seekToEvent(0);
74  break;
75  }
76  case evdb::kPREV_EVENT: {
77  rootInput->seekToEvent(-2);
78  break;
79  }
80  case evdb::kRELOAD_EVENT: {
81  rootInput->seekToEvent(evt.id());
82  break;
83  }
84  case evdb::kGOTO_EVENT: {
85  int targRun = evdb::NavState::TargetRun();
86  int targEvt = evdb::NavState::TargetEvent();
87  if(targRun<0 || targEvt<0){
88  mf::LogWarning("EvtDisplayService") << "Negative Run or Event number specified -- reloading current event.";
89  // Reload current event.
90  rootInput->seekToEvent(evt.id());
91  } else {
93  if (!rootInput->seekToEvent(id)) { // Couldn't find event
94  mf::LogWarning("EvtDisplayService") << "Unable to find "
95  << id
96  << " -- reloading current event.";
97  // Reload current event.
98  rootInput->seekToEvent(evt.id());
99  }
100  }
101  break;
102  }
103  default: {
105  << "EvtDisplayService in unhandled state "
106  << evdb::NavState::Which()
107  << ".\n";
108  }
109  }
110 
111  }
112  }
113 
114  namespace evd3d
115  {
117  }// end namespace tex
118 
119  }
art::InputSource * fInputSource
Input source of events.
GlobalSignal< detail::SignalResponseType::LIFO, void(InputSource *, std::vector< Worker * > const &)> sPostBeginJobWorkers
void postBeginJobWorkers(art::InputSource *inputs, std::vector< art::Worker * > const &workers)
void postProcessEvent(art::Event const &, art::ScheduleContext)
GlobalSignal< detail::SignalResponseType::LIFO, void(Event const &, ScheduleContext)> sPostProcessEvent
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
General GArSoft Utilities.
#define DEFINE_ART_SERVICE(svc)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
static SubRunID invalidSubRun(RunID const &rID)
Definition: SubRunID.h:165
TCEvent evt
Definition: DataStructs.cxx:7
EventID id() const
Definition: Event.cc:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
EventDisplay3DService(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)