4 #include <TAlienCollection.h>
7 #include <TGridResult.h>
13 #include "AliCDBManager.h"
16 #include "AliQADataMakerSteer.h"
17 #include "AliRawReader.h"
18 #include "AliRawReaderRoot.h"
21 TString ClassName() { return "rawqa" ; }
23 //________________________________qa______________________________________
24 void rawqa(const Int_t runNumber, Int_t maxFiles = 10, const char* year = "08")
26 const char * kDefaultOCDBStorage = Form("alien://folder=/alice/data/20%s/LHC%sa/OCDB/", year, year) ;
28 UInt_t maxEvents = 99999 ;
30 maxEvents = TMath::Abs(maxFiles) ;
33 AliLog::SetGlobalDebugLevel(0) ;
34 // connect to the grid
36 grid = TGrid::Connect("alien://") ;
38 Bool_t detIn[AliDAQ::kNDetectors] = {kFALSE} ;
39 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"} ;
40 // make the file name pattern year and run number
42 pattern.Form("%9d",runNumber);
43 pattern.ReplaceAll(" ", "0") ;
44 pattern.Prepend(year);
45 pattern.Append("*0.root");
47 // find the files associated to this run
48 TGridResult * result = 0x0 ;
49 Bool_t local = kFALSE ;
50 if (grid) { // get the list of files from AliEn directly
52 baseDir.Form("/alice/data/20%s/",year);
53 result = grid->Query(baseDir, pattern) ;
55 TString collectionFile(pattern) ;
56 collectionFile.Append(".xml") ;
57 if ( gSystem->AccessPathName(collectionFile) == 0 ) { // get the list of files from an a-priori created collection file
58 TAlienCollection collection(collectionFile.Data(), maxFiles) ;
59 result = collection.GetGridResult("", 0, 0);
60 } else { // get the list of files from the local current directory
63 sprintf(line, ".! ls %s*.root > tempo.txt", pattern.Data()) ;
64 gROOT->ProcessLine(line) ;
70 in.open("tempo.txt", ifstream::in) ;
72 AliCDBManager* man = AliCDBManager::Instance();
73 man->SetDefaultStorage(kDefaultOCDBStorage) ;
74 AliQA::SetQARefStorage("alien://folder=/alice/QA/2008/") ;
75 man->SetSpecificStorage("*", AliQA::GetQARefStorage());
76 AliQADataMakerSteer qas ;
77 TString detectors = "";
78 TString detectorsW = "";
80 UShort_t filesProcessed = 0 ;
81 UShort_t eventsProcessed = 0 ;
82 for ( file = 0 ; file < maxFiles ; file++) {
83 if ( qas.GetCurrentEvent() >= maxEvents)
91 fileName = result->GetKey(file, "turl");
94 if ( fileName.Contains("tag") )
99 sprintf(input, "%s", fileName.Data()) ;
101 sprintf(input, "%s", result->GetKey(file, "turl"));
102 AliInfo(Form("Proccessing file # %d --> %s", file, input)) ;
104 // check which detectors are present
105 AliRawReader * rawReader = new AliRawReaderRoot(input);
106 while ( rawReader->NextEvent() ) {
107 man->SetRun(rawReader->GetRunNumber());
110 while (rawReader->ReadNextData(data)) {
111 Int_t detID = rawReader->GetDetectorID();
112 if (detID < 0 || detID >= AliDAQ::kNDetectors) {
113 AliError("Wrong detector ID! Skipping payload...");
116 detIn[detID] = kTRUE ;
118 for (Int_t detID = 0; detID < AliDAQ::kNDetectors ; detID++) {
120 if ( ! detectors.Contains(detNameOff[detID]) ) {
121 detectors.Append(detNameOff[detID]) ;
122 detectors.Append(" ") ;
126 if ( !detectors.IsNull() )
129 // TEMPORARY REMOVAL OF TRD!!!
130 detectors.ReplaceAll("TRD", "") ;
131 // TEMPORARY REMOVAL OF TRD!!!
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("QA")) ;
154 for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
155 if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX(index))))
156 qa->ShowStatus(AliQA::DETECTORINDEX(index)) ;
158 AliError(Form("%s has not been produced !", AliQA::GetQAResultFileName())) ;