--- /dev/null
+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") {
+ 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 gdcList;
+ if (grp(run) > 0) {
+
+ // "t" stores the token on this disk, otherwise the alien connection is not thread/process-safe
+ TGrid::Connect("alien://", 0, 0, "t");
+
+ TObjArray *gdcs = gdcList.Tokenize(" ");
+ Int_t ngdcs = tokens->GetEntriesFast();
+ if (ngdcs > 0) {
+
+ TString dataSource = ((TObjString*)gdcs->At(0))->String();
+ dataSource.Prepend("mem://@");
+ datasource.Append(":");
+
+ // Setting CDB
+ AliCDBManager * man = AliCDBManager::Instance();
+ man->SetDefaultStorage("raw://");
+ man->SetSpecificStorage("GRP/GRP/Data",
+ Form("local://%s",gSystem->pwd()));
+ man->SetSpecificStorage("GRP/CTP/Config",
+ Form("local://%s",gSystem->pwd()));
+ man->Lock();
+
+ 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;
+ }
+ delete gdcs;
+ }
+ }
+
+ printf("Execution time: R:%.2fs C:%.2fs \n",
+ stopwatch.RealTime(),stopwatch.CpuTime());
+
+ return run;
+
+}
+
+Int_t grp(UInt_t run, TString &gdcList) {
+
+ Int_t ret=AliGRPPreprocessor::ReceivePromptRecoParameters(run, "aldaqdb", 0, "LOGBOOK", "logbook", "alice",
+ Form("local://%s",gSystem->pwd()),
+ gdcList);
+ 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);
+}
--- /dev/null
+#!/bin/bash
+
+source ~/.bashrc
+
+export BASE_DIR=/home/offline/onlineReco
+export RECO_DIR=$BASE_DIR/reco
+
+## enabling core dumps
+ulimit -c 100000000000000
+
+#----------------------------------------------------------------------
+# check that no other instances of online reconstruction are running at the same time!
+
+PIDFILE=$BASE_DIR/current.pid
+if [ -f $PIDFILE ]
+then
+ OLDPID=`cat $PIDFILE`
+ echo "Lock file $PIDFILE found. Checking process $OLDPID"
+ kill -0 $OLDPID
+ pidcheck=$?
+ if [ "$pidcheck" -eq "1" ]
+ then
+ echo "Process $OLDPID done, removing file"
+ rm -f $PIDFILE
+ else
+ echo "Process $OLDPID still running, exiting now!"
+ exit 0;
+ fi
+fi
+
+PROCNAME=`basename $0`
+CURPID=`pgrep $PROCNAME`
+echo "current process pid = " $CURPID
+echo $CURPID > $PIDFILE
+
+cd $BASE_DIR
+
+#------------------------------------------------------------------------
+# init GRID environment
+
+echo; echo 'Init GRID environment...'
+#root_alien_setup
+
+#------------------------------------------------------------------------
+# Setting environment
+
+echo;
+
+export BUILD_DIR=$BASE_DIR/build
+source $BUILD_DIR/SetAliRoot.sh
+
+echo;
+
+echo Root is: `root-config --version`
+echo AliRoot is: `aliroot --version`
+echo;
+
+cd $BASE_DIR
+
+if [ ! -e $RECO_DIR/log ]
+then
+ mkdir $RECO_DIR/log
+fi
+
+while [ 1 ]
+do
+ cd $RECO_DIR/log
+ aliroot -q $ALICE_ROOT/MONITOR/onlineReco.C\(\"listen\",\"$ALICE_ROOT/test/cosmic/rec.C\"\) | tee rec.log
+# mv rec.log log/run%%_rec.log
+done
+
+cd $BASE_DIR
+
+# remove lock file
+rm -f $PIDFILE
+
+exit 0
+
+