]>
Commit | Line | Data |
---|---|---|
ab0f914c | 1 | Bool_t |
2 | Backup(const TString& fname, Int_t n=10) | |
3 | { | |
4 | TString fn(fname); fn.Append(Form(".%d", n)); | |
5 | if (!gSystem->AccessPathName(fn.Data())) { | |
6 | Error("Backup", "Last possible backup slot (%d) filled for %s", | |
7 | n, fname.Data()); | |
8 | return false; | |
9 | } | |
10 | ||
11 | for (Int_t i=n-1; i >= 0; i--) { | |
12 | TString fi(fname); | |
13 | if (i > 0) fi.Append(Form(".%d", i)); | |
14 | if (gSystem->AccessPathName(fi.Data())) continue; | |
15 | ||
16 | TString fb(fname); fb.Append(Form(".%d", i+1)); | |
17 | ||
18 | if (gSystem->Rename(fi.Data(), fb.Data())) { | |
19 | Error("Backup", "Failed to backup %s to %s", fi.Data(), fb.Data()); | |
20 | return false; | |
21 | } | |
22 | } | |
23 | return true; | |
24 | } | |
25 | ||
26 | ||
27 | Bool_t | |
28 | MoveWhat(UInt_t what) | |
29 | { | |
30 | TString nWhat; | |
31 | switch (what) { | |
32 | case AliForwardCorrectionManager::kSecondaryMap: | |
33 | nWhat = "secondary map"; break; | |
34 | case AliForwardCorrectionManager::kDoubleHit: | |
35 | nWhat = "double hit"; break; | |
36 | case AliForwardCorrectionManager::kVertexBias: | |
37 | nWhat = "vertex bias"; break; | |
38 | case AliForwardCorrectionManager::kMergingEfficiency: | |
39 | nWhat = "merging efficiency";break; | |
40 | case AliForwardCorrectionManager::kELossFits: | |
41 | nWhat = "energy loss fits"; break; | |
42 | } | |
43 | Info("MakeWhat", " Copying %s corrections", nWhat.Data()); | |
44 | ||
45 | AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance(); | |
46 | TString dir = gSystem->ExpandPathName(mgr.GetFileDir(what)); | |
47 | ||
48 | // Make the directory if it doesn't exist | |
49 | if (gSystem->AccessPathName(dir.Data())) { | |
50 | Info("MakeWhat", " Making directory %s ... ", dir.Data()); | |
51 | if (gSystem->mkdir(dir.Data(), true)) { | |
52 | Error("MakeWhat", "couldn't make directory %s", dir.Data()); | |
53 | return false; | |
54 | } | |
55 | } | |
56 | ||
57 | TString pattern = mgr.GetFileName(what, 1, 900, 5, false); | |
58 | pattern.ReplaceAll("0900GeV", "[0-9]+GeV"); | |
59 | pattern.ReplaceAll("pp", "[a-zA-Z]+"); | |
60 | pattern.ReplaceAll("p5kG", "[pm][0-9]+kG"); | |
61 | pattern.ReplaceAll("real", "[a-zA-Z]+"); | |
62 | ||
63 | TPRegexp regex(pattern); | |
64 | ||
65 | TSystemDirectory sysdir(".", "."); | |
66 | TIter next(sysdir.GetListOfFiles()); | |
67 | TSystemFile* file = 0; | |
68 | while ((file = static_cast<TSystemFile*>(next()))) { | |
69 | if (file->IsDirectory()) continue; | |
70 | TString fname(file->GetName()); | |
71 | ||
72 | if (!regex.Match(fname)) continue; | |
73 | ||
74 | // Info("MakeWhat", " match: %s", fname.Data()); | |
75 | TString to(gSystem->ConcatFileName(dir.Data(), fname.Data())); | |
76 | ||
77 | if (!Backup(to)) return false; | |
78 | ||
79 | Info("MakeWhat", " copying %s\n to %s", | |
80 | fname.Data(), to.Data()); | |
81 | if (gSystem->CopyFile(fname.Data(), to.Data(), false)) { | |
82 | Error("MakeWhat", "Failed to copy %s to %s", fname.Data(), to.Data()); | |
83 | return false; | |
84 | } | |
85 | } | |
86 | return true; | |
87 | } | |
88 | ||
89 | void | |
90 | MoveCorrections(bool sec=true, | |
91 | bool dbl=true, | |
92 | bool vtx=true, | |
93 | bool merge=true, | |
94 | bool eloss=true) | |
95 | { | |
96 | Info("MoveCorrections", "Loadingl libraries ..."); | |
97 | gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C"); | |
98 | ||
99 | Info("MoveCorrections", "Moving selected corrections ..."); | |
100 | if (sec) MoveWhat(AliForwardCorrectionManager::kSecondaryMap); | |
101 | if (dbl) MoveWhat(AliForwardCorrectionManager::kDoubleHit); | |
102 | if (vtx) MoveWhat(AliForwardCorrectionManager::kVertexBias); | |
103 | if (merge) MoveWhat(AliForwardCorrectionManager::kMergingEfficiency); | |
104 | if (eloss) MoveWhat(AliForwardCorrectionManager::kELossFits); | |
105 | ||
106 | } | |
107 |