]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpCDB.cxx
- Use new AliMpSlatMotifMap::Instance() function to instantiate
[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
130//______________________________________________________________________________
90bcb4c9 131Bool_t AliMpCDB::WriteMpSegmentation(Bool_t readData)
3f862c88 132{
133/// Write mapping segmentation in OCDB
134
90bcb4c9 135 if ( ! readData && ! AliMpSegmentation::Instance() ) return false;
136
3f862c88 137 AliCDBManager* cdbManager = AliCDBManager::Instance();
138 if ( ! cdbManager->GetDefaultStorage() )
139 cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
140
141 AliCDBMetaData* cdbData = new AliCDBMetaData();
142 cdbData->SetResponsible("Dimuon Offline project");
143 cdbData->SetComment("MUON mapping");
144 cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
145 AliCDBId id("MUON/Calib/Mapping", 0, 9999999);
146
90bcb4c9 147 if ( readData ) {
148 AliMpSegmentation::ReadData(false);
149 AliMpDDLStore::ReadData(false);
150 }
151
3f862c88 152 return cdbManager->Put(AliMpSegmentation::Instance(), id, cdbData);
153}
154
155//______________________________________________________________________________
90bcb4c9 156Bool_t AliMpCDB::WriteDDLStore(Bool_t readData)
3f862c88 157{
158/// Write mapping DDL store in OCDB
159
90bcb4c9 160 if ( ! readData && ! AliMpDDLStore::Instance() ) return false;
161
3f862c88 162 AliCDBManager* cdbManager = AliCDBManager::Instance();
163 if ( ! cdbManager->GetDefaultStorage() )
164 cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
165
166 AliCDBMetaData* cdbData = new AliCDBMetaData();
167 cdbData->SetResponsible("Dimuon Offline project");
168 cdbData->SetComment("MUON DDL store");
169 cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
170 AliCDBId id("MUON/Calib/DDLStore", 0, 9999999);
171
90bcb4c9 172 if ( readData ) {
173 AliMpSegmentation::ReadData(false);
174 AliMpDDLStore::ReadData(false);
175 }
3f862c88 176 return cdbManager->Put(AliMpDDLStore::Instance(), id, cdbData);
177}