]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Committing macros + script to perform pass0 reconstruction, and pass1 reconstruction...
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 5 Feb 2010 20:17:14 +0000 (20:17 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 5 Feb 2010 20:17:14 +0000 (20:17 +0000)
mergeCalibObjects.C, runPassX.sh, recPass0.C

mergeCalibObjects.C  - generic merge script - Output  0-common merge file or 1- one file per object
runPassX.sh          - shell scipt to run rconstruction/calibration (to be invoked in jdl)
recPass0.C           - macro with reconstruction setting for pass 0 (ITS,TPC,TRd,TOF only)

(Marian)

ANALYSIS/macros/mergeCalibObjects.C [new file with mode: 0644]
ANALYSIS/macros/recPass0.C [new file with mode: 0644]
ANALYSIS/macros/runPassX.sh [new file with mode: 0755]

diff --git a/ANALYSIS/macros/mergeCalibObjects.C b/ANALYSIS/macros/mergeCalibObjects.C
new file mode 100644 (file)
index 0000000..7ac52cf
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+  Merge calibration entry macro:
+  
+  Example usage:
+  
+  .L $ALICE_ROOT/ANALYSIS/macros/mergeCalibObjects.C
+  mergeCalibObjects()
+  
+*/
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include <fstream>
+#include "TSystem.h"
+#include "TFile.h"
+#include "TObjArray.h"
+#include "AliSysInfo.h"
+#include "AliTPCcalibBase.h"
+#include "TH1F.h"
+#include "TMethodCall.h"
+
+#endif
+
+void IterTXT( const char * fileList="calib.list",Bool_t separate);
+void Merge(TFile* fileIn, TObjArray * array);
+void StoreResults(TObjArray * array);
+
+
+void mergeCalibObjects( const char * fileList="calib.list",Bool_t separate=kFALSE){
+
+  // main function
+
+  IterTXT(fileList,separate );
+}
+
+void LoadLib(){
+
+  // Loading the necessary libraries
+
+  gSystem->Load("libANALYSIS");
+  gSystem->Load("libTPCcalib"); 
+  TH1::AddDirectory(0);
+}
+
+
+void IterXML(){ 
+
+  // iterating over the files coming from an XML collection 
+  // to be implemented
+
+  LoadLib();
+}
+
+void IterTXT( const char * fileList, Bool_t separate){
+
+  // Merge the files indicated in the list - fileList
+  // ASCII file opition example: 
+  // find `pwd`/ | grep AliESDfriends_v1.root > calib.list
+
+  LoadLib();
+  TObjArray * mergeArray= new TObjArray;
+  
+  // Open the input stream
+  
+  ifstream in;
+  in.open(fileList);
+  // Read the input list of files 
+  TString objfile;
+  Int_t counter=0;
+  while(in.good()) {
+    in >> objfile;
+    if (!objfile.Contains("root")) continue; // protection    
+    printf("Open file:Counter\t%d\tMerging file %s\n",counter++,objfile.Data());
+    TFile currentFile(objfile.Data());
+    Merge(&currentFile, mergeArray);
+  }
+  if (separate) 
+    StoreSeparateResults(mergeArray);
+  else
+    StoreResults(mergeArray);
+  delete mergeArray;
+}
+
+void StoreResults(TObjArray * array){
+
+  // Storing the results in one single file
+
+  TFile *f = new TFile("CalibObjects.root","recreate");
+  for (Int_t i=0; i<array->GetEntries(); i++){
+    TObject *object0 = array->At(i);
+    if (!object0) continue;
+    object0->Write();
+  }
+  f->Close();
+  delete f;
+}
+
+
+void StoreSeparateResults(TObjArray * array){
+
+  // Store the results in separate files (one per object)
+
+  for (Int_t i=0; i<array->GetEntries(); i++){
+    TObject *object0 = array->At(i);
+    if (!object0) continue;
+    TFile *f = new TFile(Form("CalibObjects_%s.root",object0->GetName()),"recreate");
+    object0->Write();
+    f->Close();
+    delete f;
+  }
+}
+
+
+
+void Merge(TFile* fileIn, TObjArray * array){
+  
+  // Merging procedure
+  
+  TObjArray *carray = new TObjArray;   //array of the objects inside current file
+  carray->SetOwner(kTRUE);
+
+  // load all objects to  memory
+  
+  TList *farr = fileIn->GetListOfKeys();
+  if (!farr) return;
+  for (Int_t ical=0; ical<farr->GetEntries(); ical++){
+    if (!farr->At(ical)) continue;
+    TObject *obj = fileIn->Get(farr->At(ical)->GetName());
+    if (obj) carray->AddLast(obj);
+    AliSysInfo::AddStamp(farr->At(ical)->GetName(),1,ical);  
+  }
+
+  if (carray->GetEntries()==0) return;
+  TMethodCall callEnv;
+
+  for (Int_t i=0; i<carray->GetEntries(); i++){
+
+    TObjArray *templist = new TObjArray(1);
+    templist->SetOwner(kFALSE);
+    TObject *currentObject = carray->At(i);
+    if (!currentObject) continue;
+    printf("%s\n",currentObject->GetName());
+    callEnv.InitWithPrototype(currentObject->IsA(), "Merge", "TCollection*");
+    if (!callEnv.IsValid()) {continue;}
+
+    TObject *mergedObject = array->FindObject(currentObject->GetName());
+    if (!mergedObject) {
+      array->AddLast(currentObject);
+      carray->RemoveAt(i);
+      continue;
+    }
+    templist->AddLast(currentObject);
+    callEnv.SetParam((Long_t) templist);
+    callEnv.Execute(mergedObject);
+    delete templist;
+  }
+  delete carray;
+}
diff --git a/ANALYSIS/macros/recPass0.C b/ANALYSIS/macros/recPass0.C
new file mode 100644 (file)
index 0000000..a6d0105
--- /dev/null
@@ -0,0 +1,43 @@
+//\r
+//   rec.C to be used for pass0\r
+//   \r
+\r
+void rec(const char *filename="raw.root",Int_t nevents=-1)\r
+{\r
+  // Load some system libs for Grid and monitoring\r
+  // Set the CDB storage location\r
+  AliCDBManager * man = AliCDBManager::Instance();\r
+  man->SetDefaultStorage("raw://");\r
\r
+  // Reconstruction settings\r
+  AliReconstruction rec;\r
+\r
+  // Set protection against too many events in a chunk (should not happen)\r
+  if (nevents>0) rec.SetEventRange(0,nevents);\r
+\r
+  // Switch off HLT until the problem with schema evolution resolved\r
+  //rec.SetRunReconstruction("ALL-HLT");\r
+  //\r
+  // QA options\r
+  //\r
+  AliQAManager *qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ;\r
+  rec.SetRunQA(":");\r
+  rec.SetRunGlobalQA(kFALSE);\r
+\r
+  // AliReconstruction settings\r
+  rec.SetWriteESDfriend(kTRUE);\r
+  rec.SetWriteAlignmentData();\r
+  rec.SetInput(filename);\r
+  rec.SetUseTrackingErrorsForAlignment("ITS");\r
+  rec.SetRunReconstruction("ITS TPC TRD TOF");\r
+  rec.SetFillESD("ITS TPC TRD TOF");\r
+\r
+  // switch off cleanESD\r
+  rec.SetCleanESD(kFALSE);\r
+\r
+  AliLog::Flush();\r
+  rec.Run();\r
+\r
+}\r
+\r
+\r
diff --git a/ANALYSIS/macros/runPassX.sh b/ANALYSIS/macros/runPassX.sh
new file mode 100755 (executable)
index 0000000..fec41e6
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Script to run:
+#    1. reconstruction
+#    2. calibration and friend track filtering
+#    3. tag creation
+#
+# Files assumed to be in working directory:
+# rec.C               - reconstruction macro
+# runCalibTrain.C     - calibration/filtering macro
+# Arguments:
+#    1  - raw data file name
+#    2  - number of events to be processed
+#    3  - run number 
+
+# example:
+# runPassX.sh raw.root  50  104892
+
+#ALIEN setting
+entries=1000
+# $1 = raw input filename
+runnum=`echo $1 | cut -d "/" -f 6`
+
+#Local setting
+#entries=$2
+#runnum=$3
+
+echo File to be  processed $1
+echo Number of events to be processed $entries
+
+echo ALICE_ROOT = $ALICE_ROOT
+echo AliROOT = $AliROOT
+cp $ALICE_ROOT/.rootrc ~/.rootrc
+cp $ALICE_ROOT/.rootrc $HOME
+#cat $HOME/.rootrc
+export GRID_TOKEN=OK
+
+echo ">>>>>>>>> PATH is..."
+echo $PATH
+echo ">>>>>>>>> LD_LIBRARY_PATH is..."
+echo $LD_LIBRARY_PATH
+echo ">>>>>>>>> rec.C is..."
+cat rec.C
+echo
+
+echo ">>>>>>> Running AliRoot to reconstruct $1. Run number is $runnum..."
+aliroot -l -b -q rec.C\(\"$1\",$2\) 2>&1 | tee rec.log
+
+echo ">>>>>>> Running AliRoot to make calibration..."
+aliroot -l -b -q  runCalibTrain.C\($runnum\)   2>&1 | tee calib.log
+
+echo ">>>>>>> Running AliRoot to generate Tags..."
+aliroot -l -b -q tag.C\(\) 2>&1 | tee tag.log