]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Test version of the shell script and macro for running the online reco @ P2.
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Aug 2009 11:43:31 +0000 (11:43 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Aug 2009 11:43:31 +0000 (11:43 +0000)
MONITOR/onlineReco.C [new file with mode: 0644]
MONITOR/onlineReco.sh [new file with mode: 0644]

diff --git a/MONITOR/onlineReco.C b/MONITOR/onlineReco.C
new file mode 100644 (file)
index 0000000..46da216
--- /dev/null
@@ -0,0 +1,78 @@
+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);
+}
diff --git a/MONITOR/onlineReco.sh b/MONITOR/onlineReco.sh
new file mode 100644 (file)
index 0000000..eb92b59
--- /dev/null
@@ -0,0 +1,79 @@
+#!/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
+
+