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