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