]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/alieventserver/eventserver.cxx
New Analysis Tools for the MFT
[u/mrichter/AliRoot.git] / MONITOR / alieventserver / eventserver.cxx
1 // Author: Mihai Niculescu 2013
2
3 /**************************************************************************
4  * Copyright(c) 1998-2013, ALICE Experiment at CERN, all rights reserved. *
5  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
6  * full copyright notice.                                                 *
7  **************************************************************************/
8  
9 #include <TApplication.h>
10 #include <TSystem.h>
11 #include <TString.h>
12 #include <TROOT.h>
13 #include "AliEventServerWindow.h"
14 #include "AliEventServer.h"
15 #include <iostream>
16 #include <string.h>
17 #include <sstream>
18
19 int main(int argc, char **argv)
20 {
21   // check if there is events server already running
22   const char *pid = gSystem->GetFromPipe("pidof alieventserver").Data();
23   int pidSize = gSystem->GetFromPipe("pidof alieventserver").Sizeof();
24   std::string pidOfAll(pid,pidSize);
25   std::stringstream pidStream(pidOfAll);
26
27   int word_count=0; 
28   std::string word;
29   while( pidStream >> word ) ++word_count;
30
31   if(word_count != 1)
32     {
33       std::cout<<"There are other servers. Cannot start multiple servers on the same machine. Quitting..."<<std::endl;
34       return 0;
35     }
36
37   TApplication app("AliEventServer", &argc, argv);
38
39   if(argc<2)
40     {
41       std::cout<<"Starting Event Server without GUI"<<std::endl;
42       AliEventServer *server = new AliEventServer;
43       app.Run(kTRUE);
44       if(server){delete server;}
45     }
46   else if(strcmp(argv[1],"gui")==0)
47     {
48       std::cout<<"Starting Event Server in GUI mode"<<std::endl;
49       AliEventServerWindow *win = new AliEventServerWindow;
50       app.Run(kTRUE);
51   
52       if(win){delete win;}
53     }
54   else
55     {
56       std::cout<<"Call without parameters to run without GUI.\nCall with \"gui\" parameter to launch with GUI"<<std::endl;
57     }
58
59   return 0;
60 }