]>
Commit | Line | Data |
---|---|---|
085e6c5a | 1 | // $Id$ |
2 | /** | |
3 | * @file adjustOCDBObject.C | |
4 | * @brief Tool to adjust properties of an OCDB object and write it back to OCDB. | |
5 | * | |
6 | * Usage: | |
7 | * <pre> | |
8 | * aliroot -b -q adjustOCDBObject("file", | |
9 | * targetCDB="local://$PWD", | |
10 | * firstrun=-1, | |
11 | * lastrun=-1, | |
12 | * version=-1, | |
13 | * subversion=-1, | |
14 | * comment=NULL, | |
15 | * responsible=NULL, | |
16 | * alirootv=NULL) | |
17 | * </pre> | |
18 | * | |
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 | |
21 | * location. | |
22 | * | |
23 | * @author Matthias.Richter@ift.uib.no | |
24 | * @ingroup alihlt_tutorial | |
25 | */ | |
26 | void adjustOCDBObject(const char* file, | |
27 | const char* targetCDB="local://$PWD", | |
28 | int firstrun=-1, | |
29 | int lastrun=-1, | |
30 | int version=-1, | |
31 | int subversion=-1, | |
32 | const char* comment=NULL, | |
33 | const char* responsible=NULL, | |
34 | const char* alirootv=NULL) | |
35 | { | |
36 | TFile* origfile=new TFile(file); | |
37 | if (origfile->IsZombie()) { | |
38 | cerr << "error opening file " << file << endl; | |
39 | return; | |
40 | } | |
41 | ||
42 | AliCDBEntry* cdbEntry=NULL; | |
43 | origfile->GetObject("AliCDBEntry", cdbEntry); | |
44 | if (!cdbEntry) { | |
45 | cerr << "can not find CDB entry in file " << file << endl; | |
46 | } | |
47 | ||
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); | |
53 | ||
54 | AliCDBMetaData* meta=cdbEntry->GetMetaData(); | |
55 | if (comment) meta->SetComment(comment); | |
56 | if (responsible) meta->SetResponsible(responsible); | |
57 | if (alirootv) meta->SetAliRootVersion(alirootv); | |
58 | ||
59 | AliCDBManager* man = AliCDBManager::Instance(); | |
60 | man->SetDefaultStorage(targetCDB); | |
61 | man->Put(cdbEntry); | |
62 | ||
63 | } |