]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/CDBToGrid.C
Fix
[u/mrichter/AliRoot.git] / STEER / CDBToGrid.C
1 // This macro transfers OCDB data of one single ("detName") or all ALICE detectors from one location to another, 
2 // It is possible to set new run range, path etc... 
3 // draining "align" objects is in general to be avoided, since those present in the repository might not be updated
4 // some paths might be missing hereafter: this can be checked in advance by means of "listCdbEntries.sh" run on the
5 // starting OCDB folder
6 #if !defined(__CINT__) || defined(__MAKECINT__)
7 #include "AliCDBManager.h"
8 #include "AliCDBStorage.h"
9 #include "AliCDBEntry.h"
10 #include "AliCDBId.h"
11 #include <TString.h>
12 #include <TList.h>
13 #endif
14
15 void CDBToGrid(const char *detName="", const char* fromUri="local://$ALICE_ROOT/OCDB", 
16         const char* toUri="local://newOCDB")
17 {
18
19         AliCDBManager *man = AliCDBManager::Instance();
20         man->SetDefaultStorage(fromUri);
21         AliCDBStorage *dest = man->GetStorage(toUri);
22         man->SetRun(0);
23
24         TList* calib=0;
25         TList* align=0;
26         TList* config=0;
27
28         if(detName == "")
29         {
30                 // drain by cdb-path
31                 calib = man->GetAll("*/Calib/*");
32                 //align = man->GetAll("*/Align/Data");
33                 config = man->GetAll("*/Config/*");
34
35                 // drain everything, really!
36                 //calib = man->GetAll("*");
37
38         } else {
39                 // drain calibration and alignment for detector "detName"
40
41                 TString calibPath = detName;
42                 TString alignPath = calibPath;
43                 calibPath+="/Calib/*";  
44                 alignPath+="/Align/Data";
45
46                 //calib = man->GetAll(calibPath);
47                 //align = man->GetAll(alignPath);
48
49                 // drain everything, really!
50                 calib = man->GetAll(Form("%s/*",detName));
51         }
52
53         AliCDBEntry *entry;
54
55         Int_t ok=0; TString failed="";
56         if(calib){
57                 ok=0; failed="";
58                 for(int i=0;i<calib->GetEntries();i++){
59
60                         entry = (AliCDBEntry*) calib->At(i);
61                         entry->GetId().SetRunRange(0,AliCDBRunRange::Infinity());
62
63                         TString path=entry->GetId().GetPath();
64
65                         printf("%s\n",path.Data());
66
67                         if (path == "ITS/Resp/RespSDD") entry->GetId().SetPath("ITS/Calib/RespSDD"); // bug in ITS/Resp/RespSDD
68
69                         if(path == "TOF/Calib/Par" || path == "TOF/Calib/SimPar" || path.Contains("TOF/CDB")) continue;
70
71                         if (dest->Put(entry)) {
72                                 ok++;
73                         } else {
74                                 failed += path.Data(); failed += " "; 
75                         }
76                 }
77                 printf("\n************ CALIB *********** \n");
78                 printf("************ Stored %d objects over %d *********** \n", ok, calib->GetEntries());
79                 if(failed != ""){
80                         printf("***** List of failed objects: %s \n", failed.Data());
81                 }
82         }
83
84
85         if(align){
86                 ok=0; failed="";
87                 for(int i=0;i<align->GetEntries();i++){
88
89                         entry = (AliCDBEntry*) align->At(i);
90                         entry->GetId().SetRunRange(0,AliCDBRunRange::Infinity());
91                         TString path=entry->GetId().GetPath();
92
93                         if (dest->Put(entry)) {
94                                 ok++;
95                         } else {
96                                 failed += path.Data(); failed += " "; 
97                         }
98                 }
99                 printf("\n************ ALIGN *********** \n");
100                 printf("************ Stored %d objects over %d *********** \n", ok, align->GetEntries());
101                 if(failed != ""){
102                         printf("***** List of failed objects: %s \n", failed.Data());
103                 }
104         }
105
106         if(config){
107                 ok=0; failed = "";
108                 for(int i=0;i<config->GetEntries();i++){
109
110                         entry = (AliCDBEntry*) config->At(i);
111                         entry->GetId().SetRunRange(0,AliCDBRunRange::Infinity());
112                         TString path=entry->GetId().GetPath();
113
114                         if (dest->Put(entry)) {
115                                 ok++;
116                         } else {
117                                 failed += path.Data(); failed += " "; 
118                         }
119                 }
120                 printf("\n************ CONFIG *********** \n");
121                 printf("************ Stored %d objects over %d *********** \n", ok, config->GetEntries());
122                 if(failed != ""){
123                         printf("***** List of failed objects: %s \n", failed.Data());
124                 }
125         }
126
127         man->Destroy();
128
129 }