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