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
55 baseDir.Form("/alice/data/20%s/",year);
56 result = grid->Query(baseDir, pattern) ;
58 TString collectionFile(pattern) ;
59 collectionFile.Append(".xml") ;
60 if ( gSystem->AccessPathName(collectionFile) == 0 ) { // get the list of files from an a-priori created collection file
61 TAlienCollection collection(collectionFile.Data(), maxFiles) ;
62 result = collection.GetGridResult("", 0, 0);
63 } else { // get the list of files from the local current directory
66 sprintf(line, ".! ls %s*.root > tempo.txt", pattern.Data()) ;
67 gROOT->ProcessLine(line) ;
73 in.open("tempo.txt", ifstream::in) ;
75 AliQADataMakerSteer qas ;
76 TString detectors = "";
77 TString detectorsW = "";
79 UShort_t filesProcessed = 0 ;
80 UShort_t eventsProcessed = 0 ;
81 AliCDBManager* man = AliCDBManager::Instance();
82 for ( file = 0 ; file < maxFiles ; file++) {
83 man->SetDefaultStorage(kDefaultOCDBStorage) ;
84 if ( qas.GetCurrentEvent() >= maxEvents)
92 fileName = result->GetKey(file, "turl");
95 if ( fileName.Contains("tag") )
100 sprintf(input, "%s", fileName.Data()) ;
102 sprintf(input, "%s", result->GetKey(file, "turl"));
103 AliInfo(Form("Proccessing file # %d --> %s", file, input)) ;
105 // check which detectors are present
106 AliRawReader * rawReader = new AliRawReaderRoot(input);
107 AliTRDrawStreamBase::SetRawStreamVersion("TB");
108 while ( rawReader->NextEvent() ) {
109 man->SetRun(rawReader->GetRunNumber());
112 while (rawReader->ReadNextData(data)) {
113 Int_t detID = rawReader->GetDetectorID();
114 if (detID < 0 || detID >= AliDAQ::kNDetectors) {
115 AliError("Wrong detector ID! Skipping payload...");
118 detIn[detID] = kTRUE ;
120 for (Int_t detID = 0; detID < AliDAQ::kNDetectors ; detID++) {
122 if ( ! detectors.Contains(detNameOff[detID]) ) {
123 detectors.Append(detNameOff[detID]) ;
124 detectors.Append(" ") ;
128 if ( !detectors.IsNull() )
131 if ( !detectors.IsNull() ) {
132 qas.SetMaxEvents(maxEvents) ;
133 detectorsW = qas.Run(detectors, rawReader) ;
136 AliError("No valid detectors found") ;
139 eventsProcessed += qas.GetCurrentEvent() ;
142 qas.Merge(runNumber) ;
146 AliInfo(Form("\n\n********** Summary for run %d **********", runNumber)) ;
147 printf(" detectors present in the run : %s\n", detectors.Data()) ;
148 printf(" detectors present in the run with QA: %s\n", detectorsW.Data()) ;
149 printf(" number of files/events processed : %d/%d\n", filesProcessed, eventsProcessed) ;
150 TFile * qaResult = TFile::Open(AliQA::GetQAResultFileName()) ;
152 AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get(AliQA::GetQAName())) ;
154 for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
155 if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX_t(index))))
156 qa->ShowStatus(AliQA::DETECTORINDEX_t(index)) ;
158 AliError(Form("%s not found in %s !", AliQA::GetQAName(), AliQA::GetQAResultFileName())) ;
161 AliError(Form("%s has not been produced !", AliQA::GetQAResultFileName())) ;