-#include <iostream>
-#include <fstream>
-
-#include <TAlienCollection.h>
-#include <TFile.h>
-#include <TGrid.h>
-#include <TGridResult.h>
-#include <TROOT.h>
-#include <TString.h>
-#include <TSystem.h>
-
-#include "AliCDBManager.h"
-#include "AliLog.h"
-#include "AliQA.h"
-#include "AliQADataMakerSteer.h"
-#include "AliRawReader.h"
-#include "AliRawReaderRoot.h"
-#include "AliDAQ.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, const char* year = "08")
+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) ;
+ sfilename.Prepend("alien://") ;
+
+ baseDir.Append("/") ;
+ 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()) ;
+
+ // set the location of reference data
+ //AliQA::SetQARefStorage(Form("%s%s/", AliQA::GetQARefDefaultStorage(), year)) ;
+ AliQA::SetQARefStorage("local://$ALICE_ROOT") ;
+
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 ;
- const UInt_t kMaxFiles = 10 ;
- 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(), kMaxFiles) ;
- 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) ;
-
- AliCDBManager* man = AliCDBManager::Instance();
- man->SetDefaultStorage("alien://folder=/alice/data/2008/LHC08a/OCDB/"); // AliQA::GetQARefDefaultStorage()
- AliQA::SetQARefStorage("local://../TestCDB") ;
- man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage());
+ 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 file = 0 ;
- for ( file = 0 ; file < kMaxFiles ; file++) {
- TString fileName ;
- if ( local) {
- in >> fileName ;
- }
- else
- fileName = result->GetKey(file, "turl");
- if ( fileName == "" )
- break ;
- if ( fileName.Contains("tag") )
- continue;
- 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);
- 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;
- }
- 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(" ") ;
- }
- }
- }
- // TEMPORARY REMOVAL OF TRD!!!
- detectors.ReplaceAll("TRD","");
- // TEMPORARY REMOVAL OF TRD!!!
- if ( !detectors.IsNull() ) {
- detectorsW = qas.Run(detectors, rawReader) ;
- qas.Reset() ;
- } else {
- AliError("No valid detectors found") ;
- }
- delete rawReader;
+ 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 ;
}
- AliLog::Flush();
- qas.Merge(runNumber) ;
+ 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) ;
- AliLog::Flush();
// The summary
- AliInfo(Form("\n\n********** Summary for run %d **********", runNumber)) ;
+ 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 processed : %d\n", file) ;
+ 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(AliQA::GetQAName())) ;
+ if ( qa) {
+ for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
+ if (detectorsW.Contains(AliQA::GetDetName(index)))
+ qa->Show((AliQA::GetDetIndex(AliQA::GetDetName(index)))) ;
+ } else {
+ printf("ERROR: %s not found in %s !", AliQA::GetQAName(), AliQA::GetQAResultFileName()) ;
+ }
+ } else {
+ printf("ERROR: %s has not been produced !", AliQA::GetQAResultFileName()) ;
+ }
}