ROOTANA
root_server.cxx
Go to the documentation of this file.
1 // Default program for dealing with various standard TRIUMF VME setups:
2 // V792, V1190 (VME), L2249 (CAMAC), Agilent current meter
3 //
4 //
5 
6 #include <stdio.h>
7 #include <iostream>
8 #include <time.h>
9 
10 #include "TRootanaEventLoop.hxx"
11 #include "TAnaManager.hxx"
12 
13 
14 class Analyzer: public TRootanaEventLoop {
15 
16 
17 
18 
19 public:
20 
21  // An analysis manager. Define and fill histograms in
22  // analysis manager.
24 
26  //DisableAutoMainWindow();
27  UseBatchMode();
28  anaManager = 0;
29  DisableRootOutput(true);
30  SetOnlineName("jsroot_server");
31  gettimeofday(&LastUpdateTime, NULL);
32 
33  };
34 
35 
36  virtual ~Analyzer() {};
37 
38  void Initialize(){
39 
40 #ifdef HAVE_THTTP_SERVER
41  std::cout << "Using THttpServer in read/write mode" << std::endl;
43 #endif
44 
45  }
46 
47  void InitManager(){
48 
49  if(anaManager)
50  delete anaManager;
51  anaManager = new TAnaManager();
52 
53  }
54 
55 
56  void BeginRun(int transition,int run,int time){
57 
58  InitManager();
59 
60  }
61 
62  struct timeval LastUpdateTime;
63 
64  bool ProcessMidasEvent(TDataContainer& dataContainer){
65 
66  if(!anaManager) InitManager();
67 
68  anaManager->ProcessMidasEvent(dataContainer);
69 
70  // Only update the transient histograms (like waveforms or event displays) every second.
71  // Otherwise hammers CPU for no reason.
72  struct timeval nowTime;
73  gettimeofday(&nowTime, NULL);
74  double dtime = nowTime.tv_sec - LastUpdateTime.tv_sec + (nowTime.tv_usec - LastUpdateTime.tv_usec)/1000000.0;
75  if(dtime > 1.0){
76  anaManager->UpdateTransientPlots(dataContainer);
77  LastUpdateTime = nowTime;
78  }
79 
80  return true;
81  }
82 
83 
84 };
85 
86 
87 int main(int argc, char *argv[])
88 {
89 
90  Analyzer::CreateSingleton<Analyzer>();
91  return Analyzer::Get().ExecuteLoop(argc, argv);
92 
93 }
94 
Definition: ana.cxx:14
void InitManager()
Definition: root_server.cxx:47
void BeginRun(int transition, int run, int time)
Definition: root_server.cxx:56
bool ProcessMidasEvent(TDataContainer &dataContainer)
Definition: root_server.cxx:64
struct timeval LastUpdateTime
Definition: root_server.cxx:62
TAnaManager * anaManager
Definition: ana.cxx:23
void Initialize()
Definition: root_server.cxx:38
virtual ~Analyzer()
Definition: root_server.cxx:36
int ProcessMidasEvent(TDataContainer &dataContainer)
Processes the midas event, fills histograms, etc.
Definition: TAnaManager.cxx:77
void UpdateTransientPlots(TDataContainer &dataContainer)
static TRootanaEventLoop & Get(void)
void DisableRootOutput(bool disable=true)
void UseBatchMode()
Use a batch mode, where we don't check ROOT status.
int ExecuteLoop(int argc, char *argv[])
Method to actually process the Midas information, either as file or online.
void SetOnlineName(std::string name)
void SetTHttpServerReadWrite(bool readwrite=true)
int main(int argc, char *argv[])
Definition: root_server.cxx:87