]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpCDB.cxx
Adding call to LoadMpSegmentation() in LoadDDLStore()
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpCDB.cxx
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
20 //-----------------------------------------------------------------------------
21 // Class AliMpCDB
22 // -----------------------
23 // Manager class for mapping CDB IO
24 // Author: Ivana Hrivnacova, IPN Orsay
25 //-----------------------------------------------------------------------------
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>
38
39 /// \cond CLASSIMP
40 ClassImp(AliMpCDB)
41 /// \endcond
42
43 //
44 // static methods
45 //
46
47 //______________________________________________________________________________
48 Bool_t AliMpCDB::LoadMpSegmentation(Bool_t warn)
49 {
50 /// Load the sementation from the CDB if it does not yet exist;
51 /// return false only in case loading from CDB failed
52
53   AliDebugClass(1,"");
54
55   if ( AliMpSegmentation::Instance(false) ) {
56     if ( warn )  
57       AliWarningClass("Segmentation has been already loaded."); 
58     return true;
59   }  
60   
61   AliCDBManager* cdbManager = AliCDBManager::Instance();
62   if ( ! cdbManager->GetDefaultStorage() )
63     cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
64
65   Int_t run = cdbManager->GetRun();
66   if ( run < 0 ) {
67     run = 0;
68     cdbManager->SetRun(run);
69   }  
70
71   AliCDBEntry* cdbEntry 
72     =  cdbManager->Get("MUON/Calib/Mapping", run);
73   
74   return (AliMpSegmentation*)cdbEntry->GetObject() != 0x0;
75 }    
76
77 //______________________________________________________________________________
78 Bool_t AliMpCDB::LoadDDLStore(Bool_t warn)
79 {
80 /// Load the DDL store from the CDB if it does not yet exist
81 /// return false only in case loading from CDB failed
82
83   AliDebugClass(1,"");
84
85   if ( AliMpDDLStore::Instance(false) ) {
86     if ( warn )  
87       AliWarningClass("DDL Store has been already loaded."); 
88     return true;
89   }  
90   
91   // Load segmentation
92   //
93   LoadMpSegmentation(warn); 
94   
95   // Load DDL store
96   //
97   AliCDBManager* cdbManager = AliCDBManager::Instance();
98   if ( ! cdbManager->GetDefaultStorage() )
99     cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
100
101   Int_t run = cdbManager->GetRun();
102   if ( run < 0 ) {
103     run = 0;
104     cdbManager->SetRun(run);
105   }  
106
107   AliCDBEntry* cdbEntry 
108     =  cdbManager->Get("MUON/Calib/DDLStore", run);
109   
110   return (AliMpDDLStore*)cdbEntry->GetObject() != 0x0;
111 }    
112
113 //______________________________________________________________________________
114 Bool_t AliMpCDB::WriteMpSegmentation()
115 {
116 /// Write mapping segmentation in OCDB
117
118   AliCDBManager* cdbManager = AliCDBManager::Instance();
119   if ( ! cdbManager->GetDefaultStorage() )
120     cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
121   
122   AliCDBMetaData* cdbData = new AliCDBMetaData();
123   cdbData->SetResponsible("Dimuon Offline project");
124   cdbData->SetComment("MUON mapping");
125   cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
126   AliCDBId id("MUON/Calib/Mapping", 0, 9999999); 
127
128   AliMpSegmentation::ReadData(false);
129   return cdbManager->Put(AliMpSegmentation::Instance(), id, cdbData);
130 }
131
132 //______________________________________________________________________________
133 Bool_t AliMpCDB::WriteDDLStore()
134 {
135 /// Write mapping DDL store in OCDB
136
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 DDL store");
144   cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
145   AliCDBId id("MUON/Calib/DDLStore", 0, 9999999); 
146
147   AliMpSegmentation::ReadData(false);
148   AliMpDDLStore::ReadData(false);
149   return cdbManager->Put(AliMpDDLStore::Instance(), id, cdbData);
150 }