artdaq_demo  v3_06_01
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/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 
15 #include <TApplication.h>
16 #include <TSystem.h>
17 #include <unistd.h>
18 #include <future>
19 #include <iostream>
20 
21 namespace demo {
25 class RootApplication : public art::EDAnalyzer
26 {
27 public:
36  explicit RootApplication( fhicl::ParameterSet const& p );
37 
41  virtual ~RootApplication();
42 
46  void beginJob() override;
47 
54  void analyze( art::Event const& e ) override;
55 
59  void endJob() override;
60 
61 private:
62  std::unique_ptr<TApplication> app_;
63  bool force_new_;
64  bool dont_quit_;
65 };
66 } // namespace demo
67 
68 demo::RootApplication::RootApplication( fhicl::ParameterSet const& ps )
69  : art::EDAnalyzer( ps )
70  , force_new_( ps.get<bool>( "force_new", true ) )
71  , dont_quit_( ps.get<bool>( "dont_quit", false ) )
72 {}
73 
75 
76 void demo::RootApplication::analyze( art::Event const& ) { gSystem->ProcessEvents(); }
77 
79 {
80  if ( !gApplication || force_new_ )
81  {
82  int tmp_argc( 0 );
83  app_ = std::unique_ptr<TApplication>( new TApplication( "noapplication", &tmp_argc, 0 ) );
84  }
85 }
86 
88 {
89  if ( dont_quit_ ) app_->Run( true );
90 }
91 
92 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.