more development
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 17 Jul 2008 11:32:36 +0000 (11:32 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 17 Jul 2008 11:32:36 +0000 (11:32 +0000)
test/cosmic/qasummary.C [new file with mode: 0644]
test/cosmic/rawqa.C
test/cosmic/rawqa.sh

diff --git a/test/cosmic/qasummary.C b/test/cosmic/qasummary.C
new file mode 100644 (file)
index 0000000..33f5c3c
--- /dev/null
@@ -0,0 +1,35 @@
+void qasummary()
+{
+  // checks all QA result and issues a summary
+
+  TString cmd = Form(".! ls QA.*.root > tempo.txt") ;
+  gROOT->ProcessLine(cmd.Data()) ;                
+  ifstream in("tempo.txt") ;   
+  TString file ;
+  while ( 1 ) {
+    in >> file ; 
+    if ( !in.good() ) 
+      break ; 
+    TFile qaf(file) ;
+    Bool_t flag = kFALSE ; 
+    AliQA * qa = static_cast<AliQA *>(qaf.Get(AliQA::GetQAName())) ; 
+    for (Int_t det = 0; det < AliQA::kNDET; det++) {
+      for (Int_t task = 0; task < AliQA::kNTASK; task++) {
+       for (Int_t bit = 0; bit < AliQA::kNBIT; bit++) {
+         if (qa->IsSet(det, task, bit)) {
+           flag = kTRUE ; 
+           break ;
+         }
+         if (flag)
+           break ; 
+       }
+       if (flag) break ; 
+      }
+      if (flag) {
+       printf(" ***************** QA error found in %s :\n", file.Data()) ; 
+       qa->Show(det) ;
+       flag = kFALSE ; 
+      } 
+    }
+  }  
+}
index 5606cdd..2904c01 100644 (file)
@@ -25,153 +25,104 @@ TString ClassName() { return "rawqa" ; }
 //________________________________qa______________________________________
 void rawqa(const char * filename) 
 {      
+
+        // retrieve evironment variables
+       const char * year = gSystem->Getenv("YEAR") ; 
+       const TString baseDir(gSystem->Getenv("BASEDIR")) ;
+        const Int_t runNumber = atoi(gSystem->Getenv("RUNNUM")) ; 
+
        // build the default storage of OCDB 
        TString sfilename(filename) ; 
        sfilename = sfilename.Strip() ; 
        sfilename = sfilename.Strip(TString::kLeading) ;
-       TString baseDir(gSystem->Getenv("BASEDIR")) ;
+       sfilename.Prepend("alien://") ; 
+
        baseDir.Append("/") ; 
-       TString temp = sfilename.ReplaceAll(baseDir, "") ; 
+       TString temp(filename) ;
+       temp = temp.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 ;
-
+       
        AliLog::SetGlobalDebugLevel(0) ; 
+       
        // connect to the grid 
        TGrid * grid = 0x0 ; 
        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("*.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())) ; 
-//     }
+       
+       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"} ; 
+       
+       AliQADataMakerSteer qas ; 
+       TString detectors  = ""; 
+       TString detectorsW = ""; 
+       UShort_t eventsProcessed = 0 ; 
+       UShort_t filesProcessed  = 1 ; 
+       AliCDBManager* man = AliCDBManager::Instance();
+       man->SetDefaultStorage(kDefaultOCDBStorage) ;  
+       man->SetRun(runNumber) ; 
+       AliGeomManager::LoadGeometry();
+       printf("INFO: Proccessing file %s\n", filename) ;
+       // check which detectors are present 
+       AliRawReader * rawReader = new AliRawReaderRoot(sfilename);
+       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) {
+             printf("INFO: Wrong detector ID! Skipping payload...\n");
+             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(1) ; 
+         detectorsW = qas.Run(detectors, rawReader) ;
+         qas.Reset() ;
+               } else {
+                 printf("ERROR: No valid detectors found") ; 
+       } 
+        delete rawReader ;
+       eventsProcessed += qas.GetCurrentEvent() ; 
+       //qas.Merge(runNumber) ; 
+       
+       // The summary 
+        printf("\n\n********** Summary for run %d **********", runNumber) ; 
+        printf("     data file                           : %s\n", filename);
+       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(index))) 
+               qa->Show((AliQA::DETECTORINDEX_t)index) ;
+         } else {
+           printf("ERROR: %s not found in %s !", AliQA::GetQAName(), AliQA::GetQAResultFileName()) ; 
+         }
+       } else {
+         printf("ERROR: %s has not been produced !", AliQA::GetQAResultFileName()) ; 
+       }
 }
index 32e3227..d70187e 100755 (executable)
 # SET THE FOLLOWING PARAMETERS IF NEEDED: 
 # ---------------------------------------
 export YEAR=08
-DIALOG=┬┤which dialog┬┤
 # ---------------------------------------
 
-RUNNUM=$1
+export RUNNUM=$1
 
 [ -z $RUNNUM ] && { echo "Please provide a run number..."; exit 1; }
 
@@ -61,13 +60,33 @@ echo
 #        --ok-label OK --radiolist "Program to run:" 15 20 5 "aliroot -b" \| on alieve \| off 2> $tempfile
 PROGRAM=aliroot #`cat $tempfile`
 # 
+rm -rf $RUNNUM"/"*QA.$RUNNUM*.root
 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"."
+     SUBCHUNK=${CHUNK#*.}
+     echo "Running QA for chunk $filename. Outputs will be stored in "$RUNNUM"/"$CHUNK".   $SUBCHUNK"
      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 ../..
+     ls *.QA.$RUNNUM.0.root > $tempfile
+     cd ../
+     QAFILES=`cat $tempfile`
+     for qafile in $QAFILES; do
+        in=$CHUNK/$qafile
+        ou=${qafile/.0./.$SUBCHUNK.}
+        ln -si $in $ou
+     done
+     ln -si $CHUNK/QA.root QA.$SUBCHUNK.root
+     cd ../
 done
+cd $RUNNUM
+$PROGRAM -b <<EOF
+ AliQADataMakerSteer qas ; 
+ qas.Merge(atoi(gSystem->Getenv("RUNNUM"))) ;
+EOF
+rm -f tempo.txt
+
+$PROGRAM -b $ALICE_ROOT/test/cosmic/qasummary.C
+cd ..