]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliPreprocessor.cxx
Function GetFromOCDB() added in AliPreprocessor. Getters of OCDB and reference storag...
[u/mrichter/AliRoot.git] / STEER / AliPreprocessor.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 /*
17 $Log$
18 Revision 1.7  2006/11/06 14:24:21  jgrosseo
19 reading of run parameters from the logbook
20 online offline naming conversion
21
22 Revision 1.6  2006/10/02 12:57:48  jgrosseo
23 Small interface change of function StoreReferenceData in Shuttle
24
25 Revision 1.5  2006/09/04 17:42:34  hristov
26 Changes required by Effective C++
27
28 Revision 1.4  2006/08/08 14:20:49  jgrosseo
29 Update to shuttle classes (Alberto)
30
31 - Possibility to set the full object's path in the Preprocessor's and
32 Shuttle's  Store functions
33 - Possibility to extend the object's run validity in the same classes
34 ("startValidity" and "validityInfinite" parameters)
35 - Implementation of the StoreReferenceData function to store reference
36 data in a dedicated CDB storage.
37
38 Revision 1.3  2006/07/11 12:42:43  jgrosseo
39 adding parameters for extended validity range of data produced by preprocessor
40
41 Revision 1.2  2006/06/06 16:36:49  jgrosseo
42 minor changes in AliShuttleInterface and AliPreprocessor
43
44 Revision 1.1  2006/06/02 14:14:36  hristov
45 Separate library for CDB (Jan)
46
47 Revision 1.2  2006/03/07 07:52:34  hristov
48 New version (B.Yordanov)
49
50 Revision 1.3  2005/11/17 17:47:34  byordano
51 TList changed to TObjArray
52
53 Revision 1.2  2005/11/17 14:43:22  byordano
54 import to local CVS
55
56 Revision 1.1.1.1  2005/10/28 07:33:58  hristov
57 Initial import as subdirectory in AliRoot
58
59 Revision 1.1.1.1  2005/09/12 22:11:40  byordano
60 SHUTTLE package
61
62 Revision 1.2  2005/08/29 21:15:47  byordano
63 some docs added
64
65 */
66
67 // Description:
68 // This class is the CDBPreProcessor interface,
69 // supposed to be implemented by any detector
70 // interested in immediate processing of data 
71 // which is retrieved from DCS.
72 // For every particular run set of aliases and
73 // their corespoding value sets are returned.
74 // Usage schema:
75 //      1) virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime) 
76 //      This method is called at the begining of data retrieval.
77 //      run: run number
78 //      startTime: when the run started
79 //      endTime: when the run finished  
80 //
81 //      2) virtual void Process()
82 //
83 //      This method is called and passed a list of retrieved values from DCS
84 //
85 //
86
87
88 #include "AliPreprocessor.h"
89
90 #include <TString.h>
91 #include <TList.h>
92 #include <TMap.h>
93
94 #include "AliLog.h"
95 #include "AliCDBMetaData.h"
96 #include "AliCDBStorage.h"
97 #include "AliCDBId.h"
98 #include "AliCDBPath.h"
99 #include "AliCDBEntry.h"
100 #include "AliShuttleInterface.h"
101
102 ClassImp(AliPreprocessor)
103
104 //______________________________________________________________________________________________
105 AliPreprocessor::AliPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
106   TNamed(detector, ""),
107   fRun(-1),
108   fStartTime(0),
109   fEndTime(0),
110   fShuttle(shuttle)
111 {
112         SetTitle(Form("AliPreprocessor for %s subdetector.", detector));
113
114   if (!fShuttle)
115   {
116     AliFatal("Initialized without Shuttle instance.");
117     return;
118   }
119
120   fShuttle->RegisterPreprocessor(this);
121 }
122
123 //______________________________________________________________________________________________
124 AliPreprocessor::~AliPreprocessor()
125 {
126 }
127
128 //______________________________________________________________________________________________
129 void AliPreprocessor::Initialize(Int_t run, UInt_t startTime,   UInt_t endTime)
130 {
131   // Sets the information of the run which is currently processed
132   // can be overriden for special behaviour, make sure that you call base class
133   // function
134
135   fRun = run;
136   fStartTime = startTime;
137   fEndTime = endTime;
138 }
139
140 //______________________________________________________________________________________________
141 UInt_t AliPreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
142                 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
143 {
144   // Stores a CDB object in the storage for offline reconstruction. Objects that are not needed for
145   // offline reconstruction, but should be stored anyway (e.g. for debugging) should NOT be stored
146   // using this function. Use StoreReferenceData instead!
147   //
148   // This function should be called at the end of the preprocessor cycle
149   //
150   // The parameters are
151   //   1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
152   //         by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
153   //   3) the object to be stored
154   //   4) the metaData to be associated with the object
155   //   5) the validity start run number w.r.t. the current run,
156   //      if the data is valid only for this run leave the default 0
157   //   6) specifies if the calibration data is valid for infinity (this means until updated),
158   //      typical for calibration runs, the default is kFALSE
159   //
160   // The call is delegated to AliShuttleInterface
161
162   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
163   if(!offlineDetName) return 0;
164
165   return fShuttle->Store(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
166                 metaData, validityStart, validityInfinite);
167 }
168
169 //______________________________________________________________________________________________
170 UInt_t AliPreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
171                 AliCDBMetaData* metaData)
172 {
173   // Stores a CDB object in the storage for reference data. This objects will not be available during
174   // offline reconstrunction. Use this function for reference data only!
175   //
176   // This function should be called at the end of the preprocessor cycle
177   //
178   // The parameters are
179   //   1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
180   //         by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
181   //   3) the object to be stored
182   //   4) the metaData to be associated with the object
183   //
184   // The call is delegated to AliShuttleInterface
185
186   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
187   if(!offlineDetName) return 0;
188
189   return fShuttle->StoreReferenceData(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
190                 metaData);
191 }
192
193 //______________________________________________________________________________________________
194 const char* AliPreprocessor::GetFile(Int_t system, const char* id, const char* source)
195 {
196   // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
197   // and from the given source in the system.
198   // The function returnes the path to the local file.
199   //
200   // The call is delegated to AliShuttleInterface
201
202   return fShuttle->GetFile(system, GetName(), id, source);
203 }
204
205 //______________________________________________________________________________________________
206 TList* AliPreprocessor::GetFileSources(Int_t system, const char* id)
207 {
208   // Returns a list of sources in a given system that saved a file with the given id
209   //
210   // The call is delegated to AliShuttleInterface
211
212   return fShuttle->GetFileSources(system, GetName(), id);
213 }
214
215 //______________________________________________________________________________________________
216 void AliPreprocessor::Log(const char* message)
217 {
218   // Adds a log message to the Shuttle log of this preprocessor
219   //
220   // The call is delegated to AliShuttleInterface
221
222   fShuttle->Log(GetName(), message);
223 }
224
225 //______________________________________________________________________________________________
226 const char* AliPreprocessor::GetRunParameter(const char* param)
227 {
228   // Return run parameter read from run logbook
229   //
230   // The call is delegated to AliShuttleInterface
231
232   return fShuttle->GetRunParameter(param);
233 }
234
235 //______________________________________________________________________________________________
236 AliCDBEntry* AliPreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
237 {
238   // Return object from OCDB valid for current run
239   //
240   // The call is delegated to AliShuttleInterface
241
242   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
243   if (!offlineDetName) return 0;
244
245   return dynamic_cast<AliCDBEntry*>
246         (fShuttle->GetFromOCDB(AliCDBPath(offlineDetName, pathLevel2, pathLevel3)));
247 }