]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/alistoragemanager/AliDIMListenerThread.cxx
Online reco now listens only in PHYSICS_1
[u/mrichter/AliRoot.git] / MONITOR / alistoragemanager / AliDIMListenerThread.cxx
1 #include "AliDIMListenerThread.h"
2 #include "AliStorageTypes.h"
3
4 #include <iostream>
5 #include <sstream>
6 #include <fstream>
7
8 using namespace std;
9
10 AliDIMListenerThread::AliDIMListenerThread() : 
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
35     InitDIMListeners();
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
53 AliDIMListenerThread::~AliDIMListenerThread()
54 {
55   if(fDimSORListener){delete fDimSORListener;fDimSORListener = 0;}
56   if(fDimEORListener){delete fDimEORListener;fDimEORListener = 0;}
57
58   /*
59     for (int i = 0; i < 5; ++i){
60         if(fDimSORListener[i]) delete fDimSORListener[i];
61         if(fDimEORListener[i]) delete fDimEORListener[i];
62         
63         fDimSORListener[i] = 0;
64         fDimEORListener[i] = 0;
65         }*/
66 }
67
68 void AliDIMListenerThread::InitDIMListeners()
69 {
70
71 #ifdef ALI_DATE
72   /*
73   for (int i = 0; i < 5; ++i)
74   {
75   
76   if (i == 0)
77         {
78             fDimSORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS");
79             fDimEORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS");
80         }
81         else
82         {
83             fDimSORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_%d", i));
84             fDimEORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_%d", i));
85         }
86         fDimSORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
87         fDimEORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
88 }
89   */
90   fDimSORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_1");
91   fDimEORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_1");
92   fDimSORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
93   fDimEORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
94 #endif
95 }
96
97 void AliDIMListenerThread::StartOfRun(int run)
98 {
99     cout<<"AliDIMListenerThread -- SOR signal received for run:"<<run<<endl;
100    
101     // Kill reconstruction and start new one
102     gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco;alionlinereco %d\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str(),run));
103 }
104
105 void AliDIMListenerThread::EndOfRun(int run)
106 {
107     cout<<"AliDIMListenerThread -- EOR signal received for run:"<<run<<endl;
108
109     // kill all running reconstructions (to be changed later)
110     gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str()));
111 }