]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpCDB.cxx
Adding functions LoadMpSegmentation2(), LoadDDLStore2()
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpCDB.cxx
CommitLineData
3f862c88 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16// $Id$
17// $MpId: $
18// Category: management
19
3d1463c8 20//-----------------------------------------------------------------------------
3f862c88 21// Class AliMpCDB
22// -----------------------
23// Manager class for mapping CDB IO
24// Author: Ivana Hrivnacova, IPN Orsay
3d1463c8 25//-----------------------------------------------------------------------------
3f862c88 26
27#include "AliMpCDB.h"
28
29#include "AliMpSegmentation.h"
30#include "AliMpDDLStore.h"
31
32#include "AliLog.h"
33#include "AliCDBManager.h"
34#include "AliCDBEntry.h"
35
36#include <TSystem.h>
37#include <TClass.h>
ff5445c2 38#include <Riostream.h>
3f862c88 39
40/// \cond CLASSIMP
41ClassImp(AliMpCDB)
42/// \endcond
43
3f862c88 44//
45// static methods
46//
707ad0dc 47
3f862c88 48//______________________________________________________________________________
49Bool_t AliMpCDB::LoadMpSegmentation(Bool_t warn)
50{
51/// Load the sementation from the CDB if it does not yet exist;
52/// return false only in case loading from CDB failed
53
54 AliDebugClass(1,"");
55
56 if ( AliMpSegmentation::Instance(false) ) {
57 if ( warn )
58 AliWarningClass("Segmentation has been already loaded.");
59 return true;
60 }
61
62 AliCDBManager* cdbManager = AliCDBManager::Instance();
ff5445c2 63 if ( ! cdbManager->GetDefaultStorage() ) {
64 AliErrorClassStream() << "CDB default storage has not been set." << endl;
65 return kFALSE;
66 }
3f862c88 67
68 Int_t run = cdbManager->GetRun();
69 if ( run < 0 ) {
0be76c28 70 AliErrorClassStream() << "Cannot get run number from CDB manager." << endl;
71 return kFALSE;
3f862c88 72 }
73
5699c0e6 74 AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/Mapping", run);
3f862c88 75
5699c0e6 76 if ( cdbEntry )
77 {
78 return (AliMpSegmentation*)cdbEntry->GetObject() != 0x0;
79 }
80 else
81 {
82 return kFALSE;
83 }
3f862c88 84}
85
86//______________________________________________________________________________
87Bool_t AliMpCDB::LoadDDLStore(Bool_t warn)
88{
89/// Load the DDL store from the CDB if it does not yet exist
90/// return false only in case loading from CDB failed
91
92 AliDebugClass(1,"");
93
94 if ( AliMpDDLStore::Instance(false) ) {
95 if ( warn )
96 AliWarningClass("DDL Store has been already loaded.");
97 return true;
98 }
99
707ad0dc 100 // Load segmentation
101 //
102 LoadMpSegmentation(warn);
103
104 // Load DDL store
105 //
3f862c88 106 AliCDBManager* cdbManager = AliCDBManager::Instance();
0be76c28 107 if ( ! cdbManager->GetDefaultStorage() ) {
108 AliErrorClassStream() << "CDB default storage has not been set." << endl;
109 return kFALSE;
110 }
3f862c88 111
112 Int_t run = cdbManager->GetRun();
113 if ( run < 0 ) {
0be76c28 114 AliErrorClassStream() << "Cannot get run number from CDB manager." << endl;
115 return kFALSE;
3f862c88 116 }
117
5699c0e6 118 AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/DDLStore", run);
3f862c88 119
5699c0e6 120 if ( cdbEntry )
121 {
122 return (AliMpDDLStore*)cdbEntry->GetObject() != 0x0;
123 }
124 else
125 {
126 return kFALSE;
127 }
3f862c88 128}
129
d3af4674 130//______________________________________________________________________________
131Bool_t AliMpCDB::LoadMpSegmentation2(const char* cdbpath, Int_t runNumber,
132 Bool_t warn)
133{
134/// Load the sementation from the CDB if it does not yet exist;
135/// return false only in case loading from CDB failed.
136/// In difference from LoadMpSegmentation(), in this method the CDB path
137/// and run is set directly via arguments.
138
139
140 AliDebugClass(1,"");
141
142 if ( AliMpSegmentation::Instance(false) ) {
143 if ( warn )
144 AliWarningClass("Segmentation has been already loaded.");
145 return true;
146 }
147
148 AliCDBManager* cdbManager = AliCDBManager::Instance();
149 cdbManager->SetDefaultStorage(cdbpath);
150
151 AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/Mapping", runNumber);
152
153 if ( cdbEntry )
154 {
155 return (AliMpSegmentation*)cdbEntry->GetObject() != 0x0;
156 }
157 else
158 {
159 return kFALSE;
160 }
161}
162
163//______________________________________________________________________________
164Bool_t AliMpCDB::LoadDDLStore2(const char* cdbpath, Int_t runNumber,
165 Bool_t warn)
166{
167/// Load the DDL store from the CDB if it does not yet exist
168/// return false only in case loading from CDB failed
169/// In difference from LoadDDLStore(), in this method the CDB path
170/// and run is set directly via arguments.
171
172 AliDebugClass(1,"");
173
174 if ( AliMpDDLStore::Instance(false) ) {
175 if ( warn )
176 AliWarningClass("DDL Store has been already loaded.");
177 return true;
178 }
179
180 // Load segmentation
181 //
182 LoadMpSegmentation2(cdbpath, runNumber, warn);
183
184 // Load DDL store
185 //
186 AliCDBManager* cdbManager = AliCDBManager::Instance();
187 cdbManager->SetDefaultStorage(cdbpath);
188
189 AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/DDLStore", runNumber);
190
191 if ( cdbEntry )
192 {
193 return (AliMpDDLStore*)cdbEntry->GetObject() != 0x0;
194 }
195 else
196 {
197 return kFALSE;
198 }
199}
200
3f862c88 201//______________________________________________________________________________
90bcb4c9 202Bool_t AliMpCDB::WriteMpSegmentation(Bool_t readData)
3f862c88 203{
204/// Write mapping segmentation in OCDB
205
90bcb4c9 206 if ( ! readData && ! AliMpSegmentation::Instance() ) return false;
207
3f862c88 208 AliCDBManager* cdbManager = AliCDBManager::Instance();
209 if ( ! cdbManager->GetDefaultStorage() )
210 cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
211
212 AliCDBMetaData* cdbData = new AliCDBMetaData();
213 cdbData->SetResponsible("Dimuon Offline project");
214 cdbData->SetComment("MUON mapping");
215 cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
216 AliCDBId id("MUON/Calib/Mapping", 0, 9999999);
217
90bcb4c9 218 if ( readData ) {
219 AliMpSegmentation::ReadData(false);
220 AliMpDDLStore::ReadData(false);
221 }
222
3f862c88 223 return cdbManager->Put(AliMpSegmentation::Instance(), id, cdbData);
224}
225
226//______________________________________________________________________________
90bcb4c9 227Bool_t AliMpCDB::WriteDDLStore(Bool_t readData)
3f862c88 228{
229/// Write mapping DDL store in OCDB
230
90bcb4c9 231 if ( ! readData && ! AliMpDDLStore::Instance() ) return false;
232
3f862c88 233 AliCDBManager* cdbManager = AliCDBManager::Instance();
234 if ( ! cdbManager->GetDefaultStorage() )
235 cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
236
237 AliCDBMetaData* cdbData = new AliCDBMetaData();
238 cdbData->SetResponsible("Dimuon Offline project");
239 cdbData->SetComment("MUON DDL store");
240 cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
241 AliCDBId id("MUON/Calib/DDLStore", 0, 9999999);
242
90bcb4c9 243 if ( readData ) {
244 AliMpSegmentation::ReadData(false);
245 AliMpDDLStore::ReadData(false);
246 }
3f862c88 247 return cdbManager->Put(AliMpDDLStore::Instance(), id, cdbData);
248}