]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/alionlinemonitor.cxx
Last bunch of changes to the online reco code. In principle we are ready to try the...
[u/mrichter/AliRoot.git] / MONITOR / alionlinemonitor.cxx
1 #include "AliDimIntNotifier.h"
2 #include "AliOnlineReco.h"
3
4 #include <TRint.h>
5
6 #include <TSQLServer.h>
7 #include <TSQLResult.h>
8 #include <TSQLRow.h>
9
10 #include <TTimeStamp.h>
11
12 int main(int argc, char **argv)
13 {
14   AliDimIntNotifier::SetMainThreadId();
15
16   Bool_t test = argc > 1 && strcmp("-test", argv[1]) == 0;
17
18   TRint app("App", &argc, argv);
19
20   AliOnlineReco *win = new AliOnlineReco;
21   win->MapWindow();
22
23   if (test)
24   {
25     win->SetTestMode();
26
27     win->GetSOR()->infoHandlerTest(2214);
28     win->GetSOR()->infoHandlerTest(2215);
29     win->GetSOR()->infoHandlerTest(2224);
30     win->GetSOR()->infoHandlerTest(2244);
31
32     printf("win = (AliOnlineReco*) 0x%lx\n", (unsigned long)win);
33   }
34   else {
35
36     TString baseDir = gSystem->Getenv("ONLINERECO_BASE_DIR");
37     if (baseDir.IsNull()) {
38       printf("ERROR: ONLINERECO_BASE_DIR is not set. Exiting...");
39       return 0;
40     }
41
42     const char *dbHost = "aldaqdb";
43     Int_t dbPort = 3306;
44     const char *dbName = "LOGBOOK";
45     const char *user = "logbook";
46     const char *password = "alice";
47
48     TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password);
49     if (!server) {
50       printf("ERROR: Could not connect to DAQ Logbook");
51       return 0;
52     }
53     TString sqlQuery;
54     TTimeStamp ts;
55     sqlQuery.Form("SELECT run FROM logbook WHERE DAQ_time_start > %u AND DAQ_time_end IS NULL AND partition = 'PHYSICS'",
56                   ts.GetSec()-86400);
57     //    sqlQuery.Form("SELECT run FROM logbook WHERE DAQ_time_start > %u AND DAQ_time_end IS NULL",
58     //            ts.GetSec()-86400);
59     TSQLResult* result = server->Query(sqlQuery);
60     if (!result) {
61       printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
62       return 0;
63     }
64     if (result->GetRowCount() == 0) {
65       printf("No active physics runs found");
66     }
67     else {
68       for (Int_t iRow = 0; iRow < result->GetRowCount(); iRow++) {
69         TSQLRow* row = result->Next();
70         TString runStr = row->GetField(0);
71         if (runStr.IsDigit())
72           win->StartOfRun(runStr.Atoi());
73         delete row;
74       }
75     }
76     delete result;
77   }
78
79   app.Run(kTRUE);
80   return 0;
81 }