]> git.uio.no Git - u/mrichter/AliRoot.git/blob - prod/cosmic/rawqa.C
correct a bug in sh and changed the discovery of active detectors in C
[u/mrichter/AliRoot.git] / prod / cosmic / rawqa.C
1 #include <iostream>
2 #include <fstream>
3
4 #include <TFile.h>
5 #include <TGrid.h>
6 #include <TGridResult.h>
7 #include <TMath.h>
8 #include <TROOT.h>
9 #include <TString.h>
10 #include <TSystem.h>
11
12 #include "AliCDBManager.h"
13 #include "AliCDBEntry.h"
14 #include "AliDAQ.h"
15 #include "AliGRPObject.h"
16 #include "AliLog.h"
17 #include "AliQAv1.h"
18 #include "AliQAManager.h"
19 #include "AliRawReader.h"
20 #include "AliRawReaderRoot.h"
21 #include "AliGeomManager.h"
22 #include "AliRecoParam.h"
23
24 TString ClassName() { return "rawqa" ; } 
25
26 //________________________________qa______________________________________
27 void rawqa(Char_t * filename, Int_t run, AliRecoParam::EventSpecie_t es=AliRecoParam::kDefault) 
28 {       
29 //  TGrid * grid = TGrid::Connect("alien://") ; 
30 //  TString filename ; 
31 //  if (grid) {
32 //    filename = Form("alien:///alice/data/2009/LHC09c/000085034/raw/09000085034023.40.root") ;  
33 //  } else {
34 //    filename = "raw.root" ;       
35 //  }
36
37   // Set the CDB storage location
38   AliCDBManager * man = AliCDBManager::Instance();
39 //  man->SetDefaultStorage("local://cdb2");
40   man->SetDefaultStorage("raw://");
41   man->SetRun(run);
42   AliCDBEntry *  entry    = man->Get("GRP/GRP/Data");  
43   if (!entry) 
44     return ;
45   AliGRPObject * fGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject());
46   if (!fGRPData) {
47     printf("ERROR: No GRP entry found in OCDB") ; 
48     return ; 
49   }
50   Int_t activeDetectors = fGRPData->GetDetectorMask();
51   const char * detNameOff[AliDAQ::kNDetectors] = { 
52     "ITS",
53     "ITS",
54     "ITS",
55     "TPC",
56     "TRD",
57     "TOF",
58     "HMPID",
59     "PHOS",
60     "CPV",
61     "PMD",
62     "MUON",
63     "MUON",
64     "FMD",
65     "T0",
66     "VZERO", // Name to be changed to V0 ?
67     "ZDC",
68     "ACORDE",
69     "TRG",
70     "EMCAL",
71     "DAQ_TEST",
72     "HLT"
73   } ; 
74   TString detectors  = ""; 
75   TString detectorsW ; 
76   for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
77     if ((activeDetectors >> iDet) & 0x1) {
78       if (!detectors.Contains(detNameOff[iDet])) {
79         detectors +=detNameOff[iDet] ; 
80         detectors += " " ;  
81       }
82     }
83   }
84   AliQAv1::SetQARefStorage("local://$ALICE_ROOT/QAref") ;
85
86   AliLog::SetGlobalDebugLevel(0) ; 
87         
88   AliQAManager * qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ; 
89   qam->SetEventSpecie(AliRecoParam::kCosmic) ; 
90   AliQAv1::Instance()->SetEventSpecie(es) ; 
91 //  TString detectorsW = ""; 
92   UShort_t eventsProcessed = 0 ; 
93   UShort_t filesProcessed  = 1 ; 
94   AliGeomManager::LoadGeometry();
95   printf("INFO: Proccessing detectors %s from file %s\n", detectors.Data(), filename) ;
96   if ( !detectors.IsNull() ) {
97           qam->SetMaxEvents(-1) ; 
98     qam->SetTasks(Form("%d", AliQAv1::kRAWS));          
99     AliRawReader * rawReader = new AliRawReaderRoot(Form("alien://%s", filename));
100     detectorsW = qam->Run(detectors, rawReader) ;
101     qam->Reset() ;
102   } else {
103     printf("ERROR: No valid detectors found") ; 
104   } 
105   eventsProcessed += qam->GetCurrentEvent() ; 
106         //qam->Merge(run) ; 
107         
108         // The summary 
109   printf("\n\n********** Summary for run %d **********", run) ; 
110   printf("     data file                           : %s\n", filename);
111   printf("     detectors present in the run        : %s\n", detectors.Data()) ; 
112   printf("     detectors present in the run with QA: %s\n", detectorsW.Data()) ; 
113   printf("     number of files/events processed    : %d/%d\n", filesProcessed, eventsProcessed) ; 
114   //const char * qaFileName = AliQAv1::GetQAResultFileName() ;
115   //  TFile * qaResult = TFile::Open(qaFileName) ; 
116   TFile * qaResult = TFile::Open("QA.root") ; 
117   if ( qaResult ) {
118     AliQAv1 * qa = dynamic_cast<AliQAv1 *>(qaResult->Get(AliQAv1::GetQAName())) ; 
119     if ( qa) {
120       for (Int_t index = 0 ; index < AliQAv1::kNDET ; index++)
121         if (detectorsW.Contains(AliQAv1::GetDetName(index))) 
122           qa->Show((AliQAv1::GetDetIndex(AliQAv1::GetDetName(index)))) ;
123     } else {
124       printf("ERROR: %s not found in %s !", AliQAv1::GetQAName(), AliQAv1::GetQAResultFileName()) ; 
125     }
126   } else {
127     printf("ERROR: %s has not been produced !", AliQAv1::GetQAResultFileName()) ; 
128   }
129 }