3 * @file adjustOCDBObject.C
4 * @brief Tool to adjust properties of an OCDB object and write it back to OCDB.
8 * aliroot -b -q adjustOCDBObject("file",
9 * targetCDB="local://$PWD",
19 * The macro opens an OCDB entry directly as a file, changes properties
20 * of the entry and uses the CDBmanager to write it back to some new
23 * @author Matthias.Richter@ift.uib.no
24 * @ingroup alihlt_tutorial
26 void adjustOCDBObject(const char* file,
27 const char* targetCDB="local://$PWD",
32 const char* comment=NULL,
33 const char* responsible=NULL,
34 const char* alirootv=NULL)
36 TFile* origfile=new TFile(file);
37 if (origfile->IsZombie()) {
38 cerr << "error opening file " << file << endl;
42 AliCDBEntry* cdbEntry=NULL;
43 origfile->GetObject("AliCDBEntry", cdbEntry);
45 cerr << "can not find CDB entry in file " << file << endl;
48 AliCDBId& cdbId=cdbEntry->GetId();
49 if (version>=0) cdbId.SetVersion(version);
50 if (subversion>=0) cdbId.SetSubVersion(subversion);
51 if (firstrun>=0) cdbId.SetFirstRun(firstrun);
52 if (lastrun>=0) cdbId.SetLastRun(lastrun);
54 AliCDBMetaData* meta=cdbEntry->GetMetaData();
55 if (comment) meta->SetComment(comment);
56 if (responsible) meta->SetResponsible(responsible);
57 if (alirootv) meta->SetAliRootVersion(alirootv);
59 AliCDBManager* man = AliCDBManager::Instance();
60 man->SetDefaultStorage(targetCDB);