making macro compilable and doing some clean-up
authorrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 May 2008 14:28:51 +0000 (14:28 +0000)
committerrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 May 2008 14:28:51 +0000 (14:28 +0000)
STEER/CDBToGrid.C

index 9ddc1bf..1c7e546 100644 (file)
-
 // This macro transfers OCDB data of one single ("detName") or all ALICE detectors from one location to another, 
 // It is possible to set new run range, path etc... 
+// draining "align" objects is in general to be avoided, since those present in the repository might not be updated
+// some paths might be missing hereafter: this can be checked in advance by means of "listCdbEntries.sh" run on the
+// starting OCDB folder
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
+#include "AliCDBId.h"
+#include <TString.h>
+#include <TList.h>
+#endif
 
 void CDBToGrid(const char *detName="", const char* fromUri="local://$ALICE_ROOT", 
        const char* toUri="local://newOCDB")
 {
 
-AliCDBManager *man = AliCDBManager::Instance();
-
-man->SetDefaultStorage(fromUri);
-
-AliCDBStorage *dest = man->GetStorage(toUri);
-
-man->SetRun(0);
+       AliCDBManager *man = AliCDBManager::Instance();
+       man->SetDefaultStorage(fromUri);
+       AliCDBStorage *dest = man->GetStorage(toUri);
+       man->SetRun(0);
 
-TList* calib=0;
-TList* align=0;
-TList* recpar=0;
-TList* config=0;
+       TList* calib=0;
+       TList* align=0;
+       TList* config=0;
 
-if(detName == ""){
-// drain everything
-       //calib = man->GetAll("*/Calib/*");
-       //align = man->GetAll("*/Align/Data");
-       //recpar = man->GetAll("*/RecParam/*");
-       //config = man->GetAll("*/Config/*");
-       
-// drain everything, really!
-       calib = man->GetAll("*");
+       if(detName == "")
+       {
+               // drain by cdb-path
+               calib = man->GetAll("*/Calib/*");
+               //align = man->GetAll("*/Align/Data");
+               config = man->GetAll("*/Config/*");
 
-} else {
-// drain calibration and alignment for detector "detName"
+               // drain everything, really!
+               //calib = man->GetAll("*");
 
-       TString calibPath = detName;
-       TString alignPath = calibPath;
-       calibPath+="/Calib/*";  
-       alignPath+="/Align/Data";
+       } else {
+               // drain calibration and alignment for detector "detName"
 
-       //calib = man->GetAll(calibPath);
-       //align = man->GetAll(alignPath);
+               TString calibPath = detName;
+               TString alignPath = calibPath;
+               calibPath+="/Calib/*";  
+               alignPath+="/Align/Data";
 
-// drain everything, really!
-       calib = man->GetAll(Form("%s/*",detName.Data()));
-}
+               //calib = man->GetAll(calibPath);
+               //align = man->GetAll(alignPath);
 
-AliCDBEntry *entry;
-
-Int_t ok=0; TString failed="";
-if(calib){
-       ok=0; failed="";
-       for(int i=0;i<calib->GetEntries();i++){
-       entry = (AliCDBEntry*) calib->At(i);
-       entry->GetId().SetRunRange(0,999999999);
-       
-       TString path=entry->GetId().GetPath();
-       
-       cout << path.Data() << endl;
-      
-       if (path == "ITS/Resp/RespSDD") entry->GetId().SetPath("ITS/Calib/RespSDD"); // bug in ITS/Resp/RespSDD
-       
-       if(path == "TOF/Calib/Par" || path == "TOF/Calib/SimPar" || path.Contains("TOF/CDB")) continue;
-       if (dest->Put(entry)) {
-               ok++;
-       } else {
-               failed += path.Data(); failed += " "; 
-       }
-       }
-       printf("\n************ CALIB *********** \n");
-       printf("************ Stored %d objects over %d *********** \n", ok, calib->GetEntries());
-       if(failed != ""){
-               printf("***** List of failed objects: %s \n", failed.Data());
+               // drain everything, really!
+               calib = man->GetAll(Form("%s/*",detName));
        }
-}
 
+       AliCDBEntry *entry;
 
-if(align){
-ok=0; failed="";
-for(int i=0;i<align->GetEntries();i++){
+       Int_t ok=0; TString failed="";
+       if(calib){
+               ok=0; failed="";
+               for(int i=0;i<calib->GetEntries();i++){
 
-      entry = (AliCDBEntry*) align->At(i);
-      entry->GetId().SetRunRange(0,999999999);
-      TString path=entry->GetId().GetPath();
+                       entry = (AliCDBEntry*) calib->At(i);
+                       entry->GetId().SetRunRange(0,AliCDBRunRange::Infinity());
 
-       if (dest->Put(entry)) {
-               ok++;
-       } else {
-               failed += path.Data(); failed += " "; 
-       }
-       }
-       printf("\n************ ALIGN *********** \n");
-       printf("************ Stored %d objects over %d *********** \n", ok, align->GetEntries());
-       if(failed != ""){
-               printf("***** List of failed objects: %s \n", failed.Data());
-       }
-}
+                       TString path=entry->GetId().GetPath();
 
-if(recpar){
-       ok=0; failed="";
-       for(int i=0;i<recpar->GetEntries();i++){
+                       printf("%s\n",path.Data());
 
-       entry = (AliCDBEntry*) recpar->At(i);
-       entry->GetId().SetRunRange(0,999999999);
-       TString path=entry->GetId().GetPath();
+                       if (path == "ITS/Resp/RespSDD") entry->GetId().SetPath("ITS/Calib/RespSDD"); // bug in ITS/Resp/RespSDD
 
-       if (dest->Put(entry)) {
-                    ok++;
-       } else {
-            failed += path.Data(); failed += " "; 
-       }
-       }
-       printf("\n************ RECPAR *********** \n");
-       printf("************ Stored %d objects over %d *********** \n", ok, recpar->GetEntries());
-       if(failed != ""){
-               printf("***** List of failed objects: %s \n", failed.Data());
-       }
-}
+                       if(path == "TOF/Calib/Par" || path == "TOF/Calib/SimPar" || path.Contains("TOF/CDB")) continue;
 
-if(config){
-       ok=0; failed = "";
-       for(int i=0;i<config->GetEntries();i++){
+                       if (dest->Put(entry)) {
+                               ok++;
+                       } else {
+                               failed += path.Data(); failed += " "; 
+                       }
+               }
+               printf("\n************ CALIB *********** \n");
+               printf("************ Stored %d objects over %d *********** \n", ok, calib->GetEntries());
+               if(failed != ""){
+                       printf("***** List of failed objects: %s \n", failed.Data());
+               }
+       }
 
-       entry = (AliCDBEntry*) config->At(i);
-       entry->GetId().SetRunRange(0,999999999);
-       TString path=entry->GetId().GetPath();
 
-       if (dest->Put(entry)) {
-                    ok++;
-       } else {
-                    failed += path.Data(); failed += " "; 
-       }
+       if(align){
+               ok=0; failed="";
+               for(int i=0;i<align->GetEntries();i++){
+
+                       entry = (AliCDBEntry*) align->At(i);
+                       entry->GetId().SetRunRange(0,AliCDBRunRange::Infinity());
+                       TString path=entry->GetId().GetPath();
+
+                       if (dest->Put(entry)) {
+                               ok++;
+                       } else {
+                               failed += path.Data(); failed += " "; 
+                       }
+               }
+               printf("\n************ ALIGN *********** \n");
+               printf("************ Stored %d objects over %d *********** \n", ok, align->GetEntries());
+               if(failed != ""){
+                       printf("***** List of failed objects: %s \n", failed.Data());
+               }
        }
-       printf("\n************ CONFIG *********** \n");
-       printf("************ Stored %d objects over %d *********** \n", ok, config->GetEntries());
-       if(failed != ""){
-               printf("***** List of failed objects: %s \n", failed.Data());
+
+       if(config){
+               ok=0; failed = "";
+               for(int i=0;i<config->GetEntries();i++){
+
+                       entry = (AliCDBEntry*) config->At(i);
+                       entry->GetId().SetRunRange(0,AliCDBRunRange::Infinity());
+                       TString path=entry->GetId().GetPath();
+
+                       if (dest->Put(entry)) {
+                               ok++;
+                       } else {
+                               failed += path.Data(); failed += " "; 
+                       }
+               }
+               printf("\n************ CONFIG *********** \n");
+               printf("************ Stored %d objects over %d *********** \n", ok, config->GetEntries());
+               if(failed != ""){
+                       printf("***** List of failed objects: %s \n", failed.Data());
+               }
        }
-}
 
-man->Destroy();
+       man->Destroy();
 
 }