4 #include <TAlienCollection.h>
7 #include <TGridResult.h>
13 #include "AliCDBManager.h"
17 #include "AliQADataMakerSteer.h"
18 #include "AliRawReader.h"
19 #include "AliRawReaderRoot.h"
20 #include "AliTRDrawStreamBase.h"
22 TString ClassName() { return "rawqa" ; }
24 //________________________________qa______________________________________
25 void rawqa(const Int_t runNumber, Int_t maxFiles = 10, const char* year = "08")
27 char kDefaultOCDBStorage[120] ;
28 sprintf(kDefaultOCDBStorage, "alien://folder=/alice/data/20%s/LHC%sa/OCDB/", year, year) ;
29 AliQA::SetQARefStorage(Form("%s%s/", AliQA::GetQARefDefaultStorage(), year)) ;
30 AliQA::SetQARefDataDirName("Data") ; //Data, Pedestals, BlackEvent, .....
32 UInt_t maxEvents = 99999 ;
34 maxEvents = TMath::Abs(maxFiles) ;
37 AliLog::SetGlobalDebugLevel(0) ;
38 // connect to the grid
40 grid = TGrid::Connect("alien://") ;
42 Bool_t detIn[AliDAQ::kNDetectors] = {kFALSE} ;
43 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"} ;
44 // make the file name pattern year and run number
46 pattern.Form("%9d",runNumber);
47 pattern.ReplaceAll(" ", "0") ;
48 pattern.Prepend(year);
49 pattern.Append("*.root");
50 // find the files associated to this run
51 TGridResult * result = 0x0 ;
52 Bool_t local = kFALSE ;
53 if (grid) { // get the list of files from AliEn directly
54 TString collectionFile(pattern) ;
55 collectionFile.ReplaceAll("*.root", ".xml") ;
56 if ( gSystem->AccessPathName(collectionFile) == 0 ) { // get the list of files from an a-priori created collection file
57 TAlienCollection collection(collectionFile.Data(), maxFiles) ;
58 result = collection.GetGridResult("", 0, 0);
61 baseDir.Form("/alice/data/20%s/",year);
62 result = grid->Query(baseDir, pattern) ;
65 // get the list of files from the local current directory
68 sprintf(line, ".! ls %s*.root > tempo.txt", pattern.Data()) ;
69 gROOT->ProcessLine(line) ;
75 in.open("tempo.txt", ifstream::in) ;
77 AliQADataMakerSteer qas ;
78 TString detectors = "";
79 TString detectorsW = "";
81 UShort_t filesProcessed = 0 ;
82 UShort_t eventsProcessed = 0 ;
83 AliCDBManager* man = AliCDBManager::Instance();
84 for ( file = 0 ; file < maxFiles ; file++) {
85 man->SetDefaultStorage(kDefaultOCDBStorage) ;
86 if ( qas.GetCurrentEvent() >= maxEvents)
94 fileName = result->GetKey(file, "turl");
97 if ( fileName.Contains("tag") )
102 sprintf(input, "%s", fileName.Data()) ;
104 sprintf(input, "%s", result->GetKey(file, "turl"));
105 AliInfo(Form("Proccessing file # %d --> %s", file, input)) ;
107 // check which detectors are present
108 AliRawReader * rawReader = new AliRawReaderRoot(input);
109 AliTRDrawStreamBase::SetRawStreamVersion("TB");
110 while ( rawReader->NextEvent() ) {
111 man->SetRun(rawReader->GetRunNumber());
114 while (rawReader->ReadNextData(data)) {
115 Int_t detID = rawReader->GetDetectorID();
116 if (detID < 0 || detID >= AliDAQ::kNDetectors) {
117 AliError("Wrong detector ID! Skipping payload...");
120 detIn[detID] = kTRUE ;
122 for (Int_t detID = 0; detID < AliDAQ::kNDetectors ; detID++) {
124 if ( ! detectors.Contains(detNameOff[detID]) ) {
125 detectors.Append(detNameOff[detID]) ;
126 detectors.Append(" ") ;
130 if ( !detectors.IsNull() )
133 if ( !detectors.IsNull() ) {
134 qas.SetMaxEvents(maxEvents) ;
135 detectorsW = qas.Run(detectors, rawReader) ;
138 AliError("No valid detectors found") ;
141 eventsProcessed += qas.GetCurrentEvent() ;
144 qas.Merge(runNumber) ;
148 AliInfo(Form("\n\n********** Summary for run %d **********", runNumber)) ;
149 printf(" detectors present in the run : %s\n", detectors.Data()) ;
150 printf(" detectors present in the run with QA: %s\n", detectorsW.Data()) ;
151 printf(" number of files/events processed : %d/%d\n", filesProcessed, eventsProcessed) ;
152 TFile * qaResult = TFile::Open(AliQA::GetQAResultFileName()) ;
154 AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get(AliQA::GetQAName())) ;
156 for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
157 if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX_t(index))))
158 qa->ShowStatus(AliQA::DETECTORINDEX_t(index)) ;
160 AliError(Form("%s not found in %s !", AliQA::GetQAName(), AliQA::GetQAResultFileName())) ;
163 AliError(Form("%s has not been produced !", AliQA::GetQAResultFileName())) ;