]>
Commit | Line | Data |
---|---|---|
2b545cdd | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
10 | //* Permission to use, copy, modify and distribute this software and its * | |
11 | //* documentation strictly for non-commercial purposes is hereby granted * | |
12 | //* without fee, provided that the above copyright notice appears in all * | |
13 | //* copies and that both the copyright notice and this permission notice * | |
14 | //* appear in the supporting documentation. The authors make no claims * | |
15 | //* about the suitability of this software for any purpose. It is * | |
16 | //* provided "as is" without express or implied warranty. * | |
17 | //************************************************************************** | |
18 | ||
19 | /// @file AliHLTMisc.cxx | |
20 | /// @author Matthias Richter | |
21 | /// @date | |
22 | /// @brief Miscellaneous methods for the HLT AliRoot integration | |
23 | ||
24 | #include "AliHLTMiscImplementation.h" | |
25 | #include "AliHLTLogging.h" | |
26 | #include "AliCDBManager.h" | |
22d17395 | 27 | #include "AliCDBStorage.h" |
2b545cdd | 28 | #include "AliCDBEntry.h" |
29 | ||
30 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
31 | ClassImp(AliHLTMiscImplementation); | |
32 | ||
33 | AliHLTMiscImplementation::AliHLTMiscImplementation() | |
34 | { | |
35 | } | |
36 | ||
37 | AliHLTMiscImplementation::~AliHLTMiscImplementation() | |
38 | { | |
39 | // see header file for function documentation | |
40 | } | |
41 | ||
42 | int AliHLTMiscImplementation::InitCDB(const char* cdbpath) | |
43 | { | |
44 | // see header file for function documentation | |
45 | int iResult=0; | |
46 | AliCDBManager* pCDB = AliCDBManager::Instance(); | |
47 | AliHLTLogging log; | |
48 | if (!pCDB) { | |
49 | log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); | |
50 | } else { | |
51 | if (cdbpath && cdbpath[0]!=0) { | |
52 | pCDB->SetDefaultStorage(cdbpath); | |
53 | log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB); | |
54 | } else if (!pCDB->IsDefaultStorageSet()) { | |
55 | const char* cdbUri="local://$ALICE_ROOT/OCDB"; | |
56 | pCDB->SetDefaultStorage(cdbUri); | |
57 | pCDB->SetRun(0); | |
58 | log.Logging(kHLTLogInfo, "InitCDB", "CDB handling", "set default URI: %s", cdbUri); | |
59 | } | |
60 | } | |
61 | return iResult; | |
62 | } | |
63 | ||
64 | int AliHLTMiscImplementation::SetCDBRunNo(int runNo) | |
65 | { | |
66 | // see header file for function documentation | |
67 | int iResult=0; | |
68 | AliCDBManager* pCDB = AliCDBManager::Instance(); | |
69 | AliHLTLogging log; | |
70 | if (!pCDB) { | |
71 | log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); | |
72 | } else { | |
73 | pCDB->SetRun(runNo); | |
74 | } | |
75 | return iResult; | |
76 | } | |
77 | ||
78 | AliCDBEntry* AliHLTMiscImplementation::LoadOCDBEntry(const char* path, int runNo, int version, int subVersion) | |
79 | { | |
80 | // see header file for function documentation | |
22d17395 | 81 | AliCDBStorage* store = AliCDBManager::Instance()->GetDefaultStorage(); |
82 | if (!store) { | |
83 | return NULL; | |
84 | } | |
85 | if (version<0) version = store->GetLatestVersion(path, runNo); | |
86 | if (subVersion<0) subVersion = store->GetLatestSubVersion(path, runNo, version); | |
2b545cdd | 87 | return AliCDBManager::Instance()->Get(path, runNo, version, subVersion); |
88 | } | |
89 | ||
90 | TObject* AliHLTMiscImplementation::ExtractObject(AliCDBEntry* entry) | |
91 | { | |
92 | // see header file for function documentation | |
93 | if (!entry) return NULL; | |
94 | return entry->GetObject(); | |
95 | } | |
96 | ||
97 | int AliHLTMiscInitCDB(const char* cdbpath) | |
98 | { | |
99 | int iResult=0; | |
100 | AliCDBManager* pCDB = AliCDBManager::Instance(); | |
101 | AliHLTLogging log; | |
102 | if (!pCDB) { | |
103 | log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); | |
104 | } else { | |
105 | if (cdbpath && cdbpath[0]!=0) { | |
106 | pCDB->SetDefaultStorage(cdbpath); | |
107 | log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB); | |
108 | } else if (!pCDB->IsDefaultStorageSet()) { | |
109 | const char* cdbUri="local://$ALICE_ROOT/OCDB"; | |
110 | pCDB->SetDefaultStorage(cdbUri); | |
111 | pCDB->SetRun(0); | |
112 | log.Logging(kHLTLogInfo, "InitCDB", "CDB handling", "set default URI: %s", cdbUri); | |
113 | } | |
114 | } | |
115 | return iResult; | |
116 | } | |
117 | ||
118 | int AliHLTMiscSetCDBRunNo(int runNo) | |
119 | { | |
120 | int iResult=0; | |
121 | AliCDBManager* pCDB = AliCDBManager::Instance(); | |
122 | AliHLTLogging log; | |
123 | if (!pCDB) { | |
124 | log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); | |
125 | } else { | |
126 | pCDB->SetRun(runNo); | |
127 | } | |
128 | return iResult; | |
129 | } |