1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 Primary goal of the proposal was to provide functionality to browse and compare the content of the OCDB
19 specified by different means.
21 a.) galice.root - as currently implemented by Ruben in MC (or any file with cdbMap, and cdbList)
22 b.) AliESDs.root - for the reconstructed data
23 c.) ocdb snapshot - as used for grid productions
24 d.) TMap(s) - as used internally in galice.root and AliESDs,root
25 e.) log file (if possible) - looks logs aways used similar syntax, tested and working
26 f.) C macro - custom macro
28 Content comparison should be done:
29 a.) on the level of symbolic links
30 b.) on the level of content itself
31 - by by byte comparison dif
32 - data member by data member comparison
34 Implementation assumption:
35 All input formats (a .. f) will be converted to the TMap storages and TList if AliCDBIds
38 AliOCDBtoolkit::MakeDiffExampleUseCase();
39 or from the AliOCDBtoolkit.sh in propmpt
40 ocdbMakeTable AliESDs.root ESD OCDBrec.list
41 ocdbMakeTable galice.root MC OCDBsim.list
48 //=============================================================================
49 // Functionality to dump content of objects in human readable format
50 //=============================================================================
52 1.) compare oontent of alignent OCDB files for differnt yers
53 2.) compare ClusterParam for different periods
57 =================================================================================================================
59 // Compare alignment example:
60 // Compare TPC alignemnt 2013 and 2010
62 AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2013/OCDB/TPC/Align/Data/Run0_999999999_v1_s0.root","TPCalign2013.dump",1,1);
63 AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Align/Data/Run0_999999999_v1_s0.root","TPCalign2010.dump",1,1);
64 diff TPCalign2013.dump TPCalign2010.dump > TPCalign2013_TPCalign2010.diff
67 =================================================================================================================
69 // Compare CluterParam OCDB etry
71 AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Calib/ClusterParam/Run131541_999999999_v2_s0.root","2010_TPC_Calib_ClusterParam_Run131541_999999999_v2_s0.dump",1);
72 AliOCDBtoolkit:: AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Calib/ClusterParam/Run0_999999999_v1_s0.root","2010_TPC_Calib_ClusterParam_Run0_999999999_v1_s0.dump",1);
73 AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2013/OCDB/TPC/Calib/ClusterParam/Run0_999999999_v1_s0.root","2013_TPC_Calib_ClusterParam_Run0_999999999_v1_s0.dump",1);
74 diff 2010_TPC_Calib_ClusterParam_Run131541_999999999_v2_s0.dump 2010_TPC_Calib_ClusterParam_Run0_999999999_v1_s0.dump
81 1.) Verify hash value uasge as and MD5 sum -
93 #include "TRealData.h"
94 #include "TDataMember.h"
100 #include "TObjArray.h"
103 #include "TMessage.h"
106 #include "AliCDBManager.h"
107 #include "AliCDBEntry.h"
108 #include "AliOCDBtoolkit.h"
109 #include "AliCDBStorage.h"
112 void AliOCDBtoolkit::MakeDiffExampleUseCase(){
114 // Example usage for the MC
115 // To run example case, assuming presence of following files in working directory:
120 AliCDBManager * man = AliCDBManager::Instance();
121 AliOCDBtoolkit::LoadOCDBFromLog("rec.log",0);
122 const TMap *cdbMapLog= man->GetStorageMap(); // this is map of
123 const TList *cdbListLog=man->GetRetrievedIds(); // this is list of AliCDBId
124 // TList *cdbListLog0=man->GetRetrievedIds(); // this is list of AliCDBId
126 TFile *fmc = TFile::Open("galice.root");
127 TMap *cdbMapMC= (TMap*)fmc->Get("cdbMap"); //
128 TList *cdbListMC0= (TList*)fmc->Get("cdbList"); // this is list of TObjStrings
129 TList *cdbListMC = AliOCDBtoolkit::ConvertListStringToCDBId(cdbListMC0); // convert to the TObjArray of AliCDBids
131 TFile *fesd = TFile::Open("AliESDs.root");
132 TList *listESD = ((TTree*)fesd->Get("esdTree"))->GetUserInfo();
133 TMap *cdbMapESD= (TMap*)listESD->FindObject("cdbMap");
134 TList *cdbListESD0= (TList*)listESD->FindObject("cdbList"); // this is list of TObjStrings
135 TList *cdbListESD = AliOCDBtoolkit::ConvertListStringToCDBId(cdbListESD0); // convert to the TObjArray of AliCDBids
140 printf("Diff log>>>ESD\n\n:");
141 MakeDiff(cdbMapLog, cdbListLog, cdbMapESD, cdbListESD,0);
143 printf("Diff ESD>>>log\n\n:");
144 MakeDiff(cdbMapESD, cdbListESD,cdbMapLog, cdbListLog,0);
147 printf("Diff ESD>>>MC\n\n:");
148 MakeDiff(cdbMapMC, cdbListMC, cdbMapESD, cdbListESD,0);
152 void AliOCDBtoolkit::DumpOCDBAsTxt(const TString fInput, const TString fType, const TString outfile){
157 const TMap *cdbMap=0;
158 const TList *cdbList=0;
161 AliCDBManager * man = AliCDBManager::Instance();
162 if (fInput.Contains("alien://") && gGrid==0){
163 TGrid *myGrid = TGrid::Connect("alien://"); //Oddly this will return also a pointer if connection fails
164 if(myGrid->GetPort()==0){ //if connection fails port 0 is saved, using this to check for successful connection
165 cerr << "Cannot connect to grid!" << endl;
169 if(fType.EqualTo("MC",TString::kIgnoreCase)){
170 file = TFile::Open(fInput.Data());
171 cdbMap = (TMap*)file->Get("cdbMap");
173 printf("cdbMap does not exist in input file\t%s. Exiting\n",fInput.Data());
177 man->SetDefaultStorage(((TPair*)cdbMap->FindObject("default"))->Value()->GetName());
178 TList *cdbListMC0 = (TList*)file->Get("cdbList"); // this is list of TObjStrings
179 cdbList = AliOCDBtoolkit::ConvertListStringToCDBId(cdbListMC0); // convert to the TObjArray of AliCDBids
181 else if(fType.EqualTo("ESD",TString::kIgnoreCase)){
182 file = TFile::Open(fInput.Data());
184 printf("Input file does not exist %s. Exiting\n",fInput.Data());
187 TList *listESD = ((TTree*)file->Get("esdTree"))->GetUserInfo();
188 cdbMap = (TMap*)listESD->FindObject("cdbMap");
190 printf("cdbMap does not exist in input file\t%s. Exiting\n",fInput.Data());
193 AliOCDBtoolkit::SetStorage(cdbMap);
194 TList *cdbListESD0= (TList*)listESD->FindObject("cdbList"); // this is list of TObjStrings
195 cdbList = ConvertListStringToCDBId(cdbListESD0); // convert to the TObjArray of AliCDBids
197 else if(fType.EqualTo("log",TString::kIgnoreCase)){
198 LoadOCDBFromLog(fInput.Data(),0);
199 cdbMap = man->GetStorageMap(); // this is map of
200 cdbList =man->GetRetrievedIds(); // this is list of AliCDBId
203 printf("unsupported option: %s",fType.Data());
206 cout <<"BEGINDUMP:" << endl;
207 DumpOCDB(cdbMap,cdbList,outfile);
211 Bool_t AliOCDBtoolkit::ParseInfoFromOcdbString(TString ocdbString, TString &ocdbPath, Int_t &run0, Int_t &run1, Int_t &version, Int_t &subVersion){
213 // Parse OCDB id string and provide basic ocdb information
215 // a.) parse ocdbPath
216 Int_t indexBeginPath= ocdbString.Index("path: ")+7;
217 if (indexBeginPath<0) return kFALSE;
218 Int_t indexEndPath=ocdbString.Index(";",indexBeginPath);
219 if (indexEndPath<0) return kFALSE;
220 ocdbPath=TString(&(ocdbString.Data()[indexBeginPath]), indexEndPath-indexBeginPath-1);
221 // b.) parse runRange
222 Int_t indexRun0= ocdbString.Index(": [",indexEndPath)+3;
223 if (indexRun0<0) return kFALSE;
224 Int_t indexRun1= ocdbString.Index(",",indexRun0)+1;
225 if (indexRun1<0) return kFALSE;
226 run0=atoi(&(ocdbString.Data()[indexRun0]));
227 run1=atoi(&(ocdbString.Data()[indexRun1]));
228 AliCDBRunRange runRange(run0,run1);
229 //c.) parse version, subversion
230 Int_t indexVersion= ocdbString.Index("version: v",indexRun1)+10;
231 if (indexVersion<0) return kFALSE;
232 Int_t indexSubVersion= ocdbString.Index("_s",indexVersion)+2;
233 if (indexSubVersion<0) return kFALSE;
234 version=atoi(&(ocdbString.Data()[indexVersion]));
235 subVersion=atoi(&(ocdbString.Data()[indexSubVersion]));
239 Bool_t AliOCDBtoolkit::ParseInfoFromOcdbString(TString ocdbString, AliCDBId &cdbId){
241 // Parse OCDB id string and provide basic ocdb information and fillcdbID object
244 Int_t run0=0, run1=0;
245 Int_t version=0, subVersion=0;
246 Bool_t parseStatus = ParseInfoFromOcdbString(ocdbString, ocdbPath, run0,run1,version,subVersion);
248 AliCDBRunRange runRange(run0,run1);
249 cdbId=AliCDBId(ocdbPath.Data(),runRange,version,subVersion);
250 AliCDBId* id = AliCDBId::MakeFromString(ocdbString);
258 TList * AliOCDBtoolkit::ConvertListStringToCDBId(const TList *cdbList0){
260 // Convert input list of the TObjString to list to AliCDBid
262 Int_t entriesList0=cdbList0->GetEntries();
263 TList * array0 = new TList();
265 for (Int_t ientry0=0; ientry0<entriesList0; ientry0++){
266 if (cdbList0->At(ientry0)==0) continue;
267 Bool_t isId = cdbList0->At(ientry0)->IsA()->InheritsFrom("AliCDBId");
269 array0->AddLast(cdbList0->At(ientry0));
271 Bool_t isString = cdbList0->At(ientry0)->IsA()->InheritsFrom("TObjString");
273 TObjString* sid0 = dynamic_cast<TObjString*> (cdbList0->At(ientry0));
274 Bool_t status = ParseInfoFromOcdbString(sid0->String(), tmp0);
275 if (!status) continue;
276 array0->AddLast(new AliCDBId(tmp0));
285 void AliOCDBtoolkit::LoadOCDBFromLog(const char *logName, Int_t verbose){
288 // Load OCDB setting as specified in log
289 // Assuming fixed version of the log
290 // AliCDBManager is initilaized - ocdbMap and ID list can be exported
293 // Parsing/loading sequence:
294 // 0.) SetDefault storage *** Default Storage URI:
295 // 1.) SetSpecific storage *** Specific storage
296 // 2.) SetRunNumber Run number:
299 AliCDBManager * man = AliCDBManager::Instance();
301 // 0.) SetDefault storage *** Default Storage URI:
303 TString defaultOCDB = gSystem->GetFromPipe(TString::Format("cat %s| grep \"Storage URI:\"",logName).Data());
304 TObjArray *array = defaultOCDB.Tokenize("\"");
305 man->SetDefaultStorage(array->Last()->GetName());
308 // 1.) SetSpecific storage *** Specific storage
310 TString specificStorage = gSystem->GetFromPipe(TString::Format("cat %s| grep \"Specific storage\"",logName).Data());
311 array = specificStorage.Tokenize("\"");
312 Int_t entries = array->GetEntries();
313 for (Int_t i=1; i<entries-2; i+=4){
314 // add protection here line shuld be in expected format
315 if ((verbose&2)>0) printf("%s\t%s\n",array->At(i)->GetName(),array->At(i+2)->GetName());
316 man->SetSpecificStorage(array->At(i)->GetName(),array->At(i+2)->GetName());
320 // 2.) SetRunNumber Run number:
322 TString runLine = gSystem->GetFromPipe(TString::Format("cat %s| grep \"I-AliCDBManager::Print: Run number =\"",logName).Data());
323 array = runLine.Tokenize("=");
325 if (array->GetEntries()>1) run=atoi(array->At(1)->GetName());
331 TString ids = gSystem->GetFromPipe(TString::Format("cat %s| grep I-AliCDB | grep path| grep range | grep version", logName).Data());
332 array= ids.Tokenize("\n");
333 entries = array->GetEntries();
335 for (Int_t i=0; i<entries; i++){
337 TString ocdbString = array->At(i)->GetName();
340 Int_t run0=0, run1=0;
341 Int_t version=0, subVersion=0;
342 Bool_t parseStatus = ParseInfoFromOcdbString(ocdbString, ocdbPath, run0,run1,version,subVersion);
343 if (!parseStatus) continue;
344 AliCDBRunRange runRange(run0,run1);
346 if ((verbose&2)!=0) {
347 printf("%s/Run%d_%d_v%d_s%d.root\n",ocdbPath.Data(),run0,run1,version,subVersion);
350 man->Get(ocdbPath.Data(),runRange,version,subVersion);
351 } catch(const exception &e){
352 cerr << "OCDB retrieval failed!" << endl;
353 cerr << "Detailes: " << e.what() << endl;
358 man->GetStorageMap()->Print();
359 man->GetRetrievedIds()->Print();
363 void AliOCDBtoolkit::SetStorage(const TMap *cdbMap){
365 // Set storages as specified in the map - TO CHECK..
366 // Should go to the AliCDBmanager if not alreadyhhere +++MI
368 // In case OCDB_PATH local variable is defined
369 // alien storage is replaced by OCDB_PATH prefix: e.g: local:///cvmfs/alice.gsi.de/
371 // Regexp extensivelly used - see documentation in ????
372 // http://wwwacs.gantep.edu.tr/guides/programming/root/htmldoc/examples/tstring.C.html
373 AliCDBManager * man = AliCDBManager::Instance();
374 TIter iter(cdbMap->GetTable());
376 while ((aPair = (TPair*) iter.Next())) {
379 TString urlOrig = aPair->Value()->GetName();
380 TString url=urlOrig; // e.g TString url="alien://?User=?DBFolder=/alice/data/2010/OCDB?SE=default?CacheFolder=?OperateDisconnected=1?CacheSize=1073741824?CleanupInterval=0"
381 man->ExtractBaseFolder(url); // url==alien://Folder=/alice/data/2010/OCDB"
382 TString ocdbPrefix(gSystem->Getenv("OCDB_PATHTEST"));
384 TRegexp alienPrefix("^alien://Folder=");
385 url(alienPrefix)=ocdbPrefix+"";
388 printf("%s\t%s\t%s\n", aPair->GetName(), urlOrig.Data(), url.Data());
389 if (TString(aPair->GetName())=="default") man->SetDefaultStorage(url);
391 man->SetSpecificStorage(aPair->GetName(), url);
395 void AliOCDBtoolkit::LoadOCDBFromMap(const TMap *cdbMap, const TList *cdbList){
398 // Load OCDB setting as specified in maps
399 // Or Do we have already implementation in AliCDBanager? TO CHECK.. Should go to the AliCDBmanager if not alreadyhhere
400 AliCDBManager * man = AliCDBManager::Instance();
401 AliOCDBtoolkit::SetStorage(cdbMap);
403 TObjString *ocdbString=0;
404 while (( ocdbString= (TObjString*) iter.Next())) {
405 AliCDBId* cdbId = AliCDBId::MakeFromString(ocdbString->String());
407 // AliCDBEntry * cdbEntry = (AliCDBEntry*) man->Get(*cdbId,kTRUE);
408 man->Get(*cdbId,kTRUE);
409 } catch(const exception &e){
410 cerr << "OCDB retrieval failed!" << endl;
411 cerr << "Detailes: " << e.what() << endl;
416 void AliOCDBtoolkit::LoadOCDBFromESD(const char *fname){
418 // Load OCDB setup from the ESD file
420 TFile * fesd = TFile::Open(fname);
421 TList *listESD = ((TTree*)fesd->Get("esdTree"))->GetUserInfo();
422 TMap *cdbMapESD= (TMap*)listESD->FindObject("cdbMap");
423 TList *cdbListESD0= (TList*)listESD->FindObject("cdbList"); // this is list of TObjStrings
424 AliOCDBtoolkit::SetStorage(cdbMapESD);
425 AliOCDBtoolkit::LoadOCDBFromMap(cdbMapESD, cdbListESD0);
429 void AliOCDBtoolkit::MakeDiff(const TMap *cdbMap0, const TList *cdbList0, const TMap */*cdbMap1*/, const TList *cdbList1, Int_t /*verbose*/){
432 // Print difference between the 2 ocdb maps
434 // maps and list charactireizing OCDB setup
438 AliOCDBtoolkit::SetStorage(cdbMap0);
439 Int_t entriesList0=cdbList0->GetEntries();
440 Int_t entriesList1=cdbList1->GetEntries();
442 for (Int_t ientry0=0; ientry0<entriesList0; ientry0++){
443 AliCDBId *id0 = dynamic_cast<AliCDBId*> (cdbList0->At(ientry0));
445 for (Int_t ientry1=0; ientry1<entriesList1; ientry1++){
446 AliCDBId *cid1 = dynamic_cast<AliCDBId*> (cdbList1->At(ientry1));
449 if (cid1->GetPath().Contains(id0->GetPath().Data())==0) continue;
453 printf("Missing entry\t");
457 // Bool_t isOK=kTRUE;
458 if (id0->GetFirstRun()!= id1->GetFirstRun() ||id0->GetLastRun()!= id1->GetLastRun()){
459 printf("Differrent run range\n");
463 if (id0->GetVersion()!= id1->GetVersion() ||id0->GetSubVersion()!= id1->GetSubVersion()){
464 printf("Differrent version\n");
471 void AliOCDBtoolkit::DumpOCDB(const TMap *cdbMap0, const TList *cdbList0, const TString outfile){
473 // Dump the OCDB configuatation as formated text file
474 // with following collumns
475 // cdb name prefix cdb path
476 // OCDB entries are sorted alphabetically
478 // TPC/Calib/RecoParam /hera/alice/jwagner/software/aliroot/AliRoot_TPCdev/OCDB/ TPC/Calib/RecoParam/Run0_999999999_v0_s0.root $SIZE_AliCDBEntry_Object $HASH_AliCDBEntry_Object
480 AliCDBManager * man = AliCDBManager::Instance();
481 AliOCDBtoolkit::SetStorage(cdbMap0);
482 TList * cdbList = (TList*) cdbList0; // sorted array
490 AliCDBEntry *cdbEntry=0;
491 TGrid *myGrid = NULL;
495 FILE *ofs = fopen(outfile.Data(),"w");
497 while ((CDBId =(AliCDBId*) next())){
498 cdbName = CDBId->GetPath();
499 ostr = (TObjString*)cdbMap0->GetValue(cdbName.Data());
500 if(!ostr) ostr = (TObjString*)cdbMap0->GetValue("default");
501 cdbPath = ostr->GetString();
502 if(cdbPath.Contains("local://"))cdbPath=cdbPath(8,cdbPath.Length()).Data();
503 if(!myGrid && cdbPath.Contains("alien://")){ //check if connection to alien is initialized
504 myGrid = TGrid::Connect("alien://"); //Oddly this will return also a pointer if connection fails
505 if(myGrid->GetPort()==0){ //if connection fails port 0 is saved, using this to check for successful connection
506 cerr << "Cannot connect to grid!" << endl;
511 cdbEntry = (AliCDBEntry*) man->Get(*CDBId,kTRUE);
512 }catch(const exception &e){
513 cerr << "OCDB retrieval failed!" << endl;
514 cerr << "Detailes: " << e.what() << endl;
519 printf("Object not avaliable\n");
523 TObject *obj = cdbEntry->GetObject();
524 file = new TMessage(TBuffer::kWrite);
525 file->WriteObject(obj);
526 size = file->Length();
528 fprintf(ofs,"object %s empty!\n",cdbName.Data());
531 hash = TString::Hash(file->Buffer(),size);
532 fprintf(ofs,"%s\t%s\t%s/Run%d_%d_v%d_s%d.root\t%d\t%u\n",
536 CDBId->GetFirstRun(),
539 CDBId->GetSubVersion(),
543 //if(!(CDBId->GetPathLevel(0)).Contains("TPC")) continue;
544 //cout << CDBId.ToString() << endl;
551 //====================================================================================================
553 //====================================================================================================
559 void AliOCDBtoolkit::DumpOCDBFile(const char *finput , const char *foutput, Bool_t dumpMetaData, Bool_t xml){
562 // DumpOCDBFile("$ALICE_ROOT/OCDB/ITS/Align/Data/Run0_999999999_v0_s0.root", "ITS_Align_Data_Run0_999999999_v0_s0.dump")
564 if (finput==0) return ;
565 if (TString(finput).Contains("alien://") && gGrid==0){
566 TGrid *myGrid = TGrid::Connect("alien://"); //Oddly this will return also a pointer if connection fails
567 if(myGrid->GetPort()==0){ //if connection fails port 0 is saved, using this to check for successful connection
568 cerr << "Cannot connect to grid!" << endl;
572 TFile *falignITS = TFile::Open(finput);
573 AliCDBEntry *entry = (AliCDBEntry*)falignITS->Get("AliCDBEntry");
575 TObject *obj = ((AliCDBEntry*)falignITS->Get("AliCDBEntry"))->GetObject();
579 if (dumpMetaData) gROOT->ProcessLine(TString::Format("((TObject*)%p)->Dump(); >%s",entry, foutput).Data());
581 gROOT->ProcessLine(TString::Format("AliOCDBtoolkit::DumpObjectRecursive((TObject*)%p); >>%s",obj, foutput).Data());
584 TFile * f = TFile::Open(TString::Format("%s.xml",foutput).Data(),"recreate");
585 if (dumpMetaData) entry->Write("AliCDBEntry");
586 else obj->Write("AliCDBEntry");
593 void AliOCDBtoolkit::DumpObjectRecursive(TObject *obj){
598 printf("==> Dumping object at: %p, name=%s, class=%s)\n", obj, obj->GetName(), (obj->IsA()->GetName()));
599 DumpObjectRecursive(obj, TString(obj->IsA()->GetName())+".",counterRec);
605 void AliOCDBtoolkit::DumpObjectRecursive(TObject *obj, TString prefix, Int_t &counterRec){
607 // Recursive dump of the TObject
608 // Dump all basic types and follow pointers to the objects
609 // current limitation:
610 // a.) clases and structures not derived from TObject not followed (to fix)
611 // b.) dynamic arrays not followed
612 // c.) std maps,array .... not followed
617 // Special case of Collection classes
619 if (obj->IsA()->InheritsFrom(TCollection::Class())) {
620 TIter myiter((TCollection*)obj);
623 while ((arObject = (TObject*)myiter.Next())) {
624 TString prefixArr = TString::Format("%s[%d]",prefix.Data(),counter);
625 DumpObjectRecursive(arObject,prefixArr,counterRec);
632 TClass * cl = obj->IsA();
633 if (!(cl->GetListOfRealData())) cl->BuildRealData();
635 TIter next(cl->GetListOfRealData());
636 while ((rd = (TRealData*) next())) {
638 TDataMember* dm = rd->GetDataMember();
639 TDataType* dtype = dm->GetDataType();
640 Int_t offset = rd->GetThisOffset();
641 char* pointer = ((char*) obj) + offset;
643 if (dm->IsaPointer()) {
644 // We have a pointer to an object or a pointer to an array of basic types.
646 if (!dm->IsBasic()) {
647 clobj = TClass::GetClass(dm->GetTypeName());
650 // We have a pointer to an object.
652 if (!clobj->InheritsFrom(TObject::Class())) {
653 // It must be a TObject object.
656 char** apointer = (char**) pointer;
657 TObject* robj = (TObject*) *apointer;
660 printf("M:%s%s\n",prefix.Data(),dm->GetName()); // Missing - 0 pointer
662 printf("T:%s\t%s%s\n", clobj->GetName(),prefix.Data(), dm->GetName());
663 TString prefixNew=prefix;
664 prefixNew+=dm->GetName();
666 if (robj!=obj) DumpObjectRecursive(robj,prefixNew,counterRec); // trivial check
668 printf("R:%s\t%s%s\n",clobj->GetName(),prefix.Data(), dm->GetName());
672 } else if (dm->IsBasic()) {
676 const char* index = dm->GetArrayIndex();
677 if (dm->GetArrayDim()==0){
678 printf("B:\t%s%s\t%s\n", prefix.Data(),rd->GetName(), dtype->AsString(pointer));
681 // Basic array - fixed length
683 // if (dm->GetArrayDim()>0 && strlen(index) != 0){
684 if (dm->GetArrayDim()>0 ){
685 printf("A:\t%s%s\t",prefix.Data(),rd->GetName());
687 for (Int_t idim=0; idim<dm->GetArrayDim(); idim++){
688 //printf("A:%d\t%d\n", dm->GetArrayDim(),dm->GetMaxIndex(idim));
689 for (Int_t j=0; j<dm->GetMaxIndex(idim); j++){
690 printf("%s\t",dtype->AsString(pointer+dm->GetUnitSize()*counter));
692 if (counter%5==0) printf("\nA:\t%s%s\t",prefix.Data(),rd->GetName());
698 // Basic array - dynamic length
700 if (dm->GetArrayDim()>0 && strlen(index) != 0){
702 // Dump first only for the moment
704 printf("B:\t%s%s\t%s\n",prefix.Data(),rd->GetName(), dtype->AsString(pointer));
712 // Small checks to test the TRealData and TDataType
717 void DumpDataSimple(){
719 // Dump example for elenatr data types
721 TObject *obj = new TVectorD(20);
722 TClass * cl = obj->IsA();
723 if (!cl->GetListOfRealData()) cl->BuildRealData();
726 rd = (TRealData*)(cl->GetListOfRealData()->FindObject("fNrows"));
727 TDataMember* dm = rd->GetDataMember();
728 TDataType* dtype = dm->GetDataType();
730 Int_t offset = rd->GetThisOffset();
731 char* pointer = ((char*) obj) + offset;
732 printf("%s\n",dtype->AsString(pointer));
735 void DumpDataArray(){
737 // print array example
739 TObject *obj = new TVectorD(20);
740 TClass * cl = obj->IsA();
741 if (!cl->GetListOfRealData()) cl->BuildRealData();
743 rd = (TRealData*)(cl->GetListOfRealData()->FindObject("*fElements"));
744 TDataMember* dm = rd->GetDataMember();
745 TDataType* dtype = dm->GetDataType();
748 Int_t offset = rd->GetThisOffset();
749 char* pointer = ((char*) obj) + offset;
750 printf("%s\n",dtype->AsString(pointer));
753 void DumpTObjectArray(){
757 TObjArray *array = new TObjArray(10);
758 for (Int_t i=0; i<10; i++) array->AddLast(new TNamed(Form("n%d",i), Form("n%d",i)));
759 AliOCDBtoolkit::DumpObjectRecursive(array);
762 TObject *obj = array;
763 TClass * cl = obj->IsA();
764 if (!cl->GetListOfRealData()) cl->BuildRealData();
766 rd = (TRealData*)(cl->GetListOfRealData()->FindObject("*fCont"));
767 TDataMember* dm = rd->GetDataMember();
768 TDataType* dtype = dm->GetDataType();
770 Int_t offset = rd->GetThisOffset();
771 char* pointer = ((char*) obj) + offset;
772 char** apointer = (char**) pointer;
773 //we have pointer to pointer here
774 TObject** ppobj = (TObject**) *apointer;
780 while ((arObject = (TObject*)myiter.Next())) {
781 AliOCDBtoolkit::DumpObjectRecursive(arObject);
786 Bool_t AliOCDBtoolkit::AddoptOCDBEntry( const char *finput, const char *output, Int_t ustartRun, Int_t uendRun){
788 // Addopt OCDB entry - keeping all of the CDBentry quantities
790 // AliOCDBtoolkit::AddoptOCDBEntry("/cvmfs/alice.gsi.de/alice/simulation/2008/v4-15-Release/Residual/TPC/Calib/ClusterParam/Run127712_130850_v4_s0.root",0,0,AliCDBRunRange::Infinity())
791 TFile * fin = TFile::Open(finput);
792 if (!fin) return kFALSE;
793 AliCDBEntry * entry = (AliCDBEntry*) fin->Get("AliCDBEntry");
794 if (!entry) return kFALSE;
796 AliCDBStorage* pocdbStorage = 0;
797 if (output!=0) AliCDBManager::Instance()->GetStorage(output);
799 TString localStorage = "local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
800 pocdbStorage = AliCDBManager::Instance()->GetStorage(localStorage.Data());
803 AliCDBId idIn = entry->GetId();
804 AliCDBMetaData *metaDataIn = entry->GetMetaData();
806 AliCDBMetaData *metaData= new AliCDBMetaData();
807 metaData->SetObjectClassName(metaDataIn->GetObjectClassName());
808 metaData->SetResponsible(TString::Format("%s: copy",metaDataIn->GetResponsible()).Data());
809 metaData->SetBeamPeriod(metaDataIn->GetBeamPeriod());
811 metaData->SetAliRootVersion(metaDataIn->GetAliRootVersion()); //root version
812 metaData->SetComment((TString::Format("%s: copy",metaDataIn->GetComment()).Data()));
814 id1=new AliCDBId(idIn.GetPath(), ustartRun, uendRun);
815 pocdbStorage->Put(entry->GetObject(), (*id1), metaData);
820 void AliOCDBtoolkit::MakeSnapshotFromTxt(const TString fInput, const TString outfile, Bool_t singleKeys){
822 // Make snasphot form the txt file
824 AliCDBManager * man = AliCDBManager::Instance();
825 LoadOCDBFromList(fInput.Data());
826 man->DumpToSnapshotFile(outfile.Data(), singleKeys);