macro and bash script to check for cdb-paths and entries in an OCDB folder
authorrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 May 2008 12:42:04 +0000 (12:42 +0000)
committerrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 15 May 2008 12:42:04 +0000 (12:42 +0000)
STEER/CheckCDBentries.C [new file with mode: 0644]
STEER/listCdbEntries.sh [new file with mode: 0755]

diff --git a/STEER/CheckCDBentries.C b/STEER/CheckCDBentries.C
new file mode 100644 (file)
index 0000000..69a7a3e
--- /dev/null
@@ -0,0 +1,50 @@
+#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 CheckCDBentries(const char* dest)
+{
+       AliCDBManager* cdb = AliCDBManager::Instance();
+       const char* ref="local://$ALICE_ROOT";
+       cdb->SetDefaultStorage(ref);
+       cdb->SetRun(0);
+       AliCDBStorage* newstor = cdb->GetStorage(dest);
+       // Missing here a check that newstor is a valid storage
+       // otherwise exit
+       TList* allentries = cdb->GetAll("*/*/*");
+       TList* allnewentries = newstor->GetAll("*/*/*",0);
+       Int_t nall = allentries->GetEntries();
+       Int_t nallnew = allnewentries->GetEntries();
+       Printf("Number of entries in reference OCDB %d  and in checked OCDB %d",nall, nallnew);
+       TString missing;
+       Int_t nMissing=0;
+       if(nall!=nallnew)
+       {
+               AliCDBEntry *entry, *newentry;
+               TString cdbpath;
+               for(Int_t i=0; i<nall; i++)
+               {
+                       entry = dynamic_cast<AliCDBEntry*>(allentries->At(i));
+                       cdbpath = ((AliCDBId)entry->GetId()).GetPath();
+                       newentry = newstor->Get(cdbpath.Data(),0);
+                       if(!newentry)
+                       {
+                               missing += cdbpath;
+                               missing.Insert(missing.Length(),'\n');
+                               nMissing++;
+                       }
+               }
+       }
+       if(nMissing)
+       {
+               Printf("\n\nEntries missing in destination OCDB folder %s w.r.t. reference folder %s:",dest,ref);
+               Printf("%s",missing.Data());
+       }else{
+               Printf("\n\nNo entry is missing in destination OCDB folder %s w.r.t. reference folder %s:",dest,ref);
+       }
+}
diff --git a/STEER/listCdbEntries.sh b/STEER/listCdbEntries.sh
new file mode 100755 (executable)
index 0000000..8ec7eda
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+# List all CDB paths present in the current OCDB folder
+# The script is meant to check the different CDB path in the reference OCDB
+# ($ALICE_ROOT) to make sure all entries are copied to the destination OCDB
+# folder. In particular we are interested in the second of the three levels
+# composing the CDB-path since usually the copy from one OCDB to the other
+# is done by lines of the type
+# TList* l = cdb->GetAll("*/Calib/*");
+# TList* l = cdb->GetAll("*/Align/*");
+# (see macro CDBToGrid.C)
+#
+
+stdfname="Run0_999999999"
+msg="List of second level strings for CDB entries:"
+cd $1
+for i in `find ./ -name 'Run*' | grep -v svn`
+do
+       fname=`echo "$i" | cut -d/ -f5`
+       if(expr match "$fname" "Run0." > /dev/null)
+       then
+               if [[ $fname == Run0_99999999* ]]
+               then
+                       second=`echo "$i" | cut -d/ -f3`
+                       if [[ $second != Align ]] && [[ $second != Calib ]] && [[ $second != Config ]]
+                       then
+                               #printf "$second in $i\n"
+                               msg="$msg
+                               $second for entry $i" 
+                       fi
+               else
+                       echo "Warning: $i is not a good file name for OCDB"
+               fi
+       fi
+done
+echo "$msg"
+