]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/onlineReco.C
Test version of the shell script and macro for running the online reco @ P2.
[u/mrichter/AliRoot.git] / MONITOR / onlineReco.C
1 UInt_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") {
13     AliOnlineRecoTrigger trigger;
14     run = trigger.Run();
15   } else {
16     cout<<"Bad parameter: "<<param<<endl;
17     cout<<"Parameter options: "<<endl;
18     cout<<"<run> - run online reconstruction for the given run"<<endl;
19     cout<<"listen - start listening for ECS SOR notification"<<endl;
20     cout<<"<empty parameter> - the same as 'listen'"<<endl;
21   }
22
23   if (run > 0) {
24     TString gdcList;
25     if (grp(run) > 0) {
26
27       // "t" stores the token on this disk, otherwise the alien connection is not thread/process-safe
28       TGrid::Connect("alien://", 0, 0, "t");
29
30       TObjArray *gdcs = gdcList.Tokenize(" ");
31       Int_t ngdcs = tokens->GetEntriesFast();
32       if (ngdcs > 0) {
33
34         TString dataSource = ((TObjString*)gdcs->At(0))->String();
35         dataSource.Prepend("mem://@");
36         datasource.Append(":");
37
38         // Setting CDB
39         AliCDBManager * man = AliCDBManager::Instance();
40         man->SetDefaultStorage("raw://");
41         man->SetSpecificStorage("GRP/GRP/Data",
42                               Form("local://%s",gSystem->pwd()));
43         man->SetSpecificStorage("GRP/CTP/Config",
44                               Form("local://%s",gSystem->pwd()));
45         man->Lock();
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       }
58       delete gdcs;
59     }
60   }
61
62   printf("Execution time: R:%.2fs C:%.2fs \n",
63          stopwatch.RealTime(),stopwatch.CpuTime());
64
65   return run;
66
67 }
68
69 Int_t grp(UInt_t run, TString &gdcList) {
70
71   Int_t ret=AliGRPPreprocessor::ReceivePromptRecoParameters(run, "aldaqdb", 0, "LOGBOOK", "logbook", "alice",
72                                                             Form("local://%s",gSystem->pwd()),
73                                                             gdcList);
74   if(ret>0) cout << "Last run of the same type is: " << ret << endl;
75   else if(ret==0) cout << "No previous run of the same type found" << endl;
76   else if(ret<0) cout << "Error code while retrieving GRP parameters returned: " << ret << endl;
77   return(ret);
78 }