ROOT logo
UInt_t onlineReco(const char* param = "listen",const char *recMacroPath = "$ALICE_ROOT/test/cosmic/rec.C") {

  TString paramStr(param);
	
  UInt_t run = 0;

  TStopwatch stopwatch;
  stopwatch.Start();

  if (paramStr.IsDigit()) {
    run = paramStr.Atoi();
  } else if (paramStr == "listen") {
    gSystem->Load("libMONITOR");
    AliOnlineRecoTrigger trigger;
    run = trigger.Run();
  } else {
    cout<<"Bad parameter: "<<param<<endl;
    cout<<"Parameter options: "<<endl;
    cout<<"<run> - run online reconstruction for the given run"<<endl;
    cout<<"listen - start listening for ECS SOR notification"<<endl;
    cout<<"<empty parameter> - the same as 'listen'"<<endl;
  }

  if (run > 0) {
    TString gdc;
    if (grp(run,gdc) > 0) {

      // "t" stores the token on this disk, otherwise the alien connection is not thread/process-safe
      TGrid::Connect("alien://", 0, 0, "t");

      if (!gdc.IsNull()) {

	gSystem->Setenv("DATE_RUN_NUMBER",Form("%d",run));

	TString dataSource = "*";
	dataSource.Prepend("mem://@");
	dataSource.Append(":");

	// Setting CDB
	AliCDBManager * man = AliCDBManager::Instance();
	//	man->SetDefaultStorage("raw://");
	man->SetDefaultStorage("local:///local/cdb");
	man->SetSpecificStorage("GRP/GRP/Data",
			      Form("local://%s",gSystem->pwd()));
	man->SetSpecificStorage("GRP/CTP/Config",
			      Form("local://%s",gSystem->pwd()));
	man->SetLock(kTRUE);

	gSystem->mkdir(Form("run%d",run));
	gSystem->cd(Form("run%d",run));

	gROOT->LoadMacro(gSystem->ExpandPathName(recMacroPath));
	rec(dataSource.Data());

	AliCDBManager::Destroy();
      }
      else {
	cout << "No GDCs defined in the logbook entry for run " << run << endl;
      }
    }
  }

  printf("Execution time: R:%.2fs C:%.2fs \n",
	 stopwatch.RealTime(),stopwatch.CpuTime());

  return run;

}

Int_t grp(UInt_t run, TString &gdc) {

  Int_t ret=AliGRPPreprocessor::ReceivePromptRecoParameters(run, "aldaqdb", 0, "LOGBOOK", "logbook", "alice",
							    Form("local://%s",gSystem->pwd()),
							    gdc);
  if(ret>0) cout << "Last run of the same type is: " << ret << endl;
  else if(ret==0) cout << "No previous run of the same type found" << endl;
  else if(ret<0) cout << "Error code while retrieving GRP parameters returned: " << ret << endl;
  return(ret);
}
 onlineReco.C:1
 onlineReco.C:2
 onlineReco.C:3
 onlineReco.C:4
 onlineReco.C:5
 onlineReco.C:6
 onlineReco.C:7
 onlineReco.C:8
 onlineReco.C:9
 onlineReco.C:10
 onlineReco.C:11
 onlineReco.C:12
 onlineReco.C:13
 onlineReco.C:14
 onlineReco.C:15
 onlineReco.C:16
 onlineReco.C:17
 onlineReco.C:18
 onlineReco.C:19
 onlineReco.C:20
 onlineReco.C:21
 onlineReco.C:22
 onlineReco.C:23
 onlineReco.C:24
 onlineReco.C:25
 onlineReco.C:26
 onlineReco.C:27
 onlineReco.C:28
 onlineReco.C:29
 onlineReco.C:30
 onlineReco.C:31
 onlineReco.C:32
 onlineReco.C:33
 onlineReco.C:34
 onlineReco.C:35
 onlineReco.C:36
 onlineReco.C:37
 onlineReco.C:38
 onlineReco.C:39
 onlineReco.C:40
 onlineReco.C:41
 onlineReco.C:42
 onlineReco.C:43
 onlineReco.C:44
 onlineReco.C:45
 onlineReco.C:46
 onlineReco.C:47
 onlineReco.C:48
 onlineReco.C:49
 onlineReco.C:50
 onlineReco.C:51
 onlineReco.C:52
 onlineReco.C:53
 onlineReco.C:54
 onlineReco.C:55
 onlineReco.C:56
 onlineReco.C:57
 onlineReco.C:58
 onlineReco.C:59
 onlineReco.C:60
 onlineReco.C:61
 onlineReco.C:62
 onlineReco.C:63
 onlineReco.C:64
 onlineReco.C:65
 onlineReco.C:66
 onlineReco.C:67
 onlineReco.C:68
 onlineReco.C:69
 onlineReco.C:70
 onlineReco.C:71
 onlineReco.C:72
 onlineReco.C:73
 onlineReco.C:74
 onlineReco.C:75
 onlineReco.C:76
 onlineReco.C:77
 onlineReco.C:78
 onlineReco.C:79
 onlineReco.C:80