AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliDIMListenerThread.cxx
Go to the documentation of this file.
1 #include "AliDIMListenerThread.h"
2 #include "AliStorageTypes.h"
3 
4 #include <iostream>
5 #include <sstream>
6 #include <fstream>
7 
8 using namespace std;
9 
11  fDimSORListener(0),
12  fDimEORListener(0),
13  fOnlineReconstructionHostname(""),
14  fOnlineReconstructionUsername("")
15 {
16  ifstream configFile (GetConfigFilePath());
17 
18  if (configFile.is_open())
19  {
20  string line;
21  int from,to;
22  while(configFile.good())
23  {
24  getline(configFile,line);
25  from = line.find("\"")+1;
26  to = line.find_last_of("\"");
27  if(line.find("EVENT_SERVER=")==0){fOnlineReconstructionHostname=line.substr(from,to-from);}
28  else if(line.find("EVENT_SERVER_USER=")==0){fOnlineReconstructionUsername=line.substr(from,to-from);}
29  }
30  if(configFile.eof()){configFile.clear();}
31  configFile.close();
32  }
33  else{cout<<"AliDIMListenerThread -- Unable to open config file"<<endl;}
34 
36 
37 #ifdef ALI_DATE
38  // check if there is a run in partition PHYSICS_1
39  DimCurrentInfo SORrunNumber("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_1",-1);
40  DimCurrentInfo EORrunNumber("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_1",-1);
41 
42  if(SORrunNumber.getData() && EORrunNumber.getData())
43  {
44  cout<<"DIM Listener -- current SOR signal:"<<SORrunNumber.getInt()<<endl;
45  cout<<"DIM Listener -- current EOR signal:"<<EORrunNumber.getInt()<<endl;
46 
47  if(SORrunNumber.getInt() != EORrunNumber.getInt()){StartOfRun(SORrunNumber.getInt());}
48  }
49  else{cout<<"AliDIMListenerThread -- no data received from dim server"<<endl;}
50 #endif
51 }
52 
54 {
55  cout<<"AliDIMListenerThread -- destructor called...";
58 
59  // kill all running reconstructions (to be changed later)
60  gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str()));
61 
62  /*
63  for (int i = 0; i < 5; ++i){
64  if(fDimSORListener[i]) delete fDimSORListener[i];
65  if(fDimEORListener[i]) delete fDimEORListener[i];
66 
67  fDimSORListener[i] = 0;
68  fDimEORListener[i] = 0;
69  }*/
70  cout<<"OK"<<endl;
71 }
72 
74 {
75 
76 #ifdef ALI_DATE
77  /*
78  for (int i = 0; i < 5; ++i)
79  {
80 
81  if (i == 0)
82  {
83  fDimSORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS");
84  fDimEORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS");
85  }
86  else
87  {
88  fDimSORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_%d", i));
89  fDimEORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_%d", i));
90  }
91  fDimSORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
92  fDimEORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
93 }
94  */
95  fDimSORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_1");
96  fDimEORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_1");
97  fDimSORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
98  fDimEORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
99 #endif
100 }
101 
103 {
104  cout<<"AliDIMListenerThread -- SOR signal received for run:"<<run<<endl;
105 
106  // Kill reconstruction and start new one
107  gSystem->Exec(Form("ssh -n -f %s@%s \". ~/EventServerTesting/setEnv.sh;killall alionlinereco;alionlinereco %d\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str(),run));
108 }
109 
111 {
112  cout<<"AliDIMListenerThread -- EOR signal received for run:"<<run<<endl;
113 
114  // kill all running reconstructions (to be changed later)
115  gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str()));
116 }
std::string fOnlineReconstructionHostname
AliDimIntNotifier * fDimSORListener
AliDimIntNotifier * fDimEORListener
std::string fOnlineReconstructionUsername