Extacting the OCDB in a separate module. The detectors have write permission in the...
[u/mrichter/AliRoot.git] / test / cosmic / rawqa.C
CommitLineData
de3b7b4d 1//#include <iostream>
2//#include <fstream>
3//
4//#include <TAlienCollection.h>
5//#include <TFile.h>
6//#include <TGrid.h>
7//#include <TGridResult.h>
8//#include <TMath.h>
9//#include <TROOT.h>
10//#include <TString.h>
11//#include <TSystem.h>
12//
13//#include "AliCDBManager.h"
14//#include "AliDAQ.h"
15//#include "AliLog.h"
16//#include "AliQA.h"
17//#include "AliQADataMakerSteer.h"
18//#include "AliRawReader.h"
19//#include "AliRawReaderRoot.h"
20//#include "AliTRDrawStreamBase.h"
21//#include "AliGeomManager.h"
40d0f38f 22
23TString ClassName() { return "rawqa" ; }
24
25//________________________________qa______________________________________
de3b7b4d 26void rawqa(const char * filename)
40d0f38f 27{
aaab6050 28 // retrieve evironment variables
29 const char * year = gSystem->Getenv("YEAR") ;
30 const TString baseDir(gSystem->Getenv("BASEDIR")) ;
31 const Int_t runNumber = atoi(gSystem->Getenv("RUNNUM")) ;
35bb17ae 32
aaab6050 33 // build the default storage of OCDB
34 TString sfilename(filename) ;
35 sfilename = sfilename.Strip() ;
36 sfilename = sfilename.Strip(TString::kLeading) ;
37 sfilename.Prepend("alien://") ;
35bb17ae 38
aaab6050 39 baseDir.Append("/") ;
40 TString temp(filename) ;
41 temp = temp.ReplaceAll(baseDir, "") ;
42 temp = temp.Strip(TString::kLeading, '/') ;
43 baseDir.Append(temp(0, temp.Index("/"))) ;
44 char * kDefaultOCDBStorage = Form("alien://folder=%s/OCDB/", baseDir.Data()) ;
35bb17ae 45
aaab6050 46 // set the location of reference data
47 //AliQA::SetQARefStorage(Form("%s%s/", AliQA::GetQARefDefaultStorage(), year)) ;
162637e4 48 AliQA::SetQARefStorage("local://$ALICE_ROOT/OCDB") ;
35bb17ae 49
aaab6050 50 AliLog::SetGlobalDebugLevel(0) ;
35bb17ae 51
aaab6050 52 // connect to the grid
53 TGrid * grid = 0x0 ;
54 grid = TGrid::Connect("alien://") ;
35bb17ae 55
aaab6050 56 Bool_t detIn[AliDAQ::kNDetectors] = {kFALSE} ;
57 char * detNameOff[AliDAQ::kNDetectors] = {"ITS", "ITS", "ITS", "TPC", "TRD", "TOF", "HMPID", "PHOS", "PHOS",
58 "PMD", "MUON", "MUON", "FMD", "T0", "VZERO", "ZDC", "ACORDE", "TRG",
59 "EMCAL", "DAQ_TEST", "HLT"} ;
35bb17ae 60
aaab6050 61 AliQADataMakerSteer qas("rec") ;
62 TString detectors = "";
63 TString detectorsW = "";
64 UShort_t eventsProcessed = 0 ;
65 UShort_t filesProcessed = 1 ;
66 AliCDBManager* man = AliCDBManager::Instance();
67 man->SetDefaultStorage(kDefaultOCDBStorage) ;
68 man->SetRun(runNumber) ;
69 AliGeomManager::LoadGeometry();
70 printf("INFO: Proccessing file %s\n", filename) ;
71 // check which detectors are present
72 AliRawReader * rawReader = new AliRawReaderRoot(sfilename);
73 AliTRDrawStreamBase::SetRawStreamVersion("TB");
74 while ( rawReader->NextEvent() ) {
75 man->SetRun(rawReader->GetRunNumber());
76 AliLog::Flush();
77 UChar_t * data ;
78 while (rawReader->ReadNextData(data)) {
79 Int_t detID = rawReader->GetDetectorID();
80 if (detID < 0 || detID >= AliDAQ::kNDetectors) {
81 printf("INFO: Wrong detector ID! Skipping payload...\n");
82 continue;
83 }
84 detIn[detID] = kTRUE ;
85 }
86 for (Int_t detID = 0; detID < AliDAQ::kNDetectors ; detID++) {
87 if (detIn[detID]) {
88 if ( ! detectors.Contains(detNameOff[detID]) ) {
89 detectors.Append(detNameOff[detID]) ;
90 detectors.Append(" ") ;
91 }
92 }
93 }
94 if ( !detectors.IsNull() )
95 break ;
96 }
97 if ( !detectors.IsNull() ) {
12e6d563 98 //qas->SetMaxEvents(1) ;
aaab6050 99 qas.SetTasks(Form("%d", AliQA::kRAWS));
100 detectorsW = qas.Run(detectors, rawReader) ;
101 qas.Reset() ;
102 } else {
35bb17ae 103 printf("ERROR: No valid detectors found") ;
aaab6050 104 }
105 delete rawReader ;
106 eventsProcessed += qas.GetCurrentEvent() ;
35bb17ae 107 //qas.Merge(runNumber) ;
108
109 // The summary
aaab6050 110 printf("\n\n********** Summary for run %d **********", runNumber) ;
111 printf(" data file : %s\n", filename);
112 printf(" detectors present in the run : %s\n", detectors.Data()) ;
113 printf(" detectors present in the run with QA: %s\n", detectorsW.Data()) ;
114 printf(" number of files/events processed : %d/%d\n", filesProcessed, eventsProcessed) ;
115 TFile * qaResult = TFile::Open(AliQA::GetQAResultFileName()) ;
116 if ( qaResult ) {
117 AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get(AliQA::GetQAName())) ;
118 if ( qa) {
119 for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
120 if (detectorsW.Contains(AliQA::GetDetName(index)))
121 qa->Show((AliQA::GetDetIndex(AliQA::GetDetName(index)))) ;
122 } else {
123 printf("ERROR: %s not found in %s !", AliQA::GetQAName(), AliQA::GetQAResultFileName()) ;
124 }
125 } else {
126 printf("ERROR: %s has not been produced !", AliQA::GetQAResultFileName()) ;
127 }
40d0f38f 128}