]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/rec/AliHLTMiscImplementation.cxx
e61687d176849dbc4e7c1c5f2de6e13531022022
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTMiscImplementation.cxx
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"
27 #include "AliCDBEntry.h"
28
29 /** ROOT macro for the implementation of ROOT specific class methods */
30 ClassImp(AliHLTMiscImplementation);
31
32 AliHLTMiscImplementation::AliHLTMiscImplementation()
33 {
34 }
35
36 AliHLTMiscImplementation::~AliHLTMiscImplementation()
37 {
38   // see header file for function documentation
39 }
40
41 int AliHLTMiscImplementation::InitCDB(const char* cdbpath)
42 {
43   // see header file for function documentation
44   int iResult=0;
45   AliCDBManager* pCDB = AliCDBManager::Instance();
46   AliHLTLogging log;
47   if (!pCDB) {
48     log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance");
49   } else {
50     if (cdbpath && cdbpath[0]!=0) {
51       pCDB->SetDefaultStorage(cdbpath);
52       log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB);
53     } else if (!pCDB->IsDefaultStorageSet()) {
54       const char* cdbUri="local://$ALICE_ROOT/OCDB";
55       pCDB->SetDefaultStorage(cdbUri);
56       pCDB->SetRun(0);
57       log.Logging(kHLTLogInfo, "InitCDB", "CDB handling", "set default URI: %s", cdbUri);
58     }
59   }
60   return iResult;
61 }
62
63 int AliHLTMiscImplementation::SetCDBRunNo(int runNo)
64 {
65   // see header file for function documentation
66   int iResult=0;
67   AliCDBManager* pCDB = AliCDBManager::Instance();
68   AliHLTLogging log;
69   if (!pCDB) {
70     log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance");
71   } else {
72     pCDB->SetRun(runNo);
73   }
74   return iResult;
75 }
76
77 AliCDBEntry* AliHLTMiscImplementation::LoadOCDBEntry(const char* path, int runNo, int version, int subVersion)
78 {
79   // see header file for function documentation
80   AliCDBManager::Instance()->UnloadFromCache(path);
81   return AliCDBManager::Instance()->Get(path, runNo, version, subVersion);
82 }
83
84 TObject* AliHLTMiscImplementation::ExtractObject(AliCDBEntry* entry)
85 {
86   // see header file for function documentation
87   if (!entry) return NULL;
88   return entry->GetObject();
89 }
90
91 int AliHLTMiscInitCDB(const char* cdbpath)
92 {
93   int iResult=0;
94   AliCDBManager* pCDB = AliCDBManager::Instance();
95   AliHLTLogging log;
96   if (!pCDB) {
97     log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance");
98   } else {
99     if (cdbpath && cdbpath[0]!=0) {
100       pCDB->SetDefaultStorage(cdbpath);
101       log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB);
102     } else if (!pCDB->IsDefaultStorageSet()) {
103       const char* cdbUri="local://$ALICE_ROOT/OCDB";
104       pCDB->SetDefaultStorage(cdbUri);
105       pCDB->SetRun(0);
106       log.Logging(kHLTLogInfo, "InitCDB", "CDB handling", "set default URI: %s", cdbUri);
107     }
108   }
109   return iResult;
110 }
111
112 int AliHLTMiscSetCDBRunNo(int runNo)
113 {
114   int iResult=0;
115   AliCDBManager* pCDB = AliCDBManager::Instance();
116   AliHLTLogging log;
117   if (!pCDB) {
118     log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance");
119   } else {
120     pCDB->SetRun(runNo);
121   }
122   return iResult;
123 }