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("*0.root");
51 // find the files associated to this run
52 TGridResult * result = 0x0 ;
53 Bool_t local = kFALSE ;
54 if (grid) { // get the list of files from AliEn directly
56 baseDir.Form("/alice/data/20%s/",year);
57 result = grid->Query(baseDir, pattern) ;
59 TString collectionFile(pattern) ;
60 collectionFile.Append(".xml") ;
61 if ( gSystem->AccessPathName(collectionFile) == 0 ) { // get the list of files from an a-priori created collection file
62 TAlienCollection collection(collectionFile.Data(), maxFiles) ;
63 result = collection.GetGridResult("", 0, 0);
64 } else { // get the list of files from the local current directory
67 sprintf(line, ".! ls %s*.root > tempo.txt", pattern.Data()) ;
68 gROOT->ProcessLine(line) ;
74 in.open("tempo.txt", ifstream::in) ;
76 AliQADataMakerSteer qas ;
77 TString detectors = "";
78 TString detectorsW = "";
80 UShort_t filesProcessed = 0 ;
81 UShort_t eventsProcessed = 0 ;
82 AliCDBManager* man = AliCDBManager::Instance();
83 for ( file = 0 ; file < maxFiles ; file++) {
84 man->SetDefaultStorage(kDefaultOCDBStorage) ;
85 if ( qas.GetCurrentEvent() >= maxEvents)
93 fileName = result->GetKey(file, "turl");
96 if ( fileName.Contains("tag") )
101 sprintf(input, "%s", fileName.Data()) ;
103 sprintf(input, "%s", result->GetKey(file, "turl"));
104 AliInfo(Form("Proccessing file # %d --> %s", file, input)) ;
106 // check which detectors are present
107 AliRawReader * rawReader = new AliRawReaderRoot(input);
108 AliTRDrawStreamBase::SetRawStreamVersion("TB");
109 while ( rawReader->NextEvent() ) {
110 man->SetRun(rawReader->GetRunNumber());
113 while (rawReader->ReadNextData(data)) {
114 Int_t detID = rawReader->GetDetectorID();
115 if (detID < 0 || detID >= AliDAQ::kNDetectors) {
116 AliError("Wrong detector ID! Skipping payload...");
119 detIn[detID] = kTRUE ;
121 for (Int_t detID = 0; detID < AliDAQ::kNDetectors ; detID++) {
123 if ( ! detectors.Contains(detNameOff[detID]) ) {
124 detectors.Append(detNameOff[detID]) ;
125 detectors.Append(" ") ;
129 if ( !detectors.IsNull() )
132 if ( !detectors.IsNull() ) {
133 qas.SetMaxEvents(maxEvents) ;
134 detectorsW = qas.Run(detectors, rawReader) ;
137 AliError("No valid detectors found") ;
140 eventsProcessed += qas.GetCurrentEvent() ;
143 qas.Merge(runNumber) ;
147 AliInfo(Form("\n\n********** Summary for run %d **********", runNumber)) ;
148 printf(" detectors present in the run : %s\n", detectors.Data()) ;
149 printf(" detectors present in the run with QA: %s\n", detectorsW.Data()) ;
150 printf(" number of files/events processed : %d/%d\n", filesProcessed, eventsProcessed) ;
151 TFile * qaResult = TFile::Open(AliQA::GetQAResultFileName()) ;
153 AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get(AliQA::GetQAName())) ;
155 for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
156 if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX_t(index))))
157 qa->ShowStatus(AliQA::DETECTORINDEX_t(index)) ;
159 AliError(Form("%s not found in %s !", AliQA::GetQAName(), AliQA::GetQAResultFileName())) ;
162 AliError(Form("%s has not been produced !", AliQA::GetQAResultFileName())) ;