]>
Commit | Line | Data |
---|---|---|
2040edda | 1 | Bool_t |
2 | GetInfoFromFileName(const char* path, | |
3 | Int_t& firstRun, Int_t& lastRun, | |
4 | Int_t& version, Int_t& subVersion) | |
5 | { | |
6 | TString fn(gSystem->BaseName(path)); | |
7 | int ret = sscanf(fn.Data(), "Run%d_%d_v%d_s%d.root", | |
8 | &firstRun, &lastRun, &version, &subVersion); | |
9 | return ret == 4; | |
10 | } | |
11 | ||
12 | void | |
13 | FixOne(const char* path, const char* id, const char* fn) | |
14 | { | |
15 | TFile* file = TFile::Open(Form("%s/%s/%s", path, id, fn)); | |
16 | if (!file) { | |
17 | Warning("FixOne", "%s/%s/%s not found", path, id, fn); | |
18 | return; | |
19 | } | |
20 | ||
21 | AliCDBEntry* entry = static_cast<AliCDBEntry*>(file->Get("AliCDBEntry")); | |
22 | if (!entry) { | |
23 | Warning("FixOne", "Did not find an entry in the file"); | |
24 | return; | |
25 | } | |
26 | ||
27 | Int_t firstRun, lastRun, version, subVersion; | |
28 | if (!GetInfoFromFileName(fn, firstRun, lastRun, version, subVersion)) { | |
29 | Warning("FixOne", "Could not get info from file name"); | |
30 | return; | |
31 | } | |
32 | ||
33 | if (firstRun == entry->GetId().GetFirstRun() && | |
34 | lastRun == entry->GetId().GetLastRun() && | |
35 | version == entry->GetId().GetVersion() && | |
36 | subVersion == entry->GetId().GetSubVersion()) { | |
37 | Info("FixOne", "Entry run range and version %d->%d %d.%d match " | |
38 | "filename run range and version %d->%d %d.%d, not creating %s in %s", | |
39 | entry->GetId().GetFirstRun(), entry->GetId().GetLastRun(), | |
40 | entry->GetId().GetVersion(), entry->GetId().GetSubVersion(), | |
41 | firstRun, lastRun, version, subVersion, fn, | |
42 | gSystem->WorkingDirectory()); | |
43 | return; | |
44 | } | |
45 | ||
46 | AliCDBId cid(id, firstRun, lastRun, version, subVersion); | |
47 | entry->SetId(cid); | |
48 | ||
49 | Info("FixOne", "Creating %s", fn); | |
50 | TFile* out = TFile::Open(fn, "RECREATE"); | |
51 | out->cd(); | |
52 | entry->Write(); | |
53 | out->ls(); | |
54 | out->Close(); | |
55 | file->Close(); | |
56 | } | |
57 | ||
58 | FixCategory(const char* path, const char* id) | |
59 | { | |
60 | TSystemDirectory dir(Form("%s/%s", path, id), Form("%s/%s", path, id)); | |
61 | TList* fl = dir.GetListOfFiles(); | |
62 | TIter next(fl); | |
63 | TSystemFile* file = 0; | |
64 | while ((file = static_cast<TSystemFile*>(next()))) { | |
65 | if (file->IsDirectory()) { | |
66 | Info("FixCategory", " skipping %s", file->GetName()); | |
67 | continue; | |
68 | } | |
69 | ||
70 | TString fn(gSystem->BaseName(file->GetName())); | |
71 | if (!fn.EndsWith(".root")) { | |
72 | Info("FixCategory", " Skipping %s", fn.Data()); | |
73 | continue; | |
74 | } | |
75 | ||
76 | Info("FixCategory", " Now processing %s/%s @ %s", id, fn.Data(), path); | |
77 | FixOne(path, id, fn.Data()); | |
78 | } | |
79 | } | |
80 | ||
81 | FixOCDBEntries() | |
82 | { | |
83 | const char* path = gSystem->ExpandPathName("$ALICE_ROOT/OCDB"); | |
84 | ||
85 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
86 | cdb->SetDefaultStorage(Form("local://%s", path)); | |
87 | cdb->SetRun(0); | |
88 | ||
89 | AliFMDParameters* fmdp = AliFMDParameters::Instance(); | |
90 | fmdp->Init(kTRUE); | |
91 | ||
92 | const char* ids[] = { AliFMDParameters::PulseGainPath(), | |
93 | AliFMDParameters::PedestalPath(), | |
94 | AliFMDParameters::DeadPath(), | |
95 | AliFMDParameters::ZeroSuppressionPath(), | |
96 | AliFMDParameters::SampleRatePath(), | |
97 | AliFMDParameters::StripRangePath(), | |
98 | AliFMDParameters::AltroMapPath(), | |
99 | 0 }; | |
100 | const char** ptr = ids; | |
101 | while (*ptr) { | |
102 | Info("FixOCDBEntries", "Now processing %s", *ptr); | |
103 | FixCategory(path, *ptr); | |
104 | ptr++; | |
105 | } | |
106 | } | |
107 | ||
108 | ||
109 |