]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - test/cosmic/rawqa.C
changed format
[u/mrichter/AliRoot.git] / test / cosmic / rawqa.C
index 11607eac81960560f5f26181996f882882b9eefa..f0ea333a4edc040cc8015d37e141d05b77e405bf 100644 (file)
@@ -5,6 +5,7 @@
 #include <TFile.h>
 #include <TGrid.h>
 #include <TGridResult.h>
+#include <TMath.h>
 #include <TROOT.h>
 #include <TString.h>
 #include <TSystem.h>
 TString ClassName() { return "rawqa" ; } 
 
 //________________________________qa______________________________________
-void rawqa(const Int_t runNumber, const UInt_t kMaxFiles = 10, const char* year = "08") 
+void rawqa(const Int_t runNumber, Int_t maxFiles = 10, const char* year = "08") 
 {      
-
+       const char * kDefaultOCDBStorage = Form("alien://folder=/alice/data/20%s/LHC%sa/OCDB/", year, year) ; 
+       
+       UInt_t maxEvents = 99999 ;
+       if ( maxFiles < 0 ) {
+               maxEvents = TMath::Abs(maxFiles) ; 
+               maxFiles = 99 ; 
+       }
        AliLog::SetGlobalDebugLevel(0) ; 
        // connect to the grid 
        TGrid * grid = 0x0 ; 
@@ -48,7 +55,7 @@ void rawqa(const Int_t runNumber, const UInt_t kMaxFiles = 10, const char* year
          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(), kMaxFiles) ; 
+           TAlienCollection collection(collectionFile.Data(), maxFiles) ; 
            result = collection.GetGridResult("", 0, 0); 
          } else { // get the list of files from the local current directory 
            local = kTRUE ; 
@@ -63,15 +70,19 @@ void rawqa(const Int_t runNumber, const UInt_t kMaxFiles = 10, const char* year
                in.open("tempo.txt", ifstream::in) ; 
 
        AliCDBManager* man = AliCDBManager::Instance();
-       man->SetDefaultStorage(AliQA::GetQARefDefaultStorage()) ; 
-       AliQA::SetQARefStorage("alien://folder=/alice/QA/2008") ; 
-       man->SetSpecificStorage(Form("%s/20%s/*", AliQA::GetQAOCDBDirName(), year),AliQA::GetQARefStorage());
+       man->SetDefaultStorage(kDefaultOCDBStorage) ;  
+       AliQA::SetQARefStorage("alien://folder=/alice/QA/2008/") ; 
+       man->SetSpecificStorage("*", AliQA::GetQARefStorage());
        AliQADataMakerSteer qas ; 
        TString detectors  = ""; 
        TString detectorsW = ""; 
        UShort_t file = 0 ; 
-        UShort_t filesProcessed = 0 ; 
-       for ( file = 0 ; file < kMaxFiles ; file++) {
+       UShort_t filesProcessed = 0 ; 
+       UShort_t eventsProcessed = 0 ; 
+       for ( file = 0 ; file < maxFiles ; file++) {
+               if ( qas.GetCurrentEvent() >= maxEvents) 
+                       break ;
+
                TString fileName ; 
                if ( local) {
                        in >> fileName ;
@@ -92,35 +103,41 @@ void rawqa(const Int_t runNumber, const UInt_t kMaxFiles = 10, const char* year
                AliLog::Flush();
                // check which detectors are present 
                AliRawReader * rawReader = new AliRawReaderRoot(input);
-               rawReader->NextEvent() ; 
-               man->SetRun(rawReader->GetRunNumber());
-               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;
+               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 ; 
                        }
-                       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(" ") ;
+                       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 ; 
                }
                // TEMPORARY REMOVAL OF TRD!!!
-               detectors.ReplaceAll("TRD","");
+               detectors.ReplaceAll("TRD", "") ;
                // TEMPORARY REMOVAL OF TRD!!!
                if ( !detectors.IsNull() ) {
-                 detectorsW = qas.Run(detectors, rawReader) ;
-                 qas.Reset() ;
+                       qas.SetMaxEvents(maxEvents) ;   
+                       detectorsW = qas.Run(detectors, rawReader) ;
+                       qas.Reset() ;
                } else {
-                 AliError("No valid detectors found") ; 
+                       AliError("No valid detectors found") ; 
                } 
-               delete rawReader;
+               delete rawReader ;
+               eventsProcessed += qas.GetCurrentEvent() ; 
        }
        AliLog::Flush();
        qas.Merge(runNumber) ; 
@@ -130,10 +147,14 @@ void rawqa(const Int_t runNumber, const UInt_t kMaxFiles = 10, const char* year
        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 processed           : %d\n", filesProcessed) ; 
+       printf("     number of files/events processed    : %d/%d\n", filesProcessed, eventsProcessed) ; 
        TFile * qaResult = TFile::Open(AliQA::GetQAResultFileName()) ; 
-       AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get("QA")) ; 
-       for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
-               if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX(index)))) 
-                       qa->ShowStatus(AliQA::DETECTORINDEX(index)) ;
+       if ( qaResult ) {
+               AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get("QA")) ; 
+               for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
+                       if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX(index)))) 
+                               qa->ShowStatus(AliQA::DETECTORINDEX(index)) ;
+       } else {
+               AliError(Form("%s has not been produced !", AliQA::GetQAResultFileName())) ; 
+       }
 }