2 Backup(const TString& fname, Int_t n=10)
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",
11 for (Int_t i=n-1; i >= 0; i--) {
13 if (i > 0) fi.Append(Form(".%d", i));
14 if (gSystem->AccessPathName(fi.Data())) continue;
16 TString fb(fname); fb.Append(Form(".%d", i+1));
18 if (gSystem->Rename(fi.Data(), fb.Data())) {
19 Error("Backup", "Failed to backup %s to %s", fi.Data(), fb.Data());
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;
43 Info("MakeWhat", " Copying %s corrections", nWhat.Data());
45 AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
46 TString dir = gSystem->ExpandPathName(mgr.GetFileDir(what));
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());
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]+");
63 TPRegexp regex(pattern);
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());
72 if (!regex.Match(fname)) continue;
74 // Info("MakeWhat", " match: %s", fname.Data());
75 TString to(gSystem->ConcatFileName(dir.Data(), fname.Data()));
77 if (!Backup(to)) return false;
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());
90 MoveCorrections(bool sec=true,
96 Info("MoveCorrections", "Loadingl libraries ...");
97 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
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);