1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // Category: management
20 //-----------------------------------------------------------------------------
22 // -----------------------
23 // Manager class for mapping CDB IO
24 // Author: Ivana Hrivnacova, IPN Orsay
25 //-----------------------------------------------------------------------------
29 #include "AliMpSegmentation.h"
30 #include "AliMpDDLStore.h"
33 #include "AliCDBManager.h"
34 #include "AliCDBEntry.h"
38 #include <Riostream.h>
48 //______________________________________________________________________________
49 Bool_t AliMpCDB::LoadMpSegmentation(Bool_t warn)
51 /// Load the sementation from the CDB if it does not yet exist;
52 /// return false only in case loading from CDB failed
56 if ( AliMpSegmentation::Instance(false) ) {
58 AliWarningClass("Segmentation has been already loaded.");
62 AliCDBManager* cdbManager = AliCDBManager::Instance();
63 if ( ! cdbManager->GetDefaultStorage() ) {
64 AliErrorClassStream() << "CDB default storage has not been set." << endl;
68 Int_t run = cdbManager->GetRun();
70 AliErrorClassStream() << "Cannot get run number from CDB manager." << endl;
74 AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/Mapping", run);
78 return (AliMpSegmentation*)cdbEntry->GetObject() != 0x0;
86 //______________________________________________________________________________
87 Bool_t AliMpCDB::LoadDDLStore(Bool_t warn)
89 /// Load the DDL store from the CDB if it does not yet exist
90 /// return false only in case loading from CDB failed
94 if ( AliMpDDLStore::Instance(false) ) {
96 AliWarningClass("DDL Store has been already loaded.");
102 LoadMpSegmentation(warn);
106 AliCDBManager* cdbManager = AliCDBManager::Instance();
107 if ( ! cdbManager->GetDefaultStorage() ) {
108 AliErrorClassStream() << "CDB default storage has not been set." << endl;
112 Int_t run = cdbManager->GetRun();
114 AliErrorClassStream() << "Cannot get run number from CDB manager." << endl;
118 AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/DDLStore", run);
122 return (AliMpDDLStore*)cdbEntry->GetObject() != 0x0;
130 //______________________________________________________________________________
131 Bool_t AliMpCDB::LoadMpSegmentation2(const char* cdbpath, Int_t runNumber,
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.
142 if ( AliMpSegmentation::Instance(false) ) {
144 AliWarningClass("Segmentation has been already loaded.");
148 AliCDBManager* cdbManager = AliCDBManager::Instance();
149 cdbManager->SetDefaultStorage(cdbpath);
151 AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/Mapping", runNumber);
155 return (AliMpSegmentation*)cdbEntry->GetObject() != 0x0;
163 //______________________________________________________________________________
164 Bool_t AliMpCDB::LoadDDLStore2(const char* cdbpath, Int_t runNumber,
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.
174 if ( AliMpDDLStore::Instance(false) ) {
176 AliWarningClass("DDL Store has been already loaded.");
182 LoadMpSegmentation2(cdbpath, runNumber, warn);
186 AliCDBManager* cdbManager = AliCDBManager::Instance();
187 cdbManager->SetDefaultStorage(cdbpath);
189 AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/DDLStore", runNumber);
193 return (AliMpDDLStore*)cdbEntry->GetObject() != 0x0;
201 //______________________________________________________________________________
202 Bool_t AliMpCDB::WriteMpSegmentation(Bool_t readData)
204 /// Write mapping segmentation in OCDB
206 if ( ! readData && ! AliMpSegmentation::Instance() ) return false;
208 AliCDBManager* cdbManager = AliCDBManager::Instance();
209 if ( ! cdbManager->GetDefaultStorage() )
210 cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
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, AliCDBRunRange::Infinity());
219 AliMpSegmentation::ReadData(false);
220 AliMpDDLStore::ReadData(false);
223 return cdbManager->Put(AliMpSegmentation::Instance(), id, cdbData);
226 //______________________________________________________________________________
227 Bool_t AliMpCDB::WriteDDLStore(Bool_t readData)
229 /// Write mapping DDL store in OCDB
231 if ( ! readData && ! AliMpDDLStore::Instance() ) return false;
233 AliCDBManager* cdbManager = AliCDBManager::Instance();
234 if ( ! cdbManager->GetDefaultStorage() )
235 cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
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, AliCDBRunRange::Infinity());
244 AliMpSegmentation::ReadData(false);
245 AliMpDDLStore::ReadData(false);
247 return cdbManager->Put(AliMpDDLStore::Instance(), id, cdbData);