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