]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
rawqa aka rec
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Jul 2008 14:57:47 +0000 (14:57 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Jul 2008 14:57:47 +0000 (14:57 +0000)
test/cosmic/rawqa.C
test/cosmic/rawqa.sh [new file with mode: 0755]

index d760a6db27315d49fc709b67dd3ff272660872ef..5606cddd189d776e4fa9c4bbf03bb4fe25994c14 100644 (file)
-#include <iostream>
-#include <fstream>
-
-#include <TAlienCollection.h>
-#include <TFile.h>
-#include <TGrid.h>
-#include <TGridResult.h>
-#include <TMath.h>
-#include <TROOT.h>
-#include <TString.h>
-#include <TSystem.h>
-
-#include "AliCDBManager.h"
-#include "AliDAQ.h"
-#include "AliLog.h"
-#include "AliQA.h"
-#include "AliQADataMakerSteer.h"
-#include "AliRawReader.h"
-#include "AliRawReaderRoot.h"
-#include "AliTRDrawStreamBase.h"
+//#include <iostream>
+//#include <fstream>
+//
+//#include <TAlienCollection.h>
+//#include <TFile.h>
+//#include <TGrid.h>
+//#include <TGridResult.h>
+//#include <TMath.h>
+//#include <TROOT.h>
+//#include <TString.h>
+//#include <TSystem.h>
+//
+//#include "AliCDBManager.h"
+//#include "AliDAQ.h"
+//#include "AliLog.h"
+//#include "AliQA.h"
+//#include "AliQADataMakerSteer.h"
+//#include "AliRawReader.h"
+//#include "AliRawReaderRoot.h"
+//#include "AliTRDrawStreamBase.h"
+//#include "AliGeomManager.h"
 
 TString ClassName() { return "rawqa" ; } 
 
 //________________________________qa______________________________________
-void rawqa(const Int_t runNumber, Int_t maxFiles = 10, const char* year = "08"
+void rawqa(const char * filename
 {      
-       char kDefaultOCDBStorage[120] ; 
-       sprintf(kDefaultOCDBStorage, "alien://folder=/alice/data/20%s/LHC%sa/OCDB/", year, year) ; 
-       AliQA::SetQARefStorage(Form("%s%s/", AliQA::GetQARefDefaultStorage(), year)) ;  
-       AliQA::SetQARefDataDirName("Data") ; //Data, Pedestals, BlackEvent, ..... 
-       
+       // build the default storage of OCDB 
+       TString sfilename(filename) ; 
+       sfilename = sfilename.Strip() ; 
+       sfilename = sfilename.Strip(TString::kLeading) ;
+       TString baseDir(gSystem->Getenv("BASEDIR")) ;
+       baseDir.Append("/") ; 
+       TString temp = sfilename.ReplaceAll(baseDir, "") ; 
+       temp = temp.Strip(TString::kLeading, '/') ; 
+       baseDir.Append(temp(0, temp.Index("/"))) ;  
+       char * kDefaultOCDBStorage = Form("alien://folder=%s/OCDB/", baseDir.Data()) ; 
+       sfilename.Prepend("alien://") ; 
+
+       // set the location of reference data 
+       char * year = gSystem->Getenv("YEAR") ; 
+       //AliQA::SetQARefStorage(Form("%s%s/", AliQA::GetQARefDefaultStorage(), year)) ;  
+       AliQA::SetQARefStorage("local://$ALICE_ROOT") ;
+
        UInt_t maxEvents = 99999 ;
-       if ( maxFiles < 0 ) {
-               maxEvents = TMath::Abs(maxFiles) ; 
-               maxFiles = 99 ; 
-       }
+
        AliLog::SetGlobalDebugLevel(0) ; 
        // connect to the grid 
        TGrid * grid = 0x0 ; 
-               grid = TGrid::Connect("alien://") ; 
+       grid = TGrid::Connect("alien://") ; 
                
-       Bool_t detIn[AliDAQ::kNDetectors] = {kFALSE} ;
-       char * detNameOff[AliDAQ::kNDetectors] = {"ITS", "ITS", "ITS", "TPC", "TRD", "TOF", "HMPID", "PHOS", "PHOS", "PMD", "MUON", "MUON", "FMD", "T0", "VZERO", "ZDC", "ACORDE", "TRG", "EMCAL", "DAQ_TEST", "HLT"} ; 
-       // make the file name pattern year and run number
-       TString pattern;
-       pattern.Form("%9d",runNumber);
-       pattern.ReplaceAll(" ", "0") ; 
-       pattern.Prepend(year);
-       pattern.Append("*0.root");
-
-       // find the files associated to this run
-       TGridResult * result = 0x0 ; 
-       Bool_t local = kFALSE ; 
-       if (grid) { // get the list of files from AliEn directly 
-         TString baseDir; 
-         baseDir.Form("/alice/data/20%s/",year);
-         result = grid->Query(baseDir, pattern) ;  
-       } else {
-         TString collectionFile(pattern) ; 
-         collectionFile.Append(".xml") ; 
-         if ( gSystem->AccessPathName(collectionFile) == 0 ) { // get the list of files from an a-priori created collection file
-           TAlienCollection collection(collectionFile.Data(), maxFiles) ; 
-           result = collection.GetGridResult("", 0, 0); 
-         } else { // get the list of files from the local current directory 
-           local = kTRUE ; 
-           char line[100] ; 
-           sprintf(line, ".! ls %s*.root > tempo.txt", pattern.Data()) ; 
-           gROOT->ProcessLine(line) ;
-         }
-       }
-       AliLog::Flush();
-       ifstream in ; 
-       if (local) 
-               in.open("tempo.txt", ifstream::in) ; 
-
-       AliQADataMakerSteer qas ; 
-       TString detectors  = ""; 
-       TString detectorsW = ""; 
-       UShort_t file = 0 ; 
-       UShort_t filesProcessed = 0 ; 
-       UShort_t eventsProcessed = 0 ; 
-       AliCDBManager* man = AliCDBManager::Instance();
-       for ( file = 0 ; file < maxFiles ; file++) {
-               man->SetDefaultStorage(kDefaultOCDBStorage) ;  
-               if ( qas.GetCurrentEvent() >= maxEvents) 
-                       break ;
-
-               TString fileName ; 
-               if ( local) {
-                       in >> fileName ;
-               } 
-               else 
-                       fileName = result->GetKey(file, "turl");
-               if ( fileName == "" )  
-                       break ;
-               if ( fileName.Contains("tag") )
-                       continue; 
-                filesProcessed++ ;
-               char input[200] ; 
-               if (local) 
-                       sprintf(input, "%s", fileName.Data()) ; 
-               else 
-                       sprintf(input, "%s", result->GetKey(file, "turl")); 
-               AliInfo(Form("Proccessing file # %d --> %s", file, input)) ;
-               AliLog::Flush();
-               // check which detectors are present 
-               AliRawReader * rawReader = new AliRawReaderRoot(input);
-               AliTRDrawStreamBase::SetRawStreamVersion("TB");
-               while ( rawReader->NextEvent() ) {
-                       man->SetRun(rawReader->GetRunNumber());
-                       AliLog::Flush();
-                       UChar_t * data ; 
-                       while (rawReader->ReadNextData(data)) {
-                               Int_t detID = rawReader->GetDetectorID();
-                               if (detID < 0 || detID >= AliDAQ::kNDetectors) {
-                                       AliError("Wrong detector ID! Skipping payload...");
-                                       continue;
-                               }
-                               detIn[detID] = kTRUE ; 
-                       }
-                       for (Int_t detID = 0; detID < AliDAQ::kNDetectors ; detID++) {
-                               if (detIn[detID]) {
-                                       if ( ! detectors.Contains(detNameOff[detID]) ) {
-                                               detectors.Append(detNameOff[detID]) ;
-                                               detectors.Append(" ") ;
-                                       }
-                               }
-                       }
-                       if ( !detectors.IsNull() )
-                               break ; 
-               }
-               if ( !detectors.IsNull() ) {
-                       qas.SetMaxEvents(maxEvents) ;   
-                       detectorsW = qas.Run(detectors, rawReader) ;
-                       qas.Reset() ;
-               } else {
-                       AliError("No valid detectors found") ; 
-               } 
-               delete rawReader ;
-               eventsProcessed += qas.GetCurrentEvent() ; 
-       }
-       AliLog::Flush();
-       qas.Merge(runNumber) ; 
-       
-       AliLog::Flush();
-       // The summary 
-       AliInfo(Form("\n\n********** Summary for run %d **********", runNumber)) ; 
-       printf("     detectors present in the run        : %s\n", detectors.Data()) ; 
-       printf("     detectors present in the run with QA: %s\n", detectorsW.Data()) ; 
-       printf("     number of files/events processed    : %d/%d\n", filesProcessed, eventsProcessed) ; 
-       TFile * qaResult = TFile::Open(AliQA::GetQAResultFileName()) ; 
-       if ( qaResult ) {
-               AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get(AliQA::GetQAName())) ; 
-               if ( qa) {
-                       for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
-                               if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX_t(index)))) 
-                                       qa->ShowStatus(AliQA::DETECTORINDEX_t(index)) ;
-               } else {
-                       AliError(Form("%s not found in %s !", AliQA::GetQAName(), AliQA::GetQAResultFileName())) ; 
-               }
-       } else {
-               AliError(Form("%s has not been produced !", AliQA::GetQAResultFileName())) ; 
-       }
+//     Bool_t detIn[AliDAQ::kNDetectors] = {kFALSE} ;
+//     char * detNameOff[AliDAQ::kNDetectors] = {"ITS", "ITS", "ITS", "TPC", "TRD", "TOF", "HMPID", "PHOS", "PHOS", "PMD", "MUON", "MUON", "FMD", "T0", "VZERO", "ZDC", "ACORDE", "TRG", "EMCAL", "DAQ_TEST", "HLT"} ; 
+//     // make the file name pattern year and run number
+//     TString pattern;
+//     pattern.Form("%9d",runNumber);
+//     pattern.ReplaceAll(" ", "0") ; 
+//     pattern.Prepend(year);
+//     pattern.Append("*.root");
+//     // find the files associated to this run
+//     TGridResult * result = 0x0 ; 
+//     Bool_t local = kFALSE ; 
+//     if (grid) { // get the list of files from AliEn directly 
+//             TString collectionFile(pattern) ; 
+//             collectionFile.ReplaceAll("*.root", ".xml") ; 
+//             if ( gSystem->AccessPathName(collectionFile) == 0 ) { // get the list of files from an a-priori created collection file
+//                     TAlienCollection collection(collectionFile.Data(), maxFiles) ; 
+//                     result = collection.GetGridResult("", 0, 0); 
+//             } else { 
+//                     TString baseDir; 
+//                     baseDir.Form("/alice/data/20%s/",year);
+//                     result = grid->Query(baseDir, pattern) ;  
+//             }
+//     } else {
+//        // get the list of files from the local current directory 
+//         local = kTRUE ; 
+//         char line[100] ; 
+//         sprintf(line, ".! ls %s*.root > tempo.txt", pattern.Data()) ; 
+//         gROOT->ProcessLine(line) ;
+//     }
+//     
+//     AliLog::Flush();
+//     ifstream in ; 
+//     if (local) 
+//             in.open("tempo.txt", ifstream::in) ; 
+//
+//     AliQADataMakerSteer qas ; 
+//     TString detectors  = ""; 
+//     TString detectorsW = ""; 
+//     UShort_t file = 0 ; 
+//     UShort_t filesProcessed = 0 ; 
+//     UShort_t eventsProcessed = 0 ; 
+//     AliCDBManager* man = AliCDBManager::Instance();
+//     man->SetDefaultStorage(kDefaultOCDBStorage) ;  
+//     man->SetRun(runNumber) ; 
+//     AliGeomManager::LoadGeometry();
+//     for ( file = 0 ; file < maxFiles ; file++) {
+//             if ( qas.GetCurrentEvent() >= maxEvents) 
+//                     break ;
+//
+//             TString fileName ; 
+//             if ( local) {
+//                     in >> fileName ;
+//             } 
+//             else 
+//                     fileName = result->GetKey(file, "turl");
+//             if ( fileName == "" )  
+//                     break ;
+//             if ( fileName.Contains("tag") )
+//                     continue; 
+//                filesProcessed++ ;
+//             char input[200] ; 
+//             if (local) 
+//                     sprintf(input, "%s", fileName.Data()) ; 
+//             else 
+//                     sprintf(input, "%s", result->GetKey(file, "turl")); 
+//             AliInfo(Form("Proccessing file # %d --> %s", file, input)) ;
+//             AliLog::Flush();
+//             // check which detectors are present 
+//             AliRawReader * rawReader = new AliRawReaderRoot(input);
+//             AliTRDrawStreamBase::SetRawStreamVersion("TB");
+//             while ( rawReader->NextEvent() ) {
+//                     man->SetRun(rawReader->GetRunNumber());
+//                     AliLog::Flush();
+//                     UChar_t * data ; 
+//                     while (rawReader->ReadNextData(data)) {
+//                             Int_t detID = rawReader->GetDetectorID();
+//                             if (detID < 0 || detID >= AliDAQ::kNDetectors) {
+//                                     AliError("Wrong detector ID! Skipping payload...");
+//                                     continue;
+//                             }
+//                             detIn[detID] = kTRUE ; 
+//                     }
+//                     for (Int_t detID = 0; detID < AliDAQ::kNDetectors ; detID++) {
+//                             if (detIn[detID]) {
+//                                     if ( ! detectors.Contains(detNameOff[detID]) ) {
+//                                             detectors.Append(detNameOff[detID]) ;
+//                                             detectors.Append(" ") ;
+//                                     }
+//                             }
+//                     }
+//                     if ( !detectors.IsNull() )
+//                             break ; 
+//             }
+//             if ( !detectors.IsNull() ) {
+//                     qas.SetMaxEvents(maxEvents) ;   
+//                     detectorsW = qas.Run(detectors, rawReader) ;
+//                     qas.Reset() ;
+//             } else {
+//                     AliError("No valid detectors found") ; 
+//             } 
+//             delete rawReader ;
+//             eventsProcessed += qas.GetCurrentEvent() ; 
+//     }
+//     AliLog::Flush();
+//     qas.Merge(runNumber) ; 
+//     
+//     AliLog::Flush();
+//     // The summary 
+//     AliInfo(Form("\n\n********** Summary for run %d **********", runNumber)) ; 
+//     printf("     detectors present in the run        : %s\n", detectors.Data()) ; 
+//     printf("     detectors present in the run with QA: %s\n", detectorsW.Data()) ; 
+//     printf("     number of files/events processed    : %d/%d\n", filesProcessed, eventsProcessed) ; 
+//     TFile * qaResult = TFile::Open(AliQA::GetQAResultFileName()) ; 
+//     if ( qaResult ) {
+//             AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get(AliQA::GetQAName())) ; 
+//             if ( qa) {
+//                     for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
+//                             if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX_t(index)))) 
+//                                     qa->ShowStatus(AliQA::DETECTORINDEX_t(index)) ;
+//             } else {
+//                     AliError(Form("%s not found in %s !", AliQA::GetQAName(), AliQA::GetQAResultFileName())) ; 
+//             }
+//     } else {
+//             AliError(Form("%s has not been produced !", AliQA::GetQAResultFileName())) ; 
+//     }
 }
