GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agapro/ApplyTracking/EmulatorControl.h
Go to the documentation of this file.
1 #ifndef _EmulatorControl
2 #define _EmulatorControl
3 
4 #include "TTask.h"
5 #include "TTimer.h"
6 #include "Rtypes.h"
7 
8 #include "NarvalInterface.h"
9 
12 {
13 private:
14  // Name of the directory containing the run number
15  TString RunDir;
16  // Run Number
17  Int_t RunNumber;
18 
19 private:
21  TString DoROOTAFPConf(Int_t which_run, const char *path, const char *which_adf_data, const char *run_pat, Option_t *opt_adf_pattern, const char *tmp_rootafp_filename);
22 
23 public:
24  BaseEmulatorChain() : RunDir(""), RunNumber(0)
25  {;}
27  {;}
28 
30  TString GetRunDir() const
31  {
32  return RunDir;
33  }
34 
36  Int_t GetRunNumber() const
37  {
38  return RunNumber;
39  }
40 
42  virtual Bool_t Init()
43  {
44  return false;
45  }
47  virtual Bool_t Init(const Char_t *rootafp);
48  virtual Bool_t Init(Int_t which_run, const char *path, const char *which_adf_data, const char *run_name_pattern, Option_t *opt_adf_pattern);
49 
51  virtual Bool_t Run(UInt_t /* max_loop */ = kMaxUInt)
52  { return true; }
53 
55  {
56  return 0x0;
57  }
59  {
60  return 0x0;
61  }
62 };
63 
64 class EmulatorControl : public TTask
65 {
66 private:
68  BaseEmulatorChain *fEmulator;
70  UInt_t fNbLoop;
71  UInt_t fCurrentLoop;
73  Bool_t fIsRunning;
75  TTimer *fTimer;
76 
77 private:
78  virtual Bool_t HandleTimer(TTimer* timer);
79 
80 public:
82  TTask("_EmulatorControl","0"),
83  fEmulator(0x0),
84  fNbLoop(0),
85  fCurrentLoop(0),
86  fIsRunning(false),
87  fTimer(new TTimer())
88  {;}
90  TTask("_EmulatorControl","0"),
91  fEmulator(emulator),
92  fNbLoop(0),
93  fCurrentLoop(0),
94  fIsRunning(false),
95  fTimer(new TTimer())
96  {;}
97  virtual ~EmulatorControl()
98  {
99  if ( fEmulator)
100  delete fEmulator;
101  }
102 
104  void Run(UInt_t max_loop = kMaxUInt); //*MENU*
105  void Destroy(); //*MENU*
106 
107  void Stop();
108 
109  TTimer *GetTimer(){return fTimer;}
110 
111 
113  void Save(Option_t *opt = "*"); //*MENU*
114 
115  ClassDef(EmulatorControl,0) // to start an emulator from task folder
116 };
117 
118 
119 #endif
TString GetRunDir() const
to get back the RunDirectory
virtual ADF::NarvalProducer * GetBaseProducer()
It defines the interface needed to be a narval actor (producer).
void Save(Option_t *opt="*")
Save the spectra.
Int_t GetRunNumber() const
to get back the run number
virtual Bool_t Run(UInt_t=kMaxUInt)
loop
virtual ADF::NarvalConsumer * GetBaseConsumer()
virtual Bool_t Init()
It should be overwritten !
It defines the interface needed to be a consumer.
to have a common base class to be able to control the emulator through a TTask
void Run(UInt_t max_loop=kMaxUInt)
Run the emulator.
EmulatorControl(BaseEmulatorChain *emulator)
header file for NarvalInterface.cpp