All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WebEVD_module.cc
Go to the documentation of this file.
1 // Chris Backhouse - bckhouse@fnal.gov
2 
3 #include "fhiclcpp/ParameterSet.h"
4 #include "art/Framework/Core/ModuleMacros.h"
5 #include "art/Framework/Core/EDAnalyzer.h"
6 
7 #include "art/Framework/Services/Registry/ServiceHandle.h"
10 
13 
14 namespace evd
15 {
16 
17 class WebEVD: public art::EDAnalyzer
18 {
19 public:
20  explicit WebEVD(const fhicl::ParameterSet& pset);
21 
22  void analyze(const art::Event& evt) override;
23  void endJob() override;
24 
25 protected:
27 
28  art::ServiceHandle<geo::Geometry> fGeom;
29 };
30 
31 DEFINE_ART_MODULE(WebEVD)
32 
33 // ---------------------------------------------------------------------------
34 WebEVD::WebEVD(const fhicl::ParameterSet& pset)
35  : EDAnalyzer(pset)
36 {
37 }
38 
40 {
41  std::cout << "Ran out of events. Goodbye!" << std::endl;
42 }
43 
44 void WebEVD::analyze(const art::Event& evt)
45 {
46  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService>()->DataFor(evt);
47  const Result res = fServer.serve(evt, fGeom.get(), detProp);
48 
49  switch(res.code){
50  case kNEXT:
51  std::cout << "Next clicked in GUI. Going to next event" << std::endl;
52  // nothing, allow art to proceed to next
53  return;
54 
55  case kPREV:
56  std::cout << "Prev clicked in GUI. Going to previous event" << std::endl;
57  // Because we will automatically increment by one
58  art::ServiceHandle<InputSeeker>()->seekToEvent(-2);
59  return;
60 
61  case kQUIT:
62  // TODO give fServer a chance to clean up
63  std::cout << "Quit clicked in GUI. Goodbye!" << std::endl;
64  exit(0);
65 
66  case kERROR:
67  std::cout << "Error. Quitting" << std::endl;
68  exit(1);
69 
70  case kSEEK:
71  std::cout << "User requested seek to " << res.run << ":"<< res.subrun << ":" << res.event << std::endl;
72  art::ServiceHandle<InputSeeker>()->seekToEvent(art::EventID(res.run,
73  res.subrun,
74  res.event));
75  return;
76 
77  default:
78  std::cout << "Unhandled result code " << res.code << "!" << std::endl;
79  abort();
80  }
81 }
82 
83 } // namespace
void endJob() override
evd::WebEVDServer< art::Event > fServer
art::ServiceHandle< geo::Geometry > fGeom
EResult code
Definition: WebEVDServer.h:21
Result serve(const T &evt, const geo::GeometryCore *geom, const detinfo::DetectorPropertiesData &detprop)
TCEvent evt
Definition: DataStructs.cxx:8
WebEVD(const fhicl::ParameterSet &pset)
void analyze(const art::Event &evt) override
art framework interface to geometry description
BEGIN_PROLOG could also be cout
auto const detProp