]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/scripts/CheckCalibData.C
Debug msg
[u/mrichter/AliRoot.git] / FMD / scripts / CheckCalibData.C
CommitLineData
045a97a7 1#ifndef __CINT__
2#include <TSystemDirectory.h>
3#include <TFile.h>
4#include <TList.h>
5#include <AliCDBEntry.h>
6#include <AliFMDMap.h>
7#include <AliFMDCalibPedestal.h>
8#include <AliFMDCalibGain.h>
9#include <AliFMDCalibStripRange.h>
10#include <AliFMDCalibSampleRate.h>
11#include <TString.h>
12#include <TSystem.h>
13#include <TError.h>
14#else
15class AliFMDMap;
16#endif
17
18Bool_t
19CheckMap(const char* path, const AliFMDMap* map)
20{
21 if (!map) {
22 Warning("CheckFile", "No map in %s", path);
23 return false;
24 }
25 if (!map->Ptr() || map->MaxIndex() <= 0) {
26 Warning("CheckFile", "Map %p (%d) has no data in %s",
27 map->Ptr(), map->MaxIndex(), path);
28 return false;
29 }
30 return true;
31}
32
33enum {
34 kMap,
35 kPedestal,
36 kGain,
37 kRate,
38 kRange
39};
40
41Bool_t
42CheckFile(const char* name, const char* dirName, Int_t which)
43{
44 TString path(gSystem->ConcatFileName(dirName, name));
45 TFile* file = TFile::Open(path, "READ");
46 if (!file) {
47 Warning("CheckFile", "Failed to open %s", path.Data());
48 return false;
49 }
50 AliCDBEntry* entry = static_cast<AliCDBEntry*>(file->Get("AliCDBEntry"));
51 if (!entry) {
52 Warning("CheckFile", "No entry in %s", path.Data());
53 file->Close();
54 return false;
55 }
56 TObject* object = entry->GetObject();
57 if (!object) {
58 Warning("CheckFile", "Entry has no object in %s", path.Data());
59 file->Close();
60 return false;
61 }
62
63 const AliFMDMap* map = 0;
64 if (which == kMap) map = static_cast<AliFMDMap*>(object);
65 else if (which == kPedestal)
66 map = &(static_cast<AliFMDCalibPedestal*>(object)->Values());
67 else if (which == kGain)
68 map = &(static_cast<AliFMDCalibGain*>(object)->Values());
69 else if (which == kRate)
70 map = &(static_cast<AliFMDCalibSampleRate*>(object)->Rates());
71 else if (which == kRange)
72 map = &(static_cast<AliFMDCalibStripRange*>(object)->Ranges());
73 else {
74 Warning("CheckFile", "Don't now how to deal with what=%d", which);
75 file->Close();
76 return false;
77 }
78 if (!CheckMap(path.Data(), map)) {
79 file->Close();
80 return false;
81 }
82 Info("CheckFile", "Map OK in %s", path.Data());
83 file->Close();
84 return true;
85}
86
87
88void
89CheckCalibData(const char* dirName)
90{
91 TString dirS(dirName);
92 if (dirS.EndsWith("/")) dirS.Remove(dirS.Length()-1);
93 dirS = gSystem->BaseName(dirS.Data());
94 Int_t what = 0;
95 if (dirS == "Dead" || dirS == "ZeroSuppression") what = kMap;
96 else if (dirS == "Pedestal") what = kPedestal;
97 else if (dirS == "PulseGain") what = kGain;
98 else if (dirS == "SampleRate") what = kRate;
99 else if (dirS == "StripRange") what = kRange;
100 else {
101 Error("CheckCalibData", "Don't know how to deal with %s in %s",
102 dirS.Data(), dirName);
103 return;
104 }
105
106 TSystemDirectory dir(dirName, dirName);
107 TList* files(dir.GetListOfFiles());
108 TIter next(files);
109 TObject* obj = 0;
110
111 Int_t nTotal = 0;
112 Int_t nOk = 0;
113 while ((obj = next())) {
114 TString name(obj->GetName());
115 if (!name.EndsWith(".root")) continue;
116 nTotal++;
117 if (CheckFile(name, dirName, what)) nOk++;
118 }
119 Info("CheckCalibData", "Total: %d, OK: %d, Bad: %d in %s ",
120 nTotal, nOk, nTotal - nOk, dirName);
121}