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"
21 #include "AliGeomManager.h"
23 TString ClassName() { return "rawqa" ; }
25 //________________________________qa______________________________________
26 void rawqa(const Int_t runNumber, Int_t maxFiles = 10, const char* year = "08")
28 // char * kDefaultOCDBStorage = Form("alien://folder=/alice/data/20%s/LHC%sd/OCDB/", year, year) ;
29 char * kDefaultOCDBStorage = Form("local://$ALICE_ROOT/OCDB") ;
30 //AliQA::SetQARefStorage(Form("%s%s/", AliQA::GetQARefDefaultStorage(), year)) ;
31 AliQA::SetQARefStorage("local://$ALICE_ROOT/QAref") ;
33 UInt_t maxEvents = 99999 ;
35 maxEvents = TMath::Abs(maxFiles) ;
38 AliLog::SetGlobalDebugLevel(0) ;
39 // connect to the grid
41 // grid = TGrid::Connect("alien://") ;
43 Bool_t detIn[AliDAQ::kNDetectors] = {kFALSE} ;
44 TString 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"} ;
45 // make the file name pattern year and run number
47 pattern.Form("%9d",runNumber);
48 pattern.ReplaceAll(" ", "0") ;
49 pattern.Prepend(year);
50 pattern.Append("*.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
55 TString collectionFile(pattern) ;
56 collectionFile.ReplaceAll("*.root", ".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);
62 baseDir.Form("/alice/data/20%s/",year);
63 result = grid->Query(baseDir, pattern) ;
66 // get the list of files from the local current directory
69 sprintf(line, ".! ls %s*.root > tempo.txt", pattern.Data()) ;
70 gROOT->ProcessLine(line) ;
76 in.open("tempo.txt", ifstream::in) ;
78 TString detectors = "";
79 TString detectorsW = "";
81 UShort_t filesProcessed = 0 ;
82 UShort_t eventsProcessed = 0 ;
83 AliCDBManager* man = AliCDBManager::Instance();
84 man->SetDefaultStorage(kDefaultOCDBStorage) ;
85 man->SetRun(runNumber) ;
86 AliQAManager qam("rec") ;
87 qam->SetDefaultStorage(AliQA::GetQARefStorage()) ;
88 qam->SetRun(runNumber) ;
90 AliGeomManager::LoadGeometry();
91 for ( file = 0 ; file < maxFiles ; file++) {
92 if ( qas.GetCurrentEvent() >= maxEvents)
100 fileName = result->GetKey(file, "turl");
101 if ( fileName == "" )
103 if ( fileName.Contains("tag") )
108 sprintf(input, "%s", fileName.Data()) ;
110 sprintf(input, "%s", result->GetKey(file, "turl"));
111 AliInfo(Form("Proccessing file # %d --> %s", file, input)) ;
113 // check which detectors are present
114 AliRawReader * rawReader = new AliRawReaderRoot(input);
115 AliTRDrawStreamBase::SetRawStreamVersion("TB");
116 while ( rawReader->NextEvent() ) {
117 man->SetRun(rawReader->GetRunNumber());
118 qam->SetRun(rawReader->GetRunNumber());
121 while (rawReader->ReadNextData(data)) {
122 Int_t detID = rawReader->GetDetectorID();
123 if (detID < 0 || detID >= AliDAQ::kNDetectors) {
124 AliError("Wrong detector ID! Skipping payload...");
127 detIn[detID] = kTRUE ;
129 for (Int_t detID = 0; detID < AliDAQ::kNDetectors ; detID++) {
131 if ( ! detectors.Contains(detNameOff[detID]) ) {
132 detectors.Append(detNameOff[detID]) ;
133 detectors.Append(" ") ;
137 if ( !detectors.IsNull() )
140 if ( !detectors.IsNull() ) {
141 qam.SetMaxEvents(maxEvents) ;
142 detectorsW = qam.Run(detectors, rawReader) ;
145 AliError("No valid detectors found") ;
148 eventsProcessed += qas.GetCurrentEvent() ;
151 qam.Merge(runNumber) ;
155 AliInfo(Form("\n\n********** Summary for run %d **********", runNumber)) ;
156 printf(" detectors present in the run : %s\n", detectors.Data()) ;
157 printf(" detectors present in the run with QA: %s\n", detectorsW.Data()) ;
158 printf(" number of files/events processed : %d/%d\n", filesProcessed, eventsProcessed) ;
159 TFile * qaResult = TFile::Open(AliQA::GetQAResultFileName()) ;
161 AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get(AliQA::GetQAName())) ;
163 for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
164 if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX_t(index))))
165 qa->ShowStatus(AliQA::DETECTORINDEX_t(index)) ;
167 AliError(Form("%s not found in %s !", AliQA::GetQAName(), AliQA::GetQAResultFileName())) ;
170 AliError(Form("%s has not been produced !", AliQA::GetQAResultFileName())) ;