Bug fix in copy constructor and assignement operator (Matthias + me)
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTMiscImplementation.cxx
CommitLineData
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"
cc484ed9 29#include "AliGRPManager.h"
73305a93 30#include "AliRawReader.h"
cc484ed9 31#include "TGeoGlobalMagField.h"
2b545cdd 32
33/** ROOT macro for the implementation of ROOT specific class methods */
34ClassImp(AliHLTMiscImplementation);
35
36AliHLTMiscImplementation::AliHLTMiscImplementation()
37{
38}
39
40AliHLTMiscImplementation::~AliHLTMiscImplementation()
41{
42 // see header file for function documentation
43}
44
45int AliHLTMiscImplementation::InitCDB(const char* cdbpath)
46{
47 // see header file for function documentation
48 int iResult=0;
49 AliCDBManager* pCDB = AliCDBManager::Instance();
50 AliHLTLogging log;
51 if (!pCDB) {
52 log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance");
53 } else {
54 if (cdbpath && cdbpath[0]!=0) {
cc484ed9 55 TString uri=cdbpath;
56 if (!uri.BeginsWith("local://") &&
57 !uri.Contains("://")) {
58 // assume a local path if no uri specifier is found
59 uri="local://";
60 uri+=cdbpath;
61 }
62 pCDB->SetDefaultStorage(uri);
2b545cdd 63 log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB);
64 } else if (!pCDB->IsDefaultStorageSet()) {
65 const char* cdbUri="local://$ALICE_ROOT/OCDB";
66 pCDB->SetDefaultStorage(cdbUri);
67 pCDB->SetRun(0);
68 log.Logging(kHLTLogInfo, "InitCDB", "CDB handling", "set default URI: %s", cdbUri);
69 }
70 }
71 return iResult;
72}
73
74int AliHLTMiscImplementation::SetCDBRunNo(int runNo)
75{
76 // see header file for function documentation
77 int iResult=0;
78 AliCDBManager* pCDB = AliCDBManager::Instance();
79 AliHLTLogging log;
80 if (!pCDB) {
cc484ed9 81 log.Logging(kHLTLogError, "SetCDBRunNo", "CDB handling", "Could not get CDB instance");
2b545cdd 82 } else {
83 pCDB->SetRun(runNo);
84 }
85 return iResult;
86}
87
88AliCDBEntry* AliHLTMiscImplementation::LoadOCDBEntry(const char* path, int runNo, int version, int subVersion)
89{
90 // see header file for function documentation
22d17395 91 AliCDBStorage* store = AliCDBManager::Instance()->GetDefaultStorage();
92 if (!store) {
93 return NULL;
94 }
95 if (version<0) version = store->GetLatestVersion(path, runNo);
96 if (subVersion<0) subVersion = store->GetLatestSubVersion(path, runNo, version);
2b545cdd 97 return AliCDBManager::Instance()->Get(path, runNo, version, subVersion);
98}
99
100TObject* AliHLTMiscImplementation::ExtractObject(AliCDBEntry* entry)
101{
102 // see header file for function documentation
103 if (!entry) return NULL;
104 return entry->GetObject();
105}
106
cc484ed9 107int AliHLTMiscImplementation::InitMagneticField() const
2b545cdd 108{
cc484ed9 109 // see header file for function documentation
110
111 // BAD: unit test fails if I call TGeoGlobalMagField::Instance()
112 // at this point. Something goes wrong in the cleaning of the global
113 // ROOT onject
114 /*
115 if (TGeoGlobalMagField::Instance()->GetField()) {
116 // everything set, but think about storing the currents for
117 // a cross-check
118 return 0;
2b545cdd 119 }
cc484ed9 120 */
2b545cdd 121
cc484ed9 122 // The magnetic field is initialized once at the start
123 // of run. The fields are supposed to be constant througout the
124 // data taking of one run. The run is aborted if the changes
125 // exceed a certain limit.
126 AliGRPManager grpman;
127 if (grpman.ReadGRPEntry() && grpman.SetMagField()) {
128 return 0;
2b545cdd 129 }
cc484ed9 130
131 return -ENOENT;
2b545cdd 132}
73305a93 133
134AliHLTUInt64_t AliHLTMiscImplementation::GetTriggerMask(AliRawReader* rawReader) const
135{
136 // see header file for function documentation
137 if (!rawReader) return 0;
138 AliHLTUInt64_t trgMask=0;
139 if (rawReader) {
140 const UInt_t* pattern=rawReader->GetTriggerPattern();
141 trgMask=pattern[1]&0xfffffff; // 28 upper bits of the 50 bit mask
142 trgMask<<=32;
143 trgMask|=pattern[0]; // 32 lower bits of the mask
144 }
145 return trgMask;
146}