artdaq_demo  v3_06_00
RootApplication_module.cc
1 // Class: RootApplication
3 // Module Type: analyzer
4 // File: RootApplication_module.cc
5 //
6 // Generated at Sun Dec 2 12:23:06 2012 by Alessandro Razeto & Nicola Rossi using artmod
7 // from art v1_02_04.
9 
10 #include "art/Framework/Core/EDAnalyzer.h"
11 #include "art/Framework/Principal/Handle.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Core/ModuleMacros.h"
14 
15 #include <iostream>
16 #include <future>
17 #include <TApplication.h>
18 #include <TSystem.h>
19 #include <unistd.h>
20 
21 namespace demo
22 {
26  class RootApplication : public art::EDAnalyzer
27  {
28  public:
37  explicit RootApplication(fhicl::ParameterSet const& p);
38 
42  virtual ~RootApplication();
43 
47  void beginJob() override;
48 
55  void analyze(art::Event const& e) override;
56 
60  void endJob() override;
61 
62  private:
63  std::unique_ptr<TApplication> app_;
64  bool force_new_;
65  bool dont_quit_;
66  };
67 }
68 
69 demo::RootApplication::RootApplication(fhicl::ParameterSet const& ps): art::EDAnalyzer(ps)
70  , force_new_(ps.get<bool>("force_new", true))
71  , dont_quit_(ps.get<bool>("dont_quit", false)) {}
72 
74 
75 void demo::RootApplication::analyze(art::Event const&)
76 {
77  gSystem->ProcessEvents();
78 }
79 
81 {
82  if (!gApplication || force_new_)
83  {
84  int tmp_argc(0);
85  app_ = std::unique_ptr<TApplication>(new TApplication("noapplication", &tmp_argc, 0));
86  }
87 }
88 
90 {
91  if (dont_quit_) app_->Run(true);
92 }
93 
94 DEFINE_ART_MODULE(demo::RootApplication)
void beginJob() override
Called by art at the beginning of the job. RootApplication will create a window unless one already ex...
Provides a wrapper for displaying ROOT canvases.
void endJob() override
Called by art at the end of the job. RootApplication will close the findow if dont_quit == false...
RootApplication(fhicl::ParameterSet const &p)
RootApplication Constructor.
virtual ~RootApplication()
RootApplication Destructor.
void analyze(art::Event const &e) override
Called by art for each event.