Fixed output directory setting in submit mode (Ernesto)
[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"
a5e775ec 31#include "AliTracker.h"
84f84689 32// AliESDEvent.h includes AliESDHLTDecision.h
33// and switches the functionality
34#include "AliESDEvent.h"
35#ifdef ALIESDHLTDECISION_H
95ea76b5 36#include "AliESDHLTDecision.h"
84f84689 37#endif //ALIESDHLTDECISION_H
cc484ed9 38#include "TGeoGlobalMagField.h"
95ea76b5 39#include "AliHLTGlobalTriggerDecision.h"
2b545cdd 40
41/** ROOT macro for the implementation of ROOT specific class methods */
42ClassImp(AliHLTMiscImplementation);
43
44AliHLTMiscImplementation::AliHLTMiscImplementation()
45{
46}
47
48AliHLTMiscImplementation::~AliHLTMiscImplementation()
49{
50 // see header file for function documentation
51}
52
53int AliHLTMiscImplementation::InitCDB(const char* cdbpath)
54{
55 // see header file for function documentation
56 int iResult=0;
57 AliCDBManager* pCDB = AliCDBManager::Instance();
58 AliHLTLogging log;
59 if (!pCDB) {
60 log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance");
61 } else {
62 if (cdbpath && cdbpath[0]!=0) {
cc484ed9 63 TString uri=cdbpath;
64 if (!uri.BeginsWith("local://") &&
65 !uri.Contains("://")) {
66 // assume a local path if no uri specifier is found
67 uri="local://";
68 uri+=cdbpath;
69 }
70 pCDB->SetDefaultStorage(uri);
2b545cdd 71 log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB);
72 } else if (!pCDB->IsDefaultStorageSet()) {
73 const char* cdbUri="local://$ALICE_ROOT/OCDB";
74 pCDB->SetDefaultStorage(cdbUri);
75 pCDB->SetRun(0);
76 log.Logging(kHLTLogInfo, "InitCDB", "CDB handling", "set default URI: %s", cdbUri);
77 }
78 }
79 return iResult;
80}
81
82int AliHLTMiscImplementation::SetCDBRunNo(int runNo)
83{
84 // see header file for function documentation
85 int iResult=0;
86 AliCDBManager* pCDB = AliCDBManager::Instance();
87 AliHLTLogging log;
88 if (!pCDB) {
cc484ed9 89 log.Logging(kHLTLogError, "SetCDBRunNo", "CDB handling", "Could not get CDB instance");
2b545cdd 90 } else {
91 pCDB->SetRun(runNo);
92 }
93 return iResult;
94}
95
96AliCDBEntry* AliHLTMiscImplementation::LoadOCDBEntry(const char* path, int runNo, int version, int subVersion)
97{
98 // see header file for function documentation
22d17395 99 AliCDBStorage* store = AliCDBManager::Instance()->GetDefaultStorage();
100 if (!store) {
101 return NULL;
102 }
103 if (version<0) version = store->GetLatestVersion(path, runNo);
104 if (subVersion<0) subVersion = store->GetLatestSubVersion(path, runNo, version);
2b545cdd 105 return AliCDBManager::Instance()->Get(path, runNo, version, subVersion);
106}
107
108TObject* AliHLTMiscImplementation::ExtractObject(AliCDBEntry* entry)
109{
110 // see header file for function documentation
111 if (!entry) return NULL;
112 return entry->GetObject();
113}
114
cc484ed9 115int AliHLTMiscImplementation::InitMagneticField() const
2b545cdd 116{
cc484ed9 117 // see header file for function documentation
118
119 // BAD: unit test fails if I call TGeoGlobalMagField::Instance()
120 // at this point. Something goes wrong in the cleaning of the global
121 // ROOT onject
122 /*
123 if (TGeoGlobalMagField::Instance()->GetField()) {
124 // everything set, but think about storing the currents for
125 // a cross-check
126 return 0;
2b545cdd 127 }
cc484ed9 128 */
2b545cdd 129
cc484ed9 130 // The magnetic field is initialized once at the start
131 // of run. The fields are supposed to be constant througout the
132 // data taking of one run. The run is aborted if the changes
133 // exceed a certain limit.
134 AliGRPManager grpman;
135 if (grpman.ReadGRPEntry() && grpman.SetMagField()) {
136 return 0;
2b545cdd 137 }
cc484ed9 138
139 return -ENOENT;
2b545cdd 140}
73305a93 141
142AliHLTUInt64_t AliHLTMiscImplementation::GetTriggerMask(AliRawReader* rawReader) const
143{
144 // see header file for function documentation
145 if (!rawReader) return 0;
146 AliHLTUInt64_t trgMask=0;
147 if (rawReader) {
148 const UInt_t* pattern=rawReader->GetTriggerPattern();
149 trgMask=pattern[1]&0xfffffff; // 28 upper bits of the 50 bit mask
150 trgMask<<=32;
151 trgMask|=pattern[0]; // 32 lower bits of the mask
152 }
153 return trgMask;
154}
a5e775ec 155
156Double_t AliHLTMiscImplementation::GetBz()
157{
158 // Returns Bz.
159 return AliTracker::GetBz();
160}
161
162Double_t AliHLTMiscImplementation::GetBz(const Double_t *r)
163{
164 // Returns Bz (kG) at the point "r" .
165 return AliTracker::GetBz(r);
166}
167
168void AliHLTMiscImplementation::GetBxByBz(const Double_t r[3], Double_t b[3])
169{
170 // Returns Bx, By and Bz (kG) at the point "r" .
171 return AliTracker::GetBxByBz(r, b);
172}
95ea76b5 173
174const TClass* AliHLTMiscImplementation::IsAliESDHLTDecision() const
175{
176 // Return the IsA of the AliESDHLTDecision class
84f84689 177#ifdef ALIESDHLTDECISION_H
95ea76b5 178 return AliESDHLTDecision::Class();
84f84689 179#else // ALIESDHLTDECISION_H
95ea76b5 180 return NULL;
84f84689 181#endif // ALIESDHLTDECISION_H
95ea76b5 182}
183
184int AliHLTMiscImplementation::Copy(const AliHLTGlobalTriggerDecision* pDecision, TObject* object) const
185{
186 // Copy HLT global trigger decision to AliESDHLTDecision container
187 if (!pDecision || !object) return -EINVAL;
84f84689 188#ifdef ALIESDHLTDECISION_H
95ea76b5 189 AliESDHLTDecision* pESDHLTDecision=NULL;
190 if (object->IsA()==NULL ||
191 object->IsA() != AliESDHLTDecision::Class() ||
192 (pESDHLTDecision=dynamic_cast<AliESDHLTDecision*>(object))==NULL) {
193// HLTError("can not copy HLT global decision to object of class \"%s\"",
194// object->IsA()?object->IsA()->GetName():"NULL");
195 return -EINVAL;
196 }
197
198 pESDHLTDecision->~AliESDHLTDecision();
84f84689 199 new (pESDHLTDecision) AliESDHLTDecision(pDecision->Result(), pDecision->GetTitle());
95ea76b5 200
84f84689 201#endif // ALIESDHLTDECISION_H
95ea76b5 202 return 0;
203}