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 * Required parameters:
26 * Optional parameters, if the default values are specified the
27 * corresponding key in the entry is not changed
29 * - last run, if smaller than first run 'AliCDBRunRange::Infinity' is used
36 * @author Matthias.Richter@ift.uib.no
37 * @ingroup alihlt_tutorial
39 void adjustOCDBObject(const char* file,
40 const char* targetCDB="local://$PWD",
45 const char* comment=NULL,
46 const char* responsible=NULL,
47 const char* alirootv=NULL)
49 TFile* origfile=new TFile(file);
50 if (origfile->IsZombie()) {
51 cerr << "error opening file " << file << endl;
55 AliCDBEntry* cdbEntry=NULL;
56 origfile->GetObject("AliCDBEntry", cdbEntry);
58 cerr << "can not find CDB entry in file " << file << endl;
61 AliCDBId& cdbId=cdbEntry->GetId();
62 if (version>=0) cdbId.SetVersion(version);
63 if (subversion>=0) cdbId.SetSubVersion(subversion);
64 if (firstrun>=0) cdbId.SetFirstRun(firstrun);
65 if (lastrun>=0) cdbId.SetLastRun(lastrun);
66 if (lastrun<firstrun) cdbId.SetLastRun(AliCDBRunRange::Infinity());
68 AliCDBMetaData* meta=cdbEntry->GetMetaData();
69 if (comment) meta->SetComment(comment);
70 if (responsible) meta->SetResponsible(responsible);
71 if (alirootv) meta->SetAliRootVersion(alirootv);
73 AliCDBManager* man = AliCDBManager::Instance();
74 man->SetDefaultStorage(targetCDB);
79 void adjustOCDBObject()
81 cout << "adjustOCDBObject.C adjust properties of an OCDB entry" << endl;
82 cout << "usage:" << endl;
83 cout << " aliroot -b -q adjustOCDBObject'(\"file\", " << endl;
84 cout << " targetCDB=\"local://$PWD\", " << endl;
85 cout << " firstrun=-1, " << endl;
86 cout << " lastrun=-1, " << endl;
87 cout << " version=-1, " << endl;
88 cout << " subversion=-1, " << endl;
89 cout << " comment=NULL, " << endl;
90 cout << " responsible=NULL, " << endl;
91 cout << " alirootv=NULL)' " << endl;
92 cout << " e.g." << endl;
93 cout << " aliroot -b -q adjustOCDBObject'(\"myfile.root\", \"$ALICE_ROOT/OCDB\", 42, 42)'" << endl;