Minor improvements
[u/mrichter/AliRoot.git] / MONITOR / onlineReco.C
CommitLineData
5bea0f92 1UInt_t onlineReco(const char* param = "listen",const char *recMacroPath = "$ALICE_ROOT/test/cosmic/rec.C") {
2
3 TString paramStr(param);
4
5 UInt_t run = 0;
6
7 TStopwatch stopwatch;
8 stopwatch.Start();
9
10 if (paramStr.IsDigit()) {
11 run = paramStr.Atoi();
12 } else if (paramStr == "listen") {
3153d9c6 13 gSystem->Load("libMONITOR");
5bea0f92 14 AliOnlineRecoTrigger trigger;
15 run = trigger.Run();
16 } else {
17 cout<<"Bad parameter: "<<param<<endl;
18 cout<<"Parameter options: "<<endl;
19 cout<<"<run> - run online reconstruction for the given run"<<endl;
20 cout<<"listen - start listening for ECS SOR notification"<<endl;
21 cout<<"<empty parameter> - the same as 'listen'"<<endl;
22 }
23
24 if (run > 0) {
03e5ee4f 25 TString gdc;
26 if (grp(run,gdc) > 0) {
5bea0f92 27
28 // "t" stores the token on this disk, otherwise the alien connection is not thread/process-safe
29 TGrid::Connect("alien://", 0, 0, "t");
30
03e5ee4f 31 if (!gdc.IsNull()) {
5bea0f92 32
03e5ee4f 33 TString dataSource = gdc;
5bea0f92 34 dataSource.Prepend("mem://@");
03e5ee4f 35 dataSource.Append(":");
5bea0f92 36
37 // Setting CDB
38 AliCDBManager * man = AliCDBManager::Instance();
03e5ee4f 39 // man->SetDefaultStorage("raw://");
40 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
5bea0f92 41 man->SetSpecificStorage("GRP/GRP/Data",
42 Form("local://%s",gSystem->pwd()));
43 man->SetSpecificStorage("GRP/CTP/Config",
44 Form("local://%s",gSystem->pwd()));
03e5ee4f 45 man->SetLock(kTRUE);
5bea0f92 46
47 gSystem->mkdir(Form("run%d",run));
48 gSystem->cd(Form("run%d",run));
49
50 gROOT->LoadMacro(gSystem->ExpandPathName(recMacroPath));
51 rec(dataSource.Data());
52
53 AliCDBManager::Destroy();
54 }
55 else {
56 cout << "No GDCs defined in the logbook entry for run " << run << endl;
57 }
5bea0f92 58 }
59 }
60
61 printf("Execution time: R:%.2fs C:%.2fs \n",
62 stopwatch.RealTime(),stopwatch.CpuTime());
63
64 return run;
65
66}
67
03e5ee4f 68Int_t grp(UInt_t run, TString &gdc) {
5bea0f92 69
70 Int_t ret=AliGRPPreprocessor::ReceivePromptRecoParameters(run, "aldaqdb", 0, "LOGBOOK", "logbook", "alice",
71 Form("local://%s",gSystem->pwd()),
03e5ee4f 72 gdc);
5bea0f92 73 if(ret>0) cout << "Last run of the same type is: " << ret << endl;
74 else if(ret==0) cout << "No previous run of the same type found" << endl;
75 else if(ret<0) cout << "Error code while retrieving GRP parameters returned: " << ret << endl;
76 return(ret);
77}