2 #if !defined(__CINT__) || defined(__MAKECINT__)
3 #include "AliCDBManager.h"
4 #include "AliCDBStorage.h"
6 #include "AliCDBMetaData.h"
9 #include <TObjString.h>
13 void makeCDBSnapshotFromUserInfo(const char* defaultStorage, const char* esdFile, const char* snapshotFile)
15 // read UserInfo from an esd tree and build the corresponding single-key snapshot from it
16 // ATTENTION: it works if we are happy that all objects will be taken from the default CDB
17 // Example input esd file: "alien:///alice/data/2011/LHC11h_2/000168984/ESDs/pass2/11000168984001.12/AliESDs.root"
20 AliCDBManager *cdb = AliCDBManager::Instance();
21 cdb->SetDefaultStorage(defaultStorage);
23 TFile *f = TFile::Open(esdFile);
25 Printf("Unable to open file \"%s\". Exiting.",esdFile);
28 TTree *tree = (TTree*) f->Get("esdTree");
30 Printf("Could not get tree from file. Exiting.");
33 TList *ui = (TList*) tree->GetUserInfo();
35 Printf("Could not get user info from tree. Exiting.");
38 TList *ids = (TList*) ui->At(2);
40 Printf("Could not get CDB objects' ids from user info. Exiting.");
46 while ((oStr = dynamic_cast<TObjString*> (lIter.Next()))) {
47 TString printedId = oStr->GetString();
48 // add here lines like the following if you don't want a given object in the snapshot
49 // this should not be needed because the specific storages overwrite the snapshot-mode
50 //if(printedId.Contains("ITS/Align/Data")||printedId.Contains("MUON/Align/Data"))
52 printedId.Remove(0,printedId.First('"')+1);
53 TString path = printedId(0,printedId.First('"'));
54 printedId.Remove(0,printedId.First('[')+1);
55 TString fRun = printedId(0,printedId.First(','));
56 printedId.Remove(0,printedId.First(',')+1);
57 Int_t firstRun = fRun.Atoi();
58 TString lRun = printedId(0,printedId.First(']'));
59 Int_t lastRun = lRun.Atoi();
60 printedId.Remove(0,printedId.First(':')+1);
61 printedId.Remove(0,2);
62 printedId.Remove(printedId.First('_'),printedId.Length());
63 Int_t version = printedId.Atoi();
64 AliCDBId id(path.Data(),firstRun,lastRun,version);
66 AliCDBEntry *e = cdb->Get(id,kTRUE);
69 cdb->DumpToSnapshotFile(snapshotFile,kFALSE);