From 0309ed6ae249de91a96a12f45590a94af83e5a07 Mon Sep 17 00:00:00 2001 From: zampolli Date: Fri, 5 Feb 2010 20:17:14 +0000 Subject: [PATCH] Committing macros + script to perform pass0 reconstruction, and pass1 reconstruction with calibration: 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 | 158 ++++++++++++++++++++++++++++ ANALYSIS/macros/recPass0.C | 43 ++++++++ ANALYSIS/macros/runPassX.sh | 53 ++++++++++ 3 files changed, 254 insertions(+) create mode 100644 ANALYSIS/macros/mergeCalibObjects.C create mode 100644 ANALYSIS/macros/recPass0.C create mode 100755 ANALYSIS/macros/runPassX.sh diff --git a/ANALYSIS/macros/mergeCalibObjects.C b/ANALYSIS/macros/mergeCalibObjects.C new file mode 100644 index 00000000000..7ac52cf2ba3 --- /dev/null +++ b/ANALYSIS/macros/mergeCalibObjects.C @@ -0,0 +1,158 @@ +/* + Merge calibration entry macro: + + Example usage: + + .L $ALICE_ROOT/ANALYSIS/macros/mergeCalibObjects.C + mergeCalibObjects() + +*/ + +#if !defined(__CINT__) || defined(__MAKECINT__) + +#include +#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(¤tFile, 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; iGetEntries(); 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; iGetEntries(); 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; icalGetEntries(); 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; iGetEntries(); 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 index 00000000000..a6d0105cc89 --- /dev/null +++ b/ANALYSIS/macros/recPass0.C @@ -0,0 +1,43 @@ +// +// rec.C to be used for pass0 +// + +void rec(const char *filename="raw.root",Int_t nevents=-1) +{ + // Load some system libs for Grid and monitoring + // Set the CDB storage location + AliCDBManager * man = AliCDBManager::Instance(); + man->SetDefaultStorage("raw://"); + + // Reconstruction settings + AliReconstruction rec; + + // Set protection against too many events in a chunk (should not happen) + if (nevents>0) rec.SetEventRange(0,nevents); + + // Switch off HLT until the problem with schema evolution resolved + //rec.SetRunReconstruction("ALL-HLT"); + // + // QA options + // + AliQAManager *qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ; + rec.SetRunQA(":"); + rec.SetRunGlobalQA(kFALSE); + + // AliReconstruction settings + rec.SetWriteESDfriend(kTRUE); + rec.SetWriteAlignmentData(); + rec.SetInput(filename); + rec.SetUseTrackingErrorsForAlignment("ITS"); + rec.SetRunReconstruction("ITS TPC TRD TOF"); + rec.SetFillESD("ITS TPC TRD TOF"); + + // switch off cleanESD + rec.SetCleanESD(kFALSE); + + AliLog::Flush(); + rec.Run(); + +} + + diff --git a/ANALYSIS/macros/runPassX.sh b/ANALYSIS/macros/runPassX.sh new file mode 100755 index 00000000000..fec41e6badf --- /dev/null +++ b/ANALYSIS/macros/runPassX.sh @@ -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 -- 2.43.0