diff --git a/test/cosmic/rawqa.sh b/test/cosmic/rawqa.sh
new file mode 100755 (executable)
index 0000000..32e3227
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/sh
+#############################################################################
+# rawqa.sh. Front-end script to run reconstruction from the grid chunks
+# Usage:
+#    ./rawqa.sh <run_number>
+#############################################################################
+#
+# modification history
+# version 1.0  July 2008 adapated from rec.C by M. Meoni
+# author Yves Schutz CERN
+#
+
+
+# SET THE FOLLOWING PARAMETERS IF NEEDED: 
+# ---------------------------------------
+export YEAR=08
+DIALOG=´which dialog´
+# ---------------------------------------
+
+RUNNUM=$1
+
+[ -z $RUNNUM ] && { echo "Please provide a run number..."; exit 1; }
+
+[ ! -e "$HOME/.globus/usercert.pem" ] && { echo "FAILED: There is no certificate in $HOME/.globus"; exit 1; }
+
+[ -e "/tmp/gclient_env_$UID" ] && { source /tmp/gclient_env_$UID; }
+alien-token-init 
+
+[ ! "$?" -eq "0" ] && { echo "FAILED: Token creation failed"; exit 1; }
+
+VERSION=1.0
+TITLE="Standalone QA checking of Grid rawdata chunks. v$VERSION"
+
+# Retrieve the list of chunks from AliEn.......
+export BASEDIR="/alice/data/20"$YEAR
+PATTERN="/raw/"$YEAR"0000"$RUNNUM"*0.root"
+#aliensh -c "gbbox find $BASEDIR $PATTERN" | head --lines=-1 > collection.tmp
+aliensh -c "gbbox find $BASEDIR $PATTERN" > collection.tmp
+
+[ `ls -al collection.tmp | awk '{print $5}'` -eq 0 ] && { echo "No chunks found for the given run"; exit 1; }
+rm -r collection.tmp2
+#
+for ifile in `cat collection.tmp | grep root` ; do printf $ifile" "\|" "0" " >> collection.tmp2 ; done
+list=`cat collection.tmp2`
+[ -e collection.tmp2 ] && { rm -f collection.tmp2 ; } 
+totChunks=`cat collection.tmp | wc -l`
+rm -f collection.tmp
+
+tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
+trap "rm -f $tempfile" 0 1 2 5 15
+dialog --clear --no-cancel --title "$TITLE" \
+        --ok-label OK --checklist "$totChunks chunks available for run $RUNNUM (only the first 500 are shown). Select chunks for reconstruction" 18 80 10 \
+        $list 2> $tempfile
+
+CHUNKS=`cat $tempfile`
+echo "Selected chunks:"
+echo $CHUNKS
+echo
+
+#dialog --clear --no-cancel \
+#        --ok-label OK --radiolist "Program to run:" 15 20 5 "aliroot -b" \| on alieve \| off 2> $tempfile
+PROGRAM=aliroot #`cat $tempfile`
+# 
+for filename in $CHUNKS; do
+     filename=${filename//\"/} 
+     CHUNK=`basename $filename | cut -d "." -f 1,2`
+     echo "Running QA for chunk $filename. Outputs will be stored in "$RUNNUM"/"$CHUNK"."
+     rm -rf   $RUNNUM"/"$CHUNK
+     mkdir -p $RUNNUM"/"$CHUNK
+     cd       $RUNNUM"/"$CHUNK
+     $PROGRAM -q $ALICE_ROOT/test/cosmic/rawqa.C\(\"$filename\"\) 2>&1 | tee rawqa.log
+     cd ../..
+done